From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- third_party/WinToast/LICENSE | 21 - .../WinToast/moz-check-system-shortcut.patch | 81 - .../WinToast/moz-disable-create-shortcut.patch | 110 - third_party/WinToast/moz.yaml | 37 - .../WinToast/upstream-add-toast-scenario.patch | 123 - third_party/WinToast/wintoastlib.cpp | 1197 - third_party/WinToast/wintoastlib.h | 234 - third_party/aom/AUTHORS | 1 + third_party/aom/CHANGELOG | 36 + third_party/aom/CMakeLists.txt | 2 +- third_party/aom/aom/src/aom_codec.c | 1 + third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl | 21 +- third_party/aom/aom_dsp/arm/highbd_variance_sve.c | 9 - third_party/aom/aom_dsp/arm/intrapred_neon.c | 1 + .../aom/aom_dsp/flow_estimation/arm/disflow_neon.c | 2 +- .../aom/aom_dsp/flow_estimation/corner_match.c | 2 +- third_party/aom/aom_dsp/flow_estimation/disflow.c | 4 +- .../aom/aom_dsp/flow_estimation/x86/disflow_sse4.c | 2 +- third_party/aom/av1/av1.cmake | 1 + .../aom/av1/common/arm/highbd_warp_plane_sve.c | 293 + third_party/aom/av1/common/av1_rtcd_defs.pl | 2 +- third_party/aom/av1/common/reconintra.c | 193 +- third_party/aom/av1/encoder/encoder.c | 13 +- third_party/aom/av1/encoder/encoder.h | 4 +- third_party/aom/av1/encoder/mcomp.c | 1 - third_party/aom/av1/encoder/speed_features.c | 8 + third_party/aom/common/tools_common.c | 20 +- third_party/aom/test/av1_c_vs_simd_encode.sh | 38 +- third_party/aom/test/dr_prediction_test.cc | 68 +- third_party/aom/test/encode_api_test.cc | 48 +- third_party/aom/test/resize_test.cc | 69 +- third_party/aom/test/variance_test.cc | 6 +- third_party/aom/test/warp_filter_test.cc | 6 + third_party/dav1d/NEWS | 14 + third_party/dav1d/meson.build | 4 +- third_party/dav1d/src/arm/64/itx.S | 7 +- third_party/dav1d/src/decode.c | 42 +- third_party/dav1d/src/picture.c | 44 +- third_party/dav1d/src/riscv/64/itx.S | 803 +- third_party/dav1d/src/riscv/itx.h | 6 +- third_party/dav1d/src/x86/ipred.h | 1 + third_party/dav1d/src/x86/ipred16_avx512.asm | 610 + third_party/dav1d/tests/dav1d_argon.bash | 16 +- third_party/function2/Readme.md | 14 +- .../function2/include/function2/function2.hpp | 8 + third_party/function2/moz.yaml | 4 +- third_party/gemmology/gemmology.h | 95 +- .../kernels/GemmologyEngineNeon64I8mm.cpp | 19 + third_party/gemmology/moz.yaml | 4 +- third_party/jpeg-xl/.clang-tidy | 33 +- third_party/jpeg-xl/AUTHORS | 3 +- third_party/jpeg-xl/CHANGELOG.md | 38 + third_party/jpeg-xl/CMakeLists.txt | 4 +- third_party/jpeg-xl/MODULE.bazel | 5 +- third_party/jpeg-xl/README.md | 9 +- third_party/jpeg-xl/WORKSPACE | 182 - third_party/jpeg-xl/bash_test.sh | 6 - third_party/jpeg-xl/ci.sh | 75 +- third_party/jpeg-xl/debian/control | 1 - third_party/jpeg-xl/deps.sh | 2 +- third_party/jpeg-xl/examples/CMakeLists.txt | 10 +- .../jpeg-xl/examples/decode_exif_metadata.cc | 6 +- third_party/jpeg-xl/examples/decode_oneshot.cc | 20 +- third_party/jpeg-xl/examples/decode_progressive.cc | 12 +- third_party/jpeg-xl/examples/encode_oneshot.cc | 22 +- third_party/jpeg-xl/flake.nix | 1 - third_party/jpeg-xl/lib/BUILD | 11 +- third_party/jpeg-xl/lib/CMakeLists.txt | 10 + third_party/jpeg-xl/lib/extras/alpha_blend.cc | 7 +- third_party/jpeg-xl/lib/extras/alpha_blend.h | 2 +- third_party/jpeg-xl/lib/extras/codec.h | 2 +- third_party/jpeg-xl/lib/extras/codec_test.cc | 36 +- third_party/jpeg-xl/lib/extras/dec/apng.cc | 119 +- .../jpeg-xl/lib/extras/dec/color_description.cc | 99 +- third_party/jpeg-xl/lib/extras/dec/color_hints.cc | 9 +- third_party/jpeg-xl/lib/extras/dec/decode.cc | 6 +- third_party/jpeg-xl/lib/extras/dec/decode.h | 2 +- third_party/jpeg-xl/lib/extras/dec/exr.cc | 9 +- third_party/jpeg-xl/lib/extras/dec/gif.cc | 28 +- third_party/jpeg-xl/lib/extras/dec/jpegli.cc | 21 +- third_party/jpeg-xl/lib/extras/dec/jpg.cc | 30 +- third_party/jpeg-xl/lib/extras/dec/jxl.cc | 90 +- third_party/jpeg-xl/lib/extras/dec/jxl.h | 4 - third_party/jpeg-xl/lib/extras/dec/pgx.cc | 11 +- third_party/jpeg-xl/lib/extras/dec/pnm.cc | 31 +- third_party/jpeg-xl/lib/extras/enc/apng.cc | 29 +- third_party/jpeg-xl/lib/extras/enc/encode.cc | 2 +- third_party/jpeg-xl/lib/extras/enc/encode.h | 2 +- third_party/jpeg-xl/lib/extras/enc/exr.cc | 4 +- third_party/jpeg-xl/lib/extras/enc/jpegli.cc | 82 +- third_party/jpeg-xl/lib/extras/enc/jpg.cc | 81 +- third_party/jpeg-xl/lib/extras/enc/jxl.cc | 45 +- third_party/jpeg-xl/lib/extras/enc/jxl.h | 8 +- third_party/jpeg-xl/lib/extras/enc/npy.cc | 35 +- third_party/jpeg-xl/lib/extras/enc/pgx.cc | 4 +- third_party/jpeg-xl/lib/extras/enc/pnm.cc | 2 +- third_party/jpeg-xl/lib/extras/jpegli_test.cc | 18 +- third_party/jpeg-xl/lib/extras/mmap.cc | 7 +- third_party/jpeg-xl/lib/extras/packed_image.h | 55 +- .../jpeg-xl/lib/extras/packed_image_convert.cc | 51 +- third_party/jpeg-xl/lib/extras/tone_mapping.cc | 2 +- .../jpeg-xl/lib/extras/tone_mapping_gbench.cc | 6 +- .../jpeg-xl/lib/include/jxl/cms_interface.h | 27 +- .../jpeg-xl/lib/include/jxl/codestream_header.h | 35 +- .../jpeg-xl/lib/include/jxl/color_encoding.h | 39 +- third_party/jpeg-xl/lib/include/jxl/decode.h | 411 +- third_party/jpeg-xl/lib/include/jxl/encode.h | 403 +- .../jpeg-xl/lib/include/jxl/parallel_runner.h | 35 +- .../lib/include/jxl/resizable_parallel_runner.h | 10 +- third_party/jpeg-xl/lib/include/jxl/stats.h | 8 +- .../lib/include/jxl/thread_parallel_runner.h | 8 +- third_party/jpeg-xl/lib/include/jxl/types.h | 10 +- third_party/jpeg-xl/lib/jpegli.cmake | 1 - .../jpeg-xl/lib/jpegli/adaptive_quantization.cc | 19 +- third_party/jpeg-xl/lib/jpegli/bitstream.cc | 7 +- third_party/jpeg-xl/lib/jpegli/bitstream.h | 5 +- third_party/jpeg-xl/lib/jpegli/color_quantize.cc | 40 +- third_party/jpeg-xl/lib/jpegli/color_quantize.h | 2 +- third_party/jpeg-xl/lib/jpegli/dct-inl.h | 10 +- third_party/jpeg-xl/lib/jpegli/decode.cc | 39 +- third_party/jpeg-xl/lib/jpegli/decode_api_test.cc | 35 +- third_party/jpeg-xl/lib/jpegli/decode_internal.h | 17 +- third_party/jpeg-xl/lib/jpegli/decode_marker.cc | 63 +- third_party/jpeg-xl/lib/jpegli/decode_marker.h | 4 +- third_party/jpeg-xl/lib/jpegli/decode_scan.cc | 9 +- third_party/jpeg-xl/lib/jpegli/decode_scan.h | 4 +- .../jpeg-xl/lib/jpegli/destination_manager.cc | 16 +- third_party/jpeg-xl/lib/jpegli/downsample.cc | 8 +- third_party/jpeg-xl/lib/jpegli/encode.cc | 33 +- third_party/jpeg-xl/lib/jpegli/encode_api_test.cc | 24 +- third_party/jpeg-xl/lib/jpegli/encode_finish.cc | 2 + third_party/jpeg-xl/lib/jpegli/entropy_coding.cc | 58 +- third_party/jpeg-xl/lib/jpegli/error.h | 5 +- .../jpeg-xl/lib/jpegli/error_handling_test.cc | 21 +- third_party/jpeg-xl/lib/jpegli/huffman.cc | 5 +- third_party/jpeg-xl/lib/jpegli/idct.cc | 5 +- third_party/jpeg-xl/lib/jpegli/input.cc | 18 +- .../jpeg-xl/lib/jpegli/input_suspension_test.cc | 30 +- .../jpeg-xl/lib/jpegli/libjpeg_test_util.cc | 15 +- third_party/jpeg-xl/lib/jpegli/libjpeg_wrapper.cc | 4 +- third_party/jpeg-xl/lib/jpegli/memory_manager.h | 3 +- .../jpeg-xl/lib/jpegli/output_suspension_test.cc | 12 +- third_party/jpeg-xl/lib/jpegli/quant.cc | 18 +- third_party/jpeg-xl/lib/jpegli/render.cc | 31 +- third_party/jpeg-xl/lib/jpegli/source_manager.cc | 4 +- .../jpeg-xl/lib/jpegli/source_manager_test.cc | 4 +- third_party/jpeg-xl/lib/jpegli/streaming_test.cc | 18 +- third_party/jpeg-xl/lib/jpegli/test_utils-inl.h | 40 +- third_party/jpeg-xl/lib/jpegli/test_utils.cc | 81 +- third_party/jpeg-xl/lib/jpegli/testing.h | 20 +- third_party/jpeg-xl/lib/jpegli/transpose-inl.h | 8 +- third_party/jpeg-xl/lib/jpegli/upsample.cc | 6 +- third_party/jpeg-xl/lib/jxl.cmake | 4 +- third_party/jpeg-xl/lib/jxl/ac_strategy.cc | 13 +- third_party/jpeg-xl/lib/jxl/ac_strategy.h | 13 +- third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc | 9 +- third_party/jpeg-xl/lib/jxl/alpha_test.cc | 111 +- third_party/jpeg-xl/lib/jxl/ans_common.h | 3 +- third_party/jpeg-xl/lib/jxl/ans_test.cc | 17 +- third_party/jpeg-xl/lib/jxl/base/bits.h | 3 +- third_party/jpeg-xl/lib/jxl/base/byte_order.h | 8 +- third_party/jpeg-xl/lib/jxl/base/common.h | 44 +- third_party/jpeg-xl/lib/jxl/base/exif.h | 1 - third_party/jpeg-xl/lib/jxl/base/float.h | 10 +- third_party/jpeg-xl/lib/jxl/base/matrix_ops.h | 78 +- third_party/jpeg-xl/lib/jxl/base/override.h | 4 +- .../jpeg-xl/lib/jxl/base/rational_polynomial-inl.h | 3 +- third_party/jpeg-xl/lib/jxl/base/scope_guard.h | 6 +- third_party/jpeg-xl/lib/jxl/base/span.h | 4 +- third_party/jpeg-xl/lib/jxl/base/status.h | 15 +- third_party/jpeg-xl/lib/jxl/bits_test.cc | 6 +- third_party/jpeg-xl/lib/jxl/blending.cc | 14 +- third_party/jpeg-xl/lib/jxl/blending.h | 10 +- third_party/jpeg-xl/lib/jxl/blending_test.cc | 8 +- third_party/jpeg-xl/lib/jxl/box_content_decoder.cc | 2 +- .../jpeg-xl/lib/jxl/butteraugli/butteraugli.cc | 340 +- .../jpeg-xl/lib/jxl/butteraugli/butteraugli.h | 45 +- .../lib/jxl/butteraugli/butteraugli_test.cc | 6 +- third_party/jpeg-xl/lib/jxl/cache_aligned.cc | 3 +- third_party/jpeg-xl/lib/jxl/cache_aligned.h | 2 +- third_party/jpeg-xl/lib/jxl/chroma_from_luma.cc | 22 +- third_party/jpeg-xl/lib/jxl/chroma_from_luma.h | 11 +- .../jpeg-xl/lib/jxl/cms/color_encoding_cms.h | 4 +- third_party/jpeg-xl/lib/jxl/cms/jxl_cms.cc | 95 +- third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h | 179 +- third_party/jpeg-xl/lib/jxl/cms/opsin_params.h | 27 +- third_party/jpeg-xl/lib/jxl/cms/tone_mapping-inl.h | 6 +- third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h | 52 +- .../jpeg-xl/lib/jxl/cms/tone_mapping_test.cc | 30 +- third_party/jpeg-xl/lib/jxl/coeff_order.h | 25 +- .../jpeg-xl/lib/jxl/color_encoding_internal.cc | 4 +- .../jpeg-xl/lib/jxl/color_encoding_internal.h | 8 +- .../lib/jxl/color_encoding_internal_test.cc | 23 +- .../jpeg-xl/lib/jxl/color_management_test.cc | 226 +- third_party/jpeg-xl/lib/jxl/common.h | 32 + third_party/jpeg-xl/lib/jxl/compressed_dc.cc | 40 +- third_party/jpeg-xl/lib/jxl/compressed_dc.h | 6 +- third_party/jpeg-xl/lib/jxl/convolve-inl.h | 20 +- third_party/jpeg-xl/lib/jxl/convolve_separable5.cc | 10 +- third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc | 11 +- third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc | 5 +- third_party/jpeg-xl/lib/jxl/convolve_test.cc | 33 +- third_party/jpeg-xl/lib/jxl/dct-inl.h | 8 +- third_party/jpeg-xl/lib/jxl/dct_block-inl.h | 4 +- third_party/jpeg-xl/lib/jxl/dct_util.h | 13 +- third_party/jpeg-xl/lib/jxl/dec_ans.cc | 14 +- third_party/jpeg-xl/lib/jxl/dec_ans.h | 13 +- third_party/jpeg-xl/lib/jxl/dec_cache.cc | 5 +- third_party/jpeg-xl/lib/jxl/dec_cache.h | 27 +- third_party/jpeg-xl/lib/jxl/dec_context_map.cc | 9 +- third_party/jpeg-xl/lib/jxl/dec_external_image.cc | 42 +- .../jpeg-xl/lib/jxl/dec_external_image_gbench.cc | 5 +- third_party/jpeg-xl/lib/jxl/dec_frame.cc | 74 +- third_party/jpeg-xl/lib/jxl/dec_frame.h | 18 +- third_party/jpeg-xl/lib/jxl/dec_group.cc | 39 +- third_party/jpeg-xl/lib/jxl/dec_huffman.cc | 35 +- third_party/jpeg-xl/lib/jxl/dec_modular.cc | 64 +- third_party/jpeg-xl/lib/jxl/dec_modular.h | 2 +- third_party/jpeg-xl/lib/jxl/dec_noise.cc | 5 +- .../jpeg-xl/lib/jxl/dec_patch_dictionary.cc | 45 +- third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h | 5 +- .../jpeg-xl/lib/jxl/dec_transforms_testonly.cc | 10 +- .../jpeg-xl/lib/jxl/dec_transforms_testonly.h | 4 +- third_party/jpeg-xl/lib/jxl/dec_xyb-inl.h | 8 +- third_party/jpeg-xl/lib/jxl/dec_xyb.cc | 43 +- third_party/jpeg-xl/lib/jxl/dec_xyb.h | 4 +- third_party/jpeg-xl/lib/jxl/decode.cc | 144 +- third_party/jpeg-xl/lib/jxl/decode_test.cc | 434 +- third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc | 65 +- third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h | 16 +- .../jpeg-xl/lib/jxl/enc_adaptive_quantization.cc | 227 +- .../jpeg-xl/lib/jxl/enc_adaptive_quantization.h | 19 +- third_party/jpeg-xl/lib/jxl/enc_ans.cc | 172 +- third_party/jpeg-xl/lib/jxl/enc_ans.h | 2 +- third_party/jpeg-xl/lib/jxl/enc_ans_params.h | 11 +- .../jpeg-xl/lib/jxl/enc_ar_control_field.cc | 30 +- third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h | 24 +- third_party/jpeg-xl/lib/jxl/enc_aux_out.cc | 20 +- third_party/jpeg-xl/lib/jxl/enc_bit_writer.cc | 8 +- .../jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc | 42 +- .../jpeg-xl/lib/jxl/enc_butteraugli_comparator.h | 16 - third_party/jpeg-xl/lib/jxl/enc_cache.cc | 56 +- third_party/jpeg-xl/lib/jxl/enc_cache.h | 2 +- .../jpeg-xl/lib/jxl/enc_chroma_from_luma.cc | 21 +- third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h | 2 +- third_party/jpeg-xl/lib/jxl/enc_cluster.cc | 19 +- third_party/jpeg-xl/lib/jxl/enc_cluster.h | 6 +- third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc | 13 +- third_party/jpeg-xl/lib/jxl/enc_comparator.cc | 27 +- third_party/jpeg-xl/lib/jxl/enc_comparator.h | 8 +- third_party/jpeg-xl/lib/jxl/enc_context_map.cc | 28 +- third_party/jpeg-xl/lib/jxl/enc_debug_image.cc | 78 +- third_party/jpeg-xl/lib/jxl/enc_debug_image.h | 20 +- third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc | 154 +- third_party/jpeg-xl/lib/jxl/enc_detect_dots.h | 5 +- third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc | 19 +- third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h | 10 +- third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc | 20 +- third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h | 2 +- third_party/jpeg-xl/lib/jxl/enc_external_image.cc | 17 +- third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc | 59 +- third_party/jpeg-xl/lib/jxl/enc_fields.cc | 6 +- third_party/jpeg-xl/lib/jxl/enc_frame.cc | 308 +- third_party/jpeg-xl/lib/jxl/enc_frame.h | 2 +- third_party/jpeg-xl/lib/jxl/enc_gaborish.cc | 9 +- third_party/jpeg-xl/lib/jxl/enc_gaborish.h | 5 +- third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc | 14 +- third_party/jpeg-xl/lib/jxl/enc_group.cc | 16 +- third_party/jpeg-xl/lib/jxl/enc_heuristics.cc | 188 +- third_party/jpeg-xl/lib/jxl/enc_heuristics.h | 4 +- third_party/jpeg-xl/lib/jxl/enc_huffman.cc | 4 + third_party/jpeg-xl/lib/jxl/enc_huffman_tree.cc | 5 +- third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc | 26 +- third_party/jpeg-xl/lib/jxl/enc_icc_codec.h | 4 - third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc | 25 +- third_party/jpeg-xl/lib/jxl/enc_linalg.cc | 37 +- third_party/jpeg-xl/lib/jxl/enc_linalg.h | 10 +- third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc | 106 +- third_party/jpeg-xl/lib/jxl/enc_modular.cc | 631 +- third_party/jpeg-xl/lib/jxl/enc_modular.h | 67 +- third_party/jpeg-xl/lib/jxl/enc_noise.cc | 4 +- third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc | 2 +- third_party/jpeg-xl/lib/jxl/enc_params.h | 39 +- .../jpeg-xl/lib/jxl/enc_patch_dictionary.cc | 106 +- third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h | 19 +- .../jpeg-xl/lib/jxl/enc_photon_noise_test.cc | 47 +- third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc | 29 +- third_party/jpeg-xl/lib/jxl/enc_quant_weights.h | 6 +- third_party/jpeg-xl/lib/jxl/enc_splines.cc | 4 +- third_party/jpeg-xl/lib/jxl/enc_transforms.cc | 9 +- third_party/jpeg-xl/lib/jxl/enc_transforms.h | 3 +- third_party/jpeg-xl/lib/jxl/enc_xyb.cc | 43 +- third_party/jpeg-xl/lib/jxl/enc_xyb.h | 5 +- third_party/jpeg-xl/lib/jxl/encode.cc | 123 +- third_party/jpeg-xl/lib/jxl/encode_internal.h | 19 +- third_party/jpeg-xl/lib/jxl/encode_test.cc | 186 +- third_party/jpeg-xl/lib/jxl/entropy_coder.cc | 2 +- third_party/jpeg-xl/lib/jxl/fast_dct-inl.h | 2 +- third_party/jpeg-xl/lib/jxl/fast_dct.cc | 37 - third_party/jpeg-xl/lib/jxl/fast_dct.h | 9 - third_party/jpeg-xl/lib/jxl/fast_dct_test.cc | 9 +- third_party/jpeg-xl/lib/jxl/fast_math_test.cc | 8 +- third_party/jpeg-xl/lib/jxl/fields.cc | 9 +- third_party/jpeg-xl/lib/jxl/fields.h | 2 +- third_party/jpeg-xl/lib/jxl/fields_test.cc | 25 +- third_party/jpeg-xl/lib/jxl/frame_header.cc | 14 +- third_party/jpeg-xl/lib/jxl/frame_header.h | 10 +- third_party/jpeg-xl/lib/jxl/gradient_test.cc | 116 +- third_party/jpeg-xl/lib/jxl/headers.cc | 2 +- third_party/jpeg-xl/lib/jxl/icc_codec.cc | 6 +- third_party/jpeg-xl/lib/jxl/icc_codec.h | 6 - third_party/jpeg-xl/lib/jxl/icc_codec_common.cc | 6 +- third_party/jpeg-xl/lib/jxl/icc_codec_common.h | 2 +- third_party/jpeg-xl/lib/jxl/icc_codec_test.cc | 6 +- third_party/jpeg-xl/lib/jxl/image.cc | 210 +- third_party/jpeg-xl/lib/jxl/image.h | 86 +- third_party/jpeg-xl/lib/jxl/image_bundle.h | 8 +- third_party/jpeg-xl/lib/jxl/image_metadata.cc | 16 +- third_party/jpeg-xl/lib/jxl/image_metadata.h | 2 +- third_party/jpeg-xl/lib/jxl/image_ops.cc | 91 + third_party/jpeg-xl/lib/jxl/image_ops.h | 183 +- third_party/jpeg-xl/lib/jxl/image_ops_test.cc | 54 +- third_party/jpeg-xl/lib/jxl/image_test_utils.h | 42 +- third_party/jpeg-xl/lib/jxl/inverse_mtf-inl.h | 2 +- .../jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc | 54 +- third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc | 24 +- .../jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc | 8 +- .../jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.h | 2 +- third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc | 13 +- third_party/jpeg-xl/lib/jxl/jxl_test.cc | 326 +- third_party/jpeg-xl/lib/jxl/libjxl.pc.in | 4 +- third_party/jpeg-xl/lib/jxl/libjxl_cms.pc.in | 4 +- .../jpeg-xl/lib/jxl/memory_manager_internal.h | 10 +- .../lib/jxl/modular/encoding/context_predict.h | 12 +- .../jpeg-xl/lib/jxl/modular/encoding/dec_ma.cc | 2 + .../lib/jxl/modular/encoding/enc_debug_tree.cc | 2 +- .../lib/jxl/modular/encoding/enc_encoding.cc | 82 +- .../jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc | 15 +- .../jpeg-xl/lib/jxl/modular/encoding/encoding.cc | 12 +- .../jpeg-xl/lib/jxl/modular/modular_image.cc | 35 +- .../jpeg-xl/lib/jxl/modular/modular_image.h | 36 +- third_party/jpeg-xl/lib/jxl/modular/options.h | 8 +- .../lib/jxl/modular/transform/enc_palette.cc | 38 +- .../lib/jxl/modular/transform/enc_squeeze.cc | 49 +- .../jpeg-xl/lib/jxl/modular/transform/palette.cc | 19 +- .../jpeg-xl/lib/jxl/modular/transform/palette.h | 1 + .../jpeg-xl/lib/jxl/modular/transform/squeeze.cc | 19 +- .../jpeg-xl/lib/jxl/modular/transform/squeeze.h | 2 +- .../jpeg-xl/lib/jxl/modular/transform/transform.h | 14 +- third_party/jpeg-xl/lib/jxl/modular_test.cc | 67 +- third_party/jpeg-xl/lib/jxl/noise.h | 7 +- third_party/jpeg-xl/lib/jxl/opsin_image_test.cc | 36 +- third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc | 12 +- third_party/jpeg-xl/lib/jxl/opsin_params.cc | 22 +- third_party/jpeg-xl/lib/jxl/opsin_params.h | 5 +- third_party/jpeg-xl/lib/jxl/padded_bytes.h | 2 +- third_party/jpeg-xl/lib/jxl/passes_state.cc | 30 +- third_party/jpeg-xl/lib/jxl/passes_test.cc | 46 +- .../jpeg-xl/lib/jxl/patch_dictionary_test.cc | 2 +- third_party/jpeg-xl/lib/jxl/preview_test.cc | 4 +- third_party/jpeg-xl/lib/jxl/quant_weights.cc | 25 +- third_party/jpeg-xl/lib/jxl/quant_weights.h | 29 +- third_party/jpeg-xl/lib/jxl/quant_weights_test.cc | 20 +- third_party/jpeg-xl/lib/jxl/quantizer.h | 2 +- third_party/jpeg-xl/lib/jxl/quantizer_test.cc | 11 +- .../jpeg-xl/lib/jxl/rational_polynomial_test.cc | 10 +- .../render_pipeline/low_memory_render_pipeline.cc | 131 +- .../render_pipeline/low_memory_render_pipeline.h | 16 +- .../lib/jxl/render_pipeline/render_pipeline.cc | 19 +- .../lib/jxl/render_pipeline/render_pipeline.h | 14 +- .../jxl/render_pipeline/render_pipeline_stage.h | 14 +- .../jxl/render_pipeline/render_pipeline_test.cc | 28 +- .../jxl/render_pipeline/simple_render_pipeline.cc | 58 +- .../jxl/render_pipeline/simple_render_pipeline.h | 4 +- .../lib/jxl/render_pipeline/stage_blending.cc | 17 +- .../jxl/render_pipeline/stage_chroma_upsampling.cc | 14 +- .../jpeg-xl/lib/jxl/render_pipeline/stage_cms.cc | 23 +- .../jpeg-xl/lib/jxl/render_pipeline/stage_epf.cc | 22 +- .../lib/jxl/render_pipeline/stage_from_linear.cc | 12 +- .../lib/jxl/render_pipeline/stage_gaborish.cc | 9 +- .../jpeg-xl/lib/jxl/render_pipeline/stage_noise.cc | 27 +- .../lib/jxl/render_pipeline/stage_patches.cc | 9 +- .../lib/jxl/render_pipeline/stage_splines.cc | 7 +- .../jpeg-xl/lib/jxl/render_pipeline/stage_spot.cc | 9 +- .../lib/jxl/render_pipeline/stage_to_linear.cc | 12 +- .../lib/jxl/render_pipeline/stage_tone_mapping.cc | 12 +- .../lib/jxl/render_pipeline/stage_upsampling.cc | 7 +- .../jpeg-xl/lib/jxl/render_pipeline/stage_write.cc | 56 +- .../jpeg-xl/lib/jxl/render_pipeline/stage_xyb.cc | 22 +- .../jpeg-xl/lib/jxl/render_pipeline/stage_ycbcr.cc | 7 +- .../render_pipeline/test_render_pipeline_stages.h | 30 +- third_party/jpeg-xl/lib/jxl/roundtrip_test.cc | 98 +- third_party/jpeg-xl/lib/jxl/sanitizers.h | 30 +- third_party/jpeg-xl/lib/jxl/simd_util.cc | 39 + third_party/jpeg-xl/lib/jxl/simd_util.h | 4 + third_party/jpeg-xl/lib/jxl/speed_tier_test.cc | 2 +- third_party/jpeg-xl/lib/jxl/splines.cc | 36 +- third_party/jpeg-xl/lib/jxl/splines.h | 7 +- third_party/jpeg-xl/lib/jxl/splines_gbench.cc | 19 +- third_party/jpeg-xl/lib/jxl/splines_test.cc | 256 +- third_party/jpeg-xl/lib/jxl/test_image.cc | 20 +- third_party/jpeg-xl/lib/jxl/test_utils.cc | 57 +- third_party/jpeg-xl/lib/jxl/test_utils.h | 24 +- third_party/jpeg-xl/lib/jxl/testing.h | 33 +- third_party/jpeg-xl/lib/jxl/toc.h | 2 +- third_party/jpeg-xl/lib/jxl/transpose-inl.h | 18 +- third_party/jpeg-xl/lib/jxl/version.h.in | 2 +- third_party/jpeg-xl/lib/jxl_cms.cmake | 2 + third_party/jpeg-xl/lib/jxl_lists.bzl | 3 +- third_party/jpeg-xl/lib/jxl_lists.cmake | 3 +- third_party/jpeg-xl/lib/jxl_tests.cmake | 1 - third_party/jpeg-xl/lib/jxl_vars.bzl | 5 +- third_party/jpeg-xl/lib/nothing.cc | 7 + .../jpeg-xl/lib/threads/thread_parallel_runner.cc | 10 +- .../lib/threads/thread_parallel_runner_internal.cc | 7 +- .../lib/threads/thread_parallel_runner_internal.h | 4 +- .../jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c | 10 +- .../plugins/gdk-pixbuf/pixbufloader_test.cc | 7 +- third_party/jpeg-xl/plugins/gimp/common.cc | 9 +- third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc | 23 +- third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc | 59 +- third_party/jpeg-xl/plugins/mime/README.md | 2 +- third_party/libwebrtc/BUILD.gn | 7 +- third_party/libwebrtc/DEPS | 197 +- third_party/libwebrtc/README.moz-ff-commit | 837 + third_party/libwebrtc/README.mozilla | 558 + third_party/libwebrtc/api/BUILD.gn | 179 +- third_party/libwebrtc/api/DEPS | 80 - .../resource_adaptation_api_gn/moz.build | 5 - third_party/libwebrtc/api/array_view_gn/moz.build | 7 - .../libwebrtc/api/async_dns_resolver_gn/moz.build | 7 - third_party/libwebrtc/api/async_resolver_factory.h | 36 - .../libwebrtc/api/audio/aec3_config_gn/moz.build | 5 - .../libwebrtc/api/audio/aec3_factory_gn/moz.build | 5 - .../api/audio/audio_frame_api_gn/moz.build | 5 - .../api/audio/audio_frame_processor_gn/moz.build | 7 - .../api/audio/audio_mixer_api_gn/moz.build | 7 - .../libwebrtc/api/audio/echo_control_gn/moz.build | 7 - third_party/libwebrtc/api/audio_codecs/BUILD.gn | 1 + .../L16/audio_decoder_L16_gn/moz.build | 5 - .../L16/audio_encoder_L16_gn/moz.build | 5 - .../api/audio_codecs/audio_codecs_api_gn/moz.build | 5 - .../api/audio_codecs/audio_decoder_factory.h | 4 +- .../builtin_audio_decoder_factory_gn/moz.build | 5 - .../builtin_audio_encoder_factory_gn/moz.build | 5 - .../g711/audio_decoder_g711_gn/moz.build | 5 - .../g711/audio_encoder_g711_gn/moz.build | 5 - .../g722/audio_decoder_g722_gn/moz.build | 5 - .../g722/audio_encoder_g722_config_gn/moz.build | 7 - .../g722/audio_encoder_g722_gn/moz.build | 5 - .../ilbc/audio_decoder_ilbc_gn/moz.build | 5 - .../ilbc/audio_encoder_ilbc_config_gn/moz.build | 7 - .../ilbc/audio_encoder_ilbc_gn/moz.build | 5 - .../opus/audio_decoder_multiopus_gn/moz.build | 5 - .../opus/audio_decoder_opus_config_gn/moz.build | 7 - .../opus/audio_decoder_opus_gn/moz.build | 5 - .../opus/audio_encoder_multiopus_gn/moz.build | 5 - .../opus/audio_encoder_opus_config_gn/moz.build | 5 - .../opus/audio_encoder_opus_gn/moz.build | 5 - .../libwebrtc/api/audio_options_api_gn/moz.build | 5 - .../libwebrtc/api/bitrate_allocation_gn/moz.build | 7 - .../libwebrtc/api/call/call_factory_interface.h | 7 +- third_party/libwebrtc/api/call_api_gn/moz.build | 7 - .../libwebrtc/api/callfactory_api_gn/moz.build | 7 - .../libwebrtc/api/create_peerconnection_factory.cc | 77 +- .../libwebrtc/api/create_peerconnection_factory.h | 19 +- .../crypto/frame_decryptor_interface_gn/moz.build | 7 - .../crypto/frame_encryptor_interface_gn/moz.build | 7 - .../libwebrtc/api/crypto/options_gn/moz.build | 5 - third_party/libwebrtc/api/data_channel_interface.h | 4 +- .../libwebrtc/api/dtls_transport_interface.h | 4 +- third_party/libwebrtc/api/dtmf_sender_interface.h | 4 +- third_party/libwebrtc/api/enable_media.cc | 72 + third_party/libwebrtc/api/enable_media.h | 27 + .../libwebrtc/api/enable_media_with_defaults.cc | 46 + .../libwebrtc/api/enable_media_with_defaults.h | 28 + third_party/libwebrtc/api/environment/BUILD.gn | 63 + third_party/libwebrtc/api/environment/OWNERS | 15 + .../libwebrtc/api/environment/environment.h | 148 + .../api/environment/environment_factory.cc | 123 + .../api/environment/environment_factory.h | 148 + .../api/environment/environment_gn/moz.build | 198 + .../api/environment/environment_unittest.cc | 275 + .../libwebrtc/api/fec_controller_api_gn/moz.build | 7 - .../api/field_trials_registry_gn/moz.build | 5 - .../libwebrtc/api/field_trials_view_gn/moz.build | 7 - .../libwebrtc/api/frame_transformer_interface.h | 15 +- .../api/frame_transformer_interface_gn/moz.build | 7 - .../libwebrtc/api/function_view_gn/moz.build | 7 - .../libwebrtc/api/ice_transport_interface.h | 21 +- third_party/libwebrtc/api/jsep.h | 7 +- third_party/libwebrtc/api/legacy_stats_types.h | 4 +- .../api/libjingle_logging_api_gn/moz.build | 7 - .../api/libjingle_peerconnection_api_gn/moz.build | 7 - third_party/libwebrtc/api/location_gn/moz.build | 7 - .../libwebrtc/api/make_ref_counted_gn/moz.build | 7 - third_party/libwebrtc/api/media_stream_interface.h | 10 +- .../api/media_stream_interface_gn/moz.build | 5 - third_party/libwebrtc/api/metronome/metronome.cc | 19 - .../libwebrtc/api/metronome/metronome_gn/moz.build | 7 - .../default_neteq_controller_factory_gn/moz.build | 5 - .../libwebrtc/api/neteq/neteq_api_gn/moz.build | 5 - .../api/neteq/neteq_controller_api_gn/moz.build | 7 - .../libwebrtc/api/neteq/tick_timer_gn/moz.build | 5 - .../api/network_state_predictor_api_gn/moz.build | 7 - third_party/libwebrtc/api/packet_socket_factory.h | 21 +- .../libwebrtc/api/peer_connection_interface.cc | 2 + .../libwebrtc/api/peer_connection_interface.h | 44 +- third_party/libwebrtc/api/priority_gn/moz.build | 7 - third_party/libwebrtc/api/ref_count.h | 67 + third_party/libwebrtc/api/ref_count_gn/moz.build | 198 + .../libwebrtc/api/refcountedbase_gn/moz.build | 7 - third_party/libwebrtc/api/rtc_error_gn/moz.build | 5 - third_party/libwebrtc/api/rtc_event_log/BUILD.gn | 8 +- .../api/rtc_event_log/rtc_event_log_factory.cc | 35 +- .../api/rtc_event_log/rtc_event_log_factory.h | 18 +- .../rtc_event_log_factory_interface.h | 8 +- .../api/rtc_event_log/rtc_event_log_gn/moz.build | 5 - third_party/libwebrtc/api/rtp_headers_gn/moz.build | 5 - .../libwebrtc/api/rtp_packet_info_gn/moz.build | 5 - .../libwebrtc/api/rtp_parameters_gn/moz.build | 5 - third_party/libwebrtc/api/rtp_receiver_interface.h | 4 +- third_party/libwebrtc/api/rtp_sender_interface.h | 4 +- .../api/rtp_sender_interface_gn/moz.build | 7 - .../rtp_sender_setparameters_callback_gn/moz.build | 5 - .../api/rtp_transceiver_direction_gn/moz.build | 7 - .../libwebrtc/api/rtp_transceiver_interface.h | 4 +- third_party/libwebrtc/api/scoped_refptr.h | 33 +- .../libwebrtc/api/scoped_refptr_gn/moz.build | 7 - .../libwebrtc/api/sctp_transport_interface.h | 4 +- .../libwebrtc/api/sequence_checker_gn/moz.build | 7 - .../api/set_local_description_observer_interface.h | 4 +- .../set_remote_description_observer_interface.h | 4 +- .../api/simulated_network_api_gn/moz.build | 7 - third_party/libwebrtc/api/stats/rtc_stats_report.h | 2 +- third_party/libwebrtc/api/task_queue/BUILD.gn | 5 +- .../pending_task_safety_flag_gn/moz.build | 5 - .../api/task_queue/task_queue_gn/moz.build | 5 - .../libwebrtc/api/task_queue/task_queue_test.cc | 2 +- .../libwebrtc/api/test/compile_all_headers.cc | 1 + .../libwebrtc/api/test/create_time_controller.cc | 43 +- .../libwebrtc/api/test/create_time_controller.h | 12 +- .../api/test/create_video_codec_tester.cc | 27 - .../libwebrtc/api/test/create_video_codec_tester.h | 26 - .../api/test/mock_transformable_audio_frame.h | 3 + .../libwebrtc/api/test/mock_transformable_frame.h | 45 + .../libwebrtc/api/test/pclf/media_configuration.h | 1 - .../api/test/pclf/media_quality_test_params.h | 2 - .../api/test/peerconnection_quality_test_fixture.h | 1 - .../libwebrtc/api/test/video_codec_stats.cc | 97 - third_party/libwebrtc/api/test/video_codec_stats.h | 120 - .../libwebrtc/api/test/video_codec_tester.h | 148 - .../api/transport/bitrate_settings_gn/moz.build | 5 - .../datagram_transport_interface_gn/moz.build | 7 - .../field_trial_based_config_gn/moz.build | 5 - .../libwebrtc/api/transport/goog_cc_gn/moz.build | 5 - .../api/transport/network_control_gn/moz.build | 5 - .../rtp/dependency_descriptor_gn/moz.build | 5 - .../api/transport/rtp/rtp_source_gn/moz.build | 7 - third_party/libwebrtc/api/transport/stun.cc | 24 +- third_party/libwebrtc/api/transport/stun.h | 19 +- .../api/transport/stun_types_gn/moz.build | 7 - .../libwebrtc/api/transport/stun_unittest.cc | 156 +- .../libwebrtc/api/transport_api_gn/moz.build | 5 - .../libwebrtc/api/units/data_rate_gn/moz.build | 5 - .../libwebrtc/api/units/data_size_gn/moz.build | 5 - .../libwebrtc/api/units/frequency_gn/moz.build | 5 - .../libwebrtc/api/units/time_delta_gn/moz.build | 5 - .../libwebrtc/api/units/timestamp_gn/moz.build | 5 - third_party/libwebrtc/api/video/BUILD.gn | 1 + .../moz.build | 5 - .../libwebrtc/api/video/encoded_frame_gn/moz.build | 5 - .../libwebrtc/api/video/encoded_image_gn/moz.build | 5 - .../libwebrtc/api/video/frame_buffer_gn/moz.build | 5 - .../video/recordable_encoded_frame_gn/moz.build | 7 - .../api/video/render_resolution_gn/moz.build | 7 - .../libwebrtc/api/video/resolution_gn/moz.build | 7 - .../api/video/video_adaptation_gn/moz.build | 5 - .../video/video_bitrate_allocation_gn/moz.build | 5 - .../video_bitrate_allocator_factory_gn/moz.build | 7 - .../api/video/video_bitrate_allocator_gn/moz.build | 5 - .../api/video/video_codec_constants_gn/moz.build | 7 - third_party/libwebrtc/api/video/video_frame.h | 8 +- .../libwebrtc/api/video/video_frame_buffer.h | 4 +- .../libwebrtc/api/video/video_frame_gn/moz.build | 5 - .../api/video/video_frame_i010_gn/moz.build | 5 - .../api/video/video_frame_metadata_gn/moz.build | 5 - .../api/video/video_frame_type_gn/moz.build | 7 - .../api/video/video_layers_allocation_gn/moz.build | 7 - .../api/video/video_rtp_headers_gn/moz.build | 5 - .../api/video/video_stream_encoder_gn/moz.build | 7 - .../video_codecs/bitstream_parser_api_gn/moz.build | 7 - .../rtc_software_fallback_wrappers_gn/moz.build | 5 - .../api/video_codecs/scalability_mode_gn/moz.build | 5 - .../api/video_codecs/video_codecs_api_gn/moz.build | 5 - .../vp8_temporal_layers_factory_gn/moz.build | 5 - .../video_track_source_constraints_gn/moz.build | 7 - .../libwebrtc/api/wrapping_async_dns_resolver.h | 135 - third_party/libwebrtc/audio/BUILD.gn | 2 + third_party/libwebrtc/audio/audio_gn/moz.build | 5 - third_party/libwebrtc/audio/audio_send_stream.cc | 4 +- .../libwebrtc/audio/audio_send_stream_unittest.cc | 11 +- third_party/libwebrtc/audio/channel_receive.cc | 26 +- .../channel_receive_frame_transformer_delegate.cc | 36 +- .../channel_receive_frame_transformer_delegate.h | 9 +- ..._receive_frame_transformer_delegate_unittest.cc | 28 +- .../libwebrtc/audio/channel_receive_unittest.cc | 36 + third_party/libwebrtc/audio/channel_send.cc | 31 +- third_party/libwebrtc/audio/channel_send.h | 1 + .../channel_send_frame_transformer_delegate.cc | 44 +- .../channel_send_frame_transformer_delegate.h | 10 +- ...nel_send_frame_transformer_delegate_unittest.cc | 116 +- .../libwebrtc/audio/channel_send_unittest.cc | 7 +- .../libwebrtc/audio/mock_voe_channel_proxy.h | 4 +- .../utility/audio_frame_operations_gn/moz.build | 5 - .../libwebrtc/build/config/android/BUILD.gn | 8 - third_party/libwebrtc/call/BUILD.gn | 6 +- .../adaptation/resource_adaptation_gn/moz.build | 5 - .../call/audio_sender_interface_gn/moz.build | 7 - .../libwebrtc/call/bitrate_allocator_gn/moz.build | 5 - .../call/bitrate_configurator_gn/moz.build | 5 - .../libwebrtc/call/bitrate_estimator_tests.cc | 4 +- third_party/libwebrtc/call/call.cc | 5 +- third_party/libwebrtc/call/call_config.cc | 9 +- third_party/libwebrtc/call/call_config.h | 18 +- third_party/libwebrtc/call/call_gn/moz.build | 5 - .../libwebrtc/call/call_interfaces_gn/moz.build | 5 - third_party/libwebrtc/call/call_perf_tests.cc | 9 +- third_party/libwebrtc/call/call_unittest.cc | 13 +- third_party/libwebrtc/call/rampup_tests.cc | 21 +- .../call/receive_stream_interface_gn/moz.build | 7 - third_party/libwebrtc/call/rtp_demuxer.cc | 13 + third_party/libwebrtc/call/rtp_demuxer.h | 3 + .../libwebrtc/call/rtp_interfaces_gn/moz.build | 5 - .../libwebrtc/call/rtp_receiver_gn/moz.build | 5 - third_party/libwebrtc/call/rtp_sender_gn/moz.build | 5 - third_party/libwebrtc/call/rtp_transport_config.h | 3 - .../call/rtp_transport_controller_send.cc | 7 +- .../libwebrtc/call/rtp_video_sender_unittest.cc | 4 +- third_party/libwebrtc/call/simulated_network.h | 2 +- third_party/libwebrtc/call/version.cc | 2 +- third_party/libwebrtc/call/version_gn/moz.build | 5 - third_party/libwebrtc/call/video_send_stream.h | 1 + .../libwebrtc/call/video_stream_api_gn/moz.build | 5 - .../common_audio/common_audio_avx2_gn/moz.build | 4 - .../common_audio_c_arm_asm_gn/moz.build | 7 - .../common_audio/common_audio_c_gn/moz.build | 5 - .../common_audio/common_audio_cc_gn/moz.build | 5 - .../common_audio/common_audio_gn/moz.build | 5 - .../common_audio/common_audio_neon_c_gn/moz.build | 1 - .../common_audio/common_audio_neon_gn/moz.build | 1 - .../common_audio/common_audio_sse2_gn/moz.build | 4 - .../common_audio/fir_filter_factory_gn/moz.build | 5 - .../libwebrtc/common_audio/fir_filter_gn/moz.build | 7 - .../common_audio/sinc_resampler_gn/moz.build | 7 - .../third_party/ooura/fft_size_128_gn/moz.build | 5 - .../third_party/ooura/fft_size_256_gn/moz.build | 5 - .../spl_sqrt_floor/spl_sqrt_floor_gn/moz.build | 5 - .../common_video/common_video_gn/moz.build | 5 - .../common_video/frame_counts_gn/moz.build | 7 - .../generic_frame_descriptor_gn/moz.build | 5 - .../common_video/h265/h265_bitstream_parser.cc | 4 +- .../libwebrtc/common_video/h265/h265_common.h | 4 +- third_party/libwebrtc/examples/BUILD.gn | 2 +- .../libwebrtc/examples/androidnativeapi/BUILD.gn | 2 +- .../androidnativeapi/jni/android_call_client.cc | 13 +- .../objcnativeapi/objc/objc_call_client.mm | 18 +- .../client/peer_connection_client.cc | 1 + .../examples/stunserver/stunserver_main.cc | 3 +- third_party/libwebrtc/experiments/field_trials.py | 6 +- .../registered_field_trials_gn/moz.build | 7 - third_party/libwebrtc/g3doc/style-guide.md | 5 +- .../libwebrtc/infra/specs/client.webrtc.json | 189 +- .../infra/specs/internal.client.webrtc.json | 135 +- third_party/libwebrtc/infra/specs/mixins.pyl | 12 +- .../libwebrtc/infra/specs/mixins_webrtc.pyl | 6 + .../libwebrtc/infra/specs/tryserver.webrtc.json | 189 +- third_party/libwebrtc/infra/specs/variants.pyl | 15 +- third_party/libwebrtc/logging/BUILD.gn | 14 +- .../libwebrtc/logging/rtc_event_audio_gn/moz.build | 5 - .../libwebrtc/logging/rtc_event_bwe_gn/moz.build | 5 - .../libwebrtc/logging/rtc_event_field_gn/moz.build | 5 - .../encoder/rtc_event_log_encoder_legacy.cc | 3 - .../encoder/rtc_event_log_encoder_new_format.cc | 3 - .../rtc_event_log/fake_rtc_event_log_factory.cc | 12 +- .../rtc_event_log/fake_rtc_event_log_factory.h | 13 +- .../rtc_event_log/rtc_event_log2_proto_include.h | 4 - .../logging/rtc_event_log/rtc_event_log_parser.h | 3 - .../rtc_event_log/rtc_event_log_unittest.cc | 41 +- .../rtc_event_log_parse_status_gn/moz.build | 7 - .../rtc_event_number_encodings_gn/moz.build | 5 - .../logging/rtc_event_pacing_gn/moz.build | 5 - .../logging/rtc_event_rtp_rtcp_gn/moz.build | 5 - .../libwebrtc/logging/rtc_event_video_gn/moz.build | 5 - .../logging/rtc_stream_config_gn/moz.build | 5 - third_party/libwebrtc/media/BUILD.gn | 32 +- third_party/libwebrtc/media/base/codec.cc | 3 +- third_party/libwebrtc/media/base/codec.h | 4 +- third_party/libwebrtc/media/codec_gn/moz.build | 5 - .../engine/null_webrtc_video_engine_unittest.cc | 2 +- .../libwebrtc/media/engine/webrtc_media_engine.cc | 1 - .../libwebrtc/media/engine/webrtc_media_engine.h | 8 +- .../media/engine/webrtc_media_engine_defaults.cc | 43 - .../media/engine/webrtc_media_engine_defaults.h | 24 - .../media/engine/webrtc_media_engine_unittest.cc | 13 - .../media/engine/webrtc_video_engine_unittest.cc | 61 +- .../libwebrtc/media/engine/webrtc_voice_engine.cc | 29 +- .../libwebrtc/media/engine/webrtc_voice_engine.h | 8 +- .../media/engine/webrtc_voice_engine_unittest.cc | 89 +- .../libwebrtc/media/media_channel_gn/moz.build | 7 - .../media/media_channel_impl_gn/moz.build | 7 - .../libwebrtc/media/media_constants_gn/moz.build | 5 - .../libwebrtc/media/rid_description_gn/moz.build | 7 - .../libwebrtc/media/rtc_media_base_gn/moz.build | 5 - .../libwebrtc/media/rtc_media_config_gn/moz.build | 7 - .../rtc_simulcast_encoder_adapter_gn/moz.build | 5 - third_party/libwebrtc/media/rtp_utils_gn/moz.build | 7 - .../libwebrtc/media/stream_params_gn/moz.build | 7 - .../async_audio_processing_gn/moz.build | 5 - .../libwebrtc/modules/audio_coding/BUILD.gn | 4 +- .../acm2/audio_coding_module_unittest.cc | 26 +- .../modules/audio_coding/audio_coding_gn/moz.build | 5 - .../audio_coding_module_typedefs_gn/moz.build | 7 - .../audio_coding_opus_common_gn/moz.build | 5 - .../audio_coding/audio_encoder_cng_gn/moz.build | 5 - .../audio_network_adaptor/controller_manager.cc | 4 +- .../controller_manager_unittest.cc | 3 - .../audio_network_adaptor/debug_dump_writer.cc | 3 - .../audio_network_adaptor/debug_dump_writer.h | 4 +- .../audio_network_adaptor_config_gn/moz.build | 5 - .../audio_network_adaptor_gn/moz.build | 5 - .../default_neteq_factory_gn/moz.build | 5 - .../modules/audio_coding/g711_c_gn/moz.build | 5 - .../modules/audio_coding/g711_gn/moz.build | 5 - .../modules/audio_coding/g722_c_gn/moz.build | 5 - .../modules/audio_coding/g722_gn/moz.build | 5 - .../modules/audio_coding/ilbc_c_gn/moz.build | 5 - .../modules/audio_coding/ilbc_gn/moz.build | 5 - .../modules/audio_coding/isac_bwinfo_gn/moz.build | 7 - .../modules/audio_coding/isac_vad_gn/moz.build | 5 - .../legacy_encoded_audio_frame_gn/moz.build | 5 - .../modules/audio_coding/neteq/decision_logic.cc | 30 +- .../modules/audio_coding/neteq/decision_logic.h | 16 +- .../audio_coding/neteq/decision_logic_unittest.cc | 62 +- .../neteq/mock/mock_packet_arrival_history.h | 32 + .../audio_coding/neteq/mock/mock_packet_buffer.h | 47 +- .../modules/audio_coding/neteq/neteq_impl.cc | 185 +- .../modules/audio_coding/neteq/neteq_impl.h | 8 +- .../audio_coding/neteq/neteq_impl_unittest.cc | 99 +- .../neteq/neteq_network_stats_unittest.cc | 7 +- .../modules/audio_coding/neteq/neteq_unittest.cc | 20 +- .../audio_coding/neteq/packet_arrival_history.h | 5 +- .../modules/audio_coding/neteq/packet_buffer.cc | 200 +- .../modules/audio_coding/neteq/packet_buffer.h | 61 +- .../audio_coding/neteq/packet_buffer_unittest.cc | 468 +- .../audio_coding/neteq/test/neteq_decoding_test.cc | 4 +- .../modules/audio_coding/neteq/test/result_sink.cc | 5 +- .../modules/audio_coding/neteq_gn/moz.build | 5 - .../modules/audio_coding/pcm16b_c_gn/moz.build | 5 - .../modules/audio_coding/pcm16b_gn/moz.build | 5 - .../modules/audio_coding/red_gn/moz.build | 5 - .../modules/audio_coding/webrtc_cng_gn/moz.build | 5 - .../audio_coding/webrtc_multiopus_gn/moz.build | 5 - .../modules/audio_coding/webrtc_opus_gn/moz.build | 5 - .../audio_coding/webrtc_opus_wrapper_gn/moz.build | 5 - .../libwebrtc/modules/audio_device/BUILD.gn | 2 +- .../modules/audio_device/audio_device_gn/moz.build | 7 - .../modules/audio_device/include/audio_device.h | 4 +- .../audio_device/include/fake_audio_device.h | 4 +- .../audio_frame_manipulator_gn/moz.build | 5 - .../audio_mixer/audio_mixer_impl_gn/moz.build | 5 - .../libwebrtc/modules/audio_processing/BUILD.gn | 5 +- .../aec3/adaptive_fir_filter_erl_gn/moz.build | 7 - .../aec3/adaptive_fir_filter_gn/moz.build | 7 - .../audio_processing/aec3/aec3_avx2_gn/moz.build | 4 - .../audio_processing/aec3/aec3_common_gn/moz.build | 7 - .../audio_processing/aec3/aec3_fft_gn/moz.build | 7 - .../audio_processing/aec3/aec3_gn/moz.build | 5 - .../audio_processing/aec3/fft_data_gn/moz.build | 7 - .../aec3/matched_filter_gn/moz.build | 7 - .../aec3/render_buffer_gn/moz.build | 7 - .../audio_processing/aec3/vector_math_gn/moz.build | 7 - .../modules/audio_processing/aec_dump/BUILD.gn | 1 - .../aec_dump/aec_dump_gn/moz.build | 7 - .../audio_processing/aec_dump/aec_dump_impl.h | 3 - .../aec_dump/capture_stream_info.h | 3 - .../aec_dump/null_aec_dump_factory_gn/moz.build | 5 - .../aec_dump_interface_gn/moz.build | 5 - .../audio_processing/aecm/aecm_core_gn/moz.build | 5 - .../modules/audio_processing/agc/agc_gn/moz.build | 5 - .../agc/gain_control_interface_gn/moz.build | 7 - .../audio_processing/agc/legacy_agc_gn/moz.build | 5 - .../agc/level_estimation_gn/moz.build | 5 - .../adaptive_digital_gain_controller_gn/moz.build | 5 - .../agc2/biquad_filter_gn/moz.build | 5 - .../agc2/clipping_predictor_gn/moz.build | 5 - .../audio_processing/agc2/common_gn/moz.build | 7 - .../agc2/cpu_features_gn/moz.build | 5 - .../agc2/fixed_digital_gn/moz.build | 5 - .../agc2/gain_applier_gn/moz.build | 5 - .../audio_processing/agc2/gain_map_gn/moz.build | 7 - .../agc2/input_volume_controller_gn/moz.build | 5 - .../agc2/input_volume_stats_reporter_gn/moz.build | 5 - .../agc2/noise_level_estimator_gn/moz.build | 5 - .../rnn_vad/rnn_vad_auto_correlation_gn/moz.build | 5 - .../agc2/rnn_vad/rnn_vad_common_gn/moz.build | 7 - .../agc2/rnn_vad/rnn_vad_gn/moz.build | 5 - .../agc2/rnn_vad/rnn_vad_layers_gn/moz.build | 5 - .../agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build | 5 - .../agc2/rnn_vad/rnn_vad_pitch_gn/moz.build | 5 - .../agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build | 7 - .../rnn_vad/rnn_vad_sequence_buffer_gn/moz.build | 7 - .../rnn_vad/rnn_vad_spectral_features_gn/moz.build | 5 - .../rnn_vad_symmetric_matrix_buffer_gn/moz.build | 7 - .../agc2/rnn_vad/vector_math_avx2_gn/moz.build | 4 - .../agc2/rnn_vad/vector_math_gn/moz.build | 7 - .../agc2/saturation_protector_gn/moz.build | 5 - .../agc2/speech_level_estimator_gn/moz.build | 5 - .../audio_processing/agc2/vad_wrapper_gn/moz.build | 5 - .../modules/audio_processing/api_gn/moz.build | 5 - .../audio_processing/apm_logging_gn/moz.build | 5 - .../audio_processing/audio_buffer_gn/moz.build | 5 - .../audio_frame_proxies_gn/moz.build | 5 - .../audio_processing/audio_frame_view_gn/moz.build | 7 - .../audio_processing/audio_processing_gn/moz.build | 5 - .../audio_processing/audio_processing_impl.h | 1 - .../audio_processing_impl_unittest.cc | 2 +- .../audio_processing_statistics_gn/moz.build | 5 - .../audio_processing/audio_processing_unittest.cc | 6 +- .../capture_levels_adjuster_gn/moz.build | 5 - .../audio_processing/gain_controller2_gn/moz.build | 5 - .../audio_processing/high_pass_filter_gn/moz.build | 5 - .../audio_processing/include/audio_processing.h | 6 +- .../modules/audio_processing/ns/ns_gn/moz.build | 5 - .../moz.build | 5 - .../audio_processing/rms_level_gn/moz.build | 5 - .../test/aec_dump_based_simulator.h | 3 - .../audio_processing/test/debug_dump_replayer.h | 4 +- .../modules/audio_processing/test/protobuf_utils.h | 4 +- .../transient_suppressor_api_gn/moz.build | 7 - .../transient_suppressor_impl_gn/moz.build | 5 - .../voice_probability_delay_unit_gn/moz.build | 5 - .../utility/cascaded_biquad_filter_gn/moz.build | 5 - .../utility/legacy_delay_estimator_gn/moz.build | 5 - .../utility/pffft_wrapper_gn/moz.build | 5 - .../modules/audio_processing/vad/vad_gn/moz.build | 5 - .../congestion_controller_gn/moz.build | 5 - .../goog_cc/alr_detector_gn/moz.build | 5 - .../goog_cc/delay_based_bwe_gn/moz.build | 5 - .../goog_cc/estimators_gn/moz.build | 5 - .../goog_cc/goog_cc_gn/moz.build | 5 - .../goog_cc/link_capacity_estimator_gn/moz.build | 5 - .../goog_cc/loss_based_bwe_v1_gn/moz.build | 5 - .../goog_cc/loss_based_bwe_v2.cc | 184 +- .../goog_cc/loss_based_bwe_v2.h | 19 +- .../goog_cc/loss_based_bwe_v2_gn/moz.build | 5 - .../goog_cc/loss_based_bwe_v2_test.cc | 407 +- .../goog_cc/probe_controller_gn/moz.build | 5 - .../goog_cc/pushback_controller_gn/moz.build | 5 - .../goog_cc/send_side_bandwidth_estimation.cc | 30 +- .../goog_cc/send_side_bandwidth_estimation.h | 4 +- .../goog_cc/send_side_bwe_gn/moz.build | 5 - .../rtp/control_handler_gn/moz.build | 5 - .../rtp/transport_feedback_gn/moz.build | 5 - .../linux/wayland/base_capturer_pipewire.cc | 1 + .../linux/wayland/shared_screencast_stream.cc | 28 - .../desktop_capture/mac/desktop_frame_provider.h | 2 + .../desktop_capture/mac/screen_capturer_mac.mm | 4 + .../win/dxgi_duplicator_controller.h | 2 +- .../libwebrtc/modules/module_api_gn/moz.build | 7 - .../modules/module_api_public_gn/moz.build | 7 - .../libwebrtc/modules/module_fec_api_gn/moz.build | 7 - .../modules/pacing/interval_budget_gn/moz.build | 5 - .../libwebrtc/modules/pacing/pacing_controller.cc | 2 +- .../libwebrtc/modules/pacing/pacing_controller.h | 5 + .../modules/pacing/pacing_controller_unittest.cc | 144 +- .../libwebrtc/modules/pacing/pacing_gn/moz.build | 5 - .../modules/pacing/task_queue_paced_sender.cc | 34 +- .../modules/pacing/task_queue_paced_sender.h | 31 +- .../pacing/task_queue_paced_sender_unittest.cc | 44 +- .../libwebrtc/modules/portal/pipewire_utils.h | 75 + .../remote_bitrate_estimator/aimd_rate_control.h | 2 +- .../aimd_rate_control_unittest.cc | 18 +- .../remote_bitrate_estimator_gn/moz.build | 5 - third_party/libwebrtc/modules/rtp_rtcp/BUILD.gn | 11 + .../libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build | 5 - .../modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build | 5 - .../modules/rtp_rtcp/rtp_rtcp_gn/moz.build | 5 - .../modules/rtp_rtcp/rtp_video_header_gn/moz.build | 5 - .../source/flexfec_header_reader_writer.cc | 18 +- .../flexfec_header_reader_writer_unittest.cc | 121 +- .../modules/rtp_rtcp/source/rtp_format.cc | 9 +- .../modules/rtp_rtcp/source/rtp_packetizer_av1.cc | 3 +- .../modules/rtp_rtcp/source/rtp_packetizer_h265.cc | 350 + .../modules/rtp_rtcp/source/rtp_packetizer_h265.h | 66 + .../source/rtp_packetizer_h265_unittest.cc | 525 + .../modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 4 +- .../modules/rtp_rtcp/source/rtp_sender_audio.cc | 3 +- .../modules/rtp_rtcp/source/rtp_sender_audio.h | 3 + .../rtp_rtcp/source/rtp_sender_audio_unittest.cc | 15 + .../rtp_sender_video_frame_transformer_delegate.cc | 50 +- .../rtp_sender_video_frame_transformer_delegate.h | 3 + ...er_video_frame_transformer_delegate_unittest.cc | 30 +- ...o_stream_receiver_frame_transformer_delegate.cc | 26 +- ...eo_stream_receiver_frame_transformer_delegate.h | 5 + ...receiver_frame_transformer_delegate_unittest.cc | 23 + .../rtp_rtcp/source/video_rtp_depacketizer_av1.cc | 3 +- .../modules/third_party/fft/fft_gn/moz.build | 5 - .../modules/third_party/g711/g711_3p_gn/moz.build | 5 - .../modules/third_party/g722/g722_3p_gn/moz.build | 5 - .../libwebrtc/modules/utility/utility_gn/moz.build | 5 - .../modules/video_capture/linux/camera_portal.cc | 16 +- .../video_capture/linux/device_info_pipewire.cc | 8 +- .../video_capture/linux/device_info_pipewire.h | 2 +- .../video_capture/linux/device_info_v4l2.cc | 18 - .../video_capture/linux/video_capture_pipewire.cc | 46 +- .../video_capture/linux/video_capture_v4l2.cc | 2 +- .../modules/video_capture/video_capture.h | 2 +- .../video_capture_internal_impl_gn/moz.build | 5 - .../video_capture_module_gn/moz.build | 5 - .../libwebrtc/modules/video_coding/BUILD.gn | 67 +- .../chain_diff_calculator_gn/moz.build | 5 - .../codec_globals_headers_gn/moz.build | 7 - .../codecs/av1/av1_svc_config_gn/moz.build | 5 - .../codecs/test/video_codec_analyzer.cc | 193 - .../codecs/test/video_codec_analyzer.h | 75 - .../codecs/test/video_codec_analyzer_unittest.cc | 127 - .../codecs/test/video_codec_stats_impl.cc | 278 - .../codecs/test/video_codec_stats_impl.h | 62 - .../codecs/test/video_codec_stats_impl_unittest.cc | 148 - .../video_coding/codecs/test/video_codec_test.cc | 888 +- .../codecs/test/video_codec_tester_impl.cc | 437 - .../codecs/test/video_codec_tester_impl.h | 45 - .../test/video_codec_tester_impl_unittest.cc | 205 - .../video_coding/encoded_frame_gn/moz.build | 5 - .../frame_dependencies_calculator_gn/moz.build | 5 - .../video_coding/frame_helpers_gn/moz.build | 5 - .../modules/video_coding/generic_decoder.cc | 13 +- .../video_coding/include/video_codec_interface.h | 16 +- .../video_coding/nack_requester_gn/moz.build | 5 - .../video_coding/packet_buffer_gn/moz.build | 5 - .../svc/scalability_mode_util_gn/moz.build | 5 - .../svc/scalability_structures_gn/moz.build | 5 - .../svc/scalable_video_controller_gn/moz.build | 5 - .../svc/svc_rate_allocator_gn/moz.build | 5 - .../decode_time_percentile_filter_gn/moz.build | 5 - .../moz.build | 5 - .../moz.build | 5 - .../timing/jitter_estimator_gn/moz.build | 5 - .../video_coding/timing/rtt_filter_gn/moz.build | 5 - .../timing/timestamp_extrapolator_gn/moz.build | 5 - .../video_coding/timing/timing_module_gn/moz.build | 5 - .../video_codec_interface_gn/moz.build | 5 - .../modules/video_coding/video_coding_gn/moz.build | 5 - .../video_coding/video_coding_utility_gn/moz.build | 5 - .../webrtc_libvpx_interface_gn/moz.build | 5 - .../modules/video_coding/webrtc_vp8_gn/moz.build | 5 - .../webrtc_vp8_scalability_gn/moz.build | 5 - .../webrtc_vp8_temporal_layers_gn/moz.build | 5 - .../modules/video_coding/webrtc_vp9_gn/moz.build | 5 - .../video_coding/webrtc_vp9_helpers_gn/moz.build | 5 - third_party/libwebrtc/moz-patch-stack/0001.patch | 18 +- third_party/libwebrtc/moz-patch-stack/0002.patch | 2 +- third_party/libwebrtc/moz-patch-stack/0005.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0006.patch | 2 +- third_party/libwebrtc/moz-patch-stack/0007.patch | 2 +- third_party/libwebrtc/moz-patch-stack/0008.patch | 8 +- third_party/libwebrtc/moz-patch-stack/0009.patch | 4 +- third_party/libwebrtc/moz-patch-stack/0030.patch | 188 +- third_party/libwebrtc/moz-patch-stack/0031.patch | 4 +- third_party/libwebrtc/moz-patch-stack/0033.patch | 16 +- third_party/libwebrtc/moz-patch-stack/0041.patch | 4 +- third_party/libwebrtc/moz-patch-stack/0042.patch | 10 +- third_party/libwebrtc/moz-patch-stack/0044.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0049.patch | 2 +- third_party/libwebrtc/moz-patch-stack/0050.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0052.patch | 13 +- third_party/libwebrtc/moz-patch-stack/0053.patch | 4 +- third_party/libwebrtc/moz-patch-stack/0054.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0059.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0061.patch | 7 +- third_party/libwebrtc/moz-patch-stack/0063.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0064.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0066.patch | 6 +- third_party/libwebrtc/moz-patch-stack/0067.patch | 4 +- third_party/libwebrtc/moz-patch-stack/0068.patch | 2 +- third_party/libwebrtc/moz-patch-stack/0078.patch | 109 +- third_party/libwebrtc/moz-patch-stack/0079.patch | 76 +- third_party/libwebrtc/moz-patch-stack/0080.patch | 54 +- third_party/libwebrtc/moz-patch-stack/0081.patch | 49 +- third_party/libwebrtc/moz-patch-stack/0082.patch | 38 +- third_party/libwebrtc/moz-patch-stack/0083.patch | 42 +- third_party/libwebrtc/moz-patch-stack/0084.patch | 43 +- third_party/libwebrtc/moz-patch-stack/0085.patch | 89 +- third_party/libwebrtc/moz-patch-stack/0086.patch | 212 +- third_party/libwebrtc/moz-patch-stack/0087.patch | 186 +- third_party/libwebrtc/moz-patch-stack/0088.patch | 64 +- third_party/libwebrtc/moz-patch-stack/0089.patch | 63 +- third_party/libwebrtc/moz-patch-stack/0090.patch | 81 +- third_party/libwebrtc/moz-patch-stack/0091.patch | 123 +- third_party/libwebrtc/moz-patch-stack/0092.patch | 115 +- third_party/libwebrtc/moz-patch-stack/0093.patch | 54 +- third_party/libwebrtc/moz-patch-stack/0094.patch | 62 +- third_party/libwebrtc/moz-patch-stack/0095.patch | 55 +- third_party/libwebrtc/moz-patch-stack/0096.patch | 44 +- third_party/libwebrtc/moz-patch-stack/0097.patch | 2207 +- third_party/libwebrtc/moz-patch-stack/0098.patch | 37056 ++++++++++++++++++- third_party/libwebrtc/moz-patch-stack/0099.patch | 35372 +----------------- third_party/libwebrtc/moz-patch-stack/0100.patch | 78 +- third_party/libwebrtc/moz-patch-stack/0101.patch | 88 +- third_party/libwebrtc/moz-patch-stack/0102.patch | 213 +- third_party/libwebrtc/moz-patch-stack/0103.patch | 127 +- third_party/libwebrtc/moz-patch-stack/0104.patch | 146 +- third_party/libwebrtc/moz-patch-stack/0105.patch | 93 +- third_party/libwebrtc/moz-patch-stack/0106.patch | 208 +- .../058bfe3ae3.no-op-cherry-pick-msg | 1 + .../334e9133dc.no-op-cherry-pick-msg | 1 + .../a9d497b52d.no-op-cherry-pick-msg | 1 - third_party/libwebrtc/moz.build | 3 +- third_party/libwebrtc/net/dcsctp/common/BUILD.gn | 8 - third_party/libwebrtc/net/dcsctp/common/str_join.h | 56 - .../libwebrtc/net/dcsctp/common/str_join_test.cc | 45 - .../libwebrtc/net/dcsctp/fuzzers/dcsctp_fuzzers.h | 2 +- third_party/libwebrtc/net/dcsctp/packet/BUILD.gn | 3 - .../net/dcsctp/packet/chunk/sack_chunk.cc | 2 +- .../missing_mandatory_parameter_cause.cc | 4 +- .../parameter/supported_extensions_parameter.cc | 4 +- third_party/libwebrtc/net/dcsctp/public/BUILD.gn | 2 + .../libwebrtc/net/dcsctp/public/dcsctp_socket.h | 15 +- third_party/libwebrtc/net/dcsctp/public/types.h | 10 + third_party/libwebrtc/net/dcsctp/rx/BUILD.gn | 2 +- .../libwebrtc/net/dcsctp/rx/data_tracker_test.cc | 19 +- .../libwebrtc/net/dcsctp/rx/reassembly_queue.cc | 51 +- .../libwebrtc/net/dcsctp/rx/reassembly_queue.h | 7 - .../net/dcsctp/rx/reassembly_queue_test.cc | 27 - third_party/libwebrtc/net/dcsctp/socket/BUILD.gn | 6 +- .../net/dcsctp/socket/callback_deferrer.cc | 4 +- .../net/dcsctp/socket/callback_deferrer.h | 1 + third_party/libwebrtc/net/dcsctp/socket/context.h | 7 +- .../libwebrtc/net/dcsctp/socket/dcsctp_socket.cc | 44 +- .../libwebrtc/net/dcsctp/socket/dcsctp_socket.h | 6 +- .../dcsctp/socket/dcsctp_socket_network_test.cc | 16 +- .../net/dcsctp/socket/dcsctp_socket_test.cc | 121 +- .../net/dcsctp/socket/heartbeat_handler.cc | 43 +- .../net/dcsctp/socket/heartbeat_handler.h | 6 +- .../net/dcsctp/socket/heartbeat_handler_test.cc | 19 +- .../libwebrtc/net/dcsctp/socket/mock_context.h | 7 +- .../dcsctp/socket/mock_dcsctp_socket_callbacks.h | 12 +- .../net/dcsctp/socket/stream_reset_handler.cc | 8 +- .../net/dcsctp/socket/stream_reset_handler.h | 5 +- .../net/dcsctp/socket/stream_reset_handler_test.cc | 21 +- .../dcsctp/socket/transmission_control_block.cc | 45 +- .../net/dcsctp/socket/transmission_control_block.h | 18 +- third_party/libwebrtc/net/dcsctp/timer/BUILD.gn | 4 + .../libwebrtc/net/dcsctp/timer/fake_timeout.h | 37 +- .../net/dcsctp/timer/task_queue_timeout.cc | 24 +- .../net/dcsctp/timer/task_queue_timeout.h | 8 +- third_party/libwebrtc/net/dcsctp/timer/timer.cc | 35 +- third_party/libwebrtc/net/dcsctp/timer/timer.h | 40 +- .../libwebrtc/net/dcsctp/timer/timer_test.cc | 203 +- third_party/libwebrtc/net/dcsctp/tx/BUILD.gn | 12 +- .../libwebrtc/net/dcsctp/tx/mock_send_queue.h | 10 +- .../libwebrtc/net/dcsctp/tx/outstanding_data.cc | 261 +- .../libwebrtc/net/dcsctp/tx/outstanding_data.h | 67 +- .../net/dcsctp/tx/outstanding_data_test.cc | 58 +- .../net/dcsctp/tx/retransmission_queue.cc | 69 +- .../libwebrtc/net/dcsctp/tx/retransmission_queue.h | 22 +- .../net/dcsctp/tx/retransmission_queue_test.cc | 248 +- .../net/dcsctp/tx/retransmission_timeout.cc | 19 +- .../net/dcsctp/tx/retransmission_timeout.h | 22 +- .../net/dcsctp/tx/retransmission_timeout_test.cc | 153 +- .../libwebrtc/net/dcsctp/tx/rr_send_queue.cc | 15 +- .../libwebrtc/net/dcsctp/tx/rr_send_queue.h | 11 +- .../libwebrtc/net/dcsctp/tx/rr_send_queue_test.cc | 21 +- third_party/libwebrtc/net/dcsctp/tx/send_queue.h | 6 +- .../libwebrtc/net/dcsctp/tx/stream_scheduler.cc | 6 +- .../libwebrtc/net/dcsctp/tx/stream_scheduler.h | 8 +- .../net/dcsctp/tx/stream_scheduler_test.cc | 149 +- third_party/libwebrtc/p2p/BUILD.gn | 11 +- .../libwebrtc/p2p/base/async_stun_tcp_socket.cc | 33 +- .../libwebrtc/p2p/base/async_stun_tcp_socket.h | 2 +- .../p2p/base/async_stun_tcp_socket_unittest.cc | 44 +- .../p2p/base/basic_async_resolver_factory.cc | 33 - .../p2p/base/basic_async_resolver_factory.h | 46 - .../base/basic_async_resolver_factory_unittest.cc | 93 +- .../p2p/base/basic_packet_socket_factory.cc | 5 - .../p2p/base/basic_packet_socket_factory.h | 4 - third_party/libwebrtc/p2p/base/connection.cc | 25 +- third_party/libwebrtc/p2p/base/connection.h | 8 +- .../libwebrtc/p2p/base/fake_ice_transport.h | 4 +- .../libwebrtc/p2p/base/ice_transport_internal.cc | 8 +- .../libwebrtc/p2p/base/ice_transport_internal.h | 51 +- .../libwebrtc/p2p/base/mock_async_resolver.h | 62 - .../libwebrtc/p2p/base/p2p_transport_channel.cc | 42 +- .../libwebrtc/p2p/base/p2p_transport_channel.h | 2 - .../p2p/base/p2p_transport_channel_unittest.cc | 56 +- third_party/libwebrtc/p2p/base/port.cc | 18 +- third_party/libwebrtc/p2p/base/port.h | 23 +- third_party/libwebrtc/p2p/base/port_unittest.cc | 174 +- third_party/libwebrtc/p2p/base/pseudo_tcp.cc | 3 +- third_party/libwebrtc/p2p/base/stun_dictionary.cc | 2 +- third_party/libwebrtc/p2p/base/stun_port.cc | 38 +- third_party/libwebrtc/p2p/base/stun_port.h | 11 +- .../libwebrtc/p2p/base/stun_port_unittest.cc | 40 +- third_party/libwebrtc/p2p/base/stun_request.cc | 25 +- third_party/libwebrtc/p2p/base/stun_request.h | 7 + .../libwebrtc/p2p/base/stun_request_unittest.cc | 4 +- third_party/libwebrtc/p2p/base/stun_server.cc | 27 +- third_party/libwebrtc/p2p/base/stun_server.h | 14 +- .../libwebrtc/p2p/base/stun_server_unittest.cc | 9 +- third_party/libwebrtc/p2p/base/tcp_port.cc | 30 +- third_party/libwebrtc/p2p/base/tcp_port.h | 11 +- third_party/libwebrtc/p2p/base/test_stun_server.cc | 19 +- third_party/libwebrtc/p2p/base/test_stun_server.h | 16 +- third_party/libwebrtc/p2p/base/turn_port.cc | 51 +- third_party/libwebrtc/p2p/base/turn_port.h | 11 +- .../libwebrtc/p2p/base/turn_port_unittest.cc | 31 +- third_party/libwebrtc/p2p/base/turn_server.cc | 79 +- third_party/libwebrtc/p2p/base/turn_server.h | 29 +- .../libwebrtc/p2p/client/basic_port_allocator.cc | 22 +- .../libwebrtc/p2p/client/basic_port_allocator.h | 8 +- .../p2p/client/basic_port_allocator_unittest.cc | 4 +- .../libwebrtc/p2p/stunprober/stun_prober.cc | 34 +- third_party/libwebrtc/p2p/stunprober/stun_prober.h | 2 - .../p2p/stunprober/stun_prober_unittest.cc | 14 +- third_party/libwebrtc/pc/BUILD.gn | 50 +- third_party/libwebrtc/pc/audio_rtp_receiver.cc | 2 +- third_party/libwebrtc/pc/audio_rtp_receiver.h | 3 +- .../libwebrtc/pc/audio_rtp_receiver_unittest.cc | 2 +- third_party/libwebrtc/pc/audio_track.h | 2 +- third_party/libwebrtc/pc/channel.cc | 30 +- third_party/libwebrtc/pc/channel_unittest.cc | 28 +- third_party/libwebrtc/pc/connection_context.cc | 21 +- third_party/libwebrtc/pc/connection_context.h | 21 +- .../pc/data_channel_controller_unittest.cc | 2 +- .../libwebrtc/pc/data_channel_integrationtest.cc | 10 +- third_party/libwebrtc/pc/data_channel_unittest.cc | 17 +- third_party/libwebrtc/pc/dtls_srtp_transport.h | 9 - .../libwebrtc/pc/ice_server_parsing_unittest.cc | 7 +- third_party/libwebrtc/pc/ice_transport_unittest.cc | 2 +- .../libwebrtc/pc/jsep_transport_controller.cc | 228 +- .../libwebrtc/pc/jsep_transport_controller.h | 52 +- .../pc/jsep_transport_controller_unittest.cc | 591 +- third_party/libwebrtc/pc/legacy_stats_collector.cc | 12 +- third_party/libwebrtc/pc/legacy_stats_collector.h | 6 +- third_party/libwebrtc/pc/media_factory.h | 45 + third_party/libwebrtc/pc/media_session.cc | 865 +- third_party/libwebrtc/pc/media_session.h | 43 +- third_party/libwebrtc/pc/media_session_unittest.cc | 852 +- third_party/libwebrtc/pc/media_stream_unittest.cc | 10 +- third_party/libwebrtc/pc/peer_connection.cc | 94 +- third_party/libwebrtc/pc/peer_connection.h | 29 +- .../pc/peer_connection_crypto_unittest.cc | 2 +- .../pc/peer_connection_data_channel_unittest.cc | 7 +- .../peer_connection_encodings_integrationtest.cc | 214 +- .../libwebrtc/pc/peer_connection_factory.cc | 76 +- third_party/libwebrtc/pc/peer_connection_factory.h | 9 +- .../libwebrtc/pc/peer_connection_factory_proxy.h | 4 +- .../pc/peer_connection_factory_unittest.cc | 218 +- .../pc/peer_connection_field_trial_tests.cc | 23 +- .../peer_connection_header_extension_unittest.cc | 17 +- .../pc/peer_connection_histogram_unittest.cc | 128 +- .../libwebrtc/pc/peer_connection_ice_unittest.cc | 6 +- .../pc/peer_connection_integrationtest.cc | 376 +- .../pc/peer_connection_interface_unittest.cc | 235 +- .../libwebrtc/pc/peer_connection_jsep_unittest.cc | 12 +- .../libwebrtc/pc/peer_connection_media_unittest.cc | 71 +- .../libwebrtc/pc/peer_connection_rampup_tests.cc | 2 +- .../libwebrtc/pc/peer_connection_rtp_unittest.cc | 14 +- .../pc/peer_connection_signaling_unittest.cc | 32 +- .../pc/peer_connection_simulcast_unittest.cc | 2 +- .../pc/peer_connection_svc_integrationtest.cc | 77 +- .../libwebrtc/pc/peer_connection_wrapper.cc | 3 +- third_party/libwebrtc/pc/rtc_stats_collector.cc | 4 +- third_party/libwebrtc/pc/rtc_stats_collector.h | 2 +- .../libwebrtc/pc/rtc_stats_collector_unittest.cc | 25 +- .../libwebrtc/pc/rtc_stats_traversal_unittest.cc | 2 +- third_party/libwebrtc/pc/rtp_sender.cc | 16 +- third_party/libwebrtc/pc/rtp_sender.h | 4 +- .../libwebrtc/pc/rtp_sender_receiver_unittest.cc | 80 +- third_party/libwebrtc/pc/rtp_transceiver.cc | 6 +- third_party/libwebrtc/pc/rtp_transceiver.h | 10 +- .../libwebrtc/pc/rtp_transceiver_unittest.cc | 19 +- third_party/libwebrtc/pc/rtp_transport.cc | 19 +- third_party/libwebrtc/pc/rtp_transport.h | 2 + third_party/libwebrtc/pc/rtp_transport_internal.h | 4 +- third_party/libwebrtc/pc/rtp_transport_unittest.cc | 24 + third_party/libwebrtc/pc/sctp_transport.h | 2 +- third_party/libwebrtc/pc/sctp_utils.cc | 2 +- third_party/libwebrtc/pc/sctp_utils_unittest.cc | 4 +- third_party/libwebrtc/pc/sdp_offer_answer.cc | 105 +- third_party/libwebrtc/pc/sdp_offer_answer.h | 4 +- .../libwebrtc/pc/sdp_offer_answer_unittest.cc | 23 +- .../pc/slow_peer_connection_integration_test.cc | 18 +- third_party/libwebrtc/pc/srtp_session.cc | 6 + third_party/libwebrtc/pc/srtp_session.h | 8 + third_party/libwebrtc/pc/srtp_session_unittest.cc | 32 + third_party/libwebrtc/pc/srtp_transport.cc | 95 +- third_party/libwebrtc/pc/srtp_transport.h | 7 +- .../libwebrtc/pc/srtp_transport_unittest.cc | 64 +- .../libwebrtc/pc/test/android_test_initializer.cc | 2 +- third_party/libwebrtc/pc/test/enable_fake_media.cc | 63 + third_party/libwebrtc/pc/test/enable_fake_media.h | 38 + .../libwebrtc/pc/test/fake_peer_connection_base.h | 2 +- .../pc/test/fake_peer_connection_for_stats.h | 16 +- .../libwebrtc/pc/test/fake_periodic_video_source.h | 4 +- .../libwebrtc/pc/test/integration_test_helpers.cc | 2 +- .../libwebrtc/pc/test/integration_test_helpers.h | 290 +- .../pc/test/mock_peer_connection_observers.h | 19 +- .../libwebrtc/pc/test/rtp_transport_test_util.h | 17 +- third_party/libwebrtc/pc/test/svc_e2e_tests.cc | 42 +- .../libwebrtc/pc/video_rtp_receiver_unittest.cc | 2 +- .../pc/video_rtp_track_source_unittest.cc | 4 +- third_party/libwebrtc/pc/video_track.h | 2 +- .../libwebrtc/pc/video_track_source_proxy.h | 2 +- third_party/libwebrtc/pc/webrtc_sdp.cc | 8 +- third_party/libwebrtc/pc/webrtc_sdp_unittest.cc | 21 +- third_party/libwebrtc/rtc_base/BUILD.gn | 49 +- .../rtc_base/async_dns_resolver_gn/moz.build | 5 - .../libwebrtc/rtc_base/async_packet_socket.cc | 37 + .../libwebrtc/rtc_base/async_packet_socket.h | 22 + .../rtc_base/async_packet_socket_gn/moz.build | 7 - .../rtc_base/async_packet_socket_unittest.cc | 110 + third_party/libwebrtc/rtc_base/async_resolver.cc | 239 - third_party/libwebrtc/rtc_base/async_resolver.h | 80 - .../libwebrtc/rtc_base/async_resolver_interface.cc | 19 - .../libwebrtc/rtc_base/async_resolver_interface.h | 55 - .../rtc_base/async_resolver_interface_gn/moz.build | 233 - third_party/libwebrtc/rtc_base/async_tcp_socket.cc | 44 +- third_party/libwebrtc/rtc_base/async_tcp_socket.h | 7 +- third_party/libwebrtc/rtc_base/async_udp_socket.cc | 4 +- .../rtc_base/audio_format_to_string_gn/moz.build | 5 - .../libwebrtc/rtc_base/bit_buffer_gn/moz.build | 5 - .../rtc_base/bitrate_tracker_gn/moz.build | 5 - .../rtc_base/bitstream_reader_gn/moz.build | 5 - third_party/libwebrtc/rtc_base/buffer_gn/moz.build | 7 - third_party/libwebrtc/rtc_base/byte_buffer.cc | 54 +- third_party/libwebrtc/rtc_base/byte_buffer.h | 78 +- .../libwebrtc/rtc_base/byte_buffer_gn/moz.build | 5 - .../libwebrtc/rtc_base/byte_buffer_unittest.cc | 59 +- .../libwebrtc/rtc_base/byte_order_gn/moz.build | 7 - third_party/libwebrtc/rtc_base/checks_gn/moz.build | 5 - .../rtc_base/compile_assert_c_gn/moz.build | 7 - .../flat_containers_internal_gn/moz.build | 5 - .../rtc_base/containers/flat_map_gn/moz.build | 7 - .../rtc_base/containers/flat_set_gn/moz.build | 7 - .../libwebrtc/rtc_base/copy_on_write_buffer.h | 2 + .../rtc_base/copy_on_write_buffer_gn/moz.build | 5 - .../rtc_base/copy_on_write_buffer_unittest.cc | 12 + .../rtc_base/criticalsection_gn/moz.build | 5 - .../libwebrtc/rtc_base/divide_round_gn/moz.build | 7 - third_party/libwebrtc/rtc_base/dscp_gn/moz.build | 7 - .../libwebrtc/rtc_base/event_tracer_gn/moz.build | 5 - .../experiments/alr_experiment_gn/moz.build | 5 - .../balanced_degradation_settings_gn/moz.build | 5 - .../bandwidth_quality_scaler_settings_gn/moz.build | 5 - .../experiments/cpu_speed_experiment_gn/moz.build | 5 - .../experiments/encoder_info_settings_gn/moz.build | 5 - .../experiments/field_trial_parser_gn/moz.build | 5 - .../moz.build | 5 - .../min_video_bitrate_experiment_gn/moz.build | 5 - .../moz.build | 5 - .../quality_rampup_experiment_gn/moz.build | 5 - .../quality_scaler_settings_gn/moz.build | 5 - .../quality_scaling_experiment_gn/moz.build | 5 - .../experiments/rate_control_settings_gn/moz.build | 5 - .../experiments/rtt_mult_experiment_gn/moz.build | 5 - .../stable_target_rate_experiment_gn/moz.build | 5 - .../rtc_base/frequency_tracker_gn/moz.build | 5 - .../libwebrtc/rtc_base/gtest_prod_gn/moz.build | 7 - .../histogram_percentile_counter_gn/moz.build | 5 - .../rtc_base/ifaddrs_android_gn/moz.build | 5 - .../libwebrtc/rtc_base/ignore_wundef_gn/moz.build | 7 - .../libwebrtc/rtc_base/ip_address_gn/moz.build | 5 - .../libwebrtc/rtc_base/logging_gn/moz.build | 5 - .../libwebrtc/rtc_base/macromagic_gn/moz.build | 7 - .../rtc_base/memory/aligned_malloc_gn/moz.build | 5 - .../libwebrtc/rtc_base/mod_ops_gn/moz.build | 7 - .../rtc_base/moving_max_counter_gn/moz.build | 7 - third_party/libwebrtc/rtc_base/nat_unittest.cc | 72 +- .../libwebrtc/rtc_base/net_helpers_gn/moz.build | 5 - third_party/libwebrtc/rtc_base/network/BUILD.gn | 2 + .../libwebrtc/rtc_base/network/received_packet.cc | 21 +- .../libwebrtc/rtc_base/network/received_packet.h | 18 +- .../rtc_base/network/sent_packet_gn/moz.build | 5 - .../rtc_base/network_constants_gn/moz.build | 5 - .../libwebrtc/rtc_base/network_route_gn/moz.build | 5 - .../rtc_base/null_socket_server_gn/moz.build | 5 - .../libwebrtc/rtc_base/one_time_event_gn/moz.build | 7 - third_party/libwebrtc/rtc_base/openssl_adapter.cc | 20 +- third_party/libwebrtc/rtc_base/openssl_adapter.h | 8 - .../libwebrtc/rtc_base/openssl_adapter_unittest.cc | 15 - .../libwebrtc/rtc_base/openssl_stream_adapter.cc | 51 +- .../libwebrtc/rtc_base/openssl_stream_adapter.h | 9 - .../libwebrtc/rtc_base/physical_socket_server.h | 2 - .../rtc_base/platform_thread_gn/moz.build | 5 - .../rtc_base/platform_thread_types_gn/moz.build | 5 - .../libwebrtc/rtc_base/protobuf_utils_gn/moz.build | 7 - .../libwebrtc/rtc_base/race_checker_gn/moz.build | 5 - third_party/libwebrtc/rtc_base/random_gn/moz.build | 5 - .../libwebrtc/rtc_base/rate_limiter_gn/moz.build | 5 - .../rtc_base/rate_statistics_gn/moz.build | 5 - .../libwebrtc/rtc_base/rate_tracker_gn/moz.build | 5 - third_party/libwebrtc/rtc_base/ref_count.h | 55 +- .../libwebrtc/rtc_base/refcount_gn/moz.build | 7 - .../rtc_base/rolling_accumulator_gn/moz.build | 7 - .../libwebrtc/rtc_base/rtc_event_gn/moz.build | 5 - .../libwebrtc/rtc_base/rtc_numerics_gn/moz.build | 5 - .../libwebrtc/rtc_base/rtc_task_queue_gn/moz.build | 5 - .../libwebrtc/rtc_base/safe_compare_gn/moz.build | 7 - .../rtc_base/safe_conversions_gn/moz.build | 7 - .../libwebrtc/rtc_base/safe_minmax_gn/moz.build | 7 - .../libwebrtc/rtc_base/sample_counter_gn/moz.build | 5 - .../libwebrtc/rtc_base/sanitizer_gn/moz.build | 7 - .../libwebrtc/rtc_base/server_socket_adapters.cc | 3 +- third_party/libwebrtc/rtc_base/socket_adapters.cc | 3 +- .../libwebrtc/rtc_base/socket_address_gn/moz.build | 5 - .../libwebrtc/rtc_base/socket_factory_gn/moz.build | 7 - third_party/libwebrtc/rtc_base/socket_gn/moz.build | 5 - .../libwebrtc/rtc_base/socket_server_gn/moz.build | 7 - third_party/libwebrtc/rtc_base/socket_unittest.cc | 6 +- third_party/libwebrtc/rtc_base/ssl_gn/moz.build | 7 - .../rtc_base/ssl_stream_adapter_unittest.cc | 188 +- third_party/libwebrtc/rtc_base/strings/str_join.h | 56 + .../rtc_base/strings/str_join_unittest.cc | 45 + .../libwebrtc/rtc_base/stringutils_gn/moz.build | 5 - .../libwebrtc/rtc_base/swap_queue_gn/moz.build | 7 - .../rtc_base/synchronization/mutex_gn/moz.build | 7 - .../sequence_checker_internal_gn/moz.build | 5 - .../rtc_base/synchronization/yield_gn/moz.build | 5 - .../synchronization/yield_policy_gn/moz.build | 5 - .../libwebrtc/rtc_base/system/arch_gn/moz.build | 7 - .../rtc_base/system/asm_defines_gn/moz.build | 1 - .../rtc_base/system/file_wrapper_gn/moz.build | 5 - .../rtc_base/system/ignore_warnings_gn/moz.build | 7 - .../libwebrtc/rtc_base/system/inline_gn/moz.build | 7 - .../rtc_base/system/no_unique_address_gn/moz.build | 7 - .../rtc_base/system/rtc_export_gn/moz.build | 7 - .../libwebrtc/rtc_base/system/unused_gn/moz.build | 7 - .../warn_current_thread_is_deadlocked_gn/moz.build | 7 - .../task_utils/repeating_task_gn/moz.build | 5 - third_party/libwebrtc/rtc_base/test_client.cc | 55 +- third_party/libwebrtc/rtc_base/test_client.h | 25 +- third_party/libwebrtc/rtc_base/test_echo_server.h | 13 +- .../third_party/base64/base64_gn/moz.build | 5 - .../third_party/sigslot/sigslot_gn/moz.build | 5 - .../libwebrtc/rtc_base/threading_gn/moz.build | 6 - .../libwebrtc/rtc_base/timeutils_gn/moz.build | 5 - .../libwebrtc/rtc_base/type_traits_gn/moz.build | 7 - .../rtc_base/unique_id_generator_gn/moz.build | 7 - .../rtc_base/units/unit_base_gn/moz.build | 7 - .../libwebrtc/rtc_base/virtual_socket_server.cc | 1 + .../libwebrtc/rtc_base/weak_ptr_gn/moz.build | 5 - .../libwebrtc/rtc_base/zero_memory_gn/moz.build | 5 - third_party/libwebrtc/rtc_tools/BUILD.gn | 17 +- .../libwebrtc/rtc_tools/network_tester/BUILD.gn | 2 +- .../rtc_tools/network_tester/config_reader.h | 3 - .../rtc_tools/network_tester/packet_logger.h | 4 - .../rtc_tools/network_tester/packet_sender.h | 3 - .../libwebrtc/rtc_tools/network_tester/server.cc | 1 + .../rtc_tools/network_tester/test_controller.h | 5 +- .../rtc_tools/rtc_event_log_visualizer/plot_base.h | 4 +- .../rtc_event_log_visualizer/plot_protobuf.cc | 43 - .../rtc_event_log_visualizer/plot_protobuf.h | 40 - .../rtc_event_log_visualizer/plot_python.cc | 46 - .../rtc_event_log_visualizer/plot_python.h | 39 - .../rtc_tools/rtp_generator/rtp_generator.cc | 11 +- .../rtc_tools/rtp_generator/rtp_generator.h | 6 +- .../libwebrtc/rtc_tools/unpack_aecdump/unpack.cc | 4 +- .../libwebrtc/rtc_tools/video_file_reader.h | 4 +- third_party/libwebrtc/rtc_tools/video_replay.cc | 41 +- third_party/libwebrtc/sdk/BUILD.gn | 12 +- .../sdk/android/api/org/webrtc/EglRenderer.java | 4 - .../android/api/org/webrtc/RenderSynchronizer.java | 11 + .../src/java/org/webrtc/HardwareVideoEncoder.java | 2 +- .../api/peerconnection/RTCPeerConnectionFactory.mm | 22 +- .../sdk/objc/components/audio/RTCAudioSession.mm | 6 +- .../system_wrappers/denormal_disabler_gn/moz.build | 5 - .../system_wrappers/field_trial_gn/moz.build | 5 - .../libwebrtc/system_wrappers/metrics_gn/moz.build | 5 - .../system_wrappers/system_wrappers_gn/moz.build | 5 - third_party/libwebrtc/test/BUILD.gn | 55 +- third_party/libwebrtc/test/call_test.cc | 72 +- third_party/libwebrtc/test/call_test.h | 17 +- third_party/libwebrtc/test/fuzzers/BUILD.gn | 1 + .../fuzzers/forward_error_correction_fuzzer.cc | 6 +- .../fuzzers/rtp_frame_reference_finder_fuzzer.cc | 2 +- .../libwebrtc/test/fuzzers/stun_parser_fuzzer.cc | 3 +- third_party/libwebrtc/test/fuzzers/utils/BUILD.gn | 4 +- .../libwebrtc/test/fuzzers/utils/rtp_replayer.cc | 11 +- .../libwebrtc/test/fuzzers/utils/rtp_replayer.h | 1 - third_party/libwebrtc/test/network/BUILD.gn | 3 +- .../libwebrtc/test/network/emulated_turn_server.cc | 102 +- .../libwebrtc/test/network/emulated_turn_server.h | 3 +- .../test/network/network_emulation_pc_unittest.cc | 14 +- third_party/libwebrtc/test/pc/e2e/BUILD.gn | 3 +- .../libwebrtc/test/pc/e2e/test_peer_factory.cc | 50 +- .../test/peer_scenario/peer_scenario_client.cc | 24 +- .../test/peer_scenario/scenario_connection.cc | 20 +- .../libwebrtc/test/rtp_test_utils_gn/moz.build | 7 - third_party/libwebrtc/test/scenario/BUILD.gn | 4 +- .../libwebrtc/test/scenario/audio_stream.cc | 2 - third_party/libwebrtc/test/scenario/call_client.cc | 53 +- third_party/libwebrtc/test/scenario/call_client.h | 6 +- .../libwebrtc/test/scenario/scenario_config.h | 1 - .../libwebrtc/test/scenario/video_stream.cc | 18 +- third_party/libwebrtc/test/video_codec_tester.cc | 1324 + third_party/libwebrtc/test/video_codec_tester.h | 227 + .../libwebrtc/test/video_codec_tester_unittest.cc | 513 + .../absl/algorithm/algorithm_gn/moz.build | 7 - .../absl/algorithm/container_gn/moz.build | 7 - .../abseil-cpp/absl/base/atomic_hook_gn/moz.build | 7 - .../absl/base/base_internal_gn/moz.build | 7 - .../abseil-cpp/absl/base/config_gn/moz.build | 7 - .../abseil-cpp/absl/base/core_headers_gn/moz.build | 7 - .../abseil-cpp/absl/base/log_severity_gn/moz.build | 5 - .../abseil-cpp/absl/base/nullability_gn/moz.build | 7 - .../absl/base/raw_logging_internal_gn/moz.build | 5 - .../absl/base/throw_delegate_gn/moz.build | 5 - .../abseil-cpp/absl/cleanup/cleanup_gn/moz.build | 7 - .../absl/cleanup/cleanup_internal_gn/moz.build | 7 - .../absl/container/compressed_tuple_gn/moz.build | 7 - .../absl/container/inlined_vector_gn/moz.build | 7 - .../container/inlined_vector_internal_gn/moz.build | 7 - .../absl/functional/any_invocable_gn/moz.build | 7 - .../absl/functional/bind_front_gn/moz.build | 7 - .../abseil-cpp/absl/memory/memory_gn/moz.build | 7 - .../abseil-cpp/absl/meta/type_traits_gn/moz.build | 7 - .../abseil-cpp/absl/numeric/bits_gn/moz.build | 7 - .../abseil-cpp/absl/numeric/int128_gn/moz.build | 5 - .../absl/strings/string_view_gn/moz.build | 5 - .../abseil-cpp/absl/strings/strings_gn/moz.build | 5 - .../absl/types/bad_optional_access_gn/moz.build | 5 - .../absl/types/bad_variant_access_gn/moz.build | 5 - .../abseil-cpp/absl/types/optional_gn/moz.build | 7 - .../abseil-cpp/absl/types/span_gn/moz.build | 7 - .../abseil-cpp/absl/types/variant_gn/moz.build | 7 - .../abseil-cpp/absl/utility/utility_gn/moz.build | 7 - .../third_party/libyuv/libyuv_gn/moz.build | 7 - .../libwebrtc/third_party/pffft/pffft_gn/moz.build | 5 - .../third_party/rnnoise/rnn_vad_gn/moz.build | 5 - third_party/libwebrtc/tools/clang/OWNERS | 2 - .../tools/clang/plugins/ChromeClassTester.cpp | 294 - .../tools/clang/plugins/ChromeClassTester.h | 84 - .../tools/clang/plugins/FindBadConstructs.cpp | 435 - third_party/libwebrtc/tools/clang/plugins/Makefile | 19 - third_party/libwebrtc/tools/clang/plugins/OWNERS | 1 - .../libwebrtc/tools/clang/plugins/README.chromium | 4 - .../tools/clang/plugins/tests/base_refcounted.cpp | 72 - .../tools/clang/plugins/tests/base_refcounted.h | 121 - .../tools/clang/plugins/tests/base_refcounted.txt | 23 - .../tools/clang/plugins/tests/inline_copy_ctor.cpp | 5 - .../tools/clang/plugins/tests/inline_copy_ctor.h | 12 - .../tools/clang/plugins/tests/inline_copy_ctor.txt | 5 - .../tools/clang/plugins/tests/inline_ctor.cpp | 25 - .../tools/clang/plugins/tests/inline_ctor.h | 21 - .../tools/clang/plugins/tests/inline_ctor.txt | 8 - .../tools/clang/plugins/tests/missing_ctor.cpp | 23 - .../tools/clang/plugins/tests/missing_ctor.h | 19 - .../tools/clang/plugins/tests/missing_ctor.txt | 6 - .../plugins/tests/nested_class_inline_ctor.cpp | 5 - .../clang/plugins/tests/nested_class_inline_ctor.h | 22 - .../plugins/tests/nested_class_inline_ctor.txt | 8 - .../clang/plugins/tests/overridden_methods.cpp | 38 - .../tools/clang/plugins/tests/overridden_methods.h | 54 - .../clang/plugins/tests/overridden_methods.txt | 20 - .../libwebrtc/tools/clang/plugins/tests/test.sh | 72 - .../tools/clang/plugins/tests/virtual_methods.cpp | 36 - .../tools/clang/plugins/tests/virtual_methods.h | 39 - .../tools/clang/plugins/tests/virtual_methods.txt | 8 - .../libwebrtc/tools/clang/scripts/package.sh | 87 - .../libwebrtc/tools/clang/scripts/plugin_flags.sh | 24 - .../libwebrtc/tools/clang/scripts/update.py | 34 - .../libwebrtc/tools/clang/scripts/update.sh | 286 - .../libwebrtc/tools_webrtc/mb/mb_config.pyl | 67 +- .../tools_webrtc/remove_extra_namespace.py | 93 + third_party/libwebrtc/video/BUILD.gn | 3 +- .../video/adaptation/video_adaptation_gn/moz.build | 5 - .../video/config/encoder_config_gn/moz.build | 5 - .../video/config/streams_config_gn/moz.build | 5 - .../video/decode_synchronizer_gn/moz.build | 5 - .../video/end_to_end_tests/multi_stream_tester.cc | 18 +- .../video/end_to_end_tests/network_state_tests.cc | 2 +- .../video/end_to_end_tests/stats_tests.cc | 8 +- .../libwebrtc/video/frame_cadence_adapter.cc | 154 +- .../libwebrtc/video/frame_cadence_adapter.h | 17 +- .../video/frame_cadence_adapter_gn/moz.build | 5 - .../video/frame_cadence_adapter_unittest.cc | 145 +- .../video/frame_decode_scheduler_gn/moz.build | 7 - .../video/frame_decode_timing_gn/moz.build | 5 - .../video/frame_dumping_decoder_gn/moz.build | 5 - .../video/frame_dumping_encoder_gn/moz.build | 5 - .../render/incoming_video_stream_gn/moz.build | 5 - .../video/render/video_render_frames_gn/moz.build | 5 - .../libwebrtc/video/send_statistics_proxy.cc | 7 + .../task_queue_frame_decode_scheduler_gn/moz.build | 5 - .../video/unique_timestamp_counter_gn/moz.build | 5 - third_party/libwebrtc/video/video_gn/moz.build | 5 - third_party/libwebrtc/video/video_quality_test.cc | 51 +- .../libwebrtc/video/video_receive_stream2.cc | 21 +- .../moz.build | 5 - .../video_stream_buffer_controller_gn/moz.build | 5 - .../libwebrtc/video/video_stream_encoder.cc | 115 +- third_party/libwebrtc/video/video_stream_encoder.h | 69 +- .../video/video_stream_encoder_impl_gn/moz.build | 5 - .../video_stream_encoder_interface_gn/moz.build | 7 - .../video/video_stream_encoder_observer.h | 1 + .../video/video_stream_encoder_unittest.cc | 64 +- third_party/libwebrtc/webrtc.gni | 8 +- third_party/libwebrtc/webrtc_gn/moz.build | 7 - third_party/libwebrtc/webrtc_lib_link_test.cc | 21 +- third_party/moz.build | 3 - .../python/Mako/Mako-1.1.2.dist-info/AUTHORS | 13 + .../python/Mako/Mako-1.1.2.dist-info/LICENSE | 19 + .../python/Mako/Mako-1.1.2.dist-info/METADATA | 82 + .../python/Mako/Mako-1.1.2.dist-info/RECORD | 33 + third_party/python/Mako/Mako-1.1.2.dist-info/WHEEL | 6 + .../Mako/Mako-1.1.2.dist-info/entry_points.txt | 20 + .../python/Mako/Mako-1.1.2.dist-info/top_level.txt | 1 + third_party/python/Mako/mako/__init__.py | 8 + third_party/python/Mako/mako/_ast_util.py | 716 + third_party/python/Mako/mako/ast.py | 205 + third_party/python/Mako/mako/cache.py | 240 + third_party/python/Mako/mako/cmd.py | 103 + third_party/python/Mako/mako/codegen.py | 1318 + third_party/python/Mako/mako/compat.py | 166 + third_party/python/Mako/mako/exceptions.py | 430 + third_party/python/Mako/mako/ext/__init__.py | 0 third_party/python/Mako/mako/ext/autohandler.py | 70 + third_party/python/Mako/mako/ext/babelplugin.py | 58 + third_party/python/Mako/mako/ext/beaker_cache.py | 82 + third_party/python/Mako/mako/ext/extract.py | 125 + third_party/python/Mako/mako/ext/linguaplugin.py | 57 + third_party/python/Mako/mako/ext/preprocessors.py | 20 + third_party/python/Mako/mako/ext/pygmentplugin.py | 157 + third_party/python/Mako/mako/ext/turbogears.py | 61 + third_party/python/Mako/mako/filters.py | 219 + third_party/python/Mako/mako/lexer.py | 490 + third_party/python/Mako/mako/lookup.py | 372 + third_party/python/Mako/mako/parsetree.py | 665 + third_party/python/Mako/mako/pygen.py | 305 + third_party/python/Mako/mako/pyparser.py | 242 + third_party/python/Mako/mako/runtime.py | 970 + third_party/python/Mako/mako/template.py | 780 + third_party/python/Mako/mako/util.py | 400 + .../glean_parser-11.0.1.dist-info/AUTHORS.md | 17 - .../glean_parser-11.0.1.dist-info/LICENSE | 373 - .../glean_parser-11.0.1.dist-info/METADATA | 769 - .../glean_parser-11.0.1.dist-info/RECORD | 44 - .../glean_parser-11.0.1.dist-info/WHEEL | 5 - .../glean_parser-11.0.1.dist-info/entry_points.txt | 2 - .../glean_parser-11.0.1.dist-info/top_level.txt | 1 - .../glean_parser-13.0.0.dist-info/AUTHORS.md | 17 + .../glean_parser-13.0.0.dist-info/LICENSE | 373 + .../glean_parser-13.0.0.dist-info/METADATA | 786 + .../glean_parser-13.0.0.dist-info/RECORD | 48 + .../glean_parser-13.0.0.dist-info/WHEEL | 5 + .../glean_parser-13.0.0.dist-info/entry_points.txt | 2 + .../glean_parser-13.0.0.dist-info/top_level.txt | 1 + .../python/glean_parser/glean_parser/go_server.py | 145 + .../python/glean_parser/glean_parser/metrics.py | 60 + .../python/glean_parser/glean_parser/pings.py | 4 + .../glean_parser/glean_parser/python_server.py | 130 + .../python/glean_parser/glean_parser/rust.py | 23 +- .../glean_parser/schemas/metrics.2-0-0.schema.yaml | 13 + .../glean_parser/schemas/pings.2-0-0.schema.yaml | 15 + .../glean_parser/templates/go_server.jinja2 | 225 + .../glean_parser/templates/python_server.jinja2 | 194 + .../glean_parser/templates/rust.jinja2 | 49 +- .../glean_parser/templates/swift.jinja2 | 1 + .../python/glean_parser/glean_parser/translate.py | 4 + .../python/glean_parser/glean_parser/util.py | 1 + third_party/python/poetry.lock | 28 +- third_party/python/requirements.in | 3 +- third_party/python/requirements.txt | 10 +- .../include/rlbox_wasm2c_sandbox.hpp | 30 +- third_party/rust/aa-stroke/.cargo-checksum.json | 2 +- third_party/rust/aa-stroke/src/bezierflattener.rs | 40 +- third_party/rust/aa-stroke/src/lib.rs | 56 +- third_party/rust/ahash/.cargo-checksum.json | 2 +- third_party/rust/ahash/Cargo.toml | 61 +- third_party/rust/ahash/build.rs | 4 +- third_party/rust/ahash/src/aes_hash.rs | 13 +- third_party/rust/ahash/src/hash_quality_test.rs | 36 +- third_party/rust/ahash/src/random_state.rs | 7 +- third_party/rust/cc/.cargo-checksum.json | 2 +- third_party/rust/cc/Cargo.lock | 110 - third_party/rust/cc/Cargo.toml | 22 +- third_party/rust/cc/README.md | 212 +- third_party/rust/cc/src/bin/gcc-shim.rs | 48 - third_party/rust/cc/src/com.rs | 155 - third_party/rust/cc/src/command_helpers.rs | 433 + third_party/rust/cc/src/lib.rs | 2676 +- third_party/rust/cc/src/parallel/async_executor.rs | 118 + third_party/rust/cc/src/parallel/job_token.rs | 255 + third_party/rust/cc/src/parallel/mod.rs | 20 + third_party/rust/cc/src/parallel/stderr.rs | 90 + third_party/rust/cc/src/registry.rs | 231 - third_party/rust/cc/src/setup_config.rs | 283 - third_party/rust/cc/src/tool.rs | 399 + third_party/rust/cc/src/vs_instances.rs | 199 - third_party/rust/cc/src/winapi.rs | 218 - third_party/rust/cc/src/windows/com.rs | 157 + third_party/rust/cc/src/windows/find_tools.rs | 1100 + third_party/rust/cc/src/windows/mod.rs | 20 + third_party/rust/cc/src/windows/registry.rs | 191 + third_party/rust/cc/src/windows/setup_config.rs | 283 + third_party/rust/cc/src/windows/vs_instances.rs | 199 + third_party/rust/cc/src/windows/winapi.rs | 146 + third_party/rust/cc/src/windows/windows_sys.rs | 223 + third_party/rust/cc/src/windows_registry.rs | 900 - third_party/rust/cc/tests/cc_env.rs | 118 - third_party/rust/cc/tests/cflags.rs | 15 - third_party/rust/cc/tests/cxxflags.rs | 15 - third_party/rust/cc/tests/support/mod.rs | 172 - third_party/rust/cc/tests/test.rs | 461 - .../rust/document-features/.cargo-checksum.json | 1 + third_party/rust/document-features/CHANGELOG.md | 44 + third_party/rust/document-features/Cargo.toml | 40 + third_party/rust/document-features/LICENSE-APACHE | 73 + third_party/rust/document-features/LICENSE-MIT | 19 + third_party/rust/document-features/README.md | 43 + third_party/rust/document-features/lib.rs | 877 + third_party/rust/document-features/rustfmt.toml | 1 + .../rust/document-features/tests/self-doc.rs | 37 + third_party/rust/glean-core/.cargo-checksum.json | 2 +- third_party/rust/glean-core/Cargo.toml | 4 +- third_party/rust/glean-core/src/core/mod.rs | 6 +- third_party/rust/glean-core/src/glean.udl | 10 +- third_party/rust/glean-core/src/internal_pings.rs | 4 + third_party/rust/glean-core/src/lib.rs | 38 +- third_party/rust/glean-core/src/lib_unit_tests.rs | 4 +- third_party/rust/glean-core/src/metrics/boolean.rs | 12 +- third_party/rust/glean-core/src/metrics/counter.rs | 12 +- .../glean-core/src/metrics/custom_distribution.rs | 38 +- .../rust/glean-core/src/metrics/datetime.rs | 10 +- .../rust/glean-core/src/metrics/denominator.rs | 11 +- third_party/rust/glean-core/src/metrics/event.rs | 7 +- .../rust/glean-core/src/metrics/experiment.rs | 9 + third_party/rust/glean-core/src/metrics/labeled.rs | 2 - .../glean-core/src/metrics/memory_distribution.rs | 11 +- third_party/rust/glean-core/src/metrics/mod.rs | 11 +- .../rust/glean-core/src/metrics/numerator.rs | 8 +- third_party/rust/glean-core/src/metrics/object.rs | 135 + third_party/rust/glean-core/src/metrics/ping.rs | 28 +- .../rust/glean-core/src/metrics/quantity.rs | 11 +- third_party/rust/glean-core/src/metrics/rate.rs | 11 +- third_party/rust/glean-core/src/metrics/string.rs | 11 +- .../rust/glean-core/src/metrics/string_list.rs | 11 +- third_party/rust/glean-core/src/metrics/text.rs | 11 +- .../rust/glean-core/src/metrics/timespan.rs | 11 +- .../glean-core/src/metrics/timing_distribution.rs | 43 +- third_party/rust/glean-core/src/metrics/url.rs | 11 +- third_party/rust/glean-core/src/metrics/uuid.rs | 11 +- third_party/rust/glean-core/src/ping/mod.rs | 44 +- .../glean-core/src/traits/custom_distribution.rs | 16 + third_party/rust/glean-core/src/traits/mod.rs | 6 + third_party/rust/glean-core/src/traits/object.rs | 53 + .../glean-core/src/traits/timing_distribution.rs | 25 + .../rust/glean-core/src/upload/directory.rs | 78 +- third_party/rust/glean-core/src/upload/mod.rs | 343 +- third_party/rust/glean-core/src/upload/request.rs | 37 +- .../rust/glean-core/tests/custom_distribution.rs | 20 +- third_party/rust/glean-core/tests/event.rs | 2 + third_party/rust/glean-core/tests/object.rs | 104 + third_party/rust/glean-core/tests/ping.rs | 14 +- third_party/rust/glean-core/tests/ping_maker.rs | 26 +- .../rust/glean-core/tests/timing_distribution.rs | 6 +- third_party/rust/glean/.cargo-checksum.json | 2 +- third_party/rust/glean/Cargo.toml | 34 +- third_party/rust/glean/src/common_test.rs | 1 + third_party/rust/glean/src/configuration.rs | 2 +- third_party/rust/glean/src/lib.rs | 2 +- third_party/rust/glean/src/net/http_uploader.rs | 11 +- third_party/rust/glean/src/net/mod.rs | 25 +- third_party/rust/glean/src/private/mod.rs | 2 + third_party/rust/glean/src/private/object.rs | 192 + third_party/rust/glean/src/private/ping.rs | 2 + third_party/rust/glean/src/test.rs | 215 +- third_party/rust/glean/tests/init_fails.rs | 2 +- third_party/rust/glean/tests/never_init.rs | 2 +- third_party/rust/glean/tests/no_time_to_init.rs | 2 +- third_party/rust/glean/tests/schema.rs | 13 +- third_party/rust/glean/tests/simple.rs | 2 +- third_party/rust/glean/tests/upload_timing.rs | 10 +- third_party/rust/glslopt/.cargo-checksum.json | 2 +- third_party/rust/glslopt/Cargo.toml | 21 +- .../glslopt/glsl-optimizer/include/c99_alloca.h | 49 - .../rust/glslopt/glsl-optimizer/include/c99_math.h | 211 - .../src/compiler/glsl/lower_instructions.cpp | 2 +- .../glslopt/glsl-optimizer/src/util/rounding.h | 3 +- .../rust/glslopt/glsl-optimizer/src/util/u_math.h | 3 +- third_party/rust/litrs/.cargo-checksum.json | 1 + third_party/rust/litrs/CHANGELOG.md | 103 + third_party/rust/litrs/Cargo.toml | 51 + third_party/rust/litrs/LICENSE-APACHE | 176 + third_party/rust/litrs/LICENSE-MIT | 25 + third_party/rust/litrs/README.md | 88 + third_party/rust/litrs/src/bool/mod.rs | 55 + third_party/rust/litrs/src/bool/tests.rs | 48 + third_party/rust/litrs/src/byte/mod.rs | 107 + third_party/rust/litrs/src/byte/tests.rs | 188 + third_party/rust/litrs/src/bytestr/mod.rs | 126 + third_party/rust/litrs/src/bytestr/tests.rs | 224 + third_party/rust/litrs/src/char/mod.rs | 105 + third_party/rust/litrs/src/char/tests.rs | 227 + third_party/rust/litrs/src/err.rs | 371 + third_party/rust/litrs/src/escape.rs | 262 + third_party/rust/litrs/src/float/mod.rs | 257 + third_party/rust/litrs/src/float/tests.rs | 253 + third_party/rust/litrs/src/impls.rs | 401 + third_party/rust/litrs/src/integer/mod.rs | 356 + third_party/rust/litrs/src/integer/tests.rs | 357 + third_party/rust/litrs/src/lib.rs | 370 + third_party/rust/litrs/src/parse.rs | 125 + third_party/rust/litrs/src/string/mod.rs | 125 + third_party/rust/litrs/src/string/tests.rs | 278 + third_party/rust/litrs/src/test_util.rs | 128 + third_party/rust/litrs/src/tests.rs | 349 + third_party/rust/naga/.cargo-checksum.json | 2 +- third_party/rust/naga/Cargo.toml | 4 +- third_party/rust/naga/src/back/glsl/features.rs | 53 +- third_party/rust/naga/src/back/glsl/mod.rs | 194 +- third_party/rust/naga/src/back/hlsl/conv.rs | 12 +- third_party/rust/naga/src/back/hlsl/help.rs | 150 +- third_party/rust/naga/src/back/hlsl/keywords.rs | 2 + third_party/rust/naga/src/back/hlsl/mod.rs | 2 + third_party/rust/naga/src/back/hlsl/storage.rs | 84 +- third_party/rust/naga/src/back/hlsl/writer.rs | 183 +- third_party/rust/naga/src/back/msl/keywords.rs | 2 + third_party/rust/naga/src/back/msl/mod.rs | 15 +- third_party/rust/naga/src/back/msl/writer.rs | 200 +- third_party/rust/naga/src/back/spv/block.rs | 242 +- third_party/rust/naga/src/back/spv/writer.rs | 3 + third_party/rust/naga/src/back/wgsl/writer.rs | 25 +- third_party/rust/naga/src/front/glsl/functions.rs | 2 +- .../rust/naga/src/front/glsl/parser/functions.rs | 2 +- third_party/rust/naga/src/front/spv/function.rs | 464 +- third_party/rust/naga/src/front/spv/mod.rs | 68 +- third_party/rust/naga/src/front/wgsl/error.rs | 2 +- third_party/rust/naga/src/front/wgsl/lower/mod.rs | 2 + third_party/rust/naga/src/front/wgsl/parse/conv.rs | 8 + .../rust/naga/src/front/wgsl/parse/number.rs | 16 + third_party/rust/naga/src/front/wgsl/tests.rs | 1 + third_party/rust/naga/src/keywords/wgsl.rs | 2 + third_party/rust/naga/src/lib.rs | 27 +- .../rust/naga/src/proc/constant_evaluator.rs | 242 +- third_party/rust/naga/src/proc/mod.rs | 19 +- third_party/rust/naga/src/valid/expression.rs | 65 +- third_party/rust/naga/src/valid/mod.rs | 4 +- third_party/rust/naga/src/valid/type.rs | 44 +- third_party/rust/neqo-common/.cargo-checksum.json | 2 +- third_party/rust/neqo-common/Cargo.toml | 52 +- third_party/rust/neqo-common/build.rs | 6 + third_party/rust/neqo-common/src/codec.rs | 6 +- third_party/rust/neqo-common/src/datagram.rs | 6 + third_party/rust/neqo-common/src/event.rs | 2 +- third_party/rust/neqo-common/src/hrtime.rs | 5 +- third_party/rust/neqo-common/src/lib.rs | 5 +- third_party/rust/neqo-common/src/log.rs | 24 +- third_party/rust/neqo-common/src/qlog.rs | 3 +- third_party/rust/neqo-common/src/timer.rs | 62 +- third_party/rust/neqo-common/src/tos.rs | 37 +- third_party/rust/neqo-common/src/udp.rs | 222 + third_party/rust/neqo-common/tests/log.rs | 3 - third_party/rust/neqo-crypto/.cargo-checksum.json | 2 +- third_party/rust/neqo-crypto/Cargo.toml | 40 +- third_party/rust/neqo-crypto/build.rs | 22 +- third_party/rust/neqo-crypto/src/aead.rs | 1 - third_party/rust/neqo-crypto/src/agent.rs | 12 +- third_party/rust/neqo-crypto/src/agentio.rs | 9 +- third_party/rust/neqo-crypto/src/cert.rs | 18 +- third_party/rust/neqo-crypto/src/ech.rs | 10 +- third_party/rust/neqo-crypto/src/ext.rs | 4 +- third_party/rust/neqo-crypto/src/hkdf.rs | 23 +- third_party/rust/neqo-crypto/src/hp.rs | 8 +- third_party/rust/neqo-crypto/src/lib.rs | 132 +- third_party/rust/neqo-crypto/src/once.rs | 44 - third_party/rust/neqo-crypto/src/p11.rs | 114 +- third_party/rust/neqo-crypto/src/replay.rs | 1 - third_party/rust/neqo-crypto/src/selfencrypt.rs | 2 +- third_party/rust/neqo-crypto/src/time.rs | 74 +- third_party/rust/neqo-crypto/tests/aead.rs | 7 +- third_party/rust/neqo-crypto/tests/agent.rs | 9 +- third_party/rust/neqo-crypto/tests/ext.rs | 7 +- third_party/rust/neqo-crypto/tests/handshake.rs | 9 + third_party/rust/neqo-crypto/tests/hkdf.rs | 7 +- third_party/rust/neqo-crypto/tests/hp.rs | 7 +- third_party/rust/neqo-crypto/tests/init.rs | 7 +- third_party/rust/neqo-crypto/tests/selfencrypt.rs | 8 +- third_party/rust/neqo-http3/.cargo-checksum.json | 2 +- third_party/rust/neqo-http3/Cargo.toml | 45 +- third_party/rust/neqo-http3/src/client_events.rs | 6 +- third_party/rust/neqo-http3/src/connection.rs | 3 - .../rust/neqo-http3/src/connection_client.rs | 33 +- .../rust/neqo-http3/src/control_stream_local.rs | 5 +- .../tests/webtransport/datagrams.rs | 2 - .../extended_connect/tests/webtransport/mod.rs | 6 +- .../extended_connect/webtransport_session.rs | 20 +- .../extended_connect/webtransport_streams.rs | 10 - third_party/rust/neqo-http3/src/frames/hframe.rs | 7 +- third_party/rust/neqo-http3/src/frames/reader.rs | 2 +- third_party/rust/neqo-http3/src/frames/wtframe.rs | 2 - third_party/rust/neqo-http3/src/headers_checks.rs | 2 - third_party/rust/neqo-http3/src/lib.rs | 29 +- third_party/rust/neqo-http3/src/priority.rs | 8 +- third_party/rust/neqo-http3/src/push_controller.rs | 2 +- third_party/rust/neqo-http3/src/qlog.rs | 7 +- third_party/rust/neqo-http3/src/recv_message.rs | 8 +- third_party/rust/neqo-http3/src/send_message.rs | 18 +- third_party/rust/neqo-http3/src/server.rs | 6 +- third_party/rust/neqo-http3/src/server_events.rs | 1 - third_party/rust/neqo-http3/tests/priority.rs | 6 +- third_party/rust/neqo-http3/tests/send_message.rs | 31 +- third_party/rust/neqo-http3/tests/webtransport.rs | 6 +- third_party/rust/neqo-qpack/.cargo-checksum.json | 2 +- third_party/rust/neqo-qpack/Cargo.toml | 30 +- third_party/rust/neqo-qpack/src/decoder.rs | 4 +- third_party/rust/neqo-qpack/src/encoder.rs | 5 +- third_party/rust/neqo-qpack/src/huffman.rs | 6 +- .../rust/neqo-qpack/src/huffman_decode_helper.rs | 9 +- third_party/rust/neqo-qpack/src/lib.rs | 6 +- third_party/rust/neqo-qpack/src/qpack_send_buf.rs | 2 +- third_party/rust/neqo-qpack/src/reader.rs | 19 +- third_party/rust/neqo-qpack/src/table.rs | 2 +- .../rust/neqo-transport/.cargo-checksum.json | 2 +- third_party/rust/neqo-transport/Cargo.toml | 59 +- .../rust/neqo-transport/benches/range_tracker.rs | 50 + .../neqo-transport/benches/rx_stream_orderer.rs | 6 + .../rust/neqo-transport/benches/transfer.rs | 70 + third_party/rust/neqo-transport/src/ackrate.rs | 3 +- third_party/rust/neqo-transport/src/addr_valid.rs | 46 +- .../rust/neqo-transport/src/cc/classic_cc.rs | 6 +- third_party/rust/neqo-transport/src/cc/cubic.rs | 3 - third_party/rust/neqo-transport/src/cc/mod.rs | 1 - third_party/rust/neqo-transport/src/cc/new_reno.rs | 1 - .../rust/neqo-transport/src/cc/tests/cubic.rs | 1 - .../rust/neqo-transport/src/cc/tests/mod.rs | 1 + .../rust/neqo-transport/src/cc/tests/new_reno.rs | 1 - third_party/rust/neqo-transport/src/cid.rs | 98 +- .../rust/neqo-transport/src/connection/dump.rs | 4 +- .../rust/neqo-transport/src/connection/mod.rs | 210 +- .../rust/neqo-transport/src/connection/params.rs | 39 +- .../rust/neqo-transport/src/connection/state.rs | 19 +- .../neqo-transport/src/connection/tests/ackrate.rs | 4 +- .../rust/neqo-transport/src/connection/tests/cc.rs | 4 +- .../neqo-transport/src/connection/tests/close.rs | 2 +- .../src/connection/tests/datagram.rs | 2 +- .../neqo-transport/src/connection/tests/fuzzing.rs | 2 - .../src/connection/tests/handshake.rs | 70 +- .../neqo-transport/src/connection/tests/idle.rs | 34 +- .../neqo-transport/src/connection/tests/keys.rs | 2 +- .../src/connection/tests/migration.rs | 108 +- .../neqo-transport/src/connection/tests/mod.rs | 13 +- .../src/connection/tests/priority.rs | 4 +- .../src/connection/tests/resumption.rs | 8 +- .../neqo-transport/src/connection/tests/stream.rs | 2 +- .../rust/neqo-transport/src/connection/tests/vn.rs | 2 +- .../neqo-transport/src/connection/tests/zerortt.rs | 2 +- third_party/rust/neqo-transport/src/crypto.rs | 34 +- third_party/rust/neqo-transport/src/events.rs | 9 +- third_party/rust/neqo-transport/src/fc.rs | 3 +- third_party/rust/neqo-transport/src/frame.rs | 14 +- third_party/rust/neqo-transport/src/lib.rs | 8 +- third_party/rust/neqo-transport/src/pace.rs | 2 - third_party/rust/neqo-transport/src/packet/mod.rs | 41 +- .../rust/neqo-transport/src/packet/retry.rs | 2 - third_party/rust/neqo-transport/src/path.rs | 12 +- third_party/rust/neqo-transport/src/qlog.rs | 10 +- .../rust/neqo-transport/src/quic_datagrams.rs | 4 +- third_party/rust/neqo-transport/src/recovery.rs | 15 +- third_party/rust/neqo-transport/src/recv_stream.rs | 82 +- third_party/rust/neqo-transport/src/rtt.rs | 2 - third_party/rust/neqo-transport/src/send_stream.rs | 904 +- third_party/rust/neqo-transport/src/sender.rs | 2 +- third_party/rust/neqo-transport/src/server.rs | 59 +- third_party/rust/neqo-transport/src/stats.rs | 1 - third_party/rust/neqo-transport/src/stream_id.rs | 14 + third_party/rust/neqo-transport/src/streams.rs | 49 +- third_party/rust/neqo-transport/src/tparams.rs | 80 +- third_party/rust/neqo-transport/src/tracking.rs | 166 +- third_party/rust/neqo-transport/src/version.rs | 19 +- .../rust/neqo-transport/tests/common/mod.rs | 6 +- .../rust/neqo-transport/tests/conn_vectors.rs | 4 +- .../rust/neqo-transport/tests/connection.rs | 8 +- third_party/rust/neqo-transport/tests/network.rs | 117 +- third_party/rust/neqo-transport/tests/retry.rs | 5 +- third_party/rust/neqo-transport/tests/server.rs | 7 +- .../rust/neqo-transport/tests/sim/connection.rs | 315 - third_party/rust/neqo-transport/tests/sim/delay.rs | 102 - third_party/rust/neqo-transport/tests/sim/drop.rs | 75 - third_party/rust/neqo-transport/tests/sim/mod.rs | 232 - third_party/rust/neqo-transport/tests/sim/net.rs | 111 - third_party/rust/neqo-transport/tests/sim/rng.rs | 81 - .../rust/neqo-transport/tests/sim/taildrop.rs | 188 - third_party/rust/qlog/.cargo-checksum.json | 2 +- third_party/rust/qlog/Cargo.toml | 8 +- third_party/rust/qlog/src/events/h3.rs | 3 +- third_party/rust/serde/.cargo-checksum.json | 2 +- third_party/rust/serde/Cargo.toml | 4 +- third_party/rust/serde/README.md | 6 +- third_party/rust/serde/src/de/mod.rs | 61 +- third_party/rust/serde/src/de/value.rs | 4 +- third_party/rust/serde/src/lib.rs | 15 +- third_party/rust/serde_derive/.cargo-checksum.json | 2 +- third_party/rust/serde_derive/Cargo.toml | 14 +- third_party/rust/serde_derive/README.md | 6 +- third_party/rust/serde_derive/src/lib.rs | 2 +- third_party/rust/smallvec/.cargo-checksum.json | 2 +- third_party/rust/smallvec/Cargo.toml | 2 +- third_party/rust/smallvec/benches/bench.rs | 4 +- third_party/rust/smallvec/src/lib.rs | 66 +- third_party/rust/smallvec/src/tests.rs | 21 +- .../rust/thiserror-impl/.cargo-checksum.json | 2 +- third_party/rust/thiserror-impl/Cargo.toml | 2 +- third_party/rust/thiserror-impl/src/attr.rs | 34 +- third_party/rust/thiserror-impl/src/fmt.rs | 3 + third_party/rust/thiserror/.cargo-checksum.json | 2 +- third_party/rust/thiserror/Cargo.toml | 4 +- third_party/rust/thiserror/src/lib.rs | 2 +- third_party/rust/thiserror/tests/test_display.rs | 57 +- .../rust/thiserror/tests/ui/no-display.stderr | 3 + .../tests/ui/source-enum-not-error.stderr | 8 +- .../ui/source-enum-unnamed-field-not-error.stderr | 8 +- .../tests/ui/source-struct-not-error.stderr | 9 +- .../source-struct-unnamed-field-not-error.stderr | 9 +- .../tests/ui/transparent-enum-not-error.stderr | 5 +- ...transparent-enum-unnamed-field-not-error.stderr | 5 +- .../tests/ui/transparent-struct-not-error.stderr | 5 +- ...ansparent-struct-unnamed-field-not-error.stderr | 5 +- third_party/rust/unicode-bidi/.appveyor.yml | 19 + third_party/rust/unicode-bidi/.cargo-checksum.json | 2 +- .../rust/unicode-bidi/.github/workflows/main.yml | 49 + third_party/rust/unicode-bidi/.rustfmt.toml | 1 + third_party/rust/unicode-bidi/Cargo.lock | 175 + third_party/rust/unicode-bidi/Cargo.toml | 10 +- third_party/rust/unicode-bidi/src/char_data/mod.rs | 5 +- .../rust/unicode-bidi/src/char_data/tables.rs | 4 +- third_party/rust/unicode-bidi/src/deprecated.rs | 9 +- third_party/rust/unicode-bidi/src/explicit.rs | 129 +- third_party/rust/unicode-bidi/src/implicit.rs | 93 +- third_party/rust/unicode-bidi/src/level.rs | 15 +- third_party/rust/unicode-bidi/src/lib.rs | 129 +- third_party/rust/unicode-bidi/src/prepare.rs | 266 +- third_party/rust/unicode-bidi/src/utf16.rs | 36 +- third_party/rust/wgpu-core/.cargo-checksum.json | 2 +- third_party/rust/wgpu-core/Cargo.toml | 1 + third_party/rust/wgpu-core/src/binding_model.rs | 26 +- third_party/rust/wgpu-core/src/command/bundle.rs | 294 +- third_party/rust/wgpu-core/src/command/clear.rs | 45 +- third_party/rust/wgpu-core/src/command/compute.rs | 35 +- third_party/rust/wgpu-core/src/command/draw.rs | 120 +- third_party/rust/wgpu-core/src/command/mod.rs | 5 +- third_party/rust/wgpu-core/src/command/query.rs | 9 +- third_party/rust/wgpu-core/src/command/render.rs | 54 +- third_party/rust/wgpu-core/src/device/global.rs | 245 +- third_party/rust/wgpu-core/src/device/life.rs | 129 +- third_party/rust/wgpu-core/src/device/queue.rs | 125 +- third_party/rust/wgpu-core/src/device/resource.rs | 204 +- third_party/rust/wgpu-core/src/id.rs | 2 +- third_party/rust/wgpu-core/src/identity.rs | 63 +- third_party/rust/wgpu-core/src/instance.rs | 22 +- third_party/rust/wgpu-core/src/lib.rs | 30 +- third_party/rust/wgpu-core/src/pipeline.rs | 23 +- third_party/rust/wgpu-core/src/present.rs | 43 +- third_party/rust/wgpu-core/src/registry.rs | 9 +- third_party/rust/wgpu-core/src/resource.rs | 38 +- third_party/rust/wgpu-core/src/track/buffer.rs | 65 +- third_party/rust/wgpu-core/src/track/metadata.rs | 11 +- third_party/rust/wgpu-core/src/track/mod.rs | 218 +- third_party/rust/wgpu-core/src/track/stateless.rs | 43 +- third_party/rust/wgpu-core/src/track/texture.rs | 65 +- third_party/rust/wgpu-core/src/validation.rs | 115 +- third_party/rust/wgpu-hal/.cargo-checksum.json | 2 +- third_party/rust/wgpu-hal/Cargo.toml | 14 +- third_party/rust/wgpu-hal/src/auxil/dxgi/result.rs | 18 + third_party/rust/wgpu-hal/src/dx12/adapter.rs | 25 + third_party/rust/wgpu-hal/src/dx12/command.rs | 7 + third_party/rust/wgpu-hal/src/dx12/device.rs | 6 +- third_party/rust/wgpu-hal/src/dx12/mod.rs | 3 + .../rust/wgpu-hal/src/dx12/shader_compilation.rs | 4 +- third_party/rust/wgpu-hal/src/gles/adapter.rs | 73 +- third_party/rust/wgpu-hal/src/gles/command.rs | 7 + third_party/rust/wgpu-hal/src/gles/device.rs | 5 +- third_party/rust/wgpu-hal/src/gles/egl.rs | 69 +- third_party/rust/wgpu-hal/src/gles/mod.rs | 53 +- third_party/rust/wgpu-hal/src/gles/queue.rs | 8 +- third_party/rust/wgpu-hal/src/gles/wgl.rs | 3 + third_party/rust/wgpu-hal/src/lib.rs | 97 +- third_party/rust/wgpu-hal/src/metal/adapter.rs | 16 +- third_party/rust/wgpu-hal/src/metal/mod.rs | 1 + third_party/rust/wgpu-hal/src/vulkan/adapter.rs | 18 +- third_party/rust/wgpu-hal/src/vulkan/instance.rs | 183 +- third_party/rust/wgpu-hal/src/vulkan/mod.rs | 34 +- third_party/rust/wgpu-types/.cargo-checksum.json | 2 +- third_party/rust/wgpu-types/Cargo.toml | 2 +- third_party/rust/wgpu-types/src/lib.rs | 409 +- third_party/sqlite3/ext/fts5.c | 13 +- third_party/sqlite3/moz.yaml | 4 +- third_party/sqlite3/src/VERSION.txt | 2 +- third_party/sqlite3/src/sqlite3.c | 291 +- third_party/sqlite3/src/sqlite3.h | 8 +- third_party/wayland-proxy/wayland-proxy.cpp | 151 +- third_party/wayland-proxy/wayland-proxy.h | 5 +- .../xsimd/arch/generic/xsimd_generic_math.hpp | 59 +- .../xsimd/include/xsimd/arch/xsimd_avx2.hpp | 38 + .../xsimd/include/xsimd/arch/xsimd_avx512bw.hpp | 38 + .../xsimd/include/xsimd/arch/xsimd_i8mm_neon64.hpp | 17 + third_party/xsimd/include/xsimd/arch/xsimd_isa.hpp | 4 + .../xsimd/include/xsimd/arch/xsimd_neon.hpp | 68 +- .../xsimd/include/xsimd/arch/xsimd_neon64.hpp | 85 +- .../xsimd/include/xsimd/arch/xsimd_scalar.hpp | 33 + .../xsimd/include/xsimd/arch/xsimd_sse2.hpp | 42 + .../xsimd/include/xsimd/arch/xsimd_wasm.hpp | 40 + .../xsimd/include/xsimd/config/xsimd_arch.hpp | 2 +- .../xsimd/include/xsimd/config/xsimd_config.hpp | 11 + .../xsimd/include/xsimd/config/xsimd_cpuid.hpp | 9 + .../include/xsimd/types/xsimd_all_registers.hpp | 2 + .../xsimd/include/xsimd/types/xsimd_api.hpp | 30 + .../xsimd/types/xsimd_i8mm_neon64_register.hpp | 46 + third_party/xsimd/moz.yaml | 4 +- 2021 files changed, 94157 insertions(+), 74276 deletions(-) delete mode 100644 third_party/WinToast/LICENSE delete mode 100644 third_party/WinToast/moz-check-system-shortcut.patch delete mode 100644 third_party/WinToast/moz-disable-create-shortcut.patch delete mode 100644 third_party/WinToast/moz.yaml delete mode 100644 third_party/WinToast/upstream-add-toast-scenario.patch delete mode 100644 third_party/WinToast/wintoastlib.cpp delete mode 100644 third_party/WinToast/wintoastlib.h create mode 100644 third_party/aom/av1/common/arm/highbd_warp_plane_sve.c create mode 100644 third_party/gemmology/kernels/GemmologyEngineNeon64I8mm.cpp delete mode 100644 third_party/jpeg-xl/lib/jxl/fast_dct.cc delete mode 100644 third_party/jpeg-xl/lib/jxl/fast_dct.h create mode 100644 third_party/jpeg-xl/lib/jxl/image_ops.cc create mode 100644 third_party/jpeg-xl/lib/nothing.cc delete mode 100644 third_party/libwebrtc/api/async_resolver_factory.h create mode 100644 third_party/libwebrtc/api/enable_media.cc create mode 100644 third_party/libwebrtc/api/enable_media.h create mode 100644 third_party/libwebrtc/api/enable_media_with_defaults.cc create mode 100644 third_party/libwebrtc/api/enable_media_with_defaults.h create mode 100644 third_party/libwebrtc/api/environment/BUILD.gn create mode 100644 third_party/libwebrtc/api/environment/OWNERS create mode 100644 third_party/libwebrtc/api/environment/environment.h create mode 100644 third_party/libwebrtc/api/environment/environment_factory.cc create mode 100644 third_party/libwebrtc/api/environment/environment_factory.h create mode 100644 third_party/libwebrtc/api/environment/environment_gn/moz.build create mode 100644 third_party/libwebrtc/api/environment/environment_unittest.cc delete mode 100644 third_party/libwebrtc/api/metronome/metronome.cc create mode 100644 third_party/libwebrtc/api/ref_count.h create mode 100644 third_party/libwebrtc/api/ref_count_gn/moz.build delete mode 100644 third_party/libwebrtc/api/test/create_video_codec_tester.cc delete mode 100644 third_party/libwebrtc/api/test/create_video_codec_tester.h create mode 100644 third_party/libwebrtc/api/test/mock_transformable_frame.h delete mode 100644 third_party/libwebrtc/api/test/video_codec_stats.cc delete mode 100644 third_party/libwebrtc/api/test/video_codec_stats.h delete mode 100644 third_party/libwebrtc/api/test/video_codec_tester.h delete mode 100644 third_party/libwebrtc/api/wrapping_async_dns_resolver.h delete mode 100644 third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.cc delete mode 100644 third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.h create mode 100644 third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h create mode 100644 third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.cc create mode 100644 third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.h create mode 100644 third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265_unittest.cc delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.cc delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.h delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer_unittest.cc delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.cc delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.h delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl_unittest.cc delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.cc delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.h delete mode 100644 third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl_unittest.cc create mode 100644 third_party/libwebrtc/moz-patch-stack/058bfe3ae3.no-op-cherry-pick-msg create mode 100644 third_party/libwebrtc/moz-patch-stack/334e9133dc.no-op-cherry-pick-msg delete mode 100644 third_party/libwebrtc/moz-patch-stack/a9d497b52d.no-op-cherry-pick-msg delete mode 100644 third_party/libwebrtc/net/dcsctp/common/str_join.h delete mode 100644 third_party/libwebrtc/net/dcsctp/common/str_join_test.cc delete mode 100644 third_party/libwebrtc/p2p/base/mock_async_resolver.h create mode 100644 third_party/libwebrtc/pc/media_factory.h create mode 100644 third_party/libwebrtc/pc/test/enable_fake_media.cc create mode 100644 third_party/libwebrtc/pc/test/enable_fake_media.h create mode 100644 third_party/libwebrtc/rtc_base/async_packet_socket_unittest.cc delete mode 100644 third_party/libwebrtc/rtc_base/async_resolver.cc delete mode 100644 third_party/libwebrtc/rtc_base/async_resolver.h delete mode 100644 third_party/libwebrtc/rtc_base/async_resolver_interface.cc delete mode 100644 third_party/libwebrtc/rtc_base/async_resolver_interface.h delete mode 100644 third_party/libwebrtc/rtc_base/async_resolver_interface_gn/moz.build create mode 100644 third_party/libwebrtc/rtc_base/strings/str_join.h create mode 100644 third_party/libwebrtc/rtc_base/strings/str_join_unittest.cc delete mode 100644 third_party/libwebrtc/rtc_tools/rtc_event_log_visualizer/plot_protobuf.cc delete mode 100644 third_party/libwebrtc/rtc_tools/rtc_event_log_visualizer/plot_protobuf.h delete mode 100644 third_party/libwebrtc/rtc_tools/rtc_event_log_visualizer/plot_python.cc delete mode 100644 third_party/libwebrtc/rtc_tools/rtc_event_log_visualizer/plot_python.h create mode 100644 third_party/libwebrtc/test/video_codec_tester.cc create mode 100644 third_party/libwebrtc/test/video_codec_tester.h create mode 100644 third_party/libwebrtc/test/video_codec_tester_unittest.cc delete mode 100644 third_party/libwebrtc/tools/clang/OWNERS delete mode 100644 third_party/libwebrtc/tools/clang/plugins/ChromeClassTester.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/ChromeClassTester.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/FindBadConstructs.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/Makefile delete mode 100644 third_party/libwebrtc/tools/clang/plugins/OWNERS delete mode 100644 third_party/libwebrtc/tools/clang/plugins/README.chromium delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/base_refcounted.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/base_refcounted.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/base_refcounted.txt delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/inline_copy_ctor.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/inline_copy_ctor.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/inline_copy_ctor.txt delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/inline_ctor.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/inline_ctor.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/inline_ctor.txt delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/missing_ctor.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/missing_ctor.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/missing_ctor.txt delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/nested_class_inline_ctor.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/nested_class_inline_ctor.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/nested_class_inline_ctor.txt delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/overridden_methods.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/overridden_methods.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/overridden_methods.txt delete mode 100755 third_party/libwebrtc/tools/clang/plugins/tests/test.sh delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/virtual_methods.cpp delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/virtual_methods.h delete mode 100644 third_party/libwebrtc/tools/clang/plugins/tests/virtual_methods.txt delete mode 100755 third_party/libwebrtc/tools/clang/scripts/package.sh delete mode 100755 third_party/libwebrtc/tools/clang/scripts/plugin_flags.sh delete mode 100755 third_party/libwebrtc/tools/clang/scripts/update.py delete mode 100755 third_party/libwebrtc/tools/clang/scripts/update.sh create mode 100755 third_party/libwebrtc/tools_webrtc/remove_extra_namespace.py create mode 100644 third_party/python/Mako/Mako-1.1.2.dist-info/AUTHORS create mode 100644 third_party/python/Mako/Mako-1.1.2.dist-info/LICENSE create mode 100644 third_party/python/Mako/Mako-1.1.2.dist-info/METADATA create mode 100644 third_party/python/Mako/Mako-1.1.2.dist-info/RECORD create mode 100644 third_party/python/Mako/Mako-1.1.2.dist-info/WHEEL create mode 100644 third_party/python/Mako/Mako-1.1.2.dist-info/entry_points.txt create mode 100644 third_party/python/Mako/Mako-1.1.2.dist-info/top_level.txt create mode 100644 third_party/python/Mako/mako/__init__.py create mode 100644 third_party/python/Mako/mako/_ast_util.py create mode 100644 third_party/python/Mako/mako/ast.py create mode 100644 third_party/python/Mako/mako/cache.py create mode 100644 third_party/python/Mako/mako/cmd.py create mode 100644 third_party/python/Mako/mako/codegen.py create mode 100644 third_party/python/Mako/mako/compat.py create mode 100644 third_party/python/Mako/mako/exceptions.py create mode 100644 third_party/python/Mako/mako/ext/__init__.py create mode 100644 third_party/python/Mako/mako/ext/autohandler.py create mode 100644 third_party/python/Mako/mako/ext/babelplugin.py create mode 100644 third_party/python/Mako/mako/ext/beaker_cache.py create mode 100644 third_party/python/Mako/mako/ext/extract.py create mode 100644 third_party/python/Mako/mako/ext/linguaplugin.py create mode 100644 third_party/python/Mako/mako/ext/preprocessors.py create mode 100644 third_party/python/Mako/mako/ext/pygmentplugin.py create mode 100644 third_party/python/Mako/mako/ext/turbogears.py create mode 100644 third_party/python/Mako/mako/filters.py create mode 100644 third_party/python/Mako/mako/lexer.py create mode 100644 third_party/python/Mako/mako/lookup.py create mode 100644 third_party/python/Mako/mako/parsetree.py create mode 100644 third_party/python/Mako/mako/pygen.py create mode 100644 third_party/python/Mako/mako/pyparser.py create mode 100644 third_party/python/Mako/mako/runtime.py create mode 100644 third_party/python/Mako/mako/template.py create mode 100644 third_party/python/Mako/mako/util.py delete mode 100644 third_party/python/glean_parser/glean_parser-11.0.1.dist-info/AUTHORS.md delete mode 100644 third_party/python/glean_parser/glean_parser-11.0.1.dist-info/LICENSE delete mode 100644 third_party/python/glean_parser/glean_parser-11.0.1.dist-info/METADATA delete mode 100644 third_party/python/glean_parser/glean_parser-11.0.1.dist-info/RECORD delete mode 100644 third_party/python/glean_parser/glean_parser-11.0.1.dist-info/WHEEL delete mode 100644 third_party/python/glean_parser/glean_parser-11.0.1.dist-info/entry_points.txt delete mode 100644 third_party/python/glean_parser/glean_parser-11.0.1.dist-info/top_level.txt create mode 100644 third_party/python/glean_parser/glean_parser-13.0.0.dist-info/AUTHORS.md create mode 100644 third_party/python/glean_parser/glean_parser-13.0.0.dist-info/LICENSE create mode 100644 third_party/python/glean_parser/glean_parser-13.0.0.dist-info/METADATA create mode 100644 third_party/python/glean_parser/glean_parser-13.0.0.dist-info/RECORD create mode 100644 third_party/python/glean_parser/glean_parser-13.0.0.dist-info/WHEEL create mode 100644 third_party/python/glean_parser/glean_parser-13.0.0.dist-info/entry_points.txt create mode 100644 third_party/python/glean_parser/glean_parser-13.0.0.dist-info/top_level.txt create mode 100644 third_party/python/glean_parser/glean_parser/go_server.py create mode 100644 third_party/python/glean_parser/glean_parser/python_server.py create mode 100644 third_party/python/glean_parser/glean_parser/templates/go_server.jinja2 create mode 100644 third_party/python/glean_parser/glean_parser/templates/python_server.jinja2 delete mode 100644 third_party/rust/cc/Cargo.lock delete mode 100644 third_party/rust/cc/src/bin/gcc-shim.rs delete mode 100644 third_party/rust/cc/src/com.rs create mode 100644 third_party/rust/cc/src/command_helpers.rs create mode 100644 third_party/rust/cc/src/parallel/async_executor.rs create mode 100644 third_party/rust/cc/src/parallel/job_token.rs create mode 100644 third_party/rust/cc/src/parallel/mod.rs create mode 100644 third_party/rust/cc/src/parallel/stderr.rs delete mode 100644 third_party/rust/cc/src/registry.rs delete mode 100644 third_party/rust/cc/src/setup_config.rs create mode 100644 third_party/rust/cc/src/tool.rs delete mode 100644 third_party/rust/cc/src/vs_instances.rs delete mode 100644 third_party/rust/cc/src/winapi.rs create mode 100644 third_party/rust/cc/src/windows/com.rs create mode 100644 third_party/rust/cc/src/windows/find_tools.rs create mode 100644 third_party/rust/cc/src/windows/mod.rs create mode 100644 third_party/rust/cc/src/windows/registry.rs create mode 100644 third_party/rust/cc/src/windows/setup_config.rs create mode 100644 third_party/rust/cc/src/windows/vs_instances.rs create mode 100644 third_party/rust/cc/src/windows/winapi.rs create mode 100644 third_party/rust/cc/src/windows/windows_sys.rs delete mode 100644 third_party/rust/cc/src/windows_registry.rs delete mode 100644 third_party/rust/cc/tests/cc_env.rs delete mode 100644 third_party/rust/cc/tests/cflags.rs delete mode 100644 third_party/rust/cc/tests/cxxflags.rs delete mode 100644 third_party/rust/cc/tests/support/mod.rs delete mode 100644 third_party/rust/cc/tests/test.rs create mode 100644 third_party/rust/document-features/.cargo-checksum.json create mode 100644 third_party/rust/document-features/CHANGELOG.md create mode 100644 third_party/rust/document-features/Cargo.toml create mode 100644 third_party/rust/document-features/LICENSE-APACHE create mode 100644 third_party/rust/document-features/LICENSE-MIT create mode 100644 third_party/rust/document-features/README.md create mode 100644 third_party/rust/document-features/lib.rs create mode 100644 third_party/rust/document-features/rustfmt.toml create mode 100644 third_party/rust/document-features/tests/self-doc.rs create mode 100644 third_party/rust/glean-core/src/metrics/object.rs create mode 100644 third_party/rust/glean-core/src/traits/object.rs create mode 100644 third_party/rust/glean-core/tests/object.rs create mode 100644 third_party/rust/glean/src/private/object.rs delete mode 100644 third_party/rust/glslopt/glsl-optimizer/include/c99_alloca.h delete mode 100644 third_party/rust/glslopt/glsl-optimizer/include/c99_math.h create mode 100644 third_party/rust/litrs/.cargo-checksum.json create mode 100644 third_party/rust/litrs/CHANGELOG.md create mode 100644 third_party/rust/litrs/Cargo.toml create mode 100644 third_party/rust/litrs/LICENSE-APACHE create mode 100644 third_party/rust/litrs/LICENSE-MIT create mode 100644 third_party/rust/litrs/README.md create mode 100644 third_party/rust/litrs/src/bool/mod.rs create mode 100644 third_party/rust/litrs/src/bool/tests.rs create mode 100644 third_party/rust/litrs/src/byte/mod.rs create mode 100644 third_party/rust/litrs/src/byte/tests.rs create mode 100644 third_party/rust/litrs/src/bytestr/mod.rs create mode 100644 third_party/rust/litrs/src/bytestr/tests.rs create mode 100644 third_party/rust/litrs/src/char/mod.rs create mode 100644 third_party/rust/litrs/src/char/tests.rs create mode 100644 third_party/rust/litrs/src/err.rs create mode 100644 third_party/rust/litrs/src/escape.rs create mode 100644 third_party/rust/litrs/src/float/mod.rs create mode 100644 third_party/rust/litrs/src/float/tests.rs create mode 100644 third_party/rust/litrs/src/impls.rs create mode 100644 third_party/rust/litrs/src/integer/mod.rs create mode 100644 third_party/rust/litrs/src/integer/tests.rs create mode 100644 third_party/rust/litrs/src/lib.rs create mode 100644 third_party/rust/litrs/src/parse.rs create mode 100644 third_party/rust/litrs/src/string/mod.rs create mode 100644 third_party/rust/litrs/src/string/tests.rs create mode 100644 third_party/rust/litrs/src/test_util.rs create mode 100644 third_party/rust/litrs/src/tests.rs create mode 100644 third_party/rust/neqo-common/src/udp.rs delete mode 100644 third_party/rust/neqo-crypto/src/once.rs create mode 100644 third_party/rust/neqo-transport/benches/range_tracker.rs create mode 100644 third_party/rust/neqo-transport/benches/transfer.rs delete mode 100644 third_party/rust/neqo-transport/tests/sim/connection.rs delete mode 100644 third_party/rust/neqo-transport/tests/sim/delay.rs delete mode 100644 third_party/rust/neqo-transport/tests/sim/drop.rs delete mode 100644 third_party/rust/neqo-transport/tests/sim/mod.rs delete mode 100644 third_party/rust/neqo-transport/tests/sim/net.rs delete mode 100644 third_party/rust/neqo-transport/tests/sim/rng.rs delete mode 100644 third_party/rust/neqo-transport/tests/sim/taildrop.rs create mode 100644 third_party/rust/unicode-bidi/.appveyor.yml create mode 100644 third_party/rust/unicode-bidi/.github/workflows/main.yml create mode 100644 third_party/rust/unicode-bidi/.rustfmt.toml create mode 100644 third_party/rust/unicode-bidi/Cargo.lock create mode 100644 third_party/xsimd/include/xsimd/arch/xsimd_i8mm_neon64.hpp create mode 100644 third_party/xsimd/include/xsimd/types/xsimd_i8mm_neon64_register.hpp (limited to 'third_party') diff --git a/third_party/WinToast/LICENSE b/third_party/WinToast/LICENSE deleted file mode 100644 index c3a4fb8868..0000000000 --- a/third_party/WinToast/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 Mohammed Boujemaoui Boulaghmoudi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/third_party/WinToast/moz-check-system-shortcut.patch b/third_party/WinToast/moz-check-system-shortcut.patch deleted file mode 100644 index 84411ae7bc..0000000000 --- a/third_party/WinToast/moz-check-system-shortcut.patch +++ /dev/null @@ -1,81 +0,0 @@ -diff --git a/src/wintoastlib.cpp b/src/wintoastlib.cpp -index 0895ff7..ac8d5cf 100644 ---- a/src/wintoastlib.cpp -+++ b/src/wintoastlib.cpp -@@ -213,8 +213,8 @@ namespace Util { - } - - -- inline HRESULT defaultShellLinksDirectory(_In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) { -- DWORD written = GetEnvironmentVariableW(L"APPDATA", path, nSize); -+ inline HRESULT commonShellLinksDirectory(_In_ const WCHAR* baseEnv, _In_ WCHAR* path, _In_ DWORD nSize) { -+ DWORD written = GetEnvironmentVariableW(baseEnv, path, nSize); - HRESULT hr = written > 0 ? S_OK : E_INVALIDARG; - if (SUCCEEDED(hr)) { - errno_t result = wcscat_s(path, nSize, DEFAULT_SHELL_LINKS_PATH); -@@ -224,8 +224,8 @@ namespace Util { - return hr; - } - -- inline HRESULT defaultShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) { -- HRESULT hr = defaultShellLinksDirectory(path, nSize); -+ inline HRESULT commonShellLinkPath(_In_ const WCHAR* baseEnv, const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize) { -+ HRESULT hr = commonShellLinksDirectory(baseEnv, path, nSize); - if (SUCCEEDED(hr)) { - const std::wstring appLink(appname + DEFAULT_LINK_FORMAT); - errno_t result = wcscat_s(path, nSize, appLink.c_str()); -@@ -235,6 +235,13 @@ namespace Util { - return hr; - } - -+ inline HRESULT defaultUserShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) { -+ return commonShellLinkPath(L"APPDATA", appname, path, nSize); -+ } -+ -+ inline HRESULT defaultSystemShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) { -+ return commonShellLinkPath(L"PROGRAMDATA", appname, path, nSize); -+ } - - inline PCWSTR AsString(ComPtr &xmlDocument) { - HSTRING xml; -@@ -523,12 +530,19 @@ const std::wstring& WinToast::appUserModelId() const { - - HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) { - WCHAR path[MAX_PATH] = { L'\0' }; -- Util::defaultShellLinkPath(_appName, path); -+ Util::defaultUserShellLinkPath(_appName, path); - // Check if the file exist - DWORD attr = GetFileAttributesW(path); - if (attr >= 0xFFFFFFF) { -- DEBUG_MSG("Error, shell link not found. Try to create a new one in: " << path); -- return E_FAIL; -+ // The shortcut may be in the system Start Menu. -+ WCHAR systemPath[MAX_PATH] = { L'\0' }; -+ Util::defaultSystemShellLinkPath(_appName, systemPath); -+ attr = GetFileAttributesW(systemPath); -+ if (attr >= 0xFFFFFFF) { -+ DEBUG_MSG("Error, shell link not found. Try to create a new one in: " << path); -+ return E_FAIL; -+ } -+ wcscpy(path, systemPath); - } - - // Let's load the file as shell link to validate. -@@ -543,7 +557,7 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) { - ComPtr persistFile; - hr = shellLink.As(&persistFile); - if (SUCCEEDED(hr)) { -- hr = persistFile->Load(path, STGM_READWRITE); -+ hr = persistFile->Load(path, STGM_READ); - if (SUCCEEDED(hr)) { - ComPtr propertyStore; - hr = shellLink.As(&propertyStore); -@@ -583,7 +597,7 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) { - HRESULT WinToast::createShellLinkHelper() { - WCHAR exePath[MAX_PATH]{L'\0'}; - WCHAR slPath[MAX_PATH]{L'\0'}; -- Util::defaultShellLinkPath(_appName, slPath); -+ Util::defaultUserShellLinkPath(_appName, slPath); - Util::defaultExecutablePath(exePath); - ComPtr shellLink; - HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink)); diff --git a/third_party/WinToast/moz-disable-create-shortcut.patch b/third_party/WinToast/moz-disable-create-shortcut.patch deleted file mode 100644 index 96ccac2732..0000000000 --- a/third_party/WinToast/moz-disable-create-shortcut.patch +++ /dev/null @@ -1,110 +0,0 @@ -diff --git a/src/wintoastlib.cpp b/src/wintoastlib.cpp -index 0895ff7..52de554 100644 ---- a/src/wintoastlib.cpp -+++ b/src/wintoastlib.cpp -@@ -391,6 +391,10 @@ void WinToast::setAppUserModelId(_In_ const std::wstring& aumi) { - DEBUG_MSG(L"Default App User Model Id: " << _aumi.c_str()); - } - -+void WinToast::setShortcutPolicy(_In_ ShortcutPolicy shortcutPolicy) { -+ _shortcutPolicy = shortcutPolicy; -+} -+ - bool WinToast::isCompatible() { - DllImporter::initialize(); - return !((DllImporter::SetCurrentProcessExplicitAppUserModelID == nullptr) -@@ -492,10 +496,12 @@ bool WinToast::initialize(_Out_ WinToastError* error) { - return false; - } - -- if (createShortcut() < 0) { -- setError(error, WinToastError::ShellLinkNotCreated); -- DEBUG_MSG(L"Error while attaching the AUMI to the current proccess =("); -- return false; -+ if (_shortcutPolicy != SHORTCUT_POLICY_IGNORE) { -+ if (createShortcut() < 0) { -+ setError(error, WinToastError::ShellLinkNotCreated); -+ DEBUG_MSG(L"Error while attaching the AUMI to the current proccess =("); -+ return false; -+ } - } - - if (FAILED(DllImporter::SetCurrentProcessExplicitAppUserModelID(_aumi.c_str()))) { -@@ -555,18 +561,23 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) { - hr = DllImporter::PropVariantToString(appIdPropVar, AUMI, MAX_PATH); - wasChanged = false; - if (FAILED(hr) || _aumi != AUMI) { -- // AUMI Changed for the same app, let's update the current value! =) -- wasChanged = true; -- PropVariantClear(&appIdPropVar); -- hr = InitPropVariantFromString(_aumi.c_str(), &appIdPropVar); -- if (SUCCEEDED(hr)) { -- hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar); -+ if (_shortcutPolicy == SHORTCUT_POLICY_REQUIRE_CREATE) { -+ // AUMI Changed for the same app, let's update the current value! =) -+ wasChanged = true; -+ PropVariantClear(&appIdPropVar); -+ hr = InitPropVariantFromString(_aumi.c_str(), &appIdPropVar); - if (SUCCEEDED(hr)) { -- hr = propertyStore->Commit(); -- if (SUCCEEDED(hr) && SUCCEEDED(persistFile->IsDirty())) { -- hr = persistFile->Save(path, TRUE); -+ hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar); -+ if (SUCCEEDED(hr)) { -+ hr = propertyStore->Commit(); -+ if (SUCCEEDED(hr) && SUCCEEDED(persistFile->IsDirty())) { -+ hr = persistFile->Save(path, TRUE); -+ } - } - } -+ } else { -+ // Not allowed to touch the shortcut to fix the AUMI -+ hr = E_FAIL; - } - } - PropVariantClear(&appIdPropVar); -@@ -581,6 +592,10 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) { - - - HRESULT WinToast::createShellLinkHelper() { -+ if (_shortcutPolicy != SHORTCUT_POLICY_REQUIRE_CREATE) { -+ return E_FAIL; -+ } -+ - WCHAR exePath[MAX_PATH]{L'\0'}; - WCHAR slPath[MAX_PATH]{L'\0'}; - Util::defaultShellLinkPath(_appName, slPath); -diff --git a/src/wintoastlib.h b/src/wintoastlib.h -index 68b1cb1..dc8d745 100644 ---- a/src/wintoastlib.h -+++ b/src/wintoastlib.h -@@ -173,6 +173,16 @@ namespace WinToastLib { - SHORTCUT_CREATE_FAILED = -4 - }; - -+ enum ShortcutPolicy { -+ /* Don't check, create, or modify a shortcut. */ -+ SHORTCUT_POLICY_IGNORE = 0, -+ /* Require a shortcut with matching AUMI, don't create or modify an existing one. */ -+ SHORTCUT_POLICY_REQUIRE_NO_CREATE = 1, -+ /* Require a shortcut with matching AUMI, create if missing, modify if not matching. -+ * This is the default. */ -+ SHORTCUT_POLICY_REQUIRE_CREATE = 2, -+ }; -+ - WinToast(void); - virtual ~WinToast(); - static WinToast* instance(); -@@ -194,10 +204,12 @@ namespace WinToastLib { - const std::wstring& appUserModelId() const; - void setAppUserModelId(_In_ const std::wstring& aumi); - void setAppName(_In_ const std::wstring& appName); -+ void setShortcutPolicy(_In_ ShortcutPolicy policy); - - protected: - bool _isInitialized{false}; - bool _hasCoInitialized{false}; -+ ShortcutPolicy _shortcutPolicy{SHORTCUT_POLICY_REQUIRE_CREATE}; - std::wstring _appName{}; - std::wstring _aumi{}; - std::map> _buffer{}; diff --git a/third_party/WinToast/moz.yaml b/third_party/WinToast/moz.yaml deleted file mode 100644 index 7a27bf29ad..0000000000 --- a/third_party/WinToast/moz.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Version of this schema -schema: 1 - -# Manual Update can be done with: -# cd third_pary/WinToast -# wget https://raw.githubusercontent.com/mohabouje/WinToast/master/src/wintoastlib.cpp -# wget https://raw.githubusercontent.com/mohabouje/WinToast/master/src/wintoastlib.h -# patch -p2 < moz-check-system-shortcut.patch -# patch -p2 < moz-disable-create-shortcut.patch -# patch -p2 < upstream-add-toast-scenario.patch - -bugzilla: - # Bugzilla product and component for this directory and subdirectories - product: Toolkit - component: "General" - -# Document the source of externally hosted code -origin: - - # Short name of the package/library - name: WinToast - - description: WinToast is a lightly library written in C++ which brings a complete integration of the modern toast notifications of Windows 8 & Windows 10. - - # Full URL for the package's homepage/etc - # Usually different from repository url - url: https://github.com/mohabouje/WinToast - - # Human-readable identifier for this version/release - # Generally "version NNN", "tag SSS", "bookmark SSS" - release: commit 09227c72f16ccefc36e9d430dea3b435346dbcbc - - # The package's license, where possible using the mnemonic from - # https://spdx.org/licenses/ - # Multiple licenses can be specified (as a YAML list) - # A "LICENSE" file must exist containing the full license text - license: MIT diff --git a/third_party/WinToast/upstream-add-toast-scenario.patch b/third_party/WinToast/upstream-add-toast-scenario.patch deleted file mode 100644 index 0be8bf878d..0000000000 --- a/third_party/WinToast/upstream-add-toast-scenario.patch +++ /dev/null @@ -1,123 +0,0 @@ -diff --git a/src/wintoastlib.cpp b/src/wintoastlib.cpp -index 3cf5f21..1adfe19 100644 ---- a/src/wintoastlib.cpp -+++ b/src/wintoastlib.cpp -@@ -677,6 +677,10 @@ INT64 WinToast::showToast(_In_ const WinToastTemplate& toast, _In_ IWinToastHan - (toast.duration() == WinToastTemplate::Duration::Short) ? L"short" : L"long"); - } - -+ if (SUCCEEDED(hr)) { -+ hr = addScenarioHelper(xmlDocument.Get(), toast.scenario()); -+ } -+ - } else { - DEBUG_MSG("Modern features (Actions/Sounds/Attributes) not supported in this os version"); - } -@@ -828,6 +832,28 @@ HRESULT WinToast::addDurationHelper(_In_ IXmlDocument *xml, _In_ const std::wstr - return hr; - } - -+HRESULT WinToast::addScenarioHelper(_In_ IXmlDocument* xml, _In_ const std::wstring& scenario) { -+ ComPtr nodeList; -+ HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"toast").Get(), &nodeList); -+ if (SUCCEEDED(hr)) { -+ UINT32 length; -+ hr = nodeList->get_Length(&length); -+ if (SUCCEEDED(hr)) { -+ ComPtr toastNode; -+ hr = nodeList->Item(0, &toastNode); -+ if (SUCCEEDED(hr)) { -+ ComPtr toastElement; -+ hr = toastNode.As(&toastElement); -+ if (SUCCEEDED(hr)) { -+ hr = toastElement->SetAttribute(WinToastStringWrapper(L"scenario").Get(), -+ WinToastStringWrapper(scenario).Get()); -+ } -+ } -+ } -+ } -+ return hr; -+} -+ - HRESULT WinToast::setTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text, _In_ UINT32 pos) { - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"text").Get(), &nodeList); -@@ -1065,6 +1091,15 @@ void WinToastTemplate::setExpiration(_In_ INT64 millisecondsFromNow) { - _expiration = millisecondsFromNow; - } - -+void WinToastLib::WinToastTemplate::setScenario(Scenario scenario) { -+ switch (scenario) { -+ case Scenario::Default: _scenario = L"Default"; break; -+ case Scenario::Alarm: _scenario = L"Alarm"; break; -+ case Scenario::IncomingCall: _scenario = L"IncomingCall"; break; -+ case Scenario::Reminder: _scenario = L"Reminder"; break; -+ } -+} -+ - void WinToastTemplate::setAttributionText(_In_ const std::wstring& attributionText) { - _attributionText = attributionText; - } -@@ -1112,6 +1147,10 @@ const std::wstring& WinToastTemplate::attributionText() const { - return _attributionText; - } - -+const std::wstring& WinToastLib::WinToastTemplate::scenario() const { -+ return _scenario; -+} -+ - INT64 WinToastTemplate::expiration() const { - return _expiration; - } -diff --git a/src/wintoastlib.h b/src/wintoastlib.h -index d028994..291e15f 100644 ---- a/src/wintoastlib.h -+++ b/src/wintoastlib.h -@@ -63,6 +63,7 @@ namespace WinToastLib { - - class WinToastTemplate { - public: -+ enum class Scenario { Default, Alarm, IncomingCall, Reminder }; - enum Duration { System, Short, Long }; - enum AudioOption { Default = 0, Silent, Loop }; - enum TextField { FirstLine = 0, SecondLine, ThirdLine }; -@@ -114,13 +115,14 @@ namespace WinToastLib { - void setSecondLine(_In_ const std::wstring& text); - void setThirdLine(_In_ const std::wstring& text); - void setTextField(_In_ const std::wstring& txt, _In_ TextField pos); -- void setAttributionText(_In_ const std::wstring & attributionText); -+ void setAttributionText(_In_ const std::wstring& attributionText); - void setImagePath(_In_ const std::wstring& imgPath); - void setAudioPath(_In_ WinToastTemplate::AudioSystemFile audio); - void setAudioPath(_In_ const std::wstring& audioPath); - void setAudioOption(_In_ WinToastTemplate::AudioOption audioOption); - void setDuration(_In_ Duration duration); - void setExpiration(_In_ INT64 millisecondsFromNow); -+ void setScenario(_In_ Scenario scenario); - void addAction(_In_ const std::wstring& label); - - std::size_t textFieldsCount() const; -@@ -132,6 +134,7 @@ namespace WinToastLib { - const std::wstring& imagePath() const; - const std::wstring& audioPath() const; - const std::wstring& attributionText() const; -+ const std::wstring& scenario() const; - INT64 expiration() const; - WinToastTemplateType type() const; - WinToastTemplate::AudioOption audioOption() const; -@@ -142,6 +145,7 @@ namespace WinToastLib { - std::wstring _imagePath{}; - std::wstring _audioPath{}; - std::wstring _attributionText{}; -+ std::wstring _scenario{L"Default"}; - INT64 _expiration{0}; - AudioOption _audioOption{WinToastTemplate::AudioOption::Default}; - WinToastTemplateType _type{WinToastTemplateType::Text01}; -@@ -210,6 +214,7 @@ namespace WinToastLib { - HRESULT setAttributionTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text); - HRESULT addActionHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& action, _In_ const std::wstring& arguments); - HRESULT addDurationHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& duration); -+ HRESULT addScenarioHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& scenario); - ComPtr notifier(_In_ bool* succeded) const; - void setError(_Out_opt_ WinToastError* error, _In_ WinToastError value); - }; diff --git a/third_party/WinToast/wintoastlib.cpp b/third_party/WinToast/wintoastlib.cpp deleted file mode 100644 index ea5648a61d..0000000000 --- a/third_party/WinToast/wintoastlib.cpp +++ /dev/null @@ -1,1197 +0,0 @@ -/* * Copyright (C) 2016-2019 Mohammed Boujemaoui - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "wintoastlib.h" -#include -#include -#include -#include - -#pragma comment(lib,"shlwapi") -#pragma comment(lib,"user32") - -#ifdef NDEBUG - #define DEBUG_MSG(str) do { } while ( false ) -#else - #define DEBUG_MSG(str) do { std::wcout << str << std::endl; } while( false ) -#endif - -#define DEFAULT_SHELL_LINKS_PATH L"\\Microsoft\\Windows\\Start Menu\\Programs\\" -#define DEFAULT_LINK_FORMAT L".lnk" -#define STATUS_SUCCESS (0x00000000) - - -// Quickstart: Handling toast activations from Win32 apps in Windows 10 -// https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/10/16/quickstart-handling-toast-activations-from-win32-apps-in-windows-10/ -using namespace WinToastLib; -namespace DllImporter { - - // Function load a function from library - template - HRESULT loadFunctionFromLibrary(HINSTANCE library, LPCSTR name, Function &func) { - if (!library) { - return E_INVALIDARG; - } - func = reinterpret_cast(GetProcAddress(library, name)); - return (func != nullptr) ? S_OK : E_FAIL; - } - - typedef HRESULT(FAR STDAPICALLTYPE *f_SetCurrentProcessExplicitAppUserModelID)(__in PCWSTR AppID); - typedef HRESULT(FAR STDAPICALLTYPE *f_PropVariantToString)(_In_ REFPROPVARIANT propvar, _Out_writes_(cch) PWSTR psz, _In_ UINT cch); - typedef HRESULT(FAR STDAPICALLTYPE *f_RoGetActivationFactory)(_In_ HSTRING activatableClassId, _In_ REFIID iid, _COM_Outptr_ void ** factory); - typedef HRESULT(FAR STDAPICALLTYPE *f_WindowsCreateStringReference)(_In_reads_opt_(length + 1) PCWSTR sourceString, UINT32 length, _Out_ HSTRING_HEADER * hstringHeader, _Outptr_result_maybenull_ _Result_nullonfailure_ HSTRING * string); - typedef PCWSTR(FAR STDAPICALLTYPE *f_WindowsGetStringRawBuffer)(_In_ HSTRING string, _Out_ UINT32 *length); - typedef HRESULT(FAR STDAPICALLTYPE *f_WindowsDeleteString)(_In_opt_ HSTRING string); - - static f_SetCurrentProcessExplicitAppUserModelID SetCurrentProcessExplicitAppUserModelID; - static f_PropVariantToString PropVariantToString; - static f_RoGetActivationFactory RoGetActivationFactory; - static f_WindowsCreateStringReference WindowsCreateStringReference; - static f_WindowsGetStringRawBuffer WindowsGetStringRawBuffer; - static f_WindowsDeleteString WindowsDeleteString; - - - template - _Check_return_ __inline HRESULT _1_GetActivationFactory(_In_ HSTRING activatableClassId, _COM_Outptr_ T** factory) { - return RoGetActivationFactory(activatableClassId, IID_INS_ARGS(factory)); - } - - template - inline HRESULT Wrap_GetActivationFactory(_In_ HSTRING activatableClassId, _Inout_ Details::ComPtrRef factory) noexcept { - return _1_GetActivationFactory(activatableClassId, factory.ReleaseAndGetAddressOf()); - } - - inline HRESULT initialize() { - HINSTANCE LibShell32 = LoadLibraryW(L"SHELL32.DLL"); - HRESULT hr = loadFunctionFromLibrary(LibShell32, "SetCurrentProcessExplicitAppUserModelID", SetCurrentProcessExplicitAppUserModelID); - if (SUCCEEDED(hr)) { - HINSTANCE LibPropSys = LoadLibraryW(L"PROPSYS.DLL"); - hr = loadFunctionFromLibrary(LibPropSys, "PropVariantToString", PropVariantToString); - if (SUCCEEDED(hr)) { - HINSTANCE LibComBase = LoadLibraryW(L"COMBASE.DLL"); - const bool succeded = SUCCEEDED(loadFunctionFromLibrary(LibComBase, "RoGetActivationFactory", RoGetActivationFactory)) - && SUCCEEDED(loadFunctionFromLibrary(LibComBase, "WindowsCreateStringReference", WindowsCreateStringReference)) - && SUCCEEDED(loadFunctionFromLibrary(LibComBase, "WindowsGetStringRawBuffer", WindowsGetStringRawBuffer)) - && SUCCEEDED(loadFunctionFromLibrary(LibComBase, "WindowsDeleteString", WindowsDeleteString)); - return succeded ? S_OK : E_FAIL; - } - } - return hr; - } -} - -class WinToastStringWrapper { -public: - WinToastStringWrapper(_In_reads_(length) PCWSTR stringRef, _In_ UINT32 length) noexcept { - HRESULT hr = DllImporter::WindowsCreateStringReference(stringRef, length, &_header, &_hstring); - if (!SUCCEEDED(hr)) { - RaiseException(static_cast(STATUS_INVALID_PARAMETER), EXCEPTION_NONCONTINUABLE, 0, nullptr); - } - } - - WinToastStringWrapper(_In_ const std::wstring &stringRef) noexcept { - HRESULT hr = DllImporter::WindowsCreateStringReference(stringRef.c_str(), static_cast(stringRef.length()), &_header, &_hstring); - if (FAILED(hr)) { - RaiseException(static_cast(STATUS_INVALID_PARAMETER), EXCEPTION_NONCONTINUABLE, 0, nullptr); - } - } - - ~WinToastStringWrapper() { - DllImporter::WindowsDeleteString(_hstring); - } - - inline HSTRING Get() const noexcept { - return _hstring; - } -private: - HSTRING _hstring; - HSTRING_HEADER _header; - -}; - -class InternalDateTime : public IReference { -public: - static INT64 Now() { - FILETIME now; - GetSystemTimeAsFileTime(&now); - return ((((INT64)now.dwHighDateTime) << 32) | now.dwLowDateTime); - } - - InternalDateTime(DateTime dateTime) : _dateTime(dateTime) {} - - InternalDateTime(INT64 millisecondsFromNow) { - _dateTime.UniversalTime = Now() + millisecondsFromNow * 10000; - } - - virtual ~InternalDateTime() = default; - - operator INT64() { - return _dateTime.UniversalTime; - } - - HRESULT STDMETHODCALLTYPE get_Value(DateTime *dateTime) { - *dateTime = _dateTime; - return S_OK; - } - - HRESULT STDMETHODCALLTYPE QueryInterface(const IID& riid, void** ppvObject) { - if (!ppvObject) { - return E_POINTER; - } - if (riid == __uuidof(IUnknown) || riid == __uuidof(IReference)) { - *ppvObject = static_cast(static_cast*>(this)); - return S_OK; - } - return E_NOINTERFACE; - } - - ULONG STDMETHODCALLTYPE Release() { - return 1; - } - - ULONG STDMETHODCALLTYPE AddRef() { - return 2; - } - - HRESULT STDMETHODCALLTYPE GetIids(ULONG*, IID**) { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE GetRuntimeClassName(HSTRING*) { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE GetTrustLevel(TrustLevel*) { - return E_NOTIMPL; - } - -protected: - DateTime _dateTime; -}; - -namespace Util { - - typedef LONG NTSTATUS, *PNTSTATUS; - typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); - inline RTL_OSVERSIONINFOW getRealOSVersion() { - HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll"); - if (hMod) { - RtlGetVersionPtr fxPtr = (RtlGetVersionPtr)::GetProcAddress(hMod, "RtlGetVersion"); - if (fxPtr != nullptr) { - RTL_OSVERSIONINFOW rovi = { 0 }; - rovi.dwOSVersionInfoSize = sizeof(rovi); - if (STATUS_SUCCESS == fxPtr(&rovi)) { - return rovi; - } - } - } - RTL_OSVERSIONINFOW rovi = { 0 }; - return rovi; - } - - inline HRESULT defaultExecutablePath(_In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) { - DWORD written = GetModuleFileNameExW(GetCurrentProcess(), nullptr, path, nSize); - DEBUG_MSG("Default executable path: " << path); - return (written > 0) ? S_OK : E_FAIL; - } - - - inline HRESULT commonShellLinksDirectory(_In_ const WCHAR* baseEnv, _In_ WCHAR* path, _In_ DWORD nSize) { - DWORD written = GetEnvironmentVariableW(baseEnv, path, nSize); - HRESULT hr = written > 0 ? S_OK : E_INVALIDARG; - if (SUCCEEDED(hr)) { - errno_t result = wcscat_s(path, nSize, DEFAULT_SHELL_LINKS_PATH); - hr = (result == 0) ? S_OK : E_INVALIDARG; - DEBUG_MSG("Default shell link path: " << path); - } - return hr; - } - - inline HRESULT commonShellLinkPath(_In_ const WCHAR* baseEnv, const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize) { - HRESULT hr = commonShellLinksDirectory(baseEnv, path, nSize); - if (SUCCEEDED(hr)) { - const std::wstring appLink(appname + DEFAULT_LINK_FORMAT); - errno_t result = wcscat_s(path, nSize, appLink.c_str()); - hr = (result == 0) ? S_OK : E_INVALIDARG; - DEBUG_MSG("Default shell link file path: " << path); - } - return hr; - } - - inline HRESULT defaultUserShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) { - return commonShellLinkPath(L"APPDATA", appname, path, nSize); - } - - inline HRESULT defaultSystemShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) { - return commonShellLinkPath(L"PROGRAMDATA", appname, path, nSize); - } - - inline PCWSTR AsString(ComPtr &xmlDocument) { - HSTRING xml; - ComPtr ser; - HRESULT hr = xmlDocument.As(&ser); - hr = ser->GetXml(&xml); - if (SUCCEEDED(hr)) - return DllImporter::WindowsGetStringRawBuffer(xml, nullptr); - return nullptr; - } - - inline PCWSTR AsString(HSTRING hstring) { - return DllImporter::WindowsGetStringRawBuffer(hstring, nullptr); - } - - inline HRESULT setNodeStringValue(const std::wstring& string, IXmlNode *node, IXmlDocument *xml) { - ComPtr textNode; - HRESULT hr = xml->CreateTextNode( WinToastStringWrapper(string).Get(), &textNode); - if (SUCCEEDED(hr)) { - ComPtr stringNode; - hr = textNode.As(&stringNode); - if (SUCCEEDED(hr)) { - ComPtr appendedChild; - hr = node->AppendChild(stringNode.Get(), &appendedChild); - } - } - return hr; - } - - inline HRESULT setEventHandlers(_In_ IToastNotification* notification, _In_ std::shared_ptr eventHandler, _In_ INT64 expirationTime) { - EventRegistrationToken activatedToken, dismissedToken, failedToken; - HRESULT hr = notification->add_Activated( - Callback < Implements < RuntimeClassFlags, - ITypedEventHandler> >( - [eventHandler](IToastNotification*, IInspectable* inspectable) - { - IToastActivatedEventArgs *activatedEventArgs; - HRESULT hr = inspectable->QueryInterface(&activatedEventArgs); - if (SUCCEEDED(hr)) { - HSTRING argumentsHandle; - hr = activatedEventArgs->get_Arguments(&argumentsHandle); - if (SUCCEEDED(hr)) { - PCWSTR arguments = Util::AsString(argumentsHandle); - if (arguments && *arguments) { - eventHandler->toastActivated(static_cast(wcstol(arguments, nullptr, 10))); - return S_OK; - } - } - } - eventHandler->toastActivated(); - return S_OK; - }).Get(), &activatedToken); - - if (SUCCEEDED(hr)) { - hr = notification->add_Dismissed(Callback < Implements < RuntimeClassFlags, - ITypedEventHandler> >( - [eventHandler, expirationTime](IToastNotification*, IToastDismissedEventArgs* e) - { - ToastDismissalReason reason; - if (SUCCEEDED(e->get_Reason(&reason))) - { - if (reason == ToastDismissalReason_UserCanceled && expirationTime && InternalDateTime::Now() >= expirationTime) - reason = ToastDismissalReason_TimedOut; - eventHandler->toastDismissed(static_cast(reason)); - } - return S_OK; - }).Get(), &dismissedToken); - if (SUCCEEDED(hr)) { - hr = notification->add_Failed(Callback < Implements < RuntimeClassFlags, - ITypedEventHandler> >( - [eventHandler](IToastNotification*, IToastFailedEventArgs*) - { - eventHandler->toastFailed(); - return S_OK; - }).Get(), &failedToken); - } - } - return hr; - } - - inline HRESULT addAttribute(_In_ IXmlDocument *xml, const std::wstring &name, IXmlNamedNodeMap *attributeMap) { - ComPtr srcAttribute; - HRESULT hr = xml->CreateAttribute(WinToastStringWrapper(name).Get(), &srcAttribute); - if (SUCCEEDED(hr)) { - ComPtr node; - hr = srcAttribute.As(&node); - if (SUCCEEDED(hr)) { - ComPtr pNode; - hr = attributeMap->SetNamedItem(node.Get(), &pNode); - } - } - return hr; - } - - inline HRESULT createElement(_In_ IXmlDocument *xml, _In_ const std::wstring& root_node, _In_ const std::wstring& element_name, _In_ const std::vector& attribute_names) { - ComPtr rootList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(root_node).Get(), &rootList); - if (SUCCEEDED(hr)) { - ComPtr root; - hr = rootList->Item(0, &root); - if (SUCCEEDED(hr)) { - ComPtr audioElement; - hr = xml->CreateElement(WinToastStringWrapper(element_name).Get(), &audioElement); - if (SUCCEEDED(hr)) { - ComPtr audioNodeTmp; - hr = audioElement.As(&audioNodeTmp); - if (SUCCEEDED(hr)) { - ComPtr audioNode; - hr = root->AppendChild(audioNodeTmp.Get(), &audioNode); - if (SUCCEEDED(hr)) { - ComPtr attributes; - hr = audioNode->get_Attributes(&attributes); - if (SUCCEEDED(hr)) { - for (const auto& it : attribute_names) { - hr = addAttribute(xml, it, attributes.Get()); - } - } - } - } - } - } - } - return hr; - } -} - -WinToast* WinToast::instance() { - static WinToast instance; - return &instance; -} - -WinToast::WinToast() : - _isInitialized(false), - _hasCoInitialized(false) -{ - if (!isCompatible()) { - DEBUG_MSG(L"Warning: Your system is not compatible with this library "); - } -} - -WinToast::~WinToast() { - if (_hasCoInitialized) { - CoUninitialize(); - } -} - -void WinToast::setAppName(_In_ const std::wstring& appName) { - _appName = appName; -} - - -void WinToast::setAppUserModelId(_In_ const std::wstring& aumi) { - _aumi = aumi; - DEBUG_MSG(L"Default App User Model Id: " << _aumi.c_str()); -} - -void WinToast::setShortcutPolicy(_In_ ShortcutPolicy shortcutPolicy) { - _shortcutPolicy = shortcutPolicy; -} - -bool WinToast::isCompatible() { - DllImporter::initialize(); - return !((DllImporter::SetCurrentProcessExplicitAppUserModelID == nullptr) - || (DllImporter::PropVariantToString == nullptr) - || (DllImporter::RoGetActivationFactory == nullptr) - || (DllImporter::WindowsCreateStringReference == nullptr) - || (DllImporter::WindowsDeleteString == nullptr)); -} - -bool WinToastLib::WinToast::isSupportingModernFeatures() { - constexpr auto MinimumSupportedVersion = 6; - return Util::getRealOSVersion().dwMajorVersion > MinimumSupportedVersion; - -} -std::wstring WinToast::configureAUMI(_In_ const std::wstring &companyName, - _In_ const std::wstring &productName, - _In_ const std::wstring &subProduct, - _In_ const std::wstring &versionInformation) -{ - std::wstring aumi = companyName; - aumi += L"." + productName; - if (subProduct.length() > 0) { - aumi += L"." + subProduct; - if (versionInformation.length() > 0) { - aumi += L"." + versionInformation; - } - } - - if (aumi.length() > SCHAR_MAX) { - DEBUG_MSG("Error: max size allowed for AUMI: 128 characters."); - } - return aumi; -} - -const std::wstring& WinToast::strerror(WinToastError error) { - static const std::unordered_map Labels = { - {WinToastError::NoError, L"No error. The process was executed correctly"}, - {WinToastError::NotInitialized, L"The library has not been initialized"}, - {WinToastError::SystemNotSupported, L"The OS does not support WinToast"}, - {WinToastError::ShellLinkNotCreated, L"The library was not able to create a Shell Link for the app"}, - {WinToastError::InvalidAppUserModelID, L"The AUMI is not a valid one"}, - {WinToastError::InvalidParameters, L"The parameters used to configure the library are not valid normally because an invalid AUMI or App Name"}, - {WinToastError::NotDisplayed, L"The toast was created correctly but WinToast was not able to display the toast"}, - {WinToastError::UnknownError, L"Unknown error"} - }; - - const auto iter = Labels.find(error); - assert(iter != Labels.end()); - return iter->second; -} - -enum WinToast::ShortcutResult WinToast::createShortcut() { - if (_aumi.empty() || _appName.empty()) { - DEBUG_MSG(L"Error: App User Model Id or Appname is empty!"); - return SHORTCUT_MISSING_PARAMETERS; - } - - if (!isCompatible()) { - DEBUG_MSG(L"Your OS is not compatible with this library! =("); - return SHORTCUT_INCOMPATIBLE_OS; - } - - if (!_hasCoInitialized) { - HRESULT initHr = CoInitializeEx(nullptr, COINIT::COINIT_MULTITHREADED); - if (initHr != RPC_E_CHANGED_MODE) { - if (FAILED(initHr) && initHr != S_FALSE) { - DEBUG_MSG(L"Error on COM library initialization!"); - return SHORTCUT_COM_INIT_FAILURE; - } - else { - _hasCoInitialized = true; - } - } - } - - bool wasChanged; - HRESULT hr = validateShellLinkHelper(wasChanged); - if (SUCCEEDED(hr)) - return wasChanged ? SHORTCUT_WAS_CHANGED : SHORTCUT_UNCHANGED; - - hr = createShellLinkHelper(); - return SUCCEEDED(hr) ? SHORTCUT_WAS_CREATED : SHORTCUT_CREATE_FAILED; -} - -bool WinToast::initialize(_Out_ WinToastError* error) { - _isInitialized = false; - setError(error, WinToastError::NoError); - - if (!isCompatible()) { - setError(error, WinToastError::SystemNotSupported); - DEBUG_MSG(L"Error: system not supported."); - return false; - } - - - if (_aumi.empty() || _appName.empty()) { - setError(error, WinToastError::InvalidParameters); - DEBUG_MSG(L"Error while initializing, did you set up a valid AUMI and App name?"); - return false; - } - - if (_shortcutPolicy != SHORTCUT_POLICY_IGNORE) { - if (createShortcut() < 0) { - setError(error, WinToastError::ShellLinkNotCreated); - DEBUG_MSG(L"Error while attaching the AUMI to the current proccess =("); - return false; - } - } - - if (FAILED(DllImporter::SetCurrentProcessExplicitAppUserModelID(_aumi.c_str()))) { - setError(error, WinToastError::InvalidAppUserModelID); - DEBUG_MSG(L"Error while attaching the AUMI to the current proccess =("); - return false; - } - - _isInitialized = true; - return _isInitialized; -} - -bool WinToast::isInitialized() const { - return _isInitialized; -} - -const std::wstring& WinToast::appName() const { - return _appName; -} - -const std::wstring& WinToast::appUserModelId() const { - return _aumi; -} - - -HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) { - WCHAR path[MAX_PATH] = { L'\0' }; - Util::defaultUserShellLinkPath(_appName, path); - // Check if the file exist - DWORD attr = GetFileAttributesW(path); - if (attr >= 0xFFFFFFF) { - // The shortcut may be in the system Start Menu. - WCHAR systemPath[MAX_PATH] = { L'\0' }; - Util::defaultSystemShellLinkPath(_appName, systemPath); - attr = GetFileAttributesW(systemPath); - if (attr >= 0xFFFFFFF) { - DEBUG_MSG("Error, shell link not found. Try to create a new one in: " << path); - return E_FAIL; - } - wcscpy(path, systemPath); - } - - // Let's load the file as shell link to validate. - // - Create a shell link - // - Create a persistant file - // - Load the path as data for the persistant file - // - Read the property AUMI and validate with the current - // - Review if AUMI is equal. - ComPtr shellLink; - HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink)); - if (SUCCEEDED(hr)) { - ComPtr persistFile; - hr = shellLink.As(&persistFile); - if (SUCCEEDED(hr)) { - hr = persistFile->Load(path, STGM_READ); - if (SUCCEEDED(hr)) { - ComPtr propertyStore; - hr = shellLink.As(&propertyStore); - if (SUCCEEDED(hr)) { - PROPVARIANT appIdPropVar; - hr = propertyStore->GetValue(PKEY_AppUserModel_ID, &appIdPropVar); - if (SUCCEEDED(hr)) { - WCHAR AUMI[MAX_PATH]; - hr = DllImporter::PropVariantToString(appIdPropVar, AUMI, MAX_PATH); - wasChanged = false; - if (FAILED(hr) || _aumi != AUMI) { - if (_shortcutPolicy == SHORTCUT_POLICY_REQUIRE_CREATE) { - // AUMI Changed for the same app, let's update the current value! =) - wasChanged = true; - PropVariantClear(&appIdPropVar); - hr = InitPropVariantFromString(_aumi.c_str(), &appIdPropVar); - if (SUCCEEDED(hr)) { - hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar); - if (SUCCEEDED(hr)) { - hr = propertyStore->Commit(); - if (SUCCEEDED(hr) && SUCCEEDED(persistFile->IsDirty())) { - hr = persistFile->Save(path, TRUE); - } - } - } - } else { - // Not allowed to touch the shortcut to fix the AUMI - hr = E_FAIL; - } - } - PropVariantClear(&appIdPropVar); - } - } - } - } - } - return hr; -} - - - -HRESULT WinToast::createShellLinkHelper() { - if (_shortcutPolicy != SHORTCUT_POLICY_REQUIRE_CREATE) { - return E_FAIL; - } - - WCHAR exePath[MAX_PATH]{L'\0'}; - WCHAR slPath[MAX_PATH]{L'\0'}; - Util::defaultUserShellLinkPath(_appName, slPath); - Util::defaultExecutablePath(exePath); - ComPtr shellLink; - HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink)); - if (SUCCEEDED(hr)) { - hr = shellLink->SetPath(exePath); - if (SUCCEEDED(hr)) { - hr = shellLink->SetArguments(L""); - if (SUCCEEDED(hr)) { - hr = shellLink->SetWorkingDirectory(exePath); - if (SUCCEEDED(hr)) { - ComPtr propertyStore; - hr = shellLink.As(&propertyStore); - if (SUCCEEDED(hr)) { - PROPVARIANT appIdPropVar; - hr = InitPropVariantFromString(_aumi.c_str(), &appIdPropVar); - if (SUCCEEDED(hr)) { - hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar); - if (SUCCEEDED(hr)) { - hr = propertyStore->Commit(); - if (SUCCEEDED(hr)) { - ComPtr persistFile; - hr = shellLink.As(&persistFile); - if (SUCCEEDED(hr)) { - hr = persistFile->Save(slPath, TRUE); - } - } - } - PropVariantClear(&appIdPropVar); - } - } - } - } - } - } - return hr; -} - -INT64 WinToast::showToast(_In_ const WinToastTemplate& toast, _In_ IWinToastHandler* handler, _Out_ WinToastError* error) { - setError(error, WinToastError::NoError); - INT64 id = -1; - if (!isInitialized()) { - setError(error, WinToastError::NotInitialized); - DEBUG_MSG("Error when launching the toast. WinToast is not initialized."); - return id; - } - if (!handler) { - setError(error, WinToastError::InvalidHandler); - DEBUG_MSG("Error when launching the toast. Handler cannot be nullptr."); - return id; - } - - ComPtr notificationManager; - HRESULT hr = DllImporter::Wrap_GetActivationFactory(WinToastStringWrapper(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager).Get(), ¬ificationManager); - if (SUCCEEDED(hr)) { - ComPtr notifier; - hr = notificationManager->CreateToastNotifierWithId(WinToastStringWrapper(_aumi).Get(), ¬ifier); - if (SUCCEEDED(hr)) { - ComPtr notificationFactory; - hr = DllImporter::Wrap_GetActivationFactory(WinToastStringWrapper(RuntimeClass_Windows_UI_Notifications_ToastNotification).Get(), ¬ificationFactory); - if (SUCCEEDED(hr)) { - ComPtr xmlDocument; - HRESULT hr = notificationManager->GetTemplateContent(ToastTemplateType(toast.type()), &xmlDocument); - if (SUCCEEDED(hr)) { - for (std::size_t i = 0, fieldsCount = toast.textFieldsCount(); i < fieldsCount && SUCCEEDED(hr); i++) { - hr = setTextFieldHelper(xmlDocument.Get(), toast.textField(WinToastTemplate::TextField(i)), i); - } - - // Modern feature are supported Windows > Windows 10 - if (SUCCEEDED(hr) && isSupportingModernFeatures()) { - - // Note that we do this *after* using toast.textFieldsCount() to - // iterate/fill the template's text fields, since we're adding yet another text field. - if (SUCCEEDED(hr) - && !toast.attributionText().empty()) { - hr = setAttributionTextFieldHelper(xmlDocument.Get(), toast.attributionText()); - } - - std::array buf; - for (std::size_t i = 0, actionsCount = toast.actionsCount(); i < actionsCount && SUCCEEDED(hr); i++) { - _snwprintf_s(buf.data(), buf.size(), _TRUNCATE, L"%zd", i); - hr = addActionHelper(xmlDocument.Get(), toast.actionLabel(i), buf.data()); - } - - if (SUCCEEDED(hr)) { - hr = (toast.audioPath().empty() && toast.audioOption() == WinToastTemplate::AudioOption::Default) - ? hr : setAudioFieldHelper(xmlDocument.Get(), toast.audioPath(), toast.audioOption()); - } - - if (SUCCEEDED(hr) && toast.duration() != WinToastTemplate::Duration::System) { - hr = addDurationHelper(xmlDocument.Get(), - (toast.duration() == WinToastTemplate::Duration::Short) ? L"short" : L"long"); - } - - if (SUCCEEDED(hr)) { - hr = addScenarioHelper(xmlDocument.Get(), toast.scenario()); - } - - } else { - DEBUG_MSG("Modern features (Actions/Sounds/Attributes) not supported in this os version"); - } - - if (SUCCEEDED(hr)) { - hr = toast.hasImage() ? setImageFieldHelper(xmlDocument.Get(), toast.imagePath()) : hr; - if (SUCCEEDED(hr)) { - ComPtr notification; - hr = notificationFactory->CreateToastNotification(xmlDocument.Get(), ¬ification); - if (SUCCEEDED(hr)) { - INT64 expiration = 0, relativeExpiration = toast.expiration(); - if (relativeExpiration > 0) { - InternalDateTime expirationDateTime(relativeExpiration); - expiration = expirationDateTime; - hr = notification->put_ExpirationTime(&expirationDateTime); - } - - if (SUCCEEDED(hr)) { - hr = Util::setEventHandlers(notification.Get(), std::shared_ptr(handler), expiration); - if (FAILED(hr)) { - setError(error, WinToastError::InvalidHandler); - } - } - - if (SUCCEEDED(hr)) { - GUID guid; - hr = CoCreateGuid(&guid); - if (SUCCEEDED(hr)) { - id = guid.Data1; - _buffer[id] = notification; - DEBUG_MSG("xml: " << Util::AsString(xmlDocument)); - hr = notifier->Show(notification.Get()); - if (FAILED(hr)) { - setError(error, WinToastError::NotDisplayed); - } - } - } - } - } - } - } - } - } - } - return FAILED(hr) ? -1 : id; -} - -ComPtr WinToast::notifier(_In_ bool* succeded) const { - ComPtr notificationManager; - ComPtr notifier; - HRESULT hr = DllImporter::Wrap_GetActivationFactory(WinToastStringWrapper(RuntimeClass_Windows_UI_Notifications_ToastNotificationManager).Get(), ¬ificationManager); - if (SUCCEEDED(hr)) { - hr = notificationManager->CreateToastNotifierWithId(WinToastStringWrapper(_aumi).Get(), ¬ifier); - } - *succeded = SUCCEEDED(hr); - return notifier; -} - -bool WinToast::hideToast(_In_ INT64 id) { - if (!isInitialized()) { - DEBUG_MSG("Error when hiding the toast. WinToast is not initialized."); - return false; - } - - if (_buffer.find(id) != _buffer.end()) { - auto succeded = false; - auto notify = notifier(&succeded); - if (succeded) { - auto result = notify->Hide(_buffer[id].Get()); - _buffer.erase(id); - return SUCCEEDED(result); - } - } - return false; -} - -void WinToast::clear() { - auto succeded = false; - auto notify = notifier(&succeded); - if (succeded) { - auto end = _buffer.end(); - for (auto it = _buffer.begin(); it != end; ++it) { - notify->Hide(it->second.Get()); - } - _buffer.clear(); - } -} - -// -// Available as of Windows 10 Anniversary Update -// Ref: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts -// -// NOTE: This will add a new text field, so be aware when iterating over -// the toast's text fields or getting a count of them. -// -HRESULT WinToast::setAttributionTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text) { - Util::createElement(xml, L"binding", L"text", { L"placement" }); - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"text").Get(), &nodeList); - if (SUCCEEDED(hr)) { - UINT32 nodeListLength; - hr = nodeList->get_Length(&nodeListLength); - if (SUCCEEDED(hr)) { - for (UINT32 i = 0; i < nodeListLength; i++) { - ComPtr textNode; - hr = nodeList->Item(i, &textNode); - if (SUCCEEDED(hr)) { - ComPtr attributes; - hr = textNode->get_Attributes(&attributes); - if (SUCCEEDED(hr)) { - ComPtr editedNode; - if (SUCCEEDED(hr)) { - hr = attributes->GetNamedItem(WinToastStringWrapper(L"placement").Get(), &editedNode); - if (FAILED(hr) || !editedNode) { - continue; - } - hr = Util::setNodeStringValue(L"attribution", editedNode.Get(), xml); - if (SUCCEEDED(hr)) { - return setTextFieldHelper(xml, text, i); - } - } - } - } - } - } - } - return hr; -} - -HRESULT WinToast::addDurationHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& duration) { - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"toast").Get(), &nodeList); - if (SUCCEEDED(hr)) { - UINT32 length; - hr = nodeList->get_Length(&length); - if (SUCCEEDED(hr)) { - ComPtr toastNode; - hr = nodeList->Item(0, &toastNode); - if (SUCCEEDED(hr)) { - ComPtr toastElement; - hr = toastNode.As(&toastElement); - if (SUCCEEDED(hr)) { - hr = toastElement->SetAttribute(WinToastStringWrapper(L"duration").Get(), - WinToastStringWrapper(duration).Get()); - } - } - } - } - return hr; -} - -HRESULT WinToast::addScenarioHelper(_In_ IXmlDocument* xml, _In_ const std::wstring& scenario) { - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"toast").Get(), &nodeList); - if (SUCCEEDED(hr)) { - UINT32 length; - hr = nodeList->get_Length(&length); - if (SUCCEEDED(hr)) { - ComPtr toastNode; - hr = nodeList->Item(0, &toastNode); - if (SUCCEEDED(hr)) { - ComPtr toastElement; - hr = toastNode.As(&toastElement); - if (SUCCEEDED(hr)) { - hr = toastElement->SetAttribute(WinToastStringWrapper(L"scenario").Get(), - WinToastStringWrapper(scenario).Get()); - } - } - } - } - return hr; -} - -HRESULT WinToast::setTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text, _In_ UINT32 pos) { - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"text").Get(), &nodeList); - if (SUCCEEDED(hr)) { - ComPtr node; - hr = nodeList->Item(pos, &node); - if (SUCCEEDED(hr)) { - hr = Util::setNodeStringValue(text, node.Get(), xml); - } - } - return hr; -} - - -HRESULT WinToast::setImageFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& path) { - assert(path.size() < MAX_PATH); - - wchar_t imagePath[MAX_PATH] = L"file:///"; - HRESULT hr = StringCchCatW(imagePath, MAX_PATH, path.c_str()); - if (SUCCEEDED(hr)) { - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"image").Get(), &nodeList); - if (SUCCEEDED(hr)) { - ComPtr node; - hr = nodeList->Item(0, &node); - if (SUCCEEDED(hr)) { - ComPtr attributes; - hr = node->get_Attributes(&attributes); - if (SUCCEEDED(hr)) { - ComPtr editedNode; - hr = attributes->GetNamedItem(WinToastStringWrapper(L"src").Get(), &editedNode); - if (SUCCEEDED(hr)) { - Util::setNodeStringValue(imagePath, editedNode.Get(), xml); - } - } - } - } - } - return hr; -} - -HRESULT WinToast::setAudioFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& path, _In_opt_ WinToastTemplate::AudioOption option) { - std::vector attrs; - if (!path.empty()) attrs.push_back(L"src"); - if (option == WinToastTemplate::AudioOption::Loop) attrs.push_back(L"loop"); - if (option == WinToastTemplate::AudioOption::Silent) attrs.push_back(L"silent"); - Util::createElement(xml, L"toast", L"audio", attrs); - - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"audio").Get(), &nodeList); - if (SUCCEEDED(hr)) { - ComPtr node; - hr = nodeList->Item(0, &node); - if (SUCCEEDED(hr)) { - ComPtr attributes; - hr = node->get_Attributes(&attributes); - if (SUCCEEDED(hr)) { - ComPtr editedNode; - if (!path.empty()) { - if (SUCCEEDED(hr)) { - hr = attributes->GetNamedItem(WinToastStringWrapper(L"src").Get(), &editedNode); - if (SUCCEEDED(hr)) { - hr = Util::setNodeStringValue(path, editedNode.Get(), xml); - } - } - } - - if (SUCCEEDED(hr)) { - switch (option) { - case WinToastTemplate::AudioOption::Loop: - hr = attributes->GetNamedItem(WinToastStringWrapper(L"loop").Get(), &editedNode); - if (SUCCEEDED(hr)) { - hr = Util::setNodeStringValue(L"true", editedNode.Get(), xml); - } - break; - case WinToastTemplate::AudioOption::Silent: - hr = attributes->GetNamedItem(WinToastStringWrapper(L"silent").Get(), &editedNode); - if (SUCCEEDED(hr)) { - hr = Util::setNodeStringValue(L"true", editedNode.Get(), xml); - } - default: - break; - } - } - } - } - } - return hr; -} - -HRESULT WinToast::addActionHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& content, _In_ const std::wstring& arguments) { - ComPtr nodeList; - HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"actions").Get(), &nodeList); - if (SUCCEEDED(hr)) { - UINT32 length; - hr = nodeList->get_Length(&length); - if (SUCCEEDED(hr)) { - ComPtr actionsNode; - if (length > 0) { - hr = nodeList->Item(0, &actionsNode); - } else { - hr = xml->GetElementsByTagName(WinToastStringWrapper(L"toast").Get(), &nodeList); - if (SUCCEEDED(hr)) { - hr = nodeList->get_Length(&length); - if (SUCCEEDED(hr)) { - ComPtr toastNode; - hr = nodeList->Item(0, &toastNode); - if (SUCCEEDED(hr)) { - ComPtr toastElement; - hr = toastNode.As(&toastElement); - if (SUCCEEDED(hr)) - hr = toastElement->SetAttribute(WinToastStringWrapper(L"template").Get(), WinToastStringWrapper(L"ToastGeneric").Get()); - if (SUCCEEDED(hr)) - hr = toastElement->SetAttribute(WinToastStringWrapper(L"duration").Get(), WinToastStringWrapper(L"long").Get()); - if (SUCCEEDED(hr)) { - ComPtr actionsElement; - hr = xml->CreateElement(WinToastStringWrapper(L"actions").Get(), &actionsElement); - if (SUCCEEDED(hr)) { - hr = actionsElement.As(&actionsNode); - if (SUCCEEDED(hr)) { - ComPtr appendedChild; - hr = toastNode->AppendChild(actionsNode.Get(), &appendedChild); - } - } - } - } - } - } - } - if (SUCCEEDED(hr)) { - ComPtr actionElement; - hr = xml->CreateElement(WinToastStringWrapper(L"action").Get(), &actionElement); - if (SUCCEEDED(hr)) - hr = actionElement->SetAttribute(WinToastStringWrapper(L"content").Get(), WinToastStringWrapper(content).Get()); - if (SUCCEEDED(hr)) - hr = actionElement->SetAttribute(WinToastStringWrapper(L"arguments").Get(), WinToastStringWrapper(arguments).Get()); - if (SUCCEEDED(hr)) { - ComPtr actionNode; - hr = actionElement.As(&actionNode); - if (SUCCEEDED(hr)) { - ComPtr appendedChild; - hr = actionsNode->AppendChild(actionNode.Get(), &appendedChild); - } - } - } - } - } - return hr; -} - -void WinToast::setError(_Out_ WinToastError* error, _In_ WinToastError value) { - if (error) { - *error = value; - } -} - -WinToastTemplate::WinToastTemplate(_In_ WinToastTemplateType type) : _type(type) { - static constexpr std::size_t TextFieldsCount[] = { 1, 2, 2, 3, 1, 2, 2, 3}; - _textFields = std::vector(TextFieldsCount[type], L""); -} - -WinToastTemplate::~WinToastTemplate() { - _textFields.clear(); -} - -void WinToastTemplate::setTextField(_In_ const std::wstring& txt, _In_ WinToastTemplate::TextField pos) { - const auto position = static_cast(pos); - assert(position < _textFields.size()); - _textFields[position] = txt; -} - -void WinToastTemplate::setImagePath(_In_ const std::wstring& imgPath) { - _imagePath = imgPath; -} - -void WinToastTemplate::setAudioPath(_In_ const std::wstring& audioPath) { - _audioPath = audioPath; -} - -void WinToastTemplate::setAudioPath(_In_ AudioSystemFile file) { - static const std::unordered_map Files = { - {AudioSystemFile::DefaultSound, L"ms-winsoundevent:Notification.Default"}, - {AudioSystemFile::IM, L"ms-winsoundevent:Notification.IM"}, - {AudioSystemFile::Mail, L"ms-winsoundevent:Notification.Mail"}, - {AudioSystemFile::Reminder, L"ms-winsoundevent:Notification.Reminder"}, - {AudioSystemFile::SMS, L"ms-winsoundevent:Notification.SMS"}, - {AudioSystemFile::Alarm, L"ms-winsoundevent:Notification.Looping.Alarm"}, - {AudioSystemFile::Alarm2, L"ms-winsoundevent:Notification.Looping.Alarm2"}, - {AudioSystemFile::Alarm3, L"ms-winsoundevent:Notification.Looping.Alarm3"}, - {AudioSystemFile::Alarm4, L"ms-winsoundevent:Notification.Looping.Alarm4"}, - {AudioSystemFile::Alarm5, L"ms-winsoundevent:Notification.Looping.Alarm5"}, - {AudioSystemFile::Alarm6, L"ms-winsoundevent:Notification.Looping.Alarm6"}, - {AudioSystemFile::Alarm7, L"ms-winsoundevent:Notification.Looping.Alarm7"}, - {AudioSystemFile::Alarm8, L"ms-winsoundevent:Notification.Looping.Alarm8"}, - {AudioSystemFile::Alarm9, L"ms-winsoundevent:Notification.Looping.Alarm9"}, - {AudioSystemFile::Alarm10, L"ms-winsoundevent:Notification.Looping.Alarm10"}, - {AudioSystemFile::Call, L"ms-winsoundevent:Notification.Looping.Call"}, - {AudioSystemFile::Call1, L"ms-winsoundevent:Notification.Looping.Call1"}, - {AudioSystemFile::Call2, L"ms-winsoundevent:Notification.Looping.Call2"}, - {AudioSystemFile::Call3, L"ms-winsoundevent:Notification.Looping.Call3"}, - {AudioSystemFile::Call4, L"ms-winsoundevent:Notification.Looping.Call4"}, - {AudioSystemFile::Call5, L"ms-winsoundevent:Notification.Looping.Call5"}, - {AudioSystemFile::Call6, L"ms-winsoundevent:Notification.Looping.Call6"}, - {AudioSystemFile::Call7, L"ms-winsoundevent:Notification.Looping.Call7"}, - {AudioSystemFile::Call8, L"ms-winsoundevent:Notification.Looping.Call8"}, - {AudioSystemFile::Call9, L"ms-winsoundevent:Notification.Looping.Call9"}, - {AudioSystemFile::Call10, L"ms-winsoundevent:Notification.Looping.Call10"}, - }; - const auto iter = Files.find(file); - assert(iter != Files.end()); - _audioPath = iter->second; -} - -void WinToastTemplate::setAudioOption(_In_ WinToastTemplate::AudioOption audioOption) { - _audioOption = audioOption; -} - -void WinToastTemplate::setFirstLine(const std::wstring &text) { - setTextField(text, WinToastTemplate::FirstLine); -} - -void WinToastTemplate::setSecondLine(const std::wstring &text) { - setTextField(text, WinToastTemplate::SecondLine); -} - -void WinToastTemplate::setThirdLine(const std::wstring &text) { - setTextField(text, WinToastTemplate::ThirdLine); -} - -void WinToastTemplate::setDuration(_In_ Duration duration) { - _duration = duration; -} - -void WinToastTemplate::setExpiration(_In_ INT64 millisecondsFromNow) { - _expiration = millisecondsFromNow; -} - -void WinToastLib::WinToastTemplate::setScenario(Scenario scenario) { - switch (scenario) { - case Scenario::Default: _scenario = L"Default"; break; - case Scenario::Alarm: _scenario = L"Alarm"; break; - case Scenario::IncomingCall: _scenario = L"IncomingCall"; break; - case Scenario::Reminder: _scenario = L"Reminder"; break; - } -} - -void WinToastTemplate::setAttributionText(_In_ const std::wstring& attributionText) { - _attributionText = attributionText; -} - -void WinToastTemplate::addAction(_In_ const std::wstring & label) { - _actions.push_back(label); -} - -std::size_t WinToastTemplate::textFieldsCount() const { - return _textFields.size(); -} - -std::size_t WinToastTemplate::actionsCount() const { - return _actions.size(); -} - -bool WinToastTemplate::hasImage() const { - return _type < WinToastTemplateType::Text01; -} - -const std::vector& WinToastTemplate::textFields() const { - return _textFields; -} - -const std::wstring& WinToastTemplate::textField(_In_ TextField pos) const { - const auto position = static_cast(pos); - assert(position < _textFields.size()); - return _textFields[position]; -} - -const std::wstring& WinToastTemplate::actionLabel(_In_ std::size_t position) const { - assert(position < _actions.size()); - return _actions[position]; -} - -const std::wstring& WinToastTemplate::imagePath() const { - return _imagePath; -} - -const std::wstring& WinToastTemplate::audioPath() const { - return _audioPath; -} - -const std::wstring& WinToastTemplate::attributionText() const { - return _attributionText; -} - -const std::wstring& WinToastLib::WinToastTemplate::scenario() const { - return _scenario; -} - -INT64 WinToastTemplate::expiration() const { - return _expiration; -} - -WinToastTemplate::WinToastTemplateType WinToastTemplate::type() const { - return _type; -} - -WinToastTemplate::AudioOption WinToastTemplate::audioOption() const { - return _audioOption; -} - -WinToastTemplate::Duration WinToastTemplate::duration() const { - return _duration; -} diff --git a/third_party/WinToast/wintoastlib.h b/third_party/WinToast/wintoastlib.h deleted file mode 100644 index 93546dc5b8..0000000000 --- a/third_party/WinToast/wintoastlib.h +++ /dev/null @@ -1,234 +0,0 @@ -/* * Copyright (C) 2016-2019 Mohammed Boujemaoui - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef WINTOASTLIB_H -#define WINTOASTLIB_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -using namespace Microsoft::WRL; -using namespace ABI::Windows::Data::Xml::Dom; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::UI::Notifications; -using namespace Windows::Foundation; - - -namespace WinToastLib { - - class IWinToastHandler { - public: - enum WinToastDismissalReason { - UserCanceled = ToastDismissalReason::ToastDismissalReason_UserCanceled, - ApplicationHidden = ToastDismissalReason::ToastDismissalReason_ApplicationHidden, - TimedOut = ToastDismissalReason::ToastDismissalReason_TimedOut - }; - virtual ~IWinToastHandler() = default; - virtual void toastActivated() const = 0; - virtual void toastActivated(int actionIndex) const = 0; - virtual void toastDismissed(WinToastDismissalReason state) const = 0; - virtual void toastFailed() const = 0; - }; - - class WinToastTemplate { - public: - enum class Scenario { Default, Alarm, IncomingCall, Reminder }; - enum Duration { System, Short, Long }; - enum AudioOption { Default = 0, Silent, Loop }; - enum TextField { FirstLine = 0, SecondLine, ThirdLine }; - enum WinToastTemplateType { - ImageAndText01 = ToastTemplateType::ToastTemplateType_ToastImageAndText01, - ImageAndText02 = ToastTemplateType::ToastTemplateType_ToastImageAndText02, - ImageAndText03 = ToastTemplateType::ToastTemplateType_ToastImageAndText03, - ImageAndText04 = ToastTemplateType::ToastTemplateType_ToastImageAndText04, - Text01 = ToastTemplateType::ToastTemplateType_ToastText01, - Text02 = ToastTemplateType::ToastTemplateType_ToastText02, - Text03 = ToastTemplateType::ToastTemplateType_ToastText03, - Text04 = ToastTemplateType::ToastTemplateType_ToastText04, - }; - - enum AudioSystemFile { - DefaultSound, - IM, - Mail, - Reminder, - SMS, - Alarm, - Alarm2, - Alarm3, - Alarm4, - Alarm5, - Alarm6, - Alarm7, - Alarm8, - Alarm9, - Alarm10, - Call, - Call1, - Call2, - Call3, - Call4, - Call5, - Call6, - Call7, - Call8, - Call9, - Call10, - }; - - - WinToastTemplate(_In_ WinToastTemplateType type = WinToastTemplateType::ImageAndText02); - ~WinToastTemplate(); - - void setFirstLine(_In_ const std::wstring& text); - void setSecondLine(_In_ const std::wstring& text); - void setThirdLine(_In_ const std::wstring& text); - void setTextField(_In_ const std::wstring& txt, _In_ TextField pos); - void setAttributionText(_In_ const std::wstring& attributionText); - void setImagePath(_In_ const std::wstring& imgPath); - void setAudioPath(_In_ WinToastTemplate::AudioSystemFile audio); - void setAudioPath(_In_ const std::wstring& audioPath); - void setAudioOption(_In_ WinToastTemplate::AudioOption audioOption); - void setDuration(_In_ Duration duration); - void setExpiration(_In_ INT64 millisecondsFromNow); - void setScenario(_In_ Scenario scenario); - void addAction(_In_ const std::wstring& label); - - std::size_t textFieldsCount() const; - std::size_t actionsCount() const; - bool hasImage() const; - const std::vector& textFields() const; - const std::wstring& textField(_In_ TextField pos) const; - const std::wstring& actionLabel(_In_ std::size_t pos) const; - const std::wstring& imagePath() const; - const std::wstring& audioPath() const; - const std::wstring& attributionText() const; - const std::wstring& scenario() const; - INT64 expiration() const; - WinToastTemplateType type() const; - WinToastTemplate::AudioOption audioOption() const; - Duration duration() const; - private: - std::vector _textFields{}; - std::vector _actions{}; - std::wstring _imagePath{}; - std::wstring _audioPath{}; - std::wstring _attributionText{}; - std::wstring _scenario{L"Default"}; - INT64 _expiration{0}; - AudioOption _audioOption{WinToastTemplate::AudioOption::Default}; - WinToastTemplateType _type{WinToastTemplateType::Text01}; - Duration _duration{Duration::System}; - }; - - class WinToast { - public: - enum WinToastError { - NoError = 0, - NotInitialized, - SystemNotSupported, - ShellLinkNotCreated, - InvalidAppUserModelID, - InvalidParameters, - InvalidHandler, - NotDisplayed, - UnknownError - }; - - enum ShortcutResult { - SHORTCUT_UNCHANGED = 0, - SHORTCUT_WAS_CHANGED = 1, - SHORTCUT_WAS_CREATED = 2, - - SHORTCUT_MISSING_PARAMETERS = -1, - SHORTCUT_INCOMPATIBLE_OS = -2, - SHORTCUT_COM_INIT_FAILURE = -3, - SHORTCUT_CREATE_FAILED = -4 - }; - - enum ShortcutPolicy { - /* Don't check, create, or modify a shortcut. */ - SHORTCUT_POLICY_IGNORE = 0, - /* Require a shortcut with matching AUMI, don't create or modify an existing one. */ - SHORTCUT_POLICY_REQUIRE_NO_CREATE = 1, - /* Require a shortcut with matching AUMI, create if missing, modify if not matching. - * This is the default. */ - SHORTCUT_POLICY_REQUIRE_CREATE = 2, - }; - - WinToast(void); - virtual ~WinToast(); - static WinToast* instance(); - static bool isCompatible(); - static bool isSupportingModernFeatures(); - static std::wstring configureAUMI(_In_ const std::wstring& companyName, - _In_ const std::wstring& productName, - _In_ const std::wstring& subProduct = std::wstring(), - _In_ const std::wstring& versionInformation = std::wstring()); - static const std::wstring& strerror(_In_ WinToastError error); - virtual bool initialize(_Out_ WinToastError* error = nullptr); - virtual bool isInitialized() const; - virtual bool hideToast(_In_ INT64 id); - virtual INT64 showToast(_In_ const WinToastTemplate& toast, _In_ IWinToastHandler* handler, _Out_ WinToastError* error = nullptr); - virtual void clear(); - virtual enum ShortcutResult createShortcut(); - - const std::wstring& appName() const; - const std::wstring& appUserModelId() const; - void setAppUserModelId(_In_ const std::wstring& aumi); - void setAppName(_In_ const std::wstring& appName); - void setShortcutPolicy(_In_ ShortcutPolicy policy); - - protected: - bool _isInitialized{false}; - bool _hasCoInitialized{false}; - ShortcutPolicy _shortcutPolicy{SHORTCUT_POLICY_REQUIRE_CREATE}; - std::wstring _appName{}; - std::wstring _aumi{}; - std::map> _buffer{}; - - HRESULT validateShellLinkHelper(_Out_ bool& wasChanged); - HRESULT createShellLinkHelper(); - HRESULT setImageFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& path); - HRESULT setAudioFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& path, _In_opt_ WinToastTemplate::AudioOption option = WinToastTemplate::AudioOption::Default); - HRESULT setTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text, _In_ UINT32 pos); - HRESULT setAttributionTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text); - HRESULT addActionHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& action, _In_ const std::wstring& arguments); - HRESULT addDurationHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& duration); - HRESULT addScenarioHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& scenario); - ComPtr notifier(_In_ bool* succeded) const; - void setError(_Out_ WinToastError* error, _In_ WinToastError value); - }; -} -#endif // WINTOASTLIB_H diff --git a/third_party/aom/AUTHORS b/third_party/aom/AUTHORS index ade7a1a5d0..509c0d1c9d 100644 --- a/third_party/aom/AUTHORS +++ b/third_party/aom/AUTHORS @@ -235,6 +235,7 @@ Ronald S. Bultje Rostislav Pehlivanov Ruiling Song Rui Ueyama +Ruoyu Zhong Rupert Swarbrick Ryan Lei Ryan Overbeck diff --git a/third_party/aom/CHANGELOG b/third_party/aom/CHANGELOG index b243837d3c..b5c1afbba2 100644 --- a/third_party/aom/CHANGELOG +++ b/third_party/aom/CHANGELOG @@ -1,3 +1,39 @@ +2024-01-17 v3.8.1 + This release includes several bug fixes. This release is ABI + compatible with the last release. See + https://aomedia.googlesource.com/aom/+log/v3.8.0..v3.8.1 for all the + commits in this release. + + - Bug Fixes + * aomedia:3520: get_cubic_kernel_dbl: Assertion `0 <= x && x < 1' + failed. + * aomedia:3526: alloc_compressor_data() is called during every + aom_codec_control() call on the encoder. + * aomedia:3527: aom/av1/encoder/mcomp.c:1810: av1_full_pixel_search: + Assertion `ms_params->ms_buffers.ref->width == + ms_params->ms_buffers.src->width' failed. + * aomedia:3534: libaom encoder crashed by AOM_USAGE_ALL_INTRA and + AOM_EFLAG_NO_REF_LAST flags. + * b/310455204: Recreate workers if necessary. + * b/310548198: Update frame size in actual encoding. + * b/314858909: Do not use adaptive error estimate. + * Fix a hang of cmake on arm64 macOS with cmake 3.27.0 or later. + +2024-01-18 v3.7.2 + This release includes three bug fixes. This release is ABI compatible + with the last release. See + https://aomedia.googlesource.com/aom/+log/v3.7.1..v3.7.2 for all the + commits in this release. + + - Bug Fixes + * aomedia:3520: get_cubic_kernel_dbl: Assertion `0 <= x && x < 1' + failed. + * aomedia:3526: alloc_compressor_data() is called during every + aom_codec_control() call on the encoder. Note that this partially + reverts the fix for bug aomedia:3349. + * b/310457427 and b/310766628: Only use rec_sse in CBR mode. + * Fix a hang of cmake on arm64 macOS with cmake 3.27.0 or later. + 2023-11-30 v3.8.0 This release includes new codec interfaces, compression efficiency and perceptual improvements, speedup and memory optimizations and many bug diff --git a/third_party/aom/CMakeLists.txt b/third_party/aom/CMakeLists.txt index 76944e6917..a02b220bdb 100644 --- a/third_party/aom/CMakeLists.txt +++ b/third_party/aom/CMakeLists.txt @@ -59,7 +59,7 @@ endif() # # We set SO_FILE_VERSION = [c-a].a.r set(LT_CURRENT 11) -set(LT_REVISION 0) +set(LT_REVISION 1) set(LT_AGE 8) math(EXPR SO_VERSION "${LT_CURRENT} - ${LT_AGE}") set(SO_FILE_VERSION "${SO_VERSION}.${LT_AGE}.${LT_REVISION}") diff --git a/third_party/aom/aom/src/aom_codec.c b/third_party/aom/aom/src/aom_codec.c index 512fd28196..316cc6fd23 100644 --- a/third_party/aom/aom/src/aom_codec.c +++ b/third_party/aom/aom/src/aom_codec.c @@ -170,6 +170,7 @@ void aom_internal_error(struct aom_internal_error_info *info, void aom_internal_error_copy(struct aom_internal_error_info *info, const struct aom_internal_error_info *src) { assert(info != src); + assert(!src->setjmp); if (!src->has_detail) { aom_internal_error(info, src->error_code, NULL); diff --git a/third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl b/third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl index 4b49605e53..7bb156ac59 100755 --- a/third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl +++ b/third_party/aom/aom_dsp/aom_dsp_rtcd_defs.pl @@ -1352,16 +1352,19 @@ if (aom_config("CONFIG_AV1_ENCODER") eq "yes") { add_proto qw/unsigned int/, "aom_highbd_${bd}_mse8x16", "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; add_proto qw/unsigned int/, "aom_highbd_${bd}_mse8x8", "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"; - specialize "aom_highbd_${bd}_mse16x16", qw/sse2 neon sve/; - specialize "aom_highbd_${bd}_mse16x8", qw/neon sve/; - specialize "aom_highbd_${bd}_mse8x16", qw/neon sve/; - specialize "aom_highbd_${bd}_mse8x8", qw/sse2 neon sve/; - } + if ($bd eq 8) { + specialize "aom_highbd_${bd}_mse16x16", qw/sse2 neon neon_dotprod/; + specialize "aom_highbd_${bd}_mse16x8", qw/neon neon_dotprod/; + specialize "aom_highbd_${bd}_mse8x16", qw/neon neon_dotprod/; + specialize "aom_highbd_${bd}_mse8x8", qw/sse2 neon neon_dotprod/; + } else { + specialize "aom_highbd_${bd}_mse16x16", qw/sse2 neon sve/; + specialize "aom_highbd_${bd}_mse16x8", qw/neon sve/; + specialize "aom_highbd_${bd}_mse8x16", qw/neon sve/; + specialize "aom_highbd_${bd}_mse8x8", qw/sse2 neon sve/; + } - specialize "aom_highbd_8_mse16x16", qw/neon_dotprod/; - specialize "aom_highbd_8_mse16x8", qw/neon_dotprod/; - specialize "aom_highbd_8_mse8x16", qw/neon_dotprod/; - specialize "aom_highbd_8_mse8x8", qw/neon_dotprod/; + } } # diff --git a/third_party/aom/aom_dsp/arm/highbd_variance_sve.c b/third_party/aom/aom_dsp/arm/highbd_variance_sve.c index d0058bfa90..a2c30a1688 100644 --- a/third_party/aom/aom_dsp/arm/highbd_variance_sve.c +++ b/third_party/aom/aom_dsp/arm/highbd_variance_sve.c @@ -348,15 +348,6 @@ static INLINE uint32_t highbd_mse_wxh_sve(const uint16_t *src_ptr, } #define HIGHBD_MSE_WXH_SVE(w, h) \ - uint32_t aom_highbd_8_mse##w##x##h##_sve( \ - const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, \ - int ref_stride, uint32_t *sse) { \ - uint16_t *src = CONVERT_TO_SHORTPTR(src_ptr); \ - uint16_t *ref = CONVERT_TO_SHORTPTR(ref_ptr); \ - highbd_mse_wxh_sve(src, src_stride, ref, ref_stride, w, h, sse); \ - return *sse; \ - } \ - \ uint32_t aom_highbd_10_mse##w##x##h##_sve( \ const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, \ int ref_stride, uint32_t *sse) { \ diff --git a/third_party/aom/aom_dsp/arm/intrapred_neon.c b/third_party/aom/aom_dsp/arm/intrapred_neon.c index d8dc60c1fe..c3716b3a78 100644 --- a/third_party/aom/aom_dsp/arm/intrapred_neon.c +++ b/third_party/aom/aom_dsp/arm/intrapred_neon.c @@ -11,6 +11,7 @@ #include #include +#include #include "config/aom_config.h" #include "config/aom_dsp_rtcd.h" diff --git a/third_party/aom/aom_dsp/flow_estimation/arm/disflow_neon.c b/third_party/aom/aom_dsp/flow_estimation/arm/disflow_neon.c index ee42be7393..62729133e3 100644 --- a/third_party/aom/aom_dsp/flow_estimation/arm/disflow_neon.c +++ b/third_party/aom/aom_dsp/flow_estimation/arm/disflow_neon.c @@ -22,7 +22,7 @@ static INLINE void get_cubic_kernel_dbl(double x, double kernel[4]) { // Check that the fractional position is in range. // - // Note: x is calculated from (eg.) `u_frac = u - floor(u)`. + // Note: x is calculated from, e.g., `u_frac = u - floor(u)`. // Mathematically, this implies that 0 <= x < 1. However, in practice it is // possible to have x == 1 due to floating point rounding. This is fine, // and we still interpolate correctly if we allow x = 1. diff --git a/third_party/aom/aom_dsp/flow_estimation/corner_match.c b/third_party/aom/aom_dsp/flow_estimation/corner_match.c index cef719b68d..dc7589a8c6 100644 --- a/third_party/aom/aom_dsp/flow_estimation/corner_match.c +++ b/third_party/aom/aom_dsp/flow_estimation/corner_match.c @@ -224,7 +224,7 @@ bool av1_compute_global_motion_feature_match( *mem_alloc_failed = true; return false; } - if (!av1_compute_corner_list(src_pyramid, src_corners)) { + if (!av1_compute_corner_list(ref_pyramid, ref_corners)) { *mem_alloc_failed = true; return false; } diff --git a/third_party/aom/aom_dsp/flow_estimation/disflow.c b/third_party/aom/aom_dsp/flow_estimation/disflow.c index 147a8ab3b3..82b531c729 100644 --- a/third_party/aom/aom_dsp/flow_estimation/disflow.c +++ b/third_party/aom/aom_dsp/flow_estimation/disflow.c @@ -25,7 +25,7 @@ #include "config/aom_dsp_rtcd.h" // Amount to downsample the flow field by. -// eg. DOWNSAMPLE_SHIFT = 2 (DOWNSAMPLE_FACTOR == 4) means we calculate +// e.g., DOWNSAMPLE_SHIFT = 2 (DOWNSAMPLE_FACTOR == 4) means we calculate // one flow point for each 4x4 pixel region of the frame // Must be a power of 2 #define DOWNSAMPLE_SHIFT 3 @@ -66,7 +66,7 @@ static double flow_upscale_filter[2][FLOW_UPSCALE_TAPS] = { static INLINE void get_cubic_kernel_dbl(double x, double kernel[4]) { // Check that the fractional position is in range. // - // Note: x is calculated from (eg.) `u_frac = u - floor(u)`. + // Note: x is calculated from, e.g., `u_frac = u - floor(u)`. // Mathematically, this implies that 0 <= x < 1. However, in practice it is // possible to have x == 1 due to floating point rounding. This is fine, // and we still interpolate correctly if we allow x = 1. diff --git a/third_party/aom/aom_dsp/flow_estimation/x86/disflow_sse4.c b/third_party/aom/aom_dsp/flow_estimation/x86/disflow_sse4.c index d2b04c1973..2c5effd638 100644 --- a/third_party/aom/aom_dsp/flow_estimation/x86/disflow_sse4.c +++ b/third_party/aom/aom_dsp/flow_estimation/x86/disflow_sse4.c @@ -30,7 +30,7 @@ static INLINE void get_cubic_kernel_dbl(double x, double kernel[4]) { // Check that the fractional position is in range. // - // Note: x is calculated from (eg.) `u_frac = u - floor(u)`. + // Note: x is calculated from, e.g., `u_frac = u - floor(u)`. // Mathematically, this implies that 0 <= x < 1. However, in practice it is // possible to have x == 1 due to floating point rounding. This is fine, // and we still interpolate correctly if we allow x = 1. diff --git a/third_party/aom/av1/av1.cmake b/third_party/aom/av1/av1.cmake index 15577d0c0e..c66a748d40 100644 --- a/third_party/aom/av1/av1.cmake +++ b/third_party/aom/av1/av1.cmake @@ -406,6 +406,7 @@ list(APPEND AOM_AV1_COMMON_INTRIN_NEON_I8MM "${AOM_ROOT}/av1/common/arm/warp_plane_neon_i8mm.c") list(APPEND AOM_AV1_COMMON_INTRIN_SVE + "${AOM_ROOT}/av1/common/arm/highbd_warp_plane_sve.c" "${AOM_ROOT}/av1/common/arm/warp_plane_sve.c") list(APPEND AOM_AV1_ENCODER_INTRIN_SSE4_2 diff --git a/third_party/aom/av1/common/arm/highbd_warp_plane_sve.c b/third_party/aom/av1/common/arm/highbd_warp_plane_sve.c new file mode 100644 index 0000000000..7a14f21846 --- /dev/null +++ b/third_party/aom/av1/common/arm/highbd_warp_plane_sve.c @@ -0,0 +1,293 @@ +/* + * Copyright (c) 2024, Alliance for Open Media. All rights reserved + * + * This source code is subject to the terms of the BSD 2 Clause License and + * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License + * was not distributed with this source code in the LICENSE file, you can + * obtain it at www.aomedia.org/license/software. 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 www.aomedia.org/license/patent. + */ + +#include +#include +#include +#include + +#include "aom_dsp/aom_dsp_common.h" +#include "aom_dsp/arm/dot_sve.h" +#include "aom_dsp/arm/mem_neon.h" +#include "aom_dsp/arm/transpose_neon.h" +#include "aom_ports/mem.h" +#include "av1/common/scale.h" +#include "av1/common/warped_motion.h" +#include "config/av1_rtcd.h" +#include "highbd_warp_plane_neon.h" + +static INLINE int16x8_t highbd_horizontal_filter_4x1_f4(uint16x8x2_t in, int bd, + int sx, int alpha) { + int16x8_t f[4]; + load_filters_4(f, sx, alpha); + + int16x8_t rv0 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 0); + int16x8_t rv1 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 1); + int16x8_t rv2 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 2); + int16x8_t rv3 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 3); + + int64x2_t m0 = aom_sdotq_s16(vdupq_n_s64(0), rv0, f[0]); + int64x2_t m1 = aom_sdotq_s16(vdupq_n_s64(0), rv1, f[1]); + int64x2_t m2 = aom_sdotq_s16(vdupq_n_s64(0), rv2, f[2]); + int64x2_t m3 = aom_sdotq_s16(vdupq_n_s64(0), rv3, f[3]); + + int64x2_t m01 = vpaddq_s64(m0, m1); + int64x2_t m23 = vpaddq_s64(m2, m3); + + const int round0 = bd == 12 ? ROUND0_BITS + 2 : ROUND0_BITS; + const int offset_bits_horiz = bd + FILTER_BITS - 1; + + int32x4_t res = vcombine_s32(vmovn_s64(m01), vmovn_s64(m23)); + res = vaddq_s32(res, vdupq_n_s32(1 << offset_bits_horiz)); + res = vrshlq_s32(res, vdupq_n_s32(-round0)); + return vcombine_s16(vmovn_s32(res), vdup_n_s16(0)); +} + +static INLINE int16x8_t highbd_horizontal_filter_8x1_f8(uint16x8x2_t in, int bd, + int sx, int alpha) { + int16x8_t f[8]; + load_filters_8(f, sx, alpha); + + int16x8_t rv0 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 0); + int16x8_t rv1 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 1); + int16x8_t rv2 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 2); + int16x8_t rv3 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 3); + int16x8_t rv4 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 4); + int16x8_t rv5 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 5); + int16x8_t rv6 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 6); + int16x8_t rv7 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 7); + + int64x2_t m0 = aom_sdotq_s16(vdupq_n_s64(0), rv0, f[0]); + int64x2_t m1 = aom_sdotq_s16(vdupq_n_s64(0), rv1, f[1]); + int64x2_t m2 = aom_sdotq_s16(vdupq_n_s64(0), rv2, f[2]); + int64x2_t m3 = aom_sdotq_s16(vdupq_n_s64(0), rv3, f[3]); + int64x2_t m4 = aom_sdotq_s16(vdupq_n_s64(0), rv4, f[4]); + int64x2_t m5 = aom_sdotq_s16(vdupq_n_s64(0), rv5, f[5]); + int64x2_t m6 = aom_sdotq_s16(vdupq_n_s64(0), rv6, f[6]); + int64x2_t m7 = aom_sdotq_s16(vdupq_n_s64(0), rv7, f[7]); + + int64x2_t m01 = vpaddq_s64(m0, m1); + int64x2_t m23 = vpaddq_s64(m2, m3); + int64x2_t m45 = vpaddq_s64(m4, m5); + int64x2_t m67 = vpaddq_s64(m6, m7); + + const int round0 = bd == 12 ? ROUND0_BITS + 2 : ROUND0_BITS; + const int offset_bits_horiz = bd + FILTER_BITS - 1; + + int32x4_t res0 = vcombine_s32(vmovn_s64(m01), vmovn_s64(m23)); + int32x4_t res1 = vcombine_s32(vmovn_s64(m45), vmovn_s64(m67)); + res0 = vaddq_s32(res0, vdupq_n_s32(1 << offset_bits_horiz)); + res1 = vaddq_s32(res1, vdupq_n_s32(1 << offset_bits_horiz)); + res0 = vrshlq_s32(res0, vdupq_n_s32(-round0)); + res1 = vrshlq_s32(res1, vdupq_n_s32(-round0)); + return vcombine_s16(vmovn_s32(res0), vmovn_s32(res1)); +} + +static INLINE int16x8_t highbd_horizontal_filter_4x1_f1(uint16x8x2_t in, int bd, + int sx) { + int16x8_t f = load_filters_1(sx); + + int16x8_t rv0 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 0); + int16x8_t rv1 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 1); + int16x8_t rv2 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 2); + int16x8_t rv3 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 3); + + int64x2_t m0 = aom_sdotq_s16(vdupq_n_s64(0), rv0, f); + int64x2_t m1 = aom_sdotq_s16(vdupq_n_s64(0), rv1, f); + int64x2_t m2 = aom_sdotq_s16(vdupq_n_s64(0), rv2, f); + int64x2_t m3 = aom_sdotq_s16(vdupq_n_s64(0), rv3, f); + + int64x2_t m01 = vpaddq_s64(m0, m1); + int64x2_t m23 = vpaddq_s64(m2, m3); + + const int round0 = bd == 12 ? ROUND0_BITS + 2 : ROUND0_BITS; + const int offset_bits_horiz = bd + FILTER_BITS - 1; + + int32x4_t res = vcombine_s32(vmovn_s64(m01), vmovn_s64(m23)); + res = vaddq_s32(res, vdupq_n_s32(1 << offset_bits_horiz)); + res = vrshlq_s32(res, vdupq_n_s32(-round0)); + return vcombine_s16(vmovn_s32(res), vdup_n_s16(0)); +} + +static INLINE int16x8_t highbd_horizontal_filter_8x1_f1(uint16x8x2_t in, int bd, + int sx) { + int16x8_t f = load_filters_1(sx); + + int16x8_t rv0 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 0); + int16x8_t rv1 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 1); + int16x8_t rv2 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 2); + int16x8_t rv3 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 3); + int16x8_t rv4 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 4); + int16x8_t rv5 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 5); + int16x8_t rv6 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 6); + int16x8_t rv7 = vextq_s16(vreinterpretq_s16_u16(in.val[0]), + vreinterpretq_s16_u16(in.val[1]), 7); + + int64x2_t m0 = aom_sdotq_s16(vdupq_n_s64(0), rv0, f); + int64x2_t m1 = aom_sdotq_s16(vdupq_n_s64(0), rv1, f); + int64x2_t m2 = aom_sdotq_s16(vdupq_n_s64(0), rv2, f); + int64x2_t m3 = aom_sdotq_s16(vdupq_n_s64(0), rv3, f); + int64x2_t m4 = aom_sdotq_s16(vdupq_n_s64(0), rv4, f); + int64x2_t m5 = aom_sdotq_s16(vdupq_n_s64(0), rv5, f); + int64x2_t m6 = aom_sdotq_s16(vdupq_n_s64(0), rv6, f); + int64x2_t m7 = aom_sdotq_s16(vdupq_n_s64(0), rv7, f); + + int64x2_t m01 = vpaddq_s64(m0, m1); + int64x2_t m23 = vpaddq_s64(m2, m3); + int64x2_t m45 = vpaddq_s64(m4, m5); + int64x2_t m67 = vpaddq_s64(m6, m7); + + const int round0 = bd == 12 ? ROUND0_BITS + 2 : ROUND0_BITS; + const int offset_bits_horiz = bd + FILTER_BITS - 1; + + int32x4_t res0 = vcombine_s32(vmovn_s64(m01), vmovn_s64(m23)); + int32x4_t res1 = vcombine_s32(vmovn_s64(m45), vmovn_s64(m67)); + res0 = vaddq_s32(res0, vdupq_n_s32(1 << offset_bits_horiz)); + res1 = vaddq_s32(res1, vdupq_n_s32(1 << offset_bits_horiz)); + res0 = vrshlq_s32(res0, vdupq_n_s32(-round0)); + res1 = vrshlq_s32(res1, vdupq_n_s32(-round0)); + return vcombine_s16(vmovn_s32(res0), vmovn_s32(res1)); +} + +static INLINE int32x4_t vertical_filter_4x1_f1(const int16x8_t *tmp, int sy) { + const int16x8_t f = load_filters_1(sy); + const int16x4_t f0123 = vget_low_s16(f); + const int16x4_t f4567 = vget_high_s16(f); + + // No benefit to using SDOT here, the cost of rearrangement is too high. + int32x4_t m0123 = vmull_lane_s16(vget_low_s16(tmp[0]), f0123, 0); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[1]), f0123, 1); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[2]), f0123, 2); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[3]), f0123, 3); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[4]), f4567, 0); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[5]), f4567, 1); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[6]), f4567, 2); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[7]), f4567, 3); + return m0123; +} + +static INLINE int32x4x2_t vertical_filter_8x1_f1(const int16x8_t *tmp, int sy) { + const int16x8_t f = load_filters_1(sy); + const int16x4_t f0123 = vget_low_s16(f); + const int16x4_t f4567 = vget_high_s16(f); + + // No benefit to using SDOT here, the cost of rearrangement is too high. + int32x4_t m0123 = vmull_lane_s16(vget_low_s16(tmp[0]), f0123, 0); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[1]), f0123, 1); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[2]), f0123, 2); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[3]), f0123, 3); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[4]), f4567, 0); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[5]), f4567, 1); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[6]), f4567, 2); + m0123 = vmlal_lane_s16(m0123, vget_low_s16(tmp[7]), f4567, 3); + + int32x4_t m4567 = vmull_lane_s16(vget_high_s16(tmp[0]), f0123, 0); + m4567 = vmlal_lane_s16(m4567, vget_high_s16(tmp[1]), f0123, 1); + m4567 = vmlal_lane_s16(m4567, vget_high_s16(tmp[2]), f0123, 2); + m4567 = vmlal_lane_s16(m4567, vget_high_s16(tmp[3]), f0123, 3); + m4567 = vmlal_lane_s16(m4567, vget_high_s16(tmp[4]), f4567, 0); + m4567 = vmlal_lane_s16(m4567, vget_high_s16(tmp[5]), f4567, 1); + m4567 = vmlal_lane_s16(m4567, vget_high_s16(tmp[6]), f4567, 2); + m4567 = vmlal_lane_s16(m4567, vget_high_s16(tmp[7]), f4567, 3); + return (int32x4x2_t){ { m0123, m4567 } }; +} + +static INLINE int32x4_t vertical_filter_4x1_f4(const int16x8_t *tmp, int sy, + int gamma) { + int16x8_t s0, s1, s2, s3; + transpose_elems_s16_4x8( + vget_low_s16(tmp[0]), vget_low_s16(tmp[1]), vget_low_s16(tmp[2]), + vget_low_s16(tmp[3]), vget_low_s16(tmp[4]), vget_low_s16(tmp[5]), + vget_low_s16(tmp[6]), vget_low_s16(tmp[7]), &s0, &s1, &s2, &s3); + + int16x8_t f[4]; + load_filters_4(f, sy, gamma); + + int64x2_t m0 = aom_sdotq_s16(vdupq_n_s64(0), s0, f[0]); + int64x2_t m1 = aom_sdotq_s16(vdupq_n_s64(0), s1, f[1]); + int64x2_t m2 = aom_sdotq_s16(vdupq_n_s64(0), s2, f[2]); + int64x2_t m3 = aom_sdotq_s16(vdupq_n_s64(0), s3, f[3]); + + int64x2_t m01 = vpaddq_s64(m0, m1); + int64x2_t m23 = vpaddq_s64(m2, m3); + return vcombine_s32(vmovn_s64(m01), vmovn_s64(m23)); +} + +static INLINE int32x4x2_t vertical_filter_8x1_f8(const int16x8_t *tmp, int sy, + int gamma) { + int16x8_t s0 = tmp[0]; + int16x8_t s1 = tmp[1]; + int16x8_t s2 = tmp[2]; + int16x8_t s3 = tmp[3]; + int16x8_t s4 = tmp[4]; + int16x8_t s5 = tmp[5]; + int16x8_t s6 = tmp[6]; + int16x8_t s7 = tmp[7]; + transpose_elems_inplace_s16_8x8(&s0, &s1, &s2, &s3, &s4, &s5, &s6, &s7); + + int16x8_t f[8]; + load_filters_8(f, sy, gamma); + + int64x2_t m0 = aom_sdotq_s16(vdupq_n_s64(0), s0, f[0]); + int64x2_t m1 = aom_sdotq_s16(vdupq_n_s64(0), s1, f[1]); + int64x2_t m2 = aom_sdotq_s16(vdupq_n_s64(0), s2, f[2]); + int64x2_t m3 = aom_sdotq_s16(vdupq_n_s64(0), s3, f[3]); + int64x2_t m4 = aom_sdotq_s16(vdupq_n_s64(0), s4, f[4]); + int64x2_t m5 = aom_sdotq_s16(vdupq_n_s64(0), s5, f[5]); + int64x2_t m6 = aom_sdotq_s16(vdupq_n_s64(0), s6, f[6]); + int64x2_t m7 = aom_sdotq_s16(vdupq_n_s64(0), s7, f[7]); + + int64x2_t m01 = vpaddq_s64(m0, m1); + int64x2_t m23 = vpaddq_s64(m2, m3); + int64x2_t m45 = vpaddq_s64(m4, m5); + int64x2_t m67 = vpaddq_s64(m6, m7); + + int32x4x2_t ret; + ret.val[0] = vcombine_s32(vmovn_s64(m01), vmovn_s64(m23)); + ret.val[1] = vcombine_s32(vmovn_s64(m45), vmovn_s64(m67)); + return ret; +} + +void av1_highbd_warp_affine_sve(const int32_t *mat, const uint16_t *ref, + int width, int height, int stride, + uint16_t *pred, int p_col, int p_row, + int p_width, int p_height, int p_stride, + int subsampling_x, int subsampling_y, int bd, + ConvolveParams *conv_params, int16_t alpha, + int16_t beta, int16_t gamma, int16_t delta) { + highbd_warp_affine_common(mat, ref, width, height, stride, pred, p_col, p_row, + p_width, p_height, p_stride, subsampling_x, + subsampling_y, bd, conv_params, alpha, beta, gamma, + delta); +} diff --git a/third_party/aom/av1/common/av1_rtcd_defs.pl b/third_party/aom/av1/common/av1_rtcd_defs.pl index c5fe389ba1..ef999fbba2 100644 --- a/third_party/aom/av1/common/av1_rtcd_defs.pl +++ b/third_party/aom/av1/common/av1_rtcd_defs.pl @@ -541,7 +541,7 @@ if ($opts{config} !~ /libs-x86-win32-vs.*/) { # WARPED_MOTION / GLOBAL_MOTION functions if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") { add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta"; - specialize qw/av1_highbd_warp_affine sse4_1 avx2 neon/; + specialize qw/av1_highbd_warp_affine sse4_1 avx2 neon sve/; } add_proto qw/void av1_warp_affine/, "const int32_t *mat, const uint8_t *ref, int width, int height, int stride, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta"; diff --git a/third_party/aom/av1/common/reconintra.c b/third_party/aom/av1/common/reconintra.c index 20a1e12476..f68af18cb1 100644 --- a/third_party/aom/av1/common/reconintra.c +++ b/third_party/aom/av1/common/reconintra.c @@ -1368,7 +1368,7 @@ void av1_highbd_upsample_intra_edge_c(uint16_t *p, int sz, int bd) { } } -static void highbd_build_intra_predictors( +static void highbd_build_directional_and_filter_intra_predictors( const uint8_t *ref8, int ref_stride, uint8_t *dst8, int dst_stride, PREDICTION_MODE mode, int p_angle, FILTER_INTRA_MODE filter_intra_mode, TX_SIZE tx_size, int disable_edge_filter, int n_top_px, int n_topright_px, @@ -1376,7 +1376,7 @@ static void highbd_build_intra_predictors( int bit_depth) { int i; uint16_t *dst = CONVERT_TO_SHORTPTR(dst8); - uint16_t *ref = CONVERT_TO_SHORTPTR(ref8); + const uint16_t *const ref = CONVERT_TO_SHORTPTR(ref8); DECLARE_ALIGNED(16, uint16_t, left_data[NUM_INTRA_NEIGHBOUR_PIXELS]); DECLARE_ALIGNED(16, uint16_t, above_data[NUM_INTRA_NEIGHBOUR_PIXELS]); uint16_t *const above_row = above_data + 16; @@ -1390,7 +1390,8 @@ static void highbd_build_intra_predictors( const uint16_t *left_ref = ref - 1; const int is_dr_mode = av1_is_directional_mode(mode); const int use_filter_intra = filter_intra_mode != FILTER_INTRA_MODES; - int base = 128 << (bit_depth - 8); + assert(use_filter_intra || is_dr_mode); + const int base = 128 << (bit_depth - 8); // The left_data, above_data buffers must be zeroed to fix some intermittent // valgrind errors. Uninitialized reads in intra pred modules (e.g. width = 4 // path in av1_highbd_dr_prediction_z2_avx2()) from left_data, above_data are @@ -1492,49 +1493,124 @@ static void highbd_build_intra_predictors( return; } - if (is_dr_mode) { - int upsample_above = 0; - int upsample_left = 0; - if (!disable_edge_filter) { - const int need_right = p_angle < 90; - const int need_bottom = p_angle > 180; - if (p_angle != 90 && p_angle != 180) { - const int ab_le = need_above_left ? 1 : 0; - if (need_above && need_left && (txwpx + txhpx >= 24)) { - highbd_filter_intra_edge_corner(above_row, left_col); - } - if (need_above && n_top_px > 0) { - const int strength = intra_edge_filter_strength( - txwpx, txhpx, p_angle - 90, intra_edge_filter_type); - const int n_px = n_top_px + ab_le + (need_right ? txhpx : 0); - av1_highbd_filter_intra_edge(above_row - ab_le, n_px, strength); - } - if (need_left && n_left_px > 0) { - const int strength = intra_edge_filter_strength( - txhpx, txwpx, p_angle - 180, intra_edge_filter_type); - const int n_px = n_left_px + ab_le + (need_bottom ? txwpx : 0); - av1_highbd_filter_intra_edge(left_col - ab_le, n_px, strength); - } + assert(is_dr_mode); + int upsample_above = 0; + int upsample_left = 0; + if (!disable_edge_filter) { + const int need_right = p_angle < 90; + const int need_bottom = p_angle > 180; + if (p_angle != 90 && p_angle != 180) { + const int ab_le = need_above_left ? 1 : 0; + if (need_above && need_left && (txwpx + txhpx >= 24)) { + highbd_filter_intra_edge_corner(above_row, left_col); } - upsample_above = av1_use_intra_edge_upsample(txwpx, txhpx, p_angle - 90, - intra_edge_filter_type); - if (need_above && upsample_above) { - const int n_px = txwpx + (need_right ? txhpx : 0); - av1_highbd_upsample_intra_edge(above_row, n_px, bit_depth); + if (need_above && n_top_px > 0) { + const int strength = intra_edge_filter_strength( + txwpx, txhpx, p_angle - 90, intra_edge_filter_type); + const int n_px = n_top_px + ab_le + (need_right ? txhpx : 0); + av1_highbd_filter_intra_edge(above_row - ab_le, n_px, strength); } - upsample_left = av1_use_intra_edge_upsample(txhpx, txwpx, p_angle - 180, - intra_edge_filter_type); - if (need_left && upsample_left) { - const int n_px = txhpx + (need_bottom ? txwpx : 0); - av1_highbd_upsample_intra_edge(left_col, n_px, bit_depth); + if (need_left && n_left_px > 0) { + const int strength = intra_edge_filter_strength( + txhpx, txwpx, p_angle - 180, intra_edge_filter_type); + const int n_px = n_left_px + ab_le + (need_bottom ? txwpx : 0); + av1_highbd_filter_intra_edge(left_col - ab_le, n_px, strength); } } - highbd_dr_predictor(dst, dst_stride, tx_size, above_row, left_col, - upsample_above, upsample_left, p_angle, bit_depth); + upsample_above = av1_use_intra_edge_upsample(txwpx, txhpx, p_angle - 90, + intra_edge_filter_type); + if (need_above && upsample_above) { + const int n_px = txwpx + (need_right ? txhpx : 0); + av1_highbd_upsample_intra_edge(above_row, n_px, bit_depth); + } + upsample_left = av1_use_intra_edge_upsample(txhpx, txwpx, p_angle - 180, + intra_edge_filter_type); + if (need_left && upsample_left) { + const int n_px = txhpx + (need_bottom ? txwpx : 0); + av1_highbd_upsample_intra_edge(left_col, n_px, bit_depth); + } + } + highbd_dr_predictor(dst, dst_stride, tx_size, above_row, left_col, + upsample_above, upsample_left, p_angle, bit_depth); +} + +// For HBD encode/decode, this function generates the pred data of a given +// block for non-directional intra prediction modes (i.e., DC, SMOOTH, SMOOTH_H, +// SMOOTH_V and PAETH). +static void highbd_build_non_directional_intra_predictors( + const uint8_t *ref8, int ref_stride, uint8_t *dst8, int dst_stride, + PREDICTION_MODE mode, TX_SIZE tx_size, int n_top_px, int n_left_px, + int bit_depth) { + int i = 0; + uint16_t *dst = CONVERT_TO_SHORTPTR(dst8); + const uint16_t *const ref = CONVERT_TO_SHORTPTR(ref8); + const int txwpx = tx_size_wide[tx_size]; + const int txhpx = tx_size_high[tx_size]; + int need_left = extend_modes[mode] & NEED_LEFT; + int need_above = extend_modes[mode] & NEED_ABOVE; + int need_above_left = extend_modes[mode] & NEED_ABOVELEFT; + const uint16_t *above_ref = ref - ref_stride; + const uint16_t *left_ref = ref - 1; + const int base = 128 << (bit_depth - 8); + + assert(n_top_px >= 0); + assert(n_left_px >= 0); + assert(mode == DC_PRED || mode == SMOOTH_PRED || mode == SMOOTH_V_PRED || + mode == SMOOTH_H_PRED || mode == PAETH_PRED); + + if ((!need_above && n_left_px == 0) || (!need_left && n_top_px == 0)) { + int val = 0; + if (need_left) { + val = (n_top_px > 0) ? above_ref[0] : base + 1; + } else { + val = (n_left_px > 0) ? left_ref[0] : base - 1; + } + for (i = 0; i < txhpx; ++i) { + aom_memset16(dst, val, txwpx); + dst += dst_stride; + } return; } - // predict + DECLARE_ALIGNED(16, uint16_t, left_data[NUM_INTRA_NEIGHBOUR_PIXELS]); + DECLARE_ALIGNED(16, uint16_t, above_data[NUM_INTRA_NEIGHBOUR_PIXELS]); + uint16_t *const above_row = above_data + 16; + uint16_t *const left_col = left_data + 16; + + if (need_left) { + aom_memset16(left_data, base + 1, NUM_INTRA_NEIGHBOUR_PIXELS); + if (n_left_px > 0) { + for (i = 0; i < n_left_px; i++) left_col[i] = left_ref[i * ref_stride]; + if (i < txhpx) aom_memset16(&left_col[i], left_col[i - 1], txhpx - i); + } else if (n_top_px > 0) { + aom_memset16(left_col, above_ref[0], txhpx); + } + } + + if (need_above) { + aom_memset16(above_data, base - 1, NUM_INTRA_NEIGHBOUR_PIXELS); + if (n_top_px > 0) { + memcpy(above_row, above_ref, n_top_px * sizeof(above_ref[0])); + i = n_top_px; + if (i < txwpx) aom_memset16(&above_row[i], above_row[i - 1], (txwpx - i)); + } else if (n_left_px > 0) { + aom_memset16(above_row, left_ref[0], txwpx); + } + } + + if (need_above_left) { + if (n_top_px > 0 && n_left_px > 0) { + above_row[-1] = above_ref[-1]; + } else if (n_top_px > 0) { + above_row[-1] = above_ref[0]; + } else if (n_left_px > 0) { + above_row[-1] = left_ref[0]; + } else { + above_row[-1] = base; + } + left_col[-1] = above_row[-1]; + } + if (mode == DC_PRED) { dc_pred_high[n_left_px > 0][n_top_px > 0][tx_size]( dst, dst_stride, above_row, left_col, bit_depth); @@ -1660,12 +1736,19 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, BLOCK_SIZE sb_size, // separate function build_non_directional_intra_predictors() is introduced // for these modes to avoid redundant computations while generating pred data. - // TODO(aomedia:3532): Enable this refactoring for high bd path as well. - if (!is_hbd && !use_filter_intra && !is_dr_mode) { - build_non_directional_intra_predictors( - ref, ref_stride, dst, dst_stride, mode, tx_size, - have_top ? AOMMIN(txwpx, xr + txwpx) : 0, - have_left ? AOMMIN(txhpx, yd + txhpx) : 0); + const int n_top_px = have_top ? AOMMIN(txwpx, xr + txwpx) : 0; + const int n_left_px = have_left ? AOMMIN(txhpx, yd + txhpx) : 0; + if (!use_filter_intra && !is_dr_mode) { +#if CONFIG_AV1_HIGHBITDEPTH + if (is_hbd) { + highbd_build_non_directional_intra_predictors( + ref, ref_stride, dst, dst_stride, mode, tx_size, n_top_px, n_left_px, + xd->bd); + return; + } +#endif // CONFIG_AV1_HIGHBITDEPTH + build_non_directional_intra_predictors(ref, ref_stride, dst, dst_stride, + mode, tx_size, n_top_px, n_left_px); return; } @@ -1717,25 +1800,23 @@ void av1_predict_intra_block(const MACROBLOCKD *xd, BLOCK_SIZE sb_size, const int disable_edge_filter = !enable_intra_edge_filter; const int intra_edge_filter_type = get_intra_edge_filter_type(xd, plane); + const int n_topright_px = + have_top_right > 0 ? AOMMIN(txwpx, xr) : have_top_right; + const int n_bottomleft_px = + have_bottom_left > 0 ? AOMMIN(txhpx, yd) : have_bottom_left; #if CONFIG_AV1_HIGHBITDEPTH if (is_hbd) { - highbd_build_intra_predictors( + highbd_build_directional_and_filter_intra_predictors( ref, ref_stride, dst, dst_stride, mode, p_angle, filter_intra_mode, - tx_size, disable_edge_filter, have_top ? AOMMIN(txwpx, xr + txwpx) : 0, - have_top_right > 0 ? AOMMIN(txwpx, xr) : have_top_right, - have_left ? AOMMIN(txhpx, yd + txhpx) : 0, - have_bottom_left > 0 ? AOMMIN(txhpx, yd) : have_bottom_left, - intra_edge_filter_type, xd->bd); + tx_size, disable_edge_filter, n_top_px, n_topright_px, n_left_px, + n_bottomleft_px, intra_edge_filter_type, xd->bd); return; } #endif build_directional_and_filter_intra_predictors( ref, ref_stride, dst, dst_stride, mode, p_angle, filter_intra_mode, - tx_size, disable_edge_filter, have_top ? AOMMIN(txwpx, xr + txwpx) : 0, - have_top_right > 0 ? AOMMIN(txwpx, xr) : have_top_right, - have_left ? AOMMIN(txhpx, yd + txhpx) : 0, - have_bottom_left > 0 ? AOMMIN(txhpx, yd) : have_bottom_left, - intra_edge_filter_type); + tx_size, disable_edge_filter, n_top_px, n_topright_px, n_left_px, + n_bottomleft_px, intra_edge_filter_type); } void av1_predict_intra_block_facade(const AV1_COMMON *cm, MACROBLOCKD *xd, diff --git a/third_party/aom/av1/encoder/encoder.c b/third_party/aom/av1/encoder/encoder.c index 4732ad435b..fe053af5cc 100644 --- a/third_party/aom/av1/encoder/encoder.c +++ b/third_party/aom/av1/encoder/encoder.c @@ -2594,15 +2594,19 @@ static int encode_without_recode(AV1_COMP *cpi) { if (cpi->ref_frame_flags & av1_ref_frame_flag_list[GOLDEN_FRAME]) { const YV12_BUFFER_CONFIG *const ref = get_ref_frame_yv12_buf(cm, GOLDEN_FRAME); - if (ref->y_crop_width != cm->width || ref->y_crop_height != cm->height) + if (ref == NULL || ref->y_crop_width != cm->width || + ref->y_crop_height != cm->height) { cpi->ref_frame_flags ^= AOM_GOLD_FLAG; + } } } if (cpi->ref_frame_flags & av1_ref_frame_flag_list[ALTREF_FRAME]) { const YV12_BUFFER_CONFIG *const ref = get_ref_frame_yv12_buf(cm, ALTREF_FRAME); - if (ref->y_crop_width != cm->width || ref->y_crop_height != cm->height) + if (ref == NULL || ref->y_crop_width != cm->width || + ref->y_crop_height != cm->height) { cpi->ref_frame_flags ^= AOM_ALT_FLAG; + } } } @@ -2700,10 +2704,13 @@ static int encode_without_recode(AV1_COMP *cpi) { update_motion_stat(cpi); // Adjust the refresh of the golden (longer-term) reference based on QP - // selected for this frame. This is for CBR with 1 layer/non-svc RTC mode. + // selected for this frame. This is for CBR real-time mode, and only + // for single layer without usage of the set_ref_frame_config (so + // reference structure for 1 layer is set internally). if (!frame_is_intra_only(cm) && cpi->oxcf.rc_cfg.mode == AOM_CBR && cpi->oxcf.mode == REALTIME && svc->number_spatial_layers == 1 && svc->number_temporal_layers == 1 && !cpi->rc.rtc_external_ratectrl && + !cpi->ppi->rtc_ref.set_ref_frame_config && sf->rt_sf.gf_refresh_based_on_qp) av1_adjust_gf_refresh_qp_one_pass_rt(cpi); diff --git a/third_party/aom/av1/encoder/encoder.h b/third_party/aom/av1/encoder/encoder.h index 5f6f67eda8..e87ab9be1f 100644 --- a/third_party/aom/av1/encoder/encoder.h +++ b/third_party/aom/av1/encoder/encoder.h @@ -3156,14 +3156,14 @@ typedef struct AV1_COMP { FRAME_INDEX_SET frame_index_set; /*! - * Store the cm->width in the last call of alloc_compressor_data(). Help + * Stores the cm->width in the last call of alloc_compressor_data(). Helps * determine whether compressor data should be reallocated when cm->width * changes. */ int data_alloc_width; /*! - * Store the cm->height in the last call of alloc_compressor_data(). Help + * Stores the cm->height in the last call of alloc_compressor_data(). Helps * determine whether compressor data should be reallocated when cm->height * changes. */ diff --git a/third_party/aom/av1/encoder/mcomp.c b/third_party/aom/av1/encoder/mcomp.c index 4e53447379..f3a9828cb3 100644 --- a/third_party/aom/av1/encoder/mcomp.c +++ b/third_party/aom/av1/encoder/mcomp.c @@ -1807,7 +1807,6 @@ int av1_full_pixel_search(const FULLPEL_MV start_mv, } assert(ms_params->ms_buffers.ref->stride == ms_params->search_sites->stride); - assert(ms_params->ms_buffers.ref->width == ms_params->ms_buffers.src->width); switch (search_method) { case FAST_BIGDIA: diff --git a/third_party/aom/av1/encoder/speed_features.c b/third_party/aom/av1/encoder/speed_features.c index a6c0971096..63d69cadc5 100644 --- a/third_party/aom/av1/encoder/speed_features.c +++ b/third_party/aom/av1/encoder/speed_features.c @@ -1624,6 +1624,14 @@ static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi, sf->rt_sf.use_rtc_tf = 0; sf->rt_sf.nonrd_prune_ref_frame_search = 1; } + // rtc_tf feature allocates new source because of possible + // temporal filtering which may change the input source during encoding: + // this causes an issue on resized frames when psnr is calculated, + // so disable it here for frames that are resized (encoding width/height + // different from configured width/height). + if (is_psnr_calc_enabled(cpi) && (cpi->oxcf.frm_dim_cfg.width != cm->width || + cpi->oxcf.frm_dim_cfg.height != cm->height)) + sf->rt_sf.use_rtc_tf = 0; } // TODO(kyslov): now this is very similar to diff --git a/third_party/aom/common/tools_common.c b/third_party/aom/common/tools_common.c index 4d77a1b427..db02ca6299 100644 --- a/third_party/aom/common/tools_common.c +++ b/third_party/aom/common/tools_common.c @@ -97,7 +97,7 @@ int read_yuv_frame(struct AvxInputContext *input_ctx, aom_image_t *yuv_frame) { int w = aom_img_plane_width(yuv_frame, plane); const int h = aom_img_plane_height(yuv_frame, plane); int r; - // Assuming that for nv12 we read all chroma data at one time + // Assuming that for nv12 we read all chroma data at once if (yuv_frame->fmt == AOM_IMG_FMT_NV12 && plane > 1) break; if (yuv_frame->fmt == AOM_IMG_FMT_NV12 && plane == 1) w *= 2; /* Determine the correct plane based on the image format. The for-loop @@ -245,17 +245,21 @@ uint32_t get_fourcc_by_aom_decoder(aom_codec_iface_t *iface) { void aom_img_write(const aom_image_t *img, FILE *file) { int plane; + const int bytespp = (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1; for (plane = 0; plane < 3; ++plane) { const unsigned char *buf = img->planes[plane]; const int stride = img->stride[plane]; - const int w = aom_img_plane_width(img, plane) * - ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1); + int w = aom_img_plane_width(img, plane); const int h = aom_img_plane_height(img, plane); int y; + // Assuming that for nv12 we write all chroma data at once + if (img->fmt == AOM_IMG_FMT_NV12 && plane > 1) break; + if (img->fmt == AOM_IMG_FMT_NV12 && plane == 1) w *= 2; + for (y = 0; y < h; ++y) { - fwrite(buf, 1, w, file); + fwrite(buf, bytespp, w, file); buf += stride; } } @@ -268,12 +272,16 @@ bool aom_img_read(aom_image_t *img, FILE *file) { for (plane = 0; plane < 3; ++plane) { unsigned char *buf = img->planes[plane]; const int stride = img->stride[plane]; - const int w = aom_img_plane_width(img, plane) * bytespp; + int w = aom_img_plane_width(img, plane); const int h = aom_img_plane_height(img, plane); int y; + // Assuming that for nv12 we read all chroma data at once + if (img->fmt == AOM_IMG_FMT_NV12 && plane > 1) break; + if (img->fmt == AOM_IMG_FMT_NV12 && plane == 1) w *= 2; + for (y = 0; y < h; ++y) { - if (fread(buf, 1, w, file) != (size_t)w) return false; + if (fread(buf, bytespp, w, file) != (size_t)w) return false; buf += stride; } } diff --git a/third_party/aom/test/av1_c_vs_simd_encode.sh b/third_party/aom/test/av1_c_vs_simd_encode.sh index 296204d118..897ac081c1 100755 --- a/third_party/aom/test/av1_c_vs_simd_encode.sh +++ b/third_party/aom/test/av1_c_vs_simd_encode.sh @@ -104,16 +104,16 @@ av1_c_vs_simd_enc_verify_environment () { # } # Echo AOM_SIMD_CAPS_MASK for different instruction set architecture. -avx512f() { +avx2() { echo "0x1FF" } -avx2() { - echo "0x0FF" +avx() { + echo "0x17F" } -avx() { - echo "0x07F" +sse4_2() { + echo "0x13F" } sse4_1() { @@ -443,21 +443,21 @@ av1_test_generic() { done } -# This function encodes AV1 bitstream by enabling SSE2, SSE3, SSSE3, SSE4_1, AVX, AVX2 as there are -# no functions with MMX, SSE and AVX512 specialization. +# This function encodes AV1 bitstream by enabling SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2 as +# there are no functions with MMX, SSE and AVX512 specialization. # The value of environment variable 'AOM_SIMD_CAPS_MASK' controls enabling of different instruction # set extension optimizations. The value of the flag 'AOM_SIMD_CAPS_MASK' and the corresponding # instruction set extension optimization enabled are as follows: -# AVX512 AVX2 AVX SSE4_1 SSSE3 SSE3 SSE2 SSE MMX -# 1 1 1 1 1 1 1 1 1 -> 0x1FF -> Enable AVX512 and lower variants -# 0 1 1 1 1 1 1 1 1 -> 0x0FF -> Enable AVX2 and lower variants -# 0 0 1 1 1 1 1 1 1 -> 0x07F -> Enable AVX and lower variants -# 0 0 0 1 1 1 1 1 1 -> 0x03F -> Enable SSE4_1 and lower variants -# 0 0 0 0 1 1 1 1 1 -> 0x01F -> Enable SSSE3 and lower variants -# 0 0 0 0 0 1 1 1 1 -> 0x00F -> Enable SSE3 and lower variants -# 0 0 0 0 0 0 1 1 1 -> 0x007 -> Enable SSE2 and lower variants -# 0 0 0 0 0 0 0 1 1 -> 0x003 -> Enable SSE and lower variants -# 0 0 0 0 0 0 0 0 1 -> 0x001 -> Enable MMX +# SSE4_2 AVX2 AVX SSE4_1 SSSE3 SSE3 SSE2 SSE MMX +# 1 1 1 1 1 1 1 1 1 -> 0x1FF -> Enable AVX2 and lower variants +# 1 0 1 1 1 1 1 1 1 -> 0x17F -> Enable AVX and lower variants +# 1 0 0 1 1 1 1 1 1 -> 0x13F -> Enable SSE4_2 and lower variants +# 0 0 0 1 1 1 1 1 1 -> 0x03F -> Enable SSE4_1 and lower variants +# 0 0 0 0 1 1 1 1 1 -> 0x01F -> Enable SSSE3 and lower variants +# 0 0 0 0 0 1 1 1 1 -> 0x00F -> Enable SSE3 and lower variants +# 0 0 0 0 0 0 1 1 1 -> 0x007 -> Enable SSE2 and lower variants +# 0 0 0 0 0 0 0 1 1 -> 0x003 -> Enable SSE and lower variants +# 0 0 0 0 0 0 0 0 1 -> 0x001 -> Enable MMX ## NOTE: In x86_64 platform, it is not possible to enable sse/mmx/c using "AOM_SIMD_CAPS_MASK" as # all x86_64 platforms implement sse2. av1_test_x86() { @@ -478,8 +478,8 @@ av1_test_x86() { local cmake_command="cmake $LIBAOM_SOURCE_DIR" fi - # Available x86 isa variants: "avx2 avx sse4_1 ssse3 sse3 sse2" - local x86_isa_variants="avx2 sse4_1 sse2" + # Available x86 isa variants: "avx2 avx sse4_2 sse4_1 ssse3 sse3 sse2" + local x86_isa_variants="avx2 sse4_2 sse2" echo "Build for x86: ${target}" if ! av1_enc_build "${target}" "${cmake_command}"; then diff --git a/third_party/aom/test/dr_prediction_test.cc b/third_party/aom/test/dr_prediction_test.cc index 3865810e9b..c23b08e481 100644 --- a/third_party/aom/test/dr_prediction_test.cc +++ b/third_party/aom/test/dr_prediction_test.cc @@ -10,6 +10,7 @@ */ #include +#include #include "third_party/googletest/src/googletest/include/gtest/gtest.h" @@ -18,6 +19,7 @@ #include "aom_mem/aom_mem.h" #include "aom_ports/aom_timer.h" +#include "aom_ports/sanitizer.h" #include "av1/common/blockd.h" #include "av1/common/pred_common.h" #include "av1/common/reconintra.h" @@ -149,8 +151,6 @@ class DrPredTest : public ::testing::TestWithParam > { protected: static const int kMaxNumTests = 10000; static const int kIterations = 10; - static const int kDstStride = 64; - static const int kDstSize = kDstStride * kDstStride; static const int kOffset = 16; static const int kBufSize = ((2 * MAX_TX_SIZE) << 1) + 16; @@ -161,9 +161,6 @@ class DrPredTest : public ::testing::TestWithParam > { start_angle_ = params_.start_angle; stop_angle_ = start_angle_ + 90; - dst_ref_ = &dst_ref_data_[0]; - dst_tst_ = &dst_tst_data_[0]; - dst_stride_ = kDstStride; above_ = &above_data_[kOffset]; left_ = &left_data_[kOffset]; @@ -171,16 +168,12 @@ class DrPredTest : public ::testing::TestWithParam > { above_data_[i] = rng_.Rand8(); left_data_[i] = rng_.Rand8(); } - - for (int i = 0; i < kDstSize; ++i) { - dst_ref_[i] = 0; - dst_tst_[i] = 0; - } } ~DrPredTest() override = default; - void Predict(bool speedtest, int tx) { + void Predict(bool speedtest, int tx, Pixel *dst_ref, Pixel *dst_tst, + int dst_stride) { const int kNumTests = speedtest ? kMaxNumTests : 1; aom_usec_timer timer; int tst_time = 0; @@ -189,7 +182,7 @@ class DrPredTest : public ::testing::TestWithParam > { aom_usec_timer_start(&timer); for (int k = 0; k < kNumTests; ++k) { - params_.ref_fn(dst_ref_, dst_stride_, bw_, bh_, above_, left_, + params_.ref_fn(dst_ref, dst_stride, bw_, bh_, above_, left_, upsample_above_, upsample_left_, dx_, dy_, bd_); } aom_usec_timer_mark(&timer); @@ -198,15 +191,17 @@ class DrPredTest : public ::testing::TestWithParam > { if (params_.tst_fn) { aom_usec_timer_start(&timer); for (int k = 0; k < kNumTests; ++k) { - API_REGISTER_STATE_CHECK(params_.tst_fn(dst_tst_, dst_stride_, bw_, bh_, + API_REGISTER_STATE_CHECK(params_.tst_fn(dst_tst, dst_stride, bw_, bh_, above_, left_, upsample_above_, upsample_left_, dx_, dy_, bd_)); } aom_usec_timer_mark(&timer); tst_time = static_cast(aom_usec_timer_elapsed(&timer)); } else { - for (int i = 0; i < kDstSize; ++i) { - dst_ref_[i] = dst_tst_[i]; + for (int r = 0; r < bh_; ++r) { + for (int c = 0; c < bw_; ++c) { + dst_tst[r * dst_stride + c] = dst_ref[r * dst_stride + c]; + } } } @@ -222,18 +217,6 @@ class DrPredTest : public ::testing::TestWithParam > { } } for (int tx = 0; tx < TX_SIZES_ALL; ++tx) { - if (params_.tst_fn == nullptr) { - for (int i = 0; i < kDstSize; ++i) { - dst_tst_[i] = (1 << bd_) - 1; - dst_ref_[i] = (1 << bd_) - 1; - } - } else { - for (int i = 0; i < kDstSize; ++i) { - dst_ref_[i] = 0; - dst_tst_[i] = 0; - } - } - bw_ = tx_size_wide[kTxSize[tx]]; bh_ = tx_size_high[kTxSize[tx]]; @@ -246,12 +229,31 @@ class DrPredTest : public ::testing::TestWithParam > { upsample_above_ = upsample_left_ = 0; } - Predict(speedtest, tx); + // Add additional padding to allow detection of over reads/writes when + // the transform width is equal to MAX_TX_SIZE. + const int dst_stride = MAX_TX_SIZE + 16; + std::vector dst_ref(dst_stride * bh_); + std::vector dst_tst(dst_stride * bh_); + + for (int r = 0; r < bh_; ++r) { + ASAN_POISON_MEMORY_REGION(&dst_ref[r * dst_stride + bw_], + (dst_stride - bw_) * sizeof(Pixel)); + ASAN_POISON_MEMORY_REGION(&dst_tst[r * dst_stride + bw_], + (dst_stride - bw_) * sizeof(Pixel)); + } + + Predict(speedtest, tx, dst_ref.data(), dst_tst.data(), dst_stride); + + for (int r = 0; r < bh_; ++r) { + ASAN_UNPOISON_MEMORY_REGION(&dst_ref[r * dst_stride + bw_], + (dst_stride - bw_) * sizeof(Pixel)); + ASAN_UNPOISON_MEMORY_REGION(&dst_tst[r * dst_stride + bw_], + (dst_stride - bw_) * sizeof(Pixel)); + } for (int r = 0; r < bh_; ++r) { for (int c = 0; c < bw_; ++c) { - ASSERT_EQ(dst_ref_[r * dst_stride_ + c], - dst_tst_[r * dst_stride_ + c]) + ASSERT_EQ(dst_ref[r * dst_stride + c], dst_tst[r * dst_stride + c]) << bw_ << "x" << bh_ << " r: " << r << " c: " << c << " dx: " << dx_ << " dy: " << dy_ << " upsample_above: " << upsample_above_ @@ -292,18 +294,12 @@ class DrPredTest : public ::testing::TestWithParam > { } } - Pixel dst_ref_data_[kDstSize]; - Pixel dst_tst_data_[kDstSize]; - Pixel left_data_[kBufSize]; Pixel dummy_data_[kBufSize]; Pixel above_data_[kBufSize]; - Pixel *dst_ref_; - Pixel *dst_tst_; Pixel *above_; Pixel *left_; - int dst_stride_; int enable_upsample_; int upsample_above_; diff --git a/third_party/aom/test/encode_api_test.cc b/third_party/aom/test/encode_api_test.cc index aa4084f9e4..605743f9be 100644 --- a/third_party/aom/test/encode_api_test.cc +++ b/third_party/aom/test/encode_api_test.cc @@ -654,6 +654,52 @@ TEST(EncodeAPI, AllIntraMode) { cfg.kf_max_dist = 1; EXPECT_EQ(AOM_CODEC_INVALID_PARAM, aom_codec_enc_init(&enc, iface, &cfg, 0)); } -#endif + +TEST(EncodeAPI, AllIntraAndUsePsnr) { + aom_codec_iface_t *iface = aom_codec_av1_cx(); + aom_codec_enc_cfg_t cfg; + ASSERT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA), + AOM_CODEC_OK); + + aom_codec_ctx_t enc; + ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, AOM_CODEC_USE_PSNR), + AOM_CODEC_OK); + + aom_image_t *image = CreateGrayImage(AOM_IMG_FMT_I420, cfg.g_w, cfg.g_h); + ASSERT_NE(image, nullptr); + + ASSERT_EQ(aom_codec_encode(&enc, image, 0, 1, 0), AOM_CODEC_OK); + const aom_codec_cx_pkt_t *pkt; + aom_codec_iter_t iter = nullptr; + while ((pkt = aom_codec_get_cx_data(&enc, &iter)) != nullptr) { + if (pkt->kind != AOM_CODEC_CX_FRAME_PKT) { + ASSERT_EQ(pkt->kind, AOM_CODEC_PSNR_PKT); + } + } + + aom_img_free(image); + ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK); +} + +// A test that reproduces bug aomedia:3534. +TEST(EncodeAPI, AllIntraAndNoRefLast) { + aom_codec_iface_t *iface = aom_codec_av1_cx(); + aom_codec_enc_cfg_t cfg; + ASSERT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA), + AOM_CODEC_OK); + + aom_codec_ctx_t enc; + ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, 0), AOM_CODEC_OK); + + aom_image_t *image = CreateGrayImage(AOM_IMG_FMT_I420, cfg.g_w, cfg.g_h); + ASSERT_NE(image, nullptr); + + ASSERT_EQ(aom_codec_encode(&enc, image, 0, 1, AOM_EFLAG_NO_REF_LAST), + AOM_CODEC_OK); + + aom_img_free(image); + ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK); +} +#endif // !CONFIG_REALTIME_ONLY } // namespace diff --git a/third_party/aom/test/resize_test.cc b/third_party/aom/test/resize_test.cc index 7bad45300a..755d4e3d02 100644 --- a/third_party/aom/test/resize_test.cc +++ b/third_party/aom/test/resize_test.cc @@ -11,15 +11,17 @@ #include #include + +#include "aom/aomcx.h" #include "aom_dsp/aom_dsp_common.h" -#include "common/tools_common.h" #include "av1/encoder/encoder.h" +#include "common/tools_common.h" #include "third_party/googletest/src/googletest/include/gtest/gtest.h" #include "test/codec_factory.h" #include "test/encode_test_driver.h" #include "test/i420_video_source.h" -#include "test/video_source.h" #include "test/util.h" +#include "test/video_source.h" #include "test/y4m_video_source.h" // Enable(1) or Disable(0) writing of the compressed bitstream. @@ -403,7 +405,7 @@ class ResizeRealtimeTest ResizeRealtimeTest() : EncoderTest(GET_PARAM(0)), num_threads_(GET_PARAM(3)), set_scale_mode_(false), set_scale_mode2_(false), - set_scale_mode3_(false) {} + set_scale_mode3_(false), is_screen_(false) {} ~ResizeRealtimeTest() override = default; void PreEncodeFrameHook(libaom_test::VideoSource *video, @@ -415,6 +417,8 @@ class ResizeRealtimeTest encoder->Control(AV1E_SET_ENABLE_OBMC, 0); encoder->Control(AOME_SET_CPUUSED, set_cpu_used_); encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING, 1); + if (is_screen_) + encoder->Control(AV1E_SET_TUNE_CONTENT, AOM_CONTENT_SCREEN); } if (set_scale_mode_) { struct aom_scaling_mode mode; @@ -508,6 +512,7 @@ class ResizeRealtimeTest bool set_scale_mode_; bool set_scale_mode2_; bool set_scale_mode3_; + bool is_screen_; }; // Check the AOME_SET_SCALEMODE control by downsizing to @@ -740,6 +745,7 @@ TEST_P(ResizeRealtimeTest, TestInternalResizeDown) { TEST_P(ResizeRealtimeTest, TestInternalResizeDownUpChangeBitRate) { ::libaom_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1, 0, 400); + init_flags_ = AOM_CODEC_USE_PSNR; cfg_.g_w = 640; cfg_.g_h = 480; change_bitrate_ = true; @@ -795,6 +801,63 @@ TEST_P(ResizeRealtimeTest, TestInternalResizeDownUpChangeBitRate) { #endif } +// Verify the dynamic resizer behavior for real time, 1 pass CBR mode for +// screen content mode. Start at low target bitrate, raise the bitrate in the +// middle of the clip (at frame# = frame_change_bitrate_), scaling-up should +// occur after bitrate is increased. +TEST_P(ResizeRealtimeTest, TestInternalResizeDownUpChangeBitRateScreen) { + ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, + 30, 1, 0, 300); + init_flags_ = AOM_CODEC_USE_PSNR; + cfg_.g_w = 352; + cfg_.g_h = 288; + change_bitrate_ = true; + frame_change_bitrate_ = 120; + set_scale_mode_ = false; + set_scale_mode2_ = false; + set_scale_mode3_ = false; + mismatch_psnr_ = 0.0; + mismatch_nframes_ = 0; + is_screen_ = true; + DefaultConfig(); + // Disable dropped frames. + cfg_.rc_dropframe_thresh = 0; + // Starting bitrate low. + cfg_.rc_target_bitrate = 100; + cfg_.rc_resize_mode = RESIZE_DYNAMIC; + cfg_.g_forced_max_frame_width = 1280; + cfg_.g_forced_max_frame_height = 1280; + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + + unsigned int last_w = cfg_.g_w; + unsigned int last_h = cfg_.g_h; + unsigned int frame_number = 0; + int resize_down_count = 0; + for (std::vector::const_iterator info = frame_info_list_.begin(); + info != frame_info_list_.end(); ++info) { + if (info->w != last_w || info->h != last_h) { + if (frame_number < frame_change_bitrate_) { + // Verify that resize down occurs, before bitrate is increased. + ASSERT_LT(info->w, last_w); + ASSERT_LT(info->h, last_h); + resize_down_count++; + } + last_w = info->w; + last_h = info->h; + } + frame_number++; + } + +#if CONFIG_AV1_DECODER + // Verify that we get at least 1 resize event in this test. + ASSERT_GE(resize_down_count, 1) + << "Resizing down should occur at lease once."; + EXPECT_EQ(static_cast(0), GetMismatchFrames()); +#else + printf("Warning: AV1 decoder unavailable, unable to check resize count!\n"); +#endif +} + class ResizeCspTest : public ResizeTest { protected: #if WRITE_COMPRESSED_STREAM diff --git a/third_party/aom/test/variance_test.cc b/third_party/aom/test/variance_test.cc index a493a1f4cb..e31f8f820c 100644 --- a/third_party/aom/test/variance_test.cc +++ b/third_party/aom/test/variance_test.cc @@ -2165,11 +2165,7 @@ INSTANTIATE_TEST_SUITE_P( MseParams(4, 4, &aom_highbd_10_mse16x16_sve, 10), MseParams(4, 3, &aom_highbd_10_mse16x8_sve, 10), MseParams(3, 4, &aom_highbd_10_mse8x16_sve, 10), - MseParams(3, 3, &aom_highbd_10_mse8x8_sve, 10), - MseParams(4, 4, &aom_highbd_8_mse16x16_sve, 8), - MseParams(4, 3, &aom_highbd_8_mse16x8_sve, 8), - MseParams(3, 4, &aom_highbd_8_mse8x16_sve, 8), - MseParams(3, 3, &aom_highbd_8_mse8x8_sve, 8))); + MseParams(3, 3, &aom_highbd_10_mse8x8_sve, 10))); #endif // HAVE_SVE const VarianceParams kArrayHBDVariance_c[] = { diff --git a/third_party/aom/test/warp_filter_test.cc b/third_party/aom/test/warp_filter_test.cc index f0be7d226b..8844ba77ca 100644 --- a/third_party/aom/test/warp_filter_test.cc +++ b/third_party/aom/test/warp_filter_test.cc @@ -88,6 +88,12 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( SVE, AV1WarpFilterTest, libaom_test::AV1WarpFilter::BuildParams(av1_warp_affine_sve)); + +#if CONFIG_AV1_HIGHBITDEPTH +INSTANTIATE_TEST_SUITE_P( + SVE, AV1HighbdWarpFilterTest, + libaom_test::AV1HighbdWarpFilter::BuildParams(av1_highbd_warp_affine_sve)); +#endif // CONFIG_AV1_HIGHBITDEPTH #endif // HAVE_SVE } // namespace diff --git a/third_party/dav1d/NEWS b/third_party/dav1d/NEWS index 54f8557328..3645474a04 100644 --- a/third_party/dav1d/NEWS +++ b/third_party/dav1d/NEWS @@ -1,3 +1,17 @@ +Changes for 1.4.0 'Road Runner': +-------------------------------- + +1.4.0 is a medium release of dav1d, focusing on new architecture support and optimizations + +- AVX-512 optimizations for z1, z2, z3 in 8bit and high-bitdepth +- New architecture supported: loongarch +- Loongarch optimizations for 8bit +- New architecture supported: RISC-V +- RISC-V optimizations for itx +- Misc improvements in threading and in reducing binary size +- Fix potential integer overflow with extremely large frame sizes (CVE-2024-1580) + + Changes for 1.3.0 'Tundra Peregrine Falcon (Calidus)': ------------------------------------------------------ diff --git a/third_party/dav1d/meson.build b/third_party/dav1d/meson.build index 30ed4acc09..6e49852103 100644 --- a/third_party/dav1d/meson.build +++ b/third_party/dav1d/meson.build @@ -23,7 +23,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. project('dav1d', ['c'], - version: '1.3.0', + version: '1.4.0', default_options: ['c_std=c99', 'warning_level=2', 'buildtype=release', @@ -136,7 +136,7 @@ if host_machine.system() == 'windows' rc_data.set('API_VERSION_MAJOR', dav1d_api_version_major) rc_data.set('API_VERSION_MINOR', dav1d_api_version_minor) rc_data.set('API_VERSION_REVISION', dav1d_api_version_revision) - rc_data.set('COPYRIGHT_YEARS', '2018-2023') + rc_data.set('COPYRIGHT_YEARS', '2018-2024') else thread_dependency = dependency('threads') thread_compat_dep = [] diff --git a/third_party/dav1d/src/arm/64/itx.S b/third_party/dav1d/src/arm/64/itx.S index b1b2f8fe65..53490cd677 100644 --- a/third_party/dav1d/src/arm/64/itx.S +++ b/third_party/dav1d/src/arm/64/itx.S @@ -1426,6 +1426,7 @@ endfunc function inv_txfm_add_16x16_neon mov x15, x30 sub sp, sp, #512 + mov x8, #16*2 .irp i, 0, 8 add x6, sp, #(\i*16*2) .if \i == 8 @@ -1433,7 +1434,6 @@ function inv_txfm_add_16x16_neon b.lt 1f .endif add x7, x2, #(\i*2) - mov x8, #16*2 blr x9 .endr b 2f @@ -1449,7 +1449,6 @@ function inv_txfm_add_16x16_neon .irp i, 0, 8 add x6, x0, #(\i) add x7, sp, #(\i*2) - mov x8, #32 bl inv_txfm_add_vert_8x16_neon .endr @@ -2461,10 +2460,10 @@ function inv_txfm_add_dct_dct_32x16_8bpc_neon, export=1 b.gt 2b 3: + mov x8, #32*2 .irp i, 0, 8, 16, 24 add x6, x0, #(\i) add x7, sp, #(\i*2) - mov x8, #32*2 bl inv_txfm_add_vert_8x16_neon .endr @@ -3205,10 +3204,10 @@ function inv_txfm_add_dct_dct_64x16_8bpc_neon, export=1 3: adr x5, inv_dct_8h_x16_neon + mov x8, #64*2 .irp i, 0, 8, 16, 24, 32, 40, 48, 56 add x6, x0, #(\i) add x7, x4, #(\i*2) - mov x8, #64*2 bl inv_txfm_add_vert_8x16_neon .endr diff --git a/third_party/dav1d/src/decode.c b/third_party/dav1d/src/decode.c index 97d15ca1c6..eed9dfb756 100644 --- a/third_party/dav1d/src/decode.c +++ b/third_party/dav1d/src/decode.c @@ -2616,6 +2616,25 @@ static void read_restoration_info(Dav1dTaskContext *const t, } } +// modeled after the equivalent function in aomdec:decodeframe.c +static int check_trailing_bits_after_symbol_coder(const MsacContext *const msac) { + // check marker bit (single 1), followed by zeroes + const int n_bits = -(msac->cnt + 14); + assert(n_bits <= 0); // this assumes we errored out when cnt <= -15 in caller + const int n_bytes = (n_bits + 7) >> 3; + const uint8_t *p = &msac->buf_pos[n_bytes]; + const int pattern = 128 >> ((n_bits - 1) & 7); + if ((p[-1] & (2 * pattern - 1)) != pattern) + return 1; + + // check remainder zero bytes + for (; p < msac->buf_end; p++) + if (*p) + return 1; + + return 0; +} + int dav1d_decode_tile_sbrow(Dav1dTaskContext *const t) { const Dav1dFrameContext *const f = t->f; const enum BlockLevel root_bl = f->seq_hdr->sb128 ? BL_128X128 : BL_64X64; @@ -2659,9 +2678,6 @@ int dav1d_decode_tile_sbrow(Dav1dTaskContext *const t) { return 0; } - // error out on symbol decoder overread - if (ts->msac.cnt < -15) return 1; - if (f->c->n_tc > 1 && f->frame_hdr->use_ref_frame_mvs) { f->c->refmvs_dsp.load_tmvs(&f->rf, ts->tiling.row, ts->tiling.col_start >> 1, ts->tiling.col_end >> 1, @@ -2767,7 +2783,12 @@ int dav1d_decode_tile_sbrow(Dav1dTaskContext *const t) { memcpy(&f->lf.tx_lpf_right_edge[1][align_h * tile_col + (t->by >> ss_ver)], &t->l.tx_lpf_uv[(t->by & 16) >> ss_ver], sb_step >> ss_ver); - return 0; + // error out on symbol decoder overread + if (ts->msac.cnt <= -15) return 1; + + return c->strict_std_compliance && + (t->by >> f->sb_shift) + 1 >= f->frame_hdr->tiling.row_start_sb[tile_row + 1] && + check_trailing_bits_after_symbol_coder(&ts->msac); } int dav1d_decode_frame_init(Dav1dFrameContext *const f) { @@ -3262,7 +3283,7 @@ error: return retval; } -void dav1d_decode_frame_exit(Dav1dFrameContext *const f, const int retval) { +void dav1d_decode_frame_exit(Dav1dFrameContext *const f, int retval) { const Dav1dContext *const c = f->c; if (f->sr_cur.p.data[0]) @@ -3273,8 +3294,16 @@ void dav1d_decode_frame_exit(Dav1dFrameContext *const f, const int retval) { (size_t)f->frame_thread.cf_sz * 128 * 128 / 2); } for (int i = 0; i < 7; i++) { - if (f->refp[i].p.frame_hdr) + if (f->refp[i].p.frame_hdr) { + if (!retval && c->n_fc > 1 && c->strict_std_compliance && + atomic_load(&f->refp[i].progress[1]) == FRAME_ERROR) + { + retval = DAV1D_ERR(EINVAL); + atomic_store(&f->task_thread.error, 1); + atomic_store(&f->sr_cur.progress[1], FRAME_ERROR); + } dav1d_thread_picture_unref(&f->refp[i]); + } dav1d_ref_dec(&f->ref_mvs_ref[i]); } @@ -3328,6 +3357,7 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) { } } dav1d_decode_frame_exit(f, res); + res = f->task_thread.retval; f->n_tile_data = 0; return res; } diff --git a/third_party/dav1d/src/picture.c b/third_party/dav1d/src/picture.c index f22f05f0ca..94365bce8c 100644 --- a/third_party/dav1d/src/picture.c +++ b/third_party/dav1d/src/picture.c @@ -111,15 +111,15 @@ void dav1d_picture_free_itut_t35(const uint8_t *const data, void *const user_dat dav1d_free(itut_t35_ctx); } -static int picture_alloc_with_edges(Dav1dContext *const c, - Dav1dPicture *const p, - const int w, const int h, - Dav1dSequenceHeader *const seq_hdr, Dav1dRef *const seq_hdr_ref, - Dav1dFrameHeader *const frame_hdr, Dav1dRef *const frame_hdr_ref, - const int bpc, - const Dav1dDataProps *const props, - Dav1dPicAllocator *const p_allocator, - void **const extra_ptr) +static int picture_alloc(Dav1dContext *const c, + Dav1dPicture *const p, + const int w, const int h, + Dav1dSequenceHeader *const seq_hdr, Dav1dRef *const seq_hdr_ref, + Dav1dFrameHeader *const frame_hdr, Dav1dRef *const frame_hdr_ref, + const int bpc, + const Dav1dDataProps *const props, + Dav1dPicAllocator *const p_allocator, + void **const extra_ptr) { if (p->data[0]) { dav1d_log(c, "Picture already allocated!\n"); @@ -194,12 +194,11 @@ int dav1d_thread_picture_alloc(Dav1dContext *const c, Dav1dFrameContext *const f { Dav1dThreadPicture *const p = &f->sr_cur; - const int res = - picture_alloc_with_edges(c, &p->p, f->frame_hdr->width[1], f->frame_hdr->height, - f->seq_hdr, f->seq_hdr_ref, - f->frame_hdr, f->frame_hdr_ref, - bpc, &f->tile[0].data.m, &c->allocator, - (void **) &p->progress); + const int res = picture_alloc(c, &p->p, f->frame_hdr->width[1], f->frame_hdr->height, + f->seq_hdr, f->seq_hdr_ref, + f->frame_hdr, f->frame_hdr_ref, + bpc, &f->tile[0].data.m, &c->allocator, + (void **) &p->progress); if (res) return res; dav1d_picture_copy_props(&p->p, c->content_light, c->content_light_ref, @@ -212,9 +211,10 @@ int dav1d_thread_picture_alloc(Dav1dContext *const c, Dav1dFrameContext *const f c->itut_t35 = NULL; c->n_itut_t35 = 0; - // Don't clear these flags from c->frame_flags if the frame is not visible. + // Don't clear these flags from c->frame_flags if the frame is not going to be output. // This way they will be added to the next visible frame too. - const int flags_mask = (f->frame_hdr->show_frame || c->output_invisible_frames) + const int flags_mask = ((f->frame_hdr->show_frame || c->output_invisible_frames) && + c->max_spatial_id == f->frame_hdr->spatial_id) ? 0 : (PICTURE_FLAG_NEW_SEQUENCE | PICTURE_FLAG_NEW_OP_PARAMS_INFO); p->flags = c->frame_flags; c->frame_flags &= flags_mask; @@ -233,11 +233,11 @@ int dav1d_picture_alloc_copy(Dav1dContext *const c, Dav1dPicture *const dst, con { Dav1dMemPoolBuffer *const buf = (Dav1dMemPoolBuffer *)src->ref->const_data; struct pic_ctx_context *const pic_ctx = buf->data; - const int res = picture_alloc_with_edges(c, dst, w, src->p.h, - src->seq_hdr, src->seq_hdr_ref, - src->frame_hdr, src->frame_hdr_ref, - src->p.bpc, &src->m, &pic_ctx->allocator, - NULL); + const int res = picture_alloc(c, dst, w, src->p.h, + src->seq_hdr, src->seq_hdr_ref, + src->frame_hdr, src->frame_hdr_ref, + src->p.bpc, &src->m, &pic_ctx->allocator, + NULL); if (res) return res; dav1d_picture_copy_props(dst, src->content_light, src->content_light_ref, diff --git a/third_party/dav1d/src/riscv/64/itx.S b/third_party/dav1d/src/riscv/64/itx.S index f7d907eedf..60d045150d 100644 --- a/third_party/dav1d/src/riscv/64/itx.S +++ b/third_party/dav1d/src/riscv/64/itx.S @@ -117,39 +117,50 @@ function inv_identity_e16_x4_rvv, export=1, ext=v jr t0 endfunc +.macro iwht_4 + vadd.vv v0, v0, v1 + vsub.vv v5, v2, v3 + vsub.vv v4, v0, v5 + vsra.vi v4, v4, 1 + vsub.vv v2, v4, v1 + vsub.vv v1, v4, v3 + vadd.vv v3, v5, v2 + vsub.vv v0, v0, v1 +.endm + .macro idct_4 o0, o1, o2, o3 li t1, 2896 li t2, 1567 li t3, 3784 - vwmul.vx v8, \o0, t1 - vwmul.vx v10, \o0, t1 - vwmacc.vx v8, t1, \o2 + vwmul.vx v16, \o0, t1 + vwmul.vx v18, \o0, t1 + vwmacc.vx v16, t1, \o2 neg t1, t1 - vwmacc.vx v10, t1, \o2 + vwmacc.vx v18, t1, \o2 - vwmul.vx v12, \o1, t3 + vwmul.vx v20, \o1, t3 neg t3, t3 - vwmul.vx v14, \o1, t2 - vwmacc.vx v12, t2, \o3 - vwmacc.vx v14, t3, \o3 + vwmul.vx v22, \o1, t2 + vwmacc.vx v20, t2, \o3 + vwmacc.vx v22, t3, \o3 li t1, 2048 - vwadd.wx v8, v8, t1 - vwadd.wx v10, v10, t1 - vwadd.wx v12, v12, t1 - vwadd.wx v14, v14, t1 + vwadd.wx v16, v16, t1 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 - vnsra.wi v8, v8, 12 - vnsra.wi v10, v10, 12 - vnsra.wi v12, v12, 12 - vnsra.wi v14, v14, 12 + vnsra.wi v16, v16, 12 + vnsra.wi v18, v18, 12 + vnsra.wi v20, v20, 12 + vnsra.wi v22, v22, 12 - vsadd.vv \o0, v8, v12 - vsadd.vv \o1, v10, v14 - vssub.vv \o2, v10, v14 - vssub.vv \o3, v8, v12 + vsadd.vv \o0, v16, v20 + vsadd.vv \o1, v18, v22 + vssub.vv \o2, v18, v22 + vssub.vv \o3, v16, v20 .endm .macro iadst_4 o0, o1, o2, o3 @@ -211,6 +222,45 @@ function inv_flipadst_e16_x4_rvv, export=1, ext=v jr t0 endfunc +function inv_txfm_add_wht_wht_4x4_8bpc_rvv, export=1, ext=v + csrw vxrm, zero + + vsetivli zero, 4, e16, mf2, ta, ma + vle16.v v0, (a2) + addi t0, a2, 8 + vle16.v v1, (t0) + addi t0, t0, 8 + vle16.v v2, (t0) + addi t0, t0, 8 + vle16.v v3, (t0) + + vsra.vi v0, v0, 2 + vsra.vi v1, v1, 2 + vsra.vi v2, v2, 2 + vsra.vi v3, v3, 2 + + iwht_4 + + vmv.v.x v4, zero + + vsseg4e16.v v0, (a2) + vle16.v v0, (a2) + vse16.v v4, (a2) + addi t0, a2, 8 + vle16.v v1, (t0) + vse16.v v4, (t0) + addi t0, t0, 8 + vle16.v v2, (t0) + vse16.v v4, (t0) + addi t0, t0, 8 + vle16.v v3, (t0) + vse16.v v4, (t0) + + iwht_4 + + j itx_4x4_end +endfunc + .macro def_fn_4x4 txfm1, txfm2 function inv_txfm_add_\txfm1\()_\txfm2\()_4x4_8bpc_rvv, export=1, ext=v .ifc \txfm1\()_\txfm2, dct_dct @@ -353,7 +403,7 @@ itx_8x8_end: vwaddu.wv v6, v6, v14 vwaddu.wv v7, v7, v15 - vsetvli zero, zero, e16, m1 + vsetvli zero, zero, e16, m1, ta, ma vmax.vx v0, v0, zero vmax.vx v1, v1, zero vmax.vx v2, v2, zero @@ -410,69 +460,67 @@ function inv_identity_e16_x8_rvv, export=1, ext=v jr t0 endfunc -function inv_dct_e16_x8_rvv, export=1, ext=v - idct_4 v0, v2, v4, v6 +.macro idct_8 o0, o1, o2, o3, o4, o5, o6, o7 + idct_4 \o0, \o2, \o4, \o6 li t1, 799 li t2, 4017 li t3, 3406 li t4, 2276 - vwmul.vx v14, v1, t2 + vwmul.vx v22, \o1, t2 neg t2, t2 - vwmul.vx v8, v1, t1 - vwmacc.vx v14, t1, v7 - vwmacc.vx v8, t2, v7 + vwmul.vx v16, \o1, t1 + vwmacc.vx v22, t1, \o7 + vwmacc.vx v16, t2, \o7 - vwmul.vx v12, v5, t4 + vwmul.vx v20, \o5, t4 neg t4, t4 - vwmul.vx v10, v5, t3 - vwmacc.vx v12, t3, v3 - vwmacc.vx v10, t4, v3 + vwmul.vx v18, \o5, t3 + vwmacc.vx v20, t3, \o3 + vwmacc.vx v18, t4, \o3 li t1, 2048 - vwadd.wx v8, v8, t1 - vwadd.wx v10, v10, t1 - vwadd.wx v12, v12, t1 - vwadd.wx v14, v14, t1 + vwadd.wx v16, v16, t1 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 - vnsra.wi v8, v8, 12 - vnsra.wi v10, v10, 12 - vnsra.wi v12, v12, 12 - vnsra.wi v14, v14, 12 + vnsra.wi v16, v16, 12 + vnsra.wi v18, v18, 12 + vnsra.wi v20, v20, 12 + vnsra.wi v22, v22, 12 - vssub.vv v7, v14, v12 - vsadd.vv v14, v14, v12 - vssub.vv v1, v8, v10 - vsadd.vv v8, v8, v10 + vssub.vv \o7, v22, v20 + vsadd.vv v22, v22, v20 + vssub.vv \o1, v16, v18 + vsadd.vv v16, v16, v18 li t2, 2896 - vwmul.vx v10, v7, t2 - vwmul.vx v12, v7, t2 - vwmacc.vx v12, t2, v1 + vwmul.vx v18, \o7, t2 + vwmul.vx v20, \o7, t2 + vwmacc.vx v20, t2, \o1 neg t2, t2 - vwmacc.vx v10, t2, v1 + vwmacc.vx v18, t2, \o1 - vwadd.wx v10, v10, t1 - vwadd.wx v12, v12, t1 - - vnsra.wi v10, v10, 12 - vnsra.wi v12, v12, 12 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 - vssub.vv v7, v0, v14 - vsadd.vv v0, v0, v14 - vssub.vv v9, v2, v12 - vsadd.vv v1, v2, v12 - vssub.vv v5, v4, v10 - vsadd.vv v2, v4, v10 - vssub.vv v4, v6, v8 - vsadd.vv v3, v6, v8 - vmv.v.v v6, v9 + vnsra.wi v18, v18, 12 + vnsra.wi v20, v20, 12 - jr t0 -endfunc + vssub.vv \o7, \o0, v22 + vsadd.vv \o0, \o0, v22 + vssub.vv v17, \o2, v20 + vsadd.vv \o1, \o2, v20 + vssub.vv \o5, \o4, v18 + vsadd.vv \o2, \o4, v18 + vssub.vv \o4, \o6, v16 + vsadd.vv \o3, \o6, v16 + vmv.v.v \o6, v17 +.endm .macro iadst_8 o0, o1, o2, o3, o4, o5, o6, o7 li t1, 4076 @@ -598,6 +646,11 @@ endfunc vssub.vv \o7, v8, \o7 .endm +function inv_dct_e16_x8_rvv, export=1, ext=v + idct_8 v0, v1, v2, v3, v4, v5, v6, v7 + jr t0 +endfunc + function inv_adst_e16_x8_rvv, export=1, ext=v iadst_8 v0, v1, v2, v3, v4, v5, v6, v7 jr t0 @@ -660,3 +713,627 @@ def_fn_8x8 adst, identity def_fn_8x8 flipadst, identity def_fn_8x8 identity, adst def_fn_8x8 identity, flipadst + +function inv_identity_e16_x16_rvv, export=1, ext=v + li t1, 2*(5793-4096)*8 +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vsmul.vx v16, v\i, t1 + vsadd.vv v\i, v\i, v\i + vsadd.vv v\i, v\i, v16 +.endr + jr t0 +endfunc + +function inv_dct_e16_x16_rvv, export=1, ext=v + idct_8 v0, v2, v4, v6, v8, v10, v12, v14 + + li t1, 401 + li t2, 4076 + li t3, 3166 + li t4, 2598 + + vwmul.vx v30, v1, t2 + neg t2, t2 + vwmul.vx v16, v1, t1 + vwmacc.vx v30, t1, v15 + vwmacc.vx v16, t2, v15 + + vwmul.vx v28, v9, t4 + neg t4, t4 + vwmul.vx v18, v9, t3 + vwmacc.vx v28, t3, v7 + vwmacc.vx v18, t4, v7 + + li t1, 1931 + li t2, 3612 + li t3, 3920 + li t4, 1189 + + vwmul.vx v26, v5, t2 + neg t2, t2 + vwmul.vx v20, v5, t1 + vwmacc.vx v26, t1, v11 + vwmacc.vx v20, t2, v11 + + vwmul.vx v24, v13, t4 + neg t4, t4 + vwmul.vx v22, v13, t3 + vwmacc.vx v24, t3, v3 + vwmacc.vx v22, t4, v3 + + li t1, 2048 + li t2, 2896 + li t3, 1567 + li t4, 3784 + + vwadd.wx v16, v16, t1 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v26, v26, t1 + vwadd.wx v28, v28, t1 + vwadd.wx v30, v30, t1 + + vnsra.wi v16, v16, 12 + vnsra.wi v18, v18, 12 + vnsra.wi v20, v20, 12 + vnsra.wi v22, v22, 12 + vnsra.wi v24, v24, 12 + vnsra.wi v26, v26, 12 + vnsra.wi v28, v28, 12 + vnsra.wi v30, v30, 12 + + vssub.vv v3, v16, v18 + vsadd.vv v16, v16, v18 + vssub.vv v5, v22, v20 + vsadd.vv v22, v22, v20 + vssub.vv v11, v24, v26 + vsadd.vv v24, v24, v26 + vssub.vv v13, v30, v28 + vsadd.vv v30, v30, v28 + + vwmul.vx v28, v13, t4 + neg t4, t4 + vwmul.vx v18, v13, t3 + vwmul.vx v26, v11, t3 + vwmacc.vx v28, t3, v3 + neg t3, t3 + vwmul.vx v20, v11, t4 + vwmacc.vx v18, t4, v3 + vwmacc.vx v20, t3, v5 + vwmacc.vx v26, t4, v5 + + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v26, v26, t1 + vwadd.wx v28, v28, t1 + + vnsra.wi v18, v18, 12 + vnsra.wi v20, v20, 12 + vnsra.wi v26, v26, 12 + vnsra.wi v28, v28, 12 + + vssub.vv v5, v18, v20 + vsadd.vv v18, v18, v20 + vssub.vv v11, v28, v26 + vsadd.vv v28, v28, v26 + + vssub.vv v7, v16, v22 + vsadd.vv v16, v16, v22 + vssub.vv v9, v30, v24 + vsadd.vv v30, v30, v24 + + vwmul.vx v20, v11, t2 + vwmul.vx v22, v9, t2 + vwmul.vx v24, v9, t2 + vwmul.vx v26, v11, t2 + vwmacc.vx v24, t2, v7 + vwmacc.vx v26, t2, v5 + neg t2, t2 + vwmacc.vx v20, t2, v5 + vwmacc.vx v22, t2, v7 + + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v26, v26, t1 + + vnsra.wi v20, v20, 12 + vnsra.wi v22, v22, 12 + vnsra.wi v24, v24, 12 + vnsra.wi v26, v26, 12 + + vssub.vv v15, v0, v30 + vsadd.vv v0, v0, v30 + vssub.vv v17, v2, v28 + vsadd.vv v1, v2, v28 + vssub.vv v13, v4, v26 + vsadd.vv v2, v4, v26 + vssub.vv v19, v6, v24 + vsadd.vv v3, v6, v24 + vssub.vv v11, v8, v22 + vsadd.vv v4, v8, v22 + vsadd.vv v5, v10, v20 + vssub.vv v10, v10, v20 + vssub.vv v9, v12, v18 + vsadd.vv v6, v12, v18 + vssub.vv v8, v14, v16 + vsadd.vv v7, v14, v16 + vmv.v.v v14, v17 + vmv.v.v v12, v19 + + jr t0 +endfunc + +.macro iadst_16 o0, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15 + li t1, 4091 + li t2, 201 + li t3, 3973 + li t4, 995 + + vwmul.vx v16, v15, t1 + neg t1, t1 + vwmul.vx v18, v15, t2 + vwmacc.vx v16, t2, v0 + vwmacc.vx v18, t1, v0 + + vwmul.vx v20, v13, t3 + neg t3, t3 + vwmul.vx v22, v13, t4 + vwmacc.vx v20, t4, v2 + vwmacc.vx v22, t3, v2 + + li t1, 3703 + li t2, 1751 + li t3, 3290 + li t4, 2440 + + vwmul.vx v24, v11, t1 + neg t1, t1 + vwmul.vx v26, v11, t2 + vwmacc.vx v24, t2, v4 + vwmacc.vx v26, t1, v4 + + vwmul.vx v28, v9, t3 + neg t3, t3 + vwmul.vx v30, v9, t4 + vwmacc.vx v28, t4, v6 + vwmacc.vx v30, t3, v6 + + li t1, 2048 + + vwadd.wx v16, v16, t1 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v26, v26, t1 + vwadd.wx v28, v28, t1 + vwadd.wx v30, v30, t1 + + vnsra.wi v0, v16, 12 + vnsra.wi v18, v18, 12 + vnsra.wi v2, v20, 12 + vnsra.wi v22, v22, 12 + vnsra.wi v4, v24, 12 + vnsra.wi v26, v26, 12 + vnsra.wi v6, v28, 12 + vnsra.wi v30, v30, 12 + + li t1, 2751 + li t2, 3035 + li t3, 2106 + li t4, 3513 + + vwmul.vx v16, v7, t1 + neg t1, t1 + vwmul.vx v20, v7, t2 + vwmacc.vx v16, t2, v8 + vwmacc.vx v20, t1, v8 + + vwmul.vx v24, v5, t3 + neg t3, t3 + vwmul.vx v28, v5, t4 + vwmacc.vx v24, t4, v10 + vwmacc.vx v28, t3, v10 + + li t1, 2048 + + vwadd.wx v16, v16, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v28, v28, t1 + + vnsra.wi v16, v16, 12 + vnsra.wi v9, v20, 12 + vnsra.wi v24, v24, 12 + vnsra.wi v11, v28, 12 + + vssub.vv v8, v0, v16 + vsadd.vv v0, v0, v16 + vssub.vv v10, v2, v24 + vsadd.vv v2, v2, v24 + + li t1, 1380 + li t2, 3857 + li t3, 601 + li t4, 4052 + + vwmul.vx v16, v3, t1 + neg t1, t1 + vwmul.vx v20, v3, t2 + vwmacc.vx v16, t2, v12 + vwmacc.vx v20, t1, v12 + + vwmul.vx v24, v1, t3 + neg t3, t3 + vwmul.vx v28, v1, t4 + vwmacc.vx v24, t4, v14 + vwmacc.vx v28, t3, v14 + + li t1, 2048 + + vwadd.wx v16, v16, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v28, v28, t1 + + vnsra.wi v16, v16, 12 + vnsra.wi v13, v20, 12 + vnsra.wi v24, v24, 12 + vnsra.wi v15, v28, 12 + + vssub.vv v12, v4, v16 + vsadd.vv v16, v4, v16 + vssub.vv v14, v6, v24 + vsadd.vv v20, v6, v24 + + vsadd.vv v1, v18, v9 + vssub.vv v9, v18, v9 + vsadd.vv v3, v22, v11 + vssub.vv v11, v22, v11 + vsadd.vv v18, v26, v13 + vssub.vv v13, v26, v13 + vsadd.vv v22, v30, v15 + vssub.vv v15, v30, v15 + + vssub.vv v4, v0, v16 + vsadd.vv v0, v0, v16 + vssub.vv v5, v1, v18 + vsadd.vv v1, v1, v18 + vssub.vv v6, v2, v20 + vsadd.vv v2, v2, v20 + vssub.vv v7, v3, v22 + vsadd.vv v3, v3, v22 + + li t1, 799 + li t2, 4017 + li t3, 3406 + li t4, 2276 + + vwmul.vx v16, v8, t2 + vwmul.vx v18, v8, t1 + vwmul.vx v20, v10, t4 + vwmul.vx v22, v10, t3 + vwmul.vx v24, v13, t2 + vwmul.vx v26, v13, t1 + vwmul.vx v28, v15, t4 + vwmul.vx v30, v15, t3 + vwmacc.vx v16, t1, v9 + neg t1, t1 + vwmacc.vx v20, t3, v11 + neg t3, t3 + vwmacc.vx v26, t2, v12 + neg t2, t2 + vwmacc.vx v30, t4, v14 + neg t4, t4 + vwmacc.vx v18, t2, v9 + vwmacc.vx v22, t4, v11 + vwmacc.vx v24, t1, v12 + vwmacc.vx v28, t3, v14 + + li t1, 2048 + li t2, 2896 + li t3, 1567 + li t4, 3784 + + vwadd.wx v16, v16, t1 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v26, v26, t1 + vwadd.wx v28, v28, t1 + vwadd.wx v30, v30, t1 + + vnsra.wi v16, v16, 12 + vnsra.wi v18, v18, 12 + vnsra.wi v20, v20, 12 + vnsra.wi v22, v22, 12 + vnsra.wi v24, v24, 12 + vnsra.wi v26, v26, 12 + vnsra.wi v28, v28, 12 + vnsra.wi v30, v30, 12 + + vsadd.vv v8, v16, v24 + vsadd.vv v9, v18, v26 + vsadd.vv v10, v20, v28 + vsadd.vv v11, v22, v30 + vssub.vv v12, v16, v24 + vssub.vv v13, v18, v26 + vssub.vv v14, v20, v28 + vssub.vv v15, v22, v30 + + vwmul.vx v16, v4, t4 + vwmul.vx v18, v4, t3 + vwmul.vx v20, v7, t4 + vwmul.vx v22, v7, t3 + vwmul.vx v24, v12, t4 + vwmul.vx v26, v12, t3 + vwmul.vx v28, v15, t4 + vwmul.vx v30, v15, t3 + vwmacc.vx v16, t3, v5 + vwmacc.vx v22, t4, v6 + vwmacc.vx v24, t3, v13 + neg t3, t3 + vwmacc.vx v30, t4, v14 + neg t4, t4 + vwmacc.vx v20, t3, v6 + vwmacc.vx v28, t3, v14 + vwmacc.vx v18, t4, v5 + vwmacc.vx v26, t4, v13 + + vwadd.wx v16, v16, t1 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v26, v26, t1 + vwadd.wx v28, v28, t1 + vwadd.wx v30, v30, t1 + + vnsra.wi v16, v16, 12 + vnsra.wi v18, v18, 12 + vnsra.wi v20, v20, 12 + vnsra.wi v22, v22, 12 + vnsra.wi v24, v24, 12 + vnsra.wi v26, v26, 12 + vnsra.wi v28, v28, 12 + vnsra.wi v30, v30, 12 + +.ifc \o0, v0 + vsadd.vv \o14, v9, v11 + vssub.vv v11, v9, v11 + vssub.vv v9, v1, v3 + vsadd.vv \o15, v1, v3 + vsadd.vv \o1, v8, v10 + vssub.vv v10, v8, v10 + vssub.vv v8, v0, v2 + vsadd.vv \o0, v0, v2 +.else + vsadd.vv \o1, v8, v10 + vssub.vv v10, v8, v10 + vssub.vv v8, v0, v2 + vsadd.vv \o0, v0, v2 + vsadd.vv v2, v9, v11 + vssub.vv v11, v9, v11 + vssub.vv v9, v1, v3 + vsadd.vv \o15, v1, v3 + vmv.v.v \o14, v2 +.endif + + vsadd.vv \o3, v16, v20 + vssub.vv v6, v16, v20 + vsadd.vv \o12, v18, v22 + vssub.vv v7, v18, v22 + vsadd.vv \o2, v24, v28 + vssub.vv v24, v24, v28 + vsadd.vv \o13, v26, v30 + vssub.vv v26, v26, v30 + + neg t3, t2 + + vwmul.vx v28, v24, t2 + vwmul.vx v30, v24, t2 + vwmacc.vx v28, t2, v26 + vwmacc.vx v30, t3, v26 + + vwmul.vx v24, v10, t2 + vwmul.vx v26, v10, t2 + vwmacc.vx v24, t2, v11 + vwmacc.vx v26, t3, v11 + + vwmul.vx v20, v6, t2 + vwmul.vx v22, v6, t2 + vwmacc.vx v20, t2, v7 + vwmacc.vx v22, t3, v7 + + vwmul.vx v16, v8, t2 + vwmul.vx v18, v8, t2 + vwmacc.vx v16, t2, v9 + vwmacc.vx v18, t3, v9 + + vwadd.wx v16, v16, t1 + vwadd.wx v18, v18, t1 + vwadd.wx v20, v20, t1 + vwadd.wx v22, v22, t1 + vwadd.wx v24, v24, t1 + vwadd.wx v26, v26, t1 + vwadd.wx v28, v28, t1 + vwadd.wx v30, v30, t1 + + vnsra.wi \o7, v16, 12 + vnsra.wi \o8, v18, 12 + vnsra.wi \o4, v20, 12 + vnsra.wi \o11, v22, 12 + vnsra.wi \o6, v24, 12 + vnsra.wi \o9, v26, 12 + vnsra.wi \o5, v28, 12 + vnsra.wi \o10, v30, 12 + + vmv.v.x v16, zero + vssub.vv \o1, v16, \o1 + vssub.vv \o3, v16, \o3 + vssub.vv \o5, v16, \o5 + vssub.vv \o7, v16, \o7 + vssub.vv \o9, v16, \o9 + vssub.vv \o11, v16, \o11 + vssub.vv \o13, v16, \o13 + vssub.vv \o15, v16, \o15 +.endm + +function inv_adst_e16_x16_rvv, export=1, ext=v + iadst_16 v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 + jr t0 +endfunc + +function inv_flipadst_e16_x16_rvv, export=1, ext=v + iadst_16 v15, v14, v13, v12, v11, v10, v9, v8, v7, v6, v5, v4, v3, v2, v1, v0 + jr t0 +endfunc + +.macro def_horz_16 variant +function inv_txfm_horz\variant\()_16x8_rvv, export=1, ext=v + vmv.v.x v16, zero +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vle16.v v\i, (t4) + vse16.v v16, (t4) + add t4, t4, t6 +.endr +.ifc \variant, _identity + li t1, 2*(5793-4096)*8 +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vsmul.vx v16, v\i, t1 + vsra.vi v16, v16, 1 + vaadd.vv v\i, v\i, v16 +.endr +.else + jalr t0, a4 +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vssra.vi v\i, v\i, 2 +.endr +.endif +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vsse16.v v\i, (t5), t6 + addi t5, t5, 2 +.endr + jr a7 +endfunc +.endm + +def_horz_16 +def_horz_16 _identity + +function inv_txfm_add_vert_8x16_rvv, export=1, ext=v + vsetivli zero, 8, e16, m1, ta, ma +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vle16.v v\i, (t4) + add t4, t4, t6 +.endr + jalr t0, a5 + +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vssra.vi v\i, v\i, 4 +.endr + + vsetivli zero, 8, e8, mf2, ta, ma + mv t0, t5 +.irp i, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 + vle8.v v\i, (t0) + add t0, t0, a1 +.endr + + vwaddu.wv v0, v0, v16 + vwaddu.wv v1, v1, v17 + vwaddu.wv v2, v2, v18 + vwaddu.wv v3, v3, v19 + vwaddu.wv v4, v4, v20 + vwaddu.wv v5, v5, v21 + vwaddu.wv v6, v6, v22 + vwaddu.wv v7, v7, v23 + vwaddu.wv v8, v8, v24 + vwaddu.wv v9, v9, v25 + vwaddu.wv v10, v10, v26 + vwaddu.wv v11, v11, v27 + vwaddu.wv v12, v12, v28 + vwaddu.wv v13, v13, v29 + vwaddu.wv v14, v14, v30 + vwaddu.wv v15, v15, v31 + + vsetvli zero, zero, e16, m1, ta, ma +.irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + vmax.vx v\i, v\i, zero +.endr + + vsetvli zero, zero, e8, mf2, ta, ma + vnclipu.wi v16, v0, 0 + vnclipu.wi v17, v1, 0 + vnclipu.wi v18, v2, 0 + vnclipu.wi v19, v3, 0 + vnclipu.wi v20, v4, 0 + vnclipu.wi v21, v5, 0 + vnclipu.wi v22, v6, 0 + vnclipu.wi v23, v7, 0 + vnclipu.wi v24, v8, 0 + vnclipu.wi v25, v9, 0 + vnclipu.wi v26, v10, 0 + vnclipu.wi v27, v11, 0 + vnclipu.wi v28, v12, 0 + vnclipu.wi v29, v13, 0 + vnclipu.wi v30, v14, 0 + vnclipu.wi v31, v15, 0 + +.irp i, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 + vse8.v v\i, (t5) + add t5, t5, a1 +.endr + + jr a7 +endfunc + +function inv_txfm_add_16x16_rvv, export=1, ext=v + csrw vxrm, zero + vsetivli zero, 8, e16, m1, ta, ma + addi sp, sp, -16*32 +.irp i, 0, 8 + addi t4, a2, \i*2 + addi t5, sp, \i*16*2 + li t6, 16*2 + jalr a7, a6 +.endr +.irp i, 0, 8 + addi t4, sp, \i*2 + addi t5, a0, \i + li t6, 16*2 + jal a7, inv_txfm_add_vert_8x16_rvv +.endr + addi sp, sp, 16*32 + ret +endfunc + +.macro def_fn_16x16 txfm1, txfm2 +function inv_txfm_add_\txfm1\()_\txfm2\()_16x16_8bpc_rvv, export=1, ext=v +.ifc \txfm1, identity + la a6, inv_txfm_horz_identity_16x8_rvv +.else + la a6, inv_txfm_horz_16x8_rvv + la a4, inv_\txfm1\()_e16_x16_rvv +.endif + la a5, inv_\txfm2\()_e16_x16_rvv + j inv_txfm_add_16x16_rvv +endfunc +.endm + +def_fn_16x16 dct, dct +def_fn_16x16 identity, identity +def_fn_16x16 dct, adst +def_fn_16x16 dct, flipadst +def_fn_16x16 dct, identity +def_fn_16x16 adst, dct +def_fn_16x16 adst, adst +def_fn_16x16 adst, flipadst +def_fn_16x16 flipadst, dct +def_fn_16x16 flipadst, adst +def_fn_16x16 flipadst, flipadst +def_fn_16x16 identity, dct diff --git a/third_party/dav1d/src/riscv/itx.h b/third_party/dav1d/src/riscv/itx.h index bed215471b..28c5e54d42 100644 --- a/third_party/dav1d/src/riscv/itx.h +++ b/third_party/dav1d/src/riscv/itx.h @@ -58,7 +58,8 @@ decl_itx_fn(BF(dav1d_inv_txfm_add_wht_wht_##w##x##h, opt)) #define decl_itx_fns(ext) \ decl_itx17_fns( 4, 4, ext); \ -decl_itx16_fns( 8, 8, ext) +decl_itx16_fns( 8, 8, ext); \ +decl_itx16_fns(16, 16, ext) decl_itx_fns(rvv); @@ -103,7 +104,8 @@ static ALWAYS_INLINE void itx_dsp_init_riscv(Dav1dInvTxfmDSPContext *const c, in if (!(flags & DAV1D_RISCV_CPU_FLAG_V)) return; #if BITDEPTH == 8 - assign_itx16_fn( , 4, 4, rvv); + assign_itx17_fn( , 4, 4, rvv); assign_itx16_fn( , 8, 8, rvv); + assign_itx12_fn( , 16, 16, rvv); #endif } diff --git a/third_party/dav1d/src/x86/ipred.h b/third_party/dav1d/src/x86/ipred.h index f5f187e53d..57aff0f38c 100644 --- a/third_party/dav1d/src/x86/ipred.h +++ b/third_party/dav1d/src/x86/ipred.h @@ -144,6 +144,7 @@ static ALWAYS_INLINE void intra_pred_dsp_init_x86(Dav1dIntraPredDSPContext *cons init_angular_ipred_fn(SMOOTH_H_PRED, ipred_smooth_h, avx512icl); init_angular_ipred_fn(SMOOTH_V_PRED, ipred_smooth_v, avx512icl); init_angular_ipred_fn(Z1_PRED, ipred_z1, avx512icl); + init_angular_ipred_fn(Z2_PRED, ipred_z2, avx512icl); init_angular_ipred_fn(Z3_PRED, ipred_z3, avx512icl); init_angular_ipred_fn(FILTER_PRED, ipred_filter, avx512icl); diff --git a/third_party/dav1d/src/x86/ipred16_avx512.asm b/third_party/dav1d/src/x86/ipred16_avx512.asm index 8124a3b145..69802614c7 100644 --- a/third_party/dav1d/src/x86/ipred16_avx512.asm +++ b/third_party/dav1d/src/x86/ipred16_avx512.asm @@ -79,14 +79,17 @@ z_filter_wh: db 7, 7, 11, 11, 15, 15, 19, 19, 19, 23, 23, 23, 31, 31, 31, 39 z_filter_k: dw 8, 8, 6, 6, 4, 4 dw 4, 4, 5, 5, 4, 4 dw 0, 0, 0, 0, 2, 2 +pb_90: times 4 db 90 pw_15: times 2 dw 15 pw_16: times 2 dw 16 pw_17: times 2 dw 17 pw_24: times 2 dw 24 +pw_31: times 2 dw 31 pw_32: times 2 dw 32 pw_63: times 2 dw 63 pw_64: times 2 dw 64 pw_512: times 2 dw 512 +pw_2048: times 2 dw 2048 pw_31806: times 2 dw 31806 pw_32640: times 2 dw 32640 pw_32672: times 2 dw 32672 @@ -114,6 +117,7 @@ JMP_TABLE ipred_smooth_16bpc, avx512icl, w4, w8, w16, w32, w64 JMP_TABLE ipred_smooth_h_16bpc, avx512icl, w4, w8, w16, w32, w64 JMP_TABLE ipred_smooth_v_16bpc, avx512icl, w4, w8, w16, w32, w64 JMP_TABLE ipred_z1_16bpc, avx512icl, w4, w8, w16, w32, w64 +JMP_TABLE ipred_z2_16bpc, avx512icl, w4, w8, w16, w32, w64 JMP_TABLE ipred_z3_16bpc, avx512icl, w4, w8, w16, w32, w64 JMP_TABLE pal_pred_16bpc, avx512icl, w4, w8, w16, w32, w64 @@ -1174,6 +1178,612 @@ cglobal ipred_z1_16bpc, 3, 8, 16, dst, stride, tl, w, h, angle, dx mov rsp, r7 RET +cglobal ipred_z2_16bpc, 3, 9, 16, dst, stride, tl, w, h, angle, dx, _, dy + tzcnt wd, wm + movifnidn angled, anglem + lea dxq, [dr_intra_derivative-90] + movzx dyd, angleb + xor angled, 0x400 + mov r7, dxq + sub dxq, dyq + movifnidn hd, hm + and dyd, ~1 + vpbroadcastw m12, [tlq] + and dxq, ~1 + movzx dyd, word [r7+dyq] ; angle - 90 + lea r7, [z_filter_t0] + movzx dxd, word [dxq+270] ; 180 - angle + mova m0, [base+pw_31to0] + movsxd wq, [base+ipred_z2_16bpc_avx512icl_table+wq*4] + movu m4, [tlq+2] + neg dyd + vpermw m7, m0, [tlq-64*1] + lea wq, [base+ipred_z2_16bpc_avx512icl_table+wq] + vpbroadcastd m14, [base+pw_31806] + vpbroadcastd m15, [base+pw_1] + jmp wq +.w4: + movq xm3, [tlq] + vpbroadcastq m8, [base+pw_1to32] + test angled, 0x400 + jnz .w4_main ; !enable_intra_edge_filter + lea r3d, [hq+2] + add angled, 1022 + shl r3d, 6 + test r3d, angled + jnz .w4_no_upsample_above ; angle >= 130 || h > 8 || (is_sm && h == 8) + pshuflw xm0, xm4, q3321 + sub angled, 1075 ; angle - 53 + lea r3d, [hq+3] + call .upsample_above + punpcklwd xm4, xm3, xm4 + palignr xm3, xm4, xm12, 14 + jmp .w4_main +.w4_upsample_left: + call .upsample_left + movsldup m1, [base+z_xpos_mul] + paddw m1, m1 + jmp .w4_main2 +.w4_no_upsample_above: + lea r3d, [hq+3] + vpbroadcastd ym0, [base+pw_3] + sub angled, 1112 ; angle - 90 + call .filter_above2 + lea r3d, [hq+2] + add angled, 973 ; angle + 883 + palignr xm3, xm4, xm12, 14 + shl r3d, 6 + test r3d, angled + jz .w4_upsample_left ; angle <= 140 || h > 8 || (is_sm && h == 8) + call .filter_left16 +.w4_main: + movsldup m1, [base+z_xpos_mul] + psllw m15, 3 +.w4_main2: + vpbroadcastq m0, [base+pw_1to32] + vpbroadcastw m11, dxd + movsldup m2, [base+z_xpos_mul] + vpbroadcastw m13, dyd + vpbroadcastd m5, [tlq-2] + psllw m10, m8, 6 + valignq m5, m7, m5, 6 + pmullw m2, m11 + psubw m10, m2 ; xpos + pmullw m13, m0 ; ypos + palignr m5, m7, m5, 14 + psrlw m12, m13, 6 + psllw m13, 9 + paddw m12, m1 ; base_y + pand m13, m14 ; frac_y << 9 + psllw m11, 3 + lea r5, [strideq*3] +.w4_loop: + psrlw m1, m10, 6 ; base_x + pand m2, m14, m10 ; frac + vpermw m0, m1, m3 ; top[base_x] + vpermw m1, m1, m4 ; top[base_x+1] + vpmovw2m k1, m10 ; base_x < 0 + psllw m2, 9 + vpermw m0{k1}, m12, m5 ; left[base_y] + vpermw m1{k1}, m12, m7 ; left[base_y+1] + vmovdqu16 m2{k1}, m13 + psubw m1, m0 + pmulhrsw m1, m2 + paddw m0, m1 + vextracti32x4 xm1, ym0, 1 + movq [dstq+strideq*0], xm0 + movhps [dstq+strideq*1], xm0 + movq [dstq+strideq*2], xm1 + movhps [dstq+r5 ], xm1 + sub hd, 8 + jl .w4_end + vextracti32x8 ym0, m0, 1 + psubw m10, m11 ; base_x -= dx + lea dstq, [dstq+strideq*4] + paddw m12, m15 ; base_y++ + vextracti32x4 xm1, ym0, 1 + movq [dstq+strideq*0], xm0 + movhps [dstq+strideq*1], xm0 + movq [dstq+strideq*2], xm1 + movhps [dstq+r5 ], xm1 + lea dstq, [dstq+strideq*4] + jg .w4_loop +.w4_end: + RET +.upsample_above: ; w4/w8 + mova ym9, [base+pw_1to32] + palignr xm1, xm4, xm12, 12 + paddw xm3, xm4 ; b+c + xor angled, 0x7f ; 180 - angle + paddw xm0, xm1 ; a+d + vpbroadcastw xm1, r9m ; pixel_max + vpbroadcastb xm11, r3d + psubw xm0, xm3, xm0 + vpbroadcastb xm2, angled + psraw xm0, 3 + shr angled, 8 + paddw xm3, xm0 + pxor xm0, xm0 + vpcmpeqb k2, xm11, [base+z_filter_wh] + pmaxsw xm3, xm0 + add dxd, dxd + pavgw xm3, xm0 + vpcmpgtb k2{k2}, xm2, [base+z_filter_t0+angleq*8] + pminsw xm3, xm1 + paddw m8, m8 + jmp .filter_left16b +.upsample_left: ; h4/h8 + lea r3d, [hq-1] + palignr xm2, xm7, xm12, 14 + vpbroadcastw xm0, r3d + palignr xm1, xm7, xm12, 12 + pminuw xm0, xm9 + paddw xm2, xm7 ; b+c + vpermw xm0, xm0, xm7 + add dyd, dyd + paddw xm0, xm1 ; a+d + vpbroadcastw xm1, r9m ; pixel_max + psubw xm0, xm2, xm0 + psraw xm0, 3 + paddw xm2, xm0 + pxor xm0, xm0 + pmaxsw xm2, xm0 + pavgw xm2, xm0 + pminsw xm2, xm1 + punpckhwd xm0, xm2, xm7 + punpcklwd xm7, xm2, xm7 + vinserti32x4 ym7, xm0, 1 + ret +.filter_above: + sub angled, 90 +.filter_above2: + vpbroadcastb ym1, r3d + vpbroadcastb ym10, angled + mov r3d, angled + shr r3d, 8 + vpcmpeqb k2, ym1, [base+z_filter_wh] + mova xm11, [base+z_filter_t0+r3*8] + vpcmpgtb k1{k2}, ym10, ym11 + mova m9, [base+pw_1to32] + kmovd r3d, k1 + test r3d, r3d + jz .filter_end + pminuw ym0, ym9 + popcnt r3d, r3d + vpbroadcastd ym6, r7m ; max_w + kxnorw k1, k1, k1 + vpbroadcastd ym5, [base+z_filter_k+(r3-1)*4+12*0] + kaddw k1, k1, k1 ; ~1 + vpbroadcastd ym13, [base+z_filter_k+(r3-1)*4+12*1] + vpermw ym2, ym0, ym4 ; +1 + pmullw ym5, ym4 + paddw ym1, ym2, ym3 + vmovdqu16 m3{k1}, [tlq-2] ; -2 + vpermw ym2, ym0, ym2 ; +2 + vpbroadcastd ym0, [base+z_filter_k+(r3-1)*4+12*2] + pmullw ym1, ym13 + movu m13, [base+pw_0to31] + paddw ym2, ym3 + packssdw ym6, ym6 + pmullw ym2, ym0 + paddw ym1, ym5 + vpcmpgtw k1, ym6, ym13 + paddw ym1, ym2 + pxor ym2, ym2 + psrlw ym1, 3 + pavgw ym4{k1}, ym1, ym2 +.filter_end: + ret +.filter_left16: + vpbroadcastd ym1, [base+pb_90] + psubb ym1, ym10 + vpcmpgtb k2{k2}, ym1, ym11 +.filter_left16b: + kmovd r3d, k2 + test r3d, r3d + jz .filter_end + lea r5d, [hq-1] + vinserti32x4 ym0, ym12, xm7, 1 + vpbroadcastw ym1, r5d + popcnt r3d, r3d + vpbroadcastd ym6, r8m ; max_h + pminuw ym9, ym1 + vpbroadcastd ym5, [base+z_filter_k+(r3-1)*4+12*0] + vpermw ym2, ym9, ym7 ; +1 + vpbroadcastd ym10, [base+z_filter_k+(r3-1)*4+12*1] + palignr ym1, ym7, ym0, 14 ; -1 + pmullw ym5, ym7 + palignr ym0, ym7, ym0, 12 ; -2 + paddw ym1, ym2 + vpermw ym2, ym9, ym2 ; +2 + vpbroadcastd ym9, [base+z_filter_k+(r3-1)*4+12*2] + pmullw ym1, ym10 + paddw ym2, ym0 + packssdw ym6, ym6 + pmullw ym2, ym9 + paddw ym1, ym5 + vpcmpgtw k1, ym6, [base+pw_0to31] + paddw ym1, ym2 + pxor ym2, ym2 + psrlw ym1, 3 + pavgw ym7{k1}, ym1, ym2 + ret +.filter_left: + cmp hd, 32 + jl .filter_left16 + vpbroadcastd m5, [base+pw_3] + pminud m0, m9, [base+pw_31] {1to16} +.filter_left32: + vpbroadcastd m6, r8m ; max_h + valignq m2, m7, m12, 6 + packssdw m6, m6 + palignr m1, m7, m2, 14 ; -1 + paddw m1, m7 + palignr m2, m7, m2, 12 ; -2 + vpcmpgtw k1, m6, m13 + paddw m2, m5 + cmp hd, 64 + je .filter_left64 + lea r3d, [hq-1] + vpbroadcastw m10, r3d + pminuw m0, m10 + vpermw m10, m0, m7 ; +1 + paddw m1, m10 + vpermw m10, m0, m10 ; +2 + pavgw m2, m10 + paddw m1, m2 + vpsrlw m7{k1}, m1, 2 + ret +.filter_left64: + valignq m10, m8, m7, 2 + vpaddd m13, [base+pw_32] {1to16} + palignr m11, m10, m7, 2 ; +1 + paddw m1, m11 + palignr m11, m10, m7, 4 ; +2 + valignq m10, m8, m7, 6 + pavgw m11, m2 + vpermw m2, m0, m8 ; 32+1 + paddw m1, m11 + vpsrlw m7{k1}, m1, 2 + palignr m1, m8, m10, 14 ; 32-1 + paddw m1, m8 + palignr m10, m8, m10, 12 ; 32-2 + paddw m1, m2 + vpermw m2, m0, m2 ; 32+2 + paddw m10, m5 + vpcmpgtw k1, m6, m13 + pavgw m2, m10 + paddw m1, m2 + vpsrlw m8{k1}, m1, 2 + ret +.w8: + mova xm3, [tlq] + vbroadcasti32x4 m8, [base+pw_1to32] + test angled, 0x400 + jnz .w8_main + lea r3d, [angleq+126] + mov r3b, hb + cmp r3d, 8 + ja .w8_no_upsample_above ; angle >= 130 || h > 8 || is_sm + psrldq xm0, xm4, 2 + sub angled, 53 + pshufhw xm0, xm0, q2210 + lea r3d, [hq+7] + call .upsample_above + punpcklwd xm0, xm3, xm4 + punpckhwd xm4, xm3, xm4 + vinserti32x4 ym3, ym12, xm0, 1 + vinserti32x4 ym4, ym0, xm4, 1 + palignr ym3, ym4, ym3, 14 + jmp .w8_main +.w8_upsample_left: + call .upsample_left + movshdup m1, [base+z_xpos_mul] + psllw m15, 3 + paddw m1, m1 + jmp .w8_main2 +.w8_no_upsample_above: + lea r3d, [hq+7] + vpbroadcastd ym0, [base+pw_7] + call .filter_above + lea r3d, [angleq-51] + mov r3b, hb + palignr xm3, xm4, xm12, 14 + cmp r3d, 8 + jbe .w8_upsample_left ; angle > 140 && h <= 8 && !is_sm + call .filter_left +.w8_main: + movshdup m1, [base+z_xpos_mul] + psllw m15, 2 +.w8_main2: + vbroadcasti32x4 m0, [base+pw_1to32] + vpbroadcastw m11, dxd + movshdup m2, [base+z_xpos_mul] + vpbroadcastw m13, dyd + psllw m10, m8, 6 + valignq m5, m7, m12, 6 + pmullw m2, m11 + psubw m10, m2 ; xpos + pmullw m13, m0 ; ypos + palignr m5, m7, m5, 14 + psrlw m12, m13, 6 + psllw m13, 9 + mov r2d, 1<<6 + paddw m12, m1 ; base_y + lea r3d, [dxq-(8<<6)] ; left-only threshold + pand m13, m14 ; frac_y << 9 + shl dxd, 2 + psllw m11, 2 + lea r5, [strideq*3] +.w8_loop: + psrlw m1, m10, 6 + pand m2, m14, m10 + vpermw m0, m1, m3 + vpermw m1, m1, m4 + psllw m2, 9 + sub r2d, dxd + jge .w8_toponly + vpmovw2m k1, m10 + vpermw m0{k1}, m12, m5 + vpermw m1{k1}, m12, m7 + vmovdqu16 m2{k1}, m13 +.w8_toponly: + psubw m1, m0 + pmulhrsw m1, m2 + paddw m0, m1 + mova [dstq+strideq*0], xm0 + vextracti32x4 [dstq+strideq*1], ym0, 1 + vextracti32x4 [dstq+strideq*2], m0, 2 + vextracti32x4 [dstq+r5 ], m0, 3 + sub hd, 4 + jz .w8_end + psubw m10, m11 ; base_x -= dx + lea dstq, [dstq+strideq*4] + paddw m12, m15 ; base_y++ + cmp r2d, r3d + jge .w8_loop +.w8_leftonly_loop: + vpermw m0, m12, m5 + vpermw m1, m12, m7 + psubw m1, m0 + pmulhrsw m1, m13 + paddw m12, m15 + paddw m0, m1 + mova [dstq+strideq*0], xm0 + vextracti32x4 [dstq+strideq*1], ym0, 1 + vextracti32x4 [dstq+strideq*2], m0, 2 + vextracti32x4 [dstq+r5 ], m0, 3 + lea dstq, [dstq+strideq*4] + sub hd, 4 + jg .w8_leftonly_loop +.w8_end: + RET +.w16: + mova ym3, [tlq] + vpermw m8, m0, [tlq-64*2] + test angled, 0x400 + jnz .w16_main + lea r3d, [hq+15] + vpbroadcastd ym0, [base+pw_15] + call .filter_above + call .filter_left + vinserti32x4 ym3, ym12, xm4, 1 + palignr ym3, ym4, ym3, 14 +.w16_main: + vbroadcasti32x8 m0, [base+pw_1to32] + vpbroadcastw m11, dxd + vpbroadcastw m13, dyd + kxnorw k2, k2, k2 + psllw m10, m0, 6 + valignq m5, m7, m12, 6 + psubw m10, m11 ; xpos + valignq m6, m8, m7, 6 + pmullw m13, m0 ; ypos + knotd k1, k2 + palignr m5, m7, m5, 14 + palignr m6, m8, m6, 14 + vpsubw m10{k1}, m11 + psrlw m12, m13, 6 + psllw m13, 9 + mov r2d, 1<<6 + vpsubw m12{k2}, m15 ; base_y + pand m13, m14 ; frac_y << 9 + lea r3d, [dxq-(16<<6)] + paddw m11, m11 + add dxd, dxd + paddw m15, m15 +.w16_loop: + psrlw m1, m10, 6 + pand m2, m14, m10 + vpermw m0, m1, m3 + vpermw m1, m1, m4 + psllw m2, 9 + psubw m1, m0 + pmulhrsw m1, m2 + paddw m12, m15 ; base_y++ + paddw m0, m1 + sub r2d, dxd + jge .w16_toponly + mova m1, m5 + vpermt2w m1, m12, m6 + mova m2, m7 + vpermt2w m2, m12, m8 + vpmovw2m k1, m10 + psubw m2, m1 + pmulhrsw m2, m13 + vpaddw m0{k1}, m1, m2 +.w16_toponly: + mova [dstq+strideq*0], ym0 + vextracti32x8 [dstq+strideq*1], m0, 1 + sub hd, 2 + jz .w16_end + psubw m10, m11 ; base_x -= dx + lea dstq, [dstq+strideq*2] + cmp r2d, r3d + jge .w16_loop + paddw m12, m15 + vpermt2w m5, m12, m6 + mova m1, m7 + vpermt2w m1, m12, m8 + jmp .w16_leftonly_loop_start +.w16_leftonly_loop: + mova m1, m7 + vpermt2w m1, m12, m8 + vshufi32x4 m5, m1, q1032 +.w16_leftonly_loop_start: + psubw m0, m1, m5 + pmulhrsw m0, m13 + paddw m12, m15 + paddw m0, m5 + mova m5, m1 + mova [dstq+strideq*0], ym0 + vextracti32x8 [dstq+strideq*1], m0, 1 + lea dstq, [dstq+strideq*2] + sub hd, 2 + jg .w16_leftonly_loop +.w16_end: + RET +.w32: + mova m3, [tlq] + vpermw m8, m0, [tlq-64*2] + mova m9, [base+pw_1to32] + test angled, 0x400 + jnz .w32_main + pminud m0, m9, [base+pw_31] {1to16} + mov r3d, ~1 + kmovd k1, r3d + vpbroadcastd m5, [base+pw_3] + vpbroadcastd m6, r6m ; max_w + vpermw m2, m0, m4 ; +1 + movu m13, [base+pw_0to31] + paddw m1, m4, m3 + vmovdqu16 m3{k1}, [tlq-2] ; -2 + packssdw m6, m6 + paddw m1, m2 + vpermw m2, m0, m2 ; +2 + paddw m3, m5 + vpcmpgtw k1, m6, m13 + pavgw m2, m3 + paddw m1, m2 + psrlw m4{k1}, m1, 2 + call .filter_left32 +.w32_main: + sub rsp, 64*2 + call .w32_main1 + add rsp, 64*2 + RET +.w32_main1: + vpbroadcastw m11, dxd + movu [rsp+64], m4 + vpbroadcastw m4, dyd + movd [rsp+60], xm12 + valignq m5, m7, m12, 6 + psllw m3, m9, 6 ; xpos + valignq m6, m8, m7, 6 + pmullw m9, m4 ; ypos + palignr m5, m7, m5, 14 + mov r2d, 33<<6 + palignr m6, m8, m6, 14 + mova m10, m3 +.w32_main2: + psllw m13, m9, 9 + sub r2d, dxd + psrlw m12, m9, 6 ; base_y + mov r8d, hd + pand m13, m14 ; frac_y << 9 +.w32_loop: + mov r3d, r2d + shr r3d, 6 + psubw m10, m11 ; base_x -= dx + movu m0, [rsp+r3*2-2] + pand m2, m10, m14 ; frac_x + movu m1, [rsp+r3*2] + psllw m2, 9 + psubw m1, m0 + pmulhrsw m1, m2 + paddw m12, m15 ; base_y++ + paddw m0, m1 + cmp r2d, 32<<6 + jge .w32_toponly + mova m1, m5 + vpermt2w m1, m12, m6 + mova m2, m7 + vpermt2w m2, m12, m8 + vpmovw2m k1, m10 + psubw m2, m1 + pmulhrsw m2, m13 + vpaddw m0{k1}, m1, m2 +.w32_toponly: + mova [dstq], m0 + dec r8d + jz .w32_end + add dstq, strideq + sub r2d, dxd + jge .w32_loop + paddw m12, m15 + mova m2, m5 + vpermt2w m2, m12, m6 +.w32_leftonly_loop: + mova m1, m7 + vpermt2w m1, m12, m8 + psubw m0, m1, m2 + pmulhrsw m0, m13 + paddw m12, m15 + paddw m0, m2 + mova m2, m1 + mova [dstq], m0 + add dstq, strideq + dec r8d + jg .w32_leftonly_loop +.w32_end: + ret +.w64: + movu m3, [tlq+66] + vpermw m8, m0, [tlq-64*2] + mova m9, [base+pw_1to32] + test angled, 0x400 + jnz .w64_main + mova m2, [tlq] ; -1 + mov r3d, ~1 + vpbroadcastd m5, [base+pw_3] + kmovd k1, r3d + movu m13, [base+pw_0to31] + vpbroadcastd m6, r6m ; max_w + pminud m0, m9, [base+pw_31] {1to16} + paddw m1, m4, m2 + vmovdqu16 m2{k1}, [tlq-2] ; -2 + packssdw m6, m6 + paddw m1, [tlq+4] ; +1 + paddw m2, m5 + vpcmpgtw k1, m6, m13 + pavgw m2, [tlq+6] ; +2 + paddw m1, m2 + vpermw m2, m0, m3 ; 32+1 + psrlw m4{k1}, m1, 2 + paddw m1, m3, [tlq+64] ; 32-1 + vpaddd m11, m13, [base+pw_32] {1to16} + paddw m1, m2 + vpermw m2, m0, m2 ; 32+2 + paddw m10, m5, [tlq+62] ; 32-2 + vpcmpgtw k1, m6, m11 + pavgw m2, m10 + paddw m1, m2 + psrlw m3{k1}, m1, 2 + call .filter_left32 +.w64_main: + sub rsp, 64*3 + movu [rsp+64*2-gprsize], m3 + mov r5, dstq + call .w32_main1 + psllw m4, 5 + mov r2d, 65<<6 + vpaddd m10, m3, [base+pw_2048] {1to16} ; xpos + lea dstq, [r5+64] + paddw m9, m4 ; ypos + call .w32_main2 + add rsp, 64*3 + RET + cglobal ipred_z3_16bpc, 3, 8, 16, dst, stride, tl, w, h, angle, dy lea r7, [z_filter_t0] tzcnt wd, wm diff --git a/third_party/dav1d/tests/dav1d_argon.bash b/third_party/dav1d/tests/dav1d_argon.bash index 27a8d61911..954dad8d2d 100755 --- a/third_party/dav1d/tests/dav1d_argon.bash +++ b/third_party/dav1d/tests/dav1d_argon.bash @@ -4,8 +4,8 @@ DAV1D="tools/dav1d" ARGON_DIR='.' FILMGRAIN=1 CPUMASK=-1 -THREADS=0 -JOBS=1 +THREADS=1 +JOBS=0 usage() { NAME=$(basename "$0") @@ -19,8 +19,8 @@ usage() { printf " -a dir path to argon dir (default: 'tests/argon' if found; '.' otherwise)\n" printf " -g \$num enable filmgrain (default: 1)\n" printf " -c \$mask use restricted cpumask (default: -1)\n" - printf " -t \$num number of threads per dav1d (default: 0)\n" - printf " -j \$num number of parallel dav1d processes (default: 1)\n\n" + printf " -t \$num number of threads per dav1d (default: 1)\n" + printf " -j \$num number of parallel dav1d processes (default: 0)\n\n" } >&2 exit 1 } @@ -110,6 +110,14 @@ while getopts ":d:a:g:c:t:j:" opt; do done shift $((OPTIND-1)) +if [ "$JOBS" -eq 0 ]; then + if [ "$THREADS" -gt 0 ]; then + JOBS="$((($( (nproc || sysctl -n hw.logicalcpu || getconf _NPROCESSORS_ONLN || echo 1) 2>/dev/null)+THREADS-1)/THREADS))" + else + JOBS=1 + fi +fi + if [ "$#" -eq 0 ]; then # Everything except large scale tiles and stress files. dirs=("$ARGON_DIR/profile0_core" "$ARGON_DIR/profile0_core_special" diff --git a/third_party/function2/Readme.md b/third_party/function2/Readme.md index d8d2bdc45e..7556e83e8e 100644 --- a/third_party/function2/Readme.md +++ b/third_party/function2/Readme.md @@ -63,7 +63,7 @@ Use `fu2::function` as a wrapper for copyable function wrappers and `fu2::unique The standard implementation `std::function` and `fu2::function` are convertible to each other, see [the chapter convertibility of functions](#convertibility-of-functions) for details. A function wrapper is declared as following: -```cpp +```c++ fu2::function // Return type ~^ ^ ^ ^ // Parameters ~~~~~|~~~~~| ^ @@ -98,7 +98,7 @@ fu2::function `fu2::function` and `fu2::unique_function` (non copyable) are easy to use: -```cpp +```c++ fu2::function fun = [] { // ... }; @@ -111,7 +111,7 @@ fun(); `fu2::unique_function` also works with non copyable functors/ lambdas. -```cpp +```c++ fu2::unique_function fun = [ptr = std::make_unique(true)] { return *ptr; }; @@ -127,7 +127,7 @@ otherfun(); A `fu2::function_view` can be used to create a non owning view on a persistent object. Note that the view is only valid as long as the object lives. -```cpp +```c++ auto callable = [ptr = std::make_unique(true)] { return *ptr; }; @@ -164,7 +164,7 @@ fu2::function_view view(callable); | fu2::unique_function | No | Yes | No | | std::function | Yes | Yes | Yes | -```cpp +```c++ fu2::function fun = []{}; // OK std::function std_fun = fun; @@ -197,14 +197,14 @@ struct my_capacity { The following code defines an owning function with a variadic signature which is copyable and sfo optimization is disabled: -```cpp +```c++ template using my_function = fu2::function_base; ``` The following code defines a non copyable function which just takes 1 argument, and has a huge capacity for internal sfo optimization. Also it must be called as r-value. -```cpp +```c++ template using my_consumer = fu2::function_base, true, false, void(Arg)&&>; diff --git a/third_party/function2/include/function2/function2.hpp b/third_party/function2/include/function2/function2.hpp index e6dfca072e..ffb82b5ef7 100644 --- a/third_party/function2/include/function2/function2.hpp +++ b/third_party/function2/include/function2/function2.hpp @@ -1828,6 +1828,14 @@ constexpr auto overload(T&&... callables) { } } // namespace fu2 +namespace std{ +template +struct uses_allocator< + ::fu2::detail::function, + Alloc +> : std::true_type {}; +} // namespace std + #undef FU2_DETAIL_EXPAND_QUALIFIERS #undef FU2_DETAIL_EXPAND_QUALIFIERS_NOEXCEPT #undef FU2_DETAIL_EXPAND_CV diff --git a/third_party/function2/moz.yaml b/third_party/function2/moz.yaml index f1f1376b9f..d4fd5a2043 100644 --- a/third_party/function2/moz.yaml +++ b/third_party/function2/moz.yaml @@ -10,9 +10,9 @@ origin: url: https://naios.github.io/function2/ - release: a354bd093d2b6e50c9325dbce84d20b4e77aabc6 (2023-11-04T12:44:54Z). + release: 43fc0ca473ecb081918709bd7d524d84c2ff8dce (2024-02-25T17:37:03Z). - revision: a354bd093d2b6e50c9325dbce84d20b4e77aabc6 + revision: 43fc0ca473ecb081918709bd7d524d84c2ff8dce license: BSL-1.0 license-file: LICENSE.txt diff --git a/third_party/gemmology/gemmology.h b/third_party/gemmology/gemmology.h index d774c53388..eb5ebed3b4 100644 --- a/third_party/gemmology/gemmology.h +++ b/third_party/gemmology/gemmology.h @@ -198,6 +198,17 @@ PermuteSummer(xsimd::batch pack0123, return _mm256_add_epi32(rev, blended); } +template +inline xsimd::batch Pack0123(xsimd::batch sum0, + xsimd::batch sum1, + xsimd::batch sum2, + xsimd::batch sum3, + xsimd::kernel::requires_arch) { + auto pack01 = _mm256_hadd_epi32(sum0, sum1); + auto pack23 = _mm256_hadd_epi32(sum2, sum3); + return _mm256_hadd_epi32(pack01, pack23); +} + #ifdef __AVXVNNI__ template @@ -245,6 +256,17 @@ madd(xsimd::batch x, xsimd::batch y, xsimd::kernel::requires_arch) { return _mm_maddubs_epi16(xsimd::abs(x), _mm_sign_epi8(y, x)); } + +template +inline xsimd::batch Pack0123(xsimd::batch sum0, + xsimd::batch sum1, + xsimd::batch sum2, + xsimd::batch sum3, + xsimd::kernel::requires_arch) { + auto pack01 = _mm_hadd_epi32(sum0, sum1); + auto pack23 = _mm_hadd_epi32(sum2, sum3); + return _mm_hadd_epi32(pack01, pack23); +} #endif #ifdef __SSE2__ @@ -524,7 +546,8 @@ xsimd::batch deinterleave(xsimd::batch first, xsimd::batch second, xsimd::kernel::requires_arch) { - return vcombine_s8(vqmovn_s16(first), vqmovn_s16(second)); + + return vqmovn_high_s16(vqmovn_s16(first), second); } template @@ -532,27 +555,18 @@ xsimd::batch deinterleave(xsimd::batch first, xsimd::batch second, xsimd::kernel::requires_arch) { - return vcombine_s16(vqmovn_s32(first), vqmovn_s32(second)); + return vqmovn_high_s32(vqmovn_s32(first), second); } +#ifdef __ARM_FEATURE_MATMUL_INT8 template inline xsimd::batch -madd(xsimd::batch x, xsimd::batch y, - xsimd::kernel::requires_arch) { - int32x4_t low = vmull_s16(vget_low_s16(x), vget_low_s16(y)); - return vmlal_high_s16(low, x, y); -} - -template -inline xsimd::batch -madd(xsimd::batch x, xsimd::batch y, - xsimd::kernel::requires_arch) { - - int16x8_t tl = vmull_s8(vreinterpret_s8_u8(vget_low_u8(x)), - vget_low_s8(y)); - int16x8_t th = vmull_high_s8(vreinterpretq_s8_u8(x), y); - return vqaddq_s16(vuzp1q_s16(tl, th), vuzp2q_s16(tl, th)); +maddw(xsimd::batch x, xsimd::batch y, + xsimd::batch z, + xsimd::kernel::requires_arch>) { + return vusdotq_s32(z, x, y); } +#endif template inline xsimd::batch @@ -564,15 +578,17 @@ maddw(xsimd::batch x, xsimd::batch y, int16x8_t th = vmulq_s16(vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(x))), vmovl_s8(vget_high_s8(y))); return vpadalq_s16(vpadalq_s16(z, tl), th); - //TODO: investigate using vdotq_s32 } template -inline xsimd::batch -madd(xsimd::batch x, xsimd::batch y, - xsimd::kernel::requires_arch) { - int16x8_t low = vmull_s8(vget_low_s8(x), vget_low_s8(y)); - return vmlal_high_s8(low, x, y); +inline xsimd::batch Pack0123(xsimd::batch sum0, + xsimd::batch sum1, + xsimd::batch sum2, + xsimd::batch sum3, + xsimd::kernel::requires_arch) { + auto pack01 = vpaddq_s32(sum0, sum1); + auto pack23 = vpaddq_s32(sum2, sum3); + return vpaddq_s32(pack01, pack23); } #endif @@ -644,20 +660,35 @@ inline auto PermuteSummer(xsimd::batch pack0123, return kernel::PermuteSummer(pack0123, pack4567, Arch{}); } + +namespace kernel { + + template + inline xsimd::batch Pack0123(xsimd::batch sum0, + xsimd::batch sum1, + xsimd::batch sum2, + xsimd::batch sum3, + xsimd::kernel::requires_arch) { + + std::tie(sum0, sum1) = interleave(sum0, sum1, Arch{}); + auto pack01 = sum0 + sum1; + std::tie(sum2, sum3) = interleave(sum2, sum3, Arch{}); + auto pack23 = sum2 + sum3; + + auto packed = interleave(xsimd::bitwise_cast(pack01), + xsimd::bitwise_cast(pack23), + Arch{}); + return xsimd::bitwise_cast(std::get<0>(packed)) + + xsimd::bitwise_cast(std::get<1>(packed)); + } +} + template inline xsimd::batch Pack0123(xsimd::batch sum0, xsimd::batch sum1, xsimd::batch sum2, xsimd::batch sum3) { - std::tie(sum0, sum1) = interleave(sum0, sum1); - auto pack01 = sum0 + sum1; - std::tie(sum2, sum3) = interleave(sum2, sum3); - auto pack23 = sum2 + sum3; - - auto packed = interleave(xsimd::bitwise_cast(pack01), - xsimd::bitwise_cast(pack23)); - return xsimd::bitwise_cast(std::get<0>(packed)) + - xsimd::bitwise_cast(std::get<1>(packed)); + return kernel::Pack0123(sum0, sum1, sum2, sum3, Arch{}); } template diff --git a/third_party/gemmology/kernels/GemmologyEngineNeon64I8mm.cpp b/third_party/gemmology/kernels/GemmologyEngineNeon64I8mm.cpp new file mode 100644 index 0000000000..d8259e750f --- /dev/null +++ b/third_party/gemmology/kernels/GemmologyEngineNeon64I8mm.cpp @@ -0,0 +1,19 @@ +/* -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* this source code form is subject to the terms of the mozilla public + * license, v. 2.0. if a copy of the mpl was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include + +namespace gemmology { +template struct Engine>; +template void Engine>::SelectColumnsB(int8_t const*, int8_t*, + size_t, uint32_t const*, + uint32_t const*); +template void Engine>::Shift::Multiply( + uint8_t const*, int8_t const*, size_t, size_t, size_t, + gemmology::callbacks::UnquantizeAndAddBiasAndWrite); +template void Engine>::Shift::PrepareBias( + int8_t const*, size_t, size_t, + gemmology::callbacks::UnquantizeAndAddBiasAndWrite); +} // namespace gemmology diff --git a/third_party/gemmology/moz.yaml b/third_party/gemmology/moz.yaml index d9f9472da7..749227e2ee 100644 --- a/third_party/gemmology/moz.yaml +++ b/third_party/gemmology/moz.yaml @@ -10,8 +10,8 @@ origin: url: https://github.com/mozilla/gemmology - release: ec535e87d0ab9d1457ff6d2af247cc8113e74694 (2024-02-05T09:05:20Z). - revision: ec535e87d0ab9d1457ff6d2af247cc8113e74694 + release: dbcd029c3bc6e183355ea597216d379677ff9b19 (2024-02-20T12:36:14Z). + revision: dbcd029c3bc6e183355ea597216d379677ff9b19 license: MIT diff --git a/third_party/jpeg-xl/.clang-tidy b/third_party/jpeg-xl/.clang-tidy index 06c9875624..42d386276b 100644 --- a/third_party/jpeg-xl/.clang-tidy +++ b/third_party/jpeg-xl/.clang-tidy @@ -25,16 +25,31 @@ Checks: >- modernize-*, performance-*, readability-*, + -bugprone-narrowing-conversions, + -bugprone-branch-clone, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-infinite-loop, + -bugprone-unused-local-non-trivial-variable, + -modernize-avoid-c-arrays, -modernize-deprecated-headers, -modernize-return-braced-init-list, -modernize-use-auto, -modernize-use-default-member-init, -modernize-use-trailing-return-type, -modernize-use-using, + -performance-enum-size, + -readability-avoid-nested-conditional-operator, -readability-else-after-return, -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-magic-numbers, + -readability-redundant-access-specifiers, + -readability-simplify-boolean-expr, -readability-static-accessed-through-instance, + -readability-suspicious-call-argument, -readability-uppercase-literal-suffix, + -readability-use-anyofallof, WarningsAsErrors: >- @@ -57,11 +72,13 @@ WarningsAsErrors: >- HeaderFilterRegex: '^.*/(lib|tools)/.*\.h$' CheckOptions: - - key: readability-braces-around-statements.ShortStatementLines - value: '2' - - key: google-readability-braces-around-statements.ShortStatementLines - value: '2' - - key: readability-implicit-bool-conversion.AllowPointerConditions - value: '1' - - key: readability-implicit-bool-conversion.AllowIntegerConditions - value: '1' + - key: readability-braces-around-statements.ShortStatementLines + value: '2' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '2' + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: '1' + - key: readability-implicit-bool-conversion.AllowIntegerConditions + value: '1' + - key: bugprone-signed-char-misuse.CharTypdefsToIgnore + value: 'int8_t' diff --git a/third_party/jpeg-xl/AUTHORS b/third_party/jpeg-xl/AUTHORS index 04d436b8fe..ed6d72db66 100644 --- a/third_party/jpeg-xl/AUTHORS +++ b/third_party/jpeg-xl/AUTHORS @@ -32,6 +32,7 @@ Zoltan Szabadka # Individuals: a-shvedov Aditya Patadia +Ahmad Amsyar Asyadiq Bin Syaiful Bahri <27284123+Ahmad-Amsyar@users.noreply.github.com> Alex Xu (Hello71) Alexander Sago Alistair Barrow @@ -74,6 +75,7 @@ Misaki Kasumi Moonchild Straver Nicholas Hayes <0xC0000054@users.noreply.github.com> Nigel Tao +oupson Petr Diblík Pieter Wuille roland-rollo @@ -93,4 +95,3 @@ xiota Yonatan Nebenzhal Ziemowit Zabawa 源文雨 <41315874+fumiama@users.noreply.github.com> -oupson diff --git a/third_party/jpeg-xl/CHANGELOG.md b/third_party/jpeg-xl/CHANGELOG.md index add193bf67..3c62a1f2df 100644 --- a/third_party/jpeg-xl/CHANGELOG.md +++ b/third_party/jpeg-xl/CHANGELOG.md @@ -13,6 +13,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed / clarified +### Fixed + + +## [0.10.0] - 2024-02-21 + +### Added + - decoder API: added `JxlDecoderGetBoxSizeContents` for getting the size of the + content of a box without the headers. + - encoder API: implemented new api functions for streaming encoding. + +### Changed / clarified + - decoder/encoder API: return failure when surface allocation fail + - encoder API / cjxl: updated modular effort levels to faster settings; the + effort range is now 1-10, with 11 available in advanced mode. + +## [0.9.2] - 2024-02-07 + +### Fixed + - bugs in the gdk-pixbuf plugin + - some build issues + +## [0.9.1] - 2024-01-08 + +### Fixed + - multiple build issues + ## [0.9.0] - 2023-12-22 ### Added @@ -57,6 +83,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - fixed how large boxes are decoded (#2958) - fixed encoding files with unreadable patches (#3042, #3046) +## [0.8.2] - 2023-06-14 + +### Changed + - Security: Fix an integer underflow bug in patch decoding (#2551- CVE-2023-35790). + +## [0.8.1] - 2023-02-03 + +### Changed + - Allow fast-lossless for 16-bit float input (#2093) + - Fix bug in palette (#2120) + - Security: Fix OOB read in exif.h (#2101 - [CVE-2023-0645](https://www.cve.org/cverecord?id=CVE-2023-0645)) + ## [0.8.0] - 2023-01-18 ### Added diff --git a/third_party/jpeg-xl/CMakeLists.txt b/third_party/jpeg-xl/CMakeLists.txt index 85f3c265c2..9b74537f1c 100644 --- a/third_party/jpeg-xl/CMakeLists.txt +++ b/third_party/jpeg-xl/CMakeLists.txt @@ -161,13 +161,13 @@ set(JPEGXL_ENABLE_AVX512_SPR false CACHE BOOL set(JPEGXL_ENABLE_AVX512_ZEN4 false CACHE BOOL "Build with Zen4-optimized AVX512 support (faster on CPUs that support it, but larger binary size).") set(JPEGXL_ENABLE_WASM_TRHEADS true CACHE BOOL - "Builds WASM modules with threads suppurt") + "Builds WASM modules with threads support") # Force system dependencies. set(JPEGXL_FORCE_SYSTEM_BROTLI false CACHE BOOL "Force using system installed brotli instead of third_party/brotli source.") set(JPEGXL_FORCE_SYSTEM_GTEST false CACHE BOOL - "Force using system installed googletest (gtest/gmock) instead of third_party/googletest source.") + "Force using system installed googletest (gtest) instead of third_party/googletest source.") set(JPEGXL_FORCE_SYSTEM_LCMS2 false CACHE BOOL "Force using system installed lcms2 instead of third_party/lcms source.") set(JPEGXL_FORCE_SYSTEM_HWY false CACHE BOOL diff --git a/third_party/jpeg-xl/MODULE.bazel b/third_party/jpeg-xl/MODULE.bazel index c838384185..64a44711b3 100644 --- a/third_party/jpeg-xl/MODULE.bazel +++ b/third_party/jpeg-xl/MODULE.bazel @@ -1,4 +1,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0") +bazel_dep(name = "giflib", version = "5.2.1") bazel_dep(name = "googletest", version = "1.14.0") -bazel_dep(name = "openexr", version = "3.2.1") +bazel_dep(name = "libjpeg_turbo", version = "2.1.91") bazel_dep(name = "libpng", version = "1.6.40") +bazel_dep(name = "libwebp", version = "1.3.2") +bazel_dep(name = "openexr", version = "3.2.1") diff --git a/third_party/jpeg-xl/README.md b/third_party/jpeg-xl/README.md index bcea13ff23..d4520fff21 100644 --- a/third_party/jpeg-xl/README.md +++ b/third_party/jpeg-xl/README.md @@ -73,11 +73,14 @@ To decode a JPEG XL file run: djxl input.jxl output.png ``` -When possible `cjxl`/`djxl` are able to read/write the following -image formats: .exr, .gif, .jpeg/.jpg, .pfm, .pgm/.ppm, .pgx, .png. +When possible, `cjxl`/`djxl` are able to read/write the following image formats: +OpenEXR (`.exr`), GIF (`.gif`), JPEG (`.jpg`/`.jpeg`), NetPBM (`.pam`/`.pgm`/`.ppm`), +Portable FloatMap (`.pfm`), PGX Test Format (`.pgx`), Portable Network Graphics (`.png`), +Animated PNG (`.png`/`.apng`), and JPEG XL itself (`.jxl`). + Specifically for JPEG files, the default `cjxl` behavior is to apply lossless recompression and the default `djxl` behavior is to reconstruct the original -JPEG file (when the extension of the output file is .jpg). +JPEG file (when the extension of the output file is `.jpg`). ### Benchmarking diff --git a/third_party/jpeg-xl/WORKSPACE b/third_party/jpeg-xl/WORKSPACE index 4e0e1326bb..1383b44e0d 100644 --- a/third_party/jpeg-xl/WORKSPACE +++ b/third_party/jpeg-xl/WORKSPACE @@ -30,185 +30,3 @@ cc_library( """, path = "third_party/skcms", ) - -new_git_repository( - name = "libjpeg_turbo", - build_file_content = """ -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -SUBSTITUTIONS = { - "@BUILD@" : "20230208", - "@CMAKE_PROJECT_NAME@" : "libjpeg-turbo", - "@COPYRIGHT_YEAR@" : "2023", - "@INLINE@" : "__inline__", - "@JPEG_LIB_VERSION@" : "62", - "@LIBJPEG_TURBO_VERSION_NUMBER@" : "2001091", - "@SIZE_T@" : "8", - "@THREAD_LOCAL@" : "__thread", - "@VERSION@" : "2.1.91", -} -YES_DEFINES = [ - "C_ARITH_CODING_SUPPORTED", "D_ARITH_CODING_SUPPORTED", - "HAVE_BUILTIN_CTZL", "MEM_SRCDST_SUPPORTED" -] -NO_DEFINES = [ - "WITH_SIMD", "RIGHT_SHIFT_IS_UNSIGNED", "HAVE_INTRIN_H" -] -SUBSTITUTIONS.update({ - "#cmakedefine " + key : "#define " + key for key in YES_DEFINES -}) -SUBSTITUTIONS.update({ - "#cmakedefine " + key : "// #define " + key for key in NO_DEFINES -}) -[ - expand_template( - name = "expand_" + src, - template = src + ".in", - out = src, - substitutions = SUBSTITUTIONS, - visibility = ["//visibility:public"], - ) for src in ["jconfig.h", "jconfigint.h", "jversion.h"] -] -JPEG16_SOURCES = [ - "jccolor.c", - "jcdiffct.c", - "jclossls.c", - "jcmainct.c", - "jcprepct.c", - "jcsample.c", - "jdcolor.c", - "jddiffct.c", - "jdlossls.c", - "jdmainct.c", - "jdmerge.c", - "jdpostct.c", - "jdsample.c", - "jquant1.c", - "jquant2.c", - "jutils.c", -] -JPEG12_SOURCES = JPEG16_SOURCES + [ - "jccoefct.c", - "jcdctmgr.c", - "jdcoefct.c", - "jddctmgr.c", - "jfdctfst.c", - "jfdctint.c", - "jidctflt.c", - "jidctfst.c", - "jidctint.c", - "jidctred.c", -] -JPEG_SOURCES = JPEG12_SOURCES + [ - "jaricom.c", - "jcapimin.c", - "jcapistd.c", - "jcarith.c", - "jchuff.c", - "jcicc.c", - "jcinit.c", - "jclhuff.c", - "jcmarker.c", - "jcmaster.c", - "jcomapi.c", - "jcparam.c", - "jcphuff.c", - "jdapimin.c", - "jdapistd.c", - "jdarith.c", - "jdatadst.c", - "jdatasrc.c", - "jdhuff.c", - "jdicc.c", - "jdinput.c", - "jdlhuff.c", - "jdmarker.c", - "jdmaster.c", - "jdphuff.c", - "jdtrans.c", - "jerror.c", - "jfdctflt.c", - "jmemmgr.c", - "jmemnobs.c", -] -JPEG_HEADERS = [ - "jccolext.c", - "jchuff.h", - "jcmaster.h", - "jconfig.h", - "jconfigint.h", - "jdcoefct.h", - "jdcol565.c", - "jdcolext.c", - "jdct.h", - "jdhuff.h", - "jdmainct.h", - "jdmaster.h", - "jdmerge.h", - "jdmrg565.c", - "jdmrgext.c", - "jdsample.h", - "jerror.h", - "jinclude.h", - "jlossls.h", - "jmemsys.h", - "jmorecfg.h", - "jpeg_nbits_table.h", - "jpegapicomp.h", - "jpegint.h", - "jpeglib.h", - "jsamplecomp.h", - "jsimd.h", - "jsimddct.h", - "jstdhuff.c", - "jversion.h", -] -cc_library( - name = "jpeg16", - srcs = JPEG16_SOURCES, - hdrs = JPEG_HEADERS, - local_defines = ["BITS_IN_JSAMPLE=16"], - visibility = ["//visibility:public"], -) -cc_library( - name = "jpeg12", - srcs = JPEG12_SOURCES, - hdrs = JPEG_HEADERS, - local_defines = ["BITS_IN_JSAMPLE=12"], - visibility = ["//visibility:public"], -) -cc_library( - name = "jpeg", - srcs = JPEG_SOURCES, - hdrs = JPEG_HEADERS, - deps = [":jpeg16", ":jpeg12"], - includes = ["."], - visibility = ["//visibility:public"], -) -exports_files([ - "jmorecfg.h", - "jpeglib.h", -]) - """, - remote = "https://github.com/libjpeg-turbo/libjpeg-turbo.git", - tag = "2.1.91", -) - -http_archive( - name = "gif", - build_file_content = """ -cc_library( - name = "gif", - srcs = [ - "dgif_lib.c", "egif_lib.c", "gifalloc.c", "gif_err.c", "gif_font.c", - "gif_hash.c", "openbsd-reallocarray.c", "gif_hash.h", - "gif_lib_private.h" - ], - hdrs = ["gif_lib.h"], - includes = ["."], - visibility = ["//visibility:public"], -) - """, - sha256 = "31da5562f44c5f15d63340a09a4fd62b48c45620cd302f77a6d9acf0077879bd", - strip_prefix = "giflib-5.2.1", - url = "https://netcologne.dl.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz", -) diff --git a/third_party/jpeg-xl/bash_test.sh b/third_party/jpeg-xl/bash_test.sh index 9bd28f413b..d24ca976e6 100755 --- a/third_party/jpeg-xl/bash_test.sh +++ b/third_party/jpeg-xl/bash_test.sh @@ -106,12 +106,6 @@ test_printf_size_t() { ret=1 fi - if grep -n -E 'gmock\.h' \ - $(git ls-files | grep -E '(\.c|\.cc|\.cpp|\.h)$' | grep -v -F /testing.h); then - echo "Don't include gmock directly, instead include 'testing.h'. " >&2 - ret=1 - fi - local f for f in $(git ls-files | grep -E "\.cc$" | xargs grep 'PRI[udx]S' | cut -f 1 -d : | uniq); do diff --git a/third_party/jpeg-xl/ci.sh b/third_party/jpeg-xl/ci.sh index f33efd9693..448a7f9927 100755 --- a/third_party/jpeg-xl/ci.sh +++ b/third_party/jpeg-xl/ci.sh @@ -16,6 +16,8 @@ MYDIR=$(dirname $(realpath "$0")) ### Environment parameters: TEST_STACK_LIMIT="${TEST_STACK_LIMIT:-256}" +BENCHMARK_NUM_THREADS="${BENCHMARK_NUM_THREADS:-0}" +BUILD_CONFIG=${BUILD_CONFIG:-} CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-RelWithDebInfo} CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-} CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER:-} @@ -79,6 +81,12 @@ if [[ "${ENABLE_WASM_SIMD}" -eq "2" ]]; then CMAKE_C_FLAGS="${CMAKE_C_FLAGS} -DHWY_WANT_WASM2" fi +if [[ -z "${BUILD_CONFIG}" ]]; then + TOOLS_DIR="${BUILD_DIR}/tools" +else + TOOLS_DIR="${BUILD_DIR}/tools/${BUILD_CONFIG}" +fi + if [[ ! -z "${HWY_BASELINE_TARGETS}" ]]; then CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -DHWY_BASELINE_TARGETS=${HWY_BASELINE_TARGETS}" fi @@ -128,17 +136,17 @@ if [[ "${BUILD_TARGET%%-*}" != "arm" ]]; then ) fi -CLANG_TIDY_BIN=$(which clang-tidy-6.0 clang-tidy-7 clang-tidy-8 clang-tidy | head -n 1) +CLANG_TIDY_BIN=$(which clang-tidy-6.0 clang-tidy-7 clang-tidy-8 clang-tidy 2>/dev/null | head -n 1) # Default to "cat" if "colordiff" is not installed or if stdout is not a tty. if [[ -t 1 ]]; then - COLORDIFF_BIN=$(which colordiff cat | head -n 1) + COLORDIFF_BIN=$(which colordiff cat 2>/dev/null | head -n 1) else COLORDIFF_BIN="cat" fi -FIND_BIN=$(which gfind find | head -n 1) +FIND_BIN=$(which gfind find 2>/dev/null | head -n 1) # "false" will disable wine64 when not installed. This won't allow # cross-compiling. -WINE_BIN=$(which wine64 false | head -n 1) +WINE_BIN=$(which wine64 false 2>/dev/null | head -n 1) CLANG_VERSION="${CLANG_VERSION:-}" # Detect the clang version suffix and store it in CLANG_VERSION. For example, @@ -411,7 +419,7 @@ cmake_build_and_test() { if [[ "${PACK_TEST:-}" == "1" ]]; then (cd "${BUILD_DIR}" ${FIND_BIN} -name '*.cmake' -a '!' -path '*CMakeFiles*' - # gtest / gmock / gtest_main shared libs + # gtest / gtest_main shared libs ${FIND_BIN} lib/ -name 'libg*.so*' ${FIND_BIN} -type d -name tests -a '!' -path '*CMakeFiles*' ) | tar -C "${BUILD_DIR}" -cf "${BUILD_DIR}/tests.tar.xz" -T - \ @@ -791,9 +799,13 @@ cmd_ossfuzz_ninja() { cmd_fast_benchmark() { local small_corpus_tar="${BENCHMARK_CORPORA}/jyrki-full.tar" + local small_corpus_url="https://storage.googleapis.com/artifacts.jpegxl.appspot.com/corpora/jyrki-full.tar" mkdir -p "${BENCHMARK_CORPORA}" - curl --show-error -o "${small_corpus_tar}" -z "${small_corpus_tar}" \ - "https://storage.googleapis.com/artifacts.jpegxl.appspot.com/corpora/jyrki-full.tar" + if [ -f "${small_corpus_tar}" ]; then + curl --show-error -o "${small_corpus_tar}" -z "${small_corpus_tar}" "${small_corpus_url}" + else + curl --show-error -o "${small_corpus_tar}" "${small_corpus_url}" + fi local tmpdir=$(mktemp -d) CLEANUP_FILES+=("${tmpdir}") @@ -831,7 +843,7 @@ cmd_benchmark() { png_filename="${filename%.ppm}.png" png_filename=$(echo "${png_filename}" | tr '/' '_') sem --bg --id "${sem_id}" -j"${nprocs}" -- \ - "${BUILD_DIR}/tools/decode_and_encode" \ + "${TOOLS_DIR}/decode_and_encode" \ "${tmpdir}/${filename}" "${mode}" "${tmpdir}/${png_filename}" images+=( "${png_filename}" ) done < <(cd "${tmpdir}"; ${FIND_BIN} . -name '*.ppm' -type f) @@ -844,6 +856,8 @@ cmd_benchmark() { get_mem_available() { if [[ "${OS}" == "Darwin" ]]; then echo $(vm_stat | grep -F 'Pages free:' | awk '{print $3 * 4}') + elif [[ "${OS}" == MINGW* ]]; then + echo $(vmstat | tail -n 1 | awk '{print $4 * 4}') else echo $(grep -F MemAvailable: /proc/meminfo | awk '{print $2}') fi @@ -856,15 +870,24 @@ run_benchmark() { local output_dir="${BUILD_DIR}/benchmark_results" mkdir -p "${output_dir}" - # The memory available at the beginning of the benchmark run in kB. The number - # of threads depends on the available memory, and the passed memory per - # thread. We also add a 2 GiB of constant memory. - local mem_available="$(get_mem_available)" - # Check that we actually have a MemAvailable value. - [[ -n "${mem_available}" ]] - local num_threads=$(( (${mem_available} - 1048576) / ${mem_per_thread} )) - if [[ ${num_threads} -le 0 ]]; then - num_threads=1 + if [[ "${OS}" == MINGW* ]]; then + src_img_dir=`cygpath -w "${src_img_dir}"` + fi + + local num_threads=1 + if [[ ${BENCHMARK_NUM_THREADS} -gt 0 ]]; then + num_threads=${BENCHMARK_NUM_THREADS} + else + # The memory available at the beginning of the benchmark run in kB. The number + # of threads depends on the available memory, and the passed memory per + # thread. We also add a 2 GiB of constant memory. + local mem_available="$(get_mem_available)" + # Check that we actually have a MemAvailable value. + [[ -n "${mem_available}" ]] + num_threads=$(( (${mem_available} - 1048576) / ${mem_per_thread} )) + if [[ ${num_threads} -le 0 ]]; then + num_threads=1 + fi fi local benchmark_args=( @@ -873,20 +896,20 @@ run_benchmark() { --output_dir "${output_dir}" --show_progress --num_threads="${num_threads}" + --decode_reps=11 + --encode_reps=11 ) if [[ "${STORE_IMAGES}" == "1" ]]; then benchmark_args+=(--save_decompressed --save_compressed) fi ( [[ "${TEST_STACK_LIMIT}" == "none" ]] || ulimit -s "${TEST_STACK_LIMIT}" - "${BUILD_DIR}/tools/benchmark_xl" "${benchmark_args[@]}" | \ + "${TOOLS_DIR}/benchmark_xl" "${benchmark_args[@]}" | \ tee "${output_dir}/results.txt" # Check error code for benckmark_xl command. This will exit if not. return ${PIPESTATUS[0]} ) - - } # Helper function to wait for the CPU temperature to cool down on ARM. @@ -1027,7 +1050,7 @@ cmd_arm_benchmark() { local src_img for src_img in "${jpg_images[@]}" "${images[@]}"; do local src_img_hash=$(sha1sum "${src_img}" | cut -f 1 -d ' ') - local enc_binaries=("${BUILD_DIR}/tools/cjxl") + local enc_binaries=("${TOOLS_DIR}/cjxl") local src_ext="${src_img##*.}" for enc_binary in "${enc_binaries[@]}"; do local enc_binary_base=$(basename "${enc_binary}") @@ -1076,7 +1099,7 @@ cmd_arm_benchmark() { local dec_output wait_for_temp - dec_output=$("${BUILD_DIR}/tools/djxl" "${enc_file}" \ + dec_output=$("${TOOLS_DIR}/djxl" "${enc_file}" \ --num_reps=5 --num_threads="${num_threads}" 2>&1 | tee /dev/stderr | grep -E "M[BP]/s \[") local img_size=$(echo "${dec_output}" | cut -f 1 -d ',') @@ -1092,7 +1115,7 @@ cmd_arm_benchmark() { if [[ "${src_ext}" == "jpg" ]]; then wait_for_temp local dec_file="${BUILD_DIR}/arm_benchmark/${enc_file_hash}.jpg" - dec_output=$("${BUILD_DIR}/tools/djxl" "${enc_file}" \ + dec_output=$("${TOOLS_DIR}/djxl" "${enc_file}" \ "${dec_file}" --num_reps=5 --num_threads="${num_threads}" 2>&1 | \ tee /dev/stderr | grep -E "M[BP]/s \[") local jpeg_dec_mps_speed=$(_speed_from_output "${dec_output}") @@ -1122,12 +1145,12 @@ cmd_fuzz() { local fuzzer_crash_dir=$(realpath "${BUILD_DIR}/fuzzer_crash") mkdir -p "${corpus_dir}" "${fuzzer_crash_dir}" # Generate step. - "${BUILD_DIR}/tools/fuzzer_corpus" "${corpus_dir}" + "${TOOLS_DIR}/fuzzer_corpus" "${corpus_dir}" # Run step: local nprocs=$(nproc --all || echo 1) ( - cd "${BUILD_DIR}" - "tools/djxl_fuzzer" "${fuzzer_crash_dir}" "${corpus_dir}" \ + cd "${TOOLS_DIR}" + djxl_fuzzer "${fuzzer_crash_dir}" "${corpus_dir}" \ -max_total_time="${FUZZER_MAX_TIME}" -jobs=${nprocs} \ -artifact_prefix="${fuzzer_crash_dir}/" ) diff --git a/third_party/jpeg-xl/debian/control b/third_party/jpeg-xl/debian/control index f5dc5ce0cc..e0169a3488 100644 --- a/third_party/jpeg-xl/debian/control +++ b/third_party/jpeg-xl/debian/control @@ -11,7 +11,6 @@ Build-Depends: libgdk-pixbuf-2.0-dev | libgdk-pixbuf2.0-dev, libgif-dev, libgimp2.0-dev, - libgmock-dev, libgoogle-perftools-dev, libgtest-dev, libhwy-dev (>= 1.0.0), diff --git a/third_party/jpeg-xl/deps.sh b/third_party/jpeg-xl/deps.sh index 70b3a15f07..6c51a5cd4a 100755 --- a/third_party/jpeg-xl/deps.sh +++ b/third_party/jpeg-xl/deps.sh @@ -15,7 +15,7 @@ MYDIR=$(dirname $(realpath "$0")) # update a git submodule. TESTDATA="873045a9c42ed60721756e26e2a6b32e17415205" THIRD_PARTY_BROTLI="36533a866ed1ca4b75cf049f4521e4ec5fe24727" -THIRD_PARTY_HIGHWAY="ba0900a4957b929390ab73827235557959234fea" +THIRD_PARTY_HIGHWAY="58b52a717469e62b2d9b8eaa2f5dddb44d4a4cbf" THIRD_PARTY_SKCMS="42030a771244ba67f86b1c1c76a6493f873c5f91" THIRD_PARTY_SJPEG="e5ab13008bb214deb66d5f3e17ca2f8dbff150bf" THIRD_PARTY_ZLIB="51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf" # v1.3.1 diff --git a/third_party/jpeg-xl/examples/CMakeLists.txt b/third_party/jpeg-xl/examples/CMakeLists.txt index aee5fd43ee..8cdb09217e 100644 --- a/third_party/jpeg-xl/examples/CMakeLists.txt +++ b/third_party/jpeg-xl/examples/CMakeLists.txt @@ -11,17 +11,15 @@ project(SAMPLE_LIBJXL LANGUAGES C CXX) # Use pkg-config to find libjxl. find_package(PkgConfig) -pkg_check_modules(Jxl REQUIRED IMPORTED_TARGET libjxl) -pkg_check_modules(JxlCms REQUIRED IMPORTED_TARGET libjxl_cms) -pkg_check_modules(JxlThreads REQUIRED IMPORTED_TARGET libjxl_threads) +pkg_check_modules(Jxl REQUIRED IMPORTED_TARGET libjxl libjxl_cms libjxl_threads) # Build the example encoder/decoder binaries using the default shared libraries # installed. add_executable(decode_oneshot decode_oneshot.cc) -target_link_libraries(decode_oneshot PkgConfig::Jxl PkgConfig::JxlCms PkgConfig::JxlThreads) +target_link_libraries(decode_oneshot PkgConfig::Jxl) add_executable(decode_progressive decode_progressive.cc) -target_link_libraries(decode_progressive PkgConfig::Jxl PkgConfig::JxlCms PkgConfig::JxlThreads) +target_link_libraries(decode_progressive PkgConfig::Jxl) add_executable(encode_oneshot encode_oneshot.cc) -target_link_libraries(encode_oneshot PkgConfig::Jxl PkgConfig::JxlCms PkgConfig::JxlThreads) +target_link_libraries(encode_oneshot PkgConfig::Jxl) diff --git a/third_party/jpeg-xl/examples/decode_exif_metadata.cc b/third_party/jpeg-xl/examples/decode_exif_metadata.cc index 8ec999e4f4..d5f11705bd 100644 --- a/third_party/jpeg-xl/examples/decode_exif_metadata.cc +++ b/third_party/jpeg-xl/examples/decode_exif_metadata.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -55,8 +56,9 @@ bool DecodeJpegXlExif(const uint8_t* jxl, size_t size, return true; } JxlBoxType type; - if (JXL_DEC_SUCCESS != - JxlDecoderGetBoxType(dec.get(), type, support_decompression)) { + status = JxlDecoderGetBoxType(dec.get(), type, + TO_JXL_BOOL(support_decompression)); + if (JXL_DEC_SUCCESS != status) { fprintf(stderr, "Error, failed to get box type\n"); return false; } diff --git a/third_party/jpeg-xl/examples/decode_oneshot.cc b/third_party/jpeg-xl/examples/decode_oneshot.cc index f8d21710bf..a24bd73bfb 100644 --- a/third_party/jpeg-xl/examples/decode_oneshot.cc +++ b/third_party/jpeg-xl/examples/decode_oneshot.cc @@ -7,11 +7,6 @@ // available at once). The example outputs the pixels and color information to a // floating point image and an ICC profile on disk. -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif - -#include #include #include #include @@ -102,13 +97,13 @@ bool DecodeJpegXlOneShot(const uint8_t* jxl, size_t size, return false; } if (buffer_size != *xsize * *ysize * 16) { - fprintf(stderr, "Invalid out buffer size %" PRIu64 " %" PRIu64 "\n", - static_cast(buffer_size), - static_cast(*xsize * *ysize * 16)); + fprintf(stderr, "Invalid out buffer size %d %d\n", + static_cast(buffer_size), + static_cast(*xsize * *ysize * 16)); return false; } pixels->resize(*xsize * *ysize * 4); - void* pixels_buffer = (void*)pixels->data(); + void* pixels_buffer = static_cast(pixels->data()); size_t pixels_buffer_size = pixels->size() * sizeof(float); if (JXL_DEC_SUCCESS != JxlDecoderSetImageOutBuffer(dec.get(), &format, pixels_buffer, @@ -147,8 +142,8 @@ bool WritePFM(const char* filename, const float* pixels, size_t xsize, uint8_t little_endian[4]; memcpy(little_endian, &endian_test, 4); - fprintf(file, "PF\n%d %d\n%s\n", (int)xsize, (int)ysize, - little_endian[0] ? "-1.0" : "1.0"); + fprintf(file, "PF\n%d %d\n%s\n", static_cast(xsize), + static_cast(ysize), little_endian[0] ? "-1.0" : "1.0"); for (int y = ysize - 1; y >= 0; y--) { for (size_t x = 0; x < xsize; x++) { for (size_t c = 0; c < 3; c++) { @@ -233,7 +228,8 @@ int main(int argc, char* argv[]) { std::vector pixels; std::vector icc_profile; - size_t xsize = 0, ysize = 0; + size_t xsize = 0; + size_t ysize = 0; if (!DecodeJpegXlOneShot(jxl.data(), jxl.size(), &pixels, &xsize, &ysize, &icc_profile)) { fprintf(stderr, "Error while decoding the jxl file\n"); diff --git a/third_party/jpeg-xl/examples/decode_progressive.cc b/third_party/jpeg-xl/examples/decode_progressive.cc index a094cbeb4f..fa7f3df663 100644 --- a/third_party/jpeg-xl/examples/decode_progressive.cc +++ b/third_party/jpeg-xl/examples/decode_progressive.cc @@ -6,10 +6,6 @@ // This C++ example decodes a JPEG XL image progressively (input bytes are // passed in chunks). The example outputs the intermediate steps to PAM files. -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif - #include #include #include @@ -29,10 +25,9 @@ bool WritePAM(const char* filename, const uint8_t* buffer, size_t w, size_t h) { return false; } fprintf(fp, - "P7\nWIDTH %" PRIu64 "\nHEIGHT %" PRIu64 - "\nDEPTH 4\nMAXVAL 255\nTUPLTYPE " + "P7\nWIDTH %d\nHEIGHT %d\nDEPTH 4\nMAXVAL 255\nTUPLTYPE " "RGB_ALPHA\nENDHDR\n", - static_cast(w), static_cast(h)); + static_cast(w), static_cast(h)); size_t num_bytes = w * h * 4; if (fwrite(buffer, 1, num_bytes, fp) != num_bytes) { fclose(fp); @@ -51,7 +46,8 @@ bool DecodeJpegXlProgressive(const uint8_t* jxl, size_t size, const char* filename, size_t chunksize) { std::vector pixels; std::vector icc_profile; - size_t xsize = 0, ysize = 0; + size_t xsize = 0; + size_t ysize = 0; // Multi-threaded parallel runner. auto runner = JxlResizableParallelRunnerMake(nullptr); diff --git a/third_party/jpeg-xl/examples/encode_oneshot.cc b/third_party/jpeg-xl/examples/encode_oneshot.cc index 336446ff17..1582570432 100644 --- a/third_party/jpeg-xl/examples/encode_oneshot.cc +++ b/third_party/jpeg-xl/examples/encode_oneshot.cc @@ -39,8 +39,9 @@ bool ReadPFM(const char* filename, std::vector* pixels, uint32_t* xsize, return false; } uint32_t endian_test = 1; - uint8_t little_endian[4]; - memcpy(little_endian, &endian_test, 4); + uint8_t little_endian_check[4]; + memcpy(little_endian_check, &endian_test, 4); + bool little_endian = (little_endian_check[0] == 1); if (fseek(file, 0, SEEK_END) != 0) { fclose(file); @@ -63,7 +64,7 @@ bool ReadPFM(const char* filename, std::vector* pixels, uint32_t* xsize, data.resize(size); size_t readsize = fread(data.data(), 1, size, file); - if ((long)readsize != size) { + if (static_cast(readsize) != size) { fclose(file); return false; } @@ -116,12 +117,13 @@ bool ReadPFM(const char* filename, std::vector* pixels, uint32_t* xsize, fprintf(stderr, "%s doesn't seem to be a Portable FloatMap file (pixel data bytes " "are %d, but expected %d * %d * 3 * 4 + %d (%d).\n", - filename, (int)data.size(), (int)*ysize, (int)*xsize, (int)offset, - (int)(*ysize * *xsize * 3 * 4 + offset)); + filename, static_cast(data.size()), static_cast(*ysize), + static_cast(*xsize), static_cast(offset), + static_cast(*ysize * *xsize * 3 * 4 + offset)); return false; } - if (!!little_endian[0] != input_little_endian) { + if (little_endian != input_little_endian) { fprintf(stderr, "%s has a different endianness than we do, conversion is not " "supported.\n", @@ -132,7 +134,7 @@ bool ReadPFM(const char* filename, std::vector* pixels, uint32_t* xsize, pixels->resize(*ysize * *xsize * 3); for (int y = *ysize - 1; y >= 0; y--) { - for (int x = 0; x < (int)*xsize; x++) { + for (int x = 0; x < static_cast(*xsize); x++) { for (int c = 0; c < 3; c++) { memcpy(pixels->data() + (y * *xsize + x) * 3 + c, data.data() + offset, sizeof(float)); @@ -180,8 +182,8 @@ bool EncodeJxlOneshot(const std::vector& pixels, const uint32_t xsize, } JxlColorEncoding color_encoding = {}; - JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JXL_BOOL is_gray = TO_JXL_BOOL(pixel_format.num_channels < 3); + JxlColorEncodingSetToSRGB(&color_encoding, is_gray); if (JXL_ENC_SUCCESS != JxlEncoderSetColorEncoding(enc.get(), &color_encoding)) { fprintf(stderr, "JxlEncoderSetColorEncoding failed\n"); @@ -193,7 +195,7 @@ bool EncodeJxlOneshot(const std::vector& pixels, const uint32_t xsize, if (JXL_ENC_SUCCESS != JxlEncoderAddImageFrame(frame_settings, &pixel_format, - (void*)pixels.data(), + static_cast(pixels.data()), sizeof(float) * pixels.size())) { fprintf(stderr, "JxlEncoderAddImageFrame failed\n"); return false; diff --git a/third_party/jpeg-xl/flake.nix b/third_party/jpeg-xl/flake.nix index 4832f5b144..64a36311ab 100644 --- a/third_party/jpeg-xl/flake.nix +++ b/third_party/jpeg-xl/flake.nix @@ -19,7 +19,6 @@ cmake pkg-config gtest - gmock doxygen graphviz python3 diff --git a/third_party/jpeg-xl/lib/BUILD b/third_party/jpeg-xl/lib/BUILD index 39e61de0eb..d93858f22d 100644 --- a/third_party/jpeg-xl/lib/BUILD +++ b/third_party/jpeg-xl/lib/BUILD @@ -23,8 +23,8 @@ load( "libjxl_enc_sources", "libjxl_extras_for_tools_sources", "libjxl_extras_sources", - #'libjxl_gbench_sources', - "libjxl_jpegli_lib_version", + # "libjxl_gbench_sources", + # "libjxl_jpegli_lib_version", "libjxl_jpegli_libjpeg_helper_files", "libjxl_jpegli_sources", "libjxl_jpegli_testlib_files", @@ -51,13 +51,14 @@ load( "libjxl_deps_png", "libjxl_deps_runfiles", "libjxl_deps_skcms", - "libjxl_deps_testdata", + # "libjxl_deps_testdata", + # "libjxl_deps_webp", "libjxl_root_package", "libjxl_test_shards", "libjxl_test_timeouts", ) -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +load("@bazel_skylib//rules:expand_template.bzl", "expand_template") DEFAULT_VISIBILITY = ["//:__subpackages__"] @@ -66,7 +67,7 @@ DEFAULT_COMPATIBILITY = [] INCLUDES_DIR = "include" package( - default_visibility = ["//:__subpackages__"], + default_visibility = DEFAULT_VISIBILITY, ) licenses(["notice"]) diff --git a/third_party/jpeg-xl/lib/CMakeLists.txt b/third_party/jpeg-xl/lib/CMakeLists.txt index 938f15dcbb..1e6f4abf74 100644 --- a/third_party/jpeg-xl/lib/CMakeLists.txt +++ b/third_party/jpeg-xl/lib/CMakeLists.txt @@ -149,6 +149,16 @@ else() set(PKGCONFIG_TARGET_LIBS "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") endif() +include(CheckCXXSymbolExists) +set(PKGCONFIG_CXX_LIB "") +check_cxx_symbol_exists(__GLIBCXX__ iostream LIBSTDCXX) +check_cxx_symbol_exists(_LIBCPP_VERSION iostream LIBCXX) +if(LIBSTDCXX) + set(PKGCONFIG_CXX_LIB "-lstdc++") +elseif(LIBCXX) + set(PKGCONFIG_CXX_LIB "-lc++") +endif() + # The jxl_cms library definition. include(jxl_cms.cmake) # The jxl library definition. diff --git a/third_party/jpeg-xl/lib/extras/alpha_blend.cc b/third_party/jpeg-xl/lib/extras/alpha_blend.cc index 50c141c6fb..afb37b0a7d 100644 --- a/third_party/jpeg-xl/lib/extras/alpha_blend.cc +++ b/third_party/jpeg-xl/lib/extras/alpha_blend.cc @@ -12,7 +12,7 @@ namespace extras { namespace { -void AlphaBlend(PackedFrame* frame, float background[3]) { +void AlphaBlend(PackedFrame* frame, const float background[3]) { if (!frame) return; const PackedImage& im = frame->color; JxlPixelFormat format = im.format; @@ -20,7 +20,8 @@ void AlphaBlend(PackedFrame* frame, float background[3]) { return; } --format.num_channels; - PackedImage blended(im.xsize, im.ysize, format); + JXL_ASSIGN_OR_DIE(PackedImage blended, + PackedImage::Create(im.xsize, im.ysize, format)); // TODO(szabadka) SIMDify this and make it work for float16. for (size_t y = 0; y < im.ysize; ++y) { for (size_t x = 0; x < im.xsize; ++x) { @@ -48,7 +49,7 @@ void AlphaBlend(PackedFrame* frame, float background[3]) { } // namespace -void AlphaBlend(PackedPixelFile* ppf, float background[3]) { +void AlphaBlend(PackedPixelFile* ppf, const float background[3]) { if (!ppf || ppf->info.alpha_bits == 0) { return; } diff --git a/third_party/jpeg-xl/lib/extras/alpha_blend.h b/third_party/jpeg-xl/lib/extras/alpha_blend.h index 4d78e8681b..e49349393c 100644 --- a/third_party/jpeg-xl/lib/extras/alpha_blend.h +++ b/third_party/jpeg-xl/lib/extras/alpha_blend.h @@ -11,7 +11,7 @@ namespace jxl { namespace extras { -void AlphaBlend(PackedPixelFile* ppf, float background[3]); +void AlphaBlend(PackedPixelFile* ppf, const float background[3]); } // namespace extras } // namespace jxl diff --git a/third_party/jpeg-xl/lib/extras/codec.h b/third_party/jpeg-xl/lib/extras/codec.h index b7bc2a397e..9fd61503cb 100644 --- a/third_party/jpeg-xl/lib/extras/codec.h +++ b/third_party/jpeg-xl/lib/extras/codec.h @@ -43,7 +43,7 @@ JXL_INLINE Status SetFromBytes(const Span bytes, CodecInOut* io, orig_codec); } -Status Encode(const extras::PackedPixelFile& ppf, const extras::Codec codec, +Status Encode(const extras::PackedPixelFile& ppf, extras::Codec codec, std::vector* bytes, ThreadPool* pool); Status Encode(const extras::PackedPixelFile& ppf, const std::string& pathname, diff --git a/third_party/jpeg-xl/lib/extras/codec_test.cc b/third_party/jpeg-xl/lib/extras/codec_test.cc index 4d8a60cb33..50d5e37bc9 100644 --- a/third_party/jpeg-xl/lib/extras/codec_test.cc +++ b/third_party/jpeg-xl/lib/extras/codec_test.cc @@ -40,12 +40,6 @@ using test::ThreadPoolForTests; namespace extras { namespace { -using ::testing::AllOf; -using ::testing::Contains; -using ::testing::Field; -using ::testing::IsEmpty; -using ::testing::SizeIs; - std::string ExtensionFromCodec(Codec codec, const bool is_gray, const bool has_alpha, const size_t bits_per_sample) { @@ -78,8 +72,8 @@ void VerifySameImage(const PackedImage& im0, size_t bits_per_sample0, }; double factor0 = get_factor(im0.format, bits_per_sample0); double factor1 = get_factor(im1.format, bits_per_sample1); - auto pixels0 = static_cast(im0.pixels()); - auto pixels1 = static_cast(im1.pixels()); + const auto* pixels0 = static_cast(im0.pixels()); + const auto* pixels1 = static_cast(im1.pixels()); auto rgba0 = test::ConvertToRGBA32(pixels0, im0.xsize, im0.ysize, im0.format, factor0); auto rgba1 = @@ -227,19 +221,23 @@ void CreateTestImage(const TestImageParams& params, PackedPixelFile* ppf) { ppf->info.exponent_bits_per_sample = params.bits_per_sample == 32 ? 8 : 0; ppf->info.num_color_channels = params.is_gray ? 1 : 3; ppf->info.alpha_bits = params.add_alpha ? params.bits_per_sample : 0; - ppf->info.alpha_premultiplied = (params.codec == Codec::kEXR); + ppf->info.alpha_premultiplied = TO_JXL_BOOL(params.codec == Codec::kEXR); JxlColorEncoding color_encoding = CreateTestColorEncoding(params.is_gray); ppf->icc = GenerateICC(color_encoding); ppf->color_encoding = color_encoding; - PackedFrame frame(params.xsize, params.ysize, params.PixelFormat()); + JXL_ASSIGN_OR_DIE( + PackedFrame frame, + PackedFrame::Create(params.xsize, params.ysize, params.PixelFormat())); FillPackedImage(params.bits_per_sample, &frame.color); if (params.add_extra_channels) { for (size_t i = 0; i < 7; ++i) { JxlPixelFormat ec_format = params.PixelFormat(); ec_format.num_channels = 1; - PackedImage ec(params.xsize, params.ysize, ec_format); + JXL_ASSIGN_OR_DIE( + PackedImage ec, + PackedImage::Create(params.xsize, params.ysize, ec_format)); FillPackedImage(params.bits_per_sample, &ec); frame.extra_channels.emplace_back(std::move(ec)); PackedExtraChannel pec; @@ -432,15 +430,17 @@ TEST(CodecTest, EncodeToPNG) { ASSERT_TRUE(extras::DecodeBytes(Bytes(original_png), ColorHints(), &ppf)); const JxlPixelFormat& format = ppf.frames.front().color.format; - ASSERT_THAT( - png_encoder->AcceptedFormats(), - Contains(AllOf(Field(&JxlPixelFormat::num_channels, format.num_channels), - Field(&JxlPixelFormat::data_type, format.data_type), - Field(&JxlPixelFormat::endianness, format.endianness)))); + const auto& format_matcher = [&format](const JxlPixelFormat& candidate) { + return (candidate.num_channels == format.num_channels) && + (candidate.data_type == format.data_type) && + (candidate.endianness == format.endianness); + }; + const auto formats = png_encoder->AcceptedFormats(); + ASSERT_TRUE(std::any_of(formats.begin(), formats.end(), format_matcher)); EncodedImage encoded_png; ASSERT_TRUE(png_encoder->Encode(ppf, &encoded_png, pool)); - EXPECT_THAT(encoded_png.icc, IsEmpty()); - ASSERT_THAT(encoded_png.bitstreams, SizeIs(1)); + EXPECT_TRUE(encoded_png.icc.empty()); + ASSERT_EQ(encoded_png.bitstreams.size(), 1); PackedPixelFile decoded_ppf; ASSERT_TRUE(extras::DecodeBytes(Bytes(encoded_png.bitstreams.front()), diff --git a/third_party/jpeg-xl/lib/extras/dec/apng.cc b/third_party/jpeg-xl/lib/extras/dec/apng.cc index f77dab77d1..8b0da06eb1 100644 --- a/third_party/jpeg-xl/lib/extras/dec/apng.cc +++ b/third_party/jpeg-xl/lib/extras/dec/apng.cc @@ -71,9 +71,7 @@ const png_byte kIgnoredPngChunks[] = { }; // Returns floating-point value from the PNG encoding (times 10^5). -static double F64FromU32(const uint32_t x) { - return static_cast(x) * 1E-5; -} +double F64FromU32(const uint32_t x) { return static_cast(x) * 1E-5; } Status DecodeSRGB(const unsigned char* payload, const size_t payload_size, JxlColorEncoding* color_encoding) { @@ -402,7 +400,8 @@ class BlobsReaderPNG { } if (pos + 2 >= encoded_end) return false; // Truncated base16 2; - uint32_t nibble0, nibble1; + uint32_t nibble0; + uint32_t nibble1; JXL_RETURN_IF_ERROR(DecodeNibble(pos[0], &nibble0)); JXL_RETURN_IF_ERROR(DecodeNibble(pos[1], &nibble1)); bytes->push_back(static_cast((nibble0 << 4) + nibble1)); @@ -432,9 +431,22 @@ constexpr uint32_t kId_cHRM = 0x4D524863; constexpr uint32_t kId_eXIf = 0x66495865; struct APNGFrame { - std::vector pixels; + APNGFrame() : pixels(nullptr, free) {} + std::unique_ptr pixels; + size_t pixels_size = 0; std::vector rows; unsigned int w, h, delay_num, delay_den; + Status Resize(size_t new_size) { + if (new_size > pixels_size) { + pixels.reset(malloc(new_size)); + if (!pixels.get()) { + // TODO(szabadka): use specialized OOM error code + return JXL_FAILURE("Failed to allocate memory for image buffer"); + } + pixels_size = new_size; + } + return true; + } }; struct Reader { @@ -447,7 +459,7 @@ struct Reader { next += to_copy; return (len == to_copy); } - bool Eof() { return next == last; } + bool Eof() const { return next == last; } }; const unsigned long cMaxPNGSize = 1000000UL; @@ -463,10 +475,11 @@ void info_fn(png_structp png_ptr, png_infop info_ptr) { void row_fn(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass) { - APNGFrame* frame = (APNGFrame*)png_get_progressive_ptr(png_ptr); + APNGFrame* frame = + reinterpret_cast(png_get_progressive_ptr(png_ptr)); JXL_CHECK(frame); JXL_CHECK(row_num < frame->rows.size()); - JXL_CHECK(frame->rows[row_num] < frame->pixels.data() + frame->pixels.size()); + JXL_CHECK(frame->rows[row_num] < frame->rows[0] + frame->pixels_size); png_progressive_combine_row(png_ptr, frame->rows[row_num], new_row); } @@ -494,12 +507,13 @@ int processing_start(png_structp& png_ptr, png_infop& info_ptr, void* frame_ptr, unsigned char header[8] = {137, 80, 78, 71, 13, 10, 26, 10}; // Cleanup prior decoder, if any. - png_destroy_read_struct(&png_ptr, &info_ptr, 0); + png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); // Just in case. Not all versions on libpng wipe-out the pointers. png_ptr = nullptr; info_ptr = nullptr; - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png_ptr = + png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); info_ptr = png_create_info_struct(png_ptr); if (!png_ptr || !info_ptr) return 1; @@ -508,18 +522,17 @@ int processing_start(png_structp& png_ptr, png_infop& info_ptr, void* frame_ptr, } png_set_keep_unknown_chunks(png_ptr, 1, kIgnoredPngChunks, - (int)sizeof(kIgnoredPngChunks) / 5); + static_cast(sizeof(kIgnoredPngChunks) / 5)); png_set_crc_action(png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); - png_set_progressive_read_fn(png_ptr, frame_ptr, info_fn, row_fn, NULL); + png_set_progressive_read_fn(png_ptr, frame_ptr, info_fn, row_fn, nullptr); png_process_data(png_ptr, info_ptr, header, 8); png_process_data(png_ptr, info_ptr, chunkIHDR.data(), chunkIHDR.size()); if (hasInfo) { - for (unsigned int i = 0; i < chunksInfo.size(); i++) { - png_process_data(png_ptr, info_ptr, chunksInfo[i].data(), - chunksInfo[i].size()); + for (auto& chunk : chunksInfo) { + png_process_data(png_ptr, info_ptr, chunk.data(), chunk.size()); } } return 0; @@ -575,8 +588,6 @@ Status DecodeImageAPNG(const Span bytes, const SizeConstraints* constraints) { #if JPEGXL_ENABLE_APNG Reader r; - unsigned int id, j, w, h, w0, h0, x0, y0; - unsigned int delay_num, delay_den, dop, bop, rowbytes, imagesize; unsigned char sig[8]; png_structp png_ptr = nullptr; png_infop info_ptr = nullptr; @@ -588,7 +599,7 @@ Status DecodeImageAPNG(const Span bytes, bool seenFctl = false; APNGFrame frameRaw = {}; uint32_t num_channels; - JxlPixelFormat format; + JxlPixelFormat format = {}; unsigned int bytes_per_pixel = 0; struct FrameInfo { @@ -604,7 +615,7 @@ Status DecodeImageAPNG(const Span bytes, // Make sure png memory is released in any case. auto scope_guard = MakeScopeGuard([&]() { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); + png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); // Just in case. Not all versions on libpng wipe-out the pointers. png_ptr = nullptr; info_ptr = nullptr; @@ -616,7 +627,7 @@ Status DecodeImageAPNG(const Span bytes, if (!r.Read(sig, 8) || memcmp(sig, png_signature, 8) != 0) { return false; } - id = read_chunk(&r, &chunkIHDR); + unsigned int id = read_chunk(&r, &chunkIHDR); ppf->info.exponent_bits_per_sample = 0; ppf->info.alpha_exponent_bits = 0; @@ -625,18 +636,22 @@ Status DecodeImageAPNG(const Span bytes, ppf->frames.clear(); bool have_color = false; - bool have_cicp = false, have_iccp = false, have_srgb = false; + bool have_cicp = false; + bool have_iccp = false; + bool have_srgb = false; bool errorstate = true; if (id == kId_IHDR && chunkIHDR.size() == 25) { - x0 = 0; - y0 = 0; - delay_num = 1; - delay_den = 10; - dop = 0; - bop = 0; - - w0 = w = png_get_uint_32(chunkIHDR.data() + 8); - h0 = h = png_get_uint_32(chunkIHDR.data() + 12); + unsigned int x0 = 0; + unsigned int y0 = 0; + unsigned int delay_num = 1; + unsigned int delay_den = 10; + unsigned int dop = 0; + unsigned int bop = 0; + + unsigned int w = png_get_uint_32(chunkIHDR.data() + 8); + unsigned int h = png_get_uint_32(chunkIHDR.data() + 12); + unsigned int w0 = w; + unsigned int h0 = h; if (w > cMaxPNGSize || h > cMaxPNGSize) { return false; } @@ -648,8 +663,8 @@ Status DecodeImageAPNG(const Span bytes, ppf->color_encoding.transfer_function = JXL_TRANSFER_FUNCTION_SRGB; ppf->color_encoding.rendering_intent = JXL_RENDERING_INTENT_RELATIVE; - if (!processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo, - chunkIHDR, chunksInfo)) { + if (!processing_start(png_ptr, info_ptr, static_cast(&frameRaw), + hasInfo, chunkIHDR, chunksInfo)) { while (!r.Eof()) { id = read_chunk(&r, &chunk); if (!id) break; @@ -657,7 +672,7 @@ Status DecodeImageAPNG(const Span bytes, if (id == kId_acTL && !hasInfo && !isAnimated) { isAnimated = true; - ppf->info.have_animation = true; + ppf->info.have_animation = JXL_TRUE; ppf->info.animation.tps_numerator = 1000; ppf->info.animation.tps_denominator = 1; } else if (id == kId_IEND || @@ -666,8 +681,10 @@ Status DecodeImageAPNG(const Span bytes, if (!processing_finish(png_ptr, info_ptr, &ppf->metadata)) { // Allocates the frame buffer. uint32_t duration = delay_num * 1000 / delay_den; - frames.push_back(FrameInfo{PackedImage(w0, h0, format), duration, - x0, w0, y0, h0, dop, bop}); + JXL_ASSIGN_OR_RETURN(PackedImage image, + PackedImage::Create(w0, h0, format)); + frames.push_back(FrameInfo{std::move(image), duration, x0, w0, y0, + h0, dop, bop}); auto& frame = frames.back().data; for (size_t y = 0; y < h0; ++y) { memcpy(static_cast(frame.pixels()) + frame.stride * y, @@ -707,7 +724,8 @@ Status DecodeImageAPNG(const Span bytes, if (hasInfo) { memcpy(chunkIHDR.data() + 8, chunk.data() + 12, 8); - if (processing_start(png_ptr, info_ptr, (void*)&frameRaw, hasInfo, + if (processing_start(png_ptr, info_ptr, + static_cast(&frameRaw), hasInfo, chunkIHDR, chunksInfo)) { break; } @@ -724,7 +742,7 @@ Status DecodeImageAPNG(const Span bytes, int colortype = png_get_color_type(png_ptr, info_ptr); int png_bit_depth = png_get_bit_depth(png_ptr, info_ptr); ppf->info.bits_per_sample = png_bit_depth; - png_color_8p sigbits = NULL; + png_color_8p sigbits = nullptr; png_get_sBIT(png_ptr, info_ptr, &sigbits); if (colortype & 1) { // palette will actually be 8-bit regardless of the index bitdepth @@ -784,12 +802,18 @@ Status DecodeImageAPNG(const Span bytes, } bytes_per_pixel = num_channels * (format.data_type == JXL_TYPE_UINT16 ? 2 : 1); - rowbytes = w * bytes_per_pixel; - imagesize = h * rowbytes; - frameRaw.pixels.resize(imagesize); + size_t rowbytes = w * bytes_per_pixel; + if (h > std::numeric_limits::max() / rowbytes) { + return JXL_FAILURE("Image too big."); + } + size_t imagesize = h * rowbytes; + JXL_RETURN_IF_ERROR(frameRaw.Resize(imagesize)); frameRaw.rows.resize(h); - for (j = 0; j < h; j++) - frameRaw.rows[j] = frameRaw.pixels.data() + j * rowbytes; + for (size_t j = 0; j < h; j++) { + frameRaw.rows[j] = + reinterpret_cast(frameRaw.pixels.get()) + + j * rowbytes; + } if (processing_data(png_ptr, info_ptr, chunk.data(), chunk.size())) { break; @@ -813,6 +837,8 @@ Status DecodeImageAPNG(const Span bytes, have_cicp = true; have_color = true; ppf->icc.clear(); + ppf->primary_color_representation = + PackedPixelFile::kColorEncodingIsPrimary; } } else if (!have_cicp && id == kId_iCCP) { if (processing_data(png_ptr, info_ptr, chunk.data(), chunk.size())) { @@ -830,6 +856,7 @@ Status DecodeImageAPNG(const Span bytes, &profile, &proflen); if (ok && proflen) { ppf->icc.assign(profile, profile + proflen); + ppf->primary_color_representation = PackedPixelFile::kIccIsPrimary; have_color = true; have_iccp = true; } else { @@ -922,7 +949,8 @@ Status DecodeImageAPNG(const Span bytes, py0 + pys >= y0 + ysize && use_for_next_frame) { // If the new frame is contained within the old frame, we can pad the // new frame with zeros and not blend. - PackedImage new_data(pxs, pys, frame.data.format); + JXL_ASSIGN_OR_RETURN(PackedImage new_data, + PackedImage::Create(pxs, pys, frame.data.format)); memset(new_data.pixels(), 0, new_data.pixels_size); for (size_t y = 0; y < ysize; y++) { size_t bytes_per_pixel = @@ -944,7 +972,8 @@ Status DecodeImageAPNG(const Span bytes, ppf->frames.emplace_back(std::move(new_data)); } else { // If all else fails, insert a placeholder blank frame with kReplace. - PackedImage blank(pxs, pys, frame.data.format); + JXL_ASSIGN_OR_RETURN(PackedImage blank, + PackedImage::Create(pxs, pys, frame.data.format)); memset(blank.pixels(), 0, blank.pixels_size); ppf->frames.emplace_back(std::move(blank)); auto& pframe = ppf->frames.back(); @@ -984,7 +1013,7 @@ Status DecodeImageAPNG(const Span bytes, has_nontrivial_background && frame.dispose_op == DISPOSE_OP_BACKGROUND; } if (ppf->frames.empty()) return JXL_FAILURE("No frames decoded"); - ppf->frames.back().frame_info.is_last = true; + ppf->frames.back().frame_info.is_last = JXL_TRUE; return true; #else diff --git a/third_party/jpeg-xl/lib/extras/dec/color_description.cc b/third_party/jpeg-xl/lib/extras/dec/color_description.cc index 54f6aa4206..bf229632d0 100644 --- a/third_party/jpeg-xl/lib/extras/dec/color_description.cc +++ b/third_party/jpeg-xl/lib/extras/dec/color_description.cc @@ -9,6 +9,8 @@ #include +#include "lib/jxl/base/common.h" + namespace jxl { namespace { @@ -19,49 +21,46 @@ struct EnumName { T value; }; -const EnumName kJxlColorSpaceNames[] = { - {"RGB", JXL_COLOR_SPACE_RGB}, - {"Gra", JXL_COLOR_SPACE_GRAY}, - {"XYB", JXL_COLOR_SPACE_XYB}, - {"CS?", JXL_COLOR_SPACE_UNKNOWN}, -}; - -const EnumName kJxlWhitePointNames[] = { - {"D65", JXL_WHITE_POINT_D65}, - {"Cst", JXL_WHITE_POINT_CUSTOM}, - {"EER", JXL_WHITE_POINT_E}, - {"DCI", JXL_WHITE_POINT_DCI}, -}; - -const EnumName kJxlPrimariesNames[] = { - {"SRG", JXL_PRIMARIES_SRGB}, - {"Cst", JXL_PRIMARIES_CUSTOM}, - {"202", JXL_PRIMARIES_2100}, - {"DCI", JXL_PRIMARIES_P3}, -}; - -const EnumName kJxlTransferFunctionNames[] = { - {"709", JXL_TRANSFER_FUNCTION_709}, - {"TF?", JXL_TRANSFER_FUNCTION_UNKNOWN}, - {"Lin", JXL_TRANSFER_FUNCTION_LINEAR}, - {"SRG", JXL_TRANSFER_FUNCTION_SRGB}, - {"PeQ", JXL_TRANSFER_FUNCTION_PQ}, - {"DCI", JXL_TRANSFER_FUNCTION_DCI}, - {"HLG", JXL_TRANSFER_FUNCTION_HLG}, - {"", JXL_TRANSFER_FUNCTION_GAMMA}, -}; - -const EnumName kJxlRenderingIntentNames[] = { - {"Per", JXL_RENDERING_INTENT_PERCEPTUAL}, - {"Rel", JXL_RENDERING_INTENT_RELATIVE}, - {"Sat", JXL_RENDERING_INTENT_SATURATION}, - {"Abs", JXL_RENDERING_INTENT_ABSOLUTE}, -}; - -template -Status ParseEnum(const std::string& token, const EnumName* enum_values, - size_t enum_len, T* value) { - for (size_t i = 0; i < enum_len; i++) { +constexpr auto kJxlColorSpaceNames = + to_array>({{"RGB", JXL_COLOR_SPACE_RGB}, + {"Gra", JXL_COLOR_SPACE_GRAY}, + {"XYB", JXL_COLOR_SPACE_XYB}, + {"CS?", JXL_COLOR_SPACE_UNKNOWN}}); + +constexpr auto kJxlWhitePointNames = + to_array>({{"D65", JXL_WHITE_POINT_D65}, + {"Cst", JXL_WHITE_POINT_CUSTOM}, + {"EER", JXL_WHITE_POINT_E}, + {"DCI", JXL_WHITE_POINT_DCI}}); + +constexpr auto kJxlPrimariesNames = + to_array>({{"SRG", JXL_PRIMARIES_SRGB}, + {"Cst", JXL_PRIMARIES_CUSTOM}, + {"202", JXL_PRIMARIES_2100}, + {"DCI", JXL_PRIMARIES_P3}}); + +constexpr auto kJxlTransferFunctionNames = + to_array>( + {{"709", JXL_TRANSFER_FUNCTION_709}, + {"TF?", JXL_TRANSFER_FUNCTION_UNKNOWN}, + {"Lin", JXL_TRANSFER_FUNCTION_LINEAR}, + {"SRG", JXL_TRANSFER_FUNCTION_SRGB}, + {"PeQ", JXL_TRANSFER_FUNCTION_PQ}, + {"DCI", JXL_TRANSFER_FUNCTION_DCI}, + {"HLG", JXL_TRANSFER_FUNCTION_HLG}, + {"", JXL_TRANSFER_FUNCTION_GAMMA}}); + +constexpr auto kJxlRenderingIntentNames = + to_array>( + {{"Per", JXL_RENDERING_INTENT_PERCEPTUAL}, + {"Rel", JXL_RENDERING_INTENT_RELATIVE}, + {"Sat", JXL_RENDERING_INTENT_SATURATION}, + {"Abs", JXL_RENDERING_INTENT_ABSOLUTE}}); + +template +Status ParseEnum(const std::string& token, + const std::array, N>& enum_values, T* value) { + for (size_t i = 0; i < enum_values.size(); i++) { if (enum_values[i].name == token) { *value = enum_values[i].value; return true; @@ -69,9 +68,6 @@ Status ParseEnum(const std::string& token, const EnumName* enum_values, } return false; } -#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) -#define PARSE_ENUM(type, token, value) \ - ParseEnum(token, k##type##Names, ARRAY_SIZE(k##type##Names), value) class Tokenizer { public: @@ -122,7 +118,7 @@ Status ParseColorSpace(Tokenizer* tokenizer, JxlColorEncoding* c) { std::string str; JXL_RETURN_IF_ERROR(tokenizer->Next(&str)); JxlColorSpace cs; - if (PARSE_ENUM(JxlColorSpace, str, &cs)) { + if (ParseEnum(str, kJxlColorSpaceNames, &cs)) { c->color_space = cs; return true; } @@ -139,7 +135,7 @@ Status ParseWhitePoint(Tokenizer* tokenizer, JxlColorEncoding* c) { std::string str; JXL_RETURN_IF_ERROR(tokenizer->Next(&str)); - if (PARSE_ENUM(JxlWhitePoint, str, &c->white_point)) return true; + if (ParseEnum(str, kJxlWhitePointNames, &c->white_point)) return true; Tokenizer xy_tokenizer(&str, ';'); c->white_point = JXL_WHITE_POINT_CUSTOM; @@ -157,7 +153,7 @@ Status ParsePrimaries(Tokenizer* tokenizer, JxlColorEncoding* c) { std::string str; JXL_RETURN_IF_ERROR(tokenizer->Next(&str)); - if (PARSE_ENUM(JxlPrimaries, str, &c->primaries)) return true; + if (ParseEnum(str, kJxlPrimariesNames, &c->primaries)) return true; Tokenizer xy_tokenizer(&str, ';'); JXL_RETURN_IF_ERROR(ParseDouble(&xy_tokenizer, c->primaries_red_xy + 0)); @@ -174,7 +170,8 @@ Status ParsePrimaries(Tokenizer* tokenizer, JxlColorEncoding* c) { Status ParseRenderingIntent(Tokenizer* tokenizer, JxlColorEncoding* c) { std::string str; JXL_RETURN_IF_ERROR(tokenizer->Next(&str)); - if (PARSE_ENUM(JxlRenderingIntent, str, &c->rendering_intent)) return true; + if (ParseEnum(str, kJxlRenderingIntentNames, &c->rendering_intent)) + return true; return JXL_FAILURE("Invalid RenderingIntent %s\n", str.c_str()); } @@ -189,7 +186,7 @@ Status ParseTransferFunction(Tokenizer* tokenizer, JxlColorEncoding* c) { std::string str; JXL_RETURN_IF_ERROR(tokenizer->Next(&str)); - if (PARSE_ENUM(JxlTransferFunction, str, &c->transfer_function)) { + if (ParseEnum(str, kJxlTransferFunctionNames, &c->transfer_function)) { return true; } diff --git a/third_party/jpeg-xl/lib/extras/dec/color_hints.cc b/third_party/jpeg-xl/lib/extras/dec/color_hints.cc index 5c6d7b84a0..b1edd9f6ea 100644 --- a/third_party/jpeg-xl/lib/extras/dec/color_hints.cc +++ b/third_party/jpeg-xl/lib/extras/dec/color_hints.cc @@ -43,20 +43,21 @@ Status ApplyColorHints(const ColorHints& color_hints, } else if (key == "icc") { const uint8_t* data = reinterpret_cast(value.data()); std::vector icc(data, data + value.size()); - ppf->icc.swap(icc); + ppf->icc = std::move(icc); + ppf->primary_color_representation = PackedPixelFile::kIccIsPrimary; got_color_space = true; } else if (key == "exif") { const uint8_t* data = reinterpret_cast(value.data()); std::vector blob(data, data + value.size()); - ppf->metadata.exif.swap(blob); + ppf->metadata.exif = std::move(blob); } else if (key == "xmp") { const uint8_t* data = reinterpret_cast(value.data()); std::vector blob(data, data + value.size()); - ppf->metadata.xmp.swap(blob); + ppf->metadata.xmp = std::move(blob); } else if (key == "jumbf") { const uint8_t* data = reinterpret_cast(value.data()); std::vector blob(data, data + value.size()); - ppf->metadata.jumbf.swap(blob); + ppf->metadata.jumbf = std::move(blob); } else { JXL_WARNING("Ignoring %s hint", key.c_str()); } diff --git a/third_party/jpeg-xl/lib/extras/dec/decode.cc b/third_party/jpeg-xl/lib/extras/dec/decode.cc index b3ca711bb2..3546cb65c0 100644 --- a/third_party/jpeg-xl/lib/extras/dec/decode.cc +++ b/third_party/jpeg-xl/lib/extras/dec/decode.cc @@ -35,7 +35,8 @@ std::string GetExtension(const std::string& path) { } // namespace -Codec CodecFromPath(std::string path, size_t* JXL_RESTRICT bits_per_sample, +Codec CodecFromPath(const std::string& path, + size_t* JXL_RESTRICT bits_per_sample, std::string* extension) { std::string ext = GetExtension(path); if (extension) { @@ -98,7 +99,7 @@ Status DecodeBytes(const Span bytes, *ppf = extras::PackedPixelFile(); // Default values when not set by decoders. - ppf->info.uses_original_profile = true; + ppf->info.uses_original_profile = JXL_TRUE; ppf->info.orientation = JXL_ORIENT_IDENTITY; const auto choose_codec = [&]() -> Codec { @@ -116,6 +117,7 @@ Status DecodeBytes(const Span bytes, dparams.accepted_formats.push_back( {num_channels, JXL_TYPE_FLOAT, JXL_LITTLE_ENDIAN, /*align=*/0}); } + dparams.output_bitdepth.type = JXL_BIT_DEPTH_FROM_CODESTREAM; size_t decoded_bytes; if (DecodeImageJXL(bytes.data(), bytes.size(), dparams, &decoded_bytes, ppf) && diff --git a/third_party/jpeg-xl/lib/extras/dec/decode.h b/third_party/jpeg-xl/lib/extras/dec/decode.h index 0d7dfcbef2..1a90f4c6a3 100644 --- a/third_party/jpeg-xl/lib/extras/dec/decode.h +++ b/third_party/jpeg-xl/lib/extras/dec/decode.h @@ -40,7 +40,7 @@ bool CanDecode(Codec codec); // If and only if extension is ".pfm", *bits_per_sample is updated to 32 so // that Encode() would encode to PFM instead of PPM. -Codec CodecFromPath(std::string path, +Codec CodecFromPath(const std::string& path, size_t* JXL_RESTRICT bits_per_sample = nullptr, std::string* extension = nullptr); diff --git a/third_party/jpeg-xl/lib/extras/dec/exr.cc b/third_party/jpeg-xl/lib/extras/dec/exr.cc index 821e0f4b21..d5903155e9 100644 --- a/third_party/jpeg-xl/lib/extras/dec/exr.cc +++ b/third_party/jpeg-xl/lib/extras/dec/exr.cc @@ -121,7 +121,12 @@ Status DecodeImageEXR(Span bytes, const ColorHints& color_hints, }; ppf->frames.clear(); // Allocates the frame buffer. - ppf->frames.emplace_back(image_size.x, image_size.y, format); + { + JXL_ASSIGN_OR_RETURN( + PackedFrame frame, + PackedFrame::Create(image_size.x, image_size.y, format)); + ppf->frames.emplace_back(std::move(frame)); + } const auto& frame = ppf->frames.back(); const int row_size = input.dataWindow().size().x + 1; @@ -188,7 +193,7 @@ Status DecodeImageEXR(Span bytes, const ColorHints& color_hints, if (has_alpha) { ppf->info.alpha_bits = kExrAlphaBits; ppf->info.alpha_exponent_bits = ppf->info.exponent_bits_per_sample; - ppf->info.alpha_premultiplied = true; + ppf->info.alpha_premultiplied = JXL_TRUE; } ppf->info.intensity_target = intensity_target; return true; diff --git a/third_party/jpeg-xl/lib/extras/dec/gif.cc b/third_party/jpeg-xl/lib/extras/dec/gif.cc index 3d963941c0..3f89d460b8 100644 --- a/third_party/jpeg-xl/lib/extras/dec/gif.cc +++ b/third_party/jpeg-xl/lib/extras/dec/gif.cc @@ -50,8 +50,10 @@ void ensure_have_alpha(PackedFrame* frame) { /*endianness=*/JXL_NATIVE_ENDIAN, /*align=*/0, }; - frame->extra_channels.emplace_back(frame->color.xsize, frame->color.ysize, - alpha_format); + JXL_ASSIGN_OR_DIE(PackedImage image, + PackedImage::Create(frame->color.xsize, frame->color.ysize, + alpha_format)); + frame->extra_channels.emplace_back(std::move(image)); // We need to set opaque-by-default. std::fill_n(static_cast(frame->extra_channels[0].pixels()), frame->color.xsize * frame->color.ysize, 255u); @@ -136,7 +138,7 @@ Status DecodeImageGIF(Span bytes, const ColorHints& color_hints, } if (gif->ImageCount > 1) { - ppf->info.have_animation = true; + ppf->info.have_animation = JXL_TRUE; // Delays in GIF are specified in 100ths of a second. ppf->info.animation.tps_numerator = 100; ppf->info.animation.tps_denominator = 1; @@ -186,7 +188,9 @@ Status DecodeImageGIF(Span bytes, const ColorHints& color_hints, } const PackedRgba background_rgba{background_color.Red, background_color.Green, background_color.Blue, 0}; - PackedFrame canvas(gif->SWidth, gif->SHeight, canvas_format); + JXL_ASSIGN_OR_RETURN( + PackedFrame canvas, + PackedFrame::Create(gif->SWidth, gif->SHeight, canvas_format)); std::fill_n(static_cast(canvas.color.pixels()), canvas.color.xsize * canvas.color.ysize, background_rgba); Rect canvas_rect{0, 0, canvas.color.xsize, canvas.color.ysize}; @@ -230,8 +234,14 @@ Status DecodeImageGIF(Span bytes, const ColorHints& color_hints, } // Allocates the frame buffer. - ppf->frames.emplace_back(total_rect.xsize(), total_rect.ysize(), - packed_frame_format); + { + JXL_ASSIGN_OR_RETURN( + PackedFrame frame, + PackedFrame::Create(total_rect.xsize(), total_rect.ysize(), + packed_frame_format)); + ppf->frames.emplace_back(std::move(frame)); + } + PackedFrame* frame = &ppf->frames.back(); // We cannot tell right from the start whether there will be a @@ -301,8 +311,10 @@ Status DecodeImageGIF(Span bytes, const ColorHints& color_hints, } // Update the canvas by creating a copy first. - PackedImage new_canvas_image(canvas.color.xsize, canvas.color.ysize, - canvas.color.format); + JXL_ASSIGN_OR_RETURN( + PackedImage new_canvas_image, + PackedImage::Create(canvas.color.xsize, canvas.color.ysize, + canvas.color.format)); memcpy(new_canvas_image.pixels(), canvas.color.pixels(), new_canvas_image.pixels_size); for (size_t y = 0, byte_index = 0; y < image_rect.ysize(); ++y) { diff --git a/third_party/jpeg-xl/lib/extras/dec/jpegli.cc b/third_party/jpeg-xl/lib/extras/dec/jpegli.cc index ffa1b79c25..443dfe86ba 100644 --- a/third_party/jpeg-xl/lib/extras/dec/jpegli.cc +++ b/third_party/jpeg-xl/lib/extras/dec/jpegli.cc @@ -27,7 +27,7 @@ constexpr unsigned char kExifSignature[6] = {0x45, 0x78, 0x69, constexpr int kExifMarker = JPEG_APP0 + 1; constexpr int kICCMarker = JPEG_APP0 + 2; -static inline bool IsJPG(const std::vector& bytes) { +inline bool IsJPG(const std::vector& bytes) { if (bytes.size() < 2) return false; if (bytes[0] != 0xFF || bytes[1] != 0xD8) return false; return true; @@ -188,7 +188,11 @@ Status DecodeJpeg(const std::vector& compressed, } else if (dparams.force_grayscale) { cinfo.out_color_space = JCS_GRAYSCALE; } - if (!ReadICCProfile(&cinfo, &ppf->icc)) { + if (ReadICCProfile(&cinfo, &ppf->icc)) { + ppf->primary_color_representation = PackedPixelFile::kIccIsPrimary; + } else { + ppf->primary_color_representation = + PackedPixelFile::kColorEncodingIsPrimary; ppf->icc.clear(); // Default to SRGB ppf->color_encoding.color_space = @@ -214,7 +218,7 @@ Status DecodeJpeg(const std::vector& compressed, } else { return failure("unsupported data type"); } - ppf->info.uses_original_profile = true; + ppf->info.uses_original_profile = JXL_TRUE; // No alpha in JPG ppf->info.alpha_bits = 0; @@ -227,8 +231,8 @@ Status DecodeJpeg(const std::vector& compressed, if (dparams.num_colors > 0) { cinfo.quantize_colors = TRUE; cinfo.desired_number_of_colors = dparams.num_colors; - cinfo.two_pass_quantize = dparams.two_pass_quant; - cinfo.dither_mode = (J_DITHER_MODE)dparams.dither_mode; + cinfo.two_pass_quantize = static_cast(dparams.two_pass_quant); + cinfo.dither_mode = static_cast(dparams.dither_mode); } jpegli_start_decompress(&cinfo); @@ -242,7 +246,12 @@ Status DecodeJpeg(const std::vector& compressed, }; ppf->frames.clear(); // Allocates the frame buffer. - ppf->frames.emplace_back(cinfo.image_width, cinfo.image_height, format); + { + JXL_ASSIGN_OR_RETURN( + PackedFrame frame, + PackedFrame::Create(cinfo.image_width, cinfo.image_height, format)); + ppf->frames.emplace_back(std::move(frame)); + } const auto& frame = ppf->frames.back(); JXL_ASSERT(sizeof(JSAMPLE) * cinfo.out_color_components * cinfo.image_width <= diff --git a/third_party/jpeg-xl/lib/extras/dec/jpg.cc b/third_party/jpeg-xl/lib/extras/dec/jpg.cc index 3c8a4bccfe..4a3e0d3b21 100644 --- a/third_party/jpeg-xl/lib/extras/dec/jpg.cc +++ b/third_party/jpeg-xl/lib/extras/dec/jpg.cc @@ -34,7 +34,7 @@ constexpr unsigned char kExifSignature[6] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}; constexpr int kExifMarker = JPEG_APP0 + 1; -static inline bool IsJPG(const Span bytes) { +inline bool IsJPG(const Span bytes) { if (bytes.size() < 2) return false; if (bytes[0] != 0xFF || bytes[1] != 0xD8) return false; return true; @@ -242,7 +242,11 @@ Status DecodeImageJPG(const Span bytes, if (nbcomp != 1 && nbcomp != 3) { return failure("unsupported number of components in JPEG"); } - if (!ReadICCProfile(&cinfo, &ppf->icc)) { + if (ReadICCProfile(&cinfo, &ppf->icc)) { + ppf->primary_color_representation = PackedPixelFile::kIccIsPrimary; + } else { + ppf->primary_color_representation = + PackedPixelFile::kColorEncodingIsPrimary; ppf->icc.clear(); // Default to SRGB // Actually, (cinfo.output_components == nbcomp) will be checked after @@ -266,7 +270,7 @@ Status DecodeImageJPG(const Span bytes, ppf->info.bits_per_sample = BITS_IN_JSAMPLE; JXL_ASSERT(BITS_IN_JSAMPLE == 8 || BITS_IN_JSAMPLE == 16); ppf->info.exponent_bits_per_sample = 0; - ppf->info.uses_original_profile = true; + ppf->info.uses_original_profile = JXL_TRUE; // No alpha in JPG ppf->info.alpha_bits = 0; @@ -278,8 +282,8 @@ Status DecodeImageJPG(const Span bytes, if (dparams && dparams->num_colors > 0) { cinfo.quantize_colors = TRUE; cinfo.desired_number_of_colors = dparams->num_colors; - cinfo.two_pass_quantize = dparams->two_pass_quant; - cinfo.dither_mode = (J_DITHER_MODE)dparams->dither_mode; + cinfo.two_pass_quantize = static_cast(dparams->two_pass_quant); + cinfo.dither_mode = static_cast(dparams->dither_mode); } jpeg_start_decompress(&cinfo); @@ -295,19 +299,25 @@ Status DecodeImageJPG(const Span bytes, }; ppf->frames.clear(); // Allocates the frame buffer. - ppf->frames.emplace_back(cinfo.image_width, cinfo.image_height, format); + { + JXL_ASSIGN_OR_RETURN( + PackedFrame frame, + PackedFrame::Create(cinfo.image_width, cinfo.image_height, format)); + ppf->frames.emplace_back(std::move(frame)); + } const auto& frame = ppf->frames.back(); JXL_ASSERT(sizeof(JSAMPLE) * cinfo.out_color_components * cinfo.image_width <= frame.color.stride); if (cinfo.quantize_colors) { - jxl::msan::UnpoisonMemory(cinfo.colormap, cinfo.out_color_components * - sizeof(cinfo.colormap[0])); + JSAMPLE** colormap = cinfo.colormap; + jxl::msan::UnpoisonMemory(reinterpret_cast(colormap), + cinfo.out_color_components * sizeof(JSAMPLE*)); for (int c = 0; c < cinfo.out_color_components; ++c) { jxl::msan::UnpoisonMemory( - cinfo.colormap[c], - cinfo.actual_number_of_colors * sizeof(cinfo.colormap[c][0])); + reinterpret_cast(colormap[c]), + cinfo.actual_number_of_colors * sizeof(JSAMPLE)); } } for (size_t y = 0; y < cinfo.image_height; ++y) { diff --git a/third_party/jpeg-xl/lib/extras/dec/jxl.cc b/third_party/jpeg-xl/lib/extras/dec/jxl.cc index f3e62c970a..5b7fa03f02 100644 --- a/third_party/jpeg-xl/lib/extras/dec/jxl.cc +++ b/third_party/jpeg-xl/lib/extras/dec/jxl.cc @@ -16,20 +16,23 @@ #include "lib/extras/dec/color_description.h" #include "lib/jxl/base/exif.h" #include "lib/jxl/base/printf_macros.h" +#include "lib/jxl/base/status.h" namespace jxl { namespace extras { namespace { struct BoxProcessor { - BoxProcessor(JxlDecoder* dec) : dec_(dec) { Reset(); } + explicit BoxProcessor(JxlDecoder* dec) : dec_(dec) { Reset(); } void InitializeOutput(std::vector* out) { + JXL_ASSERT(out != nullptr); box_data_ = out; AddMoreOutput(); } bool AddMoreOutput() { + JXL_ASSERT(box_data_ != nullptr); Flush(); static const size_t kBoxOutputChunkSize = 1 << 16; box_data_->resize(box_data_->size() + kBoxOutputChunkSize); @@ -126,7 +129,7 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, return false; } - JxlPixelFormat format; + JxlPixelFormat format = {}; // Initialize to calm down clang-tidy. std::vector accepted_formats = dparams.accepted_formats; JxlColorEncoding color_encoding; @@ -177,18 +180,18 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, return false; } if (jpeg_bytes == nullptr) { - if (JXL_DEC_SUCCESS != - JxlDecoderSetRenderSpotcolors(dec, dparams.render_spotcolors)) { + if (JXL_DEC_SUCCESS != JxlDecoderSetRenderSpotcolors( + dec, TO_JXL_BOOL(dparams.render_spotcolors))) { fprintf(stderr, "JxlDecoderSetRenderSpotColors failed\n"); return false; } - if (JXL_DEC_SUCCESS != - JxlDecoderSetKeepOrientation(dec, dparams.keep_orientation)) { + if (JXL_DEC_SUCCESS != JxlDecoderSetKeepOrientation( + dec, TO_JXL_BOOL(dparams.keep_orientation))) { fprintf(stderr, "JxlDecoderSetKeepOrientation failed\n"); return false; } - if (JXL_DEC_SUCCESS != - JxlDecoderSetUnpremultiplyAlpha(dec, dparams.unpremultiply_alpha)) { + if (JXL_DEC_SUCCESS != JxlDecoderSetUnpremultiplyAlpha( + dec, TO_JXL_BOOL(dparams.unpremultiply_alpha))) { fprintf(stderr, "JxlDecoderSetUnpremultiplyAlpha failed\n"); return false; } @@ -267,6 +270,7 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, return false; } } else if (status == JXL_DEC_JPEG_NEED_MORE_OUTPUT) { + JXL_ASSERT(jpeg_bytes != nullptr); // Help clang-tidy. // Decoded a chunk to JPEG. size_t used_jpeg_output = jpeg_data_chunk.size() - JxlDecoderReleaseJPEGBuffer(dec); @@ -309,7 +313,7 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, } else { if (dparams.unpremultiply_alpha) { // Mark in the basic info that alpha was unpremultiplied. - ppf->info.alpha_premultiplied = false; + ppf->info.alpha_premultiplied = JXL_FALSE; } } bool alpha_found = false; @@ -327,7 +331,8 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, } std::string name(eci.name_length + 1, 0); if (JXL_DEC_SUCCESS != - JxlDecoderGetExtraChannelName(dec, i, &name[0], name.size())) { + JxlDecoderGetExtraChannelName( + dec, i, const_cast(name.data()), name.size())) { fprintf(stderr, "JxlDecoderGetExtraChannelName failed\n"); return false; } @@ -351,24 +356,26 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, } size_t icc_size = 0; JxlColorProfileTarget target = JXL_COLOR_PROFILE_TARGET_DATA; - ppf->color_encoding.color_space = JXL_COLOR_SPACE_UNKNOWN; - if (JXL_DEC_SUCCESS != JxlDecoderGetColorAsEncodedProfile( - dec, target, &ppf->color_encoding) || - dparams.need_icc) { - // only get ICC if it is not an Enum color encoding - if (JXL_DEC_SUCCESS != - JxlDecoderGetICCProfileSize(dec, target, &icc_size)) { - fprintf(stderr, "JxlDecoderGetICCProfileSize failed\n"); - } - if (icc_size != 0) { - ppf->icc.resize(icc_size); - if (JXL_DEC_SUCCESS != JxlDecoderGetColorAsICCProfile( - dec, target, ppf->icc.data(), icc_size)) { - fprintf(stderr, "JxlDecoderGetColorAsICCProfile failed\n"); - return false; - } + if (JXL_DEC_SUCCESS != + JxlDecoderGetICCProfileSize(dec, target, &icc_size)) { + fprintf(stderr, "JxlDecoderGetICCProfileSize failed\n"); + } + if (icc_size != 0) { + ppf->primary_color_representation = PackedPixelFile::kIccIsPrimary; + ppf->icc.resize(icc_size); + if (JXL_DEC_SUCCESS != JxlDecoderGetColorAsICCProfile( + dec, target, ppf->icc.data(), icc_size)) { + fprintf(stderr, "JxlDecoderGetColorAsICCProfile failed\n"); + return false; } } + if (JXL_DEC_SUCCESS == JxlDecoderGetColorAsEncodedProfile( + dec, target, &ppf->color_encoding)) { + ppf->primary_color_representation = + PackedPixelFile::kColorEncodingIsPrimary; + } else { + ppf->color_encoding.color_space = JXL_COLOR_SPACE_UNKNOWN; + } icc_size = 0; target = JXL_COLOR_PROFILE_TARGET_ORIGINAL; if (JXL_DEC_SUCCESS != @@ -385,14 +392,21 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, } } } else if (status == JXL_DEC_FRAME) { - jxl::extras::PackedFrame frame(ppf->info.xsize, ppf->info.ysize, format); + auto frame_or = jxl::extras::PackedFrame::Create(ppf->info.xsize, + ppf->info.ysize, format); + if (!frame_or.status()) { + fprintf(stderr, "Failed to create image frame."); + return false; + } + jxl::extras::PackedFrame frame = std::move(frame_or).value(); if (JXL_DEC_SUCCESS != JxlDecoderGetFrameHeader(dec, &frame.frame_info)) { fprintf(stderr, "JxlDecoderGetFrameHeader failed\n"); return false; } frame.name.resize(frame.frame_info.name_length + 1, 0); if (JXL_DEC_SUCCESS != - JxlDecoderGetFrameName(dec, &frame.name[0], frame.name.size())) { + JxlDecoderGetFrameName(dec, const_cast(frame.name.data()), + frame.name.size())) { fprintf(stderr, "JxlDecoderGetFrameName failed\n"); return false; } @@ -423,9 +437,16 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, fprintf(stderr, "JxlDecoderPreviewOutBufferSize failed\n"); return false; } + auto preview_image_or = jxl::extras::PackedImage::Create( + ppf->info.preview.xsize, ppf->info.preview.ysize, format); + if (!preview_image_or.status()) { + fprintf(stderr, "Failed to create preview image\n"); + return false; + } + jxl::extras::PackedImage preview_image = + std::move(preview_image_or).value(); ppf->preview_frame = std::unique_ptr( - new jxl::extras::PackedFrame(ppf->info.preview.xsize, - ppf->info.preview.ysize, format)); + new jxl::extras::PackedFrame(std::move(preview_image))); if (buffer_size != ppf->preview_frame->color.pixels_size) { fprintf(stderr, "Invalid out buffer size %" PRIuS " %" PRIuS "\n", buffer_size, ppf->preview_frame->color.pixels_size); @@ -492,8 +513,13 @@ bool DecodeImageJXL(const uint8_t* bytes, size_t bytes_size, JxlPixelFormat ec_format = format; ec_format.num_channels = 1; for (auto& eci : ppf->extra_channels_info) { - frame.extra_channels.emplace_back(jxl::extras::PackedImage( - ppf->info.xsize, ppf->info.ysize, ec_format)); + auto image = jxl::extras::PackedImage::Create( + ppf->info.xsize, ppf->info.ysize, ec_format); + if (!image.status()) { + fprintf(stderr, "Failed to create extra channel image\n"); + return false; + } + frame.extra_channels.emplace_back(std::move(image).value()); auto& ec = frame.extra_channels.back(); size_t buffer_size; if (JXL_DEC_SUCCESS != JxlDecoderExtraChannelBufferSize( diff --git a/third_party/jpeg-xl/lib/extras/dec/jxl.h b/third_party/jpeg-xl/lib/extras/dec/jxl.h index cbada1f6dd..5f4ed7f683 100644 --- a/third_party/jpeg-xl/lib/extras/dec/jxl.h +++ b/third_party/jpeg-xl/lib/extras/dec/jxl.h @@ -41,10 +41,6 @@ struct JXLDecompressParams { // Whether truncated input should be treated as an error. bool allow_partial_input = false; - // Set to true if an ICC profile has to be synthesized for Enum color - // encodings - bool need_icc = false; - // How many passes to decode at most. By default, decode everything. uint32_t max_passes = std::numeric_limits::max(); diff --git a/third_party/jpeg-xl/lib/extras/dec/pgx.cc b/third_party/jpeg-xl/lib/extras/dec/pgx.cc index a99eb0f4ee..4499069d77 100644 --- a/third_party/jpeg-xl/lib/extras/dec/pgx.cc +++ b/third_party/jpeg-xl/lib/extras/dec/pgx.cc @@ -150,7 +150,7 @@ Status DecodeImagePGX(const Span bytes, const SizeConstraints* constraints) { Parser parser(bytes); HeaderPGX header = {}; - const uint8_t* pos; + const uint8_t* pos = nullptr; if (!parser.ParseHeader(&header, &pos)) return false; JXL_RETURN_IF_ERROR( VerifyDimensions(constraints, header.xsize, header.ysize)); @@ -165,7 +165,7 @@ Status DecodeImagePGX(const Span bytes, // Original data is uint, so exponent_bits_per_sample = 0. ppf->info.bits_per_sample = header.bits_per_sample; ppf->info.exponent_bits_per_sample = 0; - ppf->info.uses_original_profile = true; + ppf->info.uses_original_profile = JXL_TRUE; // No alpha in PGX ppf->info.alpha_bits = 0; @@ -188,7 +188,12 @@ Status DecodeImagePGX(const Span bytes, }; ppf->frames.clear(); // Allocates the frame buffer. - ppf->frames.emplace_back(header.xsize, header.ysize, format); + { + JXL_ASSIGN_OR_RETURN( + PackedFrame frame, + PackedFrame::Create(header.xsize, header.ysize, format)); + ppf->frames.emplace_back(std::move(frame)); + } const auto& frame = ppf->frames.back(); size_t pgx_remaining_size = bytes.data() + bytes.size() - pos; if (pgx_remaining_size < frame.color.pixels_size) { diff --git a/third_party/jpeg-xl/lib/extras/dec/pnm.cc b/third_party/jpeg-xl/lib/extras/dec/pnm.cc index 4c4618d41d..040c0bff81 100644 --- a/third_party/jpeg-xl/lib/extras/dec/pnm.cc +++ b/third_party/jpeg-xl/lib/extras/dec/pnm.cc @@ -9,6 +9,7 @@ #include #include +#include #include #include "jxl/encode.h" @@ -55,8 +56,10 @@ class Parser { case 'f': header->is_gray = true; return ParseHeaderPFM(header, pos); + + default: + return false; } - return false; } // Exposed for testing @@ -160,11 +163,12 @@ class Parser { Status MatchString(const char* keyword, bool skipws = true) { const uint8_t* ppos = pos_; - while (*keyword) { + const uint8_t* kw = reinterpret_cast(keyword); + while (*kw) { if (ppos >= end_) return JXL_FAILURE("PAM: unexpected end of input"); - if (*keyword != *ppos) return false; + if (*kw != *ppos) return false; ppos++; - keyword++; + kw++; } pos_ = ppos; if (skipws) { @@ -387,8 +391,8 @@ StatusOr ChunkedPNMDecoder::Init(const char* path) { const size_t num_channels = dec.header_.is_gray ? 1 : 3; const size_t bytes_per_pixel = num_channels * bytes_per_channel; size_t row_size = dec.header_.xsize * bytes_per_pixel; - if (header.ysize * row_size + dec.data_start_ < size) { - return JXL_FAILURE("Invalid ppm"); + if (size < header.ysize * row_size + dec.data_start_) { + return JXL_FAILURE("PNM file too small"); } return dec; } @@ -495,10 +499,18 @@ Status DecodeImagePNM(const Span bytes, }; const JxlPixelFormat ec_format{1, format.data_type, format.endianness, 0}; ppf->frames.clear(); - ppf->frames.emplace_back(header.xsize, header.ysize, format); + { + JXL_ASSIGN_OR_RETURN( + PackedFrame frame, + PackedFrame::Create(header.xsize, header.ysize, format)); + ppf->frames.emplace_back(std::move(frame)); + } auto* frame = &ppf->frames.back(); for (size_t i = 0; i < header.ec_types.size(); ++i) { - frame->extra_channels.emplace_back(header.xsize, header.ysize, ec_format); + JXL_ASSIGN_OR_RETURN( + PackedImage ec, + PackedImage::Create(header.xsize, header.ysize, ec_format)); + frame->extra_channels.emplace_back(std::move(ec)); } size_t pnm_remaining_size = bytes.data() + bytes.size() - pos; if (pnm_remaining_size < frame->color.pixels_size) { @@ -533,6 +545,9 @@ Status DecodeImagePNM(const Span bytes, } } } + if (ppf->info.exponent_bits_per_sample == 0) { + ppf->input_bitdepth.type = JXL_BIT_DEPTH_FROM_CODESTREAM; + } return true; } diff --git a/third_party/jpeg-xl/lib/extras/enc/apng.cc b/third_party/jpeg-xl/lib/extras/enc/apng.cc index 413a9c8081..40aa876e84 100644 --- a/third_party/jpeg-xl/lib/extras/enc/apng.cc +++ b/third_party/jpeg-xl/lib/extras/enc/apng.cc @@ -86,7 +86,7 @@ class APNGEncoder : public Encoder { std::vector* bytes) const; }; -static void PngWrite(png_structp png_ptr, png_bytep data, png_size_t length) { +void PngWrite(png_structp png_ptr, png_bytep data, png_size_t length) { std::vector* bytes = static_cast*>(png_get_io_ptr(png_ptr)); bytes->insert(bytes->end(), data, data + length); @@ -137,7 +137,7 @@ class BlobsWriterPNG { std::vector* strings) { // Encoding: base16 with newline after 72 chars. const size_t base16_size = - 2 * bytes.size() + DivCeil(bytes.size(), size_t(36)) + 1; + 2 * bytes.size() + DivCeil(bytes.size(), static_cast(36)) + 1; std::string base16; base16.reserve(base16_size); for (size_t i = 0; i < bytes.size(); ++i) { @@ -155,7 +155,7 @@ class BlobsWriterPNG { snprintf(header, sizeof(header), "\n%s\n%8" PRIuS, type.c_str(), bytes.size()); - strings->push_back(std::string(key)); + strings->emplace_back(key); strings->push_back(std::string(header) + base16); return true; } @@ -303,7 +303,7 @@ Status APNGEncoder::EncodePackedPixelFileToAPNG( out[i] = static_cast(in[i] * mul + 0.5); } } else { - memcpy(&out[0], in, out_size); + memcpy(out.data(), in, out_size); } } else if (format.data_type == JXL_TYPE_UINT16) { if (ppf.info.bits_per_sample < 16 || @@ -317,20 +317,21 @@ Status APNGEncoder::EncodePackedPixelFileToAPNG( StoreBE16(static_cast(val * mul + 0.5), p_out); } } else { - memcpy(&out[0], in, out_size); + memcpy(out.data(), in, out_size); } } png_structp png_ptr; png_infop info_ptr; - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, + nullptr); if (!png_ptr) return JXL_FAILURE("Could not init png encoder"); info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) return JXL_FAILURE("Could not init png info struct"); - png_set_write_fn(png_ptr, bytes, PngWrite, NULL); + png_set_write_fn(png_ptr, bytes, PngWrite, nullptr); png_set_flush(png_ptr, 0); int width = xsize; @@ -344,11 +345,13 @@ Status APNGEncoder::EncodePackedPixelFileToAPNG( PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); if (count == 0) { - if (!ppf.icc.empty()) { - png_set_benign_errors(png_ptr, 1); - png_set_iCCP(png_ptr, info_ptr, "1", 0, ppf.icc.data(), ppf.icc.size()); - } else if (!MaybeAddSRGB(ppf.color_encoding, png_ptr, info_ptr)) { + if (!MaybeAddSRGB(ppf.color_encoding, png_ptr, info_ptr)) { MaybeAddCICP(ppf.color_encoding, png_ptr, info_ptr); + if (!ppf.icc.empty()) { + png_set_benign_errors(png_ptr, 1); + png_set_iCCP(png_ptr, info_ptr, "1", 0, ppf.icc.data(), + ppf.icc.size()); + } MaybeAddCHRM(ppf.color_encoding, png_ptr, info_ptr); MaybeAddGAMA(ppf.color_encoding, png_ptr, info_ptr); } @@ -404,7 +407,7 @@ Status APNGEncoder::EncodePackedPixelFileToAPNG( png_write_flush(png_ptr); const size_t pos = bytes->size(); - png_write_image(png_ptr, &rows[0]); + png_write_image(png_ptr, rows.data()); png_write_flush(png_ptr); if (count > 0) { std::vector fdata(4); @@ -428,7 +431,7 @@ Status APNGEncoder::EncodePackedPixelFileToAPNG( count++; if (count == ppf.frames.size() || !ppf.info.have_animation) { - png_write_end(png_ptr, NULL); + png_write_end(png_ptr, nullptr); } png_destroy_write_struct(&png_ptr, &info_ptr); diff --git a/third_party/jpeg-xl/lib/extras/enc/encode.cc b/third_party/jpeg-xl/lib/extras/enc/encode.cc index 8c9a148b27..c5e22d8c7e 100644 --- a/third_party/jpeg-xl/lib/extras/enc/encode.cc +++ b/third_party/jpeg-xl/lib/extras/enc/encode.cc @@ -54,7 +54,7 @@ Status Encoder::VerifyBitDepth(JxlDataType data_type, uint32_t bits_per_sample, (bits_per_sample > 16 || exponent_bits > 5))) { return JXL_FAILURE( "Incompatible data_type %d and bit depth %u with exponent bits %u", - (int)data_type, bits_per_sample, exponent_bits); + static_cast(data_type), bits_per_sample, exponent_bits); } return true; } diff --git a/third_party/jpeg-xl/lib/extras/enc/encode.h b/third_party/jpeg-xl/lib/extras/enc/encode.h index da5f509838..2502d9976b 100644 --- a/third_party/jpeg-xl/lib/extras/enc/encode.h +++ b/third_party/jpeg-xl/lib/extras/enc/encode.h @@ -56,7 +56,7 @@ class Encoder { // Any existing data in encoded_image is discarded. virtual Status Encode(const PackedPixelFile& ppf, EncodedImage* encoded_image, - ThreadPool* pool = nullptr) const = 0; + ThreadPool* pool) const = 0; void SetOption(std::string name, std::string value) { options_[std::move(name)] = std::move(value); diff --git a/third_party/jpeg-xl/lib/extras/enc/exr.cc b/third_party/jpeg-xl/lib/extras/enc/exr.cc index d4005c3097..5a4f7d768c 100644 --- a/third_party/jpeg-xl/lib/extras/enc/exr.cc +++ b/third_party/jpeg-xl/lib/extras/enc/exr.cc @@ -84,7 +84,7 @@ Status EncodeImageEXR(const PackedImage& image, const JxlBasicInfo& info, const size_t xsize = info.xsize; const size_t ysize = info.ysize; const bool has_alpha = info.alpha_bits > 0; - const bool alpha_is_premultiplied = info.alpha_premultiplied; + const bool alpha_is_premultiplied = FROM_JXL_BOOL(info.alpha_premultiplied); if (info.num_color_channels != 3 || c_enc.color_space != JXL_COLOR_SPACE_RGB || @@ -177,7 +177,7 @@ class EXREncoder : public Encoder { return formats; } Status Encode(const PackedPixelFile& ppf, EncodedImage* encoded_image, - ThreadPool* pool = nullptr) const override { + ThreadPool* pool) const override { JXL_RETURN_IF_ERROR(VerifyBasicInfo(ppf.info)); encoded_image->icc.clear(); encoded_image->bitstreams.clear(); diff --git a/third_party/jpeg-xl/lib/extras/enc/jpegli.cc b/third_party/jpeg-xl/lib/extras/enc/jpegli.cc index 7e1aa426df..aa10b584d0 100644 --- a/third_party/jpeg-xl/lib/extras/enc/jpegli.cc +++ b/third_party/jpeg-xl/lib/extras/enc/jpegli.cc @@ -34,6 +34,7 @@ #include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/enc_xyb.h" #include "lib/jxl/image.h" +#include "lib/jxl/simd_util.h" namespace jxl { namespace extras { @@ -53,6 +54,10 @@ Status VerifyInput(const PackedPixelFile& ppf) { if (ppf.frames.size() != 1) { return JXL_FAILURE("JPEG input must have exactly one frame."); } + if (info.num_color_channels != 1 && info.num_color_channels != 3) { + return JXL_FAILURE("Invalid number of color channels %d", + info.num_color_channels); + } const PackedImage& image = ppf.frames[0].color; JXL_RETURN_IF_ERROR(Encoder::VerifyImageSize(image, info)); if (image.format.data_type == JXL_TYPE_FLOAT16) { @@ -71,7 +76,7 @@ Status VerifyInput(const PackedPixelFile& ppf) { Status GetColorEncoding(const PackedPixelFile& ppf, ColorEncoding* color_encoding) { - if (!ppf.icc.empty()) { + if (ppf.primary_color_representation == PackedPixelFile::kIccIsPrimary) { IccBytes icc = ppf.icc; JXL_RETURN_IF_ERROR( color_encoding->SetICC(std::move(icc), JxlGetDefaultCms())); @@ -122,12 +127,12 @@ Status WriteAppData(j_compress_ptr cinfo, return true; } -static constexpr int kICCMarker = 0xe2; +constexpr int kICCMarker = 0xe2; constexpr unsigned char kICCSignature[12] = { 0x49, 0x43, 0x43, 0x5F, 0x50, 0x52, 0x4F, 0x46, 0x49, 0x4C, 0x45, 0x00}; -static constexpr uint8_t kUnknownTf = 2; -static constexpr unsigned char kCICPTagSignature[4] = {0x63, 0x69, 0x63, 0x70}; -static constexpr size_t kCICPTagSize = 12; +constexpr uint8_t kUnknownTf = 2; +constexpr unsigned char kCICPTagSignature[4] = {0x63, 0x69, 0x63, 0x70}; +constexpr size_t kCICPTagSize = 12; bool FindCICPTag(const uint8_t* icc_data, size_t len, bool is_first_chunk, size_t* cicp_offset, size_t* cicp_length, uint8_t* cicp_tag, @@ -248,32 +253,48 @@ JpegliEndianness ConvertEndianness(JxlEndianness endianness) { } } -void ToFloatRow(const uint8_t* row_in, JxlPixelFormat format, size_t len, - float* row_out) { +void ToFloatRow(const uint8_t* row_in, JxlPixelFormat format, size_t xsize, + size_t c_out, float* row_out) { bool is_little_endian = (format.endianness == JXL_LITTLE_ENDIAN || (format.endianness == JXL_NATIVE_ENDIAN && IsLittleEndian())); static constexpr double kMul8 = 1.0 / 255.0; static constexpr double kMul16 = 1.0 / 65535.0; + const size_t c_in = format.num_channels; if (format.data_type == JXL_TYPE_UINT8) { - for (size_t x = 0; x < len; ++x) { - row_out[x] = row_in[x] * kMul8; + for (size_t x = 0; x < xsize; ++x) { + for (size_t c = 0; c < c_out; ++c) { + const size_t ix = c_in * x + c; + row_out[c_out * x + c] = row_in[ix] * kMul8; + } } } else if (format.data_type == JXL_TYPE_UINT16 && is_little_endian) { - for (size_t x = 0; x < len; ++x) { - row_out[x] = LoadLE16(&row_in[2 * x]) * kMul16; + for (size_t x = 0; x < xsize; ++x) { + for (size_t c = 0; c < c_out; ++c) { + const size_t ix = c_in * x + c; + row_out[c_out * x + c] = LoadLE16(&row_in[2 * ix]) * kMul16; + } } } else if (format.data_type == JXL_TYPE_UINT16 && !is_little_endian) { - for (size_t x = 0; x < len; ++x) { - row_out[x] = LoadBE16(&row_in[2 * x]) * kMul16; + for (size_t x = 0; x < xsize; ++x) { + for (size_t c = 0; c < c_out; ++c) { + const size_t ix = c_in * x + c; + row_out[c_out * x + c] = LoadBE16(&row_in[2 * ix]) * kMul16; + } } } else if (format.data_type == JXL_TYPE_FLOAT && is_little_endian) { - for (size_t x = 0; x < len; ++x) { - row_out[x] = LoadLEFloat(&row_in[4 * x]); + for (size_t x = 0; x < xsize; ++x) { + for (size_t c = 0; c < c_out; ++c) { + const size_t ix = c_in * x + c; + row_out[c_out * x + c] = LoadLEFloat(&row_in[4 * ix]); + } } } else if (format.data_type == JXL_TYPE_FLOAT && !is_little_endian) { - for (size_t x = 0; x < len; ++x) { - row_out[x] = LoadBEFloat(&row_in[4 * x]); + for (size_t x = 0; x < xsize; ++x) { + for (size_t c = 0; c < c_out; ++c) { + const size_t ix = c_in * x + c; + row_out[c_out * x + c] = LoadBEFloat(&row_in[4 * ix]); + } } } } @@ -352,9 +373,6 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings, ColorSpaceTransform c_transform(*JxlGetDefaultCms()); ColorEncoding xyb_encoding; if (jpeg_settings.xyb) { - if (ppf.info.num_color_channels != 3) { - return JXL_FAILURE("Only RGB input is supported in XYB mode."); - } if (HasICCProfile(jpeg_settings.app_data)) { return JXL_FAILURE("APP data ICC profile is not supported in XYB mode."); } @@ -374,11 +392,11 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings, unsigned char* output_buffer = nullptr; unsigned long output_size = 0; std::vector row_bytes; - size_t rowlen = RoundUpTo(ppf.info.xsize, VectorSize()); + size_t rowlen = RoundUpTo(ppf.info.xsize, MaxVectorSize()); hwy::AlignedFreeUniquePtr xyb_tmp = hwy::AllocateAligned(6 * rowlen); hwy::AlignedFreeUniquePtr premul_absorb = - hwy::AllocateAligned(VectorSize() * 12); + hwy::AllocateAligned(MaxVectorSize() * 12); ComputePremulAbsorb(255.0f, premul_absorb.get()); jpeg_compress_struct cinfo; @@ -401,6 +419,8 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings, cinfo.input_components == 1 ? JCS_GRAYSCALE : JCS_RGB; if (jpeg_settings.xyb) { jpegli_set_xyb_mode(&cinfo); + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; } else if (jpeg_settings.use_std_quant_tables) { jpegli_use_standard_quant_tables(&cinfo); } @@ -436,7 +456,7 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings, } } jpegli_enable_adaptive_quantization( - &cinfo, jpeg_settings.use_adaptive_quantization); + &cinfo, TO_JXL_BOOL(jpeg_settings.use_adaptive_quantization)); if (jpeg_settings.psnr_target > 0.0) { jpegli_set_psnr(&cinfo, jpeg_settings.psnr_target, jpeg_settings.search_tolerance, @@ -448,11 +468,11 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings, jpegli_set_distance(&cinfo, jpeg_settings.distance, TRUE); } jpegli_set_progressive_level(&cinfo, jpeg_settings.progressive_level); - cinfo.optimize_coding = jpeg_settings.optimize_coding; + cinfo.optimize_coding = TO_JXL_BOOL(jpeg_settings.optimize_coding); if (!jpeg_settings.app_data.empty()) { // Make sure jpegli_start_compress() does not write any APP markers. - cinfo.write_JFIF_header = false; - cinfo.write_Adobe_marker = false; + cinfo.write_JFIF_header = JXL_FALSE; + cinfo.write_Adobe_marker = JXL_FALSE; } const PackedImage& image = ppf.frames[0].color; if (jpeg_settings.xyb) { @@ -476,10 +496,10 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings, float* dst_buf = c_transform.BufDst(0); for (size_t y = 0; y < image.ysize; ++y) { // convert to float - ToFloatRow(&pixels[y * image.stride], image.format, 3 * image.xsize, - src_buf); + ToFloatRow(&pixels[y * image.stride], image.format, image.xsize, + info.num_color_channels, src_buf); // convert to linear srgb - if (!c_transform.Run(0, src_buf, dst_buf)) { + if (!c_transform.Run(0, src_buf, dst_buf, image.xsize)) { return false; } // deinterleave channels @@ -508,9 +528,9 @@ Status EncodeJpeg(const PackedPixelFile& ppf, const JpegSettings& jpeg_settings, } } else { row_bytes.resize(image.stride); - if (cinfo.num_components == (int)image.format.num_channels) { + if (cinfo.num_components == static_cast(image.format.num_channels)) { for (size_t y = 0; y < info.ysize; ++y) { - memcpy(&row_bytes[0], pixels + y * image.stride, image.stride); + memcpy(row_bytes.data(), pixels + y * image.stride, image.stride); JSAMPROW row[] = {row_bytes.data()}; jpegli_write_scanlines(&cinfo, row, 1); } diff --git a/third_party/jpeg-xl/lib/extras/enc/jpg.cc b/third_party/jpeg-xl/lib/extras/enc/jpg.cc index c34dc6c13f..de0228fc0d 100644 --- a/third_party/jpeg-xl/lib/extras/enc/jpg.cc +++ b/third_party/jpeg-xl/lib/extras/enc/jpg.cc @@ -23,6 +23,7 @@ #include #include "lib/extras/exif.h" +#include "lib/jxl/base/common.h" #include "lib/jxl/base/status.h" #include "lib/jxl/sanitizers.h" #if JPEGXL_ENABLE_SJPEG @@ -50,23 +51,21 @@ enum class JpegEncoder { kSJpeg, }; -#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) - // Popular jpeg scan scripts // The fields of the individual scans are: // comps_in_scan, component_index[], Ss, Se, Ah, Al -static constexpr jpeg_scan_info kScanScript1[] = { +constexpr auto kScanScript1 = to_array({ {1, {0}, 0, 0, 0, 0}, // {1, {1}, 0, 0, 0, 0}, // {1, {2}, 0, 0, 0, 0}, // {1, {0}, 1, 8, 0, 0}, // {1, {0}, 9, 63, 0, 0}, // {1, {1}, 1, 63, 0, 0}, // - {1, {2}, 1, 63, 0, 0}, // -}; -static constexpr size_t kNumScans1 = ARRAY_SIZE(kScanScript1); + {1, {2}, 1, 63, 0, 0} // +}); +constexpr size_t kNumScans1 = kScanScript1.size(); -static constexpr jpeg_scan_info kScanScript2[] = { +constexpr auto kScanScript2 = to_array({ {1, {0}, 0, 0, 0, 0}, // {1, {1}, 0, 0, 0, 0}, // {1, {2}, 0, 0, 0, 0}, // @@ -74,11 +73,11 @@ static constexpr jpeg_scan_info kScanScript2[] = { {1, {0}, 3, 63, 0, 1}, // {1, {0}, 1, 63, 1, 0}, // {1, {1}, 1, 63, 0, 0}, // - {1, {2}, 1, 63, 0, 0}, // -}; -static constexpr size_t kNumScans2 = ARRAY_SIZE(kScanScript2); + {1, {2}, 1, 63, 0, 0} // +}); +constexpr size_t kNumScans2 = kScanScript2.size(); -static constexpr jpeg_scan_info kScanScript3[] = { +constexpr auto kScanScript3 = to_array({ {1, {0}, 0, 0, 0, 0}, // {1, {1}, 0, 0, 0, 0}, // {1, {2}, 0, 0, 0, 0}, // @@ -86,11 +85,11 @@ static constexpr jpeg_scan_info kScanScript3[] = { {1, {0}, 1, 63, 2, 1}, // {1, {0}, 1, 63, 1, 0}, // {1, {1}, 1, 63, 0, 0}, // - {1, {2}, 1, 63, 0, 0}, // -}; -static constexpr size_t kNumScans3 = ARRAY_SIZE(kScanScript3); + {1, {2}, 1, 63, 0, 0} // +}); +constexpr size_t kNumScans3 = kScanScript3.size(); -static constexpr jpeg_scan_info kScanScript4[] = { +constexpr auto kScanScript4 = to_array({ {3, {0, 1, 2}, 0, 0, 0, 1}, // {1, {0}, 1, 5, 0, 2}, // {1, {2}, 1, 63, 0, 1}, // @@ -100,11 +99,11 @@ static constexpr jpeg_scan_info kScanScript4[] = { {3, {0, 1, 2}, 0, 0, 1, 0}, // {1, {2}, 1, 63, 1, 0}, // {1, {1}, 1, 63, 1, 0}, // - {1, {0}, 1, 63, 1, 0}, // -}; -static constexpr size_t kNumScans4 = ARRAY_SIZE(kScanScript4); + {1, {0}, 1, 63, 1, 0} // +}); +constexpr size_t kNumScans4 = kScanScript4.size(); -static constexpr jpeg_scan_info kScanScript5[] = { +constexpr auto kScanScript5 = to_array({ {3, {0, 1, 2}, 0, 0, 0, 1}, // {1, {0}, 1, 5, 0, 2}, // {1, {1}, 1, 5, 0, 2}, // @@ -118,12 +117,12 @@ static constexpr jpeg_scan_info kScanScript5[] = { {3, {0, 1, 2}, 0, 0, 1, 0}, // {1, {0}, 1, 63, 1, 0}, // {1, {1}, 1, 63, 1, 0}, // - {1, {2}, 1, 63, 1, 0}, // -}; -static constexpr size_t kNumScans5 = ARRAY_SIZE(kScanScript5); + {1, {2}, 1, 63, 1, 0} // +}); +constexpr size_t kNumScans5 = kScanScript5.size(); // default progressive mode of jpegli -static constexpr jpeg_scan_info kScanScript6[] = { +constexpr auto kScanScript6 = to_array({ {3, {0, 1, 2}, 0, 0, 0, 0}, // {1, {0}, 1, 2, 0, 0}, // {1, {1}, 1, 2, 0, 0}, // @@ -137,8 +136,8 @@ static constexpr jpeg_scan_info kScanScript6[] = { {1, {0}, 3, 63, 1, 0}, // {1, {1}, 3, 63, 1, 0}, // {1, {2}, 3, 63, 1, 0}, // -}; -static constexpr size_t kNumScans6 = ARRAY_SIZE(kScanScript6); +}); +constexpr size_t kNumScans6 = kScanScript6.size(); // Adapt RGB scan info to grayscale jpegs. void FilterScanComponents(const jpeg_compress_struct* cinfo, @@ -163,12 +162,12 @@ Status SetJpegProgression(int progressive_id, jpeg_simple_progression(cinfo); return true; } - constexpr const jpeg_scan_info* kScanScripts[] = {kScanScript1, kScanScript2, - kScanScript3, kScanScript4, - kScanScript5, kScanScript6}; - constexpr size_t kNumScans[] = {kNumScans1, kNumScans2, kNumScans3, - kNumScans4, kNumScans5, kNumScans6}; - if (progressive_id > static_cast(ARRAY_SIZE(kNumScans))) { + const jpeg_scan_info* kScanScripts[] = { + kScanScript1.data(), kScanScript2.data(), kScanScript3.data(), + kScanScript4.data(), kScanScript5.data(), kScanScript6.data()}; + constexpr auto kNumScans = to_array( + {kNumScans1, kNumScans2, kNumScans3, kNumScans4, kNumScans5, kNumScans6}); + if (progressive_id > static_cast(kNumScans.size())) { return JXL_FAILURE("Unknown jpeg scan script id %d", progressive_id); } const jpeg_scan_info* scan_script = kScanScripts[progressive_id - 1]; @@ -178,7 +177,7 @@ Status SetJpegProgression(int progressive_id, jpeg_scan_info scan_info = scan_script[i]; FilterScanComponents(cinfo, &scan_info); if (scan_info.comps_in_scan > 0) { - scan_infos->emplace_back(std::move(scan_info)); + scan_infos->emplace_back(scan_info); } } cinfo->scan_info = scan_infos->data(); @@ -217,8 +216,8 @@ void WriteExif(jpeg_compress_struct* const cinfo, for (const unsigned char c : kExifSignature) { jpeg_write_m_byte(cinfo, c); } - for (size_t i = 0; i < exif.size(); ++i) { - jpeg_write_m_byte(cinfo, exif[i]); + for (uint8_t c : exif) { + jpeg_write_m_byte(cinfo, c); } } @@ -284,7 +283,7 @@ Status EncodeWithLibJpeg(const PackedImage& image, const JxlBasicInfo& info, cinfo.input_components = info.num_color_channels; cinfo.in_color_space = info.num_color_channels == 1 ? JCS_GRAYSCALE : JCS_RGB; jpeg_set_defaults(&cinfo); - cinfo.optimize_coding = params.optimize_coding; + cinfo.optimize_coding = static_cast(params.optimize_coding); if (cinfo.input_components == 3) { JXL_RETURN_IF_ERROR( SetChromaSubsampling(params.chroma_subsampling, &cinfo)); @@ -310,10 +309,10 @@ Status EncodeWithLibJpeg(const PackedImage& image, const JxlBasicInfo& info, std::vector row_bytes(image.stride); const uint8_t* pixels = reinterpret_cast(image.pixels()); - if (cinfo.num_components == (int)image.format.num_channels && + if (cinfo.num_components == static_cast(image.format.num_channels) && image.format.data_type == JXL_TYPE_UINT8) { for (size_t y = 0; y < info.ysize; ++y) { - memcpy(&row_bytes[0], pixels + y * image.stride, image.stride); + memcpy(row_bytes.data(), pixels + y * image.stride, image.stride); JSAMPROW row[] = {row_bytes.data()}; jpeg_write_scanlines(&cinfo, row, 1); } @@ -401,7 +400,7 @@ struct MySearchHook : public sjpeg::SearchHook { } bool Update(float result) override { value = result; - if (fabs(value - target) < tolerance * target) { + if (std::fabs(value - target) < tolerance * target) { return true; } if (value > target) { @@ -420,9 +419,9 @@ struct MySearchHook : public sjpeg::SearchHook { } else { q = (qmin + qmax) / 2.; } - return (pass > 0 && fabs(q - last_q) < q_precision); + return (pass > 0 && std::fabs(q - last_q) < q_precision); } - ~MySearchHook() override {} + ~MySearchHook() override = default; }; #endif @@ -539,7 +538,7 @@ class JPEGEncoder : public Encoder { return formats; } Status Encode(const PackedPixelFile& ppf, EncodedImage* encoded_image, - ThreadPool* pool = nullptr) const override { + ThreadPool* pool) const override { JXL_RETURN_IF_ERROR(VerifyBasicInfo(ppf.info)); JpegEncoder jpeg_encoder = JpegEncoder::kLibJpeg; JpegParams params; diff --git a/third_party/jpeg-xl/lib/extras/enc/jxl.cc b/third_party/jpeg-xl/lib/extras/enc/jxl.cc index 00adbb7dda..d563f298e6 100644 --- a/third_party/jpeg-xl/lib/extras/enc/jxl.cc +++ b/third_party/jpeg-xl/lib/extras/enc/jxl.cc @@ -7,6 +7,7 @@ #include #include +#include #include "lib/jxl/base/exif.h" @@ -132,7 +133,7 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, return false; } - auto settings = JxlEncoderFrameSettingsCreate(enc, nullptr); + auto* settings = JxlEncoderFrameSettingsCreate(enc, nullptr); size_t option_idx = 0; if (!SetFrameOptions(params.options, 0, &option_idx, settings)) { return false; @@ -150,10 +151,11 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, JxlEncoderCollectStats(settings, params.stats); } + bool has_jpeg_bytes = (jpeg_bytes != nullptr); bool use_boxes = !ppf.metadata.exif.empty() || !ppf.metadata.xmp.empty() || !ppf.metadata.jumbf.empty() || !ppf.metadata.iptc.empty(); bool use_container = params.use_container || use_boxes || - (jpeg_bytes && params.jpeg_store_metadata); + (has_jpeg_bytes && params.jpeg_store_metadata); if (JXL_ENC_SUCCESS != JxlEncoderUseContainer(enc, static_cast(use_container))) { @@ -161,12 +163,22 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, return false; } - if (jpeg_bytes) { + if (has_jpeg_bytes) { if (params.jpeg_store_metadata && JXL_ENC_SUCCESS != JxlEncoderStoreJPEGMetadata(enc, JXL_TRUE)) { fprintf(stderr, "Storing JPEG metadata failed.\n"); return false; } + if (params.jpeg_store_metadata && params.jpeg_strip_exif) { + fprintf(stderr, + "Cannot store metadata and strip exif at the same time.\n"); + return false; + } + if (params.jpeg_store_metadata && params.jpeg_strip_xmp) { + fprintf(stderr, + "Cannot store metadata and strip xmp at the same time.\n"); + return false; + } if (!params.jpeg_store_metadata && params.jpeg_strip_exif) { JxlEncoderFrameSettingsSetOption(settings, JXL_ENC_FRAME_SETTING_JPEG_KEEP_EXIF, 0); @@ -210,8 +222,8 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, basic_info.num_extra_channels = std::max(num_alpha_channels, ppf.info.num_extra_channels); basic_info.num_color_channels = ppf.info.num_color_channels; - const bool lossless = params.distance == 0; - basic_info.uses_original_profile = lossless; + const bool lossless = (params.distance == 0); + basic_info.uses_original_profile = TO_JXL_BOOL(lossless); if (params.override_bitdepth != 0) { basic_info.bits_per_sample = params.override_bitdepth; basic_info.exponent_bits_per_sample = @@ -233,7 +245,7 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, return false; } if (JXL_ENC_SUCCESS != - JxlEncoderSetFrameBitDepth(settings, ¶ms.input_bitdepth)) { + JxlEncoderSetFrameBitDepth(settings, &ppf.input_bitdepth)) { fprintf(stderr, "JxlEncoderSetFrameBitDepth() failed.\n"); return false; } @@ -248,7 +260,7 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, fprintf(stderr, "JxlEncoderSetFrameLossless() failed.\n"); return false; } - if (!ppf.icc.empty()) { + if (ppf.primary_color_representation == PackedPixelFile::kIccIsPrimary) { if (JXL_ENC_SUCCESS != JxlEncoderSetICCProfile(enc, ppf.icc.data(), ppf.icc.size())) { fprintf(stderr, "JxlEncoderSetICCProfile() failed.\n"); @@ -284,14 +296,15 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, {"jumb", ppf.metadata.jumbf}, {"xml ", ppf.metadata.iptc}, }; - for (size_t i = 0; i < sizeof boxes / sizeof *boxes; ++i) { - const BoxInfo& box = boxes[i]; - if (!box.bytes.empty() && - JXL_ENC_SUCCESS != JxlEncoderAddBox(enc, box.type, box.bytes.data(), - box.bytes.size(), - params.compress_boxes)) { - fprintf(stderr, "JxlEncoderAddBox() failed (%s).\n", box.type); - return false; + for (auto box : boxes) { + if (!box.bytes.empty()) { + if (JXL_ENC_SUCCESS != + JxlEncoderAddBox(enc, box.type, box.bytes.data(), + box.bytes.size(), + TO_JXL_BOOL(params.compress_boxes))) { + fprintf(stderr, "JxlEncoderAddBox() failed (%s).\n", box.type); + return false; + } } } JxlEncoderCloseBoxes(enc); @@ -336,7 +349,7 @@ bool EncodeImageJXL(const JXLCompressParams& params, const PackedPixelFile& ppf, } const bool last_frame = fi + 1 == ppf.chunked_frames.size(); if (JXL_ENC_SUCCESS != - JxlEncoderAddChunkedFrame(settings, last_frame, + JxlEncoderAddChunkedFrame(settings, TO_JXL_BOOL(last_frame), chunked_frame.GetInputSource())) { fprintf(stderr, "JxlEncoderAddChunkedFrame() failed.\n"); return false; diff --git a/third_party/jpeg-xl/lib/extras/enc/jxl.h b/third_party/jpeg-xl/lib/extras/enc/jxl.h index b8ca5bda2f..2b3793c0c4 100644 --- a/third_party/jpeg-xl/lib/extras/enc/jxl.h +++ b/third_party/jpeg-xl/lib/extras/enc/jxl.h @@ -38,7 +38,7 @@ struct JXLCompressParams { std::vector options; // Target butteraugli distance, 0.0 means lossless. float distance = 1.0f; - float alpha_distance = 1.0f; + float alpha_distance = 0.0f; // If set to true, forces container mode. bool use_container = false; // Whether to enable/disable byte-exact jpeg reconstruction for jpeg inputs. @@ -57,8 +57,6 @@ struct JXLCompressParams { size_t override_bitdepth = 0; int32_t codestream_level = -1; int32_t premultiply = -1; - // Override input buffer interpretation. - JxlBitDepth input_bitdepth = {JXL_BIT_DEPTH_FROM_PIXEL_FORMAT, 0, 0}; // If runner_opaque is set, the decoder uses this parallel runner. JxlParallelRunner runner = JxlThreadParallelRunner; void* runner_opaque = nullptr; @@ -69,10 +67,10 @@ struct JXLCompressParams { bool allow_expert_options = false; void AddOption(JxlEncoderFrameSettingId id, int64_t val) { - options.emplace_back(JXLOption(id, val, 0)); + options.emplace_back(id, val, 0); } void AddFloatOption(JxlEncoderFrameSettingId id, float val) { - options.emplace_back(JXLOption(id, val, 0)); + options.emplace_back(id, val, 0); } bool HasOutputProcessor() const { return (output_processor.get_buffer != nullptr && diff --git a/third_party/jpeg-xl/lib/extras/enc/npy.cc b/third_party/jpeg-xl/lib/extras/enc/npy.cc index ae8cf13cc4..8d9954ef31 100644 --- a/third_party/jpeg-xl/lib/extras/enc/npy.cc +++ b/third_party/jpeg-xl/lib/extras/enc/npy.cc @@ -7,11 +7,13 @@ #include +#include #include #include #include #include "lib/extras/packed_image.h" +#include "lib/jxl/base/common.h" namespace jxl { namespace extras { @@ -52,14 +54,17 @@ class JSONDict : public JSONField { static_assert(std::is_convertible::value, "T must be a JSONField"); T* ret = new T(); - values_.emplace_back( - key, std::unique_ptr(static_cast(ret))); + JSONField* field = static_cast(ret); + auto handle = std::unique_ptr(field); + values_.emplace_back(key, std::move(handle)); return ret; } template void Add(const std::string& key, const T& value) { - values_.emplace_back(key, std::unique_ptr(new JSONValue(value))); + JSONField* field = static_cast(new JSONValue(value)); + auto handle = std::unique_ptr(field); + values_.emplace_back(key, std::move(handle)); } void Write(std::ostream& o, uint32_t indent) const override { @@ -71,11 +76,11 @@ class JSONDict : public JSONField { o << ","; } is_first = false; - o << std::endl << indent_str << " \"" << key_value.first << "\": "; + o << "\n" << indent_str << " \"" << key_value.first << "\": "; key_value.second->Write(o, indent + 2); } if (!values_.empty()) { - o << std::endl << indent_str; + o << "\n" << indent_str; } o << "}"; } @@ -112,11 +117,11 @@ class JSONArray : public JSONField { o << ","; } is_first = false; - o << std::endl << indent_str << " "; + o << "\n" << indent_str << " "; value->Write(o, indent + 2); } if (!values_.empty()) { - o << std::endl << indent_str; + o << "\n" << indent_str; } o << "]"; } @@ -160,13 +165,13 @@ void GenerateMetadata(const PackedPixelFile& ppf, std::vector* out) { } { - auto ectype = meta.AddEmpty("extra_channel_type"); - auto bps = meta.AddEmpty("bits_per_sample"); - auto ebps = meta.AddEmpty("exp_bits_per_sample"); + auto* ectype = meta.AddEmpty("extra_channel_type"); + auto* bps = meta.AddEmpty("bits_per_sample"); + auto* ebps = meta.AddEmpty("exp_bits_per_sample"); bps->Add(ppf.info.bits_per_sample); ebps->Add(ppf.info.exponent_bits_per_sample); - for (size_t i = 0; i < ppf.extra_channels_info.size(); i++) { - switch (ppf.extra_channels_info[i].ec_info.type) { + for (const auto& eci : ppf.extra_channels_info) { + switch (eci.ec_info.type) { case JXL_CHANNEL_ALPHA: { ectype->Add(std::string("Alpha")); break; @@ -200,8 +205,8 @@ void GenerateMetadata(const PackedPixelFile& ppf, std::vector* out) { break; } } - bps->Add(ppf.extra_channels_info[i].ec_info.bits_per_sample); - ebps->Add(ppf.extra_channels_info[i].ec_info.exponent_bits_per_sample); + bps->Add(eci.ec_info.bits_per_sample); + ebps->Add(eci.ec_info.exponent_bits_per_sample); } } @@ -282,7 +287,7 @@ bool WriteNPYArray(const PackedPixelFile& ppf, std::vector* out) { class NumPyEncoder : public Encoder { public: Status Encode(const PackedPixelFile& ppf, EncodedImage* encoded_image, - ThreadPool* pool = nullptr) const override { + ThreadPool* pool) const override { JXL_RETURN_IF_ERROR(VerifyBasicInfo(ppf.info)); GenerateMetadata(ppf, &encoded_image->metadata); encoded_image->bitstreams.emplace_back(); diff --git a/third_party/jpeg-xl/lib/extras/enc/pgx.cc b/third_party/jpeg-xl/lib/extras/enc/pgx.cc index d4809e38b6..eb8eab4271 100644 --- a/third_party/jpeg-xl/lib/extras/enc/pgx.cc +++ b/third_party/jpeg-xl/lib/extras/enc/pgx.cc @@ -60,7 +60,7 @@ Status EncodeImagePGX(const PackedFrame& frame, const JxlBasicInfo& info, std::vector pixels(num_samples * bytes_per_sample); if (format.data_type == JXL_TYPE_UINT8) { - memcpy(&pixels[0], in, num_samples * bytes_per_sample); + memcpy(pixels.data(), in, num_samples * bytes_per_sample); } else if (format.data_type == JXL_TYPE_UINT16) { if (format.endianness != JXL_BIG_ENDIAN) { const uint8_t* p_in = in; @@ -69,7 +69,7 @@ Status EncodeImagePGX(const PackedFrame& frame, const JxlBasicInfo& info, StoreBE16(LoadLE16(p_in), p_out); } } else { - memcpy(&pixels[0], in, num_samples * bytes_per_sample); + memcpy(pixels.data(), in, num_samples * bytes_per_sample); } } else { return JXL_FAILURE("Unsupported pixel data type"); diff --git a/third_party/jpeg-xl/lib/extras/enc/pnm.cc b/third_party/jpeg-xl/lib/extras/enc/pnm.cc index 4183900198..966611cfca 100644 --- a/third_party/jpeg-xl/lib/extras/enc/pnm.cc +++ b/third_party/jpeg-xl/lib/extras/enc/pnm.cc @@ -31,7 +31,7 @@ constexpr size_t kMaxHeaderSize = 200; class BasePNMEncoder : public Encoder { public: Status Encode(const PackedPixelFile& ppf, EncodedImage* encoded_image, - ThreadPool* pool = nullptr) const override { + ThreadPool* pool) const override { JXL_RETURN_IF_ERROR(VerifyBasicInfo(ppf.info)); if (!ppf.metadata.exif.empty() || !ppf.metadata.iptc.empty() || !ppf.metadata.jumbf.empty() || !ppf.metadata.xmp.empty()) { diff --git a/third_party/jpeg-xl/lib/extras/jpegli_test.cc b/third_party/jpeg-xl/lib/extras/jpegli_test.cc index 66c18617a6..3049049a64 100644 --- a/third_party/jpeg-xl/lib/extras/jpegli_test.cc +++ b/third_party/jpeg-xl/lib/extras/jpegli_test.cc @@ -85,7 +85,7 @@ Status EncodeWithLibjpeg(const PackedPixelFile& ppf, int quality, std::unique_ptr encoder = GetJPEGEncoder(); encoder->SetOption("q", std::to_string(quality)); EncodedImage encoded; - JXL_RETURN_IF_ERROR(encoder->Encode(ppf, &encoded)); + JXL_RETURN_IF_ERROR(encoder->Encode(ppf, &encoded, nullptr)); JXL_RETURN_IF_ERROR(!encoded.bitstreams.empty()); *compressed = std::move(encoded.bitstreams[0]); return true; @@ -156,8 +156,8 @@ TEST(JpegliTest, JpegliXYBEncodeTest) { PackedPixelFile ppf_out; ASSERT_TRUE(DecodeWithLibjpeg(compressed, &ppf_out)); - EXPECT_THAT(BitsPerPixel(ppf_in, compressed), IsSlightlyBelow(1.45f)); - EXPECT_THAT(ButteraugliDistance(ppf_in, ppf_out), IsSlightlyBelow(1.32f)); + EXPECT_SLIGHTLY_BELOW(BitsPerPixel(ppf_in, compressed), 1.45f); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(ppf_in, ppf_out), 1.32f); } TEST(JpegliTest, JpegliDecodeTestLargeSmoothArea) { @@ -205,8 +205,8 @@ TEST(JpegliTest, JpegliYUVEncodeTest) { PackedPixelFile ppf_out; ASSERT_TRUE(DecodeWithLibjpeg(compressed, &ppf_out)); - EXPECT_THAT(BitsPerPixel(ppf_in, compressed), IsSlightlyBelow(1.7f)); - EXPECT_THAT(ButteraugliDistance(ppf_in, ppf_out), IsSlightlyBelow(1.32f)); + EXPECT_SLIGHTLY_BELOW(BitsPerPixel(ppf_in, compressed), 1.7f); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(ppf_in, ppf_out), 1.32f); } TEST(JpegliTest, JpegliYUVChromaSubsamplingEncodeTest) { @@ -247,8 +247,8 @@ TEST(JpegliTest, JpegliYUVEncodeTestNoAq) { PackedPixelFile ppf_out; ASSERT_TRUE(DecodeWithLibjpeg(compressed, &ppf_out)); - EXPECT_THAT(BitsPerPixel(ppf_in, compressed), IsSlightlyBelow(1.85f)); - EXPECT_THAT(ButteraugliDistance(ppf_in, ppf_out), IsSlightlyBelow(1.25f)); + EXPECT_SLIGHTLY_BELOW(BitsPerPixel(ppf_in, compressed), 1.85f); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(ppf_in, ppf_out), 1.25f); } TEST(JpegliTest, JpegliHDRRoundtripTest) { @@ -267,8 +267,8 @@ TEST(JpegliTest, JpegliHDRRoundtripTest) { JpegDecompressParams dparams; dparams.output_data_type = JXL_TYPE_UINT16; ASSERT_TRUE(DecodeJpeg(compressed, dparams, nullptr, &ppf_out)); - EXPECT_THAT(BitsPerPixel(ppf_in, compressed), IsSlightlyBelow(2.95f)); - EXPECT_THAT(ButteraugliDistance(ppf_in, ppf_out), IsSlightlyBelow(1.05f)); + EXPECT_SLIGHTLY_BELOW(BitsPerPixel(ppf_in, compressed), 2.95f); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(ppf_in, ppf_out), 1.05f); } TEST(JpegliTest, JpegliSetAppData) { diff --git a/third_party/jpeg-xl/lib/extras/mmap.cc b/third_party/jpeg-xl/lib/extras/mmap.cc index 7852831ebd..9f5bba97ed 100644 --- a/third_party/jpeg-xl/lib/extras/mmap.cc +++ b/third_party/jpeg-xl/lib/extras/mmap.cc @@ -10,7 +10,8 @@ #include "lib/jxl/base/common.h" -#if __unix__ +#if defined(__unix__) || defined(__unix) || \ + defined(__APPLE__) && defined(__MACH__) #include #include #include @@ -54,7 +55,7 @@ struct MemoryMappedFileImpl { } // namespace jxl -#elif __WIN32__ +#elif defined(_WIN32) #include #include @@ -97,6 +98,8 @@ struct MemoryMappedFileImpl { return f; } + ~MemoryMappedFileImpl() { UnmapViewOfFile(ptr); } + const uint8_t* data() const { return reinterpret_cast(ptr); } size_t size() const { return fsize.QuadPart; } diff --git a/third_party/jpeg-xl/lib/extras/packed_image.h b/third_party/jpeg-xl/lib/extras/packed_image.h index edd5f1be75..a66ddfbd70 100644 --- a/third_party/jpeg-xl/lib/extras/packed_image.h +++ b/third_party/jpeg-xl/lib/extras/packed_image.h @@ -37,11 +37,18 @@ namespace extras { // Class representing an interleaved image with a bunch of channels. class PackedImage { public: - PackedImage(size_t xsize, size_t ysize, const JxlPixelFormat& format) - : PackedImage(xsize, ysize, format, CalcStride(format, xsize)) {} + static StatusOr Create(size_t xsize, size_t ysize, + const JxlPixelFormat& format) { + PackedImage image(xsize, ysize, format, CalcStride(format, xsize)); + if (!image.pixels()) { + // TODO(szabadka): use specialized OOM error code + return JXL_FAILURE("Failed to allocate memory for image"); + } + return image; + } PackedImage Copy() const { - PackedImage copy(xsize, ysize, format); + PackedImage copy(xsize, ysize, format, CalcStride(format, xsize)); memcpy(reinterpret_cast(copy.pixels()), reinterpret_cast(pixels()), pixels_size); return copy; @@ -108,7 +115,7 @@ class PackedImage { } } - void SetPixelValue(size_t y, size_t x, size_t c, float val) { + void SetPixelValue(size_t y, size_t x, size_t c, float val) const { uint8_t* data = pixels(y, x, c); switch (format.data_type) { case JXL_TYPE_UINT8: @@ -169,17 +176,25 @@ class PackedImage { // as all other frames in the same image. class PackedFrame { public: - template - explicit PackedFrame(Args&&... args) : color(std::forward(args)...) {} + explicit PackedFrame(PackedImage&& image) : color(std::move(image)) {} + + static StatusOr Create(size_t xsize, size_t ysize, + const JxlPixelFormat& format) { + JXL_ASSIGN_OR_RETURN(PackedImage image, + PackedImage::Create(xsize, ysize, format)); + PackedFrame frame(std::move(image)); + return frame; + } - PackedFrame Copy() const { - PackedFrame copy(color.xsize, color.ysize, color.format); + StatusOr Copy() const { + JXL_ASSIGN_OR_RETURN( + PackedFrame copy, + PackedFrame::Create(color.xsize, color.ysize, color.format)); copy.frame_info = frame_info; copy.name = name; copy.color = color.Copy(); - for (size_t i = 0; i < extra_channels.size(); ++i) { - PackedImage ec = extra_channels[i].Copy(); - copy.extra_channels.emplace_back(std::move(ec)); + for (const auto& ec : extra_channels) { + copy.extra_channels.emplace_back(ec.Copy()); } return copy; } @@ -244,12 +259,26 @@ class PackedPixelFile { std::vector extra_channels_info; // Color information of the decoded pixels. - // If the icc is empty, the JxlColorEncoding should be used instead. - std::vector icc; + // `primary_color_representation` indicates whether `color_encoding` or `icc` + // is the “authoritative” encoding of the colorspace, as opposed to a fallback + // encoding. For example, if `color_encoding` is the primary one, as would + // occur when decoding a jxl file with such a representation, then `enc/jxl` + // will use it and ignore the ICC profile, whereas `enc/png` will include the + // ICC profile for compatibility. + // If `icc` is the primary representation, `enc/jxl` will preserve it when + // compressing losslessly, but *may* encode it as a color_encoding when + // compressing lossily. + enum { + kColorEncodingIsPrimary, + kIccIsPrimary + } primary_color_representation = kColorEncodingIsPrimary; JxlColorEncoding color_encoding = {}; + std::vector icc; // The icc profile of the original image. std::vector orig_icc; + JxlBitDepth input_bitdepth = {JXL_BIT_DEPTH_FROM_PIXEL_FORMAT, 0, 0}; + std::unique_ptr preview_frame; std::vector frames; mutable std::vector chunked_frames; diff --git a/third_party/jpeg-xl/lib/extras/packed_image_convert.cc b/third_party/jpeg-xl/lib/extras/packed_image_convert.cc index 56f3b044a4..2ad001bf09 100644 --- a/third_party/jpeg-xl/lib/extras/packed_image_convert.cc +++ b/third_party/jpeg-xl/lib/extras/packed_image_convert.cc @@ -22,15 +22,15 @@ namespace jxl { namespace extras { Status ConvertPackedFrameToImageBundle(const JxlBasicInfo& info, + const JxlBitDepth& input_bitdepth, const PackedFrame& frame, const CodecInOut& io, ThreadPool* pool, ImageBundle* bundle) { JXL_ASSERT(frame.color.pixels() != nullptr); - const bool float_in = frame.color.format.data_type == JXL_TYPE_FLOAT16 || - frame.color.format.data_type == JXL_TYPE_FLOAT; size_t frame_bits_per_sample = - float_in ? PackedImage::BitsPerChannel(frame.color.format.data_type) - : info.bits_per_sample; + input_bitdepth.type == JXL_BIT_DEPTH_FROM_PIXEL_FORMAT + ? PackedImage::BitsPerChannel(frame.color.format.data_type) + : info.bits_per_sample; JXL_ASSERT(frame_bits_per_sample != 0); // It is ok for the frame.color.format.num_channels to not match the // number of channels on the image. @@ -64,7 +64,8 @@ Status ConvertPackedFrameToImageBundle(const JxlBasicInfo& info, bundle->extra_channels().resize(io.metadata.m.extra_channel_info.size()); for (size_t i = 0; i < frame.extra_channels.size(); i++) { const auto& ppf_ec = frame.extra_channels[i]; - bundle->extra_channels()[i] = ImageF(ppf_ec.xsize, ppf_ec.ysize); + JXL_ASSIGN_OR_RETURN(bundle->extra_channels()[i], + ImageF::Create(ppf_ec.xsize, ppf_ec.ysize)); JXL_CHECK(BufferToImageF(ppf_ec.format, ppf_ec.xsize, ppf_ec.ysize, ppf_ec.pixels(), ppf_ec.pixels_size, pool, &bundle->extra_channels()[i])); @@ -97,23 +98,23 @@ Status ConvertPackedPixelFileToCodecInOut(const PackedPixelFile& ppf, ppf.info.exponent_bits_per_sample == 0 && ppf.info.bits_per_sample <= 12; io->metadata.m.SetAlphaBits(ppf.info.alpha_bits, - ppf.info.alpha_premultiplied); + FROM_JXL_BOOL(ppf.info.alpha_premultiplied)); ExtraChannelInfo* alpha = io->metadata.m.Find(ExtraChannel::kAlpha); if (alpha) alpha->bit_depth = io->metadata.m.bit_depth; - io->metadata.m.xyb_encoded = !ppf.info.uses_original_profile; + io->metadata.m.xyb_encoded = !FROM_JXL_BOOL(ppf.info.uses_original_profile); JXL_ASSERT(ppf.info.orientation > 0 && ppf.info.orientation <= 8); io->metadata.m.orientation = ppf.info.orientation; // Convert animation metadata JXL_ASSERT(ppf.frames.size() == 1 || ppf.info.have_animation); - io->metadata.m.have_animation = ppf.info.have_animation; + io->metadata.m.have_animation = FROM_JXL_BOOL(ppf.info.have_animation); io->metadata.m.animation.tps_numerator = ppf.info.animation.tps_numerator; io->metadata.m.animation.tps_denominator = ppf.info.animation.tps_denominator; io->metadata.m.animation.num_loops = ppf.info.animation.num_loops; // Convert the color encoding. - if (!ppf.icc.empty()) { + if (ppf.primary_color_representation == PackedPixelFile::kIccIsPrimary) { IccBytes icc = ppf.icc; if (!io->metadata.m.color_encoding.SetICC(std::move(icc), JxlGetDefaultCms())) { @@ -170,15 +171,16 @@ Status ConvertPackedPixelFileToCodecInOut(const PackedPixelFile& ppf, JXL_RETURN_IF_ERROR( io->metadata.m.preview_size.Set(preview_xsize, preview_ysize)); JXL_RETURN_IF_ERROR(ConvertPackedFrameToImageBundle( - ppf.info, *ppf.preview_frame, *io, pool, &io->preview_frame)); + ppf.info, ppf.input_bitdepth, *ppf.preview_frame, *io, pool, + &io->preview_frame)); } // Convert the pixels io->frames.clear(); for (const auto& frame : ppf.frames) { ImageBundle bundle(&io->metadata.m); - JXL_RETURN_IF_ERROR( - ConvertPackedFrameToImageBundle(ppf.info, frame, *io, pool, &bundle)); + JXL_RETURN_IF_ERROR(ConvertPackedFrameToImageBundle( + ppf.info, ppf.input_bitdepth, frame, *io, pool, &bundle)); io->frames.push_back(std::move(bundle)); } @@ -210,7 +212,8 @@ PackedPixelFile ConvertImage3FToPackedPixelFile(const Image3F& image, : 0; ppf.color_encoding = c_enc.ToExternal(); ppf.frames.clear(); - PackedFrame frame(image.xsize(), image.ysize(), format); + JXL_ASSIGN_OR_DIE(PackedFrame frame, + PackedFrame::Create(image.xsize(), image.ysize(), format)); const ImageF* channels[3]; for (int c = 0; c < 3; ++c) { channels[c] = &image.Plane(c); @@ -242,7 +245,8 @@ Status ConvertCodecInOutToPackedPixelFile(const CodecInOut& io, ppf->info.alpha_bits = alpha_channel->bit_depth.bits_per_sample; ppf->info.alpha_exponent_bits = alpha_channel->bit_depth.exponent_bits_per_sample; - ppf->info.alpha_premultiplied = alpha_channel->alpha_associated; + ppf->info.alpha_premultiplied = + TO_JXL_BOOL(alpha_channel->alpha_associated); } // Convert the image metadata @@ -257,9 +261,9 @@ Status ConvertCodecInOutToPackedPixelFile(const CodecInOut& io, ppf->info.linear_below = io.metadata.m.tone_mapping.linear_below; ppf->info.min_nits = io.metadata.m.tone_mapping.min_nits; ppf->info.relative_to_max_display = - io.metadata.m.tone_mapping.relative_to_max_display; + TO_JXL_BOOL(io.metadata.m.tone_mapping.relative_to_max_display); - ppf->info.uses_original_profile = !io.metadata.m.xyb_encoded; + ppf->info.uses_original_profile = TO_JXL_BOOL(!io.metadata.m.xyb_encoded); JXL_ASSERT(0 < io.metadata.m.orientation && io.metadata.m.orientation <= 8); ppf->info.orientation = static_cast(io.metadata.m.orientation); @@ -267,13 +271,16 @@ Status ConvertCodecInOutToPackedPixelFile(const CodecInOut& io, // Convert animation metadata JXL_ASSERT(io.frames.size() == 1 || io.metadata.m.have_animation); - ppf->info.have_animation = io.metadata.m.have_animation; + ppf->info.have_animation = TO_JXL_BOOL(io.metadata.m.have_animation); ppf->info.animation.tps_numerator = io.metadata.m.animation.tps_numerator; ppf->info.animation.tps_denominator = io.metadata.m.animation.tps_denominator; ppf->info.animation.num_loops = io.metadata.m.animation.num_loops; // Convert the color encoding ppf->icc.assign(c_desired.ICC().begin(), c_desired.ICC().end()); + ppf->primary_color_representation = + c_desired.WantICC() ? PackedPixelFile::kIccIsPrimary + : PackedPixelFile::kColorEncodingIsPrimary; ppf->color_encoding = c_desired.ToExternal(); // Convert the extra blobs @@ -289,22 +296,24 @@ Status ConvertCodecInOutToPackedPixelFile(const CodecInOut& io, JXL_ASSERT(frame.metadata()->bit_depth.bits_per_sample != 0); // It is ok for the frame.color().kNumPlanes to not match the // number of channels on the image. + const uint32_t alpha_channels = has_alpha ? 1 : 0; const uint32_t num_channels = - frame.metadata()->color_encoding.Channels() + has_alpha; + frame.metadata()->color_encoding.Channels() + alpha_channels; JxlPixelFormat format{/*num_channels=*/num_channels, /*data_type=*/pixel_format.data_type, /*endianness=*/pixel_format.endianness, /*align=*/pixel_format.align}; - PackedFrame packed_frame(frame.oriented_xsize(), frame.oriented_ysize(), - format); + JXL_ASSIGN_OR_RETURN(PackedFrame packed_frame, + PackedFrame::Create(frame.oriented_xsize(), + frame.oriented_ysize(), format)); const size_t bits_per_sample = float_out ? packed_frame.color.BitsPerChannel(pixel_format.data_type) : ppf->info.bits_per_sample; packed_frame.name = frame.name; packed_frame.frame_info.name_length = frame.name.size(); // Color transform - ImageBundle ib = frame.Copy(); + JXL_ASSIGN_OR_RETURN(ImageBundle ib, frame.Copy()); const ImageBundle* to_color_transform = &ib; ImageMetadata metadata = io.metadata.m; ImageBundle store(&metadata); diff --git a/third_party/jpeg-xl/lib/extras/tone_mapping.cc b/third_party/jpeg-xl/lib/extras/tone_mapping.cc index 3d0269524b..39df304501 100644 --- a/third_party/jpeg-xl/lib/extras/tone_mapping.cc +++ b/third_party/jpeg-xl/lib/extras/tone_mapping.cc @@ -19,7 +19,7 @@ HWY_BEFORE_NAMESPACE(); namespace jxl { namespace HWY_NAMESPACE { -static constexpr float rec2020_luminances[3] = {0.2627f, 0.6780f, 0.0593f}; +static constexpr Vector3 rec2020_luminances{0.2627f, 0.6780f, 0.0593f}; Status ToneMapFrame(const std::pair display_nits, ImageBundle* const ib, ThreadPool* const pool) { diff --git a/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc b/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc index 34cbdde781..8fc928a4fd 100644 --- a/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc +++ b/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc @@ -6,11 +6,12 @@ #include "benchmark/benchmark.h" #include "lib/extras/codec.h" #include "lib/extras/tone_mapping.h" +#include "lib/jxl/image.h" namespace jxl { static void BM_ToneMapping(benchmark::State& state) { - Image3F color(2268, 1512); + JXL_ASSIGN_OR_DIE(Image3F color, Image3F::Create(2268, 1512)); FillImage(0.5f, &color); // Use linear Rec. 2020 so that `ToneMapTo` doesn't have to convert to it and @@ -25,7 +26,8 @@ static void BM_ToneMapping(benchmark::State& state) { for (auto _ : state) { state.PauseTiming(); CodecInOut tone_mapping_input; - Image3F color2(color.xsize(), color.ysize()); + JXL_ASSIGN_OR_DIE(Image3F color2, + Image3F::Create(color.xsize(), color.ysize())); CopyImageTo(color, &color2); tone_mapping_input.SetFromImage(std::move(color2), linear_rec2020); tone_mapping_input.metadata.m.SetIntensityTarget(255); diff --git a/third_party/jpeg-xl/lib/include/jxl/cms_interface.h b/third_party/jpeg-xl/lib/include/jxl/cms_interface.h index c164eaccb5..25c700867a 100644 --- a/third_party/jpeg-xl/lib/include/jxl/cms_interface.h +++ b/third_party/jpeg-xl/lib/include/jxl/cms_interface.h @@ -29,10 +29,10 @@ extern "C" { /** Parses an ICC profile and populates @p c and @p cmyk with the data. * - * @param user_data JxlCmsInterface::set_fields_data passed as-is. + * @param user_data @ref JxlCmsInterface::set_fields_data passed as-is. * @param icc_data the ICC data to parse. * @param icc_size how many bytes of icc_data are valid. - * @param c a JxlColorEncoding to populate if applicable. + * @param c a @ref JxlColorEncoding to populate if applicable. * @param cmyk a boolean to set to whether the colorspace is a CMYK colorspace. * @return Whether the relevant fields in @p c were successfully populated. */ @@ -66,22 +66,23 @@ typedef struct { /** Allocates and returns the data needed for @p num_threads parallel transforms * from the @p input colorspace to @p output, with up to @p pixels_per_thread - * pixels to transform per call to JxlCmsInterface::run. @p init_data comes - * directly from the JxlCmsInterface instance. Since @c run only receives the - * data returned by @c init, a reference to @p init_data should be kept there - * if access to it is desired in @c run. Likewise for JxlCmsInterface::destroy. + * pixels to transform per call to @ref JxlCmsInterface::run. @p init_data comes + * directly from the @ref JxlCmsInterface instance. Since @c run only receives + * the data returned by @c init, a reference to @p init_data should be kept + * there if access to it is desired in @c run. Likewise for @ref + * JxlCmsInterface::destroy. * * The ICC data in @p input and @p output is guaranteed to outlive the @c init / * @c run / @c destroy cycle. * - * @param init_data JxlCmsInterface::init_data passed as-is. + * @param init_data @ref JxlCmsInterface::init_data passed as-is. * @param num_threads the maximum number of threads from which - * JxlCmsInterface::run will be called. + * @ref JxlCmsInterface::run will be called. * @param pixels_per_thread the maximum number of pixels that each call to - * JxlCmsInterface::run will have to transform. + * @ref JxlCmsInterface::run will have to transform. * @param input_profile the input colorspace for the transform. - * @param output_profile the colorspace to which JxlCmsInterface::run should - * convert the input data. + * @param output_profile the colorspace to which @ref JxlCmsInterface::run + * should convert the input data. * @param intensity_target for colorspaces where luminance is relative * (essentially: not PQ), indicates the luminance at which (1, 1, 1) will * be displayed. This is useful for conversions between PQ and a relative @@ -135,7 +136,7 @@ typedef float* (*jpegxl_cms_get_buffer_func)(void* user_data, size_t thread); * @param output_buffer the buffer receiving the transformed pixel data. * @param num_pixels the number of pixels to transform from @p input to * @p output. - * @return JXL_TRUE on success, JXL_FALSE on failure. + * @return ::JXL_TRUE on success, ::JXL_FALSE on failure. */ typedef JXL_BOOL (*jpegxl_cms_run_func)(void* user_data, size_t thread, const float* input_buffer, @@ -226,7 +227,7 @@ typedef void (*jpegxl_cms_destroy_func)(void*); typedef struct { /** CMS-specific data that will be passed to @ref set_fields_from_icc. */ void* set_fields_data; - /** Populates a JxlColorEncoding from an ICC profile. */ + /** Populates a @ref JxlColorEncoding from an ICC profile. */ jpegxl_cms_set_fields_from_icc_func set_fields_from_icc; /** CMS-specific data that will be passed to @ref init. */ diff --git a/third_party/jpeg-xl/lib/include/jxl/codestream_header.h b/third_party/jpeg-xl/lib/include/jxl/codestream_header.h index fb71484233..e60eb03355 100644 --- a/third_party/jpeg-xl/lib/include/jxl/codestream_header.h +++ b/third_party/jpeg-xl/lib/include/jxl/codestream_header.h @@ -71,7 +71,7 @@ typedef struct { } JxlPreviewHeader; /** The codestream animation header, optionally present in the beginning of - * the codestream, and if it is it applies to all animation frames, unlike + * the codestream, and if it is it applies to all animation frames, unlike @ref * JxlFrameHeader which applies to an individual frame. */ typedef struct { @@ -166,12 +166,12 @@ typedef struct { * it to to the original color profile. The decoder also does not convert to * the target display color profile. To convert the pixel data produced by * the decoder to the original color profile, one of the JxlDecoderGetColor* - * functions needs to be called with @ref JXL_COLOR_PROFILE_TARGET_DATA to get - * the color profile of the decoder output, and then an external CMS can be - * used for conversion. - * Note that for lossy compression, this should be set to false for most use - * cases, and if needed, the image should be converted to the original color - * profile after decoding, as described above. + * functions needs to be called with + * ::JXL_COLOR_PROFILE_TARGET_DATA to get the color profile of the decoder + * output, and then an external CMS can be used for conversion. Note that for + * lossy compression, this should be set to false for most use cases, and if + * needed, the image should be converted to the original color profile after + * decoding, as described above. */ JXL_BOOL uses_original_profile; @@ -194,17 +194,19 @@ typedef struct { * grayscale data, or 3 for colored data. This count does not include * the alpha channel or other extra channels. To check presence of an alpha * channel, such as in the case of RGBA color, check alpha_bits != 0. - * If and only if this is 1, the JxlColorSpace in the JxlColorEncoding is - * JXL_COLOR_SPACE_GRAY. + * If and only if this is 1, the @ref JxlColorSpace in the @ref + * JxlColorEncoding is + * ::JXL_COLOR_SPACE_GRAY. */ uint32_t num_color_channels; /** Number of additional image channels. This includes the main alpha channel, * but can also include additional channels such as depth, additional alpha * channels, spot colors, and so on. Information about the extra channels - * can be queried with JxlDecoderGetExtraChannelInfo. The main alpha channel, - * if it exists, also has its information available in the alpha_bits, - * alpha_exponent_bits and alpha_premultiplied fields in this JxlBasicInfo. + * can be queried with @ref JxlDecoderGetExtraChannelInfo. The main alpha + * channel, if it exists, also has its information available in the + * alpha_bits, alpha_exponent_bits and alpha_premultiplied fields in this @ref + * JxlBasicInfo. */ uint32_t num_extra_channels; @@ -388,7 +390,8 @@ typedef struct { /** The header of one displayed frame or non-coalesced layer. */ typedef struct { /** How long to wait after rendering in ticks. The duration in seconds of a - * tick is given by tps_numerator and tps_denominator in JxlAnimationHeader. + * tick is given by tps_numerator and tps_denominator in @ref + * JxlAnimationHeader. */ uint32_t duration; @@ -396,9 +399,9 @@ typedef struct { * interpreted from most-significant to least-significant as hour, minute, * second, and frame. If timecode is nonzero, it is strictly larger than that * of a previous frame with nonzero duration. These values are only available - * if have_timecodes in JxlAnimationHeader is JXL_TRUE. - * This value is only used if have_timecodes in JxlAnimationHeader is - * JXL_TRUE. + * if have_timecodes in @ref JxlAnimationHeader is ::JXL_TRUE. + * This value is only used if have_timecodes in @ref JxlAnimationHeader is + * ::JXL_TRUE. */ uint32_t timecode; diff --git a/third_party/jpeg-xl/lib/include/jxl/color_encoding.h b/third_party/jpeg-xl/lib/include/jxl/color_encoding.h index 928117e8dd..e6325dcb30 100644 --- a/third_party/jpeg-xl/lib/include/jxl/color_encoding.h +++ b/third_party/jpeg-xl/lib/include/jxl/color_encoding.h @@ -24,9 +24,9 @@ extern "C" { typedef enum { /** Tristimulus RGB */ JXL_COLOR_SPACE_RGB, - /** Luminance based, the primaries in JxlColorEncoding must be ignored. This - * value implies that num_color_channels in JxlBasicInfo is 1, any other value - * implies num_color_channels is 3. */ + /** Luminance based, the primaries in @ref JxlColorEncoding must be ignored. + * This value implies that num_color_channels in @ref JxlBasicInfo is 1, any + * other value implies num_color_channels is 3. */ JXL_COLOR_SPACE_GRAY, /** XYB (opsin) color space */ JXL_COLOR_SPACE_XYB, @@ -35,18 +35,18 @@ typedef enum { } JxlColorSpace; /** Built-in whitepoints for color encoding. When decoding, the numerical xy - * whitepoint value can be read from the JxlColorEncoding white_point field + * whitepoint value can be read from the @ref JxlColorEncoding white_point field * regardless of the enum value. When encoding, enum values except - * JXL_WHITE_POINT_CUSTOM override the numerical fields. Some enum values match - * a subset of CICP (Rec. ITU-T H.273 | ISO/IEC 23091-2:2019(E)), however the - * white point and RGB primaries are separate enums here. + * ::JXL_WHITE_POINT_CUSTOM override the numerical fields. Some enum values + * match a subset of CICP (Rec. ITU-T H.273 | ISO/IEC 23091-2:2019(E)), however + * the white point and RGB primaries are separate enums here. */ typedef enum { /** CIE Standard Illuminant D65: 0.3127, 0.3290 */ JXL_WHITE_POINT_D65 = 1, - /** White point must be read from the JxlColorEncoding white_point field, or - * as ICC profile. This enum value is not an exact match of the corresponding - * CICP value. */ + /** White point must be read from the @ref JxlColorEncoding white_point field, + * or as ICC profile. This enum value is not an exact match of the + * corresponding CICP value. */ JXL_WHITE_POINT_CUSTOM = 2, /** CIE Standard Illuminant E (equal-energy): 1/3, 1/3 */ JXL_WHITE_POINT_E = 10, @@ -55,10 +55,10 @@ typedef enum { } JxlWhitePoint; /** Built-in primaries for color encoding. When decoding, the primaries can be - * read from the JxlColorEncoding primaries_red_xy, primaries_green_xy and + * read from the @ref JxlColorEncoding primaries_red_xy, primaries_green_xy and * primaries_blue_xy fields regardless of the enum value. When encoding, the - * enum values except JXL_PRIMARIES_CUSTOM override the numerical fields. Some - * enum values match a subset of CICP (Rec. ITU-T H.273 | ISO/IEC + * enum values except ::JXL_PRIMARIES_CUSTOM override the numerical fields. + * Some enum values match a subset of CICP (Rec. ITU-T H.273 | ISO/IEC * 23091-2:2019(E)), however the white point and RGB primaries are separate * enums here. */ @@ -66,7 +66,7 @@ typedef enum { /** The CIE xy values of the red, green and blue primaries are: 0.639998686, 0.330010138; 0.300003784, 0.600003357; 0.150002046, 0.059997204 */ JXL_PRIMARIES_SRGB = 1, - /** Primaries must be read from the JxlColorEncoding primaries_red_xy, + /** Primaries must be read from the @ref JxlColorEncoding primaries_red_xy, * primaries_green_xy and primaries_blue_xy fields, or as ICC profile. This * enum value is not an exact match of the corresponding CICP value. */ JXL_PRIMARIES_CUSTOM = 2, @@ -94,7 +94,7 @@ typedef enum { JXL_TRANSFER_FUNCTION_DCI = 17, /** As specified in Rec. ITU-R BT.2100-1 (HLG) */ JXL_TRANSFER_FUNCTION_HLG = 18, - /** Transfer function follows power law given by the gamma value in + /** Transfer function follows power law given by the gamma value in @ref JxlColorEncoding. Not a CICP value. */ JXL_TRANSFER_FUNCTION_GAMMA = 65535, } JxlTransferFunction; @@ -118,7 +118,7 @@ typedef struct { */ JxlColorSpace color_space; - /** Built-in white point. If this value is JXL_WHITE_POINT_CUSTOM, must + /** Built-in white point. If this value is ::JXL_WHITE_POINT_CUSTOM, must * use the numerical whitepoint values from white_point_xy. */ JxlWhitePoint white_point; @@ -126,10 +126,10 @@ typedef struct { /** Numerical whitepoint values in CIE xy space. */ double white_point_xy[2]; - /** Built-in RGB primaries. If this value is JXL_PRIMARIES_CUSTOM, must + /** Built-in RGB primaries. If this value is ::JXL_PRIMARIES_CUSTOM, must * use the numerical primaries values below. This field and the custom values * below are unused and must be ignored if the color space is - * JXL_COLOR_SPACE_GRAY or JXL_COLOR_SPACE_XYB. + * ::JXL_COLOR_SPACE_GRAY or ::JXL_COLOR_SPACE_XYB. */ JxlPrimaries primaries; @@ -145,7 +145,8 @@ typedef struct { /** Transfer function if have_gamma is 0 */ JxlTransferFunction transfer_function; - /** Gamma value used when transfer_function is JXL_TRANSFER_FUNCTION_GAMMA + /** Gamma value used when transfer_function is @ref + * JXL_TRANSFER_FUNCTION_GAMMA */ double gamma; diff --git a/third_party/jpeg-xl/lib/include/jxl/decode.h b/third_party/jpeg-xl/lib/include/jxl/decode.h index eaee70fa61..599b8336f3 100644 --- a/third_party/jpeg-xl/lib/include/jxl/decode.h +++ b/third_party/jpeg-xl/lib/include/jxl/decode.h @@ -66,12 +66,12 @@ typedef enum { * @p size doesn't need to be a full image, only the beginning of the file. * * @return a flag indicating if a JPEG XL signature was found and what type. - * - @ref JXL_SIG_NOT_ENOUGH_BYTES if not enough bytes were passed to + * - ::JXL_SIG_NOT_ENOUGH_BYTES if not enough bytes were passed to * determine if a valid signature is there. - * - @ref JXL_SIG_INVALID if no valid signature found for JPEG XL decoding. - * - @ref JXL_SIG_CODESTREAM if a valid JPEG XL codestream signature was + * - ::JXL_SIG_INVALID if no valid signature found for JPEG XL decoding. + * - ::JXL_SIG_CODESTREAM if a valid JPEG XL codestream signature was * found. - * - @ref JXL_SIG_CONTAINER if a valid JPEG XL container signature was found. + * - ::JXL_SIG_CONTAINER if a valid JPEG XL container signature was found. */ JXL_EXPORT JxlSignature JxlSignatureCheck(const uint8_t* buf, size_t len); @@ -115,7 +115,7 @@ JXL_EXPORT void JxlDecoderDestroy(JxlDecoder* dec); /** * Return value for @ref JxlDecoderProcessInput. - * The values from @ref JXL_DEC_BASIC_INFO onwards are optional informative + * The values from ::JXL_DEC_BASIC_INFO onwards are optional informative * events that can be subscribed to, they are never returned if they * have not been registered with @ref JxlDecoderSubscribeEvents. */ @@ -123,12 +123,12 @@ typedef enum { /** Function call finished successfully, or decoding is finished and there is * nothing more to be done. * - * Note that @ref JxlDecoderProcessInput will return JXL_DEC_SUCCESS if all - * events that were registered with @ref JxlDecoderSubscribeEvents were + * Note that @ref JxlDecoderProcessInput will return ::JXL_DEC_SUCCESS if + * all events that were registered with @ref JxlDecoderSubscribeEvents were * processed, even before the end of the JPEG XL codestream. * * In this case, the return value @ref JxlDecoderReleaseInput will be the same - * as it was at the last signaled event. E.g. if JXL_DEC_FULL_IMAGE was + * as it was at the last signaled event. E.g. if ::JXL_DEC_FULL_IMAGE was * subscribed to, then all bytes from the end of the JPEG XL codestream * (including possible boxes needed for jpeg reconstruction) will be returned * as unprocessed. @@ -151,14 +151,14 @@ typedef enum { * In most cases, @ref JxlDecoderReleaseInput will return no unprocessed bytes * at this event, the only exceptions are if the previously set input ended * within (a) the raw codestream signature, (b) the signature box, (c) a box - * header, or (d) the first 4 bytes of a brob, ftyp, or jxlp box. In any of - * these cases the number of unprocessed bytes is less than 20. + * header, or (d) the first 4 bytes of a `brob`, `ftyp`, or `jxlp` box. In any + * of these cases the number of unprocessed bytes is less than 20. */ JXL_DEC_NEED_MORE_INPUT = 2, /** The decoder is able to decode a preview image and requests setting a * preview output buffer using @ref JxlDecoderSetPreviewOutBuffer. This occurs - * if @ref JXL_DEC_PREVIEW_IMAGE is requested and it is possible to decode a + * if ::JXL_DEC_PREVIEW_IMAGE is requested and it is possible to decode a * preview image from the codestream and the preview out buffer was not yet * set. There is maximum one preview image in a codestream. * In this case, @ref JxlDecoderReleaseInput will return all bytes from the @@ -179,13 +179,13 @@ typedef enum { /** The JPEG reconstruction buffer is too small for reconstructed JPEG * codestream to fit. @ref JxlDecoderSetJPEGBuffer must be called again to * make room for remaining bytes. This event may occur multiple times - * after @ref JXL_DEC_JPEG_RECONSTRUCTION. + * after ::JXL_DEC_JPEG_RECONSTRUCTION. */ JXL_DEC_JPEG_NEED_MORE_OUTPUT = 6, /** The box contents output buffer is too small. @ref JxlDecoderSetBoxBuffer * must be called again to make room for remaining bytes. This event may occur - * multiple times after @ref JXL_DEC_BOX. + * multiple times after ::JXL_DEC_BOX. */ JXL_DEC_BOX_NEED_MORE_OUTPUT = 7, @@ -201,7 +201,7 @@ typedef enum { /** Informative event by @ref JxlDecoderProcessInput * "JxlDecoderProcessInput": Color encoding or ICC profile from the * codestream header. This event occurs max once per image and always later - * than @ref JXL_DEC_BASIC_INFO and earlier than any pixel data. + * than ::JXL_DEC_BASIC_INFO and earlier than any pixel data. * In this case, @ref JxlDecoderReleaseInput will return all bytes from the * end of the image header (which is the start of the first frame) as * unprocessed. @@ -212,7 +212,7 @@ typedef enum { * "JxlDecoderProcessInput": Preview image, a small frame, decoded. This * event can only happen if the image has a preview frame encoded. This event * occurs max once for the codestream and always later than @ref - * JXL_DEC_COLOR_ENCODING and before @ref JXL_DEC_FRAME. + * JXL_DEC_COLOR_ENCODING and before ::JXL_DEC_FRAME. * In this case, @ref JxlDecoderReleaseInput will return all bytes from the * end of the preview frame as unprocessed. */ @@ -223,19 +223,19 @@ typedef enum { * JxlDecoderGetFrameHeader can be used at this point. A note on frames: * a JPEG XL image can have internal frames that are not intended to be * displayed (e.g. used for compositing a final frame), but this only returns - * displayed frames, unless @ref JxlDecoderSetCoalescing was set to JXL_FALSE: - * in that case, the individual layers are returned, without blending. Note - * that even when coalescing is disabled, only frames of type kRegularFrame - * are returned; frames of type kReferenceOnly and kLfFrame are always for - * internal purposes only and cannot be accessed. A displayed frame either has - * an animation duration or is the only or last frame in the image. This event - * occurs max once per displayed frame, always later than @ref - * JXL_DEC_COLOR_ENCODING, and always earlier than any pixel data. While - * JPEG XL supports encoding a single frame as the composition of multiple - * internal sub-frames also called frames, this event is not indicated for the - * internal frames. - * In this case, @ref JxlDecoderReleaseInput will return all bytes from the - * end of the frame header (including ToC) as unprocessed. + * displayed frames, unless @ref JxlDecoderSetCoalescing was set to @ref + * JXL_FALSE "JXL_FALSE": in that case, the individual layers are returned, + * without blending. Note that even when coalescing is disabled, only frames + * of type kRegularFrame are returned; frames of type kReferenceOnly + * and kLfFrame are always for internal purposes only and cannot be accessed. + * A displayed frame either has an animation duration or is the only or last + * frame in the image. This event occurs max once per displayed frame, always + * later than ::JXL_DEC_COLOR_ENCODING, and always earlier than any pixel + * data. While JPEG XL supports encoding a single frame as the composition of + * multiple internal sub-frames also called frames, this event is not + * indicated for the internal frames. In this case, @ref + * JxlDecoderReleaseInput will return all bytes from the end of the frame + * header (including ToC) as unprocessed. */ JXL_DEC_FRAME = 0x400, @@ -246,7 +246,7 @@ typedef enum { * not this return status only indicates we're past this point in the * codestream. This event occurs max once per frame. * In this case, @ref JxlDecoderReleaseInput will return all bytes from the - * end of the frame (or if @ref JXL_DEC_JPEG_RECONSTRUCTION is subscribed to, + * end of the frame (or if ::JXL_DEC_JPEG_RECONSTRUCTION is subscribed to, * from the end of the last box that is needed for jpeg reconstruction) as * unprocessed. */ @@ -259,9 +259,9 @@ typedef enum { * is set a byte stream identical to the JPEG codestream used to encode the * image will be written to the JPEG reconstruction buffer instead of pixels * to the image out buffer. This event occurs max once per image and always - * before @ref JXL_DEC_FULL_IMAGE. + * before ::JXL_DEC_FULL_IMAGE. * In this case, @ref JxlDecoderReleaseInput will return all bytes from the - * end of the 'jbrd' box as unprocessed. + * end of the `jbrd` box as unprocessed. */ JXL_DEC_JPEG_RECONSTRUCTION = 0x2000, @@ -290,8 +290,8 @@ typedef enum { * * The buffer set with @ref JxlDecoderSetBoxBuffer must be set again for each * next box to be obtained, or can be left unset to skip outputting this box. - * The output buffer contains the full box data when the next @ref JXL_DEC_BOX - * event or @ref JXL_DEC_SUCCESS occurs. @ref JXL_DEC_BOX occurs for all + * The output buffer contains the full box data when the next ::JXL_DEC_BOX + * event or ::JXL_DEC_SUCCESS occurs. ::JXL_DEC_BOX occurs for all * boxes, including non-metadata boxes such as the signature box or codestream * boxes. To check whether the box is a metadata type for respectively EXIF, * XMP or JUMBF, use @ref JxlDecoderGetBoxType and check for types "Exif", @@ -324,26 +324,40 @@ typedef enum { * Setting a progressive detail with value N implies all progressive details * with smaller or equal value. Currently only the following level of * progressive detail is implemented: - * - kDC (which implies kFrames) - * - kLastPasses (which implies kDC and kFrames) - * - kPasses (which implies kLastPasses, kDC and kFrames) + * - @ref kDC (which implies kFrames) + * - @ref kLastPasses (which implies @ref kDC and @ref kFrames) + * - @ref kPasses (which implies @ref kLastPasses, kDC and @ref kFrames) */ typedef enum { - // after completed kRegularFrames + /** + * after completed kRegularFrames + */ kFrames = 0, - // after completed DC (1:8) + /** + * after completed DC (1:8) + */ kDC = 1, - // after completed AC passes that are the last pass for their resolution - // target. + /** + * after completed AC passes that are the last pass for their resolution + * target. + */ kLastPasses = 2, - // after completed AC passes that are not the last pass for their resolution - // target. + /** + * after completed AC passes that are not the last pass for their resolution + * target. + */ kPasses = 3, - // during DC frame when lower resolution are completed (1:32, 1:16) + /** + * during DC frame when lower resolution are completed (1:32, 1:16) + */ kDCProgressive = 4, - // after completed groups + /** + * after completed groups + */ kDCGroups = 5, - // after completed groups + /** + * after completed groups + */ kGroups = 6, } JxlProgressiveDetail; @@ -354,8 +368,8 @@ typedef enum { * more efficiently with @ref JxlDecoderSkipFrames. Settings such as parallel * runner or subscribed events are kept. After rewind, @ref * JxlDecoderSubscribeEvents can be used again, and it is feasible to leave out - * events that were already handled before, such as @ref JXL_DEC_BASIC_INFO - * and @ref JXL_DEC_COLOR_ENCODING, since they will provide the same information + * events that were already handled before, such as ::JXL_DEC_BASIC_INFO + * and ::JXL_DEC_COLOR_ENCODING, since they will provide the same information * as before. * The difference to @ref JxlDecoderReset is that some state is kept, namely * settings set by a call to @@ -376,14 +390,14 @@ JXL_EXPORT void JxlDecoderRewind(JxlDecoder* dec); * the input, but will not output the frame events. It can be more efficient * when skipping frames, and even more so when using this after @ref * JxlDecoderRewind. If the decoder is already processing a frame (could - * have emitted @ref JXL_DEC_FRAME but not yet @ref JXL_DEC_FULL_IMAGE), it + * have emitted ::JXL_DEC_FRAME but not yet ::JXL_DEC_FULL_IMAGE), it * starts skipping from the next frame. If the amount is larger than the amount * of frames remaining in the image, all remaining frames are skipped. Calling * this function multiple times adds the amount to skip to the already existing * amount. * * A frame here is defined as a frame that without skipping emits events such - * as @ref JXL_DEC_FRAME and @ref JXL_DEC_FULL_IMAGE, frames that are internal + * as ::JXL_DEC_FRAME and ::JXL_DEC_FULL_IMAGE, frames that are internal * to the file format but are not rendered as part of an animation, or are not * the final still frame of a still image, are not counted. * @@ -394,14 +408,14 @@ JXL_EXPORT void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount); /** * Skips processing the current frame. Can be called after frame processing - * already started, signaled by a @ref JXL_DEC_NEED_IMAGE_OUT_BUFFER event, - * but before the corresponding @ref JXL_DEC_FULL_IMAGE event. The next signaled - * event will be another @ref JXL_DEC_FRAME, or @ref JXL_DEC_SUCCESS if there + * already started, signaled by a ::JXL_DEC_NEED_IMAGE_OUT_BUFFER event, + * but before the corresponding ::JXL_DEC_FULL_IMAGE event. The next signaled + * event will be another ::JXL_DEC_FRAME, or ::JXL_DEC_SUCCESS if there * are no more frames. If pixel data is required from the already processed part * of the frame, @ref JxlDecoderFlushImage must be called before this. * * @param dec decoder object - * @return @ref JXL_DEC_SUCCESS if there is a frame to skip, and @ref + * @return ::JXL_DEC_SUCCESS if there is a frame to skip, and @ref * JXL_DEC_ERROR if the function was not called during frame processing. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSkipCurrentFrame(JxlDecoder* dec); @@ -415,7 +429,7 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSkipCurrentFrame(JxlDecoder* dec); * be NULL to use the default, single-threaded, runner. A multithreaded * runner should be set to reach fast performance. * @param parallel_runner_opaque opaque pointer for parallel_runner. - * @return @ref JXL_DEC_SUCCESS if the runner was set, @ref JXL_DEC_ERROR + * @return ::JXL_DEC_SUCCESS if the runner was set, ::JXL_DEC_ERROR * otherwise (the previous runner remains set). */ JXL_EXPORT JxlDecoderStatus @@ -439,7 +453,7 @@ JxlDecoderSetParallelRunner(JxlDecoder* dec, JxlParallelRunner parallel_runner, */ JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec); -/** Select for which informative events, i.e. @ref JXL_DEC_BASIC_INFO, etc., the +/** Select for which informative events, i.e. ::JXL_DEC_BASIC_INFO, etc., the * decoder should return with a status. It is not required to subscribe to any * events, data can still be requested from the decoder as soon as it available. * By default, the decoder is subscribed to no events (events_wanted == 0), and @@ -449,7 +463,7 @@ JXL_EXPORT size_t JxlDecoderSizeHintBasicInfo(const JxlDecoder* dec); * * @param dec decoder object * @param events_wanted bitfield of desired events. - * @return @ref JXL_DEC_SUCCESS if no error, @ref JXL_DEC_ERROR otherwise. + * @return ::JXL_DEC_SUCCESS if no error, ::JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder* dec, int events_wanted); @@ -459,14 +473,14 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder* dec, * indicating that the decoder must perform a rotation and/or * mirroring to the encoded image data. * - * - If skip_reorientation is JXL_FALSE (the default): the decoder + * - If skip_reorientation is ::JXL_FALSE (the default): the decoder * will apply the transformation from the orientation setting, hence * rendering the image according to its specified intent. When - * producing a JxlBasicInfo, the decoder will always set the + * producing a @ref JxlBasicInfo, the decoder will always set the * orientation field to JXL_ORIENT_IDENTITY (matching the returned * pixel data) and also align xsize and ysize so that they correspond * to the width and the height of the returned pixel data. - * - If skip_reorientation is JXL_TRUE: the decoder will skip + * - If skip_reorientation is ::JXL_TRUE "JXL_TRUE": the decoder will skip * applying the transformation from the orientation setting, returning * the image in the as-in-bitstream pixeldata orientation. * This may be faster to decode since the decoder doesn't have to apply the @@ -483,17 +497,18 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSubscribeEvents(JxlDecoder* dec, * * @param dec decoder object * @param skip_reorientation JXL_TRUE to enable, JXL_FALSE to disable. - * @return @ref JXL_DEC_SUCCESS if no error, @ref JXL_DEC_ERROR otherwise. + * @return ::JXL_DEC_SUCCESS if no error, ::JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetKeepOrientation(JxlDecoder* dec, JXL_BOOL skip_reorientation); /** * Enables or disables preserving of associated alpha channels. If - * unpremul_alpha is set to JXL_FALSE then for associated alpha channel, the - * pixel data is returned with premultiplied colors. If it is set to JXL_TRUE, - * The colors will be unpremultiplied based on the alpha channel. This function - * has no effect if the image does not have an associated alpha channel. + * unpremul_alpha is set to ::JXL_FALSE then for associated alpha channel, + * the pixel data is returned with premultiplied colors. If it is set to @ref + * JXL_TRUE, The colors will be unpremultiplied based on the alpha channel. This + * function has no effect if the image does not have an associated alpha + * channel. * * By default, this option is disabled, and the returned pixel data "as is". * @@ -501,20 +516,20 @@ JxlDecoderSetKeepOrientation(JxlDecoder* dec, JXL_BOOL skip_reorientation); * * @param dec decoder object * @param unpremul_alpha JXL_TRUE to enable, JXL_FALSE to disable. - * @return @ref JXL_DEC_SUCCESS if no error, @ref JXL_DEC_ERROR otherwise. + * @return ::JXL_DEC_SUCCESS if no error, ::JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetUnpremultiplyAlpha(JxlDecoder* dec, JXL_BOOL unpremul_alpha); /** Enables or disables rendering spot colors. By default, spot colors * are rendered, which is OK for viewing the decoded image. If render_spotcolors - * is JXL_FALSE, then spot colors are not rendered, and have to be retrieved - * separately using @ref JxlDecoderSetExtraChannelBuffer. This is useful for - * e.g. printing applications. + * is ::JXL_FALSE, then spot colors are not rendered, and have to be + * retrieved separately using @ref JxlDecoderSetExtraChannelBuffer. This is + * useful for e.g. printing applications. * * @param dec decoder object * @param render_spotcolors JXL_TRUE to enable (default), JXL_FALSE to disable. - * @return @ref JXL_DEC_SUCCESS if no error, @ref JXL_DEC_ERROR otherwise. + * @return ::JXL_DEC_SUCCESS if no error, ::JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetRenderSpotcolors(JxlDecoder* dec, JXL_BOOL render_spotcolors); @@ -530,7 +545,7 @@ JxlDecoderSetRenderSpotcolors(JxlDecoder* dec, JXL_BOOL render_spotcolors); * @param dec decoder object * @param coalescing JXL_TRUE to enable coalescing (default), JXL_FALSE to * disable it. - * @return @ref JXL_DEC_SUCCESS if no error, @ref JXL_DEC_ERROR otherwise. + * @return ::JXL_DEC_SUCCESS if no error, ::JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetCoalescing(JxlDecoder* dec, JXL_BOOL coalescing); @@ -547,32 +562,32 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetCoalescing(JxlDecoder* dec, * * The returned status indicates whether the decoder needs more input bytes, or * more output buffer for a certain type of output data. No matter what the - * returned status is (other than @ref JXL_DEC_ERROR), new information, such + * returned status is (other than ::JXL_DEC_ERROR), new information, such * as @ref JxlDecoderGetBasicInfo, may have become available after this call. - * When the return value is not @ref JXL_DEC_ERROR or @ref JXL_DEC_SUCCESS, the + * When the return value is not ::JXL_DEC_ERROR or ::JXL_DEC_SUCCESS, the * decoding requires more @ref JxlDecoderProcessInput calls to continue. * * @param dec decoder object - * @return @ref JXL_DEC_SUCCESS when decoding finished and all events handled. + * @return ::JXL_DEC_SUCCESS when decoding finished and all events handled. * If you still have more unprocessed input data anyway, then you can still * continue by using @ref JxlDecoderSetInput and calling @ref * JxlDecoderProcessInput again, similar to handling @ref - * JXL_DEC_NEED_MORE_INPUT. @ref JXL_DEC_SUCCESS can occur instead of @ref + * JXL_DEC_NEED_MORE_INPUT. ::JXL_DEC_SUCCESS can occur instead of @ref * JXL_DEC_NEED_MORE_INPUT when, for example, the input data ended right at * the boundary of a box of the container format, all essential codestream * boxes were already decoded, but extra metadata boxes are still present in * the next data. @ref JxlDecoderProcessInput cannot return success if all * codestream boxes have not been seen yet. - * @return @ref JXL_DEC_ERROR when decoding failed, e.g. invalid codestream. + * @return ::JXL_DEC_ERROR when decoding failed, e.g. invalid codestream. * TODO(lode): document the input data mechanism - * @return @ref JXL_DEC_NEED_MORE_INPUT when more input data is necessary. - * @return @ref JXL_DEC_BASIC_INFO when basic info such as image dimensions is + * @return ::JXL_DEC_NEED_MORE_INPUT when more input data is necessary. + * @return ::JXL_DEC_BASIC_INFO when basic info such as image dimensions is * available and this informative event is subscribed to. - * @return @ref JXL_DEC_COLOR_ENCODING when color profile information is + * @return ::JXL_DEC_COLOR_ENCODING when color profile information is * available and this informative event is subscribed to. - * @return @ref JXL_DEC_PREVIEW_IMAGE when preview pixel information is + * @return ::JXL_DEC_PREVIEW_IMAGE when preview pixel information is * available and output in the preview buffer. - * @return @ref JXL_DEC_FULL_IMAGE when all pixel information at highest detail + * @return ::JXL_DEC_FULL_IMAGE when all pixel information at highest detail * is available and has been output in the pixel buffer. */ JXL_EXPORT JxlDecoderStatus JxlDecoderProcessInput(JxlDecoder* dec); @@ -588,8 +603,8 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderProcessInput(JxlDecoder* dec); * @param dec decoder object * @param data pointer to next bytes to read from * @param size amount of bytes available starting from data - * @return @ref JXL_DEC_ERROR if input was already set without releasing or @ref - * JxlDecoderCloseInput was already called, @ref JXL_DEC_SUCCESS otherwise. + * @return ::JXL_DEC_ERROR if input was already set without releasing or @ref + * JxlDecoderCloseInput was already called, ::JXL_DEC_SUCCESS otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetInput(JxlDecoder* dec, const uint8_t* data, @@ -602,17 +617,17 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetInput(JxlDecoder* dec, * whenever any input is already set and new input needs to be added with @ref * JxlDecoderSetInput, but is not required before @ref JxlDecoderDestroy or @ref * JxlDecoderReset. Calling @ref JxlDecoderReleaseInput when no input is set is - * not an error and returns 0. + * not an error and returns `0`. * * @param dec decoder object * @return The amount of bytes the decoder has not yet processed that are still - * remaining in the data set by @ref JxlDecoderSetInput, or 0 if no input is - * set or @ref JxlDecoderReleaseInput was already called. For a next call - * to @ref JxlDecoderProcessInput, the buffer must start with these - * unprocessed bytes. From this value it is possible to infer the position - * of certain JPEG XL codestream elements (e.g. end of headers, frame - * start/end). See the documentation of individual values of @ref - * JxlDecoderStatus for more information. + * remaining in the data set by @ref JxlDecoderSetInput, or `0` if no input + * is set or @ref JxlDecoderReleaseInput was already called. For a next call to + * @ref JxlDecoderProcessInput, the buffer must start with these unprocessed + * bytes. From this value it is possible to infer the position of certain JPEG + * XL codestream elements (e.g. end of headers, frame start/end). See the + * documentation of individual values of @ref JxlDecoderStatus for more + * information. */ JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec); @@ -621,9 +636,9 @@ JXL_EXPORT size_t JxlDecoderReleaseInput(JxlDecoder* dec); * will be called. This function allows the decoder to determine correctly if it * should return success, need more input or error in certain cases. For * backwards compatibility with a previous version of the API, using this - * function is optional when not using the @ref JXL_DEC_BOX event (the decoder + * function is optional when not using the ::JXL_DEC_BOX event (the decoder * is able to determine the end of the image frames without marking the end), - * but using this function is required when using @ref JXL_DEC_BOX for getting + * but using this function is required when using ::JXL_DEC_BOX for getting * metadata box contents. This function does not replace @ref * JxlDecoderReleaseInput, that function should still be called if its return * value is needed. @@ -643,8 +658,8 @@ JXL_EXPORT void JxlDecoderCloseInput(JxlDecoder* dec); * @param dec decoder object * @param info struct to copy the information into, or NULL to only check * whether the information is available through the return value. - * @return @ref JXL_DEC_SUCCESS if the value is available, @ref - * JXL_DEC_NEED_MORE_INPUT if not yet available, @ref JXL_DEC_ERROR + * @return ::JXL_DEC_SUCCESS if the value is available, @ref + * JXL_DEC_NEED_MORE_INPUT if not yet available, ::JXL_DEC_ERROR * in case of other error conditions. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder* dec, @@ -652,14 +667,14 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder* dec, /** * Outputs information for extra channel at the given index. The index must be - * smaller than num_extra_channels in the associated JxlBasicInfo. + * smaller than num_extra_channels in the associated @ref JxlBasicInfo. * * @param dec decoder object * @param index index of the extra channel to query. * @param info struct to copy the information into, or NULL to only check * whether the information is available through the return value. - * @return @ref JXL_DEC_SUCCESS if the value is available, @ref - * JXL_DEC_NEED_MORE_INPUT if not yet available, @ref JXL_DEC_ERROR + * @return ::JXL_DEC_SUCCESS if the value is available, @ref + * JXL_DEC_NEED_MORE_INPUT if not yet available, ::JXL_DEC_ERROR * in case of other error conditions. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelInfo( @@ -667,16 +682,16 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelInfo( /** * Outputs name for extra channel at the given index in UTF-8. The index must be - * smaller than num_extra_channels in the associated JxlBasicInfo. The buffer - * for name must have at least name_length + 1 bytes allocated, gotten from - * the associated JxlExtraChannelInfo. + * smaller than `num_extra_channels` in the associated @ref JxlBasicInfo. The + * buffer for name must have at least `name_length + 1` bytes allocated, gotten + * from the associated @ref JxlExtraChannelInfo. * * @param dec decoder object * @param index index of the extra channel to query. * @param name buffer to copy the name into * @param size size of the name buffer in bytes - * @return @ref JXL_DEC_SUCCESS if the value is available, @ref - * JXL_DEC_NEED_MORE_INPUT if not yet available, @ref JXL_DEC_ERROR + * @return ::JXL_DEC_SUCCESS if the value is available, @ref + * JXL_DEC_NEED_MORE_INPUT if not yet available, ::JXL_DEC_ERROR * in case of other error conditions. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelName(const JxlDecoder* dec, @@ -719,7 +734,7 @@ typedef enum { * problematic, in that: while ICC profiles can encode a transfer function * that happens to approximate those of PQ and HLG (HLG for only one given * system gamma at a time, and necessitating a 3D LUT if gamma is to be - * different from 1), they cannot (before ICCv4.4) semantically signal that + * different from `1`), they cannot (before ICCv4.4) semantically signal that * this is the color space that they represent. Therefore, they will * typically not actually be interpreted as representing an HDR color space. * This is especially detrimental to PQ which will then be interpreted as if @@ -741,8 +756,8 @@ typedef enum { * or the color profile of the decoded pixels. * @param color_encoding struct to copy the information into, or NULL to only * check whether the information is available through the return value. - * @return @ref JXL_DEC_SUCCESS if the data is available and returned, @ref - * JXL_DEC_NEED_MORE_INPUT if not yet available, @ref JXL_DEC_ERROR in + * @return ::JXL_DEC_SUCCESS if the data is available and returned, @ref + * JXL_DEC_NEED_MORE_INPUT if not yet available, ::JXL_DEC_ERROR in * case the encoded structured color profile does not exist in the * codestream. */ @@ -766,10 +781,10 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsEncodedProfile( * or the color profile of the decoded pixels. * @param size variable to output the size into, or NULL to only check the * return status. - * @return @ref JXL_DEC_SUCCESS if the ICC profile is available, @ref + * @return ::JXL_DEC_SUCCESS if the ICC profile is available, @ref * JXL_DEC_NEED_MORE_INPUT if the decoder has not yet received enough * input data to determine whether an ICC profile is available or what its - * size is, @ref JXL_DEC_ERROR in case the ICC profile is not available and + * size is, ::JXL_DEC_ERROR in case the ICC profile is not available and * cannot be generated. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetICCProfileSize( @@ -785,8 +800,8 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetICCProfileSize( * or the color profile of the decoded pixels. * @param icc_profile buffer to copy the ICC profile into * @param size size of the icc_profile buffer in bytes - * @return @ref JXL_DEC_SUCCESS if the profile was successfully returned is - * available, @ref JXL_DEC_NEED_MORE_INPUT if not yet available, @ref + * @return ::JXL_DEC_SUCCESS if the profile was successfully returned is + * available, ::JXL_DEC_NEED_MORE_INPUT if not yet available, @ref * JXL_DEC_ERROR if the profile doesn't exist or the output size is not * large enough. */ @@ -801,7 +816,7 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetColorAsICCProfile( * * @param dec decoder object * @param color_encoding the default color encoding to set - * @return @ref JXL_DEC_SUCCESS if the preference was set successfully, @ref + * @return ::JXL_DEC_SUCCESS if the preference was set successfully, @ref * JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile( @@ -814,7 +829,7 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreferredColorProfile( * change from version to version. * @param dec decoder object * @param desired_intensity_target the intended target peak luminance - * @return @ref JXL_DEC_SUCCESS if the preference was set successfully, @ref + * @return ::JXL_DEC_SUCCESS if the preference was set successfully, @ref * JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetDesiredIntensityTarget( @@ -823,7 +838,7 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetDesiredIntensityTarget( /** * Sets the desired output color profile of the decoded image either from a * color encoding or an ICC profile. Valid calls of this function have either @c - * color_encoding or @c icc_data set to NULL and @c icc_size must be 0 if and + * color_encoding or @c icc_data set to NULL and @c icc_size must be `0` if and * only if @c icc_data is NULL. * * Depending on whether a color management system (CMS) has been set the @@ -848,17 +863,17 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetDesiredIntensityTarget( * If called with an ICC profile (after a call to @ref JxlDecoderSetCms), the * ICC profile has to be a valid RGB or grayscale color profile. * - * Can only be set after the @ref JXL_DEC_COLOR_ENCODING event occurred and + * Can only be set after the ::JXL_DEC_COLOR_ENCODING event occurred and * before any other event occurred, and should be used before getting - * JXL_COLOR_PROFILE_TARGET_DATA. + * ::JXL_COLOR_PROFILE_TARGET_DATA. * - * This function must not be called before JxlDecoderSetCms. + * This function must not be called before @ref JxlDecoderSetCms. * * @param dec decoder orbject * @param color_encoding the output color encoding * @param icc_data bytes of the icc profile * @param icc_size size of the icc profile in bytes - * @return @ref JXL_DEC_SUCCESS if the color profile was set successfully, @ref + * @return ::JXL_DEC_SUCCESS if the color profile was set successfully, @ref * JXL_DEC_ERROR otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetOutputColorProfile( @@ -891,7 +906,7 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetCms(JxlDecoder* dec, * @param dec decoder object * @param format format of pixels * @param size output value, buffer size in bytes - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * information not available yet. */ JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize( @@ -901,15 +916,15 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize( * Sets the buffer to write the small resolution preview image * to. The size of the buffer must be at least as large as given by @ref * JxlDecoderPreviewOutBufferSize. The buffer follows the format described - * by JxlPixelFormat. The preview image dimensions are given by the - * JxlPreviewHeader. The buffer is owned by the caller. + * by @ref JxlPixelFormat. The preview image dimensions are given by the + * @ref JxlPreviewHeader. The buffer is owned by the caller. * * @param dec decoder object * @param format format of pixels. Object owned by user and its contents are * copied internally. * @param buffer buffer type to output the pixel data to * @param size size of buffer in bytes - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * size too small. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer( @@ -917,14 +932,14 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer( /** * Outputs the information from the frame, such as duration when have_animation. - * This function can be called when @ref JXL_DEC_FRAME occurred for the current + * This function can be called when ::JXL_DEC_FRAME occurred for the current * frame, even when have_animation in the JxlBasicInfo is JXL_FALSE. * * @param dec decoder object * @param header struct to copy the information into, or NULL to only check * whether the information is available through the return value. - * @return @ref JXL_DEC_SUCCESS if the value is available, @ref - * JXL_DEC_NEED_MORE_INPUT if not yet available, @ref JXL_DEC_ERROR in + * @return ::JXL_DEC_SUCCESS if the value is available, @ref + * JXL_DEC_NEED_MORE_INPUT if not yet available, ::JXL_DEC_ERROR in * case of other error conditions. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder* dec, @@ -932,14 +947,14 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder* dec, /** * Outputs name for the current frame. The buffer for name must have at least - * name_length + 1 bytes allocated, gotten from the associated JxlFrameHeader. + * `name_length + 1` bytes allocated, gotten from the associated JxlFrameHeader. * * @param dec decoder object * @param name buffer to copy the name into * @param size size of the name buffer in bytes, including zero termination - * character, so this must be at least JxlFrameHeader.name_length + 1. - * @return @ref JXL_DEC_SUCCESS if the value is available, @ref - * JXL_DEC_NEED_MORE_INPUT if not yet available, @ref JXL_DEC_ERROR in + * character, so this must be at least @ref JxlFrameHeader.name_length + 1. + * @return ::JXL_DEC_SUCCESS if the value is available, @ref + * JXL_DEC_NEED_MORE_INPUT if not yet available, ::JXL_DEC_ERROR in * case of other error conditions. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameName(const JxlDecoder* dec, @@ -947,15 +962,15 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetFrameName(const JxlDecoder* dec, /** * Outputs the blend information for the current frame for a specific extra - * channel. This function can be called when @ref JXL_DEC_FRAME occurred for the - * current frame, even when have_animation in the JxlBasicInfo is JXL_FALSE. - * This information is only useful if coalescing is disabled; otherwise the - * decoder will have performed blending already. + * channel. This function can be called when ::JXL_DEC_FRAME occurred for the + * current frame, even when have_animation in the @ref JxlBasicInfo is @ref + * JXL_FALSE. This information is only useful if coalescing is disabled; + * otherwise the decoder will have performed blending already. * * @param dec decoder object * @param index the index of the extra channel * @param blend_info struct to copy the information into - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelBlendInfo( const JxlDecoder* dec, size_t index, JxlBlendInfo* blend_info); @@ -965,14 +980,14 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetExtraChannelBlendInfo( * given format. This is the buffer for @ref JxlDecoderSetImageOutBuffer. * Requires that the basic image information is available in the decoder in the * case of coalescing enabled (default). In case coalescing is disabled, this - * can only be called after the @ref JXL_DEC_FRAME event occurs. In that case, + * can only be called after the ::JXL_DEC_FRAME event occurs. In that case, * it will return the size required to store the possibly cropped frame (which * can be larger or smaller than the image dimensions). * * @param dec decoder object * @param format format of the pixels. * @param size output value, buffer size in bytes - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * information not available yet. */ JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize( @@ -980,18 +995,18 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize( /** * Sets the buffer to write the full resolution image to. This can be set when - * the @ref JXL_DEC_FRAME event occurs, must be set when the @ref + * the ::JXL_DEC_FRAME event occurs, must be set when the @ref * JXL_DEC_NEED_IMAGE_OUT_BUFFER event occurs, and applies only for the * current frame. The size of the buffer must be at least as large as given * by @ref JxlDecoderImageOutBufferSize. The buffer follows the format described - * by JxlPixelFormat. The buffer is owned by the caller. + * by @ref JxlPixelFormat. The buffer is owned by the caller. * * @param dec decoder object * @param format format of the pixels. Object owned by user and its contents * are copied internally. * @param buffer buffer type to output the pixel data to * @param size size of buffer in bytes - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * size too small. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetImageOutBuffer( @@ -1062,15 +1077,15 @@ typedef void (*JxlImageOutDestroyCallback)(void* run_opaque); /** * Sets pixel output callback. This is an alternative to @ref - * JxlDecoderSetImageOutBuffer. This can be set when the @ref JXL_DEC_FRAME - * event occurs, must be set when the @ref JXL_DEC_NEED_IMAGE_OUT_BUFFER event + * JxlDecoderSetImageOutBuffer. This can be set when the ::JXL_DEC_FRAME + * event occurs, must be set when the ::JXL_DEC_NEED_IMAGE_OUT_BUFFER event * occurs, and applies only for the current frame. Only one of @ref * JxlDecoderSetImageOutBuffer or @ref JxlDecoderSetImageOutCallback may be used * for the same frame, not both at the same time. * * The callback will be called multiple times, to receive the image * data in small chunks. The callback receives a horizontal stripe of pixel - * data, 1 pixel high, xsize pixels wide, called a scanline. The xsize here is + * data, `1` pixel high, xsize pixels wide, called a scanline. The xsize here is * not the same as the full image width, the scanline may be a partial section, * and xsize may differ between calls. The user can then process and/or copy the * partial scanline to an image buffer. The callback may be called @@ -1099,7 +1114,7 @@ typedef void (*JxlImageOutDestroyCallback)(void* run_opaque); * data. * @param opaque optional user data, which will be passed on to the callback, * may be NULL. - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such * as @ref JxlDecoderSetImageOutBuffer already set. */ JXL_EXPORT JxlDecoderStatus @@ -1122,7 +1137,7 @@ JxlDecoderSetImageOutCallback(JxlDecoder* dec, const JxlPixelFormat* format, * @param init_opaque optional user data passed to @c init_callback, may be NULL * (unlike the return value from @c init_callback which may only be NULL if * initialization failed). - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such * as @ref JxlDecoderSetImageOutBuffer having already been called. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetMultithreadedImageOutCallback( @@ -1137,12 +1152,12 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetMultithreadedImageOutCallback( * * @param dec decoder object * @param format format of the pixels. The num_channels value is ignored and is - * always treated to be 1. + * always treated to be `1`. * @param size output value, buffer size in bytes * @param index which extra channel to get, matching the index used in @ref * JxlDecoderGetExtraChannelInfo. Must be smaller than num_extra_channels in - * the associated JxlBasicInfo. - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * the associated @ref JxlBasicInfo. + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * information not available yet or invalid index. */ JXL_EXPORT JxlDecoderStatus JxlDecoderExtraChannelBufferSize( @@ -1151,13 +1166,13 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderExtraChannelBufferSize( /** * Sets the buffer to write an extra channel to. This can be set when - * the @ref JXL_DEC_FRAME or @ref JXL_DEC_NEED_IMAGE_OUT_BUFFER event occurs, + * the ::JXL_DEC_FRAME or ::JXL_DEC_NEED_IMAGE_OUT_BUFFER event occurs, * and applies only for the current frame. The size of the buffer must be at * least as large as given by @ref JxlDecoderExtraChannelBufferSize. The buffer - * follows the format described by JxlPixelFormat, but where num_channels is 1. - * The buffer is owned by the caller. The amount of extra channels is given by - * the num_extra_channels field in the associated JxlBasicInfo, and the - * information of individual extra channels can be queried with @ref + * follows the format described by @ref JxlPixelFormat, but where num_channels + * is `1`. The buffer is owned by the caller. The amount of extra channels is + * given by the num_extra_channels field in the associated @ref JxlBasicInfo, + * and the information of individual extra channels can be queried with @ref * JxlDecoderGetExtraChannelInfo. To get multiple extra channels, this function * must be called multiple times, once for each wanted index. Not all images * have extra channels. The alpha channel is an extra channel and can be gotten @@ -1170,13 +1185,13 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderExtraChannelBufferSize( * @param dec decoder object * @param format format of the pixels. Object owned by user and its contents * are copied internally. The num_channels value is ignored and is always - * treated to be 1. + * treated to be `1`. * @param buffer buffer type to output the pixel data to * @param size size of buffer in bytes * @param index which extra channel to get, matching the index used in @ref * JxlDecoderGetExtraChannelInfo. Must be smaller than num_extra_channels in - * the associated JxlBasicInfo. - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * the associated @ref JxlBasicInfo. + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * size too small or invalid index. */ JXL_EXPORT JxlDecoderStatus @@ -1197,8 +1212,8 @@ JxlDecoderSetExtraChannelBuffer(JxlDecoder* dec, const JxlPixelFormat* format, * @param dec decoder object * @param data pointer to next bytes to write to * @param size amount of bytes available starting from data - * @return @ref JXL_DEC_ERROR if output buffer was already set and @ref - * JxlDecoderReleaseJPEGBuffer was not called on it, @ref JXL_DEC_SUCCESS + * @return ::JXL_DEC_ERROR if output buffer was already set and @ref + * JxlDecoderReleaseJPEGBuffer was not called on it, ::JXL_DEC_SUCCESS * otherwise */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetJPEGBuffer(JxlDecoder* dec, @@ -1213,11 +1228,11 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetJPEGBuffer(JxlDecoder* dec, * JxlDecoderDestroy or @ref JxlDecoderReset. * * Calling @ref JxlDecoderReleaseJPEGBuffer when no buffer is set is - * not an error and returns 0. + * not an error and returns `0`. * * @param dec decoder object * @return the amount of bytes the decoder has not yet written to of the data - * set by @ref JxlDecoderSetJPEGBuffer, or 0 if no buffer is set or @ref + * set by @ref JxlDecoderSetJPEGBuffer, or `0` if no buffer is set or @ref * JxlDecoderReleaseJPEGBuffer was already called. */ JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec); @@ -1233,15 +1248,15 @@ JXL_EXPORT size_t JxlDecoderReleaseJPEGBuffer(JxlDecoder* dec); * JxlDecoderReleaseBoxBuffer, bytes that the decoder has already output * should not be included, only the remaining bytes output must be set. * - * The @ref JxlDecoderReleaseBoxBuffer must be used at the next @ref JXL_DEC_BOX - * event or final @ref JXL_DEC_SUCCESS event to compute the size of the output + * The @ref JxlDecoderReleaseBoxBuffer must be used at the next ::JXL_DEC_BOX + * event or final ::JXL_DEC_SUCCESS event to compute the size of the output * box bytes. * * @param dec decoder object * @param data pointer to next bytes to write to * @param size amount of bytes available starting from data - * @return @ref JXL_DEC_ERROR if output buffer was already set and @ref - * JxlDecoderReleaseBoxBuffer was not called on it, @ref JXL_DEC_SUCCESS + * @return ::JXL_DEC_ERROR if output buffer was already set and @ref + * JxlDecoderReleaseBoxBuffer was not called on it, ::JXL_DEC_SUCCESS * otherwise */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetBoxBuffer(JxlDecoder* dec, @@ -1256,11 +1271,11 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetBoxBuffer(JxlDecoder* dec, * JxlDecoderDestroy or @ref JxlDecoderReset. * * Calling @ref JxlDecoderReleaseBoxBuffer when no buffer is set is - * not an error and returns 0. + * not an error and returns `0`. * * @param dec decoder object * @return the amount of bytes the decoder has not yet written to of the data - * set by @ref JxlDecoderSetBoxBuffer, or 0 if no buffer is set or @ref + * set by @ref JxlDecoderSetBoxBuffer, or `0` if no buffer is set or @ref * JxlDecoderReleaseBoxBuffer was already called. */ JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder* dec); @@ -1274,23 +1289,23 @@ JXL_EXPORT size_t JxlDecoderReleaseBoxBuffer(JxlDecoder* dec); * finished. * * The default mode is raw. This setting can only be changed before decoding, or - * directly after a @ref JXL_DEC_BOX event, and is remembered until the decoder + * directly after a ::JXL_DEC_BOX event, and is remembered until the decoder * is reset or destroyed. * * Enabling decompressed mode requires Brotli support from the library. * * @param dec decoder object - * @param decompress JXL_TRUE to transparently decompress, JXL_FALSE to get - * boxes in raw mode. - * @return @ref JXL_DEC_ERROR if decompressed mode is set and Brotli is not - * available, @ref JXL_DEC_SUCCESS otherwise. + * @param decompress ::JXL_TRUE to transparently decompress, ::JXL_FALSE + * to get boxes in raw mode. + * @return ::JXL_DEC_ERROR if decompressed mode is set and Brotli is not + * available, ::JXL_DEC_SUCCESS otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderSetDecompressBoxes(JxlDecoder* dec, JXL_BOOL decompress); /** - * Outputs the type of the current box, after a @ref JXL_DEC_BOX event occurred, - * as 4 characters without null termination character. In case of a compressed + * Outputs the type of the current box, after a ::JXL_DEC_BOX event occurred, + * as `4` characters without null termination character. In case of a compressed * "brob" box, this will return "brob" if the decompressed argument is * JXL_FALSE, or the underlying box type if the decompressed argument is * JXL_TRUE. @@ -1306,15 +1321,15 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetDecompressBoxes(JxlDecoder* dec, * - "xml ": a box with XML data, in particular XMP metadata. * - "jumb": a JUMBF superbox (JPEG Universal Metadata Box Format, ISO/IEC * 19566-5). - * - "JXL ": mandatory signature box, must come first, 12 bytes long including - * the box header - * - "ftyp": a second mandatory signature box, must come second, 20 bytes long - * including the box header - * - "jxll": a JXL level box. This indicates if the codestream is level 5 or - * level 10 compatible. If not present, it is level 5. Level 10 allows more - * features such as very high image resolution and bit-depths above 16 bits - * per channel. Added automatically by the encoder when - * JxlEncoderSetCodestreamLevel is used + * - "JXL ": mandatory signature box, must come first, `12` bytes long + * including the box header + * - "ftyp": a second mandatory signature box, must come second, `20` bytes + * long including the box header + * - "jxll": a JXL level box. This indicates if the codestream is level `5` or + * level `10` compatible. If not present, it is level `5`. Level `10` allows + * more features such as very high image resolution and bit-depths above `16` + * bits per channel. Added automatically by the encoder when + * @ref JxlEncoderSetCodestreamLevel is used * - "jxlc": a box with the image codestream, in case the codestream is not * split across multiple boxes. The codestream contains the JPEG XL image * itself, including the basic info such as image dimensions, ICC color @@ -1350,7 +1365,7 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetDecompressBoxes(JxlDecoder* dec, * @param type buffer to copy the type into * @param decompressed which box type to get: JXL_FALSE to get the raw box type, * which can be "brob", JXL_TRUE, get the underlying box type. - * @return @ref JXL_DEC_SUCCESS if the value is available, @ref JXL_DEC_ERROR if + * @return ::JXL_DEC_SUCCESS if the value is available, ::JXL_DEC_ERROR if * not, for example the JXL file does not use the container format. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxType(JxlDecoder* dec, @@ -1363,12 +1378,28 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxType(JxlDecoder* dec, * * @param dec decoder object * @param size raw size of the box in bytes - * @return @ref JXL_DEC_ERROR if no box size is available, @ref JXL_DEC_SUCCESS + * @return ::JXL_DEC_ERROR if no box size is available, ::JXL_DEC_SUCCESS * otherwise. */ JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxSizeRaw(const JxlDecoder* dec, uint64_t* size); +/** + * Returns the size of the contents of a box, after the @ref + * JXL_DEC_BOX event. This does not include any of the headers of the box. For + * compressed "brob" boxes, this is the size of the compressed content. Even + * when @ref JxlDecoderSetDecompressBoxes is enabled, the return value of + * function does not change, and the decompressed size is not known before it + * has already been decompressed and output. + * + * @param dec decoder object + * @param size size of the payload of the box in bytes + * @return @ref JXL_DEC_ERROR if no box size is available, @ref JXL_DEC_SUCCESS + * otherwise. + */ +JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxSizeContents(const JxlDecoder* dec, + uint64_t* size); + /** * Configures at which progressive steps in frame decoding these @ref * JXL_DEC_FRAME_PROGRESSION event occurs. The default value for the level @@ -1377,7 +1408,7 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderGetBoxSizeRaw(const JxlDecoder* dec, * @param dec decoder object * @param detail at which level of detail to trigger @ref * JXL_DEC_FRAME_PROGRESSION - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * an invalid value for the progressive detail. */ JXL_EXPORT JxlDecoderStatus @@ -1385,11 +1416,11 @@ JxlDecoderSetProgressiveDetail(JxlDecoder* dec, JxlProgressiveDetail detail); /** * Returns the intended downsampling ratio for the progressive frame produced - * by @ref JxlDecoderFlushImage after the latest @ref JXL_DEC_FRAME_PROGRESSION + * by @ref JxlDecoderFlushImage after the latest ::JXL_DEC_FRAME_PROGRESSION * event. * * @param dec decoder object - * @return The intended downsampling ratio, can be 1, 2, 4 or 8. + * @return The intended downsampling ratio, can be `1`, `2`, `4` or `8`. */ JXL_EXPORT size_t JxlDecoderGetIntendedDownsamplingRatio(JxlDecoder* dec); @@ -1399,12 +1430,12 @@ JXL_EXPORT size_t JxlDecoderGetIntendedDownsamplingRatio(JxlDecoder* dec); * JxlDecoderSetImageOutBuffer will contain partial image data. * * Can be called when @ref JxlDecoderProcessInput returns @ref - * JXL_DEC_NEED_MORE_INPUT, after the @ref JXL_DEC_FRAME event already occurred - * and before the @ref JXL_DEC_FULL_IMAGE event occurred for a frame. + * JXL_DEC_NEED_MORE_INPUT, after the ::JXL_DEC_FRAME event already occurred + * and before the ::JXL_DEC_FULL_IMAGE event occurred for a frame. * * @param dec decoder object - * @return @ref JXL_DEC_SUCCESS if image data was flushed to the output buffer, - * or @ref JXL_DEC_ERROR when no flush was done, e.g. if not enough image + * @return ::JXL_DEC_SUCCESS if image data was flushed to the output buffer, + * or ::JXL_DEC_ERROR when no flush was done, e.g. if not enough image * data was available yet even for flush, or no output buffer was set yet. * This error is not fatal, it only indicates no flushed image is available * right now. Regular decoding can still be performed. @@ -1416,11 +1447,11 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder* dec); * * Can be called after @ref JxlDecoderSetImageOutBuffer or @ref * JxlDecoderSetImageOutCallback. For float pixel data types, only the default - * @ref JXL_BIT_DEPTH_FROM_PIXEL_FORMAT setting is supported. + * ::JXL_BIT_DEPTH_FROM_PIXEL_FORMAT setting is supported. * * @param dec decoder object * @param bit_depth the bit depth setting of the pixel output - * @return @ref JXL_DEC_SUCCESS on success, @ref JXL_DEC_ERROR on error, such as + * @return ::JXL_DEC_SUCCESS on success, ::JXL_DEC_ERROR on error, such as * incompatible custom bit depth and pixel data type. */ JXL_EXPORT JxlDecoderStatus diff --git a/third_party/jpeg-xl/lib/include/jxl/encode.h b/third_party/jpeg-xl/lib/include/jxl/encode.h index 2a87821f06..bb11dd7572 100644 --- a/third_party/jpeg-xl/lib/include/jxl/encode.h +++ b/third_party/jpeg-xl/lib/include/jxl/encode.h @@ -41,8 +41,8 @@ JXL_EXPORT uint32_t JxlEncoderVersion(void); /** * Opaque structure that holds the JPEG XL encoder. * - * Allocated and initialized with JxlEncoderCreate(). - * Cleaned up and deallocated with JxlEncoderDestroy(). + * Allocated and initialized with @ref JxlEncoderCreate(). + * Cleaned up and deallocated with @ref JxlEncoderDestroy(). */ typedef struct JxlEncoderStruct JxlEncoder; @@ -50,9 +50,9 @@ typedef struct JxlEncoderStruct JxlEncoder; * Settings and metadata for a single image frame. This includes encoder options * for a frame such as compression quality and speed. * - * Allocated and initialized with JxlEncoderFrameSettingsCreate(). + * Allocated and initialized with @ref JxlEncoderFrameSettingsCreate(). * Cleaned up and deallocated when the encoder is destroyed with - * JxlEncoderDestroy(). + * @ref JxlEncoderDestroy(). */ typedef struct JxlEncoderFrameSettingsStruct JxlEncoderFrameSettings; @@ -126,7 +126,7 @@ typedef enum { typedef enum { /** Sets encoder effort/speed level without affecting decoding speed. Valid * values are, from faster to slower speed: 1:lightning 2:thunder 3:falcon - * 4:cheetah 5:hare 6:wombat 7:squirrel 8:kitten 9:tortoise. + * 4:cheetah 5:hare 6:wombat 7:squirrel 8:kitten 9:tortoise 10:glacier. * Default: squirrel (7). */ JXL_ENC_FRAME_SETTING_EFFORT = 0, @@ -145,7 +145,7 @@ typedef enum { */ JXL_ENC_FRAME_SETTING_RESAMPLING = 2, - /** Similar to JXL_ENC_FRAME_SETTING_RESAMPLING, but for extra channels. + /** Similar to ::JXL_ENC_FRAME_SETTING_RESAMPLING, but for extra channels. * Integer option, use -1 for the default behavior (depends on encoder * implementation), 1 for no downsampling (1x1), 2 for 2x2 downsampling, 4 for * 4x4 downsampling, 8 for 8x8 downsampling. @@ -158,7 +158,7 @@ typedef enum { * downsampled resolution, not the full image resolution. The downsampled * resolution is given by ceil(xsize / resampling), ceil(ysize / resampling) * with xsize and ysize the dimensions given in the basic info, and resampling - * the factor set with @ref JXL_ENC_FRAME_SETTING_RESAMPLING. + * the factor set with ::JXL_ENC_FRAME_SETTING_RESAMPLING. * Use 0 to disable, 1 to enable. Default value is 0. */ JXL_ENC_FRAME_SETTING_ALREADY_DOWNSAMPLED = 4, @@ -171,8 +171,8 @@ typedef enum { JXL_ENC_FRAME_SETTING_PHOTON_NOISE = 5, /** Enables adaptive noise generation. This setting is not recommended for - * use, please use JXL_ENC_FRAME_SETTING_PHOTON_NOISE instead. Use -1 for the - * default (encoder chooses), 0 to disable, 1 to enable. + * use, please use ::JXL_ENC_FRAME_SETTING_PHOTON_NOISE instead. Use -1 for + * the default (encoder chooses), 0 to disable, 1 to enable. */ JXL_ENC_FRAME_SETTING_NOISE = 6, @@ -320,27 +320,28 @@ typedef enum { * 1 = index this frame within the Frame Index Box. * If any frames are indexed, the first frame needs to * be indexed, too. If the first frame is not indexed, and - * a later frame is attempted to be indexed, JXL_ENC_ERROR will occur. + * a later frame is attempted to be indexed, ::JXL_ENC_ERROR will occur. * If non-keyframes, i.e., frames with cropping, blending or patches are - * attempted to be indexed, JXL_ENC_ERROR will occur. + * attempted to be indexed, ::JXL_ENC_ERROR will occur. */ JXL_ENC_FRAME_INDEX_BOX = 31, - /** Sets brotli encode effort for use in JPEG recompression and compressed - * metadata boxes (brob). Can be -1 (default) or 0 (fastest) to 11 (slowest). - * Default is based on the general encode effort in case of JPEG + /** Sets brotli encode effort for use in JPEG recompression and + * compressed metadata boxes (brob). Can be -1 (default) or 0 (fastest) to 11 + * (slowest). Default is based on the general encode effort in case of JPEG * recompression, and 4 for brob boxes. */ JXL_ENC_FRAME_SETTING_BROTLI_EFFORT = 32, /** Enables or disables brotli compression of metadata boxes derived from - * a JPEG frame when using JxlEncoderAddJPEGFrame. This has no effect on boxes - * added using JxlEncoderAddBox. - * -1 = default, 0 = disable compression, 1 = enable compression. + * a JPEG frame when using @ref JxlEncoderAddJPEGFrame. This has no effect on + * boxes added using @ref JxlEncoderAddBox. -1 = default, 0 = disable + * compression, 1 = enable compression. */ JXL_ENC_FRAME_SETTING_JPEG_COMPRESS_BOXES = 33, /** Control what kind of buffering is used, when using chunked image frames. + * -1 = default (let the encoder decide) * 0 = buffers everything, basically the same as non-streamed code path (mainly for testing) * 1 = buffers everything for images that are smaller than 2048 x 2048, and @@ -351,30 +352,30 @@ typedef enum { * * When using streaming input and output the encoder minimizes memory usage at * the cost of compression density. Also note that images produced with - * streaming mode might can not be decoded progressively. + * streaming mode might not be progressively decodeable. */ JXL_ENC_FRAME_SETTING_BUFFERING = 34, /** Keep or discard Exif metadata boxes derived from a JPEG frame when using - * JxlEncoderAddJPEGFrame. This has no effect on boxes added using - * JxlEncoderAddBox. When JxlEncoderStoreJPEGMetadata is set to 1, this option - * cannot be set to 0. Even when Exif metadata is discarded, the orientation - * will still be applied. 0 = discard Exif metadata, 1 = keep Exif metadata - * (default). + * @ref JxlEncoderAddJPEGFrame. This has no effect on boxes added using + * @ref JxlEncoderAddBox. When @ref JxlEncoderStoreJPEGMetadata is set to 1, + * this option cannot be set to 0. Even when Exif metadata is discarded, the + * orientation will still be applied. 0 = discard Exif metadata, 1 = keep Exif + * metadata (default). */ JXL_ENC_FRAME_SETTING_JPEG_KEEP_EXIF = 35, /** Keep or discard XMP metadata boxes derived from a JPEG frame when using - * JxlEncoderAddJPEGFrame. This has no effect on boxes added using - * JxlEncoderAddBox. When JxlEncoderStoreJPEGMetadata is set to 1, this option - * cannot be set to 0. 0 = discard XMP metadata, 1 = keep XMP metadata - * (default). + * @ref JxlEncoderAddJPEGFrame. This has no effect on boxes added using + * @ref JxlEncoderAddBox. When @ref JxlEncoderStoreJPEGMetadata is set to 1, + * this option cannot be set to 0. 0 = discard XMP metadata, 1 = keep XMP + * metadata (default). */ JXL_ENC_FRAME_SETTING_JPEG_KEEP_XMP = 36, /** Keep or discard JUMBF metadata boxes derived from a JPEG frame when using - * JxlEncoderAddJPEGFrame. This has no effect on boxes added using - * JxlEncoderAddBox. 0 = discard JUMBF metadata, 1 = keep JUMBF metadata + * @ref JxlEncoderAddJPEGFrame. This has no effect on boxes added using + * @ref JxlEncoderAddBox. 0 = discard JUMBF metadata, 1 = keep JUMBF metadata * (default). */ JXL_ENC_FRAME_SETTING_JPEG_KEEP_JUMBF = 37, @@ -395,7 +396,7 @@ typedef enum { } JxlEncoderFrameSettingId; /** - * Creates an instance of JxlEncoder and initializes it. + * Creates an instance of @ref JxlEncoder and initializes it. * * @p memory_manager will be used for all the library dynamic allocations made * from this instance. The parameter may be NULL, in which case the default @@ -404,21 +405,21 @@ typedef enum { * @param memory_manager custom allocator function. It may be NULL. The memory * manager will be copied internally. * @return @c NULL if the instance can not be allocated or initialized - * @return pointer to initialized JxlEncoder otherwise + * @return pointer to initialized @ref JxlEncoder otherwise */ JXL_EXPORT JxlEncoder* JxlEncoderCreate(const JxlMemoryManager* memory_manager); /** - * Re-initializes a JxlEncoder instance, so it can be re-used for encoding + * Re-initializes a @ref JxlEncoder instance, so it can be re-used for encoding * another image. All state and settings are reset as if the object was - * newly created with JxlEncoderCreate, but the memory manager is kept. + * newly created with @ref JxlEncoderCreate, but the memory manager is kept. * * @param enc instance to be re-initialized. */ JXL_EXPORT void JxlEncoderReset(JxlEncoder* enc); /** - * Deinitializes and frees JxlEncoder instance. + * Deinitializes and frees a @ref JxlEncoder instance. * * @param enc instance to be cleaned up and deallocated. */ @@ -430,8 +431,8 @@ JXL_EXPORT void JxlEncoderDestroy(JxlEncoder* enc); * left unset, the default CMS implementation will be used. * * @param enc encoder object. - * @param cms structure representing a CMS implementation. See JxlCmsInterface - * for more details. + * @param cms structure representing a CMS implementation. See @ref + * JxlCmsInterface for more details. */ JXL_EXPORT void JxlEncoderSetCms(JxlEncoder* enc, JxlCmsInterface cms); @@ -444,7 +445,7 @@ JXL_EXPORT void JxlEncoderSetCms(JxlEncoder* enc, JxlCmsInterface cms); * be NULL to use the default, single-threaded, runner. A multithreaded * runner should be set to reach fast performance. * @param parallel_runner_opaque opaque pointer for parallel_runner. - * @return JXL_ENC_SUCCESS if the runner was set, JXL_ENC_ERROR + * @return ::JXL_ENC_SUCCESS if the runner was set, ::JXL_ENC_ERROR * otherwise (the previous runner remains set). */ JXL_EXPORT JxlEncoderStatus @@ -452,16 +453,16 @@ JxlEncoderSetParallelRunner(JxlEncoder* enc, JxlParallelRunner parallel_runner, void* parallel_runner_opaque); /** - * Get the (last) error code in case JXL_ENC_ERROR was returned. + * Get the (last) error code in case ::JXL_ENC_ERROR was returned. * * @param enc encoder object. - * @return the JxlEncoderError that caused the (last) JXL_ENC_ERROR to be - * returned. + * @return the @ref JxlEncoderError that caused the (last) ::JXL_ENC_ERROR to + * be returned. */ JXL_EXPORT JxlEncoderError JxlEncoderGetError(JxlEncoder* enc); /** - * Encodes JPEG XL file using the available bytes. @p *avail_out indicates how + * Encodes a JPEG XL file using the available bytes. @p *avail_out indicates how * many output bytes are available, and @p *next_out points to the input bytes. * *avail_out will be decremented by the amount of bytes that have been * processed by the encoder and *next_out will be incremented by the same @@ -469,12 +470,12 @@ JXL_EXPORT JxlEncoderError JxlEncoderGetError(JxlEncoder* enc); * bytes. * * The returned status indicates whether the encoder needs more output bytes. - * When the return value is not JXL_ENC_ERROR or JXL_ENC_SUCCESS, the encoding - * requires more JxlEncoderProcessOutput calls to continue. + * When the return value is not ::JXL_ENC_ERROR or ::JXL_ENC_SUCCESS, the + * encoding requires more @ref JxlEncoderProcessOutput calls to continue. * * The caller must guarantee that *avail_out >= 32 when calling - * JxlEncoderProcessOutput; otherwise, JXL_ENC_NEED_MORE_OUTPUT will be - * returned. It is guaranteed that, if *avail_out >= 32, at least one byte of + * @ref JxlEncoderProcessOutput; otherwise, ::JXL_ENC_NEED_MORE_OUTPUT will + * be returned. It is guaranteed that, if *avail_out >= 32, at least one byte of * output will be written. * * This encodes the frames and/or boxes added so far. If the last frame or last @@ -486,9 +487,9 @@ JXL_EXPORT JxlEncoderError JxlEncoderGetError(JxlEncoder* enc); * @param enc encoder object. * @param next_out pointer to next bytes to write to. * @param avail_out amount of bytes available starting from *next_out. - * @return JXL_ENC_SUCCESS when encoding finished and all events handled. - * @return JXL_ENC_ERROR when encoding failed, e.g. invalid input. - * @return JXL_ENC_NEED_MORE_OUTPUT more output buffer is necessary. + * @return ::JXL_ENC_SUCCESS when encoding finished and all events handled. + * @return ::JXL_ENC_ERROR when encoding failed, e.g. invalid input. + * @return ::JXL_ENC_NEED_MORE_OUTPUT more output buffer is necessary. */ JXL_EXPORT JxlEncoderStatus JxlEncoderProcessOutput(JxlEncoder* enc, uint8_t** next_out, @@ -509,13 +510,14 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderProcessOutput(JxlEncoder* enc, * time duration of 0, making them form a composite still. See @ref * JxlFrameHeader for more information. * - * This information is stored in the JxlEncoderFrameSettings and so is used for - * any frame encoded with these JxlEncoderFrameSettings. It is ok to change - * between @ref JxlEncoderAddImageFrame calls, each added image frame will have - * the frame header that was set in the options at the time of calling - * JxlEncoderAddImageFrame. + * This information is stored in the @ref JxlEncoderFrameSettings and so is used + * for any frame encoded with these @ref JxlEncoderFrameSettings. It is ok to + * change between @ref JxlEncoderAddImageFrame calls, each added image frame + * will have the frame header that was set in the options at the time of calling + * @ref JxlEncoderAddImageFrame. * - * The is_last and name_length fields of the JxlFrameHeader are ignored, use + * The is_last and name_length fields of the @ref JxlFrameHeader are ignored, + * use * @ref JxlEncoderCloseFrames to indicate last frame, and @ref * JxlEncoderSetFrameName to indicate the name and its length instead. * Calling this function will clear any name that was previously set with @ref @@ -525,7 +527,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderProcessOutput(JxlEncoder* enc, * includes reference to the encoder object. * @param frame_header frame header data to set. Object owned by the caller and * does not need to be kept in memory, its information is copied internally. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameHeader(JxlEncoderFrameSettings* frame_settings, @@ -540,7 +542,7 @@ JxlEncoderSetFrameHeader(JxlEncoderFrameSettings* frame_settings, * includes reference to the encoder object. * @param index index of the extra channel to use. * @param blend_info blend info to set for the extra channel - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBlendInfo( JxlEncoderFrameSettings* frame_settings, size_t index, @@ -550,8 +552,9 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBlendInfo( * Sets the name of the animation frame. This function is optional, frames are * not required to have a name. This setting is a part of the frame header, and * the same principles as for @ref JxlEncoderSetFrameHeader apply. The - * name_length field of JxlFrameHeader is ignored by the encoder, this function - * determines the name length instead as the length in bytes of the C string. + * name_length field of @ref JxlFrameHeader is ignored by the encoder, this + * function determines the name length instead as the length in bytes of the C + * string. * * The maximum possible name length is 1071 bytes (excluding terminating null * character). @@ -563,7 +566,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBlendInfo( * includes reference to the encoder object. * @param frame_name name of the next frame to be encoded, as a UTF-8 encoded C * string (zero terminated). Owned by the caller, and copied internally. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameName( JxlEncoderFrameSettings* frame_settings, const char* frame_name); @@ -571,15 +574,17 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameName( /** * Sets the bit depth of the input buffer. * - * For float pixel formats, only the default JXL_BIT_DEPTH_FROM_PIXEL_FORMAT + * For float pixel formats, only the default @ref + JXL_BIT_DEPTH_FROM_PIXEL_FORMAT * setting is allowed, while for unsigned pixel formats, - * JXL_BIT_DEPTH_FROM_CODESTREAM setting is also allowed. See the comment on + * ::JXL_BIT_DEPTH_FROM_CODESTREAM setting is also allowed. See the comment + on * @ref JxlEncoderAddImageFrame for the effects of the bit depth setting. * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. * @param bit_depth the bit depth setting of the pixel input - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameBitDepth( JxlEncoderFrameSettings* frame_settings, const JxlBitDepth* bit_depth); @@ -587,13 +592,13 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameBitDepth( /** * Sets the buffer to read JPEG encoded bytes from for the next frame to encode. * - * If JxlEncoderSetBasicInfo has not yet been called, calling - * JxlEncoderAddJPEGFrame will implicitly call it with the parameters of the - * added JPEG frame. + * If @ref JxlEncoderSetBasicInfo has not yet been called, calling + * @ref JxlEncoderAddJPEGFrame will implicitly call it with the parameters of + * the added JPEG frame. * - * If JxlEncoderSetColorEncoding or JxlEncoderSetICCProfile has not yet been - * called, calling JxlEncoderAddJPEGFrame will implicitly call it with the - * parameters of the added JPEG frame. + * If @ref JxlEncoderSetColorEncoding or @ref JxlEncoderSetICCProfile has not + * yet been called, calling @ref JxlEncoderAddJPEGFrame will implicitly call it + * with the parameters of the added JPEG frame. * * If the encoder is set to store JPEG reconstruction metadata using @ref * JxlEncoderStoreJPEGMetadata and a single JPEG frame is added, it will be @@ -603,12 +608,16 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameBitDepth( * JxlEncoderCloseFrames must be called before the next * @ref JxlEncoderProcessOutput call. * + * Note, this can only be used to add JPEG frames for lossless compression. To + * encode with lossy compression, the JPEG must be decoded manually and a pixel + * buffer added using JxlEncoderAddImageFrame. + * * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. * @param buffer bytes to read JPEG from. Owned by the caller and its contents * are copied internally. * @param size size of buffer in bytes. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderAddJPEGFrame(const JxlEncoderFrameSettings* frame_settings, @@ -616,33 +625,36 @@ JxlEncoderAddJPEGFrame(const JxlEncoderFrameSettings* frame_settings, /** * Sets the buffer to read pixels from for the next image to encode. Must call - * JxlEncoderSetBasicInfo before JxlEncoderAddImageFrame. + * @ref JxlEncoderSetBasicInfo before @ref JxlEncoderAddImageFrame. * * Currently only some data types for pixel formats are supported: - * - JXL_TYPE_UINT8, with range 0..255 - * - JXL_TYPE_UINT16, with range 0..65535 - * - JXL_TYPE_FLOAT16, with nominal range 0..1 - * - JXL_TYPE_FLOAT, with nominal range 0..1 + * - ::JXL_TYPE_UINT8, with range 0..255 + * - ::JXL_TYPE_UINT16, with range 0..65535 + * - ::JXL_TYPE_FLOAT16, with nominal range 0..1 + * - ::JXL_TYPE_FLOAT, with nominal range 0..1 * * Note: the sample data type in pixel_format is allowed to be different from - * what is described in the JxlBasicInfo. The type in pixel_format, together - * with an optional @ref JxlBitDepth parameter set by @ref + * what is described in the @ref JxlBasicInfo. The type in pixel_format, + * together with an optional @ref JxlBitDepth parameter set by @ref * JxlEncoderSetFrameBitDepth describes the format of the uncompressed pixel - * buffer. The bits_per_sample and exponent_bits_per_sample in the JxlBasicInfo - * describes what will actually be encoded in the JPEG XL codestream. - * For example, to encode a 12-bit image, you would set bits_per_sample to 12, - * while the input frame buffer can be in the following formats: - * - if pixel format is in JXL_TYPE_UINT16 with default bit depth setting - * (i.e. JXL_BIT_DEPTH_FROM_PIXEL_FORMAT), input sample values are rescaled - * to 16-bit, i.e. multiplied by 65535/4095; - * - if pixel format is in JXL_TYPE_UINT16 with JXL_BIT_DEPTH_FROM_CODESTREAM - * bit depth setting, input sample values are provided unscaled; - * - if pixel format is in JXL_TYPE_FLOAT, input sample values are rescaled - * to 0..1, i.e. multiplied by 1.f/4095.f. - * While it is allowed, it is obviously not recommended to use a pixel_format - * with lower precision than what is specified in the JxlBasicInfo. - * - * We support interleaved channels as described by the JxlPixelFormat: + * buffer. The bits_per_sample and exponent_bits_per_sample in the @ref + * JxlBasicInfo describes what will actually be encoded in the JPEG XL + * codestream. For example, to encode a 12-bit image, you would set + * bits_per_sample to 12, while the input frame buffer can be in the following + * formats: + * - if pixel format is in ::JXL_TYPE_UINT16 with default bit depth setting + * (i.e. ::JXL_BIT_DEPTH_FROM_PIXEL_FORMAT), input sample values are + * rescaled to 16-bit, i.e. multiplied by 65535/4095; + * - if pixel format is in ::JXL_TYPE_UINT16 with @ref + * JXL_BIT_DEPTH_FROM_CODESTREAM bit depth setting, input sample values are + * provided unscaled; + * - if pixel format is in ::JXL_TYPE_FLOAT, input sample values are + * rescaled to 0..1, i.e. multiplied by 1.f/4095.f. While it is allowed, it is + * obviously not recommended to use a pixel_format with lower precision than + * what is specified in the @ref JxlBasicInfo. + * + * We support interleaved channels as described by the @ref JxlPixelFormat + * "JxlPixelFormat": * - single-channel data, e.g. grayscale * - single-channel + alpha * - trichromatic, e.g. RGB @@ -654,10 +666,11 @@ JxlEncoderAddJPEGFrame(const JxlEncoderFrameSettings* frame_settings, * set to all-opaque (an alpha value of 1.0 everywhere). * * The pixels are assumed to be encoded in the original profile that is set with - * JxlEncoderSetColorEncoding or JxlEncoderSetICCProfile. If none of these - * functions were used, the pixels are assumed to be nonlinear sRGB for integer - * data types (JXL_TYPE_UINT8, JXL_TYPE_UINT16), and linear sRGB for floating - * point data types (JXL_TYPE_FLOAT16, JXL_TYPE_FLOAT). + * @ref JxlEncoderSetColorEncoding or @ref JxlEncoderSetICCProfile. If none of + * these functions were used, the pixels are assumed to be nonlinear sRGB for + * integer data types (::JXL_TYPE_UINT8, ::JXL_TYPE_UINT16), and linear + * sRGB for floating point data types (::JXL_TYPE_FLOAT16, @ref + * JXL_TYPE_FLOAT). * * Sample values in floating-point pixel formats are allowed to be outside the * nominal range, e.g. to represent out-of-sRGB-gamut colors in the @@ -676,14 +689,14 @@ JxlEncoderAddJPEGFrame(const JxlEncoderFrameSettings* frame_settings, * and its contents are copied internally. * @param size size of buffer in bytes. This size should match what is implied * by the frame dimensions and the pixel format. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderAddImageFrame( const JxlEncoderFrameSettings* frame_settings, const JxlPixelFormat* pixel_format, const void* buffer, size_t size); /** - * The JxlEncoderOutputProcessor structure provides an interface for the + * The @ref JxlEncoderOutputProcessor structure provides an interface for the * encoder's output processing. Users of the library, who want to do streaming * encoding, should implement the required callbacks for buffering, writing, * seeking (if supported), and setting a finalized position during the encoding @@ -785,7 +798,7 @@ struct JxlEncoderOutputProcessor { * @param enc encoder object. * @param output_processor the struct containing the callbacks for managing * output. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error. + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error. */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetOutputProcessor( JxlEncoder* enc, struct JxlEncoderOutputProcessor output_processor); @@ -801,7 +814,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetOutputProcessor( * This should not be used when using @ref JxlEncoderProcessOutput. * * @param enc encoder object. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error. + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error. */ JXL_EXPORT JxlEncoderStatus JxlEncoderFlushInput(JxlEncoder* enc); @@ -923,9 +936,9 @@ struct JxlChunkedFrameInputSource { * chunked or streaming manner, which can be especially useful when dealing with * large images that may not fit entirely in memory or when trying to optimize * memory usage. The input data is provided through callbacks defined in the - * `JxlChunkedFrameInputSource` struct. Once the frame data has been completely - * retrieved, this function will flush the input and close it if it is the last - * frame. + * @ref JxlChunkedFrameInputSource struct. Once the frame data has been + * completely retrieved, this function will flush the input and close it if it + * is the last frame. * * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. @@ -943,7 +956,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderAddChunkedFrame( /** * Sets the buffer to read pixels from for an extra channel at a given index. * The index must be smaller than the num_extra_channels in the associated - * JxlBasicInfo. Must call @ref JxlEncoderSetExtraChannelInfo before + * @ref JxlBasicInfo. Must call @ref JxlEncoderSetExtraChannelInfo before @ref * JxlEncoderSetExtraChannelBuffer. * * TODO(firsching): mention what data types in pixel formats are supported. @@ -961,15 +974,15 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderAddChunkedFrame( * @param size size of buffer in bytes. This size should match what is implied * by the frame dimensions and the pixel format. * @param index index of the extra channel to use. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBuffer( const JxlEncoderFrameSettings* frame_settings, const JxlPixelFormat* pixel_format, const void* buffer, size_t size, uint32_t index); -/** Adds a metadata box to the file format. JxlEncoderProcessOutput must be used - * to effectively write the box to the output. @ref JxlEncoderUseBoxes must +/** Adds a metadata box to the file format. @ref JxlEncoderProcessOutput must be + * used to effectively write the box to the output. @ref JxlEncoderUseBoxes must * be enabled before using this function. * * Boxes allow inserting application-specific data and metadata (Exif, XML/XMP, @@ -996,10 +1009,10 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBuffer( * the encoder encodes the size header itself. Most boxes are written * automatically by the encoder as needed ("JXL ", "ftyp", "jxll", "jxlc", * "jxlp", "jxli", "jbrd"), and this function only needs to be called to add - * optional metadata when encoding from pixels (using JxlEncoderAddImageFrame). - * When recompressing JPEG files (using JxlEncoderAddJPEGFrame), if the input - * JPEG contains EXIF, XMP or JUMBF metadata, the corresponding boxes are - * already added automatically. + * optional metadata when encoding from pixels (using @ref + * JxlEncoderAddImageFrame). When recompressing JPEG files (using @ref + * JxlEncoderAddJPEGFrame), if the input JPEG contains EXIF, XMP or JUMBF + * metadata, the corresponding boxes are already added automatically. * * Box types are given by 4 characters. The following boxes can be added with * this function: @@ -1032,9 +1045,9 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBuffer( * @param size size of the box contents. * @param compress_box Whether to compress this box as a "brob" box. Requires * Brotli support. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error, such as when - * using this function without JxlEncoderUseContainer, or adding a box type - * that would result in an invalid file format. + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error, such as + * when using this function without @ref JxlEncoderUseContainer, or adding a box + * type that would result in an invalid file format. */ JXL_EXPORT JxlEncoderStatus JxlEncoderAddBox(JxlEncoder* enc, const JxlBoxType type, @@ -1061,9 +1074,9 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderUseBoxes(JxlEncoder* enc); * the stream will be finished. It is not necessary to use this function if * @ref JxlEncoderUseBoxes is not used. Further frames may still be added. * - * Must be called between JxlEncoderAddBox of the last box - * and the next call to JxlEncoderProcessOutput, or @ref JxlEncoderProcessOutput - * won't output the last box correctly. + * Must be called between @ref JxlEncoderAddBox of the last box + * and the next call to @ref JxlEncoderProcessOutput, or @ref + * JxlEncoderProcessOutput won't output the last box correctly. * * NOTE: if you don't need to close frames and boxes at separate times, you can * use @ref JxlEncoderCloseInput instead to close both at once. @@ -1087,10 +1100,10 @@ JXL_EXPORT void JxlEncoderCloseBoxes(JxlEncoder* enc); JXL_EXPORT void JxlEncoderCloseFrames(JxlEncoder* enc); /** - * Closes any input to the encoder, equivalent to calling JxlEncoderCloseFrames - * as well as calling JxlEncoderCloseBoxes if needed. No further input of any - * kind may be given to the encoder, but further @ref JxlEncoderProcessOutput - * calls should be done to create the final output. + * Closes any input to the encoder, equivalent to calling @ref + * JxlEncoderCloseFrames as well as calling @ref JxlEncoderCloseBoxes if needed. + * No further input of any kind may be given to the encoder, but further @ref + * JxlEncoderProcessOutput calls should be done to create the final output. * * The requirements of both @ref JxlEncoderCloseFrames and @ref * JxlEncoderCloseBoxes apply to this function. Either this function or the @@ -1104,39 +1117,39 @@ JXL_EXPORT void JxlEncoderCloseInput(JxlEncoder* enc); /** * Sets the original color encoding of the image encoded by this encoder. This - * is an alternative to JxlEncoderSetICCProfile and only one of these two must - * be used. This one sets the color encoding as a @ref JxlColorEncoding, while - * the other sets it as ICC binary data. - * Must be called after JxlEncoderSetBasicInfo. + * is an alternative to @ref JxlEncoderSetICCProfile and only one of these two + * must be used. This one sets the color encoding as a @ref JxlColorEncoding, + * while the other sets it as ICC binary data. Must be called after @ref + * JxlEncoderSetBasicInfo. * * @param enc encoder object. * @param color color encoding. Object owned by the caller and its contents are * copied internally. - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR or - * JXL_ENC_NOT_SUPPORTED otherwise + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR otherwise */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetColorEncoding(JxlEncoder* enc, const JxlColorEncoding* color); /** * Sets the original color encoding of the image encoded by this encoder as an - * ICC color profile. This is an alternative to JxlEncoderSetColorEncoding and - * only one of these two must be used. This one sets the color encoding as ICC - * binary data, while the other defines it as a @ref JxlColorEncoding. - * Must be called after JxlEncoderSetBasicInfo. + * ICC color profile. This is an alternative to @ref JxlEncoderSetColorEncoding + * and only one of these two must be used. This one sets the color encoding as + * ICC binary data, while the other defines it as a @ref JxlColorEncoding. Must + * be called after @ref JxlEncoderSetBasicInfo. * * @param enc encoder object. * @param icc_profile bytes of the original ICC profile * @param size size of the icc_profile buffer in bytes - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR or - * JXL_ENC_NOT_SUPPORTED otherwise + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR otherwise */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetICCProfile(JxlEncoder* enc, const uint8_t* icc_profile, size_t size); /** - * Initializes a JxlBasicInfo struct to default values. + * Initializes a @ref JxlBasicInfo struct to default values. * For forwards-compatibility, this function has to be called before values * are assigned to the struct fields. * The default values correspond to an 8-bit RGB image, no alpha or any @@ -1147,7 +1160,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetICCProfile(JxlEncoder* enc, JXL_EXPORT void JxlEncoderInitBasicInfo(JxlBasicInfo* info); /** - * Initializes a JxlFrameHeader struct to default values. + * Initializes a @ref JxlFrameHeader struct to default values. * For forwards-compatibility, this function has to be called before values * are assigned to the struct fields. * The default values correspond to a frame with no animation duration and the @@ -1159,7 +1172,7 @@ JXL_EXPORT void JxlEncoderInitBasicInfo(JxlBasicInfo* info); JXL_EXPORT void JxlEncoderInitFrameHeader(JxlFrameHeader* frame_header); /** - * Initializes a JxlBlendInfo struct to default values. + * Initializes a @ref JxlBlendInfo struct to default values. * For forwards-compatibility, this function has to be called before values * are assigned to the struct fields. * @@ -1170,26 +1183,26 @@ JXL_EXPORT void JxlEncoderInitBlendInfo(JxlBlendInfo* blend_info); /** * Sets the global metadata of the image encoded by this encoder. * - * If the JxlBasicInfo contains information of extra channels beyond an alpha - * channel, then @ref JxlEncoderSetExtraChannelInfo must be called between - * JxlEncoderSetBasicInfo and @ref JxlEncoderAddImageFrame. In order to indicate - * extra channels, the value of `info.num_extra_channels` should be set to the - * number of extra channels, also counting the alpha channel if present. + * If the @ref JxlBasicInfo contains information of extra channels beyond an + * alpha channel, then @ref JxlEncoderSetExtraChannelInfo must be called between + * @ref JxlEncoderSetBasicInfo and @ref JxlEncoderAddImageFrame. In order to + * indicate extra channels, the value of `info.num_extra_channels` should be set + * to the number of extra channels, also counting the alpha channel if present. * * @param enc encoder object. * @param info global image metadata. Object owned by the caller and its * contents are copied internally. - * @return JXL_ENC_SUCCESS if the operation was successful, - * JXL_ENC_ERROR or JXL_ENC_NOT_SUPPORTED otherwise + * @return ::JXL_ENC_SUCCESS if the operation was successful, + * ::JXL_ENC_ERROR otherwise */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetBasicInfo(JxlEncoder* enc, const JxlBasicInfo* info); /** * Sets the upsampling method the decoder will use in case there are frames - * with JXL_ENC_FRAME_SETTING_RESAMPLING set. This is useful in combination - * with the JXL_ENC_FRAME_SETTING_ALREADY_DOWNSAMPLED option, to control the - * type of upsampling that will be used. + * with ::JXL_ENC_FRAME_SETTING_RESAMPLING set. This is useful in combination + * with the ::JXL_ENC_FRAME_SETTING_ALREADY_DOWNSAMPLED option, to control + * the type of upsampling that will be used. * * @param enc encoder object. * @param factor upsampling factor to configure (1, 2, 4 or 8; for 1 this @@ -1198,15 +1211,15 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetBasicInfo(JxlEncoder* enc, * -1: default (good for photographic images, no signaling overhead) * 0: nearest neighbor (good for pixel art) * 1: 'pixel dots' (same as NN for 2x, diamond-shaped 'pixel dots' for 4x/8x) - * @return JXL_ENC_SUCCESS if the operation was successful, - * JXL_ENC_ERROR or JXL_ENC_NOT_SUPPORTED otherwise + * @return ::JXL_ENC_SUCCESS if the operation was successful, + * ::JXL_ENC_ERROR otherwise */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetUpsamplingMode(JxlEncoder* enc, int64_t factor, int64_t mode); /** - * Initializes a JxlExtraChannelInfo struct to default values. + * Initializes a @ref JxlExtraChannelInfo struct to default values. * For forwards-compatibility, this function has to be called before values * are assigned to the struct fields. * The default values correspond to an 8-bit channel of the provided type. @@ -1220,23 +1233,24 @@ JXL_EXPORT void JxlEncoderInitExtraChannelInfo(JxlExtraChannelType type, /** * Sets information for the extra channel at the given index. The index - * must be smaller than num_extra_channels in the associated JxlBasicInfo. + * must be smaller than num_extra_channels in the associated @ref JxlBasicInfo. * * @param enc encoder object * @param index index of the extra channel to set. * @param info global extra channel metadata. Object owned by the caller and its * contents are copied internally. - * @return JXL_ENC_SUCCESS on success, JXL_ENC_ERROR on error + * @return ::JXL_ENC_SUCCESS on success, ::JXL_ENC_ERROR on error */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelInfo( JxlEncoder* enc, size_t index, const JxlExtraChannelInfo* info); /** * Sets the name for the extra channel at the given index in UTF-8. The index - * must be smaller than the num_extra_channels in the associated JxlBasicInfo. + * must be smaller than the num_extra_channels in the associated @ref + * JxlBasicInfo. * * TODO(lode): remove size parameter for consistency with - * JxlEncoderSetFrameName + * @ref JxlEncoderSetFrameName * * @param enc encoder object * @param index index of the extra channel to set. @@ -1252,17 +1266,18 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelName(JxlEncoder* enc, /** * Sets a frame-specific option of integer type to the encoder options. - * The JxlEncoderFrameSettingId argument determines which option is set. + * The @ref JxlEncoderFrameSettingId argument determines which option is set. * * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. * @param option ID of the option to set. * @param value Integer value to set for this option. - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR in - * case of an error, such as invalid or unknown option id, or invalid integer - * value for the given option. If an error is returned, the state of the - * JxlEncoderFrameSettings object is still valid and is the same as before this - * function was called. + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR in case of an error, such as invalid or unknown option id, or + * invalid integer value for the given option. If an error is returned, the + * state of the + * @ref JxlEncoderFrameSettings object is still valid and is the same as before + * this function was called. */ JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetOption( JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option, @@ -1270,17 +1285,18 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetOption( /** * Sets a frame-specific option of float type to the encoder options. - * The JxlEncoderFrameSettingId argument determines which option is set. + * The @ref JxlEncoderFrameSettingId argument determines which option is set. * * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. * @param option ID of the option to set. * @param value Float value to set for this option. - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR in - * case of an error, such as invalid or unknown option id, or invalid integer - * value for the given option. If an error is returned, the state of the - * JxlEncoderFrameSettings object is still valid and is the same as before this - * function was called. + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR in case of an error, such as invalid or unknown option id, or + * invalid integer value for the given option. If an error is returned, the + * state of the + * @ref JxlEncoderFrameSettings object is still valid and is the same as before + * this function was called. */ JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetFloatOption( JxlEncoderFrameSettings* frame_settings, JxlEncoderFrameSettingId option, @@ -1292,7 +1308,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderFrameSettingsSetFloatOption( * When using @ref JxlEncoderUseBoxes, @ref JxlEncoderStoreJPEGMetadata or @ref * JxlEncoderSetCodestreamLevel with level 10, the encoder will automatically * also use the container format, it is not necessary to use - * JxlEncoderUseContainer for those use cases. + * @ref JxlEncoderUseContainer for those use cases. * * By default this setting is disabled. * @@ -1318,8 +1334,8 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderUseContainer(JxlEncoder* enc, * * @param enc encoder object. * @param store_jpeg_metadata true if the encoder should store JPEG metadata. - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR - * otherwise. + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR otherwise. */ JXL_EXPORT JxlEncoderStatus JxlEncoderStoreJPEGMetadata(JxlEncoder* enc, JXL_BOOL store_jpeg_metadata); @@ -1334,8 +1350,8 @@ JxlEncoderStoreJPEGMetadata(JxlEncoder* enc, JXL_BOOL store_jpeg_metadata); * 268435456 pixels total with a maximum width or height of 262144 pixels, * maximum 16-bit color channel depth, maximum 120 frames per second for * animation, maximum ICC color profile size of 4 MiB, it allows all color - * models and extra channel types except CMYK and the JXL_CHANNEL_BLACK extra - * channel, and a maximum of 4 extra channels in addition to the 3 color + * models and extra channel types except CMYK and the JXL_CHANNEL_BLACK + * extra channel, and a maximum of 4 extra channels in addition to the 3 color * channels. It also sets boundaries to certain internally used coding tools. * * Level 10: this level removes or increases the bounds of most of the level @@ -1355,8 +1371,8 @@ JxlEncoderStoreJPEGMetadata(JxlEncoder* enc, JXL_BOOL store_jpeg_metadata); * * @param enc encoder object. * @param level the level value to set, must be -1, 5, or 10. - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR - * otherwise. + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR otherwise. */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetCodestreamLevel(JxlEncoder* enc, int level); @@ -1370,9 +1386,10 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetCodestreamLevel(JxlEncoder* enc, * the JPEG XL file. * * If this returns 5, nothing needs to be done and the codestream can be - * compatible with any decoder. If this returns 10, JxlEncoderSetCodestreamLevel - * has to be used to set the codestream level to 10, or the encoder can be - * configured differently to allow using the more compatible level 5. + * compatible with any decoder. If this returns 10, @ref + * JxlEncoderSetCodestreamLevel has to be used to set the codestream level to + * 10, or the encoder can be configured differently to allow using the more + * compatible level 5. * * @param enc encoder object. * @return -1 if no level can support the configuration (e.g. image dimensions @@ -1391,14 +1408,14 @@ JXL_EXPORT int JxlEncoderGetRequiredCodestreamLevel(const JxlEncoder* enc); * * When disabled, those options are not overridden, but since those options * could still have been manually set to a combination that operates losslessly, - * using this function with lossless set to JXL_DEC_FALSE does not guarantee - * lossy encoding, though the default set of options is lossy. + * using this function with lossless set to ::JXL_FALSE does not + * guarantee lossy encoding, though the default set of options is lossy. * * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. * @param lossless whether to override options for lossless mode - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR - * otherwise. + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR otherwise. */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameLossless( JxlEncoderFrameSettings* frame_settings, JXL_BOOL lossless); @@ -1406,7 +1423,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameLossless( /** * Sets the distance level for lossy compression: target max butteraugli * distance, lower = higher quality. Range: 0 .. 25. - * 0.0 = mathematically lossless (however, use JxlEncoderSetFrameLossless + * 0.0 = mathematically lossless (however, use @ref JxlEncoderSetFrameLossless * instead to use true lossless, as setting distance to 0 alone is not the only * requirement). 1.0 = visually lossless. Recommended range: 0.5 .. 3.0. Default * value: 1.0. @@ -1414,24 +1431,25 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameLossless( * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. * @param distance the distance value to set. - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR - * otherwise. + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR otherwise. */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetFrameDistance( JxlEncoderFrameSettings* frame_settings, float distance); /** * Sets the distance level for lossy compression of extra channels. - * The distance is as in JxlEncoderSetFrameDistance (lower = higher quality). - * If not set, or if set to the special value -1, the distance that was set with - * JxlEncoderSetFrameDistance will be used. + * The distance is as in @ref JxlEncoderSetFrameDistance (lower = higher + * quality). If not set, or if set to the special value -1, the distance that + * was set with + * @ref JxlEncoderSetFrameDistance will be used. * * @param frame_settings set of options and metadata for this frame. Also * includes reference to the encoder object. * @param index index of the extra channel to set a distance value for. * @param distance the distance value to set. - * @return JXL_ENC_SUCCESS if the operation was successful, JXL_ENC_ERROR - * otherwise. + * @return ::JXL_ENC_SUCCESS if the operation was successful, @ref + * JXL_ENC_ERROR otherwise. */ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelDistance( JxlEncoderFrameSettings* frame_settings, size_t index, float distance); @@ -1441,8 +1459,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelDistance( * * This function takes in input a JPEG-style quality factor `quality` and * produces as output a `distance` value suitable to be used with @ref - * JxlEncoderSetFrameDistance and - * @ref JxlEncoderSetExtraChannelDistance. + * JxlEncoderSetFrameDistance and @ref JxlEncoderSetExtraChannelDistance. * * The `distance` value influences the level of compression, with lower values * indicating higher quality: @@ -1479,10 +1496,10 @@ JXL_EXPORT float JxlEncoderDistanceFromQuality(float quality); * the @p source options, or set to default if @p source is NULL. * * The returned pointer is an opaque struct tied to the encoder and it will be - * deallocated by the encoder when JxlEncoderDestroy() is called. For functions - * taking both a @ref JxlEncoder and a @ref JxlEncoderFrameSettings, only - * JxlEncoderFrameSettings created with this function for the same encoder - * instance can be used. + * deallocated by the encoder when @ref JxlEncoderDestroy() is called. For + * functions taking both a @ref JxlEncoder and a @ref JxlEncoderFrameSettings, + * only @ref JxlEncoderFrameSettings created with this function for the same + * encoder instance can be used. * * @param enc encoder object. * @param source source options to copy initial values from, or NULL to get @@ -1513,7 +1530,7 @@ JXL_EXPORT void JxlColorEncodingSetToLinearSRGB( /** * Enables usage of expert options. * - * At the moment, the only expert option is setting an effort value of 10, + * At the moment, the only expert option is setting an effort value of 11, * which gives the best compression for pixel-lossless modes but is very slow. * * @param enc encoder object. diff --git a/third_party/jpeg-xl/lib/include/jxl/parallel_runner.h b/third_party/jpeg-xl/lib/include/jxl/parallel_runner.h index e71e0aa926..ea66685dbc 100644 --- a/third_party/jpeg-xl/lib/include/jxl/parallel_runner.h +++ b/third_party/jpeg-xl/lib/include/jxl/parallel_runner.h @@ -46,39 +46,41 @@ extern "C" { /** Return code used in the JxlParallel* functions as return value. A value * of 0 means success and any other value means error. The special value - * JXL_PARALLEL_RET_RUNNER_ERROR can be used by the runner to indicate any + * ::JXL_PARALLEL_RET_RUNNER_ERROR can be used by the runner to indicate any * other error. */ typedef int JxlParallelRetCode; /** - * General error returned by the JxlParallelRunInit function to indicate + * General error returned by the @ref JxlParallelRunInit function to indicate * an error. */ #define JXL_PARALLEL_RET_RUNNER_ERROR (-1) /** - * Parallel run initialization callback. See JxlParallelRunner for details. + * Parallel run initialization callback. See @ref JxlParallelRunner for details. * * This function MUST be called by the JxlParallelRunner only once, on the - * same thread that called JxlParallelRunner, before any parallel execution. - * The purpose of this call is to provide the maximum number of threads that the - * JxlParallelRunner will use, which can be used by JPEG XL to allocate + * same thread that called @ref JxlParallelRunner, before any parallel + * execution. The purpose of this call is to provide the maximum number of + * threads that the + * @ref JxlParallelRunner will use, which can be used by JPEG XL to allocate * per-thread storage if needed. * * @param jpegxl_opaque the @p jpegxl_opaque handle provided to - * JxlParallelRunner() must be passed here. + * @ref JxlParallelRunner() must be passed here. * @param num_threads the maximum number of threads. This value must be * positive. * @return 0 if the initialization process was successful. * @return an error code if there was an error, which should be returned by - * JxlParallelRunner(). + * @ref JxlParallelRunner(). */ typedef JxlParallelRetCode (*JxlParallelRunInit)(void* jpegxl_opaque, size_t num_threads); /** - * Parallel run data processing callback. See JxlParallelRunner for details. + * Parallel run data processing callback. See @ref JxlParallelRunner for + * details. * * This function MUST be called once for every number in the range [start_range, * end_range) (including start_range but not including end_range) passing this @@ -86,11 +88,11 @@ typedef JxlParallelRetCode (*JxlParallelRunInit)(void* jpegxl_opaque, * different threads in parallel. * * @param jpegxl_opaque the @p jpegxl_opaque handle provided to - * JxlParallelRunner() must be passed here. + * @ref JxlParallelRunner() must be passed here. * @param value the number in the range [start_range, end_range) of the call. * @param thread_id the thread number where this function is being called from. * This must be lower than the @p num_threads value passed to - * JxlParallelRunInit. + * @ref JxlParallelRunInit. */ typedef void (*JxlParallelRunFunction)(void* jpegxl_opaque, uint32_t value, size_t thread_id); @@ -103,11 +105,12 @@ typedef void (*JxlParallelRunFunction)(void* jpegxl_opaque, uint32_t value, * number in the range [start_range, end_range) (including start_range but not * including end_range) possibly from different multiple threads in parallel. * - * The JxlParallelRunner function does not need to be re-entrant. This means - * that the same JxlParallelRunner function with the same runner_opaque - * provided parameter will not be called from the library from either @p init or + * The @ref JxlParallelRunner function does not need to be re-entrant. This + * means that the same @ref JxlParallelRunner function with the same + * runner_opaque provided parameter will not be called from the library from + * either @p init or * @p func in the same decoder or encoder instance. However, a single decoding - * or encoding instance may call the provided JxlParallelRunner multiple + * or encoding instance may call the provided @ref JxlParallelRunner multiple * times for different parts of the decoding or encoding process. * * @return 0 if the @p init call succeeded (returned 0) and no other error @@ -120,7 +123,7 @@ typedef JxlParallelRetCode (*JxlParallelRunner)( void* runner_opaque, void* jpegxl_opaque, JxlParallelRunInit init, JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range); -/* The following is an example of a JxlParallelRunner that doesn't use any +/* The following is an example of a @ref JxlParallelRunner that doesn't use any * multi-threading. Note that this implementation doesn't store any state * between multiple calls of the ExampleSequentialRunner function, so the * runner_opaque value is not used. diff --git a/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner.h b/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner.h index a65015d861..c82b0bc23b 100644 --- a/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner.h +++ b/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner.h @@ -16,7 +16,7 @@ * created can be changed after creation of the thread pool; the threads * (including the main thread) are re-used for every * ResizableParallelRunner::Runner call. Only one concurrent - * JxlResizableParallelRunner call per instance is allowed at a time. + * @ref JxlResizableParallelRunner call per instance is allowed at a time. * * This is a scalable, lower-overhead thread pool runner, especially suitable * for data-parallel computations in the fork-join model, where clients need to @@ -41,20 +41,20 @@ extern "C" { #endif -/** Parallel runner internally using std::thread. Use as JxlParallelRunner. +/** Parallel runner internally using std::thread. Use as @ref JxlParallelRunner. */ JXL_THREADS_EXPORT JxlParallelRetCode JxlResizableParallelRunner( void* runner_opaque, void* jpegxl_opaque, JxlParallelRunInit init, JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range); -/** Creates the runner for JxlResizableParallelRunner. Use as the opaque +/** Creates the runner for @ref JxlResizableParallelRunner. Use as the opaque * runner. The runner will execute tasks on the calling thread until * @ref JxlResizableParallelRunnerSetThreads is called. */ JXL_THREADS_EXPORT void* JxlResizableParallelRunnerCreate( const JxlMemoryManager* memory_manager); -/** Changes the number of threads for JxlResizableParallelRunner. +/** Changes the number of threads for @ref JxlResizableParallelRunner. */ JXL_THREADS_EXPORT void JxlResizableParallelRunnerSetThreads( void* runner_opaque, size_t num_threads); @@ -64,7 +64,7 @@ JXL_THREADS_EXPORT void JxlResizableParallelRunnerSetThreads( JXL_THREADS_EXPORT uint32_t JxlResizableParallelRunnerSuggestThreads(uint64_t xsize, uint64_t ysize); -/** Destroys the runner created by JxlResizableParallelRunnerCreate. +/** Destroys the runner created by @ref JxlResizableParallelRunnerCreate. */ JXL_THREADS_EXPORT void JxlResizableParallelRunnerDestroy(void* runner_opaque); diff --git a/third_party/jpeg-xl/lib/include/jxl/stats.h b/third_party/jpeg-xl/lib/include/jxl/stats.h index c9359dc870..5ed440636f 100644 --- a/third_party/jpeg-xl/lib/include/jxl/stats.h +++ b/third_party/jpeg-xl/lib/include/jxl/stats.h @@ -23,15 +23,15 @@ extern "C" { /** * Opaque structure that holds the encoder statistics. * - * Allocated and initialized with JxlEncoderStatsCreate(). - * Cleaned up and deallocated with JxlEncoderStatsDestroy(). + * Allocated and initialized with @ref JxlEncoderStatsCreate(). + * Cleaned up and deallocated with @ref JxlEncoderStatsDestroy(). */ typedef struct JxlEncoderStatsStruct JxlEncoderStats; /** * Creates an instance of JxlEncoderStats and initializes it. * - * @return pointer to initialized JxlEncoderStats instance + * @return pointer to initialized @ref JxlEncoderStats instance */ JXL_EXPORT JxlEncoderStats* JxlEncoderStatsCreate(void); @@ -43,7 +43,7 @@ JXL_EXPORT JxlEncoderStats* JxlEncoderStatsCreate(void); */ JXL_EXPORT void JxlEncoderStatsDestroy(JxlEncoderStats* stats); -/** Data type for querying JxlEncoderStats object +/** Data type for querying @ref JxlEncoderStats object */ typedef enum { JXL_ENC_STAT_HEADER_BITS, diff --git a/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner.h b/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner.h index 6166fe7d36..933f373ce9 100644 --- a/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner.h +++ b/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner.h @@ -41,24 +41,24 @@ extern "C" { #endif -/** Parallel runner internally using std::thread. Use as JxlParallelRunner. +/** Parallel runner internally using std::thread. Use as @ref JxlParallelRunner. */ JXL_THREADS_EXPORT JxlParallelRetCode JxlThreadParallelRunner( void* runner_opaque, void* jpegxl_opaque, JxlParallelRunInit init, JxlParallelRunFunction func, uint32_t start_range, uint32_t end_range); -/** Creates the runner for JxlThreadParallelRunner. Use as the opaque +/** Creates the runner for @ref JxlThreadParallelRunner. Use as the opaque * runner. */ JXL_THREADS_EXPORT void* JxlThreadParallelRunnerCreate( const JxlMemoryManager* memory_manager, size_t num_worker_threads); -/** Destroys the runner created by JxlThreadParallelRunnerCreate. +/** Destroys the runner created by @ref JxlThreadParallelRunnerCreate. */ JXL_THREADS_EXPORT void JxlThreadParallelRunnerDestroy(void* runner_opaque); /** Returns a default num_worker_threads value for - * JxlThreadParallelRunnerCreate. + * @ref JxlThreadParallelRunnerCreate. */ JXL_THREADS_EXPORT size_t JxlThreadParallelRunnerDefaultNumWorkerThreads(void); diff --git a/third_party/jpeg-xl/lib/include/jxl/types.h b/third_party/jpeg-xl/lib/include/jxl/types.h index a47216f878..2538dbaa82 100644 --- a/third_party/jpeg-xl/lib/include/jxl/types.h +++ b/third_party/jpeg-xl/lib/include/jxl/types.h @@ -13,7 +13,6 @@ #ifndef JXL_TYPES_H_ #define JXL_TYPES_H_ -#include #include #include @@ -32,15 +31,17 @@ extern "C" { #define JXL_TRUE 1 /** Portable @c false replacement. */ #define JXL_FALSE 0 -/** Converts of bool-like value to either JXL_TRUE or JXL_FALSE. */ +/** Converts of bool-like value to either ::JXL_TRUE or ::JXL_FALSE. */ #define TO_JXL_BOOL(C) (!!(C) ? JXL_TRUE : JXL_FALSE) +/** Converts JXL_BOOL to C++ bool. */ +#define FROM_JXL_BOOL(C) (static_cast(C)) /** Data type for the sample values per channel per pixel. */ typedef enum { /** Use 32-bit single-precision floating point values, with range 0.0-1.0 * (within gamut, may go outside this range for wide color gamut). Floating - * point output, either JXL_TYPE_FLOAT or JXL_TYPE_FLOAT16, is recommended + * point output, either ::JXL_TYPE_FLOAT or ::JXL_TYPE_FLOAT16, is recommended * for HDR and wide gamut images when color profile conversion is required. */ JXL_TYPE_FLOAT = 0, @@ -92,8 +93,7 @@ typedef struct { JxlDataType data_type; /** Whether multi-byte data types are represented in big endian or little - * endian format. This applies to JXL_TYPE_UINT16, JXL_TYPE_UINT32 - * and JXL_TYPE_FLOAT. + * endian format. This applies to ::JXL_TYPE_UINT16 and ::JXL_TYPE_FLOAT. */ JxlEndianness endianness; diff --git a/third_party/jpeg-xl/lib/jpegli.cmake b/third_party/jpeg-xl/lib/jpegli.cmake index f06912f438..a471c8b2ab 100644 --- a/third_party/jpeg-xl/lib/jpegli.cmake +++ b/third_party/jpeg-xl/lib/jpegli.cmake @@ -88,7 +88,6 @@ foreach (TESTFILE IN LISTS JPEGXL_INTERNAL_JPEGLI_TESTS) target_link_libraries(${TESTNAME} hwy jpegli-static - gmock GTest::GTest GTest::Main ${JPEG_LIBRARIES} diff --git a/third_party/jpeg-xl/lib/jpegli/adaptive_quantization.cc b/third_party/jpeg-xl/lib/jpegli/adaptive_quantization.cc index 6a8c4d3128..2039326cbd 100644 --- a/third_party/jpeg-xl/lib/jpegli/adaptive_quantization.cc +++ b/third_party/jpeg-xl/lib/jpegli/adaptive_quantization.cc @@ -5,6 +5,7 @@ #include "lib/jpegli/adaptive_quantization.h" +#include #include #include @@ -46,7 +47,7 @@ using hwy::HWY_NAMESPACE::Sqrt; using hwy::HWY_NAMESPACE::Sub; using hwy::HWY_NAMESPACE::ZeroIfNegative; -static constexpr float kInputScaling = 1.0f / 255.0f; +constexpr float kInputScaling = 1.0f / 255.0f; // Primary template: default to actual division. template @@ -65,7 +66,7 @@ struct FastDivision { } V operator()(const V n, const V d) const { -#if 1 // Faster on SKX +#if JXL_TRUE // Faster on SKX return Div(n, d); #else return n * ReciprocalNR(d); @@ -191,12 +192,12 @@ V ComputeMask(const D d, const V out_val) { } // mul and mul2 represent a scaling difference between jxl and butteraugli. -static const float kSGmul = 226.0480446705883f; -static const float kSGmul2 = 1.0f / 73.377132366608819f; -static const float kLog2 = 0.693147181f; +const float kSGmul = 226.0480446705883f; +const float kSGmul2 = 1.0f / 73.377132366608819f; +const float kLog2 = 0.693147181f; // Includes correction factor for std::log -> log2. -static const float kSGRetMul = kSGmul2 * 18.6580932135f * kLog2; -static const float kSGVOffset = 7.14672470003f; +const float kSGRetMul = kSGmul2 * 18.6580932135f * kLog2; +const float kSGVOffset = 7.14672470003f; template V RatioOfDerivativesOfCubicRootToSimpleGamma(const D d, V v) { @@ -226,7 +227,7 @@ V RatioOfDerivativesOfCubicRootToSimpleGamma(const D d, V v) { } template -static float RatioOfDerivativesOfCubicRootToSimpleGamma(float v) { +float RatioOfDerivativesOfCubicRootToSimpleGamma(float v) { using DScalar = HWY_CAPPED(float, 1); auto vscalar = Load(DScalar(), &v); return GetLane( @@ -503,7 +504,7 @@ HWY_EXPORT(PerBlockModulations); namespace { -static constexpr int kPreErosionBorder = 1; +constexpr int kPreErosionBorder = 1; } // namespace diff --git a/third_party/jpeg-xl/lib/jpegli/bitstream.cc b/third_party/jpeg-xl/lib/jpegli/bitstream.cc index 3448367dde..4dbeb738bb 100644 --- a/third_party/jpeg-xl/lib/jpegli/bitstream.cc +++ b/third_party/jpeg-xl/lib/jpegli/bitstream.cc @@ -90,8 +90,8 @@ bool EncodeDQT(j_compress_ptr cinfo, bool write_all_tables) { JPEGLI_ERROR("Missing quant table %d", i); } int precision = 0; - for (size_t k = 0; k < DCTSIZE2; ++k) { - if (quant_table->quantval[k] > 255) { + for (UINT16 q : quant_table->quantval) { + if (q > 255) { precision = 1; is_baseline = false; } @@ -123,7 +123,6 @@ bool EncodeDQT(j_compress_ptr cinfo, bool write_all_tables) { void EncodeSOF(j_compress_ptr cinfo, bool is_baseline) { if (cinfo->data_precision != kJpegPrecision) { - is_baseline = false; JPEGLI_ERROR("Unsupported data precision %d", cinfo->data_precision); } const uint8_t marker = cinfo->progressive_mode ? 0xc2 @@ -302,7 +301,7 @@ void WriteBlock(const int32_t* JXL_RESTRICT symbols, namespace { -static JXL_INLINE void EmitMarker(JpegBitWriter* bw, int marker) { +JXL_INLINE void EmitMarker(JpegBitWriter* bw, int marker) { bw->data[bw->pos++] = 0xFF; bw->data[bw->pos++] = marker; } diff --git a/third_party/jpeg-xl/lib/jpegli/bitstream.h b/third_party/jpeg-xl/lib/jpegli/bitstream.h index aa54c73d7e..bed441aefe 100644 --- a/third_party/jpeg-xl/lib/jpegli/bitstream.h +++ b/third_party/jpeg-xl/lib/jpegli/bitstream.h @@ -32,9 +32,8 @@ void EncodeSOS(j_compress_ptr cinfo, int scan_index); void WriteScanHeader(j_compress_ptr cinfo, int scan_index); void WriteBlock(const int32_t* JXL_RESTRICT symbols, - const int32_t* JXL_RESTRICT extra_bits, const int num_nonzeros, - const bool emit_eob, - const HuffmanCodeTable* JXL_RESTRICT dc_code, + const int32_t* JXL_RESTRICT extra_bits, int num_nonzeros, + bool emit_eob, const HuffmanCodeTable* JXL_RESTRICT dc_code, const HuffmanCodeTable* JXL_RESTRICT ac_code, JpegBitWriter* JXL_RESTRICT bw); void WriteScanData(j_compress_ptr cinfo, int scan_index); diff --git a/third_party/jpeg-xl/lib/jpegli/color_quantize.cc b/third_party/jpeg-xl/lib/jpegli/color_quantize.cc index e8357e2160..c4f32bf439 100644 --- a/third_party/jpeg-xl/lib/jpegli/color_quantize.cc +++ b/third_party/jpeg-xl/lib/jpegli/color_quantize.cc @@ -11,13 +11,14 @@ #include "lib/jpegli/decode_internal.h" #include "lib/jpegli/error.h" +#include "lib/jxl/base/status.h" namespace jpegli { namespace { -static constexpr int kNumColorCellBits[kMaxComponents] = {3, 4, 3, 3}; -static constexpr int kCompW[kMaxComponents] = {2, 3, 1, 1}; +constexpr int kNumColorCellBits[kMaxComponents] = {3, 4, 3, 3}; +constexpr int kCompW[kMaxComponents] = {2, 3, 1, 1}; int Pow(int a, int b) { int r = 1; @@ -102,8 +103,8 @@ namespace { // 2^13 priority levels for the PQ seems to be a good compromise between // accuracy, running time and stack space usage. -static const int kMaxPriority = 1 << 13; -static const int kMaxLevel = 3; +const int kMaxPriority = 1 << 13; +const int kMaxLevel = 3; // This function is used in the multi-resolution grid to be able to compute // the keys for the different resolutions by just shifting the first key. @@ -153,7 +154,7 @@ inline int ColorIntQuadDistanceRGB(uint8_t r1, uint8_t g1, uint8_t b1, } inline int ScaleQuadDistanceRGB(int d) { - return static_cast(sqrt(d * 0.25) + 0.5); + return static_cast(std::lround(sqrt(d * 0.25))); } // The function updates the minimal distances, the clustering and the @@ -216,9 +217,9 @@ struct WangHasher { // to a unique integer index assigned to the different colors in order of // appearance in the image. Return the number of unique colors found. // The colors are pre-quantized to 3 * 6 bits precision. -static int BuildRGBColorIndex(const uint8_t* const image, int const num_pixels, - int* const count, uint8_t* const red, - uint8_t* const green, uint8_t* const blue) { +int BuildRGBColorIndex(const uint8_t* const image, int const num_pixels, + int* const count, uint8_t* const red, + uint8_t* const green, uint8_t* const blue) { // Impossible because rgb are in the low 24 bits, and the upper 8 bits is 0. const uint32_t impossible_pixel_value = 0x10000000; std::unordered_map index_map(1 << 12); @@ -264,7 +265,7 @@ void ChooseColorMap2Pass(j_decompress_ptr cinfo) { std::unique_ptr blue(new uint8_t[max_color_count]); std::vector count(max_color_count, 0); // number of colors - int n = BuildRGBColorIndex(m->pixels_, num_pixels, &count[0], &red[0], + int n = BuildRGBColorIndex(m->pixels_, num_pixels, count.data(), &red[0], &green[0], &blue[0]); std::vector dist(n, std::numeric_limits::max()); @@ -285,14 +286,14 @@ void ChooseColorMap2Pass(j_decompress_ptr cinfo) { winner = i; } if (!in_palette[i] && count[i] > count_threshold) { - AddToRGBPalette(&red[0], &green[0], &blue[0], &count[0], i, k++, n, - &dist[0], &cluster[0], ¢er[0], &error); + AddToRGBPalette(&red[0], &green[0], &blue[0], count.data(), i, k++, n, + dist.data(), cluster.data(), ¢er[0], &error); in_palette[i] = true; } } if (k == 0) { - AddToRGBPalette(&red[0], &green[0], &blue[0], &count[0], winner, k++, n, - &dist[0], &cluster[0], ¢er[0], &error); + AddToRGBPalette(&red[0], &green[0], &blue[0], count.data(), winner, k++, n, + dist.data(), cluster.data(), ¢er[0], &error); in_palette[winner] = true; } @@ -365,8 +366,8 @@ void ChooseColorMap2Pass(j_decompress_ptr cinfo) { if (priority < top_priority) { bucket_array[priority].push_back(i); } else { - AddToRGBPalette(&red[0], &green[0], &blue[0], &count[0], i, k++, n, - &dist[0], &cluster[0], ¢er[0], &error); + AddToRGBPalette(&red[0], &green[0], &blue[0], count.data(), i, k++, n, + dist.data(), cluster.data(), ¢er[0], &error); } bucket_array[top_priority].pop_back(); while (top_priority >= 0 && bucket_array[top_priority].empty()) { @@ -387,7 +388,7 @@ void ChooseColorMap2Pass(j_decompress_ptr cinfo) { namespace { -void FindCandidatesForCell(j_decompress_ptr cinfo, int ncomp, int cell[], +void FindCandidatesForCell(j_decompress_ptr cinfo, int ncomp, const int cell[], std::vector* candidates) { int cell_min[kMaxComponents]; int cell_max[kMaxComponents]; @@ -404,7 +405,8 @@ void FindCandidatesForCell(j_decompress_ptr cinfo, int ncomp, int cell[], int dmax = 0; for (int c = 0; c < ncomp; ++c) { int palette_c = cinfo->colormap[c][i]; - int dminc = 0, dmaxc; + int dminc = 0; + int dmaxc; if (palette_c < cell_min[c]) { dminc = cell_min[c] - palette_c; dmaxc = cell_max[c] - palette_c; @@ -436,6 +438,8 @@ void FindCandidatesForCell(j_decompress_ptr cinfo, int ncomp, int cell[], void CreateInverseColorMap(j_decompress_ptr cinfo) { jpeg_decomp_master* m = cinfo->master; int ncomp = cinfo->out_color_components; + JXL_ASSERT(ncomp > 0); + JXL_ASSERT(ncomp <= kMaxComponents); int num_cells = 1; for (int c = 0; c < ncomp; ++c) { num_cells *= (1 << kNumColorCellBits[c]); @@ -455,7 +459,7 @@ void CreateInverseColorMap(j_decompress_ptr cinfo) { m->regenerate_inverse_colormap_ = false; } -int LookupColorIndex(j_decompress_ptr cinfo, JSAMPLE* pixel) { +int LookupColorIndex(j_decompress_ptr cinfo, const JSAMPLE* pixel) { jpeg_decomp_master* m = cinfo->master; int num_channels = cinfo->out_color_components; int index = 0; diff --git a/third_party/jpeg-xl/lib/jpegli/color_quantize.h b/third_party/jpeg-xl/lib/jpegli/color_quantize.h index 3dda1d8713..92b922f756 100644 --- a/third_party/jpeg-xl/lib/jpegli/color_quantize.h +++ b/third_party/jpeg-xl/lib/jpegli/color_quantize.h @@ -20,7 +20,7 @@ void CreateOrderedDitherTables(j_decompress_ptr cinfo); void InitFSDitherState(j_decompress_ptr cinfo); -int LookupColorIndex(j_decompress_ptr cinfo, JSAMPLE* pixel); +int LookupColorIndex(j_decompress_ptr cinfo, const JSAMPLE* pixel); } // namespace jpegli diff --git a/third_party/jpeg-xl/lib/jpegli/dct-inl.h b/third_party/jpeg-xl/lib/jpegli/dct-inl.h index 1cbe704002..66cc3b6b53 100644 --- a/third_party/jpeg-xl/lib/jpegli/dct-inl.h +++ b/third_party/jpeg-xl/lib/jpegli/dct-inl.h @@ -187,7 +187,7 @@ void DCT1D(const float* JXL_RESTRICT pixels, size_t pixels_stride, } } -static JXL_INLINE JXL_MAYBE_UNUSED void TransformFromPixels( +JXL_INLINE JXL_MAYBE_UNUSED void TransformFromPixels( const float* JXL_RESTRICT pixels, size_t pixels_stride, float* JXL_RESTRICT coefficients, float* JXL_RESTRICT scratch_space) { DCT1D(pixels, pixels_stride, scratch_space); @@ -196,14 +196,14 @@ static JXL_INLINE JXL_MAYBE_UNUSED void TransformFromPixels( Transpose8x8Block(scratch_space, coefficients); } -static JXL_INLINE JXL_MAYBE_UNUSED void StoreQuantizedValue(const Vec& ival, - int16_t* out) { +JXL_INLINE JXL_MAYBE_UNUSED void StoreQuantizedValue(const Vec& ival, + int16_t* out) { Rebind di16; Store(DemoteTo(di16, ival), di16, out); } -static JXL_INLINE JXL_MAYBE_UNUSED void StoreQuantizedValue(const Vec& ival, - int32_t* out) { +JXL_INLINE JXL_MAYBE_UNUSED void StoreQuantizedValue(const Vec& ival, + int32_t* out) { DI di; Store(ival, di, out); } diff --git a/third_party/jpeg-xl/lib/jpegli/decode.cc b/third_party/jpeg-xl/lib/jpegli/decode.cc index 758babeb5e..9fdf68dd18 100644 --- a/third_party/jpeg-xl/lib/jpegli/decode.cc +++ b/third_party/jpeg-xl/lib/jpegli/decode.cc @@ -115,8 +115,10 @@ void InitProgressMonitor(j_decompress_ptr cinfo, bool coef_only) { cinfo->progress->total_passes = 1; } else { int input_passes = !cinfo->buffered_image && m->is_multiscan_ ? 1 : 0; - bool two_pass_quant = cinfo->quantize_colors && !cinfo->colormap && - cinfo->two_pass_quantize && cinfo->enable_2pass_quant; + bool two_pass_quant = FROM_JXL_BOOL(cinfo->quantize_colors) && + (cinfo->colormap != nullptr) && + FROM_JXL_BOOL(cinfo->two_pass_quantize) && + FROM_JXL_BOOL(cinfo->enable_2pass_quant); cinfo->progress->total_passes = input_passes + (two_pass_quant ? 2 : 1); } cinfo->progress->completed_passes = 0; @@ -175,7 +177,7 @@ void BuildHuffmanLookupTable(j_decompress_ptr cinfo, JHUFF_TBL* table, for (int i = 0; i < total_count; ++i) { int value = table->huffval[i]; if (values_seen[value]) { - return JPEGLI_ERROR("Duplicate Huffman code value %d", value); + JPEGLI_ERROR("Duplicate Huffman code value %d", value); } values_seen[value] = 1; values[i] = value; @@ -223,7 +225,7 @@ void PrepareForScan(j_decompress_ptr cinfo) { HuffmanTableEntry* huff_lut = &m->dc_huff_lut_[dc_tbl_idx * kJpegHuffmanLutSize]; if (!table) { - return JPEGLI_ERROR("DC Huffman table %d not found", dc_tbl_idx); + JPEGLI_ERROR("DC Huffman table %d not found", dc_tbl_idx); } BuildHuffmanLookupTable(cinfo, table, huff_lut); } @@ -233,7 +235,7 @@ void PrepareForScan(j_decompress_ptr cinfo) { HuffmanTableEntry* huff_lut = &m->ac_huff_lut_[ac_tbl_idx * kJpegHuffmanLutSize]; if (!table) { - return JPEGLI_ERROR("AC Huffman table %d not found", ac_tbl_idx); + JPEGLI_ERROR("AC Huffman table %d not found", ac_tbl_idx); } BuildHuffmanLookupTable(cinfo, table, huff_lut); } @@ -543,8 +545,8 @@ void jpegli_CreateDecompress(j_decompress_ptr cinfo, int version, cinfo->is_decompressor = TRUE; cinfo->progress = nullptr; cinfo->src = nullptr; - for (int i = 0; i < NUM_QUANT_TBLS; i++) { - cinfo->quant_tbl_ptrs[i] = nullptr; + for (auto& quant_tbl_ptr : cinfo->quant_tbl_ptrs) { + quant_tbl_ptr = nullptr; } for (int i = 0; i < NUM_HUFF_TBLS; i++) { cinfo->dc_huff_tbl_ptrs[i] = nullptr; @@ -555,8 +557,8 @@ void jpegli_CreateDecompress(j_decompress_ptr cinfo, int version, cinfo->rec_outbuf_height = 1; // output works with any buffer height cinfo->master = new jpeg_decomp_master; jpeg_decomp_master* m = cinfo->master; - for (int i = 0; i < 16; ++i) { - m->app_marker_parsers[i] = nullptr; + for (auto& app_marker_parser : m->app_marker_parsers) { + app_marker_parser = nullptr; } m->com_marker_parser = nullptr; memset(m->markers_to_save_, 0, sizeof(m->markers_to_save_)); @@ -661,7 +663,7 @@ boolean jpegli_read_icc_profile(j_decompress_ptr cinfo, JOCTET** icc_data_ptr, return FALSE; } *icc_data_len = m->icc_profile_.size(); - *icc_data_ptr = (JOCTET*)malloc(*icc_data_len); + *icc_data_ptr = static_cast(malloc(*icc_data_len)); if (*icc_data_ptr == nullptr) { JPEGLI_ERROR("jpegli_read_icc_profile: Out of memory"); } @@ -738,21 +740,26 @@ void jpegli_calc_output_dimensions(j_decompress_ptr cinfo) { } boolean jpegli_has_multiple_scans(j_decompress_ptr cinfo) { - if (cinfo->input_scan_number == 0) { - JPEGLI_ERROR("No SOS marker found."); + if (cinfo->global_state != jpegli::kDecHeaderDone && + cinfo->global_state != jpegli::kDecProcessScan && + cinfo->global_state != jpegli::kDecProcessMarkers) { + JPEGLI_ERROR("jpegli_has_multiple_scans: unexpected state %d", + cinfo->global_state); } - return cinfo->master->is_multiscan_; + return TO_JXL_BOOL(cinfo->master->is_multiscan_); } boolean jpegli_input_complete(j_decompress_ptr cinfo) { - return cinfo->master->found_eoi_; + return TO_JXL_BOOL(cinfo->master->found_eoi_); } boolean jpegli_start_decompress(j_decompress_ptr cinfo) { jpeg_decomp_master* m = cinfo->master; if (cinfo->global_state == jpegli::kDecHeaderDone) { - m->streaming_mode_ = !m->is_multiscan_ && !cinfo->buffered_image && - (!cinfo->quantize_colors || !cinfo->two_pass_quantize); + m->streaming_mode_ = !m->is_multiscan_ && + !FROM_JXL_BOOL(cinfo->buffered_image) && + (!FROM_JXL_BOOL(cinfo->quantize_colors) || + !FROM_JXL_BOOL(cinfo->two_pass_quantize)); jpegli::AllocateCoefficientBuffer(cinfo); jpegli_calc_output_dimensions(cinfo); jpegli::PrepareForScan(cinfo); diff --git a/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc b/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc index c48b9377c3..0cc5a194d7 100644 --- a/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc @@ -18,8 +18,8 @@ namespace jpegli { namespace { -static constexpr uint8_t kFakeEoiMarker[2] = {0xff, 0xd9}; -static constexpr size_t kNumSourceBuffers = 4; +constexpr uint8_t kFakeEoiMarker[2] = {0xff, 0xd9}; +constexpr size_t kNumSourceBuffers = 4; // Custom source manager that refills the input buffer in chunks, simulating // a file reader with a fixed buffer size. @@ -61,7 +61,7 @@ class SourceManager { static void init_source(j_decompress_ptr cinfo) {} static boolean fill_input_buffer(j_decompress_ptr cinfo) { - auto src = reinterpret_cast(cinfo->src); + auto* src = reinterpret_cast(cinfo->src); if (src->pos_ < src->len_) { size_t chunk_size = std::min(src->len_ - src->pos_, src->max_chunk_size_); size_t next_idx = ++src->chunk_idx_ % kNumSourceBuffers; @@ -79,7 +79,7 @@ class SourceManager { } static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) { - auto src = reinterpret_cast(cinfo->src); + auto* src = reinterpret_cast(cinfo->src); if (num_bytes <= 0) { return; } @@ -166,9 +166,9 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo, rowdata[c][i] = y0 + i < ysize ? &output->raw_data[c][(y0 + i) * xsize] : nullptr; } - data[c] = &rowdata[c][0]; + data[c] = rowdata[c].data(); } - num_output_lines = jpegli_read_raw_data(cinfo, &data[0], max_lines); + num_output_lines = jpegli_read_raw_data(cinfo, data.data(), max_lines); } else { size_t max_output_lines = dparams.max_output_lines; if (max_output_lines == 0) max_output_lines = cinfo->output_height; @@ -189,7 +189,7 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo, scanlines[i] = &output->pixels[yidx * stride]; } num_output_lines = - jpegli_read_scanlines(cinfo, &scanlines[0], max_lines); + jpegli_read_scanlines(cinfo, scanlines.data(), max_lines); if (cinfo->quantize_colors) { for (size_t i = 0; i < num_output_lines; ++i) { UnmapColors(scanlines[i], cinfo->output_width, @@ -222,7 +222,7 @@ struct TestConfig { std::vector GetTestJpegData(TestConfig& config) { std::vector compressed; if (!config.fn.empty()) { - compressed = ReadTestData(config.fn.c_str()); + compressed = ReadTestData(config.fn); } else { GeneratePixels(&config.input); JXL_CHECK(EncodeWithJpegli(config.input, config.jparams, &compressed)); @@ -297,10 +297,10 @@ void TestAPIBuffered(const CompressParams& jparams, SetDecompressParams(dparams, cinfo); jpegli_set_output_format(cinfo, dparams.data_type, dparams.endianness); VerifyHeader(jparams, cinfo); + bool has_multiple_scans = FROM_JXL_BOOL(jpegli_has_multiple_scans(cinfo)); EXPECT_TRUE(jpegli_start_decompress(cinfo)); // start decompress should not read the whole input in buffered image mode EXPECT_FALSE(jpegli_input_complete(cinfo)); - bool has_multiple_scans = jpegli_has_multiple_scans(cinfo); EXPECT_EQ(0, cinfo->output_scan_number); int sos_marker_cnt = 1; // read_header reads the first SOS marker while (!jpegli_input_complete(cinfo)) { @@ -341,8 +341,11 @@ void TestAPIBuffered(const CompressParams& jparams, } TEST(DecodeAPITest, ReuseCinfo) { - TestImage input, output, expected; - std::vector output_progression, expected_output_progression; + TestImage input; + TestImage output; + TestImage expected; + std::vector output_progression; + std::vector expected_output_progression; CompressParams jparams; DecompressParams dparams; std::vector compressed; @@ -383,8 +386,8 @@ TEST(DecodeAPITest, ReuseCinfo) { expected.Clear(); DecodeWithLibjpeg(jparams, dparams, compressed, &expected); output.Clear(); - cinfo.buffered_image = false; - cinfo.raw_data_out = false; + cinfo.buffered_image = JXL_FALSE; + cinfo.raw_data_out = JXL_FALSE; cinfo.scale_num = cinfo.scale_denom = 1; SourceManager src(compressed.data(), compressed.size(), 1u << 12); @@ -1245,7 +1248,8 @@ std::ostream& operator<<(std::ostream& os, const DecompressParams& dparams) { } os << IOMethodName(dparams.data_type, dparams.endianness); if (dparams.set_out_color_space) { - os << "OutColor" << ColorSpaceName((J_COLOR_SPACE)dparams.out_color_space); + os << "OutColor" + << ColorSpaceName(static_cast(dparams.out_color_space)); } if (dparams.crop_output) { os << "Crop"; @@ -1265,7 +1269,8 @@ std::ostream& operator<<(std::ostream& os, const DecompressParams& dparams) { if (i > 0) os << "_"; const auto& sparam = dparams.scan_params[i]; os << QuantMode(sparam.color_quant_mode); - os << DitherMode((J_DITHER_MODE)sparam.dither_mode) << "Dither"; + os << DitherMode(static_cast(sparam.dither_mode)) + << "Dither"; } } if (dparams.skip_scans) { diff --git a/third_party/jpeg-xl/lib/jpegli/decode_internal.h b/third_party/jpeg-xl/lib/jpegli/decode_internal.h index ed7baa39e9..37dfcc4526 100644 --- a/third_party/jpeg-xl/lib/jpegli/decode_internal.h +++ b/third_party/jpeg-xl/lib/jpegli/decode_internal.h @@ -45,12 +45,13 @@ struct jpeg_decomp_master { size_t input_buffer_pos_; // Number of bits after codestream_pos_ that were already processed. size_t codestream_bits_ahead_; - bool streaming_mode_; // Coefficient buffers jvirt_barray_ptr* coef_arrays; JBLOCKARRAY coeff_rows[jpegli::kMaxComponents]; + bool streaming_mode_; + // // Marker data processing state. // @@ -58,6 +59,11 @@ struct jpeg_decomp_master { bool found_dri_; bool found_sof_; bool found_eoi_; + + // Whether this jpeg has multiple scans (progressive or non-interleaved + // sequential). + bool is_multiscan_; + size_t icc_index_; size_t icc_total_; std::vector icc_profile_; @@ -66,9 +72,6 @@ struct jpeg_decomp_master { uint8_t markers_to_save_[32]; jpeg_marker_parser_method app_marker_parsers[16]; jpeg_marker_parser_method com_marker_parser; - // Whether this jpeg has multiple scans (progressive or non-interleaved - // sequential). - bool is_multiscan_; // Fields defined by SOF marker. size_t iMCU_cols_; @@ -96,9 +99,11 @@ struct jpeg_decomp_master { // int output_passes_done_; JpegliDataType output_data_type_ = JPEGLI_TYPE_UINT8; - bool swap_endianness_ = false; size_t xoffset_; + bool swap_endianness_ = false; bool need_context_rows_; + bool regenerate_inverse_colormap_; + bool apply_smoothing; int min_scaled_dct_size; int scaled_dct_size[jpegli::kMaxComponents]; @@ -127,7 +132,6 @@ struct jpeg_decomp_master { uint8_t* pixels_; JSAMPARRAY scanlines_; std::vector> candidate_lists_; - bool regenerate_inverse_colormap_; float* dither_[jpegli::kMaxComponents]; float* error_row_[2 * jpegli::kMaxComponents]; size_t dither_size_; @@ -145,7 +149,6 @@ struct jpeg_decomp_master { // i.e. the bottom half when rendering incomplete scans. int (*coef_bits_latch)[SAVED_COEFS]; int (*prev_coef_bits_latch)[SAVED_COEFS]; - bool apply_smoothing; }; #endif // LIB_JPEGLI_DECODE_INTERNAL_H_ diff --git a/third_party/jpeg-xl/lib/jpegli/decode_marker.cc b/third_party/jpeg-xl/lib/jpegli/decode_marker.cc index c5c5790cdf..a9ed4df329 100644 --- a/third_party/jpeg-xl/lib/jpegli/decode_marker.cc +++ b/third_party/jpeg-xl/lib/jpegli/decode_marker.cc @@ -5,6 +5,7 @@ #include "lib/jpegli/decode_marker.h" +#include #include #include "lib/jpegli/common.h" @@ -22,23 +23,22 @@ constexpr uint8_t kIccProfileTag[12] = "ICC_PROFILE"; // Macros for commonly used error conditions. -#define JPEG_VERIFY_LEN(n) \ - if (pos + (n) > len) { \ - return JPEGLI_ERROR("Unexpected end of marker: pos=%" PRIuS \ - " need=%d len=%" PRIuS, \ - pos, static_cast(n), len); \ +#define JPEG_VERIFY_LEN(n) \ + if (pos + (n) > len) { \ + JPEGLI_ERROR("Unexpected end of marker: pos=%" PRIuS \ + " need=%d len=%" PRIuS, \ + pos, static_cast(n), len); \ } -#define JPEG_VERIFY_INPUT(var, low, high) \ - if ((var) < (low) || (var) > (high)) { \ - return JPEGLI_ERROR("Invalid " #var ": %d", static_cast(var)); \ +#define JPEG_VERIFY_INPUT(var, low, high) \ + if ((var) < (low) || (var) > (high)) { \ + JPEGLI_ERROR("Invalid " #var ": %d", static_cast(var)); \ } -#define JPEG_VERIFY_MARKER_END() \ - if (pos != len) { \ - return JPEGLI_ERROR("Invalid marker length: declared=%" PRIuS \ - " actual=%" PRIuS, \ - len, pos); \ +#define JPEG_VERIFY_MARKER_END() \ + if (pos != len) { \ + JPEGLI_ERROR("Invalid marker length: declared=%" PRIuS " actual=%" PRIuS, \ + len, pos); \ } inline int ReadUint8(const uint8_t* data, size_t* pos) { @@ -60,7 +60,7 @@ void ProcessSOF(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { JPEGLI_ERROR("Duplicate SOF marker."); } m->found_sof_ = true; - cinfo->progressive_mode = (cinfo->unread_marker == 0xc2); + cinfo->progressive_mode = TO_JXL_BOOL(cinfo->unread_marker == 0xc2); cinfo->arith_code = 0; size_t pos = 2; JPEG_VERIFY_LEN(6); @@ -181,7 +181,7 @@ void ProcessSOS(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { for (int i = 0; i < cinfo->comps_in_scan; ++i) { int id = ReadUint8(data, &pos); if (ids_seen[id]) { // (cf. section B.2.3, regarding CSj) - return JPEGLI_ERROR("Duplicate ID %d in SOS.", id); + JPEGLI_ERROR("Duplicate ID %d in SOS.", id); } ids_seen[id] = 1; jpeg_component_info* comp = nullptr; @@ -192,8 +192,7 @@ void ProcessSOS(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { } } if (!comp) { - return JPEGLI_ERROR("SOS marker: Could not find component with id %d", - id); + JPEGLI_ERROR("SOS marker: Could not find component with id %d", id); } int c = ReadUint8(data, &pos); comp->dc_tbl_no = c >> 4; @@ -222,7 +221,7 @@ void ProcessSOS(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { if (cinfo->input_scan_number == 0) { m->is_multiscan_ = (cinfo->comps_in_scan < cinfo->num_components || - cinfo->progressive_mode); + FROM_JXL_BOOL(cinfo->progressive_mode)); } if (cinfo->Ah != 0 && cinfo->Al != cinfo->Ah - 1) { // section G.1.1.1.2 : Successive approximation control only improves @@ -261,12 +260,12 @@ void ProcessSOS(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { int comp_idx = cinfo->cur_comp_info[i]->component_index; for (int k = cinfo->Ss; k <= cinfo->Se; ++k) { if (m->scan_progression_[comp_idx][k] & scan_bitmask) { - return JPEGLI_ERROR( + JPEGLI_ERROR( "Overlapping scans: component=%d k=%d prev_mask: %u cur_mask %u", comp_idx, k, m->scan_progression_[i][k], scan_bitmask); } if (m->scan_progression_[comp_idx][k] & refinement_bitmask) { - return JPEGLI_ERROR( + JPEGLI_ERROR( "Invalid scan order, a more refined scan was already done: " "component=%d k=%d prev_mask=%u cur_mask=%u", comp_idx, k, m->scan_progression_[i][k], scan_bitmask); @@ -275,7 +274,7 @@ void ProcessSOS(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { } } if (cinfo->Al > 10) { - return JPEGLI_ERROR("Scan parameter Al=%d is not supported.", cinfo->Al); + JPEGLI_ERROR("Scan parameter Al=%d is not supported.", cinfo->Al); } } @@ -285,7 +284,7 @@ void ProcessSOS(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { void ProcessDHT(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { size_t pos = 2; if (pos == len) { - return JPEGLI_ERROR("DHT marker: no Huffman table found"); + JPEGLI_ERROR("DHT marker: no Huffman table found"); } while (pos < len) { JPEG_VERIFY_LEN(1 + kJpegHuffmanMaxBitLength); @@ -293,7 +292,7 @@ void ProcessDHT(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { // component Huffman codes, 0x10 is added to the index. int slot_id = ReadUint8(data, &pos); int huffman_index = slot_id; - int is_ac_table = (slot_id & 0x10) != 0; + bool is_ac_table = ((slot_id & 0x10) != 0); JHUFF_TBL** table; if (is_ac_table) { huffman_index -= 0x10; @@ -343,7 +342,7 @@ void ProcessDQT(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { } size_t pos = 2; if (pos == len) { - return JPEGLI_ERROR("DQT marker: no quantization table found"); + JPEGLI_ERROR("DQT marker: no quantization table found"); } while (pos < len) { JPEG_VERIFY_LEN(1); @@ -377,7 +376,7 @@ void ProcessDNL(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { void ProcessDRI(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { jpeg_decomp_master* m = cinfo->master; if (m->found_dri_) { - return JPEGLI_ERROR("Duplicate DRI marker."); + JPEGLI_ERROR("Duplicate DRI marker."); } m->found_dri_ = true; size_t pos = 2; @@ -411,24 +410,24 @@ void ProcessAPP(j_decompress_ptr cinfo, const uint8_t* data, size_t len) { payload += sizeof(kIccProfileTag); payload_size -= sizeof(kIccProfileTag); if (payload_size < 2) { - return JPEGLI_ERROR("ICC chunk is too small."); + JPEGLI_ERROR("ICC chunk is too small."); } uint8_t index = payload[0]; uint8_t total = payload[1]; ++m->icc_index_; if (m->icc_index_ != index) { - return JPEGLI_ERROR("Invalid ICC chunk order."); + JPEGLI_ERROR("Invalid ICC chunk order."); } if (total == 0) { - return JPEGLI_ERROR("Invalid ICC chunk total."); + JPEGLI_ERROR("Invalid ICC chunk total."); } if (m->icc_total_ == 0) { m->icc_total_ = total; } else if (m->icc_total_ != total) { - return JPEGLI_ERROR("Invalid ICC chunk total."); + JPEGLI_ERROR("Invalid ICC chunk total."); } if (m->icc_index_ > m->icc_total_) { - return JPEGLI_ERROR("Invalid ICC chunk index."); + JPEGLI_ERROR("Invalid ICC chunk index."); } m->icc_profile_.insert(m->icc_profile_.end(), payload + 2, payload + payload_size); @@ -494,8 +493,8 @@ uint8_t ProcessNextMarker(j_decompress_ptr cinfo, const uint8_t* const data, marker = data[*pos + 1]; if (num_skipped > 0) { if (m->found_soi_) { - JPEGLI_WARN("Skipped %d bytes before marker 0x%02x", (int)num_skipped, - marker); + JPEGLI_WARN("Skipped %d bytes before marker 0x%02x", + static_cast(num_skipped), marker); } else { JPEGLI_ERROR("Did not find SOI marker."); } diff --git a/third_party/jpeg-xl/lib/jpegli/decode_marker.h b/third_party/jpeg-xl/lib/jpegli/decode_marker.h index fb24b3ee87..f3d47f6ad2 100644 --- a/third_party/jpeg-xl/lib/jpegli/decode_marker.h +++ b/third_party/jpeg-xl/lib/jpegli/decode_marker.h @@ -22,8 +22,8 @@ namespace jpegli { // EOI marker. Input buffer refill is handled by the caller; // * JPEG_REACHED_SOS, if the next SOS marker is found; // * JPEG_REACHED_EOR, if the end of the input is found. -int ProcessMarkers(j_decompress_ptr cinfo, const uint8_t* const data, - const size_t len, size_t* pos); +int ProcessMarkers(j_decompress_ptr cinfo, const uint8_t* data, size_t len, + size_t* pos); jpeg_marker_parser_method GetMarkerProcessor(j_decompress_ptr cinfo); diff --git a/third_party/jpeg-xl/lib/jpegli/decode_scan.cc b/third_party/jpeg-xl/lib/jpegli/decode_scan.cc index 05b1f37220..1b50792f0a 100644 --- a/third_party/jpeg-xl/lib/jpegli/decode_scan.cc +++ b/third_party/jpeg-xl/lib/jpegli/decode_scan.cc @@ -61,7 +61,7 @@ struct BitReaderState { if (bits_left_ <= 16) { while (bits_left_ <= 56) { val_ <<= 8; - val_ |= (uint64_t)GetNextByte(); + val_ |= static_cast(GetNextByte()); bits_left_ += 8; } } @@ -427,7 +427,7 @@ void PrepareForiMCURow(j_decompress_ptr cinfo) { int offset = m->streaming_mode_ ? 0 : by0; m->coeff_rows[c] = (*cinfo->mem->access_virt_barray)( reinterpret_cast(cinfo), m->coef_arrays[c], offset, - max_block_rows, true); + max_block_rows, TRUE); } } @@ -451,7 +451,8 @@ int ProcessScan(j_decompress_ptr cinfo, const uint8_t* const data, ++num_skipped; } if (num_skipped > 0) { - JPEGLI_WARN("Skipped %d bytes before restart marker", (int)num_skipped); + JPEGLI_WARN("Skipped %d bytes before restart marker", + static_cast(num_skipped)); } if (*pos + 2 > len) { return kNeedMoreInput; @@ -471,7 +472,7 @@ int ProcessScan(j_decompress_ptr cinfo, const uint8_t* const data, } // Decode one MCU. - HWY_ALIGN_MAX coeff_t sink_block[DCTSIZE2]; + HWY_ALIGN_MAX static coeff_t sink_block[DCTSIZE2] = {0}; bool scan_ok = true; for (int i = 0; i < cinfo->comps_in_scan; ++i) { const jpeg_component_info* comp = cinfo->cur_comp_info[i]; diff --git a/third_party/jpeg-xl/lib/jpegli/decode_scan.h b/third_party/jpeg-xl/lib/jpegli/decode_scan.h index 1d7b18fc1a..dd1bfcd110 100644 --- a/third_party/jpeg-xl/lib/jpegli/decode_scan.h +++ b/third_party/jpeg-xl/lib/jpegli/decode_scan.h @@ -21,8 +21,8 @@ namespace jpegli { // * JPEG_SUSPENDED, if the input buffer ends before the end of an iMCU row; // * JPEG_ROW_COMPLETED, if the next iMCU row (but not the scan) is reached; // * JPEG_SCAN_COMPLETED, if the end of the scan is reached. -int ProcessScan(j_decompress_ptr cinfo, const uint8_t* const data, - const size_t len, size_t* pos, size_t* bit_pos); +int ProcessScan(j_decompress_ptr cinfo, const uint8_t* data, size_t len, + size_t* pos, size_t* bit_pos); void PrepareForiMCURow(j_decompress_ptr cinfo); diff --git a/third_party/jpeg-xl/lib/jpegli/destination_manager.cc b/third_party/jpeg-xl/lib/jpegli/destination_manager.cc index 9bc269f0c9..6548130866 100644 --- a/third_party/jpeg-xl/lib/jpegli/destination_manager.cc +++ b/third_party/jpeg-xl/lib/jpegli/destination_manager.cc @@ -19,13 +19,13 @@ struct StdioDestinationManager { uint8_t* buffer; static void init_destination(j_compress_ptr cinfo) { - auto dest = reinterpret_cast(cinfo->dest); + auto* dest = reinterpret_cast(cinfo->dest); dest->pub.next_output_byte = dest->buffer; dest->pub.free_in_buffer = kDestBufferSize; } static boolean empty_output_buffer(j_compress_ptr cinfo) { - auto dest = reinterpret_cast(cinfo->dest); + auto* dest = reinterpret_cast(cinfo->dest); if (fwrite(dest->buffer, 1, kDestBufferSize, dest->f) != kDestBufferSize) { JPEGLI_ERROR("Failed to write to output stream."); } @@ -35,7 +35,7 @@ struct StdioDestinationManager { } static void term_destination(j_compress_ptr cinfo) { - auto dest = reinterpret_cast(cinfo->dest); + auto* dest = reinterpret_cast(cinfo->dest); size_t bytes_left = kDestBufferSize - dest->pub.free_in_buffer; if (bytes_left && fwrite(dest->buffer, 1, bytes_left, dest->f) != bytes_left) { @@ -62,7 +62,7 @@ struct MemoryDestinationManager { static void init_destination(j_compress_ptr cinfo) {} static boolean empty_output_buffer(j_compress_ptr cinfo) { - auto dest = reinterpret_cast(cinfo->dest); + auto* dest = reinterpret_cast(cinfo->dest); uint8_t* next_buffer = reinterpret_cast(malloc(dest->buffer_size * 2)); memcpy(next_buffer, dest->current_buffer, dest->buffer_size); @@ -80,7 +80,7 @@ struct MemoryDestinationManager { } static void term_destination(j_compress_ptr cinfo) { - auto dest = reinterpret_cast(cinfo->dest); + auto* dest = reinterpret_cast(cinfo->dest); *dest->output_size = dest->buffer_size - dest->pub.free_in_buffer; } }; @@ -99,7 +99,7 @@ void jpegli_stdio_dest(j_compress_ptr cinfo, FILE* outfile) { cinfo->dest = reinterpret_cast( jpegli::Allocate(cinfo, 1)); } - auto dest = reinterpret_cast(cinfo->dest); + auto* dest = reinterpret_cast(cinfo->dest); dest->f = outfile; dest->buffer = jpegli::Allocate(cinfo, jpegli::kDestBufferSize); dest->pub.next_output_byte = dest->buffer; @@ -122,11 +122,11 @@ void jpegli_mem_dest(j_compress_ptr cinfo, unsigned char** outbuffer, JPEGLI_ERROR("jpegli_mem_dest: a different dest manager was already set"); } if (!cinfo->dest) { - auto dest = jpegli::Allocate(cinfo, 1); + auto* dest = jpegli::Allocate(cinfo, 1); dest->temp_buffer = nullptr; cinfo->dest = reinterpret_cast(dest); } - auto dest = reinterpret_cast(cinfo->dest); + auto* dest = reinterpret_cast(cinfo->dest); dest->pub.init_destination = jpegli::MemoryDestinationManager::init_destination; dest->pub.empty_output_buffer = diff --git a/third_party/jpeg-xl/lib/jpegli/downsample.cc b/third_party/jpeg-xl/lib/jpegli/downsample.cc index df2c156972..f1e945d509 100644 --- a/third_party/jpeg-xl/lib/jpegli/downsample.cc +++ b/third_party/jpeg-xl/lib/jpegli/downsample.cc @@ -29,7 +29,7 @@ void DownsampleRow2x1(const float* row_in, size_t len, float* row_out) { const size_t N = Lanes(d); const size_t len_out = len / 2; const auto mul = Set(d, 0.5f); - Vec v0, v1; + Vec v0, v1; // NOLINT for (size_t x = 0; x < len_out; x += N) { LoadInterleaved2(d, row_in + 2 * x, v0, v1); Store(Mul(mul, Add(v0, v1)), d, row_out + x); @@ -40,7 +40,7 @@ void DownsampleRow3x1(const float* row_in, size_t len, float* row_out) { const size_t N = Lanes(d); const size_t len_out = len / 3; const auto mul = Set(d, 1.0f / 3); - Vec v0, v1, v2; + Vec v0, v1, v2; // NOLINT for (size_t x = 0; x < len_out; x += N) { LoadInterleaved3(d, row_in + 3 * x, v0, v1, v2); Store(Mul(mul, Add(Add(v0, v1), v2)), d, row_out + x); @@ -51,7 +51,7 @@ void DownsampleRow4x1(const float* row_in, size_t len, float* row_out) { const size_t N = Lanes(d); const size_t len_out = len / 4; const auto mul = Set(d, 0.25f); - Vec v0, v1, v2, v3; + Vec v0, v1, v2, v3; // NOLINT for (size_t x = 0; x < len_out; x += N) { LoadInterleaved4(d, row_in + 4 * x, v0, v1, v2, v3); Store(Mul(mul, Add(Add(v0, v1), Add(v2, v3))), d, row_out + x); @@ -91,7 +91,7 @@ void Downsample2x2(float* rows_in[MAX_SAMP_FACTOR], size_t len, const auto mul = Set(d, 0.25f); float* row0 = rows_in[0]; float* row1 = rows_in[1]; - Vec v0, v1, v2, v3; + Vec v0, v1, v2, v3; // NOLINT for (size_t x = 0; x < len_out; x += N) { LoadInterleaved2(d, row0 + 2 * x, v0, v1); LoadInterleaved2(d, row1 + 2 * x, v2, v3); diff --git a/third_party/jpeg-xl/lib/jpegli/encode.cc b/third_party/jpeg-xl/lib/jpegli/encode.cc index 8a106e239a..5326f2cb0f 100644 --- a/third_party/jpeg-xl/lib/jpegli/encode.cc +++ b/third_party/jpeg-xl/lib/jpegli/encode.cc @@ -5,6 +5,8 @@ #include "lib/jpegli/encode.h" +#include + #include #include #include @@ -323,8 +325,8 @@ void ProcessCompressionParams(j_compress_ptr cinfo) { if (cinfo->scan_info == nullptr) { SetDefaultScanScript(cinfo); } - cinfo->progressive_mode = - cinfo->scan_info->Ss != 0 || cinfo->scan_info->Se != DCTSIZE2 - 1; + cinfo->progressive_mode = TO_JXL_BOOL(cinfo->scan_info->Ss != 0 || + cinfo->scan_info->Se != DCTSIZE2 - 1); ValidateScanScript(cinfo); m->scan_token_info = Allocate(cinfo, cinfo->num_scans, JPOOL_IMAGE); @@ -449,7 +451,7 @@ void AllocateBuffers(j_compress_ptr cinfo) { const size_t ysize_blocks = comp->height_in_blocks; m->coeff_buffers[c] = (*cinfo->mem->request_virt_barray)( reinterpret_cast(cinfo), JPOOL_IMAGE, - /*pre_zero=*/false, xsize_blocks, ysize_blocks, comp->v_samp_factor); + /*pre_zero=*/FALSE, xsize_blocks, ysize_blocks, comp->v_samp_factor); } } if (m->use_adaptive_quantization) { @@ -663,8 +665,8 @@ void jpegli_CreateCompress(j_compress_ptr cinfo, int version, cinfo->num_components = 0; cinfo->jpeg_color_space = JCS_UNKNOWN; cinfo->comp_info = nullptr; - for (int i = 0; i < NUM_QUANT_TBLS; ++i) { - cinfo->quant_tbl_ptrs[i] = nullptr; + for (auto& quant_tbl_ptr : cinfo->quant_tbl_ptrs) { + quant_tbl_ptr = nullptr; } for (int i = 0; i < NUM_HUFF_TBLS; ++i) { cinfo->dc_huff_tbl_ptrs[i] = nullptr; @@ -673,7 +675,7 @@ void jpegli_CreateCompress(j_compress_ptr cinfo, int version, memset(cinfo->arith_dc_L, 0, sizeof(cinfo->arith_dc_L)); memset(cinfo->arith_dc_U, 0, sizeof(cinfo->arith_dc_U)); memset(cinfo->arith_ac_K, 0, sizeof(cinfo->arith_ac_K)); - cinfo->write_Adobe_marker = false; + cinfo->write_Adobe_marker = FALSE; cinfo->master = jpegli::Allocate(cinfo, 1); jpegli::InitializeCompressParams(cinfo); cinfo->master->force_baseline = true; @@ -763,7 +765,7 @@ void jpegli_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace) { JPEGLI_ERROR("Unsupported jpeg colorspace %d", colorspace); } // Adobe marker is only needed to distinguish CMYK and YCCK JPEGs. - cinfo->write_Adobe_marker = (cinfo->jpeg_color_space == JCS_YCCK); + cinfo->write_Adobe_marker = TO_JXL_BOOL(cinfo->jpeg_color_space == JCS_YCCK); if (cinfo->comp_info == nullptr) { cinfo->comp_info = jpegli::Allocate(cinfo, MAX_COMPONENTS); @@ -810,7 +812,7 @@ void jpegli_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace) { void jpegli_set_distance(j_compress_ptr cinfo, float distance, boolean force_baseline) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->force_baseline = force_baseline; + cinfo->master->force_baseline = FROM_JXL_BOOL(force_baseline); float distances[NUM_QUANT_TBLS] = {distance, distance, distance}; jpegli::SetQuantMatrices(cinfo, distances, /*add_two_chroma_tables=*/true); } @@ -834,7 +836,7 @@ void jpegli_set_psnr(j_compress_ptr cinfo, float psnr, float tolerance, void jpegli_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->force_baseline = force_baseline; + cinfo->master->force_baseline = FROM_JXL_BOOL(force_baseline); float distance = jpegli_quality_to_distance(quality); float distances[NUM_QUANT_TBLS] = {distance, distance, distance}; jpegli::SetQuantMatrices(cinfo, distances, /*add_two_chroma_tables=*/false); @@ -843,7 +845,7 @@ void jpegli_set_quality(j_compress_ptr cinfo, int quality, void jpegli_set_linear_quality(j_compress_ptr cinfo, int scale_factor, boolean force_baseline) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->force_baseline = force_baseline; + cinfo->master->force_baseline = FROM_JXL_BOOL(force_baseline); float distance = jpegli::LinearQualityToDistance(scale_factor); float distances[NUM_QUANT_TBLS] = {distance, distance, distance}; jpegli::SetQuantMatrices(cinfo, distances, /*add_two_chroma_tables=*/false); @@ -894,7 +896,7 @@ void jpegli_add_quant_table(j_compress_ptr cinfo, int which_tbl, void jpegli_enable_adaptive_quantization(j_compress_ptr cinfo, boolean value) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->use_adaptive_quantization = value; + cinfo->master->use_adaptive_quantization = FROM_JXL_BOOL(value); } void jpegli_simple_progression(j_compress_ptr cinfo) { @@ -955,7 +957,7 @@ void jpegli_copy_critical_parameters(j_decompress_ptr srcinfo, jpegli_set_colorspace(dstinfo, srcinfo->jpeg_color_space); if (dstinfo->num_components != srcinfo->num_components) { const auto& cinfo = dstinfo; - return JPEGLI_ERROR("Mismatch between src colorspace and components"); + JPEGLI_ERROR("Mismatch between src colorspace and components"); } dstinfo->data_precision = srcinfo->data_precision; dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; @@ -1005,7 +1007,7 @@ void jpegli_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr* coef_arrays) { CheckState(cinfo, jpegli::kEncStart); cinfo->global_state = jpegli::kEncWriteCoeffs; - jpegli::InitCompress(cinfo, /*write_all_tables=*/true); + jpegli::InitCompress(cinfo, /*write_all_tables=*/TRUE); cinfo->master->coeff_buffers = coef_arrays; cinfo->next_scanline = cinfo->image_height; cinfo->master->next_input_row = cinfo->image_height; @@ -1047,7 +1049,7 @@ void jpegli_write_m_header(j_compress_ptr cinfo, int marker, marker_data[1] = marker; marker_data[2] = (datalen + 2) >> 8; marker_data[3] = (datalen + 2) & 0xff; - jpegli::WriteOutput(cinfo, &marker_data[0], 4); + jpegli::WriteOutput(cinfo, marker_data.data(), 4); } void jpegli_write_m_byte(j_compress_ptr cinfo, int val) { @@ -1213,7 +1215,8 @@ void jpegli_finish_compress(j_compress_ptr cinfo) { } const bool tokens_done = jpegli::IsStreamingSupported(cinfo); - const bool bitstream_done = tokens_done && !cinfo->optimize_coding; + const bool bitstream_done = + tokens_done && !FROM_JXL_BOOL(cinfo->optimize_coding); if (!tokens_done) { jpegli::TokenizeJpeg(cinfo); diff --git a/third_party/jpeg-xl/lib/jpegli/encode_api_test.cc b/third_party/jpeg-xl/lib/jpegli/encode_api_test.cc index 8d53557567..1afdcf610d 100644 --- a/third_party/jpeg-xl/lib/jpegli/encode_api_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/encode_api_test.cc @@ -133,12 +133,11 @@ TEST(EncodeAPITest, ReuseCinfoSameMemOutput) { jpegli_destroy_compress(&cinfo); } size_t pos = 0; - for (size_t i = 0; i < all_configs.size(); ++i) { + for (auto& config : all_configs) { TestImage output; - pos += - DecodeWithLibjpeg(all_configs[i].jparams, DecompressParams(), nullptr, - 0, buffer + pos, buffer_size - pos, &output); - VerifyOutputImage(all_configs[i].input, output, all_configs[i].max_dist); + pos += DecodeWithLibjpeg(config.jparams, DecompressParams(), nullptr, 0, + buffer + pos, buffer_size - pos, &output); + VerifyOutputImage(config.input, output, config.max_dist); } if (buffer) free(buffer); } @@ -164,20 +163,21 @@ TEST(EncodeAPITest, ReuseCinfoSameStdOutput) { size_t total_size = ftell(tmpf); rewind(tmpf); std::vector compressed(total_size); - JXL_CHECK(total_size == fread(&compressed[0], 1, total_size, tmpf)); + JXL_CHECK(total_size == fread(compressed.data(), 1, total_size, tmpf)); fclose(tmpf); size_t pos = 0; - for (size_t i = 0; i < all_configs.size(); ++i) { + for (auto& config : all_configs) { TestImage output; - pos += DecodeWithLibjpeg(all_configs[i].jparams, DecompressParams(), - nullptr, 0, &compressed[pos], - compressed.size() - pos, &output); - VerifyOutputImage(all_configs[i].input, output, all_configs[i].max_dist); + pos += + DecodeWithLibjpeg(config.jparams, DecompressParams(), nullptr, 0, + &compressed[pos], compressed.size() - pos, &output); + VerifyOutputImage(config.input, output, config.max_dist); } } TEST(EncodeAPITest, ReuseCinfoChangeParams) { - TestImage input, output; + TestImage input; + TestImage output; CompressParams jparams; DecompressParams dparams; uint8_t* buffer = nullptr; diff --git a/third_party/jpeg-xl/lib/jpegli/encode_finish.cc b/third_party/jpeg-xl/lib/jpegli/encode_finish.cc index 955676bdee..767a6532c5 100644 --- a/third_party/jpeg-xl/lib/jpegli/encode_finish.cc +++ b/third_party/jpeg-xl/lib/jpegli/encode_finish.cc @@ -213,6 +213,8 @@ float FindDistanceForPSNR(j_compress_ptr cinfo) { d = best_distance; if (sampling == 1 && PSNR_SEARCH_DBG) { printf("Final PSNR %.2f at distance %.4f\n", best_psnr, d); + } else { + (void)best_psnr; } } return d; diff --git a/third_party/jpeg-xl/lib/jpegli/entropy_coding.cc b/third_party/jpeg-xl/lib/jpegli/entropy_coding.cc index 7e50bbc3a7..515996a43d 100644 --- a/third_party/jpeg-xl/lib/jpegli/entropy_coding.cc +++ b/third_party/jpeg-xl/lib/jpegli/entropy_coding.cc @@ -99,10 +99,16 @@ void TokenizeACProgressiveScan(j_compress_ptr cinfo, int scan_index, TokenArray* ta = &m->token_arrays[m->cur_token_array]; sti->token_offset = m->total_num_tokens + ta->num_tokens; sti->restarts = Allocate(cinfo, num_restarts, JPOOL_IMAGE); + const auto emit_eob_run = [&]() { + int nbits = jxl::FloorLog2Nonzero(eob_run); + int symbol = nbits << 4u; + *m->next_token++ = Token(context, symbol, eob_run & ((1 << nbits) - 1)); + eob_run = 0; + }; for (JDIMENSION by = 0; by < comp->height_in_blocks; ++by) { JBLOCKARRAY ba = (*cinfo->mem->access_virt_barray)( reinterpret_cast(cinfo), m->coeff_buffers[comp_idx], by, - 1, false); + 1, FALSE); // Each coefficient can appear in at most one token, but we have to reserve // one extra EOBrun token that was rolled over from the previous block-row // and has to be flushed at the end. @@ -121,13 +127,7 @@ void TokenizeACProgressiveScan(j_compress_ptr cinfo, int scan_index, } for (JDIMENSION bx = 0; bx < comp->width_in_blocks; ++bx) { if (restart_interval > 0 && restarts_to_go == 0) { - if (eob_run > 0) { - int nbits = jxl::FloorLog2Nonzero(eob_run); - int symbol = nbits << 4u; - *m->next_token++ = - Token(context, symbol, eob_run & ((1 << nbits) - 1)); - eob_run = 0; - } + if (eob_run > 0) emit_eob_run(); ta->num_tokens = m->next_token - ta->tokens; sti->restarts[restart_idx++] = m->total_num_tokens + ta->num_tokens; restarts_to_go = restart_interval; @@ -139,7 +139,8 @@ void TokenizeACProgressiveScan(j_compress_ptr cinfo, int scan_index, int num_nzeros = 0; int num_future_nzeros = 0; for (int k = Ss; k <= Se; ++k) { - if ((temp = block[k]) == 0) { + temp = block[k]; + if (temp == 0) { r++; continue; } @@ -156,13 +157,7 @@ void TokenizeACProgressiveScan(j_compress_ptr cinfo, int scan_index, num_future_nzeros++; continue; } - if (eob_run > 0) { - int nbits = jxl::FloorLog2Nonzero(eob_run); - int symbol = nbits << 4u; - *m->next_token++ = - Token(context, symbol, eob_run & ((1 << nbits) - 1)); - eob_run = 0; - } + if (eob_run > 0) emit_eob_run(); while (r > 15) { *m->next_token++ = Token(context, 0xf0, 0); r -= 16; @@ -175,13 +170,7 @@ void TokenizeACProgressiveScan(j_compress_ptr cinfo, int scan_index, } if (r > 0) { ++eob_run; - if (eob_run == 0x7FFF) { - int nbits = jxl::FloorLog2Nonzero(eob_run); - int symbol = nbits << 4u; - *m->next_token++ = - Token(context, symbol, eob_run & ((1 << nbits) - 1)); - eob_run = 0; - } + if (eob_run == 0x7FFF) emit_eob_run(); } sti->num_nonzeros += num_nzeros; sti->num_future_nonzeros += num_future_nzeros; @@ -190,11 +179,8 @@ void TokenizeACProgressiveScan(j_compress_ptr cinfo, int scan_index, ta->num_tokens = m->next_token - ta->tokens; } if (eob_run > 0) { - int nbits = jxl::FloorLog2Nonzero(eob_run); - int symbol = nbits << 4u; - *m->next_token++ = Token(context, symbol, eob_run & ((1 << nbits) - 1)); + emit_eob_run(); ++ta->num_tokens; - eob_run = 0; } sti->num_tokens = m->total_num_tokens + ta->num_tokens - sti->token_offset; sti->restarts[restart_idx++] = m->total_num_tokens + ta->num_tokens; @@ -229,7 +215,7 @@ void TokenizeACRefinementScan(j_compress_ptr cinfo, int scan_index, for (JDIMENSION by = 0; by < comp->height_in_blocks; ++by) { JBLOCKARRAY ba = (*cinfo->mem->access_virt_barray)( reinterpret_cast(cinfo), m->coeff_buffers[comp_idx], by, - 1, false); + 1, FALSE); for (JDIMENSION bx = 0; bx < comp->width_in_blocks; ++bx) { if (restart_interval > 0 && restarts_to_go == 0) { sti->restarts[restart_idx++] = next_token - sti->tokens; @@ -337,7 +323,7 @@ void TokenizeScan(j_compress_ptr cinfo, size_t scan_index, int ac_ctx_offset, // "Non-interleaved" means color data comes in separate scans, in other words // each scan can contain only one color component. const bool is_interleaved = (scan_info->comps_in_scan > 1); - const bool is_progressive = cinfo->progressive_mode; + const bool is_progressive = FROM_JXL_BOOL(cinfo->progressive_mode); const int Ah = scan_info->Ah; const int Al = scan_info->Al; HWY_ALIGN constexpr coeff_t kSinkBlock[DCTSIZE2] = {0}; @@ -373,7 +359,7 @@ void TokenizeScan(j_compress_ptr cinfo, size_t scan_index, int ac_ctx_offset, int max_block_rows = std::min(n_blocks_y, block_rows_left); ba[i] = (*cinfo->mem->access_virt_barray)( reinterpret_cast(cinfo), m->coeff_buffers[comp_idx], - by0, max_block_rows, false); + by0, max_block_rows, FALSE); } if (!cinfo->progressive_mode) { int max_tokens_per_mcu_row = MaxNumTokensPerMCURow(cinfo); @@ -557,7 +543,7 @@ float HistogramCost(const Histogram& histo) { } counts[kJpegHuffmanAlphabetSize] = 1; CreateHuffmanTree(counts.data(), counts.size(), kJpegHuffmanMaxBitLength, - &depths[0]); + depths.data()); size_t header_bits = (1 + kJpegHuffmanMaxBitLength) * 8; size_t data_bits = 0; for (size_t i = 0; i < kJpegHuffmanAlphabetSize; ++i) { @@ -576,8 +562,8 @@ void AddHistograms(const Histogram& a, const Histogram& b, Histogram* c) { } bool IsEmptyHistogram(const Histogram& histo) { - for (size_t i = 0; i < kJpegHuffmanAlphabetSize; ++i) { - if (histo.count[i]) return false; + for (int count : histo.count) { + if (count) return false; } return true; } @@ -668,7 +654,7 @@ void BuildJpegHuffmanTable(const Histogram& histo, JHUFF_TBL* table) { } counts[kJpegHuffmanAlphabetSize] = 1; CreateHuffmanTree(counts.data(), counts.size(), kJpegHuffmanMaxBitLength, - &depths[0]); + depths.data()); memset(table, 0, sizeof(JHUFF_TBL)); for (size_t i = 0; i < kJpegHuffmanAlphabetSize; ++i) { if (depths[i] > 0) { @@ -726,7 +712,7 @@ void OptimizeHuffmanCodes(j_compress_ptr cinfo) { jpeg_comp_master* m = cinfo->master; // Build DC and AC histograms. std::vector histograms(m->num_contexts); - BuildHistograms(cinfo, &histograms[0]); + BuildHistograms(cinfo, histograms.data()); // Cluster DC histograms. JpegClusteredHistograms dc_clusters; @@ -760,7 +746,7 @@ void OptimizeHuffmanCodes(j_compress_ptr cinfo) { m->context_map = Allocate(cinfo, m->num_contexts, JPOOL_IMAGE); memset(m->context_map, 0, m->num_contexts); for (size_t i = 0; i < m->num_contexts; ++i) { - if (i < (size_t)cinfo->num_components) { + if (i < static_cast(cinfo->num_components)) { m->context_map[i] = dc_clusters.histogram_indexes[i]; } else if (i >= 4) { m->context_map[i] = num_dc_huff + ac_clusters.histogram_indexes[i - 4]; diff --git a/third_party/jpeg-xl/lib/jpegli/error.h b/third_party/jpeg-xl/lib/jpegli/error.h index 4451abd416..5f266baee1 100644 --- a/third_party/jpeg-xl/lib/jpegli/error.h +++ b/third_party/jpeg-xl/lib/jpegli/error.h @@ -10,6 +10,7 @@ #include #include "lib/jpegli/common.h" +#include "lib/jxl/base/status.h" namespace jpegli { @@ -17,10 +18,12 @@ bool FormatString(char* buffer, const char* format, ...); } // namespace jpegli +// `error_exit` should be no-return; but let's add some guarantees on our side. #define JPEGLI_ERROR(format, ...) \ jpegli::FormatString(cinfo->err->msg_parm.s, ("%s:%d: " format), __FILE__, \ __LINE__, ##__VA_ARGS__), \ - (*cinfo->err->error_exit)(reinterpret_cast(cinfo)) + (*cinfo->err->error_exit)(reinterpret_cast(cinfo)), \ + (void)jxl::Abort() #define JPEGLI_WARN(format, ...) \ jpegli::FormatString(cinfo->err->msg_parm.s, ("%s:%d: " format), __FILE__, \ diff --git a/third_party/jpeg-xl/lib/jpegli/error_handling_test.cc b/third_party/jpeg-xl/lib/jpegli/error_handling_test.cc index 0d481c572a..3eaf6a313b 100644 --- a/third_party/jpeg-xl/lib/jpegli/error_handling_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/error_handling_test.cc @@ -241,9 +241,10 @@ TEST(EncoderErrorHandlingTest, InvalidQuantValue) { cinfo.image_height = 1; cinfo.input_components = 1; jpegli_set_defaults(&cinfo); - cinfo.quant_tbl_ptrs[0] = jpegli_alloc_quant_table((j_common_ptr)&cinfo); - for (size_t k = 0; k < DCTSIZE2; ++k) { - cinfo.quant_tbl_ptrs[0]->quantval[k] = 0; + cinfo.quant_tbl_ptrs[0] = + jpegli_alloc_quant_table(reinterpret_cast(&cinfo)); + for (UINT16& q : cinfo.quant_tbl_ptrs[0]->quantval) { + q = 0; } jpegli_start_compress(&cinfo, TRUE); JSAMPLE image[1] = {0}; @@ -992,7 +993,7 @@ TEST(EncoderErrorHandlingTest, AddOnTableNoStringParam) { jpegli_destroy_compress(&cinfo); } -static const uint8_t kCompressed0[] = { +const uint8_t kCompressed0[] = { // SOI 0xff, 0xd8, // // DQT @@ -1036,12 +1037,12 @@ static const uint8_t kCompressed0[] = { // EOI 0xff, 0xd9, // }; -static const size_t kLen0 = sizeof(kCompressed0); +const size_t kLen0 = sizeof(kCompressed0); -static const size_t kDQTOffset = 2; -static const size_t kSOFOffset = 71; -static const size_t kDHTOffset = 84; -static const size_t kSOSOffset = 296; +const size_t kDQTOffset = 2; +const size_t kSOFOffset = 71; +const size_t kDHTOffset = 84; +const size_t kSOSOffset = 296; TEST(DecoderErrorHandlingTest, MinimalSuccess) { JXL_CHECK(kCompressed0[kDQTOffset] == 0xff); @@ -1130,7 +1131,7 @@ TEST(DecoderErrorHandlingTest, NoReadScanlines) { jpegli_destroy_decompress(&cinfo); } -static const size_t kMaxImageWidth = 0xffff; +const size_t kMaxImageWidth = 0xffff; JSAMPLE kOutputBuffer[MAX_COMPONENTS * kMaxImageWidth]; bool ParseCompressed(const std::vector& compressed) { diff --git a/third_party/jpeg-xl/lib/jpegli/huffman.cc b/third_party/jpeg-xl/lib/jpegli/huffman.cc index 1cf88a5536..5391030213 100644 --- a/third_party/jpeg-xl/lib/jpegli/huffman.cc +++ b/third_party/jpeg-xl/lib/jpegli/huffman.cc @@ -183,7 +183,8 @@ void CreateHuffmanTree(const uint32_t* data, const size_t length, size_t i = 0; // Points to the next leaf node. size_t j = n + 1; // Points to the next non-leaf node. for (size_t k = n - 1; k != 0; --k) { - size_t left, right; + size_t left; + size_t right; if (tree[i].total_count <= tree[j].total_count) { left = i; ++i; @@ -210,7 +211,7 @@ void CreateHuffmanTree(const uint32_t* data, const size_t length, tree.push_back(sentinel); } JXL_DASSERT(tree.size() == 2 * n + 1); - SetDepth(tree[2 * n - 1], &tree[0], depth, 0); + SetDepth(tree[2 * n - 1], tree.data(), depth, 0); // We need to pack the Huffman tree in tree_limit bits. // If this was not successful, add fake entities to the lowest values diff --git a/third_party/jpeg-xl/lib/jpegli/idct.cc b/third_party/jpeg-xl/lib/jpegli/idct.cc index 4d10563583..9859e8ef85 100644 --- a/third_party/jpeg-xl/lib/jpegli/idct.cc +++ b/third_party/jpeg-xl/lib/jpegli/idct.cc @@ -197,7 +197,7 @@ void InverseTransformBlock8x8(const int16_t* JXL_RESTRICT qblock, // Computes the N-point IDCT of in[], and stores the result in out[]. The in[] // array is at most 8 values long, values in[8:N-1] are assumed to be 0. -void Compute1dIDCT(float* in, float* out, size_t N) { +void Compute1dIDCT(const float* in, float* out, size_t N) { switch (N) { case 3: { static constexpr float kC3[3] = { @@ -608,6 +608,9 @@ void Compute1dIDCT(float* in, float* out, size_t N) { out[8] = even7 - odd7; break; } + default: + JXL_ABORT("Compute1dIDCT does not support N=%d", static_cast(N)); + break; } } diff --git a/third_party/jpeg-xl/lib/jpegli/input.cc b/third_party/jpeg-xl/lib/jpegli/input.cc index 765bf98946..16299477f7 100644 --- a/third_party/jpeg-xl/lib/jpegli/input.cc +++ b/third_party/jpeg-xl/lib/jpegli/input.cc @@ -89,7 +89,7 @@ void ReadUint8RowInterleaved2(const uint8_t* row_in, size_t len, const size_t simd_len = len & (~(N - 1)); float* JXL_RESTRICT const row0 = row_out[0]; float* JXL_RESTRICT const row1 = row_out[1]; - Vec out0, out1; + Vec out0, out1; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved2(du8, row_in + 2 * x, out0, out1); Store(ConvertTo(d, PromoteTo(du, out0)), d, row0 + x); @@ -105,7 +105,7 @@ void ReadUint8RowInterleaved3(const uint8_t* row_in, size_t len, float* JXL_RESTRICT const row0 = row_out[0]; float* JXL_RESTRICT const row1 = row_out[1]; float* JXL_RESTRICT const row2 = row_out[2]; - Vec out0, out1, out2; + Vec out0, out1, out2; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved3(du8, row_in + 3 * x, out0, out1, out2); Store(ConvertTo(d, PromoteTo(du, out0)), d, row0 + x); @@ -123,7 +123,7 @@ void ReadUint8RowInterleaved4(const uint8_t* row_in, size_t len, float* JXL_RESTRICT const row1 = row_out[1]; float* JXL_RESTRICT const row2 = row_out[2]; float* JXL_RESTRICT const row3 = row_out[3]; - Vec out0, out1, out2, out3; + Vec out0, out1, out2, out3; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved4(du8, row_in + 4 * x, out0, out1, out2, out3); Store(ConvertTo(d, PromoteTo(du, out0)), d, row0 + x); @@ -158,7 +158,7 @@ void ReadUint16RowInterleaved2(const uint8_t* row_in, size_t len, reinterpret_cast(row_in); float* JXL_RESTRICT const row0 = row_out[0]; float* JXL_RESTRICT const row1 = row_out[1]; - Vec out0, out1; + Vec out0, out1; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved2(du16, row + 2 * x, out0, out1); Store(Mul(mul, ConvertTo(d, PromoteTo(du, out0))), d, row0 + x); @@ -177,7 +177,7 @@ void ReadUint16RowInterleaved3(const uint8_t* row_in, size_t len, float* JXL_RESTRICT const row0 = row_out[0]; float* JXL_RESTRICT const row1 = row_out[1]; float* JXL_RESTRICT const row2 = row_out[2]; - Vec out0, out1, out2; + Vec out0, out1, out2; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved3(du16, row + 3 * x, out0, out1, out2); Store(Mul(mul, ConvertTo(d, PromoteTo(du, out0))), d, row0 + x); @@ -198,7 +198,7 @@ void ReadUint16RowInterleaved4(const uint8_t* row_in, size_t len, float* JXL_RESTRICT const row1 = row_out[1]; float* JXL_RESTRICT const row2 = row_out[2]; float* JXL_RESTRICT const row3 = row_out[3]; - Vec out0, out1, out2, out3; + Vec out0, out1, out2, out3; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved4(du16, row + 4 * x, out0, out1, out2, out3); Store(Mul(mul, ConvertTo(d, PromoteTo(du, out0))), d, row0 + x); @@ -250,7 +250,7 @@ void ReadFloatRowInterleaved2(const uint8_t* row_in, size_t len, const float* JXL_RESTRICT const row = reinterpret_cast(row_in); float* JXL_RESTRICT const row0 = row_out[0]; float* JXL_RESTRICT const row1 = row_out[1]; - Vec out0, out1; + Vec out0, out1; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved2(d, row + 2 * x, out0, out1); Store(Mul(mul, out0), d, row0 + x); @@ -268,7 +268,7 @@ void ReadFloatRowInterleaved3(const uint8_t* row_in, size_t len, float* JXL_RESTRICT const row0 = row_out[0]; float* JXL_RESTRICT const row1 = row_out[1]; float* JXL_RESTRICT const row2 = row_out[2]; - Vec out0, out1, out2; + Vec out0, out1, out2; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved3(d, row + 3 * x, out0, out1, out2); Store(Mul(mul, out0), d, row0 + x); @@ -288,7 +288,7 @@ void ReadFloatRowInterleaved4(const uint8_t* row_in, size_t len, float* JXL_RESTRICT const row1 = row_out[1]; float* JXL_RESTRICT const row2 = row_out[2]; float* JXL_RESTRICT const row3 = row_out[3]; - Vec out0, out1, out2, out3; + Vec out0, out1, out2, out3; // NOLINT for (size_t x = 0; x < simd_len; x += N) { LoadInterleaved4(d, row + 4 * x, out0, out1, out2, out3); Store(Mul(mul, out0), d, row0 + x); diff --git a/third_party/jpeg-xl/lib/jpegli/input_suspension_test.cc b/third_party/jpeg-xl/lib/jpegli/input_suspension_test.cc index 09bafd9188..eb8b7ebc26 100644 --- a/third_party/jpeg-xl/lib/jpegli/input_suspension_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/input_suspension_test.cc @@ -17,7 +17,7 @@ namespace jpegli { namespace { -static constexpr uint8_t kFakeEoiMarker[2] = {0xff, 0xd9}; +constexpr uint8_t kFakeEoiMarker[2] = {0xff, 0xd9}; struct SourceManager { SourceManager(const uint8_t* data, size_t len, size_t max_chunk_size, @@ -50,14 +50,14 @@ struct SourceManager { } if (pub_.bytes_in_buffer > 0) { EXPECT_LE(pub_.bytes_in_buffer, buffer_.size()); - memmove(&buffer_[0], pub_.next_input_byte, pub_.bytes_in_buffer); + memmove(buffer_.data(), pub_.next_input_byte, pub_.bytes_in_buffer); } size_t chunk_size = pos_ < len_ ? std::min(len_ - pos_, max_chunk_size_) : 2; buffer_.resize(pub_.bytes_in_buffer + chunk_size); memcpy(&buffer_[pub_.bytes_in_buffer], pos_ < len_ ? data_ + pos_ : kFakeEoiMarker, chunk_size); - pub_.next_input_byte = &buffer_[0]; + pub_.next_input_byte = buffer_.data(); pub_.bytes_in_buffer += chunk_size; pos_ += chunk_size; return true; @@ -73,7 +73,7 @@ struct SourceManager { bool is_partial_file_; static void init_source(j_decompress_ptr cinfo) { - auto src = reinterpret_cast(cinfo->src); + auto* src = reinterpret_cast(cinfo->src); src->pub_.next_input_byte = nullptr; src->pub_.bytes_in_buffer = 0; } @@ -81,7 +81,7 @@ struct SourceManager { static boolean fill_input_buffer(j_decompress_ptr cinfo) { return FALSE; } static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) { - auto src = reinterpret_cast(cinfo->src); + auto* src = reinterpret_cast(cinfo->src); if (num_bytes <= 0) { return; } @@ -156,10 +156,10 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo, rowdata[c][i] = y0 + i < ysize ? &output->raw_data[c][(y0 + i) * xsize] : nullptr; } - data[c] = &rowdata[c][0]; + data[c] = rowdata[c].data(); } while ((num_output_lines = - jpegli_read_raw_data(cinfo, &data[0], max_lines)) == 0) { + jpegli_read_raw_data(cinfo, data.data(), max_lines)) == 0) { JXL_CHECK(src && src->LoadNextChunk()); } } else { @@ -173,7 +173,7 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo, size_t yidx = cinfo->output_scanline + i; scanlines[i] = &output->pixels[yidx * stride]; } - while ((num_output_lines = jpegli_read_scanlines(cinfo, &scanlines[0], + while ((num_output_lines = jpegli_read_scanlines(cinfo, scanlines.data(), max_lines)) == 0) { JXL_CHECK(src && src->LoadNextChunk()); } @@ -197,7 +197,7 @@ struct TestConfig { std::vector GetTestJpegData(TestConfig& config) { if (!config.fn.empty()) { - return ReadTestData(config.fn.c_str()); + return ReadTestData(config.fn); } GeneratePixels(&config.input); std::vector compressed; @@ -249,7 +249,7 @@ TEST_P(InputSuspensionTestParam, InputOutputLockStepNonBuffered) { EXPECT_EQ(0, memcmp(markers_seen, kMarkerSequence, num_markers_seen)); } VerifyHeader(config.jparams, &cinfo); - cinfo.raw_data_out = dparams.output_mode == RAW_DATA; + cinfo.raw_data_out = TO_JXL_BOOL(dparams.output_mode == RAW_DATA); if (dparams.output_mode == COEFFICIENTS) { jvirt_barray_ptr* coef_arrays; @@ -303,7 +303,7 @@ TEST_P(InputSuspensionTestParam, InputOutputLockStepBuffered) { jpegli_set_output_format(&cinfo, dparams.data_type, dparams.endianness); cinfo.buffered_image = TRUE; - cinfo.raw_data_out = dparams.output_mode == RAW_DATA; + cinfo.raw_data_out = TO_JXL_BOOL(dparams.output_mode == RAW_DATA); EXPECT_TRUE(jpegli_start_decompress(&cinfo)); EXPECT_FALSE(jpegli_input_complete(&cinfo)); @@ -380,8 +380,8 @@ TEST_P(InputSuspensionTestParam, PreConsumeInputBuffered) { } EXPECT_EQ(JPEG_REACHED_SOS, jpegli_consume_input(&cinfo)); cinfo.buffered_image = TRUE; - cinfo.raw_data_out = dparams.output_mode == RAW_DATA; - cinfo.do_block_smoothing = dparams.do_block_smoothing; + cinfo.raw_data_out = TO_JXL_BOOL(dparams.output_mode == RAW_DATA); + cinfo.do_block_smoothing = TO_JXL_BOOL(dparams.do_block_smoothing); EXPECT_TRUE(jpegli_start_decompress(&cinfo)); EXPECT_FALSE(jpegli_input_complete(&cinfo)); @@ -446,8 +446,8 @@ TEST_P(InputSuspensionTestParam, PreConsumeInputNonBuffered) { } } EXPECT_EQ(JPEG_REACHED_SOS, jpegli_consume_input(&cinfo)); - cinfo.raw_data_out = dparams.output_mode == RAW_DATA; - cinfo.do_block_smoothing = dparams.do_block_smoothing; + cinfo.raw_data_out = TO_JXL_BOOL(dparams.output_mode == RAW_DATA); + cinfo.do_block_smoothing = TO_JXL_BOOL(dparams.do_block_smoothing); if (dparams.output_mode == COEFFICIENTS) { jpegli_read_coefficients(&cinfo); diff --git a/third_party/jpeg-xl/lib/jpegli/libjpeg_test_util.cc b/third_party/jpeg-xl/lib/jpegli/libjpeg_test_util.cc index de2303756e..020adf5e9e 100644 --- a/third_party/jpeg-xl/lib/jpegli/libjpeg_test_util.cc +++ b/third_party/jpeg-xl/lib/jpegli/libjpeg_test_util.cc @@ -37,12 +37,13 @@ void ReadOutputPass(j_decompress_ptr cinfo, const DecompressParams& dparams, output->ysize = ysize_cropped; output->components = cinfo->out_color_components; if (cinfo->quantize_colors) { - jxl::msan::UnpoisonMemory(cinfo->colormap, cinfo->out_color_components * - sizeof(cinfo->colormap[0])); + JSAMPLE** colormap = cinfo->colormap; + jxl::msan::UnpoisonMemory(reinterpret_cast(colormap), + cinfo->out_color_components * sizeof(JSAMPLE*)); for (int c = 0; c < cinfo->out_color_components; ++c) { jxl::msan::UnpoisonMemory( - cinfo->colormap[c], - cinfo->actual_number_of_colors * sizeof(cinfo->colormap[c][0])); + reinterpret_cast(colormap[c]), + cinfo->actual_number_of_colors * sizeof(JSAMPLE)); } } if (!cinfo->raw_data_out) { @@ -89,10 +90,10 @@ void ReadOutputPass(j_decompress_ptr cinfo, const DecompressParams& dparams, rowdata[c][i] = y0 + i < ysize ? &output->raw_data[c][(y0 + i) * xsize] : nullptr; } - data[c] = &rowdata[c][0]; + data[c] = rowdata[c].data(); } JXL_CHECK(iMCU_height == - jpeg_read_raw_data(cinfo, &data[0], iMCU_height)); + jpeg_read_raw_data(cinfo, data.data(), iMCU_height)); } } JXL_CHECK(cinfo->total_iMCU_rows == @@ -113,7 +114,7 @@ void DecodeWithLibjpeg(const CompressParams& jparams, jpeg_read_header(cinfo, /*require_image=*/TRUE)); if (!jparams.icc.empty()) { uint8_t* icc_data = nullptr; - unsigned int icc_len; + unsigned int icc_len = 0; // "unpoison" via initialization JXL_CHECK(jpeg_read_icc_profile(cinfo, &icc_data, &icc_len)); JXL_CHECK(icc_data); jxl::msan::UnpoisonMemory(icc_data, icc_len); diff --git a/third_party/jpeg-xl/lib/jpegli/libjpeg_wrapper.cc b/third_party/jpeg-xl/lib/jpegli/libjpeg_wrapper.cc index b38d16f255..471b7c7192 100644 --- a/third_party/jpeg-xl/lib/jpegli/libjpeg_wrapper.cc +++ b/third_party/jpeg-xl/lib/jpegli/libjpeg_wrapper.cc @@ -122,11 +122,11 @@ boolean jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, } void jpeg_abort_decompress(j_decompress_ptr cinfo) { - return jpegli_abort_decompress(cinfo); + jpegli_abort_decompress(cinfo); } void jpeg_destroy_decompress(j_decompress_ptr cinfo) { - return jpegli_destroy_decompress(cinfo); + jpegli_destroy_decompress(cinfo); } void jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize) { diff --git a/third_party/jpeg-xl/lib/jpegli/memory_manager.h b/third_party/jpeg-xl/lib/jpegli/memory_manager.h index 3e2bdabe06..c650caad49 100644 --- a/third_party/jpeg-xl/lib/jpegli/memory_manager.h +++ b/third_party/jpeg-xl/lib/jpegli/memory_manager.h @@ -19,7 +19,8 @@ void InitMemoryManager(j_common_ptr cinfo); template T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) { - void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, len * sizeof(T)); + const size_t size = len * sizeof(T); // NOLINT + void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size); return reinterpret_cast(p); } diff --git a/third_party/jpeg-xl/lib/jpegli/output_suspension_test.cc b/third_party/jpeg-xl/lib/jpegli/output_suspension_test.cc index 73db791727..3cb2fd3ee4 100644 --- a/third_party/jpeg-xl/lib/jpegli/output_suspension_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/output_suspension_test.cc @@ -10,8 +10,8 @@ namespace jpegli { namespace { -static constexpr size_t kInitialBufferSize = 1024; -static constexpr size_t kFinalBufferSize = 18; +constexpr size_t kInitialBufferSize = 1024; +constexpr size_t kFinalBufferSize = 18; struct DestinationManager { jpeg_destination_mgr pub; @@ -37,7 +37,7 @@ struct DestinationManager { } static void init_destination(j_compress_ptr cinfo) { - auto us = reinterpret_cast(cinfo->dest); + auto* us = reinterpret_cast(cinfo->dest); us->buffer.resize(kInitialBufferSize); us->Rewind(); } @@ -84,7 +84,7 @@ TEST_P(OutputSuspensionTestParam, PixelData) { while (cinfo.next_scanline < cinfo.image_height) { size_t lines_left = cinfo.image_height - cinfo.next_scanline; size_t num_lines = std::min(config.lines_batch_size, lines_left); - memcpy(&row_bytes[0], &input.pixels[cinfo.next_scanline * stride], + memcpy(row_bytes.data(), &input.pixels[cinfo.next_scanline * stride], num_lines * stride); std::vector rows(num_lines); for (size_t i = 0; i < num_lines; ++i) { @@ -142,7 +142,7 @@ TEST_P(OutputSuspensionTestParam, RawData) { std::vector data(cinfo.num_components); for (int c = 0; c < cinfo.num_components; ++c) { rowdata[c].resize(config.jparams.v_samp(c) * DCTSIZE); - data[c] = &rowdata[c][0]; + data[c] = rowdata[c].data(); } while (cinfo.next_scanline < cinfo.image_height) { for (int c = 0; c < cinfo.num_components; ++c) { @@ -155,7 +155,7 @@ TEST_P(OutputSuspensionTestParam, RawData) { (y0 + i < cheight ? &raw_data[c][(y0 + i) * cwidth] : nullptr); } } - while (jpegli_write_raw_data(&cinfo, &data[0], max_lines) == 0) { + while (jpegli_write_raw_data(&cinfo, data.data(), max_lines) == 0) { dest.EmptyTo(&compressed, config.buffer_size); } } diff --git a/third_party/jpeg-xl/lib/jpegli/quant.cc b/third_party/jpeg-xl/lib/jpegli/quant.cc index 36f1df4cdd..14db6701b2 100644 --- a/third_party/jpeg-xl/lib/jpegli/quant.cc +++ b/third_party/jpeg-xl/lib/jpegli/quant.cc @@ -26,7 +26,7 @@ namespace { constexpr float kGlobalScaleXYB = 1.43951668f; constexpr float kGlobalScaleYCbCr = 1.73966010f; -static constexpr float kBaseQuantMatrixXYB[] = { +constexpr float kBaseQuantMatrixXYB[] = { // c = 0 7.5629935265f, 19.8247814178f, @@ -224,7 +224,7 @@ static constexpr float kBaseQuantMatrixXYB[] = { 63.6065597534f, }; -static const float kBaseQuantMatrixYCbCr[] = { +const float kBaseQuantMatrixYCbCr[] = { // c = 0 1.2397409345866273f, // 1.7227115097630963f, // @@ -422,8 +422,8 @@ static const float kBaseQuantMatrixYCbCr[] = { 114.89202448569779f, // }; -static const float k420GlobalScale = 1.22; -static const float k420Rescale[64] = { +const float k420GlobalScale = 1.22; +const float k420Rescale[64] = { 0.4093, 0.3209, 0.3477, 0.3333, 0.3144, 0.2823, 0.3214, 0.3354, // 0.3209, 0.3111, 0.3489, 0.2801, 0.3059, 0.3119, 0.4135, 0.3445, // 0.3477, 0.3489, 0.3586, 0.3257, 0.2727, 0.3754, 0.3369, 0.3484, // @@ -434,7 +434,7 @@ static const float k420Rescale[64] = { 0.3354, 0.3445, 0.3484, 0.3839, 0.3836, 0.0726, 0.0553, 0.3368, // }; -static const float kBaseQuantMatrixStd[] = { +const float kBaseQuantMatrixStd[] = { // c = 0 16.0f, 11.0f, 10.0f, 16.0f, 24.0f, 40.0f, 51.0f, 61.0f, // 12.0f, 12.0f, 14.0f, 19.0f, 26.0f, 58.0f, 60.0f, 55.0f, // @@ -455,7 +455,7 @@ static const float kBaseQuantMatrixStd[] = { 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, 99.0f, // }; -static const float kZeroBiasMulYCbCrLQ[] = { +const float kZeroBiasMulYCbCrLQ[] = { // c = 0 0.0000f, 0.0568f, 0.3880f, 0.6190f, 0.6190f, 0.4490f, 0.4490f, 0.6187f, // 0.0568f, 0.5829f, 0.6189f, 0.6190f, 0.6190f, 0.7190f, 0.6190f, 0.6189f, // @@ -485,7 +485,7 @@ static const float kZeroBiasMulYCbCrLQ[] = { 0.2960f, 0.2113f, 0.2426f, 0.1590f, 0.5403f, 0.3060f, 0.3060f, 0.3060f, // }; -static const float kZeroBiasMulYCbCrHQ[] = { +const float kZeroBiasMulYCbCrHQ[] = { // c = 0 0.0000f, 0.0044f, 0.2521f, 0.6547f, 0.8161f, 0.6130f, 0.8841f, 0.8155f, // 0.0044f, 0.6831f, 0.6553f, 0.6295f, 0.7848f, 0.7843f, 0.8474f, 0.7836f, // @@ -515,9 +515,9 @@ static const float kZeroBiasMulYCbCrHQ[] = { 0.4836f, 0.4897f, 0.2583f, 0.3565f, 0.5949f, 0.6629f, 0.6644f, 0.6644f, // }; -static const float kZeroBiasOffsetYCbCrDC[] = {0.0f, 0.0f, 0.0f}; +const float kZeroBiasOffsetYCbCrDC[] = {0.0f, 0.0f, 0.0f}; -static const float kZeroBiasOffsetYCbCrAC[] = { +const float kZeroBiasOffsetYCbCrAC[] = { 0.59082f, 0.58146f, 0.57988f, diff --git a/third_party/jpeg-xl/lib/jpegli/render.cc b/third_party/jpeg-xl/lib/jpegli/render.cc index 24e7e99618..c550f9a575 100644 --- a/third_party/jpeg-xl/lib/jpegli/render.cc +++ b/third_party/jpeg-xl/lib/jpegli/render.cc @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -203,12 +202,13 @@ void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], if (cinfo->quantize_colors && m->quant_pass_ == 1) { float* error_row[kMaxComponents]; float* next_error_row[kMaxComponents]; - if (cinfo->dither_mode == JDITHER_ORDERED) { + J_DITHER_MODE dither_mode = cinfo->dither_mode; + if (dither_mode == JDITHER_ORDERED) { for (size_t c = 0; c < num_channels; ++c) { DitherRow(cinfo, &rows[c][xoffset], c, cinfo->output_scanline, cinfo->output_width); } - } else if (cinfo->dither_mode == JDITHER_FS) { + } else if (dither_mode == JDITHER_FS) { for (size_t c = 0; c < num_channels; ++c) { if (cinfo->output_scanline % 2 == 0) { error_row[c] = m->error_row_[c]; @@ -221,12 +221,12 @@ void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], } } const float mul = 255.0f; - if (cinfo->dither_mode != JDITHER_FS) { + if (dither_mode != JDITHER_FS) { StoreUnsignedRow(rows, xoffset, len, num_channels, mul, scratch_space); } for (size_t i = 0; i < len; ++i) { uint8_t* pixel = &scratch_space[num_channels * i]; - if (cinfo->dither_mode == JDITHER_FS) { + if (dither_mode == JDITHER_FS) { for (size_t c = 0; c < num_channels; ++c) { float val = rows[c][i] * mul + LimitError(error_row[c][i]); pixel[c] = std::round(std::min(255.0f, std::max(0.0f, val))); @@ -234,7 +234,7 @@ void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], } int index = LookupColorIndex(cinfo, pixel); output[i] = index; - if (cinfo->dither_mode == JDITHER_FS) { + if (dither_mode == JDITHER_FS) { size_t prev_i = i > 0 ? i - 1 : 0; size_t next_i = i + 1 < len ? i + 1 : len - 1; for (size_t c = 0; c < num_channels; ++c) { @@ -293,19 +293,18 @@ HWY_EXPORT(DecenterRow); void GatherBlockStats(const int16_t* JXL_RESTRICT coeffs, const size_t coeffs_size, int32_t* JXL_RESTRICT nonzeros, int32_t* JXL_RESTRICT sumabs) { - return HWY_DYNAMIC_DISPATCH(GatherBlockStats)(coeffs, coeffs_size, nonzeros, - sumabs); + HWY_DYNAMIC_DISPATCH(GatherBlockStats)(coeffs, coeffs_size, nonzeros, sumabs); } void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], size_t xoffset, size_t len, size_t num_channels, uint8_t* JXL_RESTRICT output) { - return HWY_DYNAMIC_DISPATCH(WriteToOutput)(cinfo, rows, xoffset, len, - num_channels, output); + HWY_DYNAMIC_DISPATCH(WriteToOutput) + (cinfo, rows, xoffset, len, num_channels, output); } void DecenterRow(float* row, size_t xsize) { - return HWY_DYNAMIC_DISPATCH(DecenterRow)(row, xsize); + HWY_DYNAMIC_DISPATCH(DecenterRow)(row, xsize); } bool ShouldApplyDequantBiases(j_decompress_ptr cinfo, int ci) { @@ -360,8 +359,8 @@ bool do_smoothing(j_decompress_ptr cinfo) { if (!cinfo->progressive_mode || cinfo->coef_bits == nullptr) { return false; } - auto coef_bits_latch = m->coef_bits_latch; - auto prev_coef_bits_latch = m->prev_coef_bits_latch; + auto* coef_bits_latch = m->coef_bits_latch; + auto* prev_coef_bits_latch = m->prev_coef_bits_latch; for (int ci = 0; ci < cinfo->num_components; ci++) { jpeg_component_info* compptr = &cinfo->comp_info[ci]; @@ -468,6 +467,7 @@ void PredictSmooth(j_decompress_ptr cinfo, JBLOCKARRAY blocks, int component, return swap_indices ? dc_values[j][i] : dc_values[i][j]; }; Al = coef_bits[coef_index]; + JXL_ASSERT(coef_index >= 0 && coef_index < 10); switch (coef_index) { case 0: // set the DC @@ -520,6 +520,7 @@ void PredictSmooth(j_decompress_ptr cinfo, JBLOCKARRAY blocks, int component, break; case 7: case 8: + default: // set Q12 and Q21 num = (dc(1, 1) - 3 * dc(1, 2) + dc(1, 3) - dc(3, 1) + 3 * dc(3, 2) - dc(3, 3)); @@ -551,7 +552,7 @@ void PredictSmooth(j_decompress_ptr cinfo, JBLOCKARRAY blocks, int component, void PrepareForOutput(j_decompress_ptr cinfo) { jpeg_decomp_master* m = cinfo->master; bool smoothing = do_smoothing(cinfo); - m->apply_smoothing = smoothing && cinfo->do_block_smoothing; + m->apply_smoothing = smoothing && FROM_JXL_BOOL(cinfo->do_block_smoothing); size_t coeffs_per_block = cinfo->num_components * DCTSIZE2; memset(m->nonzeros_, 0, coeffs_per_block * sizeof(m->nonzeros_[0])); memset(m->sumabs_, 0, coeffs_per_block * sizeof(m->sumabs_[0])); @@ -584,7 +585,7 @@ void DecodeCurrentiMCURow(j_decompress_ptr cinfo) { int offset = m->streaming_mode_ ? 0 : by0; ba[c] = (*cinfo->mem->access_virt_barray)( reinterpret_cast(cinfo), m->coef_arrays[c], offset, - max_block_rows, false); + max_block_rows, FALSE); } for (int c = 0; c < cinfo->num_components; ++c) { size_t k0 = c * DCTSIZE2; diff --git a/third_party/jpeg-xl/lib/jpegli/source_manager.cc b/third_party/jpeg-xl/lib/jpegli/source_manager.cc index 0b8e0a5c8c..58adf803b1 100644 --- a/third_party/jpeg-xl/lib/jpegli/source_manager.cc +++ b/third_party/jpeg-xl/lib/jpegli/source_manager.cc @@ -39,7 +39,7 @@ struct StdioSourceManager { uint8_t* buffer; static boolean fill_input_buffer(j_decompress_ptr cinfo) { - auto src = reinterpret_cast(cinfo->src); + auto* src = reinterpret_cast(cinfo->src); size_t num_bytes_read = fread(src->buffer, 1, kStdioBufferSize, src->f); if (num_bytes_read == 0) { return EmitFakeEoiMarker(cinfo); @@ -77,7 +77,7 @@ void jpegli_stdio_src(j_decompress_ptr cinfo, FILE* infile) { cinfo->src = reinterpret_cast( jpegli::Allocate(cinfo, 1)); } - auto src = reinterpret_cast(cinfo->src); + auto* src = reinterpret_cast(cinfo->src); src->f = infile; src->buffer = jpegli::Allocate(cinfo, jpegli::kStdioBufferSize); src->pub.next_input_byte = src->buffer; diff --git a/third_party/jpeg-xl/lib/jpegli/source_manager_test.cc b/third_party/jpeg-xl/lib/jpegli/source_manager_test.cc index 4e137876c9..59d12b001b 100644 --- a/third_party/jpeg-xl/lib/jpegli/source_manager_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/source_manager_test.cc @@ -50,7 +50,7 @@ FILE* MemOpen(const std::vector& data) { TEST_P(SourceManagerTestParam, TestStdioSourceManager) { TestConfig config = GetParam(); - std::vector compressed = ReadTestData(config.fn.c_str()); + std::vector compressed = ReadTestData(config.fn); if (config.dparams.size_factor < 1.0) { compressed.resize(compressed.size() * config.dparams.size_factor); } @@ -77,7 +77,7 @@ TEST_P(SourceManagerTestParam, TestStdioSourceManager) { TEST_P(SourceManagerTestParam, TestMemSourceManager) { TestConfig config = GetParam(); - std::vector compressed = ReadTestData(config.fn.c_str()); + std::vector compressed = ReadTestData(config.fn); if (config.dparams.size_factor < 1.0f) { compressed.resize(compressed.size() * config.dparams.size_factor); } diff --git a/third_party/jpeg-xl/lib/jpegli/streaming_test.cc b/third_party/jpeg-xl/lib/jpegli/streaming_test.cc index 8d2e3577f3..2e6f7029b0 100644 --- a/third_party/jpeg-xl/lib/jpegli/streaming_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/streaming_test.cc @@ -36,13 +36,13 @@ struct SourceManager { // input buffer. The buffer size is kept short because empty_output_buffer() is // called only when the output buffer is full, and we want to update the decoder // input frequently to demonstrate that streaming works. -static constexpr size_t kOutputBufferSize = 1024; +constexpr size_t kOutputBufferSize = 1024; struct DestinationManager { jpeg_destination_mgr pub; std::vector buffer; SourceManager* dest; - DestinationManager(SourceManager* src) + explicit DestinationManager(SourceManager* src) : buffer(kOutputBufferSize), dest(src) { pub.next_output_byte = buffer.data(); pub.free_in_buffer = buffer.size(); @@ -54,7 +54,7 @@ struct DestinationManager { static void init_destination(j_compress_ptr cinfo) {} static boolean empty_output_buffer(j_compress_ptr cinfo) { - auto us = reinterpret_cast(cinfo->dest); + auto* us = reinterpret_cast(cinfo->dest); jpeg_destination_mgr* src = &us->pub; jpeg_source_mgr* dst = &us->dest->pub; std::vector& src_buf = us->buffer; @@ -69,7 +69,7 @@ struct DestinationManager { dst->bytes_in_buffer = dst_buf.size(); src->next_output_byte = src_buf.data(); src->free_in_buffer = src_buf.size(); - return true; + return TRUE; } static void term_destination(j_compress_ptr cinfo) { @@ -87,6 +87,7 @@ class StreamingTestParam : public ::testing::TestWithParam {}; TEST_P(StreamingTestParam, TestStreaming) { jpeg_decompress_struct dinfo = {}; jpeg_compress_struct cinfo = {}; + SourceManager src; TestConfig config = GetParam(); TestImage& input = config.input; TestImage output; @@ -99,7 +100,6 @@ TEST_P(StreamingTestParam, TestStreaming) { // compressor's output is connected to the decompressor's input. jpegli_create_decompress(&dinfo); jpegli_create_compress(&cinfo); - SourceManager src; dinfo.src = reinterpret_cast(&src); DestinationManager dest(&src); cinfo.dest = reinterpret_cast(&dest); @@ -107,7 +107,7 @@ TEST_P(StreamingTestParam, TestStreaming) { cinfo.image_width = input.xsize; cinfo.image_height = input.ysize; cinfo.input_components = input.components; - cinfo.in_color_space = (J_COLOR_SPACE)input.color_space; + cinfo.in_color_space = static_cast(input.color_space); jpegli_set_defaults(&cinfo); cinfo.comp_info[0].v_samp_factor = config.jparams.v_sampling[0]; jpegli_set_progressive_level(&cinfo, 0); @@ -122,13 +122,13 @@ TEST_P(StreamingTestParam, TestStreaming) { while (yin < cinfo.image_height) { // Feed one iMCU row at a time to the compressor. size_t lines_in = std::min(iMCU_height, cinfo.image_height - yin); - memcpy(&row_bytes[0], &input.pixels[yin * stride], lines_in * stride); + memcpy(row_bytes.data(), &input.pixels[yin * stride], lines_in * stride); std::vector rows_in(lines_in); for (size_t i = 0; i < lines_in; ++i) { rows_in[i] = &row_bytes[i * stride]; } EXPECT_EQ(lines_in, - jpegli_write_scanlines(&cinfo, &rows_in[0], lines_in)); + jpegli_write_scanlines(&cinfo, rows_in.data(), lines_in)); yin += lines_in; if (yin == cinfo.image_height) { jpegli_finish_compress(&cinfo); @@ -180,7 +180,7 @@ TEST_P(StreamingTestParam, TestStreaming) { reinterpret_cast(&output.pixels[(yout + i) * stride]); } EXPECT_EQ(lines_out, - jpegli_read_scanlines(&dinfo, &rows_out[0], lines_out)); + jpegli_read_scanlines(&dinfo, rows_out.data(), lines_out)); VerifyOutputImage(input, output, yout, lines_out, 3.8f); yout += lines_out; diff --git a/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h b/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h index a454917187..4fbcb721e4 100644 --- a/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h +++ b/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h @@ -8,20 +8,20 @@ // include paths for the jpeg headers. // Sequential non-interleaved. -static constexpr jpeg_scan_info kScript1[] = { +constexpr jpeg_scan_info kScript1[] = { {1, {0}, 0, 63, 0, 0}, {1, {1}, 0, 63, 0, 0}, {1, {2}, 0, 63, 0, 0}, }; // Sequential partially interleaved, chroma first. -static constexpr jpeg_scan_info kScript2[] = { +constexpr jpeg_scan_info kScript2[] = { {2, {1, 2}, 0, 63, 0, 0}, {1, {0}, 0, 63, 0, 0}, }; // Rest of the scan scripts are progressive. -static constexpr jpeg_scan_info kScript3[] = { +constexpr jpeg_scan_info kScript3[] = { // Interleaved full DC. {3, {0, 1, 2}, 0, 0, 0, 0}, // Full AC scans. @@ -29,7 +29,7 @@ static constexpr jpeg_scan_info kScript3[] = { {1, {1}, 1, 63, 0, 0}, {1, {2}, 1, 63, 0, 0}, }; -static constexpr jpeg_scan_info kScript4[] = { +constexpr jpeg_scan_info kScript4[] = { // Non-interleaved full DC. {1, {0}, 0, 0, 0, 0}, {1, {1}, 0, 0, 0, 0}, @@ -39,7 +39,7 @@ static constexpr jpeg_scan_info kScript4[] = { {1, {1}, 1, 63, 0, 0}, {1, {2}, 1, 63, 0, 0}, }; -static constexpr jpeg_scan_info kScript5[] = { +constexpr jpeg_scan_info kScript5[] = { // Partially interleaved full DC, chroma first. {2, {1, 2}, 0, 0, 0, 0}, {1, {0}, 0, 0, 0, 0}, @@ -52,7 +52,7 @@ static constexpr jpeg_scan_info kScript5[] = { {1, {1}, 1, 63, 1, 0}, {1, {2}, 1, 63, 1, 0}, }; -static constexpr jpeg_scan_info kScript6[] = { +constexpr jpeg_scan_info kScript6[] = { // Interleaved DC shifted by 2 bits. {3, {0, 1, 2}, 0, 0, 0, 2}, // Interleaved DC refinement scans. @@ -64,7 +64,7 @@ static constexpr jpeg_scan_info kScript6[] = { {1, {2}, 1, 63, 0, 0}, }; -static constexpr jpeg_scan_info kScript7[] = { +constexpr jpeg_scan_info kScript7[] = { // Non-interleaved DC shifted by 2 bits. {1, {0}, 0, 0, 0, 2}, {1, {1}, 0, 0, 0, 2}, @@ -83,7 +83,7 @@ static constexpr jpeg_scan_info kScript7[] = { {1, {2}, 1, 63, 0, 0}, }; -static constexpr jpeg_scan_info kScript8[] = { +constexpr jpeg_scan_info kScript8[] = { // Partially interleaved DC shifted by 2 bits, chroma first {2, {1, 2}, 0, 0, 0, 2}, {1, {0}, 0, 0, 0, 2}, @@ -99,7 +99,7 @@ static constexpr jpeg_scan_info kScript8[] = { {1, {2}, 1, 63, 0, 0}, }; -static constexpr jpeg_scan_info kScript9[] = { +constexpr jpeg_scan_info kScript9[] = { // Interleaved full DC. {3, {0, 1, 2}, 0, 0, 0, 0}, // AC scans for component 0 @@ -123,7 +123,7 @@ static constexpr jpeg_scan_info kScript9[] = { {1, {2}, 17, 63, 1, 0}, }; -static constexpr jpeg_scan_info kScript10[] = { +constexpr jpeg_scan_info kScript10[] = { // Interleaved full DC. {3, {0, 1, 2}, 0, 0, 0, 0}, // AC scans for spectral range 1..16 @@ -156,14 +156,14 @@ struct ScanScript { const jpeg_scan_info* scans; }; -static constexpr ScanScript kTestScript[] = { +constexpr ScanScript kTestScript[] = { {ARRAY_SIZE(kScript1), kScript1}, {ARRAY_SIZE(kScript2), kScript2}, {ARRAY_SIZE(kScript3), kScript3}, {ARRAY_SIZE(kScript4), kScript4}, {ARRAY_SIZE(kScript5), kScript5}, {ARRAY_SIZE(kScript6), kScript6}, {ARRAY_SIZE(kScript7), kScript7}, {ARRAY_SIZE(kScript8), kScript8}, {ARRAY_SIZE(kScript9), kScript9}, {ARRAY_SIZE(kScript10), kScript10}, }; -static constexpr int kNumTestScripts = ARRAY_SIZE(kTestScript); +constexpr int kNumTestScripts = ARRAY_SIZE(kTestScript); void SetScanDecompressParams(const DecompressParams& dparams, j_decompress_ptr cinfo, int scan_number) { @@ -178,7 +178,7 @@ void SetScanDecompressParams(const DecompressParams& dparams, return; } if (dparams.quantize_colors) { - cinfo->dither_mode = (J_DITHER_MODE)sparams->dither_mode; + cinfo->dither_mode = static_cast(sparams->dither_mode); if (sparams->color_quant_mode == CQUANT_1PASS) { cinfo->two_pass_quantize = FALSE; cinfo->colormap = nullptr; @@ -194,7 +194,8 @@ void SetScanDecompressParams(const DecompressParams& dparams, cinfo->colormap = (*cinfo->mem->alloc_sarray)( reinterpret_cast(cinfo), JPOOL_IMAGE, cinfo->actual_number_of_colors, 3); - jxl::msan::UnpoisonMemory(cinfo->colormap, 3 * sizeof(JSAMPROW)); + jxl::msan::UnpoisonMemory(reinterpret_cast(cinfo->colormap), + 3 * sizeof(JSAMPLE*)); for (int i = 0; i < kTestColorMapNumColors; ++i) { cinfo->colormap[0][i] = (kTestColorMap[i] >> 16) & 0xff; cinfo->colormap[1][i] = (kTestColorMap[i] >> 8) & 0xff; @@ -212,20 +213,21 @@ void SetScanDecompressParams(const DecompressParams& dparams, void SetDecompressParams(const DecompressParams& dparams, j_decompress_ptr cinfo) { - cinfo->do_block_smoothing = dparams.do_block_smoothing; - cinfo->do_fancy_upsampling = dparams.do_fancy_upsampling; + cinfo->do_block_smoothing = dparams.do_block_smoothing ? 1 : 0; + cinfo->do_fancy_upsampling = dparams.do_fancy_upsampling ? 1 : 0; if (dparams.output_mode == RAW_DATA) { cinfo->raw_data_out = TRUE; } if (dparams.set_out_color_space) { - cinfo->out_color_space = (J_COLOR_SPACE)dparams.out_color_space; + cinfo->out_color_space = + static_cast(dparams.out_color_space); if (dparams.out_color_space == JCS_UNKNOWN) { cinfo->jpeg_color_space = JCS_UNKNOWN; } } cinfo->scale_num = dparams.scale_num; cinfo->scale_denom = dparams.scale_denom; - cinfo->quantize_colors = dparams.quantize_colors; + cinfo->quantize_colors = dparams.quantize_colors ? 1 : 0; cinfo->desired_number_of_colors = dparams.desired_number_of_colors; if (!dparams.scan_params.empty()) { if (cinfo->buffered_image) { @@ -420,7 +422,7 @@ void CopyCoefficients(j_decompress_ptr cinfo, jvirt_barray_ptr* coef_arrays, DCTSIZE2); for (size_t by = 0; by < comp->height_in_blocks; ++by) { JBLOCKARRAY ba = (*cinfo->mem->access_virt_barray)(comptr, coef_arrays[c], - by, 1, true); + by, 1, TRUE); size_t stride = comp->width_in_blocks * sizeof(JBLOCK); size_t offset = by * comp->width_in_blocks * DCTSIZE2; memcpy(&coeffs[offset], ba[0], stride); diff --git a/third_party/jpeg-xl/lib/jpegli/test_utils.cc b/third_party/jpeg-xl/lib/jpegli/test_utils.cc index 232b937496..4e675070cf 100644 --- a/third_party/jpeg-xl/lib/jpegli/test_utils.cc +++ b/third_party/jpeg-xl/lib/jpegli/test_utils.cc @@ -153,7 +153,7 @@ bool ReadPNM(const std::vector& data, size_t* xsize, size_t* ysize, return false; } pixels->resize(data.data() + data.size() - pos); - memcpy(&(*pixels)[0], pos, pixels->size()); + memcpy(pixels->data(), pos, pixels->size()); return true; } @@ -216,7 +216,8 @@ std::ostream& operator<<(std::ostream& os, const TestImage& input) { os << input.xsize << "x" << input.ysize; os << IOMethodName(input.data_type, input.endianness); if (input.color_space != JCS_RGB) { - os << "InputColor" << ColorSpaceName((J_COLOR_SPACE)input.color_space); + os << "InputColor" + << ColorSpaceName(static_cast(input.color_space)); } if (input.color_space == JCS_UNKNOWN) { os << input.components; @@ -229,18 +230,18 @@ std::ostream& operator<<(std::ostream& os, const CompressParams& jparams) { os << SamplingId(jparams); if (jparams.set_jpeg_colorspace) { os << "JpegColor" - << ColorSpaceName((J_COLOR_SPACE)jparams.jpeg_color_space); + << ColorSpaceName(static_cast(jparams.jpeg_color_space)); } if (!jparams.comp_ids.empty()) { os << "CID"; - for (size_t i = 0; i < jparams.comp_ids.size(); ++i) { - os << jparams.comp_ids[i]; + for (int cid : jparams.comp_ids) { + os << cid; } } if (!jparams.quant_indexes.empty()) { os << "QIDX"; - for (size_t i = 0; i < jparams.quant_indexes.size(); ++i) { - os << jparams.quant_indexes[i]; + for (int qi : jparams.quant_indexes) { + os << qi; } for (const auto& table : jparams.quant_tables) { os << "TABLE" << table.slot_idx << "T" << table.table_type << "F" @@ -320,7 +321,7 @@ void RGBToYCbCr(float r, float g, float b, float* y, float* cb, float* cr) { void ConvertPixel(const uint8_t* input_rgb, uint8_t* out, J_COLOR_SPACE colorspace, size_t num_channels, JpegliDataType data_type = JPEGLI_TYPE_UINT8, - bool swap_endianness = JPEGLI_NATIVE_ENDIAN) { + JXL_BOOL swap_endianness = JPEGLI_NATIVE_ENDIAN) { const float kMul = 255.0f; float r = input_rgb[0] / kMul; float g = input_rgb[1] / kMul; @@ -334,7 +335,9 @@ void ConvertPixel(const uint8_t* input_rgb, uint8_t* out, out8[c] = input_rgb[std::min(2, c)]; } } else if (colorspace == JCS_YCbCr) { - float Y, Cb, Cr; + float Y; + float Cb; + float Cr; RGBToYCbCr(r, g, b, &Y, &Cb, &Cr); out8[0] = static_cast(std::round(Y * kMul)); out8[1] = static_cast(std::round(Cb * kMul)); @@ -350,7 +353,9 @@ void ConvertPixel(const uint8_t* input_rgb, uint8_t* out, out8[1] = static_cast(std::round((1.0f - g) * kMul)); out8[2] = static_cast(std::round((1.0f - b) * kMul)); } else if (colorspace == JCS_YCCK) { - float Y, Cb, Cr; + float Y; + float Cb; + float Cr; RGBToYCbCr(r, g, b, &Y, &Cb, &Cr); out8[0] = static_cast(std::round(Y * kMul)); out8[1] = static_cast(std::round(Cb * kMul)); @@ -399,7 +404,10 @@ void ConvertToGrayscale(TestImage* img) { void GeneratePixels(TestImage* img) { const std::vector imgdata = ReadTestData("jxl/flower/flower.pnm"); - size_t xsize, ysize, channels, bitdepth; + size_t xsize; + size_t ysize; + size_t channels; + size_t bitdepth; std::vector pixels; JXL_CHECK(ReadPNM(imgdata, &xsize, &ysize, &channels, &bitdepth, &pixels)); if (img->xsize == 0) img->xsize = xsize; @@ -412,7 +420,8 @@ void GeneratePixels(TestImage* img) { size_t in_stride = xsize * in_bytes_per_pixel; size_t x0 = (xsize - img->xsize) / 2; size_t y0 = (ysize - img->ysize) / 2; - SetNumChannels((J_COLOR_SPACE)img->color_space, &img->components); + SetNumChannels(static_cast(img->color_space), + &img->components); size_t out_bytes_per_pixel = jpegli_bytes_per_sample(img->data_type) * img->components; size_t out_stride = img->xsize * out_bytes_per_pixel; @@ -427,8 +436,9 @@ void GeneratePixels(TestImage* img) { size_t idx_in = y * in_stride + x * in_bytes_per_pixel; size_t idx_out = iy * out_stride + ix * out_bytes_per_pixel; ConvertPixel(&pixels[idx_in], &img->pixels[idx_out], - (J_COLOR_SPACE)img->color_space, img->components, - img->data_type, swap_endianness); + static_cast(img->color_space), + img->components, img->data_type, + TO_JXL_BOOL(swap_endianness)); } } } @@ -492,7 +502,7 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, jpegli_set_progressive_level(cinfo, 0); } jpegli_set_defaults(cinfo); - cinfo->in_color_space = (J_COLOR_SPACE)input.color_space; + cinfo->in_color_space = static_cast(input.color_space); jpegli_default_colorspace(cinfo); if (jparams.override_JFIF >= 0) { cinfo->write_JFIF_header = jparams.override_JFIF; @@ -501,7 +511,8 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, cinfo->write_Adobe_marker = jparams.override_Adobe; } if (jparams.set_jpeg_colorspace) { - jpegli_set_colorspace(cinfo, (J_COLOR_SPACE)jparams.jpeg_color_space); + jpegli_set_colorspace(cinfo, + static_cast(jparams.jpeg_color_space)); } if (!jparams.comp_ids.empty()) { for (int c = 0; c < cinfo->num_components; ++c) { @@ -522,15 +533,16 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, for (const auto& table : jparams.quant_tables) { if (table.add_raw) { cinfo->quant_tbl_ptrs[table.slot_idx] = - jpegli_alloc_quant_table((j_common_ptr)cinfo); + jpegli_alloc_quant_table(reinterpret_cast(cinfo)); for (int k = 0; k < DCTSIZE2; ++k) { cinfo->quant_tbl_ptrs[table.slot_idx]->quantval[k] = table.quantval[k]; } cinfo->quant_tbl_ptrs[table.slot_idx]->sent_table = FALSE; } else { - jpegli_add_quant_table(cinfo, table.slot_idx, &table.basic_table[0], - table.scale_factor, table.force_baseline); + jpegli_add_quant_table(cinfo, table.slot_idx, table.basic_table.data(), + table.scale_factor, + TO_JXL_BOOL(table.force_baseline)); } } } @@ -546,7 +558,8 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, jpegli_set_progressive_level(cinfo, jparams.progressive_mode); } jpegli_set_input_format(cinfo, input.data_type, input.endianness); - jpegli_enable_adaptive_quantization(cinfo, jparams.use_adaptive_quantization); + jpegli_enable_adaptive_quantization( + cinfo, TO_JXL_BOOL(jparams.use_adaptive_quantization)); cinfo->restart_interval = jparams.restart_interval; cinfo->restart_in_rows = jparams.restart_in_rows; cinfo->smoothing_factor = jparams.smoothing_factor; @@ -555,7 +568,7 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, } else if (jparams.optimize_coding == 0) { cinfo->optimize_coding = FALSE; } - cinfo->raw_data_in = !input.raw_data.empty(); + cinfo->raw_data_in = TO_JXL_BOOL(!input.raw_data.empty()); if (jparams.optimize_coding == 0 && jparams.use_flat_dc_luma_code) { JHUFF_TBL* tbl = cinfo->dc_huff_tbl_ptrs[0]; memset(tbl, 0, sizeof(*tbl)); @@ -572,13 +585,13 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, cinfo->ac_huff_tbl_ptrs[0]->sent_table = TRUE; cinfo->ac_huff_tbl_ptrs[1]->sent_table = TRUE; } - jpegli_start_compress(cinfo, write_all_tables); + jpegli_start_compress(cinfo, TO_JXL_BOOL(write_all_tables)); if (jparams.add_marker) { jpegli_write_marker(cinfo, kSpecialMarker0, kMarkerData, sizeof(kMarkerData)); jpegli_write_m_header(cinfo, kSpecialMarker1, sizeof(kMarkerData)); - for (size_t p = 0; p < sizeof(kMarkerData); ++p) { - jpegli_write_m_byte(cinfo, kMarkerData[p]); + for (uint8_t c : kMarkerData) { + jpegli_write_m_byte(cinfo, c); } for (size_t i = 0; i < kMarkerSequenceLen; ++i) { jpegli_write_marker(cinfo, kMarkerSequence[i], kMarkerData, @@ -597,7 +610,7 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, std::vector data(cinfo->num_components); for (int c = 0; c < cinfo->num_components; ++c) { rowdata[c].resize(jparams.v_samp(c) * DCTSIZE); - data[c] = &rowdata[c][0]; + data[c] = rowdata[c].data(); } while (cinfo->next_scanline < cinfo->image_height) { for (int c = 0; c < cinfo->num_components; ++c) { @@ -610,7 +623,7 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, (y0 + i < cheight ? &raw_data[c][(y0 + i) * cwidth] : nullptr); } } - size_t num_lines = jpegli_write_raw_data(cinfo, &data[0], max_lines); + size_t num_lines = jpegli_write_raw_data(cinfo, data.data(), max_lines); JXL_CHECK(num_lines == max_lines); } } else if (!input.coeffs.empty()) { @@ -630,15 +643,15 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, jpegli_write_marker(cinfo, kSpecialMarker0, kMarkerData, sizeof(kMarkerData)); jpegli_write_m_header(cinfo, kSpecialMarker1, sizeof(kMarkerData)); - for (size_t p = 0; p < sizeof(kMarkerData); ++p) { - jpegli_write_m_byte(cinfo, kMarkerData[p]); + for (uint8_t c : kMarkerData) { + jpegli_write_m_byte(cinfo, c); } } for (int c = 0; c < cinfo->num_components; ++c) { jpeg_component_info* comp = &cinfo->comp_info[c]; for (size_t by = 0; by < comp->height_in_blocks; ++by) { JBLOCKARRAY ba = (*cinfo->mem->access_virt_barray)( - comptr, coef_arrays[c], by, 1, true); + comptr, coef_arrays[c], by, 1, TRUE); size_t stride = comp->width_in_blocks * sizeof(JBLOCK); size_t offset = by * comp->width_in_blocks * DCTSIZE2; memcpy(ba[0], &input.coeffs[c][offset], stride); @@ -649,7 +662,7 @@ void EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, jpegli_bytes_per_sample(input.data_type); std::vector row_bytes(stride); for (size_t y = 0; y < cinfo->image_height; ++y) { - memcpy(&row_bytes[0], &input.pixels[y * stride], stride); + memcpy(row_bytes.data(), &input.pixels[y * stride], stride); JSAMPROW row[] = {row_bytes.data()}; jpegli_write_scanlines(cinfo, row, 1); } @@ -681,15 +694,15 @@ bool EncodeWithJpegli(const TestImage& input, const CompressParams& jparams, int NumTestScanScripts() { return kNumTestScripts; } -void DumpImage(const TestImage& image, const std::string fn) { +void DumpImage(const TestImage& image, const std::string& fn) { JXL_CHECK(image.components == 1 || image.components == 3); size_t bytes_per_sample = jpegli_bytes_per_sample(image.data_type); uint32_t maxval = (1u << (8 * bytes_per_sample)) - 1; char type = image.components == 1 ? '5' : '6'; std::ofstream out(fn.c_str(), std::ofstream::binary); - out << "P" << type << std::endl - << image.xsize << " " << image.ysize << std::endl - << maxval << std::endl; + out << "P" << type << "\n" + << image.xsize << " " << image.ysize << "\n" + << maxval << "\n"; out.write(reinterpret_cast(image.pixels.data()), image.pixels.size()); out.close(); diff --git a/third_party/jpeg-xl/lib/jpegli/testing.h b/third_party/jpeg-xl/lib/jpegli/testing.h index 873a0171e7..6a6e0ca638 100644 --- a/third_party/jpeg-xl/lib/jpegli/testing.h +++ b/third_party/jpeg-xl/lib/jpegli/testing.h @@ -6,15 +6,7 @@ #ifndef LIB_JPEGLI_TESTING_H_ #define LIB_JPEGLI_TESTING_H_ -// GTest/GMock specific macros / wrappers. - -// gmock unconditionally redefines those macros (to wrong values). -// Lets include it only here and mitigate the problem. -#pragma push_macro("PRIdS") -#pragma push_macro("PRIuS") -#include "gmock/gmock.h" -#pragma pop_macro("PRIuS") -#pragma pop_macro("PRIdS") +// GTest specific macros / wrappers. #include "gtest/gtest.h" @@ -28,8 +20,12 @@ // Ensures that we don't make our test bounds too lax, effectively disabling the // tests. -MATCHER_P(IsSlightlyBelow, max, "") { - return max * 0.75 <= arg && arg <= max * 1.0; -} +#define EXPECT_SLIGHTLY_BELOW(A, E) \ + { \ + double _actual = (A); \ + double _expected = (E); \ + EXPECT_LE(_actual, _expected); \ + EXPECT_GE(_actual, 0.75 * _expected); \ + } #endif // LIB_JPEGLI_TESTING_H_ diff --git a/third_party/jpeg-xl/lib/jpegli/transpose-inl.h b/third_party/jpeg-xl/lib/jpegli/transpose-inl.h index 9fdd222f4e..cdc289f96c 100644 --- a/third_party/jpeg-xl/lib/jpegli/transpose-inl.h +++ b/third_party/jpeg-xl/lib/jpegli/transpose-inl.h @@ -18,8 +18,8 @@ namespace HWY_NAMESPACE { namespace { #if HWY_CAP_GE256 -static JXL_INLINE void Transpose8x8Block(const float* JXL_RESTRICT from, - float* JXL_RESTRICT to) { +JXL_INLINE void Transpose8x8Block(const float* JXL_RESTRICT from, + float* JXL_RESTRICT to) { const HWY_CAPPED(float, 8) d; auto i0 = Load(d, from); auto i1 = Load(d, from + 1 * 8); @@ -67,8 +67,8 @@ static JXL_INLINE void Transpose8x8Block(const float* JXL_RESTRICT from, Store(i7, d, to + 7 * 8); } #elif HWY_TARGET != HWY_SCALAR -static JXL_INLINE void Transpose8x8Block(const float* JXL_RESTRICT from, - float* JXL_RESTRICT to) { +JXL_INLINE void Transpose8x8Block(const float* JXL_RESTRICT from, + float* JXL_RESTRICT to) { const HWY_CAPPED(float, 4) d; for (size_t n = 0; n < 8; n += 4) { for (size_t m = 0; m < 8; m += 4) { diff --git a/third_party/jpeg-xl/lib/jpegli/upsample.cc b/third_party/jpeg-xl/lib/jpegli/upsample.cc index 5559aa78a6..7dae841b8a 100644 --- a/third_party/jpeg-xl/lib/jpegli/upsample.cc +++ b/third_party/jpeg-xl/lib/jpegli/upsample.cc @@ -122,7 +122,7 @@ HWY_EXPORT(Upsample2Vertical); void Upsample2Horizontal(float* JXL_RESTRICT row, float* JXL_RESTRICT scratch_space, size_t len_out) { - return HWY_DYNAMIC_DISPATCH(Upsample2Horizontal)(row, scratch_space, len_out); + HWY_DYNAMIC_DISPATCH(Upsample2Horizontal)(row, scratch_space, len_out); } void Upsample2Vertical(const float* JXL_RESTRICT row_top, @@ -130,8 +130,8 @@ void Upsample2Vertical(const float* JXL_RESTRICT row_top, const float* JXL_RESTRICT row_bot, float* JXL_RESTRICT row_out0, float* JXL_RESTRICT row_out1, size_t len) { - return HWY_DYNAMIC_DISPATCH(Upsample2Vertical)(row_top, row_mid, row_bot, - row_out0, row_out1, len); + HWY_DYNAMIC_DISPATCH(Upsample2Vertical) + (row_top, row_mid, row_bot, row_out0, row_out1, len); } } // namespace jpegli #endif // HWY_ONCE diff --git a/third_party/jpeg-xl/lib/jxl.cmake b/third_party/jpeg-xl/lib/jxl.cmake index 8c7e711f52..86fa37151d 100644 --- a/third_party/jpeg-xl/lib/jxl.cmake +++ b/third_party/jpeg-xl/lib/jxl.cmake @@ -60,7 +60,7 @@ include(GenerateExportHeader) # CMake does not allow generate_export_header for INTERFACE library, so we # add this stub library just for file generation. -add_library(jxl_export OBJECT ${JPEGXL_INTERNAL_PUBLIC_HEADERS}) +add_library(jxl_export OBJECT ${JPEGXL_INTERNAL_PUBLIC_HEADERS} nothing.cc) set_target_properties(jxl_export PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1 @@ -269,8 +269,10 @@ set(JPEGXL_LIBRARY_REQUIRES if (BUILD_SHARED_LIBS) set(JPEGXL_REQUIRES_TYPE "Requires.private") + set(JPEGXL_PRIVATE_LIBS "-lm ${PKGCONFIG_CXX_LIB}") else() set(JPEGXL_REQUIRES_TYPE "Requires") + set(JPEGXL_PUBLIC_LIBS "-lm ${PKGCONFIG_CXX_LIB}") endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/jxl/libjxl.pc.in" diff --git a/third_party/jpeg-xl/lib/jxl/ac_strategy.cc b/third_party/jpeg-xl/lib/jxl/ac_strategy.cc index 3de477f71c..e7a72f5a33 100644 --- a/third_party/jpeg-xl/lib/jxl/ac_strategy.cc +++ b/third_party/jpeg-xl/lib/jxl/ac_strategy.cc @@ -8,12 +8,9 @@ #include #include -#include // iota -#include #include #include "lib/jxl/base/bits.h" -#include "lib/jxl/image_ops.h" namespace jxl { @@ -86,10 +83,12 @@ constexpr size_t AcStrategy::kMaxCoeffBlocks; constexpr size_t AcStrategy::kMaxBlockDim; constexpr size_t AcStrategy::kMaxCoeffArea; -AcStrategyImage::AcStrategyImage(size_t xsize, size_t ysize) - : layers_(xsize, ysize) { - row_ = layers_.Row(0); - stride_ = layers_.PixelsPerRow(); +StatusOr AcStrategyImage::Create(size_t xsize, size_t ysize) { + AcStrategyImage img; + JXL_ASSIGN_OR_RETURN(img.layers_, ImageB::Create(xsize, ysize)); + img.row_ = img.layers_.Row(0); + img.stride_ = img.layers_.PixelsPerRow(); + return img; } size_t AcStrategyImage::CountBlocks(AcStrategy::Type type) const { diff --git a/third_party/jpeg-xl/lib/jxl/ac_strategy.h b/third_party/jpeg-xl/lib/jxl/ac_strategy.h index ecdcbbbd32..9e5917ff1b 100644 --- a/third_party/jpeg-xl/lib/jxl/ac_strategy.h +++ b/third_party/jpeg-xl/lib/jxl/ac_strategy.h @@ -144,7 +144,7 @@ class AcStrategy { 8, 4, 8, 16, 8, 16, 32, 16, 32}; static_assert(sizeof(kLut) / sizeof(*kLut) == kNumValidStrategies, "Update LUT"); - return kLut[size_t(strategy_)]; + return kLut[static_cast(strategy_)]; } JXL_INLINE size_t covered_blocks_y() const { @@ -153,7 +153,7 @@ class AcStrategy { 8, 8, 4, 16, 16, 8, 32, 32, 16}; static_assert(sizeof(kLut) / sizeof(*kLut) == kNumValidStrategies, "Update LUT"); - return kLut[size_t(strategy_)]; + return kLut[static_cast(strategy_)]; } JXL_INLINE size_t log2_covered_blocks() const { @@ -162,7 +162,7 @@ class AcStrategy { 6, 5, 5, 8, 7, 7, 10, 9, 9}; static_assert(sizeof(kLut) / sizeof(*kLut) == kNumValidStrategies, "Update LUT"); - return kLut[size_t(strategy_)]; + return kLut[static_cast(strategy_)]; } private: @@ -181,7 +181,9 @@ class AcStrategyRow { public: explicit AcStrategyRow(const uint8_t* row) : row_(row) {} AcStrategy operator[](size_t x) const { - return AcStrategy(static_cast(row_[x] >> 1), row_[x] & 1); + AcStrategy::Type strategy = static_cast(row_[x] >> 1); + bool is_first = static_cast(row_[x] & 1); + return AcStrategy(strategy, is_first); } private: @@ -191,7 +193,8 @@ class AcStrategyRow { class AcStrategyImage { public: AcStrategyImage() = default; - AcStrategyImage(size_t xsize, size_t ysize); + static StatusOr Create(size_t xsize, size_t ysize); + AcStrategyImage(AcStrategyImage&&) = default; AcStrategyImage& operator=(AcStrategyImage&&) = default; diff --git a/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc b/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc index 3745db2b32..b1d9103466 100644 --- a/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc +++ b/third_party/jpeg-xl/lib/jxl/ac_strategy_test.cc @@ -81,7 +81,8 @@ class AcStrategyRoundtrip : public ::hwy::TestWithParamTargetAndT { HWY_TARGET_INSTANTIATE_TEST_SUITE_P_T( AcStrategyRoundtrip, - ::testing::Range(0, int(AcStrategy::Type::kNumValidStrategies))); + ::testing::Range(0, + static_cast(AcStrategy::Type::kNumValidStrategies))); TEST_P(AcStrategyRoundtrip, Test) { Run(); } @@ -141,7 +142,8 @@ class AcStrategyRoundtripDownsample HWY_TARGET_INSTANTIATE_TEST_SUITE_P_T( AcStrategyRoundtripDownsample, - ::testing::Range(0, int(AcStrategy::Type::kNumValidStrategies))); + ::testing::Range(0, + static_cast(AcStrategy::Type::kNumValidStrategies))); TEST_P(AcStrategyRoundtripDownsample, Test) { Run(); } @@ -205,7 +207,8 @@ class AcStrategyDownsample : public ::hwy::TestWithParamTargetAndT { HWY_TARGET_INSTANTIATE_TEST_SUITE_P_T( AcStrategyDownsample, - ::testing::Range(0, int(AcStrategy::Type::kNumValidStrategies))); + ::testing::Range(0, + static_cast(AcStrategy::Type::kNumValidStrategies))); TEST_P(AcStrategyDownsample, Test) { Run(); } diff --git a/third_party/jpeg-xl/lib/jxl/alpha_test.cc b/third_party/jpeg-xl/lib/jxl/alpha_test.cc index ddafd829ec..a93254f3dd 100644 --- a/third_party/jpeg-xl/lib/jxl/alpha_test.cc +++ b/third_party/jpeg-xl/lib/jxl/alpha_test.cc @@ -5,69 +5,59 @@ #include "lib/jxl/alpha.h" -#include "lib/jxl/test_utils.h" +#include + +#include "lib/jxl/base/common.h" #include "lib/jxl/testing.h" namespace jxl { namespace { -using ::testing::_; -using ::testing::ElementsAre; -using ::testing::FloatNear; - TEST(AlphaTest, BlendingWithNonPremultiplied) { - const float bg_rgb[3] = {100, 110, 120}; + const Color bg_rgb{100, 110, 120}; const float bg_a = 180.f / 255; - const float fg_rgb[3] = {25, 21, 23}; + const Color fg_rgb{25, 21, 23}; const float fg_a = 15420.f / 65535; const float fg_a2 = 2.0f; - float out_rgb[3]; + Color out_rgb; float out_a; PerformAlphaBlending( /*bg=*/{&bg_rgb[0], &bg_rgb[1], &bg_rgb[2], &bg_a}, /*fg=*/{&fg_rgb[0], &fg_rgb[1], &fg_rgb[2], &fg_a}, /*out=*/{&out_rgb[0], &out_rgb[1], &out_rgb[2], &out_a}, 1, /*alpha_is_premultiplied=*/false, /*clamp=*/false); - EXPECT_THAT(out_rgb, - ElementsAre(FloatNear(77.2f, .05f), FloatNear(83.0f, .05f), - FloatNear(90.6f, .05f))); + EXPECT_ARRAY_NEAR(out_rgb, (Color{77.2f, 83.0f, 90.6f}), 0.05f); EXPECT_NEAR(out_a, 3174.f / 4095, 1e-5); PerformAlphaBlending( /*bg=*/{&bg_rgb[0], &bg_rgb[1], &bg_rgb[2], &bg_a}, /*fg=*/{&fg_rgb[0], &fg_rgb[1], &fg_rgb[2], &fg_a2}, /*out=*/{&out_rgb[0], &out_rgb[1], &out_rgb[2], &out_a}, 1, /*alpha_is_premultiplied=*/false, /*clamp=*/true); - EXPECT_THAT(out_rgb, ElementsAre(FloatNear(fg_rgb[0], .05f), - FloatNear(fg_rgb[1], .05f), - FloatNear(fg_rgb[2], .05f))); + EXPECT_ARRAY_NEAR(out_rgb, fg_rgb, 0.05f); EXPECT_NEAR(out_a, 1.0f, 1e-5); } TEST(AlphaTest, BlendingWithPremultiplied) { - const float bg_rgb[3] = {100, 110, 120}; + const Color bg_rgb{100, 110, 120}; const float bg_a = 180.f / 255; - const float fg_rgb[3] = {25, 21, 23}; + const Color fg_rgb{25, 21, 23}; const float fg_a = 15420.f / 65535; const float fg_a2 = 2.0f; - float out_rgb[3]; + Color out_rgb; float out_a; PerformAlphaBlending( /*bg=*/{&bg_rgb[0], &bg_rgb[1], &bg_rgb[2], &bg_a}, /*fg=*/{&fg_rgb[0], &fg_rgb[1], &fg_rgb[2], &fg_a}, /*out=*/{&out_rgb[0], &out_rgb[1], &out_rgb[2], &out_a}, 1, /*alpha_is_premultiplied=*/true, /*clamp=*/false); - EXPECT_THAT(out_rgb, - ElementsAre(FloatNear(101.5f, .05f), FloatNear(105.1f, .05f), - FloatNear(114.8f, .05f))); + EXPECT_ARRAY_NEAR(out_rgb, (Color{101.5f, 105.1f, 114.8f}), 0.05f); EXPECT_NEAR(out_a, 3174.f / 4095, 1e-5); PerformAlphaBlending( /*bg=*/{&bg_rgb[0], &bg_rgb[1], &bg_rgb[2], &bg_a}, /*fg=*/{&fg_rgb[0], &fg_rgb[1], &fg_rgb[2], &fg_a2}, /*out=*/{&out_rgb[0], &out_rgb[1], &out_rgb[2], &out_a}, 1, /*alpha_is_premultiplied=*/true, /*clamp=*/true); - EXPECT_THAT(out_rgb, ElementsAre(FloatNear(fg_rgb[0], .05f), - FloatNear(fg_rgb[1], .05f), - FloatNear(fg_rgb[2], .05f))); + EXPECT_ARRAY_NEAR(out_rgb, fg_rgb, 0.05f); EXPECT_NEAR(out_a, 1.0f, 1e-5); } @@ -76,58 +66,51 @@ TEST(AlphaTest, Mul) { const float fg = 25; float out; PerformMulBlending(&bg, &fg, &out, 1, /*clamp=*/false); - EXPECT_THAT(out, FloatNear(fg * bg, .05f)); + EXPECT_NEAR(out, fg * bg, .05f); PerformMulBlending(&bg, &fg, &out, 1, /*clamp=*/true); - EXPECT_THAT(out, FloatNear(bg, .05f)); + EXPECT_NEAR(out, bg, .05f); } TEST(AlphaTest, PremultiplyAndUnpremultiply) { - const float alpha[] = {0.f, 63.f / 255, 127.f / 255, 1.f}; - float r[] = {120, 130, 140, 150}; - float g[] = {124, 134, 144, 154}; - float b[] = {127, 137, 147, 157}; + using F4 = std::array; + const F4 alpha{0.f, 63.f / 255, 127.f / 255, 1.f}; + F4 r{120, 130, 140, 150}; + F4 g{124, 134, 144, 154}; + F4 b{127, 137, 147, 157}; - PremultiplyAlpha(r, g, b, alpha, 4); - EXPECT_THAT( - r, ElementsAre(FloatNear(0.f, 1e-5f), FloatNear(130 * 63.f / 255, 1e-5f), - FloatNear(140 * 127.f / 255, 1e-5f), 150)); - EXPECT_THAT( - g, ElementsAre(FloatNear(0.f, 1e-5f), FloatNear(134 * 63.f / 255, 1e-5f), - FloatNear(144 * 127.f / 255, 1e-5f), 154)); - EXPECT_THAT( - b, ElementsAre(FloatNear(0.f, 1e-5f), FloatNear(137 * 63.f / 255, 1e-5f), - FloatNear(147 * 127.f / 255, 1e-5f), 157)); + PremultiplyAlpha(r.data(), g.data(), b.data(), alpha.data(), alpha.size()); + EXPECT_ARRAY_NEAR(r, (F4{0.0f, 130 * 63.f / 255, 140 * 127.f / 255, 150}), + 1e-5f); + EXPECT_ARRAY_NEAR(g, (F4{0.0f, 134 * 63.f / 255, 144 * 127.f / 255, 154}), + 1e-5f); + EXPECT_ARRAY_NEAR(b, (F4{0.0f, 137 * 63.f / 255, 147 * 127.f / 255, 157}), + 1e-5f); - UnpremultiplyAlpha(r, g, b, alpha, 4); - EXPECT_THAT(r, ElementsAre(FloatNear(120, 1e-4f), FloatNear(130, 1e-4f), - FloatNear(140, 1e-4f), FloatNear(150, 1e-4f))); - EXPECT_THAT(g, ElementsAre(FloatNear(124, 1e-4f), FloatNear(134, 1e-4f), - FloatNear(144, 1e-4f), FloatNear(154, 1e-4f))); - EXPECT_THAT(b, ElementsAre(FloatNear(127, 1e-4f), FloatNear(137, 1e-4f), - FloatNear(147, 1e-4f), FloatNear(157, 1e-4f))); + UnpremultiplyAlpha(r.data(), g.data(), b.data(), alpha.data(), alpha.size()); + EXPECT_ARRAY_NEAR(r, (F4{120, 130, 140, 150}), 1e-4f); + EXPECT_ARRAY_NEAR(g, (F4{124, 134, 144, 154}), 1e-4f); + EXPECT_ARRAY_NEAR(b, (F4{127, 137, 147, 157}), 1e-4f); } TEST(AlphaTest, UnpremultiplyAndPremultiply) { - const float alpha[] = {0.f, 63.f / 255, 127.f / 255, 1.f}; - float r[] = {50, 60, 70, 80}; - float g[] = {54, 64, 74, 84}; - float b[] = {57, 67, 77, 87}; + using F4 = std::array; + const F4 alpha{0.f, 63.f / 255, 127.f / 255, 1.f}; + F4 r{50, 60, 70, 80}; + F4 g{54, 64, 74, 84}; + F4 b{57, 67, 77, 87}; - UnpremultiplyAlpha(r, g, b, alpha, 4); - EXPECT_THAT(r, ElementsAre(_, FloatNear(60 * 255.f / 63, 1e-4f), - FloatNear(70 * 255.f / 127, 1e-4f), 80)); - EXPECT_THAT(g, ElementsAre(_, FloatNear(64 * 255.f / 63, 1e-4f), - FloatNear(74 * 255.f / 127, 1e-4f), 84)); - EXPECT_THAT(b, ElementsAre(_, FloatNear(67 * 255.f / 63, 1e-4f), - FloatNear(77 * 255.f / 127, 1e-4f), 87)); + UnpremultiplyAlpha(r.data(), g.data(), b.data(), alpha.data(), alpha.size()); + EXPECT_ARRAY_NEAR( + r, (F4{50.0f * (1 << 26), 60 * 255.f / 63, 70 * 255.f / 127, 80}), 1e-4f); + EXPECT_ARRAY_NEAR( + g, (F4{54.0f * (1 << 26), 64 * 255.f / 63, 74 * 255.f / 127, 84}), 1e-4f); + EXPECT_ARRAY_NEAR( + b, (F4{57.0f * (1 << 26), 67 * 255.f / 63, 77 * 255.f / 127, 87}), 1e-4f); - PremultiplyAlpha(r, g, b, alpha, 4); - EXPECT_THAT(r, ElementsAre(FloatNear(50, 1e-4f), FloatNear(60, 1e-4f), - FloatNear(70, 1e-4f), FloatNear(80, 1e-4f))); - EXPECT_THAT(g, ElementsAre(FloatNear(54, 1e-4f), FloatNear(64, 1e-4f), - FloatNear(74, 1e-4f), FloatNear(84, 1e-4f))); - EXPECT_THAT(b, ElementsAre(FloatNear(57, 1e-4f), FloatNear(67, 1e-4f), - FloatNear(77, 1e-4f), FloatNear(87, 1e-4f))); + PremultiplyAlpha(r.data(), g.data(), b.data(), alpha.data(), alpha.size()); + EXPECT_ARRAY_NEAR(r, (F4{50, 60, 70, 80}), 1e-4); + EXPECT_ARRAY_NEAR(g, (F4{54, 64, 74, 84}), 1e-4); + EXPECT_ARRAY_NEAR(b, (F4{57, 67, 77, 87}), 1e-4); } } // namespace diff --git a/third_party/jpeg-xl/lib/jxl/ans_common.h b/third_party/jpeg-xl/lib/jxl/ans_common.h index fb5058e310..44b8e3fba1 100644 --- a/third_party/jpeg-xl/lib/jxl/ans_common.h +++ b/third_party/jpeg-xl/lib/jxl/ans_common.h @@ -24,7 +24,8 @@ namespace jxl { static JXL_INLINE uint32_t GetPopulationCountPrecision(uint32_t logcount, uint32_t shift) { int32_t r = std::min( - logcount, int(shift) - int((ANS_LOG_TAB_SIZE - logcount) >> 1)); + logcount, static_cast(shift) - + static_cast((ANS_LOG_TAB_SIZE - logcount) >> 1)); if (r < 0) return 0; return r; } diff --git a/third_party/jpeg-xl/lib/jxl/ans_test.cc b/third_party/jpeg-xl/lib/jxl/ans_test.cc index c28daf7b85..5d6a5ef090 100644 --- a/third_party/jpeg-xl/lib/jxl/ans_test.cc +++ b/third_party/jpeg-xl/lib/jxl/ans_test.cc @@ -113,8 +113,8 @@ void RoundtripRandomUnbalancedStream(int alphabet_size) { Rng rng(0); for (size_t i = 0; i < kReps; i++) { std::vector distributions[kNumHistograms] = {}; - for (int j = 0; j < kNumHistograms; j++) { - distributions[j].resize(kPrecision); + for (auto& distr : distributions) { + distr.resize(kPrecision); int symbol = 0; int remaining = 1; for (int k = 0; k < kPrecision; k++) { @@ -126,7 +126,7 @@ void RoundtripRandomUnbalancedStream(int alphabet_size) { // sufficiently dissimilar. remaining = rng.UniformU(0, kPrecision - k + 1); } - distributions[j][k] = symbol; + distr[k] = symbol; remaining--; } } @@ -158,7 +158,8 @@ TEST(ANSTest, RandomUnbalancedStreamRoundtripBig) { TEST(ANSTest, UintConfigRoundtrip) { for (size_t log_alpha_size = 5; log_alpha_size <= 8; log_alpha_size++) { - std::vector uint_config, uint_config_dec; + std::vector uint_config; + std::vector uint_config_dec; for (size_t i = 0; i < log_alpha_size; i++) { for (size_t j = 0; j <= i; j++) { for (size_t k = 0; k <= i - j; k++) { @@ -187,16 +188,16 @@ TEST(ANSTest, UintConfigRoundtrip) { void TestCheckpointing(bool ans, bool lz77) { std::vector> input_values(1); for (size_t i = 0; i < 1024; i++) { - input_values[0].push_back(Token(0, i % 4)); + input_values[0].emplace_back(0, i % 4); } // up to lz77 window size. for (size_t i = 0; i < (1 << 20) - 1022; i++) { - input_values[0].push_back(Token(0, (i % 5) + 4)); + input_values[0].emplace_back(0, (i % 5) + 4); } // Ensure that when the window wraps around, new values are different. - input_values[0].push_back(Token(0, 0)); + input_values[0].emplace_back(0, 0); for (size_t i = 0; i < 1024; i++) { - input_values[0].push_back(Token(0, i % 4)); + input_values[0].emplace_back(0, i % 4); } std::vector context_map; diff --git a/third_party/jpeg-xl/lib/jxl/base/bits.h b/third_party/jpeg-xl/lib/jxl/base/bits.h index 9f86118e72..a79fdc2c99 100644 --- a/third_party/jpeg-xl/lib/jxl/base/bits.h +++ b/third_party/jpeg-xl/lib/jxl/base/bits.h @@ -26,7 +26,8 @@ struct SizeTag {}; template constexpr bool IsSigned() { - return T(0) > T(-1); + // TODO(eustas): remove dupes + return static_cast(0) > static_cast(-1); } // Undefined results for x == 0. diff --git a/third_party/jpeg-xl/lib/jxl/base/byte_order.h b/third_party/jpeg-xl/lib/jxl/base/byte_order.h index 8966834e08..cf8d7db082 100644 --- a/third_party/jpeg-xl/lib/jxl/base/byte_order.h +++ b/third_party/jpeg-xl/lib/jxl/base/byte_order.h @@ -237,22 +237,22 @@ struct OrderLE {}; // Wrappers for calling from generic code. static JXL_INLINE void Store16(OrderBE /*tag*/, const uint32_t native, uint8_t* p) { - return StoreBE16(native, p); + StoreBE16(native, p); } static JXL_INLINE void Store16(OrderLE /*tag*/, const uint32_t native, uint8_t* p) { - return StoreLE16(native, p); + StoreLE16(native, p); } static JXL_INLINE void Store32(OrderBE /*tag*/, const uint32_t native, uint8_t* p) { - return StoreBE32(native, p); + StoreBE32(native, p); } static JXL_INLINE void Store32(OrderLE /*tag*/, const uint32_t native, uint8_t* p) { - return StoreLE32(native, p); + StoreLE32(native, p); } static JXL_INLINE uint32_t Load16(OrderBE /*tag*/, const uint8_t* p) { diff --git a/third_party/jpeg-xl/lib/jxl/base/common.h b/third_party/jpeg-xl/lib/jxl/base/common.h index b7fe6ab0bc..0893ef26b5 100644 --- a/third_party/jpeg-xl/lib/jxl/base/common.h +++ b/third_party/jpeg-xl/lib/jxl/base/common.h @@ -8,11 +8,13 @@ // Shared constants and helper functions. +#include #include #include #include #include #include +#include #include "lib/jxl/base/compiler_specific.h" @@ -22,11 +24,11 @@ namespace jxl { constexpr size_t kBitsPerByte = 8; // more clear than CHAR_BIT constexpr inline size_t RoundUpBitsToByteMultiple(size_t bits) { - return (bits + 7) & ~size_t(7); + return (bits + 7) & ~static_cast(7); } constexpr inline size_t RoundUpToBlockDim(size_t dim) { - return (dim + 7) & ~size_t(7); + return (dim + 7) & ~static_cast(7); } static inline bool JXL_MAYBE_UNUSED SafeAdd(const uint64_t a, const uint64_t b, @@ -68,6 +70,37 @@ std::unique_ptr make_unique(Args&&... args) { using std::make_unique; #endif +typedef std::array Color; + +// Backported std::experimental::to_array + +template +using remove_cv_t = typename std::remove_cv::type; + +template +struct index_sequence {}; + +template +struct make_index_sequence : make_index_sequence {}; + +template +struct make_index_sequence<0, I...> : index_sequence {}; + +namespace detail { + +template +constexpr auto to_array(T (&&arr)[N], index_sequence _) + -> std::array, N> { + return {{std::move(arr[I])...}}; +} + +} // namespace detail + +template +constexpr auto to_array(T (&&arr)[N]) -> std::array, N> { + return detail::to_array(std::move(arr), make_index_sequence()); +} + template JXL_INLINE T Clamp1(T val, T low, T hi) { return val < low ? low : val > hi ? hi : val; @@ -77,10 +110,10 @@ JXL_INLINE T Clamp1(T val, T low, T hi) { template std::string ToString(T n) { char data[32] = {}; - if (T(0.1) != T(0)) { + if (std::is_floating_point::value) { // float snprintf(data, sizeof(data), "%g", static_cast(n)); - } else if (T(-1) > T(0)) { + } else if (std::is_unsigned::value) { // unsigned snprintf(data, sizeof(data), "%llu", static_cast(n)); } else { @@ -90,6 +123,9 @@ std::string ToString(T n) { return data; } +#define JXL_JOIN(x, y) JXL_DO_JOIN(x, y) +#define JXL_DO_JOIN(x, y) x##y + } // namespace jxl #endif // LIB_JXL_BASE_COMMON_H_ diff --git a/third_party/jpeg-xl/lib/jxl/base/exif.h b/third_party/jpeg-xl/lib/jxl/base/exif.h index 2caafddc04..a3574a16ff 100644 --- a/third_party/jpeg-xl/lib/jxl/base/exif.h +++ b/third_party/jpeg-xl/lib/jxl/base/exif.h @@ -79,7 +79,6 @@ JXL_INLINE void InterpretExif(const std::vector& exif, uint32_t count = (bigendian ? LoadBE32(t) : LoadLE32(t)); t += 4; uint16_t value = (bigendian ? LoadBE16(t) : LoadLE16(t)); - t += 4; if (type == 3 && count == 1 && value >= 1 && value <= 8) { *orientation = static_cast(value); } diff --git a/third_party/jpeg-xl/lib/jxl/base/float.h b/third_party/jpeg-xl/lib/jxl/base/float.h index 00e112bb34..0f5b3b1f3a 100644 --- a/third_party/jpeg-xl/lib/jxl/base/float.h +++ b/third_party/jpeg-xl/lib/jxl/base/float.h @@ -17,9 +17,9 @@ namespace jxl { -namespace { +namespace detail { // Based on highway scalar implementation, for testing -float LoadFloat16(uint16_t bits16) { +static JXL_INLINE float LoadFloat16(uint16_t bits16) { const uint32_t sign = bits16 >> 15; const uint32_t biased_exp = (bits16 >> 10) & 0x1F; const uint32_t mantissa = bits16 & 0x3FF; @@ -40,7 +40,7 @@ float LoadFloat16(uint16_t bits16) { memcpy(&result, &bits32, 4); return result; } -} // namespace +} // namespace detail template static Status JXL_INLINE LoadFloatRow(const uint8_t* src, size_t count, @@ -83,11 +83,11 @@ static Status JXL_INLINE LoadFloatRow(const uint8_t* src, size_t count, case JXL_TYPE_FLOAT16: if (little_endian) { for (size_t i = 0; i < count; ++i) { - callback(i, LoadFloat16(LoadLE16(src + stride * i))); + callback(i, detail::LoadFloat16(LoadLE16(src + stride * i))); } } else { for (size_t i = 0; i < count; ++i) { - callback(i, LoadFloat16(LoadBE16(src + stride * i))); + callback(i, detail::LoadFloat16(LoadBE16(src + stride * i))); } } return true; diff --git a/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h b/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h index 1a969bd4f0..cde6a64b1e 100644 --- a/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h +++ b/third_party/jpeg-xl/lib/jxl/base/matrix_ops.h @@ -8,6 +8,7 @@ // 3x3 matrix operations. +#include #include // abs #include @@ -15,66 +16,67 @@ namespace jxl { +typedef std::array Vector3; +typedef std::array Vector3d; +typedef std::array Matrix3x3; +typedef std::array Matrix3x3d; + // Computes C = A * B, where A, B, C are 3x3 matrices. -template -void Mul3x3Matrix(const T* a, const T* b, T* c) { - alignas(16) T temp[3]; // For transposed column +template +void Mul3x3Matrix(const Matrix& a, const Matrix& b, Matrix& c) { for (size_t x = 0; x < 3; x++) { - for (size_t z = 0; z < 3; z++) { - temp[z] = b[z * 3 + x]; - } + alignas(16) Vector3d temp{b[0][x], b[1][x], b[2][x]}; // transpose for (size_t y = 0; y < 3; y++) { - double e = 0; - for (size_t z = 0; z < 3; z++) { - e += a[y * 3 + z] * temp[z]; - } - c[y * 3 + x] = e; + c[y][x] = a[y][0] * temp[0] + a[y][1] * temp[1] + a[y][2] * temp[2]; } } } // Computes C = A * B, where A is 3x3 matrix and B is vector. -template -void Mul3x3Vector(const T* a, const T* b, T* c) { +template +void Mul3x3Vector(const Matrix& a, const Vector& b, Vector& c) { for (size_t y = 0; y < 3; y++) { double e = 0; for (size_t x = 0; x < 3; x++) { - e += a[y * 3 + x] * b[x]; + e += a[y][x] * b[x]; } c[y] = e; } } // Inverts a 3x3 matrix in place. -template -Status Inv3x3Matrix(T* matrix) { +template +Status Inv3x3Matrix(Matrix& matrix) { // Intermediate computation is done in double precision. - double temp[9]; - temp[0] = static_cast(matrix[4]) * matrix[8] - - static_cast(matrix[5]) * matrix[7]; - temp[1] = static_cast(matrix[2]) * matrix[7] - - static_cast(matrix[1]) * matrix[8]; - temp[2] = static_cast(matrix[1]) * matrix[5] - - static_cast(matrix[2]) * matrix[4]; - temp[3] = static_cast(matrix[5]) * matrix[6] - - static_cast(matrix[3]) * matrix[8]; - temp[4] = static_cast(matrix[0]) * matrix[8] - - static_cast(matrix[2]) * matrix[6]; - temp[5] = static_cast(matrix[2]) * matrix[3] - - static_cast(matrix[0]) * matrix[5]; - temp[6] = static_cast(matrix[3]) * matrix[7] - - static_cast(matrix[4]) * matrix[6]; - temp[7] = static_cast(matrix[1]) * matrix[6] - - static_cast(matrix[0]) * matrix[7]; - temp[8] = static_cast(matrix[0]) * matrix[4] - - static_cast(matrix[1]) * matrix[3]; - double det = matrix[0] * temp[0] + matrix[1] * temp[3] + matrix[2] * temp[6]; + Matrix3x3d temp; + temp[0][0] = static_cast(matrix[1][1]) * matrix[2][2] - + static_cast(matrix[1][2]) * matrix[2][1]; + temp[0][1] = static_cast(matrix[0][2]) * matrix[2][1] - + static_cast(matrix[0][1]) * matrix[2][2]; + temp[0][2] = static_cast(matrix[0][1]) * matrix[1][2] - + static_cast(matrix[0][2]) * matrix[1][1]; + temp[1][0] = static_cast(matrix[1][2]) * matrix[2][0] - + static_cast(matrix[1][0]) * matrix[2][2]; + temp[1][1] = static_cast(matrix[0][0]) * matrix[2][2] - + static_cast(matrix[0][2]) * matrix[2][0]; + temp[1][2] = static_cast(matrix[0][2]) * matrix[1][0] - + static_cast(matrix[0][0]) * matrix[1][2]; + temp[2][0] = static_cast(matrix[1][0]) * matrix[2][1] - + static_cast(matrix[1][1]) * matrix[2][0]; + temp[2][1] = static_cast(matrix[0][1]) * matrix[2][0] - + static_cast(matrix[0][0]) * matrix[2][1]; + temp[2][2] = static_cast(matrix[0][0]) * matrix[1][1] - + static_cast(matrix[0][1]) * matrix[1][0]; + double det = matrix[0][0] * temp[0][0] + matrix[0][1] * temp[1][0] + + matrix[0][2] * temp[2][0]; if (std::abs(det) < 1e-10) { return JXL_FAILURE("Matrix determinant is too close to 0"); } double idet = 1.0 / det; - for (size_t i = 0; i < 9; i++) { - matrix[i] = temp[i] * idet; + for (size_t j = 0; j < 3; j++) { + for (size_t i = 0; i < 3; i++) { + matrix[j][i] = temp[j][i] * idet; + } } return true; } diff --git a/third_party/jpeg-xl/lib/jxl/base/override.h b/third_party/jpeg-xl/lib/jxl/base/override.h index 1f8b657974..da070e6e62 100644 --- a/third_party/jpeg-xl/lib/jxl/base/override.h +++ b/third_party/jpeg-xl/lib/jxl/base/override.h @@ -6,13 +6,15 @@ #ifndef LIB_JXL_BASE_OVERRIDE_H_ #define LIB_JXL_BASE_OVERRIDE_H_ +#include + // 'Trool' for command line arguments: force enable/disable, or use default. namespace jxl { // No effect if kDefault, otherwise forces a feature (typically a FrameHeader // flag) on or off. -enum class Override : int { kOn = 1, kOff = 0, kDefault = -1 }; +enum class Override : int8_t { kOn = 1, kOff = 0, kDefault = -1 }; static inline Override OverrideFromBool(bool flag) { return flag ? Override::kOn : Override::kOff; diff --git a/third_party/jpeg-xl/lib/jxl/base/rational_polynomial-inl.h b/third_party/jpeg-xl/lib/jxl/base/rational_polynomial-inl.h index e073937675..7a89c0bac1 100644 --- a/third_party/jpeg-xl/lib/jxl/base/rational_polynomial-inl.h +++ b/third_party/jpeg-xl/lib/jxl/base/rational_polynomial-inl.h @@ -13,6 +13,7 @@ #define LIB_JXL_BASE_RATIONAL_POLYNOMIAL_INL_H_ #endif +#include #include #include @@ -42,7 +43,7 @@ struct FastDivision { } V operator()(const V n, const V d) const { -#if 1 // Faster on SKX +#if JXL_TRUE // Faster on SKX return Div(n, d); #else return n * ReciprocalNR(d); diff --git a/third_party/jpeg-xl/lib/jxl/base/scope_guard.h b/third_party/jpeg-xl/lib/jxl/base/scope_guard.h index a18a44cb79..f060c5bc1d 100644 --- a/third_party/jpeg-xl/lib/jxl/base/scope_guard.h +++ b/third_party/jpeg-xl/lib/jxl/base/scope_guard.h @@ -24,8 +24,8 @@ class ScopeGuard { } template - explicit ScopeGuard(CallbackParam &&callback) - : callback_(std::forward(callback)), armed_(true) {} + ScopeGuard(CallbackParam &&callback, bool armed) + : callback_(std::forward(callback)), armed_(armed) {} ~ScopeGuard() { if (armed_) callback_(); @@ -40,7 +40,7 @@ class ScopeGuard { template ScopeGuard MakeScopeGuard(Callback &&callback) { - return ScopeGuard{std::forward(callback)}; + return ScopeGuard{std::forward(callback), true}; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/base/span.h b/third_party/jpeg-xl/lib/jxl/base/span.h index dc1c781b9d..ba09d62316 100644 --- a/third_party/jpeg-xl/lib/jxl/base/span.h +++ b/third_party/jpeg-xl/lib/jxl/base/span.h @@ -64,8 +64,8 @@ class Span { // NCT == non-const-T; compiler will complain if NCT is not compatible with T. template - void AppendTo(std::vector* dst) const { - dst->insert(dst->end(), begin(), end()); + void AppendTo(std::vector& dst) const { + dst.insert(dst.end(), begin(), end()); } private: diff --git a/third_party/jpeg-xl/lib/jxl/base/status.h b/third_party/jpeg-xl/lib/jxl/base/status.h index b33bd64fc3..2e88ba68ae 100644 --- a/third_party/jpeg-xl/lib/jxl/base/status.h +++ b/third_party/jpeg-xl/lib/jxl/base/status.h @@ -16,6 +16,7 @@ #include #include +#include "lib/jxl/base/common.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/sanitizer_definitions.h" @@ -442,7 +443,7 @@ class JXL_MUST_USE_RESULT StatusOr { #define JXL_ASSIGN_OR_RETURN(lhs, statusor) \ PRIVATE_JXL_ASSIGN_OR_RETURN_IMPL( \ - assign_or_return_temporary_variable##__LINE__, lhs, statusor) + JXL_JOIN(assign_or_return_temporary_variable, __LINE__), lhs, statusor) // NOLINTBEGIN(bugprone-macro-parentheses) #define PRIVATE_JXL_ASSIGN_OR_RETURN_IMPL(name, lhs, statusor) \ @@ -451,6 +452,18 @@ class JXL_MUST_USE_RESULT StatusOr { lhs = std::move(name).value(); // NOLINTEND(bugprone-macro-parentheses) +// NB: do not use outside of tests / tools!!! +#define JXL_ASSIGN_OR_DIE(lhs, statusor) \ + PRIVATE_JXL_ASSIGN_OR_DIE_IMPL( \ + JXL_JOIN(assign_or_die_temporary_variable, __LINE__), lhs, statusor) + +// NOLINTBEGIN(bugprone-macro-parentheses) +#define PRIVATE_JXL_ASSIGN_OR_DIE_IMPL(name, lhs, statusor) \ + auto name = statusor; \ + if (!name.ok()) jxl::Abort(); \ + lhs = std::move(name).value(); +// NOLINTEND(bugprone-macro-parentheses) + } // namespace jxl #endif // LIB_JXL_BASE_STATUS_H_ diff --git a/third_party/jpeg-xl/lib/jxl/bits_test.cc b/third_party/jpeg-xl/lib/jxl/bits_test.cc index bd7aa548c8..45db8c0d6e 100644 --- a/third_party/jpeg-xl/lib/jxl/bits_test.cc +++ b/third_party/jpeg-xl/lib/jxl/bits_test.cc @@ -38,7 +38,8 @@ TEST(BitsTest, TestFloorLog2) { const size_t expected[7] = {0, 1, 1, 2, 2, 2, 2}; for (uint32_t i = 1; i <= 7; ++i) { EXPECT_EQ(expected[i - 1], FloorLog2Nonzero(i)) << " " << i; - EXPECT_EQ(expected[i - 1], FloorLog2Nonzero(uint64_t(i))) << " " << i; + EXPECT_EQ(expected[i - 1], FloorLog2Nonzero(static_cast(i))) + << " " << i; } EXPECT_EQ(11u, FloorLog2Nonzero(0x00000fffu)); // 4095 @@ -63,7 +64,8 @@ TEST(BitsTest, TestCeilLog2) { const size_t expected[7] = {0, 1, 2, 2, 3, 3, 3}; for (uint32_t i = 1; i <= 7; ++i) { EXPECT_EQ(expected[i - 1], CeilLog2Nonzero(i)) << " " << i; - EXPECT_EQ(expected[i - 1], CeilLog2Nonzero(uint64_t(i))) << " " << i; + EXPECT_EQ(expected[i - 1], CeilLog2Nonzero(static_cast(i))) + << " " << i; } EXPECT_EQ(12u, CeilLog2Nonzero(0x00000fffu)); // 4095 diff --git a/third_party/jpeg-xl/lib/jxl/blending.cc b/third_party/jpeg-xl/lib/jxl/blending.cc index ccb168ee45..7575ec6e4a 100644 --- a/third_party/jpeg-xl/lib/jxl/blending.cc +++ b/third_party/jpeg-xl/lib/jxl/blending.cc @@ -6,7 +6,6 @@ #include "lib/jxl/blending.h" #include "lib/jxl/alpha.h" -#include "lib/jxl/image_ops.h" namespace jxl { @@ -29,11 +28,11 @@ bool NeedsBlending(const FrameHeader& frame_header) { return true; } -void PerformBlending(const float* const* bg, const float* const* fg, - float* const* out, size_t x0, size_t xsize, - const PatchBlending& color_blending, - const PatchBlending* ec_blending, - const std::vector& extra_channel_info) { +Status PerformBlending( + const float* const* bg, const float* const* fg, float* const* out, + size_t x0, size_t xsize, const PatchBlending& color_blending, + const PatchBlending* ec_blending, + const std::vector& extra_channel_info) { bool has_alpha = false; size_t num_ec = extra_channel_info.size(); for (size_t i = 0; i < num_ec; i++) { @@ -42,7 +41,7 @@ void PerformBlending(const float* const* bg, const float* const* fg, break; } } - ImageF tmp(xsize, 3 + num_ec); + JXL_ASSIGN_OR_RETURN(ImageF tmp, ImageF::Create(xsize, 3 + num_ec)); // Blend extra channels first so that we use the pre-blending alpha. for (size_t i = 0; i < num_ec; i++) { if (ec_blending[i].mode == PatchBlendMode::kAdd) { @@ -146,6 +145,7 @@ void PerformBlending(const float* const* bg, const float* const* fg, for (size_t i = 0; i < 3 + num_ec; i++) { if (xsize != 0) memcpy(out[i] + x0, tmp.Row(i), xsize * sizeof(**out)); } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/blending.h b/third_party/jpeg-xl/lib/jxl/blending.h index 3f23297f1d..94bead8dd6 100644 --- a/third_party/jpeg-xl/lib/jxl/blending.h +++ b/third_party/jpeg-xl/lib/jxl/blending.h @@ -16,11 +16,11 @@ namespace jxl { bool NeedsBlending(const FrameHeader& frame_header); -void PerformBlending(const float* const* bg, const float* const* fg, - float* const* out, size_t x0, size_t xsize, - const PatchBlending& color_blending, - const PatchBlending* ec_blending, - const std::vector& extra_channel_info); +Status PerformBlending(const float* const* bg, const float* const* fg, + float* const* out, size_t x0, size_t xsize, + const PatchBlending& color_blending, + const PatchBlending* ec_blending, + const std::vector& extra_channel_info); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/blending_test.cc b/third_party/jpeg-xl/lib/jxl/blending_test.cc index c34ab5c7ca..c363358592 100644 --- a/third_party/jpeg-xl/lib/jxl/blending_test.cc +++ b/third_party/jpeg-xl/lib/jxl/blending_test.cc @@ -20,8 +20,6 @@ namespace jxl { namespace { -using ::testing::SizeIs; - TEST(BlendingTest, Crops) { const std::vector compressed = jxl::test::ReadTestData("jxl/blending/cropped_traffic_light.jxl"); @@ -30,7 +28,7 @@ TEST(BlendingTest, Crops) { extras::PackedPixelFile decoded; ASSERT_TRUE(DecodeImageJXL(compressed.data(), compressed.size(), dparams, /*decoded_bytes=*/nullptr, &decoded)); - ASSERT_THAT(decoded.frames, SizeIs(4)); + ASSERT_EQ(decoded.frames.size(), 4); int i = 0; for (auto&& decoded_frame : decoded.frames) { @@ -40,8 +38,10 @@ TEST(BlendingTest, Crops) { jxl::test::ReadTestData(filename.str()); extras::PackedPixelFile decoded_frame_ppf; decoded_frame_ppf.info = decoded.info; - decoded_frame_ppf.icc = decoded.icc; + decoded_frame_ppf.primary_color_representation = + decoded.primary_color_representation; decoded_frame_ppf.color_encoding = decoded.color_encoding; + decoded_frame_ppf.icc = decoded.icc; decoded_frame_ppf.extra_channels_info = decoded.extra_channels_info; decoded_frame_ppf.frames.emplace_back(std::move(decoded_frame)); extras::PackedPixelFile expected_frame_ppf; diff --git a/third_party/jpeg-xl/lib/jxl/box_content_decoder.cc b/third_party/jpeg-xl/lib/jxl/box_content_decoder.cc index c4cba3a31a..c7d87f4ca0 100644 --- a/third_party/jpeg-xl/lib/jxl/box_content_decoder.cc +++ b/third_party/jpeg-xl/lib/jxl/box_content_decoder.cc @@ -9,7 +9,7 @@ namespace jxl { -JxlBoxContentDecoder::JxlBoxContentDecoder() {} +JxlBoxContentDecoder::JxlBoxContentDecoder() = default; JxlBoxContentDecoder::~JxlBoxContentDecoder() { if (brotli_dec) { diff --git a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc index 66dde9afb1..2e06d79eba 100644 --- a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc +++ b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc @@ -28,11 +28,12 @@ #include #include -#include #include -#include +#include #include +#include "lib/jxl/image.h" + #undef HWY_TARGET_INCLUDE #define HWY_TARGET_INCLUDE "lib/jxl/butteraugli/butteraugli.cc" #include @@ -222,8 +223,8 @@ void ConvolutionWithTranspose(const ImageF& in, // We retain a special case for 5x5 kernels (even faster than gauss_blur), // optionally use gauss_blur followed by fixup of the borders for large images, // or fall back to the previous truncated FIR followed by a transpose. -void Blur(const ImageF& in, float sigma, const ButteraugliParams& params, - BlurTemp* temp, ImageF* out) { +Status Blur(const ImageF& in, float sigma, const ButteraugliParams& params, + BlurTemp* temp, ImageF* out) { std::vector kernel = ComputeKernel(sigma); // Separable5 does an in-place convolution, so this fast path is not safe if // in aliases out. @@ -241,12 +242,14 @@ void Blur(const ImageF& in, float sigma, const ButteraugliParams& params, {HWY_REP4(w0), HWY_REP4(w1), HWY_REP4(w2)}, }; Separable5(in, Rect(in), weights, /*pool=*/nullptr, out); - return; + return true; } - ImageF* JXL_RESTRICT temp_t = temp->GetTransposed(in); + ImageF* temp_t; + JXL_RETURN_IF_ERROR(temp->GetTransposed(in, &temp_t)); ConvolutionWithTranspose(in, kernel, temp_t); ConvolutionWithTranspose(*temp_t, kernel, out); + return true; } // Allows PaddedMaltaUnit to call either function via overloading. @@ -386,29 +389,32 @@ void Subtract(const ImageF& a, const ImageF& b, ImageF* c) { } } -void SeparateLFAndMF(const ButteraugliParams& params, const Image3F& xyb, - Image3F* lf, Image3F* mf, BlurTemp* blur_temp) { +Status SeparateLFAndMF(const ButteraugliParams& params, const Image3F& xyb, + Image3F* lf, Image3F* mf, BlurTemp* blur_temp) { static const double kSigmaLf = 7.15593339443; for (int i = 0; i < 3; ++i) { // Extract lf ... - Blur(xyb.Plane(i), kSigmaLf, params, blur_temp, &lf->Plane(i)); + JXL_RETURN_IF_ERROR( + Blur(xyb.Plane(i), kSigmaLf, params, blur_temp, &lf->Plane(i))); // ... and keep everything else in mf. Subtract(xyb.Plane(i), lf->Plane(i), &mf->Plane(i)); } XybLowFreqToVals(lf); + return true; } -void SeparateMFAndHF(const ButteraugliParams& params, Image3F* mf, ImageF* hf, - BlurTemp* blur_temp) { +Status SeparateMFAndHF(const ButteraugliParams& params, Image3F* mf, ImageF* hf, + BlurTemp* blur_temp) { const HWY_FULL(float) d; static const double kSigmaHf = 3.22489901262; const size_t xsize = mf->xsize(); const size_t ysize = mf->ysize(); - hf[0] = ImageF(xsize, ysize); - hf[1] = ImageF(xsize, ysize); + JXL_ASSIGN_OR_RETURN(hf[0], ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(hf[1], ImageF::Create(xsize, ysize)); for (int i = 0; i < 3; ++i) { if (i == 2) { - Blur(mf->Plane(i), kSigmaHf, params, blur_temp, &mf->Plane(i)); + JXL_RETURN_IF_ERROR( + Blur(mf->Plane(i), kSigmaHf, params, blur_temp, &mf->Plane(i))); break; } for (size_t y = 0; y < ysize; ++y) { @@ -418,7 +424,8 @@ void SeparateMFAndHF(const ButteraugliParams& params, Image3F* mf, ImageF* hf, Store(Load(d, row_mf + x), d, row_hf + x); } } - Blur(mf->Plane(i), kSigmaHf, params, blur_temp, &mf->Plane(i)); + JXL_RETURN_IF_ERROR( + Blur(mf->Plane(i), kSigmaHf, params, blur_temp, &mf->Plane(i))); static const double kRemoveMfRange = 0.29; static const double kAddMfRange = 0.1; if (i == 0) { @@ -450,16 +457,17 @@ void SeparateMFAndHF(const ButteraugliParams& params, Image3F* mf, ImageF* hf, } // Suppress red-green by intensity change in the high freq channels. SuppressXByY(hf[1], &hf[0]); + return true; } -void SeparateHFAndUHF(const ButteraugliParams& params, ImageF* hf, ImageF* uhf, - BlurTemp* blur_temp) { +Status SeparateHFAndUHF(const ButteraugliParams& params, ImageF* hf, + ImageF* uhf, BlurTemp* blur_temp) { const HWY_FULL(float) d; const size_t xsize = hf[0].xsize(); const size_t ysize = hf[0].ysize(); static const double kSigmaUhf = 1.56416327805; - uhf[0] = ImageF(xsize, ysize); - uhf[1] = ImageF(xsize, ysize); + JXL_ASSIGN_OR_RETURN(uhf[0], ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(uhf[1], ImageF::Create(xsize, ysize)); for (int i = 0; i < 2; ++i) { // Divide hf into hf and uhf. for (size_t y = 0; y < ysize; ++y) { @@ -469,7 +477,7 @@ void SeparateHFAndUHF(const ButteraugliParams& params, ImageF* hf, ImageF* uhf, row_uhf[x] = row_hf[x]; } } - Blur(hf[i], kSigmaUhf, params, blur_temp, &hf[i]); + JXL_RETURN_IF_ERROR(Blur(hf[i], kSigmaUhf, params, blur_temp, &hf[i])); static const double kRemoveHfRange = 1.5; static const double kAddHfRange = 0.132; static const double kRemoveUhfRange = 0.04; @@ -510,6 +518,7 @@ void SeparateHFAndUHF(const ButteraugliParams& params, ImageF* hf, ImageF* uhf, } } } + return true; } void DeallocateHFAndUHF(ImageF* hf, ImageF* uhf) { @@ -519,15 +528,16 @@ void DeallocateHFAndUHF(ImageF* hf, ImageF* uhf) { } } -static void SeparateFrequencies(size_t xsize, size_t ysize, - const ButteraugliParams& params, - BlurTemp* blur_temp, const Image3F& xyb, - PsychoImage& ps) { - ps.lf = Image3F(xyb.xsize(), xyb.ysize()); - ps.mf = Image3F(xyb.xsize(), xyb.ysize()); - SeparateLFAndMF(params, xyb, &ps.lf, &ps.mf, blur_temp); - SeparateMFAndHF(params, &ps.mf, &ps.hf[0], blur_temp); - SeparateHFAndUHF(params, &ps.hf[0], &ps.uhf[0], blur_temp); +Status SeparateFrequencies(size_t xsize, size_t ysize, + const ButteraugliParams& params, BlurTemp* blur_temp, + const Image3F& xyb, PsychoImage& ps) { + JXL_ASSIGN_OR_RETURN(ps.lf, Image3F::Create(xyb.xsize(), xyb.ysize())); + JXL_ASSIGN_OR_RETURN(ps.mf, Image3F::Create(xyb.xsize(), xyb.ysize())); + JXL_RETURN_IF_ERROR(SeparateLFAndMF(params, xyb, &ps.lf, &ps.mf, blur_temp)); + JXL_RETURN_IF_ERROR(SeparateMFAndHF(params, &ps.mf, &ps.hf[0], blur_temp)); + JXL_RETURN_IF_ERROR( + SeparateHFAndUHF(params, &ps.hf[0], &ps.uhf[0], blur_temp)); + return true; } namespace { @@ -1024,7 +1034,7 @@ static void MaltaDiffMapT(const Tag tag, const ImageF& lum0, const ImageF& lum1, } const HWY_FULL(float) df; - const size_t aligned_x = std::max(size_t(4), Lanes(df)); + const size_t aligned_x = std::max(static_cast(4), Lanes(df)); const intptr_t stride = diffs->PixelsPerRow(); // Middle @@ -1097,7 +1107,7 @@ void CombineChannelsForMasking(const ImageF* hf, const ImageF* uhf, float xdiff = (row_x_uhf[x] + row_x_hf[x]) * muls[0]; float ydiff = row_y_uhf[x] * muls[1] + row_y_hf[x] * muls[2]; row[x] = xdiff * xdiff + ydiff * ydiff; - row[x] = sqrt(row[x]); + row[x] = std::sqrt(row[x]); } } } @@ -1106,13 +1116,13 @@ void DiffPrecompute(const ImageF& xyb, float mul, float bias_arg, ImageF* out) { const size_t xsize = xyb.xsize(); const size_t ysize = xyb.ysize(); const float bias = mul * bias_arg; - const float sqrt_bias = sqrt(bias); + const float sqrt_bias = std::sqrt(bias); for (size_t y = 0; y < ysize; ++y) { const float* BUTTERAUGLI_RESTRICT row_in = xyb.Row(y); float* BUTTERAUGLI_RESTRICT row_out = out->Row(y); for (size_t x = 0; x < xsize; ++x) { // kBias makes sqrt behave more linearly. - row_out[x] = sqrt(mul * std::abs(row_in[x]) + bias) - sqrt_bias; + row_out[x] = std::sqrt(mul * std::abs(row_in[x]) + bias) - sqrt_bias; } } } @@ -1188,25 +1198,25 @@ void FuzzyErosion(const ImageF& from, ImageF* to) { // Compute values of local frequency and dc masking based on the activity // in the two images. img_diff_ac may be null. -void Mask(const ImageF& mask0, const ImageF& mask1, - const ButteraugliParams& params, BlurTemp* blur_temp, - ImageF* BUTTERAUGLI_RESTRICT mask, - ImageF* BUTTERAUGLI_RESTRICT diff_ac) { +Status Mask(const ImageF& mask0, const ImageF& mask1, + const ButteraugliParams& params, BlurTemp* blur_temp, + ImageF* BUTTERAUGLI_RESTRICT mask, + ImageF* BUTTERAUGLI_RESTRICT diff_ac) { const size_t xsize = mask0.xsize(); const size_t ysize = mask0.ysize(); - *mask = ImageF(xsize, ysize); + JXL_ASSIGN_OR_RETURN(*mask, ImageF::Create(xsize, ysize)); static const float kMul = 6.19424080439; static const float kBias = 12.61050594197; static const float kRadius = 2.7; - ImageF diff0(xsize, ysize); - ImageF diff1(xsize, ysize); - ImageF blurred0(xsize, ysize); - ImageF blurred1(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF diff0, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(ImageF diff1, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(ImageF blurred0, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(ImageF blurred1, ImageF::Create(xsize, ysize)); DiffPrecompute(mask0, kMul, kBias, &diff0); DiffPrecompute(mask1, kMul, kBias, &diff1); - Blur(diff0, kRadius, params, blur_temp, &blurred0); + JXL_RETURN_IF_ERROR(Blur(diff0, kRadius, params, blur_temp, &blurred0)); FuzzyErosion(blurred0, &diff0); - Blur(diff1, kRadius, params, blur_temp, &blurred1); + JXL_RETURN_IF_ERROR(Blur(diff1, kRadius, params, blur_temp, &blurred1)); for (size_t y = 0; y < ysize; ++y) { for (size_t x = 0; x < xsize; ++x) { mask->Row(y)[x] = diff0.Row(y)[x]; @@ -1217,19 +1227,21 @@ void Mask(const ImageF& mask0, const ImageF& mask1, } } } + return true; } // `diff_ac` may be null. -void MaskPsychoImage(const PsychoImage& pi0, const PsychoImage& pi1, - const size_t xsize, const size_t ysize, - const ButteraugliParams& params, BlurTemp* blur_temp, - ImageF* BUTTERAUGLI_RESTRICT mask, - ImageF* BUTTERAUGLI_RESTRICT diff_ac) { - ImageF mask0(xsize, ysize); - ImageF mask1(xsize, ysize); +Status MaskPsychoImage(const PsychoImage& pi0, const PsychoImage& pi1, + const size_t xsize, const size_t ysize, + const ButteraugliParams& params, BlurTemp* blur_temp, + ImageF* BUTTERAUGLI_RESTRICT mask, + ImageF* BUTTERAUGLI_RESTRICT diff_ac) { + JXL_ASSIGN_OR_RETURN(ImageF mask0, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(ImageF mask1, ImageF::Create(xsize, ysize)); CombineChannelsForMasking(&pi0.hf[0], &pi0.uhf[0], &mask0); CombineChannelsForMasking(&pi1.hf[0], &pi1.uhf[0], &mask1); - Mask(mask0, mask1, params, blur_temp, mask, diff_ac); + JXL_RETURN_IF_ERROR(Mask(mask0, mask1, params, blur_temp, mask, diff_ac)); + return true; } double MaskY(double delta) { @@ -1275,8 +1287,8 @@ void CombineChannelsToDiffmap(const ImageF& mask, const Image3F& block_diff_dc, } diff_ac[0] *= xmul; diff_dc[0] *= xmul; - row_out[x] = - sqrt(MaskColor(diff_dc, dc_maskval) + MaskColor(diff_ac, maskval)); + row_out[x] = std::sqrt(MaskColor(diff_dc, dc_maskval) + + MaskColor(diff_ac, maskval)); } } } @@ -1430,12 +1442,15 @@ BUTTERAUGLI_INLINE void OpsinAbsorbance(const DF df, const V& in0, const V& in1, } // `blurred` is a temporary image used inside this function and not returned. -void OpsinDynamicsImage(const Image3F& rgb, const ButteraugliParams& params, - Image3F* blurred, BlurTemp* blur_temp, Image3F* xyb) { +Status OpsinDynamicsImage(const Image3F& rgb, const ButteraugliParams& params, + Image3F* blurred, BlurTemp* blur_temp, Image3F* xyb) { const double kSigma = 1.2; - Blur(rgb.Plane(0), kSigma, params, blur_temp, &blurred->Plane(0)); - Blur(rgb.Plane(1), kSigma, params, blur_temp, &blurred->Plane(1)); - Blur(rgb.Plane(2), kSigma, params, blur_temp, &blurred->Plane(2)); + JXL_RETURN_IF_ERROR( + Blur(rgb.Plane(0), kSigma, params, blur_temp, &blurred->Plane(0))); + JXL_RETURN_IF_ERROR( + Blur(rgb.Plane(1), kSigma, params, blur_temp, &blurred->Plane(1))); + JXL_RETURN_IF_ERROR( + Blur(rgb.Plane(2), kSigma, params, blur_temp, &blurred->Plane(2))); const HWY_FULL(float) df; const auto intensity_target_multiplier = Set(df, params.intensity_target); for (size_t y = 0; y < rgb.ysize(); ++y) { @@ -1497,31 +1512,36 @@ void OpsinDynamicsImage(const Image3F& rgb, const ButteraugliParams& params, Store(cur_mixed2, df, row_out_b + x); } } + return true; } -void ButteraugliDiffmapInPlace(Image3F& image0, Image3F& image1, - const ButteraugliParams& params, - ImageF& diffmap) { +Status ButteraugliDiffmapInPlace(Image3F& image0, Image3F& image1, + const ButteraugliParams& params, + ImageF& diffmap) { // image0 and image1 are in linear sRGB color space const size_t xsize = image0.xsize(); const size_t ysize = image0.ysize(); BlurTemp blur_temp; { // Convert image0 and image1 to XYB in-place - Image3F temp(xsize, ysize); - OpsinDynamicsImage(image0, params, &temp, &blur_temp, &image0); - OpsinDynamicsImage(image1, params, &temp, &blur_temp, &image1); + JXL_ASSIGN_OR_RETURN(Image3F temp, Image3F::Create(xsize, ysize)); + JXL_RETURN_IF_ERROR( + OpsinDynamicsImage(image0, params, &temp, &blur_temp, &image0)); + JXL_RETURN_IF_ERROR( + OpsinDynamicsImage(image1, params, &temp, &blur_temp, &image1)); } // image0 and image1 are in XYB color space - ImageF block_diff_dc(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF block_diff_dc, ImageF::Create(xsize, ysize)); ZeroFillImage(&block_diff_dc); { // separate out LF components from image0 and image1 and compute the dc // diff image from them - Image3F lf0 = Image3F(xsize, ysize); - Image3F lf1 = Image3F(xsize, ysize); - SeparateLFAndMF(params, image0, &lf0, &image0, &blur_temp); - SeparateLFAndMF(params, image1, &lf1, &image1, &blur_temp); + JXL_ASSIGN_OR_RETURN(Image3F lf0, Image3F::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(Image3F lf1, Image3F::Create(xsize, ysize)); + JXL_RETURN_IF_ERROR( + SeparateLFAndMF(params, image0, &lf0, &image0, &blur_temp)); + JXL_RETURN_IF_ERROR( + SeparateLFAndMF(params, image1, &lf1, &image1, &blur_temp)); for (size_t c = 0; c < 3; ++c) { L2Diff(lf0.Plane(c), lf1.Plane(c), wmul[6 + c], &block_diff_dc); } @@ -1529,15 +1549,15 @@ void ButteraugliDiffmapInPlace(Image3F& image0, Image3F& image1, // image0 and image1 are MF residuals (before blurring) in XYB color space ImageF hf0[2]; ImageF hf1[2]; - SeparateMFAndHF(params, &image0, &hf0[0], &blur_temp); - SeparateMFAndHF(params, &image1, &hf1[0], &blur_temp); + JXL_RETURN_IF_ERROR(SeparateMFAndHF(params, &image0, &hf0[0], &blur_temp)); + JXL_RETURN_IF_ERROR(SeparateMFAndHF(params, &image1, &hf1[0], &blur_temp)); // image0 and image1 are MF-images in XYB color space - ImageF block_diff_ac(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF block_diff_ac, ImageF::Create(xsize, ysize)); ZeroFillImage(&block_diff_ac); // start accumulating ac diff image from MF images { - ImageF diffs(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF diffs, ImageF::Create(xsize, ysize)); MaltaDiffMapLF(image0.Plane(1), image1.Plane(1), wMfMalta, wMfMalta, norm1Mf, &diffs, &block_diff_ac); MaltaDiffMapLF(image0.Plane(0), image1.Plane(0), wMfMaltaX, wMfMaltaX, @@ -1553,13 +1573,13 @@ void ButteraugliDiffmapInPlace(Image3F& image0, Image3F& image1, ImageF uhf0[2]; ImageF uhf1[2]; - SeparateHFAndUHF(params, &hf0[0], &uhf0[0], &blur_temp); - SeparateHFAndUHF(params, &hf1[0], &uhf1[0], &blur_temp); + JXL_RETURN_IF_ERROR(SeparateHFAndUHF(params, &hf0[0], &uhf0[0], &blur_temp)); + JXL_RETURN_IF_ERROR(SeparateHFAndUHF(params, &hf1[0], &uhf1[0], &blur_temp)); // continue accumulating ac diff image from HF and UHF images const float hf_asymmetry = params.hf_asymmetry; { - ImageF diffs(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF diffs, ImageF::Create(xsize, ysize)); MaltaDiffMap(uhf0[1], uhf1[1], wUhfMalta * hf_asymmetry, wUhfMalta / hf_asymmetry, norm1Uhf, &diffs, &block_diff_ac); MaltaDiffMap(uhf0[0], uhf1[0], wUhfMaltaX * hf_asymmetry, @@ -1577,19 +1597,20 @@ void ButteraugliDiffmapInPlace(Image3F& image0, Image3F& image1, } // compute mask image from HF and UHF X and Y images - ImageF mask(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF mask, ImageF::Create(xsize, ysize)); { - ImageF mask0(xsize, ysize); - ImageF mask1(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF mask0, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(ImageF mask1, ImageF::Create(xsize, ysize)); CombineChannelsForMasking(&hf0[0], &uhf0[0], &mask0); CombineChannelsForMasking(&hf1[0], &uhf1[0], &mask1); DeallocateHFAndUHF(&hf1[0], &uhf1[0]); DeallocateHFAndUHF(&hf0[0], &uhf0[0]); - Mask(mask0, mask1, params, &blur_temp, &mask, &block_diff_ac); + JXL_RETURN_IF_ERROR( + Mask(mask0, mask1, params, &blur_temp, &mask, &block_diff_ac)); } // compute final diffmap from mask image and ac and dc diff images - diffmap = ImageF(xsize, ysize); + JXL_ASSIGN_OR_RETURN(diffmap, ImageF::Create(xsize, ysize)); for (size_t y = 0; y < ysize; ++y) { const float* row_dc = block_diff_dc.Row(y); const float* row_ac = block_diff_ac.Row(y); @@ -1599,6 +1620,7 @@ void ButteraugliDiffmapInPlace(Image3F& image0, Image3F& image1, row_out[x] = sqrt(row_dc[x] * MaskDcY(val) + row_ac[x] * MaskY(val)); } } + return true; } // NOLINTNEXTLINE(google-readability-namespace-comments) @@ -1669,10 +1691,10 @@ static inline void CheckImage(const ImageF& image, const char* name) { // Calculate a 2x2 subsampled image for purposes of recursive butteraugli at // multiresolution. -static Image3F SubSample2x(const Image3F& in) { +static StatusOr SubSample2x(const Image3F& in) { size_t xs = (in.xsize() + 1) / 2; size_t ys = (in.ysize() + 1) / 2; - Image3F retval(xs, ys); + JXL_ASSIGN_OR_RETURN(Image3F retval, Image3F::Create(xs, ys)); for (size_t c = 0; c < 3; ++c) { for (size_t y = 0; y < ys; ++y) { for (size_t x = 0; x < xs; ++x) { @@ -1724,69 +1746,86 @@ Image3F* ButteraugliComparator::Temp() const { void ButteraugliComparator::ReleaseTemp() const { temp_in_use_.clear(); } -ButteraugliComparator::ButteraugliComparator(const Image3F& rgb0, +ButteraugliComparator::ButteraugliComparator(size_t xsize, size_t ysize, const ButteraugliParams& params) - : xsize_(rgb0.xsize()), - ysize_(rgb0.ysize()), - params_(params), - temp_(xsize_, ysize_) { - if (xsize_ < 8 || ysize_ < 8) { - return; + : xsize_(xsize), ysize_(ysize), params_(params) {} + +StatusOr> ButteraugliComparator::Make( + const Image3F& rgb0, const ButteraugliParams& params) { + size_t xsize = rgb0.xsize(); + size_t ysize = rgb0.ysize(); + std::unique_ptr result = + std::unique_ptr( + new ButteraugliComparator(xsize, ysize, params)); + JXL_ASSIGN_OR_RETURN(result->temp_, Image3F::Create(xsize, ysize)); + + if (xsize < 8 || ysize < 8) { + return result; } - Image3F xyb0(xsize_, ysize_); - HWY_DYNAMIC_DISPATCH(OpsinDynamicsImage) - (rgb0, params, Temp(), &blur_temp_, &xyb0); - ReleaseTemp(); - HWY_DYNAMIC_DISPATCH(SeparateFrequencies) - (xsize_, ysize_, params_, &blur_temp_, xyb0, pi0_); + JXL_ASSIGN_OR_RETURN(Image3F xyb0, Image3F::Create(xsize, ysize)); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(OpsinDynamicsImage)( + rgb0, params, result->Temp(), &result->blur_temp_, &xyb0)); + result->ReleaseTemp(); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(SeparateFrequencies)( + xsize, ysize, params, &result->blur_temp_, xyb0, result->pi0_)); // Awful recursive construction of samples of different resolution. // This is an after-thought and possibly somewhat parallel in // functionality with the PsychoImage multi-resolution approach. - sub_.reset(new ButteraugliComparator(SubSample2x(rgb0), params)); + JXL_ASSIGN_OR_RETURN(Image3F subsampledRgb0, SubSample2x(rgb0)); + StatusOr> sub = + ButteraugliComparator::Make(subsampledRgb0, params); + if (!sub.ok()) return sub.status(); + result->sub_ = std::move(sub).value(); + + return result; } -void ButteraugliComparator::Mask(ImageF* BUTTERAUGLI_RESTRICT mask) const { - HWY_DYNAMIC_DISPATCH(MaskPsychoImage) - (pi0_, pi0_, xsize_, ysize_, params_, &blur_temp_, mask, nullptr); +Status ButteraugliComparator::Mask(ImageF* BUTTERAUGLI_RESTRICT mask) const { + return HWY_DYNAMIC_DISPATCH(MaskPsychoImage)( + pi0_, pi0_, xsize_, ysize_, params_, &blur_temp_, mask, nullptr); } -void ButteraugliComparator::Diffmap(const Image3F& rgb1, ImageF& result) const { +Status ButteraugliComparator::Diffmap(const Image3F& rgb1, + ImageF& result) const { if (xsize_ < 8 || ysize_ < 8) { ZeroFillImage(&result); - return; + return true; } - Image3F xyb1(xsize_, ysize_); - HWY_DYNAMIC_DISPATCH(OpsinDynamicsImage) - (rgb1, params_, Temp(), &blur_temp_, &xyb1); + JXL_ASSIGN_OR_RETURN(Image3F xyb1, Image3F::Create(xsize_, ysize_)); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(OpsinDynamicsImage)( + rgb1, params_, Temp(), &blur_temp_, &xyb1)); ReleaseTemp(); - DiffmapOpsinDynamicsImage(xyb1, result); + JXL_RETURN_IF_ERROR(DiffmapOpsinDynamicsImage(xyb1, result)); if (sub_) { if (sub_->xsize_ < 8 || sub_->ysize_ < 8) { - return; + return true; } - Image3F sub_xyb(sub_->xsize_, sub_->ysize_); - HWY_DYNAMIC_DISPATCH(OpsinDynamicsImage) - (SubSample2x(rgb1), params_, sub_->Temp(), &sub_->blur_temp_, &sub_xyb); + JXL_ASSIGN_OR_RETURN(Image3F sub_xyb, + Image3F::Create(sub_->xsize_, sub_->ysize_)); + JXL_ASSIGN_OR_RETURN(Image3F subsampledRgb1, SubSample2x(rgb1)); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(OpsinDynamicsImage)( + subsampledRgb1, params_, sub_->Temp(), &sub_->blur_temp_, &sub_xyb)); sub_->ReleaseTemp(); ImageF subresult; - sub_->DiffmapOpsinDynamicsImage(sub_xyb, subresult); + JXL_RETURN_IF_ERROR(sub_->DiffmapOpsinDynamicsImage(sub_xyb, subresult)); AddSupersampled2x(subresult, 0.5, result); } + return true; } -void ButteraugliComparator::DiffmapOpsinDynamicsImage(const Image3F& xyb1, - ImageF& result) const { +Status ButteraugliComparator::DiffmapOpsinDynamicsImage(const Image3F& xyb1, + ImageF& result) const { if (xsize_ < 8 || ysize_ < 8) { ZeroFillImage(&result); - return; + return true; } PsychoImage pi1; - HWY_DYNAMIC_DISPATCH(SeparateFrequencies) - (xsize_, ysize_, params_, &blur_temp_, xyb1, pi1); - result = ImageF(xsize_, ysize_); - DiffmapPsychoImage(pi1, result); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(SeparateFrequencies)( + xsize_, ysize_, params_, &blur_temp_, xyb1, pi1)); + JXL_ASSIGN_OR_RETURN(result, ImageF::Create(xsize_, ysize_)); + return DiffmapPsychoImage(pi1, result); } namespace { @@ -1809,18 +1848,18 @@ void MaltaDiffMapLF(const ImageF& lum0, const ImageF& lum1, const double w_0gt1, } // namespace -void ButteraugliComparator::DiffmapPsychoImage(const PsychoImage& pi1, - ImageF& diffmap) const { +Status ButteraugliComparator::DiffmapPsychoImage(const PsychoImage& pi1, + ImageF& diffmap) const { if (xsize_ < 8 || ysize_ < 8) { ZeroFillImage(&diffmap); - return; + return true; } const float hf_asymmetry_ = params_.hf_asymmetry; const float xmul_ = params_.xmul; - ImageF diffs(xsize_, ysize_); - Image3F block_diff_ac(xsize_, ysize_); + JXL_ASSIGN_OR_RETURN(ImageF diffs, ImageF::Create(xsize_, ysize_)); + JXL_ASSIGN_OR_RETURN(Image3F block_diff_ac, Image3F::Create(xsize_, ysize_)); ZeroFillImage(&block_diff_ac); MaltaDiffMap(pi0_.uhf[1], pi1.uhf[1], wUhfMalta * hf_asymmetry_, wUhfMalta / hf_asymmetry_, norm1Uhf, &diffs, &block_diff_ac, 1); @@ -1838,7 +1877,7 @@ void ButteraugliComparator::DiffmapPsychoImage(const PsychoImage& pi1, MaltaDiffMapLF(pi0_.mf.Plane(0), pi1.mf.Plane(0), wMfMaltaX, wMfMaltaX, norm1MfX, &diffs, &block_diff_ac, 0); - Image3F block_diff_dc(xsize_, ysize_); + JXL_ASSIGN_OR_RETURN(Image3F block_diff_dc, Image3F::Create(xsize_, ysize_)); for (size_t c = 0; c < 3; ++c) { if (c < 2) { // No blue channel error accumulated at HF. HWY_DYNAMIC_DISPATCH(L2DiffAsymmetric) @@ -1852,12 +1891,13 @@ void ButteraugliComparator::DiffmapPsychoImage(const PsychoImage& pi1, } ImageF mask; - HWY_DYNAMIC_DISPATCH(MaskPsychoImage) - (pi0_, pi1, xsize_, ysize_, params_, &blur_temp_, &mask, - &block_diff_ac.Plane(1)); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(MaskPsychoImage)( + pi0_, pi1, xsize_, ysize_, params_, &blur_temp_, &mask, + &block_diff_ac.Plane(1))); HWY_DYNAMIC_DISPATCH(CombineChannelsToDiffmap) (mask, block_diff_dc, block_diff_ac, xmul_, &diffmap); + return true; } double ButteraugliScoreFromDiffmap(const ImageF& diffmap, @@ -1872,8 +1912,8 @@ double ButteraugliScoreFromDiffmap(const ImageF& diffmap, return retval; } -bool ButteraugliDiffmap(const Image3F& rgb0, const Image3F& rgb1, - double hf_asymmetry, double xmul, ImageF& diffmap) { +Status ButteraugliDiffmap(const Image3F& rgb0, const Image3F& rgb1, + double hf_asymmetry, double xmul, ImageF& diffmap) { ButteraugliParams params; params.hf_asymmetry = hf_asymmetry; params.xmul = xmul; @@ -1893,8 +1933,8 @@ bool ButteraugliDiffmapSmall(const Image3F& rgb0, const Image3F& rgb1, size_t yborder = ysize < kMax ? (kMax - ysize) / 2 : 0; size_t xscaled = std::max(kMax, xsize); size_t yscaled = std::max(kMax, ysize); - Image3F scaled0(xscaled, yscaled); - Image3F scaled1(xscaled, yscaled); + JXL_ASSIGN_OR_RETURN(Image3F scaled0, Image3F::Create(xscaled, yscaled)); + JXL_ASSIGN_OR_RETURN(Image3F scaled1, Image3F::Create(xscaled, yscaled)); for (int i = 0; i < 3; ++i) { for (size_t y = 0; y < yscaled; ++y) { for (size_t x = 0; x < xscaled; ++x) { @@ -1907,7 +1947,7 @@ bool ButteraugliDiffmapSmall(const Image3F& rgb0, const Image3F& rgb1, } ImageF diffmap_scaled; const bool ok = ButteraugliDiffmap(scaled0, scaled1, params, diffmap_scaled); - diffmap = ImageF(xsize, ysize); + JXL_ASSIGN_OR_RETURN(diffmap, ImageF::Create(xsize, ysize)); for (size_t y = 0; y < ysize; ++y) { for (size_t x = 0; x < xsize; ++x) { diffmap.Row(y)[x] = diffmap_scaled.Row(y + yborder)[x + xborder]; @@ -1916,8 +1956,8 @@ bool ButteraugliDiffmapSmall(const Image3F& rgb0, const Image3F& rgb1, return ok; } -bool ButteraugliDiffmap(const Image3F& rgb0, const Image3F& rgb1, - const ButteraugliParams& params, ImageF& diffmap) { +Status ButteraugliDiffmap(const Image3F& rgb0, const Image3F& rgb1, + const ButteraugliParams& params, ImageF& diffmap) { const size_t xsize = rgb0.xsize(); const size_t ysize = rgb0.ysize(); if (xsize < 1 || ysize < 1) { @@ -1930,8 +1970,9 @@ bool ButteraugliDiffmap(const Image3F& rgb0, const Image3F& rgb1, if (xsize < kMax || ysize < kMax) { return ButteraugliDiffmapSmall(rgb0, rgb1, params, diffmap); } - ButteraugliComparator butteraugli(rgb0, params); - butteraugli.Diffmap(rgb1, diffmap); + JXL_ASSIGN_OR_RETURN(std::unique_ptr butteraugli, + ButteraugliComparator::Make(rgb0, params)); + JXL_RETURN_IF_ERROR(butteraugli->Diffmap(rgb1, diffmap)); return true; } @@ -1954,9 +1995,9 @@ bool ButteraugliInterface(const Image3F& rgb0, const Image3F& rgb1, return true; } -bool ButteraugliInterfaceInPlace(Image3F&& rgb0, Image3F&& rgb1, - const ButteraugliParams& params, - ImageF& diffmap, double& diffvalue) { +Status ButteraugliInterfaceInPlace(Image3F&& rgb0, Image3F&& rgb1, + const ButteraugliParams& params, + ImageF& diffmap, double& diffvalue) { const size_t xsize = rgb0.xsize(); const size_t ysize = rgb0.ysize(); if (xsize < 1 || ysize < 1) { @@ -1973,12 +2014,13 @@ bool ButteraugliInterfaceInPlace(Image3F&& rgb0, Image3F&& rgb1, } ImageF subdiffmap; if (xsize >= 15 && ysize >= 15) { - Image3F rgb0_sub = SubSample2x(rgb0); - Image3F rgb1_sub = SubSample2x(rgb1); - HWY_DYNAMIC_DISPATCH(ButteraugliDiffmapInPlace) - (rgb0_sub, rgb1_sub, params, subdiffmap); + JXL_ASSIGN_OR_RETURN(Image3F rgb0_sub, SubSample2x(rgb0)); + JXL_ASSIGN_OR_RETURN(Image3F rgb1_sub, SubSample2x(rgb1)); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(ButteraugliDiffmapInPlace)( + rgb0_sub, rgb1_sub, params, subdiffmap)); } - HWY_DYNAMIC_DISPATCH(ButteraugliDiffmapInPlace)(rgb0, rgb1, params, diffmap); + JXL_RETURN_IF_ERROR(HWY_DYNAMIC_DISPATCH(ButteraugliDiffmapInPlace)( + rgb0, rgb1, params, diffmap)); if (xsize >= 15 && ysize >= 15) { AddSupersampled2x(subdiffmap, 0.5, diffmap); } @@ -2066,9 +2108,11 @@ void ScoreToRgb(double score, double good_threshold, double bad_threshold, } // namespace -Image3F CreateHeatMapImage(const ImageF& distmap, double good_threshold, - double bad_threshold) { - Image3F heatmap(distmap.xsize(), distmap.ysize()); +StatusOr CreateHeatMapImage(const ImageF& distmap, + double good_threshold, + double bad_threshold) { + JXL_ASSIGN_OR_RETURN(Image3F heatmap, + Image3F::Create(distmap.xsize(), distmap.ysize())); for (size_t y = 0; y < distmap.ysize(); ++y) { const float* BUTTERAUGLI_RESTRICT row_distmap = distmap.ConstRow(y); float* BUTTERAUGLI_RESTRICT row_h0 = heatmap.PlaneRow(0, y); diff --git a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.h b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.h index 29130e8768..e0bfd354e1 100644 --- a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.h +++ b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.h @@ -14,12 +14,12 @@ #include #include +#include #include -#include #include "lib/jxl/base/compiler_specific.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/image.h" -#include "lib/jxl/image_ops.h" #define BUTTERAUGLI_ENABLE_CHECKS 0 #define BUTTERAUGLI_RESTRICT JXL_RESTRICT @@ -87,9 +87,9 @@ bool ButteraugliInterface(const Image3F &rgb0, const Image3F &rgb1, // Same as ButteraugliInterface, but reuses rgb0 and rgb1 for other purposes // inside the function after they are not needed any more, and it ignores // params.xmul. -bool ButteraugliInterfaceInPlace(Image3F &&rgb0, Image3F &&rgb1, - const ButteraugliParams ¶ms, - ImageF &diffmap, double &diffvalue); +Status ButteraugliInterfaceInPlace(Image3F &&rgb0, Image3F &&rgb1, + const ButteraugliParams ¶ms, + ImageF &diffmap, double &diffvalue); // Converts the butteraugli score into fuzzy class values that are continuous // at the class boundary. The class boundary location is based on human @@ -147,11 +147,13 @@ struct PsychoImage { // Blur needs a transposed image. // Hold it here and only allocate on demand to reduce memory usage. struct BlurTemp { - ImageF *GetTransposed(const ImageF &in) { + Status GetTransposed(const ImageF &in, ImageF **out) { if (transposed_temp.xsize() == 0) { - transposed_temp = ImageF(in.ysize(), in.xsize()); + JXL_ASSIGN_OR_RETURN(transposed_temp, + ImageF::Create(in.ysize(), in.xsize())); } - return &transposed_temp; + *out = &transposed_temp; + return true; } ImageF transposed_temp; @@ -162,22 +164,26 @@ class ButteraugliComparator { // Butteraugli is calibrated at xmul = 1.0. We add a multiplier here so that // we can test the hypothesis that a higher weighing of the X channel would // improve results at higher Butteraugli values. - ButteraugliComparator(const Image3F &rgb0, const ButteraugliParams ¶ms); virtual ~ButteraugliComparator() = default; + static StatusOr> Make( + const Image3F &rgb0, const ButteraugliParams ¶ms); + // Computes the butteraugli map between the original image given in the // constructor and the distorted image give here. - void Diffmap(const Image3F &rgb1, ImageF &result) const; + Status Diffmap(const Image3F &rgb1, ImageF &result) const; // Same as above, but OpsinDynamicsImage() was already applied. - void DiffmapOpsinDynamicsImage(const Image3F &xyb1, ImageF &result) const; + Status DiffmapOpsinDynamicsImage(const Image3F &xyb1, ImageF &result) const; // Same as above, but the frequency decomposition was already applied. - void DiffmapPsychoImage(const PsychoImage &pi1, ImageF &diffmap) const; + Status DiffmapPsychoImage(const PsychoImage &pi1, ImageF &diffmap) const; - void Mask(ImageF *BUTTERAUGLI_RESTRICT mask) const; + Status Mask(ImageF *BUTTERAUGLI_RESTRICT mask) const; private: + ButteraugliComparator(size_t xsize, size_t ysize, + const ButteraugliParams ¶ms); Image3F *Temp() const; void ReleaseTemp() const; @@ -196,18 +202,19 @@ class ButteraugliComparator { }; // Deprecated. -bool ButteraugliDiffmap(const Image3F &rgb0, const Image3F &rgb1, - double hf_asymmetry, double xmul, ImageF &diffmap); +Status ButteraugliDiffmap(const Image3F &rgb0, const Image3F &rgb1, + double hf_asymmetry, double xmul, ImageF &diffmap); -bool ButteraugliDiffmap(const Image3F &rgb0, const Image3F &rgb1, - const ButteraugliParams ¶ms, ImageF &diffmap); +Status ButteraugliDiffmap(const Image3F &rgb0, const Image3F &rgb1, + const ButteraugliParams ¶ms, ImageF &diffmap); double ButteraugliScoreFromDiffmap(const ImageF &diffmap, const ButteraugliParams *params = nullptr); // Generate rgb-representation of the distance between two images. -Image3F CreateHeatMapImage(const ImageF &distmap, double good_threshold, - double bad_threshold); +StatusOr CreateHeatMapImage(const ImageF &distmap, + double good_threshold, + double bad_threshold); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc index c2ccf56175..39df4bd473 100644 --- a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc +++ b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc @@ -30,7 +30,7 @@ using extras::PackedPixelFile; using test::TestImage; Image3F SinglePixelImage(float red, float green, float blue) { - Image3F img(1, 1); + JXL_ASSIGN_OR_DIE(Image3F img, Image3F::Create(1, 1)); img.PlaneRow(0, 0)[0] = red; img.PlaneRow(1, 0)[0] = green; img.PlaneRow(2, 0)[0] = blue; @@ -42,7 +42,7 @@ Image3F GetColorImage(const PackedPixelFile& ppf) { const PackedImage& image = ppf.frames[0].color; const JxlPixelFormat& format = image.format; const uint8_t* pixels = reinterpret_cast(image.pixels()); - Image3F color(image.xsize, image.ysize); + JXL_ASSIGN_OR_DIE(Image3F color, Image3F::Create(image.xsize, image.ysize)); for (size_t c = 0; c < format.num_channels; ++c) { JXL_CHECK(ConvertFromExternal(pixels, image.pixels_size, image.xsize, image.ysize, ppf.info.bits_per_sample, format, @@ -93,7 +93,7 @@ TEST(ButteraugliInPlaceTest, LargeImage) { TestImage img; img.SetDimensions(xsize, ysize).AddFrame().RandomFill(777); Image3F rgb0 = GetColorImage(img.ppf()); - Image3F rgb1(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3F rgb1, Image3F::Create(xsize, ysize)); CopyImageTo(rgb0, &rgb1); AddUniformNoise(&rgb1, 0.02f, 7777); AddEdge(&rgb1, 0.1f, xsize / 2, xsize / 2); diff --git a/third_party/jpeg-xl/lib/jxl/cache_aligned.cc b/third_party/jpeg-xl/lib/jxl/cache_aligned.cc index 992efc4d48..8a95634d68 100644 --- a/third_party/jpeg-xl/lib/jxl/cache_aligned.cc +++ b/third_party/jpeg-xl/lib/jxl/cache_aligned.cc @@ -5,6 +5,7 @@ #include "lib/jxl/cache_aligned.h" +#include #include #include @@ -95,7 +96,7 @@ void* CacheAligned::Allocate(const size_t payload_size, size_t offset) { aligned &= ~(kAlias - 1); #endif -#if 0 +#if JXL_FALSE // No effect. uintptr_t page_aligned = reinterpret_cast(allocated); page_aligned &= ~(4096 - 1); diff --git a/third_party/jpeg-xl/lib/jxl/cache_aligned.h b/third_party/jpeg-xl/lib/jxl/cache_aligned.h index d79d7be461..8480471e5c 100644 --- a/third_party/jpeg-xl/lib/jxl/cache_aligned.h +++ b/third_party/jpeg-xl/lib/jxl/cache_aligned.h @@ -49,7 +49,7 @@ class CacheAligned { // Avoids the need for a function pointer (deleter) in CacheAlignedUniquePtr. struct CacheAlignedDeleter { void operator()(uint8_t* aligned_pointer) const { - return CacheAligned::Free(aligned_pointer); + CacheAligned::Free(aligned_pointer); } }; diff --git a/third_party/jpeg-xl/lib/jxl/chroma_from_luma.cc b/third_party/jpeg-xl/lib/jxl/chroma_from_luma.cc index 63d21cbb4b..69585c44cf 100644 --- a/third_party/jpeg-xl/lib/jxl/chroma_from_luma.cc +++ b/third_party/jpeg-xl/lib/jxl/chroma_from_luma.cc @@ -5,17 +5,25 @@ #include "lib/jxl/chroma_from_luma.h" +#include "lib/jxl/image_ops.h" + namespace jxl { -ColorCorrelationMap::ColorCorrelationMap(size_t xsize, size_t ysize, bool XYB) - : ytox_map(DivCeil(xsize, kColorTileDim), DivCeil(ysize, kColorTileDim)), - ytob_map(DivCeil(xsize, kColorTileDim), DivCeil(ysize, kColorTileDim)) { - ZeroFillImage(&ytox_map); - ZeroFillImage(&ytob_map); +StatusOr ColorCorrelationMap::Create(size_t xsize, + size_t ysize, + bool XYB) { + ColorCorrelationMap result; + size_t xblocks = DivCeil(xsize, kColorTileDim); + size_t yblocks = DivCeil(ysize, kColorTileDim); + JXL_ASSIGN_OR_RETURN(result.ytox_map, ImageSB::Create(xblocks, yblocks)); + JXL_ASSIGN_OR_RETURN(result.ytob_map, ImageSB::Create(xblocks, yblocks)); + ZeroFillImage(&result.ytox_map); + ZeroFillImage(&result.ytob_map); if (!XYB) { - base_correlation_b_ = 0; + result.base_correlation_b_ = 0; } - RecomputeDCFactors(); + result.RecomputeDCFactors(); + return result; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h b/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h index cb3b710762..1f2353d9af 100644 --- a/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h +++ b/third_party/jpeg-xl/lib/jxl/chroma_from_luma.h @@ -12,19 +12,15 @@ #include #include -#include +#include -#include "lib/jxl/base/compiler_specific.h" -#include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" #include "lib/jxl/cms/opsin_params.h" #include "lib/jxl/dec_bit_reader.h" -#include "lib/jxl/entropy_coder.h" #include "lib/jxl/field_encodings.h" #include "lib/jxl/fields.h" #include "lib/jxl/frame_dimensions.h" #include "lib/jxl/image.h" -#include "lib/jxl/quant_weights.h" namespace jxl { @@ -55,7 +51,8 @@ struct ColorCorrelationMap { // xsize/ysize are in pixels // set XYB=false to do something close to no-op cmap (needed for now since // cmap is mandatory) - ColorCorrelationMap(size_t xsize, size_t ysize, bool XYB = true); + static StatusOr Create(size_t xsize, size_t ysize, + bool XYB = true); float YtoXRatio(int32_t x_factor) const { return base_correlation_x_ + x_factor * color_scale_; @@ -96,7 +93,7 @@ struct ColorCorrelationMap { color_factor_ == kDefaultColorFactor; } - int32_t RatioJPEG(int32_t factor) const { + static int32_t RatioJPEG(int32_t factor) { return factor * (1 << kCFLFixedPointPrecision) / kDefaultColorFactor; } diff --git a/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h b/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h index db61f820ca..3b7ae09d6f 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h +++ b/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h @@ -96,6 +96,8 @@ enum class RenderingIntent : uint32_t { // Chromaticity (Y is omitted because it is 1 for white points and implicit for // primaries) struct CIExy { + CIExy() = default; + CIExy(double x, double y) : x(x), y(y) {} double x = 0.0; double y = 0.0; }; @@ -516,7 +518,7 @@ struct ColorEncoding { JXL_RETURN_IF_ERROR(cms.set_fields_from_icc(cms.set_fields_data, new_icc.data(), new_icc.size(), &external, &new_cmyk)); - cmyk = new_cmyk; + cmyk = static_cast(new_cmyk); JXL_RETURN_IF_ERROR(FromExternal(external)); icc = std::move(new_icc); return true; diff --git a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms.cc b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms.cc index dd00b8b81f..e35b3ce172 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms.cc +++ b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms.cc @@ -307,7 +307,7 @@ int DoColorSpaceTransform(void* t, size_t thread, const float* buf_src, #if JPEGXL_ENABLE_SKCMS -JXL_MUST_USE_RESULT CIExy CIExyFromXYZ(const float XYZ[3]) { +JXL_MUST_USE_RESULT CIExy CIExyFromXYZ(const Color& XYZ) { const float factor = 1.f / (XYZ[0] + XYZ[1] + XYZ[2]); CIExy xy; xy.x = XYZ[0] * factor; @@ -405,8 +405,8 @@ ColorSpace ColorSpaceFromProfile(const skcms_ICCProfile& profile) { } // vector_out := matmul(matrix, vector_in) -void MatrixProduct(const skcms_Matrix3x3& matrix, const float vector_in[3], - float vector_out[3]) { +void MatrixProduct(const skcms_Matrix3x3& matrix, const Color& vector_in, + Color& vector_out) { for (int i = 0; i < 3; ++i) { vector_out[i] = 0; for (int j = 0; j < 3; ++j) { @@ -418,8 +418,8 @@ void MatrixProduct(const skcms_Matrix3x3& matrix, const float vector_in[3], // Returns white point that was specified when creating the profile. JXL_MUST_USE_RESULT Status UnadaptedWhitePoint(const skcms_ICCProfile& profile, CIExy* out) { - float media_white_point_XYZ[3]; - if (!skcms_GetWTPT(&profile, media_white_point_XYZ)) { + Color media_white_point_XYZ; + if (!skcms_GetWTPT(&profile, media_white_point_XYZ.data())) { return JXL_FAILURE("ICC profile does not contain WhitePoint tag"); } skcms_Matrix3x3 CHAD; @@ -435,7 +435,7 @@ JXL_MUST_USE_RESULT Status UnadaptedWhitePoint(const skcms_ICCProfile& profile, if (!skcms_Matrix3x3_invert(&CHAD, &inverse_CHAD)) { return JXL_FAILURE("Non-invertible ChromaticAdaptation matrix"); } - float unadapted_white_point_XYZ[3]; + Color unadapted_white_point_XYZ; MatrixProduct(inverse_CHAD, media_white_point_XYZ, unadapted_white_point_XYZ); *out = CIExyFromXYZ(unadapted_white_point_XYZ); return true; @@ -445,7 +445,8 @@ Status IdentifyPrimaries(const skcms_ICCProfile& profile, const CIExy& wp_unadapted, ColorEncoding* c) { if (!c->HasPrimaries()) return true; - skcms_Matrix3x3 CHAD, inverse_CHAD; + skcms_Matrix3x3 CHAD; + skcms_Matrix3x3 inverse_CHAD; if (skcms_GetCHAD(&profile, &CHAD)) { JXL_RETURN_IF_ERROR(skcms_Matrix3x3_invert(&CHAD, &inverse_CHAD)); } else { @@ -457,11 +458,12 @@ Status IdentifyPrimaries(const skcms_ICCProfile& profile, {{0.9869929, -0.1470543, 0.1599627}, {0.4323053, 0.5183603, 0.0492912}, {-0.0085287, 0.0400428, 0.9684867}}}; - static constexpr float kWpD50XYZ[3] = {0.96420288, 1.0, 0.82490540}; - float wp_unadapted_XYZ[3]; + static constexpr Color kWpD50XYZ{0.96420288, 1.0, 0.82490540}; + Color wp_unadapted_XYZ; JXL_RETURN_IF_ERROR( CIEXYZFromWhiteCIExy(wp_unadapted.x, wp_unadapted.y, wp_unadapted_XYZ)); - float wp_D50_LMS[3], wp_unadapted_LMS[3]; + Color wp_D50_LMS; + Color wp_unadapted_LMS; MatrixProduct(kLMSFromXYZ, kWpD50XYZ, wp_D50_LMS); MatrixProduct(kLMSFromXYZ, wp_unadapted_XYZ, wp_unadapted_LMS); inverse_CHAD = {{{wp_unadapted_LMS[0] / wp_D50_LMS[0], 0, 0}, @@ -471,16 +473,16 @@ Status IdentifyPrimaries(const skcms_ICCProfile& profile, inverse_CHAD = skcms_Matrix3x3_concat(&inverse_CHAD, &kLMSFromXYZ); } - float XYZ[3]; + Color XYZ; PrimariesCIExy primaries; CIExy* const chromaticities[] = {&primaries.r, &primaries.g, &primaries.b}; for (int i = 0; i < 3; ++i) { float RGB[3] = {}; RGB[i] = 1; skcms_Transform(RGB, skcms_PixelFormat_RGB_fff, skcms_AlphaFormat_Opaque, - &profile, XYZ, skcms_PixelFormat_RGB_fff, + &profile, XYZ.data(), skcms_PixelFormat_RGB_fff, skcms_AlphaFormat_Opaque, skcms_XYZD50_profile(), 1); - float unadapted_XYZ[3]; + Color unadapted_XYZ; MatrixProduct(inverse_CHAD, XYZ, unadapted_XYZ); *chromaticities[i] = CIExyFromXYZ(unadapted_XYZ); } @@ -829,17 +831,17 @@ Status GetPrimariesLuminances(const ColorEncoding& encoding, // From there, by multiplying each total by its corresponding y, we get Y for // that primary. - float white_XYZ[3]; + Color white_XYZ; CIExy wp = encoding.GetWhitePoint(); JXL_RETURN_IF_ERROR(CIEXYZFromWhiteCIExy(wp.x, wp.y, white_XYZ)); const PrimariesCIExy primaries = encoding.GetPrimaries(); - double chromaticities[3][3] = { - {primaries.r.x, primaries.g.x, primaries.b.x}, - {primaries.r.y, primaries.g.y, primaries.b.y}, - {1 - primaries.r.x - primaries.r.y, 1 - primaries.g.x - primaries.g.y, - 1 - primaries.b.x - primaries.b.y}}; - JXL_RETURN_IF_ERROR(Inv3x3Matrix(&chromaticities[0][0])); + Matrix3x3d chromaticities{ + {{primaries.r.x, primaries.g.x, primaries.b.x}, + {primaries.r.y, primaries.g.y, primaries.b.y}, + {1 - primaries.r.x - primaries.r.y, 1 - primaries.g.x - primaries.g.y, + 1 - primaries.b.x - primaries.b.y}}}; + JXL_RETURN_IF_ERROR(Inv3x3Matrix(chromaticities)); const double ys[3] = {primaries.r.y, primaries.g.y, primaries.b.y}; for (size_t i = 0; i < 3; ++i) { luminances[i] = ys[i] * (chromaticities[i][0] * white_XYZ[0] + @@ -971,14 +973,31 @@ JXL_BOOL JxlCmsSetFieldsFromICC(void* user_data, const uint8_t* icc_data, JXL_RETURN_IF_ERROR(skcms_Parse(icc_data, icc_size, &profile)); // skcms does not return the rendering intent, so get it from the file. It - // is encoded as big-endian 32-bit integer in bytes 60..63. - uint32_t rendering_intent32 = icc_data[67]; - if (rendering_intent32 > 3 || icc_data[64] != 0 || icc_data[65] != 0 || - icc_data[66] != 0) { - return JXL_FAILURE("Invalid rendering intent %u\n", rendering_intent32); + // should be encoded as big-endian 32-bit integer in bytes 60..63. + uint32_t big_endian_rendering_intent = icc_data[67] + (icc_data[66] << 8) + + (icc_data[65] << 16) + + (icc_data[64] << 24); + // Some files encode rendering intent as little endian, which is not spec + // compliant. However we accept those with a warning. + uint32_t little_endian_rendering_intent = (icc_data[67] << 24) + + (icc_data[66] << 16) + + (icc_data[65] << 8) + icc_data[64]; + uint32_t candidate_rendering_intent = + std::min(big_endian_rendering_intent, little_endian_rendering_intent); + if (candidate_rendering_intent != big_endian_rendering_intent) { + JXL_WARNING( + "Invalid rendering intent bytes: [0x%02X 0x%02X 0x%02X 0x%02X], " + "assuming %u was meant", + icc_data[64], icc_data[65], icc_data[66], icc_data[67], + candidate_rendering_intent); + } + if (candidate_rendering_intent > 3) { + return JXL_FAILURE("Invalid rendering intent %u\n", + candidate_rendering_intent); } // ICC and RenderingIntent have the same values (0..3). - c_enc.rendering_intent = static_cast(rendering_intent32); + c_enc.rendering_intent = + static_cast(candidate_rendering_intent); if (profile.has_CICP && ApplyCICP(profile.CICP.color_primaries, @@ -986,11 +1005,11 @@ JXL_BOOL JxlCmsSetFieldsFromICC(void* user_data, const uint8_t* icc_data, profile.CICP.matrix_coefficients, profile.CICP.video_full_range_flag, &c_enc)) { *c = c_enc.ToExternal(); - return true; + return JXL_TRUE; } c_enc.color_space = ColorSpaceFromProfile(profile); - *cmyk = (profile.data_color_space == skcms_Signature_CMYK); + *cmyk = TO_JXL_BOOL(profile.data_color_space == skcms_Signature_CMYK); CIExy wp_unadapted; JXL_RETURN_IF_ERROR(UnadaptedWhitePoint(profile, &wp_unadapted)); @@ -1026,14 +1045,14 @@ JXL_BOOL JxlCmsSetFieldsFromICC(void* user_data, const uint8_t* icc_data, ApplyCICP(cicp_buffer[8], cicp_buffer[9], cicp_buffer[10], cicp_buffer[11], &c_enc)) { *c = c_enc.ToExternal(); - return true; + return JXL_TRUE; } c_enc.color_space = ColorSpaceFromProfile(profile); if (cmsGetColorSpace(profile.get()) == cmsSigCmykData) { *cmyk = JXL_TRUE; *c = c_enc.ToExternal(); - return true; + return JXL_TRUE; } const cmsCIEXYZ wp_unadapted = UnadaptedWhitePoint(context, profile, c_enc); @@ -1049,7 +1068,7 @@ JXL_BOOL JxlCmsSetFieldsFromICC(void* user_data, const uint8_t* icc_data, #endif // JPEGXL_ENABLE_SKCMS *c = c_enc.ToExternal(); - return true; + return JXL_TRUE; } } // namespace @@ -1084,9 +1103,10 @@ void* JxlCmsInit(void* init_data, size_t num_threads, size_t xsize, const JxlColorProfile* input, const JxlColorProfile* output, float intensity_target) { JXL_ASSERT(init_data != nullptr); - auto cms = static_cast(init_data); + const auto* cms = static_cast(init_data); auto t = jxl::make_unique(); - IccBytes icc_src, icc_dst; + IccBytes icc_src; + IccBytes icc_dst; if (input->icc.size == 0) { JXL_NOTIFY_ERROR("JxlCmsInit: empty input ICC"); return nullptr; @@ -1259,8 +1279,6 @@ void* JxlCmsInit(void* init_data, size_t num_threads, size_t xsize, // Not including alpha channel (copied separately). const size_t channels_src = (c_src.cmyk ? 4 : c_src.Channels()); const size_t channels_dst = c_dst.Channels(); - JXL_CHECK(channels_src == channels_dst || - (channels_src == 4 && channels_dst == 3)); #if JXL_CMS_VERBOSE printf("Channels: %" PRIuS "; Threads: %" PRIuS "\n", channels_src, num_threads); @@ -1294,13 +1312,14 @@ void* JxlCmsInit(void* init_data, size_t num_threads, size_t xsize, // outputs (or vice versa), we use floating point input/output. t->channels_src = channels_src; t->channels_dst = channels_dst; +#if !JPEGXL_ENABLE_SKCMS size_t actual_channels_src = channels_src; size_t actual_channels_dst = channels_dst; -#if JPEGXL_ENABLE_SKCMS +#else // SkiaCMS doesn't support grayscale float buffers, so we create space for RGB // float buffers anyway. - actual_channels_src = (channels_src == 4 ? 4 : 3); - actual_channels_dst = 3; + size_t actual_channels_src = (channels_src == 4 ? 4 : 3); + size_t actual_channels_dst = 3; #endif AllocateBuffer(xsize * actual_channels_src, num_threads, &t->src_storage, &t->buf_src); diff --git a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h index c00fe82d8c..7f59e688d0 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h +++ b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h @@ -41,7 +41,7 @@ enum class ExtraTF { }; static Status PrimariesToXYZ(float rx, float ry, float gx, float gy, float bx, - float by, float wx, float wy, float matrix[9]) { + float by, float wx, float wy, Matrix3x3& matrix) { bool ok = (wx >= 0) && (wx <= 1) && (wy > 0) && (wy <= 1); if (!ok) { return JXL_FAILURE("Invalid white point"); @@ -49,51 +49,48 @@ static Status PrimariesToXYZ(float rx, float ry, float gx, float gy, float bx, // TODO(lode): also require rx, ry, gx, gy, bx, to be in range 0-1? ICC // profiles in theory forbid negative XYZ values, but in practice the ACES P0 // color space uses a negative y for the blue primary. - float primaries[9] = { - rx, gx, bx, ry, gy, by, 1.0f - rx - ry, 1.0f - gx - gy, 1.0f - bx - by}; - float primaries_inv[9]; - memcpy(primaries_inv, primaries, sizeof(float) * 9); + Matrix3x3 primaries{{{rx, gx, bx}, + {ry, gy, by}, + {1.0f - rx - ry, 1.0f - gx - gy, 1.0f - bx - by}}}; + Matrix3x3 primaries_inv; + primaries_inv = primaries; JXL_RETURN_IF_ERROR(Inv3x3Matrix(primaries_inv)); - float w[3] = {wx / wy, 1.0f, (1.0f - wx - wy) / wy}; + Vector3 w{wx / wy, 1.0f, (1.0f - wx - wy) / wy}; // 1 / tiny float can still overflow JXL_RETURN_IF_ERROR(std::isfinite(w[0]) && std::isfinite(w[2])); - float xyz[3]; + Vector3 xyz; Mul3x3Vector(primaries_inv, w, xyz); - float a[9] = { - xyz[0], 0, 0, 0, xyz[1], 0, 0, 0, xyz[2], - }; + Matrix3x3 a{{{xyz[0], 0, 0}, {0, xyz[1], 0}, {0, 0, xyz[2]}}}; Mul3x3Matrix(primaries, a, matrix); return true; } /* Chromatic adaptation matrices*/ -constexpr float kBradford[9] = { - 0.8951f, 0.2664f, -0.1614f, -0.7502f, 1.7135f, - 0.0367f, 0.0389f, -0.0685f, 1.0296f, -}; -constexpr float kBradfordInv[9] = { - 0.9869929f, -0.1470543f, 0.1599627f, 0.4323053f, 0.5183603f, - 0.0492912f, -0.0085287f, 0.0400428f, 0.9684867f, -}; +constexpr Matrix3x3 kBradford{{{0.8951f, 0.2664f, -0.1614f}, + {-0.7502f, 1.7135f, 0.0367f}, + {0.0389f, -0.0685f, 1.0296f}}}; +constexpr Matrix3x3 kBradfordInv{{{0.9869929f, -0.1470543f, 0.1599627f}, + {0.4323053f, 0.5183603f, 0.0492912f}, + {-0.0085287f, 0.0400428f, 0.9684867f}}}; // Adapts whitepoint x, y to D50 -static Status AdaptToXYZD50(float wx, float wy, float matrix[9]) { +static Status AdaptToXYZD50(float wx, float wy, Matrix3x3& matrix) { bool ok = (wx >= 0) && (wx <= 1) && (wy > 0) && (wy <= 1); if (!ok) { // Out of range values can cause division through zero // further down with the bradford adaptation too. return JXL_FAILURE("Invalid white point"); } - float w[3] = {wx / wy, 1.0f, (1.0f - wx - wy) / wy}; + Vector3 w{wx / wy, 1.0f, (1.0f - wx - wy) / wy}; // 1 / tiny float can still overflow JXL_RETURN_IF_ERROR(std::isfinite(w[0]) && std::isfinite(w[2])); - float w50[3] = {0.96422f, 1.0f, 0.82521f}; + Vector3 w50{0.96422f, 1.0f, 0.82521f}; - float lms[3]; - float lms50[3]; + Vector3 lms; + Vector3 lms50; Mul3x3Vector(kBradford, w, lms); Mul3x3Vector(kBradford, w50, lms50); @@ -101,15 +98,15 @@ static Status AdaptToXYZD50(float wx, float wy, float matrix[9]) { if (lms[0] == 0 || lms[1] == 0 || lms[2] == 0) { return JXL_FAILURE("Invalid white point"); } - float a[9] = { - // /----> 0, 1, 2, 3, /----> 4, 5, 6, 7, /----> 8, - lms50[0] / lms[0], 0, 0, 0, lms50[1] / lms[1], 0, 0, 0, lms50[2] / lms[2], - }; - if (!std::isfinite(a[0]) || !std::isfinite(a[4]) || !std::isfinite(a[8])) { + Matrix3x3 a{{{lms50[0] / lms[0], 0, 0}, + {0, lms50[1] / lms[1], 0}, + {0, 0, lms50[2] / lms[2]}}}; + if (!std::isfinite(a[0][0]) || !std::isfinite(a[1][1]) || + !std::isfinite(a[2][2])) { return JXL_FAILURE("Invalid white point"); } - float b[9]; + Matrix3x3 b; Mul3x3Matrix(a, kBradford, b); Mul3x3Matrix(kBradfordInv, b, matrix); @@ -118,10 +115,10 @@ static Status AdaptToXYZD50(float wx, float wy, float matrix[9]) { static Status PrimariesToXYZD50(float rx, float ry, float gx, float gy, float bx, float by, float wx, float wy, - float matrix[9]) { - float toXYZ[9]; + Matrix3x3& matrix) { + Matrix3x3 toXYZ; JXL_RETURN_IF_ERROR(PrimariesToXYZ(rx, ry, gx, gy, bx, by, wx, wy, toXYZ)); - float d50[9]; + Matrix3x3 d50; JXL_RETURN_IF_ERROR(AdaptToXYZD50(wx, wy, d50)); Mul3x3Matrix(d50, toXYZ, matrix); @@ -130,14 +127,13 @@ static Status PrimariesToXYZD50(float rx, float ry, float gx, float gy, static Status ToneMapPixel(const JxlColorEncoding& c, const float in[3], uint8_t pcslab_out[3]) { - float primaries_XYZ[9]; + Matrix3x3 primaries_XYZ; JXL_RETURN_IF_ERROR(PrimariesToXYZ( c.primaries_red_xy[0], c.primaries_red_xy[1], c.primaries_green_xy[0], c.primaries_green_xy[1], c.primaries_blue_xy[0], c.primaries_blue_xy[1], c.white_point_xy[0], c.white_point_xy[1], primaries_XYZ)); - const float luminances[3] = {primaries_XYZ[3], primaries_XYZ[4], - primaries_XYZ[5]}; - float linear[3]; + const Vector3 luminances = primaries_XYZ[1]; + Color linear; JxlTransferFunction tf = c.transfer_function; if (tf == JXL_TRANSFER_FUNCTION_PQ) { for (size_t i = 0; i < 3; ++i) { @@ -151,25 +147,25 @@ static Status ToneMapPixel(const JxlColorEncoding& c, const float in[3], } if (tf == JXL_TRANSFER_FUNCTION_PQ) { Rec2408ToneMapperBase tone_mapper({0, 10000}, {0, 250}, luminances); - tone_mapper.ToneMap(&linear[0], &linear[1], &linear[2]); + tone_mapper.ToneMap(linear); } else { HlgOOTF_Base ootf(/*source_luminance=*/300, /*target_luminance=*/80, luminances); - ootf.Apply(&linear[0], &linear[1], &linear[2]); + ootf.Apply(linear); } - GamutMapScalar(&linear[0], &linear[1], &linear[2], luminances, + GamutMapScalar(linear, luminances, /*preserve_saturation=*/0.3f); - float chad[9]; + Matrix3x3 chad; JXL_RETURN_IF_ERROR( AdaptToXYZD50(c.white_point_xy[0], c.white_point_xy[1], chad)); - float to_xyzd50[9]; + Matrix3x3 to_xyzd50; Mul3x3Matrix(chad, primaries_XYZ, to_xyzd50); - float xyz[3] = {0, 0, 0}; + Vector3 xyz{0, 0, 0}; for (size_t xyz_c = 0; xyz_c < 3; ++xyz_c) { for (size_t rgb_c = 0; rgb_c < 3; ++rgb_c) { - xyz[xyz_c] += linear[rgb_c] * to_xyzd50[3 * xyz_c + rgb_c]; + xyz[xyz_c] += linear[rgb_c] * to_xyzd50[xyz_c][rgb_c]; } } @@ -206,7 +202,7 @@ static std::vector CreateTableCurve(uint32_t N, const ExtraTF tf, JXL_ASSERT(N <= 4096); // ICC MFT2 only allows 4K entries JXL_ASSERT(tf == ExtraTF::kPQ || tf == ExtraTF::kHLG); - static constexpr float kLuminances[] = {1.f / 3, 1.f / 3, 1.f / 3}; + static constexpr Vector3 kLuminances{1.f / 3, 1.f / 3, 1.f / 3}; Rec2408ToneMapperBase tone_mapper({0, kPQIntensityTarget}, {0, kDefaultIntensityTarget}, kLuminances); // No point using float - LCMS converts to 16-bit for A2B/MFT. @@ -220,9 +216,10 @@ static std::vector CreateTableCurve(uint32_t N, const ExtraTF tf, : TF_PQ_Base::DisplayFromEncoded(kPQIntensityTarget, dx); if (tone_map && tf == ExtraTF::kPQ && kPQIntensityTarget > kDefaultIntensityTarget) { - float r = y * 10000 / kPQIntensityTarget, g = r, b = r; - tone_mapper.ToneMap(&r, &g, &b); - y = r; + float l = y * 10000 / kPQIntensityTarget; + Color gray{l, l, l}; + tone_mapper.ToneMap(gray); + y = gray[0]; } JXL_ASSERT(y >= 0.0); // Clamp to table range - necessary for HLG. @@ -233,7 +230,7 @@ static std::vector CreateTableCurve(uint32_t N, const ExtraTF tf, return table; } -static Status CIEXYZFromWhiteCIExy(double wx, double wy, float XYZ[3]) { +static Status CIEXYZFromWhiteCIExy(double wx, double wy, Color& XYZ) { // Target Y = 1. if (std::abs(wy) < 1e-12) return JXL_FAILURE("Y value is too small"); const float factor = 1 / wy; @@ -292,10 +289,18 @@ static void ICCComputeMD5(const std::vector& data, uint8_t sum[16]) 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, }; - uint32_t a0 = 0x67452301, b0 = 0xefcdab89, c0 = 0x98badcfe, d0 = 0x10325476; + uint32_t a0 = 0x67452301; + uint32_t b0 = 0xefcdab89; + uint32_t c0 = 0x98badcfe; + uint32_t d0 = 0x10325476; for (size_t i = 0; i < data64.size(); i += 64) { - uint32_t a = a0, b = b0, c = c0, d = d0, f, g; + uint32_t a = a0; + uint32_t b = b0; + uint32_t c = c0; + uint32_t d = d0; + uint32_t f; + uint32_t g; for (size_t j = 0; j < 64; j++) { if (j < 16) { f = (b & c) | ((~b) & d); @@ -310,8 +315,10 @@ static void ICCComputeMD5(const std::vector& data, uint8_t sum[16]) f = c ^ (b | (~d)); g = (7 * j) & 0xf; } - uint32_t dg0 = data64[i + g * 4 + 0], dg1 = data64[i + g * 4 + 1], - dg2 = data64[i + g * 4 + 2], dg3 = data64[i + g * 4 + 3]; + uint32_t dg0 = data64[i + g * 4 + 0]; + uint32_t dg1 = data64[i + g * 4 + 1]; + uint32_t dg2 = data64[i + g * 4 + 2]; + uint32_t dg3 = data64[i + g * 4 + 3]; uint32_t u = dg0 | (dg1 << 8u) | (dg2 << 16u) | (dg3 << 24u); f += a + sineparts[j] + u; a = d; @@ -342,23 +349,23 @@ static void ICCComputeMD5(const std::vector& data, uint8_t sum[16]) sum[15] = d0 >> 24u; } -static Status CreateICCChadMatrix(double wx, double wy, float result[9]) { - float m[9]; +static Status CreateICCChadMatrix(double wx, double wy, Matrix3x3& result) { + Matrix3x3 m; if (wy == 0) { // WhitePoint can not be pitch-black. return JXL_FAILURE("Invalid WhitePoint"); } JXL_RETURN_IF_ERROR(AdaptToXYZD50(wx, wy, m)); - memcpy(result, m, sizeof(float) * 9); + result = m; return true; } // Creates RGB to XYZ matrix given RGB primaries and whitepoint in xy. static Status CreateICCRGBMatrix(double rx, double ry, double gx, double gy, double bx, double by, double wx, double wy, - float result[9]) { - float m[9]; + Matrix3x3& result) { + Matrix3x3 m; JXL_RETURN_IF_ERROR(PrimariesToXYZD50(rx, ry, gx, gy, bx, by, wx, wy, m)); - memcpy(result, m, sizeof(float) * 9); + result = m; return true; } @@ -433,8 +440,12 @@ static Status CreateICCHeader(const JxlColorEncoding& c, // Three uint32_t's date/time encoding. // TODO(lode): encode actual date and time, this is a placeholder - uint32_t year = 2019, month = 12, day = 1; - uint32_t hour = 0, minute = 0, second = 0; + uint32_t year = 2019; + uint32_t month = 12; + uint32_t day = 1; + uint32_t hour = 0; + uint32_t minute = 0; + uint32_t second = 0; WriteICCUint16(year, 24, header); WriteICCUint16(month, 26, header); WriteICCUint16(day, 28, header); @@ -491,13 +502,13 @@ static void CreateICCMlucTag(const std::string& text, WriteICCTag("enUS", tags->size(), tags); WriteICCUint32(text.size() * 2, tags->size(), tags); WriteICCUint32(28, tags->size(), tags); - for (size_t i = 0; i < text.size(); i++) { + for (char c : text) { tags->push_back(0); // prepend 0 for UTF-16 - tags->push_back(text[i]); + tags->push_back(c); } } -static Status CreateICCXYZTag(float xyz[3], std::vector* tags) { +static Status CreateICCXYZTag(const Color& xyz, std::vector* tags) { WriteICCTag("XYZ ", tags->size(), tags); WriteICCUint32(0, tags->size(), tags); for (size_t i = 0; i < 3; ++i) { @@ -506,11 +517,14 @@ static Status CreateICCXYZTag(float xyz[3], std::vector* tags) { return true; } -static Status CreateICCChadTag(float chad[9], std::vector* tags) { +static Status CreateICCChadTag(const Matrix3x3& chad, + std::vector* tags) { WriteICCTag("sf32", tags->size(), tags); WriteICCUint32(0, tags->size(), tags); - for (size_t i = 0; i < 9; i++) { - JXL_RETURN_IF_ERROR(WriteICCS15Fixed16(chad[i], tags->size(), tags)); + for (size_t j = 0; j < 3; j++) { + for (size_t i = 0; i < 3; i++) { + JXL_RETURN_IF_ERROR(WriteICCS15Fixed16(chad[j][i], tags->size(), tags)); + } } return true; } @@ -573,8 +587,8 @@ static Status CreateICCCurvParaTag(std::vector params, size_t curve_type, WriteICCUint32(0, tags->size(), tags); WriteICCUint16(curve_type, tags->size(), tags); WriteICCUint16(0, tags->size(), tags); - for (size_t i = 0; i < params.size(); i++) { - JXL_RETURN_IF_ERROR(WriteICCS15Fixed16(params[i], tags->size(), tags)); + for (float param : params) { + JXL_RETURN_IF_ERROR(WriteICCS15Fixed16(param, tags->size(), tags)); } return true; } @@ -649,8 +663,8 @@ static Status CreateICCLutAtoBTagForXYB(std::vector* tags) { -0.050022, 0.5683655, -0.018344, -1.387676, 1.1145555, 0.6857255}; // 12 * 4 = 48 bytes - for (size_t i = 0; i < 9; ++i) { - JXL_RETURN_IF_ERROR(WriteICCS15Fixed16(matrix[i], tags->size(), tags)); + for (double v : matrix) { + JXL_RETURN_IF_ERROR(WriteICCS15Fixed16(v, tags->size(), tags)); } for (size_t i = 0; i < 3; ++i) { float intercept = 0; @@ -880,7 +894,9 @@ static std::string ColorEncodingDescriptionImpl(const JxlColorEncoding& c) { static Status MaybeCreateProfileImpl(const JxlColorEncoding& c, std::vector* icc) { - std::vector header, tagtable, tags; + std::vector header; + std::vector tagtable; + std::vector tags; JxlTransferFunction tf = c.transfer_function; if (c.color_space == JXL_COLOR_SPACE_UNKNOWN || tf == JXL_TRANSFER_FUNCTION_UNKNOWN) { @@ -910,7 +926,8 @@ static Status MaybeCreateProfileImpl(const JxlColorEncoding& c, // tag count, deferred to later WriteICCUint32(0, tagtable.size(), &tagtable); - size_t tag_offset = 0, tag_size = 0; + size_t tag_offset = 0; + size_t tag_size = 0; CreateICCMlucTag(ColorEncodingDescriptionImpl(c), &tags); FinalizeICCTag(&tags, &tag_offset, &tag_size); @@ -923,12 +940,12 @@ static Status MaybeCreateProfileImpl(const JxlColorEncoding& c, // TODO(eustas): isn't it the other way round: gray image has d50 WhitePoint? if (c.color_space == JXL_COLOR_SPACE_GRAY) { - float wtpt[3]; + Color wtpt; JXL_RETURN_IF_ERROR( CIEXYZFromWhiteCIExy(c.white_point_xy[0], c.white_point_xy[1], wtpt)); JXL_RETURN_IF_ERROR(CreateICCXYZTag(wtpt, &tags)); } else { - float d50[3] = {0.964203, 1.0, 0.824905}; + Color d50{0.964203, 1.0, 0.824905}; JXL_RETURN_IF_ERROR(CreateICCXYZTag(d50, &tags)); } FinalizeICCTag(&tags, &tag_offset, &tag_size); @@ -936,7 +953,7 @@ static Status MaybeCreateProfileImpl(const JxlColorEncoding& c, if (c.color_space != JXL_COLOR_SPACE_GRAY) { // Chromatic adaptation matrix - float chad[9]; + Matrix3x3 chad; JXL_RETURN_IF_ERROR( CreateICCChadMatrix(c.white_point_xy[0], c.white_point_xy[1], chad)); @@ -949,14 +966,14 @@ static Status MaybeCreateProfileImpl(const JxlColorEncoding& c, MaybeCreateICCCICPTag(c, &tags, &tag_offset, &tag_size, &tagtable, &offsets); - float m[9]; + Matrix3x3 m; JXL_RETURN_IF_ERROR(CreateICCRGBMatrix( c.primaries_red_xy[0], c.primaries_red_xy[1], c.primaries_green_xy[0], c.primaries_green_xy[1], c.primaries_blue_xy[0], c.primaries_blue_xy[1], c.white_point_xy[0], c.white_point_xy[1], m)); - float r[3] = {m[0], m[3], m[6]}; - float g[3] = {m[1], m[4], m[7]}; - float b[3] = {m[2], m[5], m[8]}; + Color r{m[0][0], m[1][0], m[2][0]}; + Color g{m[0][1], m[1][1], m[2][1]}; + Color b{m[0][2], m[1][2], m[2][2]}; JXL_RETURN_IF_ERROR(CreateICCXYZTag(r, &tags)); FinalizeICCTag(&tags, &tag_offset, &tag_size); @@ -1042,8 +1059,8 @@ static Status MaybeCreateProfileImpl(const JxlColorEncoding& c, WriteICCUint32(header.size() + tagtable.size() + tags.size(), 0, &header); *icc = header; - Bytes(tagtable).AppendTo(icc); - Bytes(tags).AppendTo(icc); + Bytes(tagtable).AppendTo(*icc); + Bytes(tags).AppendTo(*icc); // The MD5 checksum must be computed on the profile with profile flags, // rendering intent, and region of the checksum itself, set to 0. diff --git a/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h b/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h index 48e8e254f7..69dcd0b512 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h +++ b/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h @@ -6,7 +6,7 @@ #ifndef LIB_JXL_CMS_OPSIN_PARAMS_H_ #define LIB_JXL_CMS_OPSIN_PARAMS_H_ -#include +#include "lib/jxl/base/matrix_ops.h" // Constants that define the XYB color space. @@ -35,21 +35,20 @@ constexpr float kOpsinAbsorbanceBias1 = kOpsinAbsorbanceBias0; constexpr float kOpsinAbsorbanceBias2 = kOpsinAbsorbanceBias0; // Opsin absorbance matrix is now frozen. -constexpr std::array kOpsinAbsorbanceMatrix = { - kM00, kM01, kM02, kM10, kM11, kM12, kM20, kM21, kM22, -}; +constexpr Matrix3x3 kOpsinAbsorbanceMatrix{ + {{kM00, kM01, kM02}, {kM10, kM11, kM12}, {kM20, kM21, kM22}}}; -constexpr std::array kDefaultInverseOpsinAbsorbanceMatrix = { - 11.031566901960783f, -9.866943921568629f, -0.16462299647058826f, - -3.254147380392157f, 4.418770392156863f, -0.16462299647058826f, - -3.6588512862745097f, 2.7129230470588235f, 1.9459282392156863f}; +constexpr Matrix3x3 kDefaultInverseOpsinAbsorbanceMatrix{ + {{11.031566901960783f, -9.866943921568629f, -0.16462299647058826f}, + {-3.254147380392157f, 4.418770392156863f, -0.16462299647058826f}, + {-3.6588512862745097f, 2.7129230470588235f, 1.9459282392156863f}}}; // Must be the inverse matrix of kOpsinAbsorbanceMatrix and match the spec. -static inline const float* DefaultInverseOpsinAbsorbanceMatrix() { - return kDefaultInverseOpsinAbsorbanceMatrix.data(); +static inline const Matrix3x3& DefaultInverseOpsinAbsorbanceMatrix() { + return kDefaultInverseOpsinAbsorbanceMatrix; } -constexpr std::array kOpsinAbsorbanceBias = { +constexpr Vector3 kOpsinAbsorbanceBias = { kOpsinAbsorbanceBias0, kOpsinAbsorbanceBias1, kOpsinAbsorbanceBias2, @@ -63,14 +62,14 @@ constexpr float kScaledXYBOffset0 = 0.015386134f; constexpr float kScaledXYBOffset1 = 0.0f; constexpr float kScaledXYBOffset2 = 0.27770459f; -constexpr std::array kScaledXYBOffset = { - kScaledXYBOffset0, kScaledXYBOffset1, kScaledXYBOffset2}; +constexpr Vector3 kScaledXYBOffset = {kScaledXYBOffset0, kScaledXYBOffset1, + kScaledXYBOffset2}; constexpr float kScaledXYBScale0 = 22.995788804f; constexpr float kScaledXYBScale1 = 1.183000077f; constexpr float kScaledXYBScale2 = 1.502141333f; -constexpr std::array kScaledXYBScale = { +constexpr Vector3 kScaledXYBScale = { kScaledXYBScale0, kScaledXYBScale1, kScaledXYBScale2, diff --git a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping-inl.h b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping-inl.h index 3d94ccea12..7d09beed32 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping-inl.h +++ b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping-inl.h @@ -100,14 +100,14 @@ class HlgOOTF : HlgOOTF_Base { using HlgOOTF_Base::HlgOOTF_Base; static HlgOOTF FromSceneLight(float display_luminance, - const float primaries_luminances[3]) { + const Vector3& primaries_luminances) { return HlgOOTF(/*gamma=*/1.2f * std::pow(1.111f, std::log2(display_luminance / 1000.f)), primaries_luminances); } static HlgOOTF ToSceneLight(float display_luminance, - const float primaries_luminances[3]) { + const Vector3& primaries_luminances) { return HlgOOTF( /*gamma=*/(1 / 1.2f) * std::pow(1.111f, -std::log2(display_luminance / 1000.f)), @@ -132,7 +132,7 @@ class HlgOOTF : HlgOOTF_Base { }; template -void GamutMap(V* red, V* green, V* blue, const float primaries_luminances[3], +void GamutMap(V* red, V* green, V* blue, const Vector3& primaries_luminances, float preserve_saturation = 0.1f) { hwy::HWY_NAMESPACE::DFromV df; const V luminance = diff --git a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h index a114109ea6..81f301a31d 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h +++ b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h @@ -12,6 +12,7 @@ #include "lib/jxl/base/common.h" #include "lib/jxl/base/compiler_specific.h" +#include "lib/jxl/base/matrix_ops.h" #include "lib/jxl/cms/transfer_functions.h" namespace jxl { @@ -20,7 +21,7 @@ class Rec2408ToneMapperBase { public: explicit Rec2408ToneMapperBase(std::pair source_range, std::pair target_range, - const float primaries_luminances[3]) + const Vector3& primaries_luminances) : source_range_(source_range), target_range_(target_range), red_Y_(primaries_luminances[0]), @@ -28,10 +29,10 @@ class Rec2408ToneMapperBase { blue_Y_(primaries_luminances[2]) {} // TODO(eustas): test me - void ToneMap(float* red, float* green, float* blue) const { + void ToneMap(Color& rgb) const { const float luminance = source_range_.second * - (red_Y_ * *red + green_Y_ * *green + blue_Y_ * *blue); + (red_Y_ * rgb[0] + green_Y_ * rgb[1] + blue_Y_ * rgb[2]); const float normalized_pq = std::min(1.f, (InvEOTF(luminance) - pq_mastering_min_) * inv_pq_mastering_range_); @@ -49,8 +50,8 @@ class Rec2408ToneMapperBase { const float ratio = new_luminance / std::max(luminance, min_luminance); const float cap = new_luminance * inv_target_peak_; const float multiplier = ratio * normalizer_; - for (float* const val : {red, green, blue}) { - *val = use_cap ? cap : *val * multiplier; + for (size_t idx : {0, 1, 2}) { + rgb[idx] = use_cap ? cap : rgb[idx] * multiplier; } } @@ -96,23 +97,24 @@ class Rec2408ToneMapperBase { class HlgOOTF_Base { public: explicit HlgOOTF_Base(float source_luminance, float target_luminance, - const float primaries_luminances[3]) + const Vector3& primaries_luminances) : HlgOOTF_Base(/*gamma=*/std::pow(1.111f, std::log2(target_luminance / source_luminance)), primaries_luminances) {} // TODO(eustas): test me - void Apply(float* red, float* green, float* blue) const { + void Apply(Color& rgb) const { if (!apply_ootf_) return; - const float luminance = red_Y_ * *red + green_Y_ * *green + blue_Y_ * *blue; + const float luminance = + red_Y_ * rgb[0] + green_Y_ * rgb[1] + blue_Y_ * rgb[2]; const float ratio = std::min(powf(luminance, exponent_), 1e9); - *red *= ratio; - *green *= ratio; - *blue *= ratio; + rgb[0] *= ratio; + rgb[1] *= ratio; + rgb[2] *= ratio; } protected: - explicit HlgOOTF_Base(float gamma, const float luminances[3]) + explicit HlgOOTF_Base(float gamma, const Vector3& luminances) : exponent_(gamma - 1), red_Y_(luminances[0]), green_Y_(luminances[1]), @@ -124,13 +126,12 @@ class HlgOOTF_Base { const float blue_Y_; }; -static JXL_MAYBE_UNUSED void GamutMapScalar(float* red, float* green, - float* blue, - const float primaries_luminances[3], +static JXL_MAYBE_UNUSED void GamutMapScalar(Color& rgb, + const Vector3& primaries_luminances, float preserve_saturation = 0.1f) { - const float luminance = primaries_luminances[0] * *red + - primaries_luminances[1] * *green + - primaries_luminances[2] * *blue; + const float luminance = primaries_luminances[0] * rgb[0] + + primaries_luminances[1] * rgb[1] + + primaries_luminances[2] * rgb[2]; // Desaturate out-of-gamut pixels. This is done by mixing each pixel // with just enough gray of the target luminance to make all @@ -142,8 +143,8 @@ static JXL_MAYBE_UNUSED void GamutMapScalar(float* red, float* green, // done by mixing in yet more gray. That will desaturate it further. float gray_mix_saturation = 0.0f; float gray_mix_luminance = 0.0f; - for (const float* ch : {red, green, blue}) { - const float& val = *ch; + for (size_t idx : {0, 1, 2}) { + const float& val = rgb[idx]; const float val_minus_gray = val - luminance; const float inv_val_minus_gray = 1.0f / ((val_minus_gray == 0.0f) ? 1.0f : val_minus_gray); @@ -162,15 +163,14 @@ static JXL_MAYBE_UNUSED void GamutMapScalar(float* red, float* green, Clamp1((preserve_saturation * (gray_mix_saturation - gray_mix_luminance) + gray_mix_luminance), 0.0f, 1.0f); - for (float* const ch : {red, green, blue}) { - float& val = *ch; + for (size_t idx : {0, 1, 2}) { + float& val = rgb[idx]; val = gray_mix * (luminance - val) + val; } - const float max_clr = std::max({1.0f, *red, *green, *blue}); + const float max_clr = std::max({1.0f, rgb[0], rgb[1], rgb[2]}); const float normalizer = 1.0f / max_clr; - for (float* const ch : {red, green, blue}) { - float& val = *ch; - val *= normalizer; + for (size_t idx : {0, 1, 2}) { + rgb[idx] *= normalizer; } } diff --git a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping_test.cc b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping_test.cc index dda2bbb0aa..76165d26e7 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping_test.cc +++ b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping_test.cc @@ -30,17 +30,17 @@ HWY_NOINLINE void TestRec2408ToneMap() { for (size_t i = 0; i < kNumTrials; i++) { float src = 11000.0 + rng.UniformF(-150.0f, 150.0f); float tgt = 250 + rng.UniformF(-5.0f, 5.0f); - float luminances[3] = {rng.UniformF(0.2f, 0.4f), rng.UniformF(0.2f, 0.4f), - rng.UniformF(0.2f, 0.4f)}; - float rgb[3] = {rng.UniformF(0.0f, 1.0f), rng.UniformF(0.0f, 1.0f), - rng.UniformF(0.0f, 1.0f)}; + Vector3 luminances{rng.UniformF(0.2f, 0.4f), rng.UniformF(0.2f, 0.4f), + rng.UniformF(0.2f, 0.4f)}; + Color rgb{rng.UniformF(0.0f, 1.0f), rng.UniformF(0.0f, 1.0f), + rng.UniformF(0.0f, 1.0f)}; Rec2408ToneMapper tone_mapper({0, src}, {0, tgt}, luminances); auto r = Set(d, rgb[0]); auto g = Set(d, rgb[1]); auto b = Set(d, rgb[2]); tone_mapper.ToneMap(&r, &g, &b); Rec2408ToneMapperBase tone_mapper_base({0, src}, {0, tgt}, luminances); - tone_mapper_base.ToneMap(&rgb[0], &rgb[1], &rgb[2]); + tone_mapper_base.ToneMap(rgb); const float actual_r = GetLane(r); const float expected_r = rgb[0]; const float abs_err_r = std::abs(expected_r - actual_r); @@ -66,17 +66,17 @@ HWY_NOINLINE void TestHlgOotfApply() { for (size_t i = 0; i < kNumTrials; i++) { float src = 300.0 + rng.UniformF(-50.0f, 50.0f); float tgt = 80 + rng.UniformF(-5.0f, 5.0f); - float luminances[3] = {rng.UniformF(0.2f, 0.4f), rng.UniformF(0.2f, 0.4f), - rng.UniformF(0.2f, 0.4f)}; - float rgb[3] = {rng.UniformF(0.0f, 1.0f), rng.UniformF(0.0f, 1.0f), - rng.UniformF(0.0f, 1.0f)}; + Vector3 luminances{rng.UniformF(0.2f, 0.4f), rng.UniformF(0.2f, 0.4f), + rng.UniformF(0.2f, 0.4f)}; + Color rgb{rng.UniformF(0.0f, 1.0f), rng.UniformF(0.0f, 1.0f), + rng.UniformF(0.0f, 1.0f)}; HlgOOTF ootf(src, tgt, luminances); auto r = Set(d, rgb[0]); auto g = Set(d, rgb[1]); auto b = Set(d, rgb[2]); ootf.Apply(&r, &g, &b); HlgOOTF_Base ootf_base(src, tgt, luminances); - ootf_base.Apply(&rgb[0], &rgb[1], &rgb[2]); + ootf_base.Apply(rgb); const float actual_r = GetLane(r); const float expected_r = rgb[0]; const float abs_err_r = std::abs(expected_r - actual_r); @@ -101,15 +101,15 @@ HWY_NOINLINE void TestGamutMap() { HWY_FULL(float) d; for (size_t i = 0; i < kNumTrials; i++) { float preserve_saturation = rng.UniformF(0.2f, 0.4f); - float luminances[3] = {rng.UniformF(0.2f, 0.4f), rng.UniformF(0.2f, 0.4f), - rng.UniformF(0.2f, 0.4f)}; - float rgb[3] = {rng.UniformF(0.0f, 1.0f), rng.UniformF(0.0f, 1.0f), - rng.UniformF(0.0f, 1.0f)}; + Vector3 luminances{rng.UniformF(0.2f, 0.4f), rng.UniformF(0.2f, 0.4f), + rng.UniformF(0.2f, 0.4f)}; + Color rgb{rng.UniformF(0.0f, 1.0f), rng.UniformF(0.0f, 1.0f), + rng.UniformF(0.0f, 1.0f)}; auto r = Set(d, rgb[0]); auto g = Set(d, rgb[1]); auto b = Set(d, rgb[2]); GamutMap(&r, &g, &b, luminances, preserve_saturation); - GamutMapScalar(&rgb[0], &rgb[1], &rgb[2], luminances, preserve_saturation); + GamutMapScalar(rgb, luminances, preserve_saturation); const float actual_r = GetLane(r); const float expected_r = rgb[0]; const float abs_err_r = std::abs(expected_r - actual_r); diff --git a/third_party/jpeg-xl/lib/jxl/coeff_order.h b/third_party/jpeg-xl/lib/jxl/coeff_order.h index 75f6f99e9f..79c0c976c9 100644 --- a/third_party/jpeg-xl/lib/jxl/coeff_order.h +++ b/third_party/jpeg-xl/lib/jxl/coeff_order.h @@ -10,10 +10,10 @@ #include #include "lib/jxl/ac_strategy.h" +#include "lib/jxl/base/common.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/status.h" #include "lib/jxl/coeff_order_fwd.h" -#include "lib/jxl/dct_util.h" #include "lib/jxl/frame_dimensions.h" namespace jxl { @@ -21,22 +21,21 @@ namespace jxl { class BitReader; // Those offsets get multiplied by kDCTBlockSize. -static constexpr size_t kCoeffOrderOffset[] = { + +static constexpr size_t kCoeffOrderLimit = 6156; + +static constexpr std::array kCoeffOrderOffset = { 0, 1, 2, 3, 4, 5, 6, 10, 14, 18, 34, 50, 66, 68, 70, 72, 76, 80, 84, 92, 100, 108, 172, 236, 300, 332, 364, 396, 652, 908, - 1164, 1292, 1420, 1548, 2572, 3596, 4620, 5132, 5644, 6156, -}; -static_assert(3 * kNumOrders + 1 == - sizeof(kCoeffOrderOffset) / sizeof(*kCoeffOrderOffset), - "Update this array when adding or removing order types."); + 1164, 1292, 1420, 1548, 2572, 3596, 4620, 5132, 5644, kCoeffOrderLimit}; -static constexpr size_t CoeffOrderOffset(size_t order, size_t c) { - return kCoeffOrderOffset[3 * order + c] * kDCTBlockSize; -} +// TODO(eustas): rollback to constexpr once modern C++ becomes reuired. +#define CoeffOrderOffset(O, C) \ + (kCoeffOrderOffset[3 * (O) + (C)] * kDCTBlockSize) -static constexpr size_t kCoeffOrderMaxSize = - kCoeffOrderOffset[3 * kNumOrders] * kDCTBlockSize; +static JXL_MAYBE_UNUSED constexpr size_t kCoeffOrderMaxSize = + kCoeffOrderLimit * kDCTBlockSize; // Mapping from AC strategy to order bucket. Strategies with different natural // orders must have different buckets. @@ -49,7 +48,7 @@ static_assert(AcStrategy::kNumValidStrategies == sizeof(kStrategyOrder) / sizeof(*kStrategyOrder), "Update this array when adding or removing AC strategies."); -constexpr uint32_t kPermutationContexts = 8; +constexpr JXL_MAYBE_UNUSED uint32_t kPermutationContexts = 8; uint32_t CoeffOrderContext(uint32_t val); diff --git a/third_party/jpeg-xl/lib/jxl/color_encoding_internal.cc b/third_party/jpeg-xl/lib/jxl/color_encoding_internal.cc index 19273dad3c..895faaa07d 100644 --- a/third_party/jpeg-xl/lib/jxl/color_encoding_internal.cc +++ b/third_party/jpeg-xl/lib/jxl/color_encoding_internal.cc @@ -47,12 +47,12 @@ std::array ColorEncoding::CreateC2(Primaries pr, const ColorEncoding& ColorEncoding::SRGB(bool is_gray) { static std::array c2 = CreateC2(Primaries::kSRGB, TransferFunction::kSRGB); - return c2[is_gray]; + return c2[is_gray ? 1 : 0]; } const ColorEncoding& ColorEncoding::LinearSRGB(bool is_gray) { static std::array c2 = CreateC2(Primaries::kSRGB, TransferFunction::kLinear); - return c2[is_gray]; + return c2[is_gray ? 1 : 0]; } Status ColorEncoding::SetWhitePointType(const WhitePoint& wp) { diff --git a/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h b/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h index 0a104a12b2..61e4628dbd 100644 --- a/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h +++ b/third_party/jpeg-xl/lib/jxl/color_encoding_internal.h @@ -314,7 +314,6 @@ class ColorSpaceTransform { Status Init(const ColorEncoding& c_src, const ColorEncoding& c_dst, float intensity_target, size_t xsize, size_t num_threads) { - xsize_ = xsize; JxlColorProfile input_profile; icc_src_ = c_src.ICC(); input_profile.icc.data = icc_src_.data(); @@ -343,8 +342,10 @@ class ColorSpaceTransform { return cms_.get_dst_buf(cms_data_, thread); } - Status Run(const size_t thread, const float* buf_src, float* buf_dst) { - return cms_.run(cms_data_, thread, buf_src, buf_dst, xsize_); + Status Run(const size_t thread, const float* buf_src, float* buf_dst, + size_t xsize) { + // TODO(eustas): convert false to Status? + return FROM_JXL_BOOL(cms_.run(cms_data_, thread, buf_src, buf_dst, xsize)); } private: @@ -353,7 +354,6 @@ class ColorSpaceTransform { // The interface may retain pointers into these. IccBytes icc_src_; IccBytes icc_dst_; - size_t xsize_; }; } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc b/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc index 4d2d3e8119..2a9f60427a 100644 --- a/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc +++ b/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc @@ -97,24 +97,29 @@ TEST(ColorEncodingTest, InternalExternalConversion) { ColorEncoding source_internal; ColorEncoding destination_internal; + const auto rand_float = []() { + return (static_cast(rand()) / static_cast(RAND_MAX) * 0.5) + + 0.25; + }; + for (int i = 0; i < 100; i++) { source_internal.color_space = static_cast(rand() % 4); CIExy wp; - wp.x = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; - wp.y = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; + wp.x = rand_float(); + wp.y = rand_float(); EXPECT_TRUE(source_internal.SetWhitePoint(wp)); if (source_internal.HasPrimaries()) { PrimariesCIExy primaries; - primaries.r.x = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; - primaries.r.y = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; - primaries.g.x = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; - primaries.g.y = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; - primaries.b.x = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; - primaries.b.y = (float(rand()) / float((RAND_MAX)) * 0.5) + 0.25; + primaries.r.x = rand_float(); + primaries.r.y = rand_float(); + primaries.g.x = rand_float(); + primaries.g.y = rand_float(); + primaries.b.x = rand_float(); + primaries.b.y = rand_float(); EXPECT_TRUE(source_internal.SetPrimaries(primaries)); } jxl::cms::CustomTransferFunction tf; - EXPECT_TRUE(tf.SetGamma((float(rand()) / float((RAND_MAX)) * 0.5) + 0.25)); + EXPECT_TRUE(tf.SetGamma(rand_float())); source_internal.tf = tf; source_internal.rendering_intent = static_cast(rand() % 4); diff --git a/third_party/jpeg-xl/lib/jxl/color_management_test.cc b/third_party/jpeg-xl/lib/jxl/color_management_test.cc index ca50c9960e..b2d47c73f9 100644 --- a/third_party/jpeg-xl/lib/jxl/color_management_test.cc +++ b/third_party/jpeg-xl/lib/jxl/color_management_test.cc @@ -45,55 +45,10 @@ std::ostream& operator<<(std::ostream& os, const PrimariesCIExy& primaries) { namespace { -using ::testing::ElementsAre; -using ::testing::FloatNear; - // Small enough to be fast. If changed, must update Generate*. -static constexpr size_t kWidth = 16; - -static constexpr size_t kNumThreads = 1; // only have a single row. +constexpr size_t kWidth = 16; -MATCHER_P(HasSameFieldsAs, expected, "") { - if (arg.GetRenderingIntent() != expected.GetRenderingIntent()) { - *result_listener << "which has a different rendering intent: " - << ToString(arg.GetRenderingIntent()) << " instead of " - << ToString(expected.GetRenderingIntent()); - return false; - } - if (arg.GetColorSpace() != expected.GetColorSpace()) { - *result_listener << "which has a different color space: " - << ToString(arg.GetColorSpace()) << " instead of " - << ToString(expected.GetColorSpace()); - return false; - } - if (arg.GetWhitePointType() != expected.GetWhitePointType()) { - *result_listener << "which has a different white point: " - << ToString(arg.GetWhitePointType()) << " instead of " - << ToString(expected.GetWhitePointType()); - return false; - } - if (arg.HasPrimaries() && - arg.GetPrimariesType() != expected.GetPrimariesType()) { - *result_listener << "which has different primaries: " - << ToString(arg.GetPrimariesType()) << " instead of " - << ToString(expected.GetPrimariesType()); - return false; - } - if (!arg.Tf().IsSame(expected.Tf())) { - static const auto tf_to_string = - [](const jxl::cms::CustomTransferFunction& tf) { - if (tf.have_gamma) { - return "g" + ToString(tf.GetGamma()); - } - return ToString(tf.transfer_function); - }; - *result_listener << "which has a different transfer function: " - << tf_to_string(arg.Tf()) << " instead of " - << tf_to_string(expected.Tf()); - return false; - } - return true; -} +constexpr size_t kNumThreads = 1; // only have a single row. struct Globals { // TODO(deymo): Make this a const. @@ -106,15 +61,15 @@ struct Globals { Globals() { in_gray = GenerateGray(); in_color = GenerateColor(); - out_gray = ImageF(kWidth, 1); - out_color = ImageF(kWidth * 3, 1); + JXL_ASSIGN_OR_DIE(out_gray, ImageF::Create(kWidth, 1)); + JXL_ASSIGN_OR_DIE(out_color, ImageF::Create(kWidth * 3, 1)); c_native = ColorEncoding::LinearSRGB(/*is_gray=*/false); c_gray = ColorEncoding::LinearSRGB(/*is_gray=*/true); } static ImageF GenerateGray() { - ImageF gray(kWidth, 1); + JXL_ASSIGN_OR_DIE(ImageF gray, ImageF::Create(kWidth, 1)); float* JXL_RESTRICT row = gray.Row(0); // Increasing left to right for (uint32_t x = 0; x < kWidth; ++x) { @@ -124,7 +79,7 @@ struct Globals { } static ImageF GenerateColor() { - ImageF image(kWidth * 3, 1); + JXL_ASSIGN_OR_DIE(ImageF image, ImageF::Create(kWidth * 3, 1)); float* JXL_RESTRICT interleaved = image.Row(0); std::fill(interleaved, interleaved + kWidth * 3, 0.0f); @@ -182,8 +137,10 @@ class ColorManagementTest const size_t thread = 0; const ImageF& in = c.IsGray() ? g->in_gray : g->in_color; ImageF* JXL_RESTRICT out = c.IsGray() ? &g->out_gray : &g->out_color; - ASSERT_TRUE(xform_fwd.Run(thread, in.Row(0), xform_fwd.BufDst(thread))); - ASSERT_TRUE(xform_rev.Run(thread, xform_fwd.BufDst(thread), out->Row(0))); + ASSERT_TRUE( + xform_fwd.Run(thread, in.Row(0), xform_fwd.BufDst(thread), kWidth)); + ASSERT_TRUE( + xform_rev.Run(thread, xform_fwd.BufDst(thread), out->Row(0), kWidth)); // With lcms2, this value is lower: 5E-5 double max_l1 = 7E-4; @@ -200,77 +157,108 @@ JXL_GTEST_INSTANTIATE_TEST_SUITE_P(ColorManagementTestInstantiation, // Exercises the ColorManagement interface for ALL ColorEncoding synthesizable // via enums. TEST_P(ColorManagementTest, VerifyAllProfiles) { - ColorEncoding c = ColorEncodingFromDescriptor(GetParam()); - printf("%s\n", Description(c).c_str()); + ColorEncoding actual = ColorEncodingFromDescriptor(GetParam()); + printf("%s\n", Description(actual).c_str()); // Can create profile. - ASSERT_TRUE(c.CreateICC()); + ASSERT_TRUE(actual.CreateICC()); // Can set an equivalent ColorEncoding from the generated ICC profile. - ColorEncoding c3; - ASSERT_TRUE(c3.SetICC(IccBytes(c.ICC()), JxlGetDefaultCms())); - EXPECT_THAT(c3, HasSameFieldsAs(c)); + ColorEncoding expected; + ASSERT_TRUE(expected.SetICC(IccBytes(actual.ICC()), JxlGetDefaultCms())); + + EXPECT_EQ(actual.GetRenderingIntent(), expected.GetRenderingIntent()) + << "different rendering intent: " << ToString(actual.GetRenderingIntent()) + << " instead of " << ToString(expected.GetRenderingIntent()); + EXPECT_EQ(actual.GetColorSpace(), expected.GetColorSpace()) + << "different color space: " << ToString(actual.GetColorSpace()) + << " instead of " << ToString(expected.GetColorSpace()); + EXPECT_EQ(actual.GetWhitePointType(), expected.GetWhitePointType()) + << "different white point: " << ToString(actual.GetWhitePointType()) + << " instead of " << ToString(expected.GetWhitePointType()); + EXPECT_EQ(actual.HasPrimaries(), expected.HasPrimaries()); + if (actual.HasPrimaries()) { + EXPECT_EQ(actual.GetPrimariesType(), expected.GetPrimariesType()) + << "different primaries: " << ToString(actual.GetPrimariesType()) + << " instead of " << ToString(expected.GetPrimariesType()); + } - VerifyPixelRoundTrip(c); -} + static const auto tf_to_string = + [](const jxl::cms::CustomTransferFunction& tf) { + if (tf.have_gamma) { + return "g" + ToString(tf.GetGamma()); + } + return ToString(tf.transfer_function); + }; + EXPECT_TRUE(actual.Tf().IsSame(expected.Tf())) + << "different transfer function: " << tf_to_string(actual.Tf()) + << " instead of " << tf_to_string(expected.Tf()); -testing::Matcher CIExyIs(const double x, const double y) { - static constexpr double kMaxError = 1e-4; - return testing::AllOf( - testing::Field(&CIExy::x, testing::DoubleNear(x, kMaxError)), - testing::Field(&CIExy::y, testing::DoubleNear(y, kMaxError))); + VerifyPixelRoundTrip(actual); } -testing::Matcher PrimariesAre( - const testing::Matcher& r, const testing::Matcher& g, - const testing::Matcher& b) { - return testing::AllOf(testing::Field(&PrimariesCIExy::r, r), - testing::Field(&PrimariesCIExy::g, g), - testing::Field(&PrimariesCIExy::b, b)); -} +#define EXPECT_CIEXY_NEAR(A, E, T) \ + { \ + CIExy _actual = (A); \ + CIExy _expected = (E); \ + double _tolerance = (T); \ + EXPECT_NEAR(_actual.x, _expected.x, _tolerance) << "x is different"; \ + EXPECT_NEAR(_actual.y, _expected.y, _tolerance) << "y is different"; \ + } + +#define EXPECT_PRIMARIES_NEAR(A, E, T) \ + { \ + PrimariesCIExy _actual = (A); \ + PrimariesCIExy _expected = (E); \ + double _tolerance = (T); \ + EXPECT_NEAR(_actual.r.x, _expected.r.x, _tolerance) << "r.x is different"; \ + EXPECT_NEAR(_actual.r.y, _expected.r.y, _tolerance) << "r.y is different"; \ + EXPECT_NEAR(_actual.g.x, _expected.g.x, _tolerance) << "g.x is different"; \ + EXPECT_NEAR(_actual.g.y, _expected.g.y, _tolerance) << "g.y is different"; \ + EXPECT_NEAR(_actual.b.x, _expected.b.x, _tolerance) << "b.x is different"; \ + EXPECT_NEAR(_actual.b.y, _expected.b.y, _tolerance) << "b.y is different"; \ + } TEST_F(ColorManagementTest, sRGBChromaticity) { const ColorEncoding sRGB = ColorEncoding::SRGB(); - EXPECT_THAT(sRGB.GetWhitePoint(), CIExyIs(0.3127, 0.3290)); - EXPECT_THAT(sRGB.GetPrimaries(), - PrimariesAre(CIExyIs(0.64, 0.33), CIExyIs(0.30, 0.60), - CIExyIs(0.15, 0.06))); + EXPECT_CIEXY_NEAR(sRGB.GetWhitePoint(), CIExy(0.3127, 0.3290), 1e-4); + PrimariesCIExy srgb_primaries = {{0.64, 0.33}, {0.30, 0.60}, {0.15, 0.06}}; + EXPECT_PRIMARIES_NEAR(sRGB.GetPrimaries(), srgb_primaries, 1e-4); } TEST_F(ColorManagementTest, D2700Chromaticity) { std::vector icc_data = jxl::test::ReadTestData("jxl/color_management/sRGB-D2700.icc"); IccBytes icc; - Bytes(icc_data).AppendTo(&icc); + Bytes(icc_data).AppendTo(icc); ColorEncoding sRGB_D2700; ASSERT_TRUE(sRGB_D2700.SetICC(std::move(icc), JxlGetDefaultCms())); - EXPECT_THAT(sRGB_D2700.GetWhitePoint(), CIExyIs(0.45986, 0.41060)); + EXPECT_CIEXY_NEAR(sRGB_D2700.GetWhitePoint(), CIExy(0.45986, 0.41060), 1e-4); // The illuminant-relative chromaticities of this profile's primaries are the // same as for sRGB. It is the PCS-relative chromaticities that would be // different. - EXPECT_THAT(sRGB_D2700.GetPrimaries(), - PrimariesAre(CIExyIs(0.64, 0.33), CIExyIs(0.30, 0.60), - CIExyIs(0.15, 0.06))); + PrimariesCIExy srgb_primaries = {{0.64, 0.33}, {0.30, 0.60}, {0.15, 0.06}}; + EXPECT_PRIMARIES_NEAR(sRGB_D2700.GetPrimaries(), srgb_primaries, 1e-4); } TEST_F(ColorManagementTest, D2700ToSRGB) { std::vector icc_data = jxl::test::ReadTestData("jxl/color_management/sRGB-D2700.icc"); IccBytes icc; - Bytes(icc_data).AppendTo(&icc); + Bytes(icc_data).AppendTo(icc); ColorEncoding sRGB_D2700; ASSERT_TRUE(sRGB_D2700.SetICC(std::move(icc), JxlGetDefaultCms())); ColorSpaceTransform transform(*JxlGetDefaultCms()); ASSERT_TRUE(transform.Init(sRGB_D2700, ColorEncoding::SRGB(), kDefaultIntensityTarget, 1, 1)); - const float sRGB_D2700_values[3] = {0.863, 0.737, 0.490}; - float sRGB_values[3]; - ASSERT_TRUE(transform.Run(0, sRGB_D2700_values, sRGB_values)); - EXPECT_THAT(sRGB_values, - ElementsAre(FloatNear(0.914, 1e-3), FloatNear(0.745, 1e-3), - FloatNear(0.601, 1e-3))); + Color sRGB_D2700_values{0.863, 0.737, 0.490}; + Color sRGB_values; + ASSERT_TRUE( + transform.Run(0, sRGB_D2700_values.data(), sRGB_values.data(), 1)); + Color sRGB_expected{0.914, 0.745, 0.601}; + EXPECT_ARRAY_NEAR(sRGB_values, sRGB_expected, 1e-3); } TEST_F(ColorManagementTest, P3HlgTo2020Hlg) { @@ -287,12 +275,12 @@ TEST_F(ColorManagementTest, P3HlgTo2020Hlg) { ColorSpaceTransform transform(*JxlGetDefaultCms()); ASSERT_TRUE(transform.Init(p3_hlg, rec2020_hlg, 1000, 1, 1)); - const float p3_hlg_values[3] = {0., 0.75, 0.}; - float rec2020_hlg_values[3]; - ASSERT_TRUE(transform.Run(0, p3_hlg_values, rec2020_hlg_values)); - EXPECT_THAT(rec2020_hlg_values, - ElementsAre(FloatNear(0.3973, 1e-4), FloatNear(0.7382, 1e-4), - FloatNear(0.1183, 1e-4))); + Color p3_hlg_values{0., 0.75, 0.}; + Color rec2020_hlg_values; + ASSERT_TRUE( + transform.Run(0, p3_hlg_values.data(), rec2020_hlg_values.data(), 1)); + Color rec2020_hlg_expected{0.3973, 0.7382, 0.1183}; + EXPECT_ARRAY_NEAR(rec2020_hlg_values, rec2020_hlg_expected, 1e-4); } TEST_F(ColorManagementTest, HlgOotf) { @@ -307,38 +295,34 @@ TEST_F(ColorManagementTest, HlgOotf) { ASSERT_TRUE( transform_to_1000.Init(p3_hlg, ColorEncoding::LinearSRGB(), 1000, 1, 1)); // HDR reference white: https://www.itu.int/pub/R-REP-BT.2408-4-2021 - float p3_hlg_values[3] = {0.75, 0.75, 0.75}; - float linear_srgb_values[3]; - ASSERT_TRUE(transform_to_1000.Run(0, p3_hlg_values, linear_srgb_values)); + Color p3_hlg_values{0.75, 0.75, 0.75}; + Color linear_srgb_values; + ASSERT_TRUE(transform_to_1000.Run(0, p3_hlg_values.data(), + linear_srgb_values.data(), 1)); // On a 1000-nit display, HDR reference white should be 203 cd/m² which is // 0.203 times the maximum. - EXPECT_THAT(linear_srgb_values, - ElementsAre(FloatNear(0.203, 1e-3), FloatNear(0.203, 1e-3), - FloatNear(0.203, 1e-3))); + EXPECT_ARRAY_NEAR(linear_srgb_values, (Color{0.203, 0.203, 0.203}), 1e-3); ColorSpaceTransform transform_to_400(*JxlGetDefaultCms()); ASSERT_TRUE( transform_to_400.Init(p3_hlg, ColorEncoding::LinearSRGB(), 400, 1, 1)); - ASSERT_TRUE(transform_to_400.Run(0, p3_hlg_values, linear_srgb_values)); + ASSERT_TRUE(transform_to_400.Run(0, p3_hlg_values.data(), + linear_srgb_values.data(), 1)); // On a 400-nit display, it should be 100 cd/m². - EXPECT_THAT(linear_srgb_values, - ElementsAre(FloatNear(0.250, 1e-3), FloatNear(0.250, 1e-3), - FloatNear(0.250, 1e-3))); + EXPECT_ARRAY_NEAR(linear_srgb_values, (Color{0.250, 0.250, 0.250}), 1e-3); p3_hlg_values[2] = 0.50; - ASSERT_TRUE(transform_to_1000.Run(0, p3_hlg_values, linear_srgb_values)); - EXPECT_THAT(linear_srgb_values, - ElementsAre(FloatNear(0.201, 1e-3), FloatNear(0.201, 1e-3), - FloatNear(0.050, 1e-3))); + ASSERT_TRUE(transform_to_1000.Run(0, p3_hlg_values.data(), + linear_srgb_values.data(), 1)); + EXPECT_ARRAY_NEAR(linear_srgb_values, (Color{0.201, 0.201, 0.050}), 1e-3); ColorSpaceTransform transform_from_400(*JxlGetDefaultCms()); ASSERT_TRUE( transform_from_400.Init(ColorEncoding::LinearSRGB(), p3_hlg, 400, 1, 1)); linear_srgb_values[0] = linear_srgb_values[1] = linear_srgb_values[2] = 0.250; - ASSERT_TRUE(transform_from_400.Run(0, linear_srgb_values, p3_hlg_values)); - EXPECT_THAT(p3_hlg_values, - ElementsAre(FloatNear(0.75, 1e-3), FloatNear(0.75, 1e-3), - FloatNear(0.75, 1e-3))); + ASSERT_TRUE(transform_from_400.Run(0, linear_srgb_values.data(), + p3_hlg_values.data(), 1)); + EXPECT_ARRAY_NEAR(p3_hlg_values, (Color{0.75, 0.75, 0.75}), 1e-3); ColorEncoding grayscale_hlg; grayscale_hlg.SetColorSpace(ColorSpace::kGray); @@ -352,8 +336,8 @@ TEST_F(ColorManagementTest, HlgOotf) { const float grayscale_hlg_value = 0.75; float linear_grayscale_value; ASSERT_TRUE(grayscale_transform.Run(0, &grayscale_hlg_value, - &linear_grayscale_value)); - EXPECT_THAT(linear_grayscale_value, FloatNear(0.203, 1e-3)); + &linear_grayscale_value, 1)); + EXPECT_NEAR(linear_grayscale_value, 0.203, 1e-3); } TEST_F(ColorManagementTest, XYBProfile) { @@ -373,7 +357,7 @@ TEST_F(ColorManagementTest, XYBProfile) { ImageMetadata metadata; metadata.color_encoding = c_native; ImageBundle ib(&metadata); - Image3F native(kNumColors, 1); + JXL_ASSIGN_OR_DIE(Image3F native, Image3F::Create(kNumColors, 1)); float mul = 1.0f / (kGridDim - 1); for (size_t ir = 0, x = 0; ir < kGridDim; ++ir) { for (size_t ig = 0; ig < kGridDim; ++ig) { @@ -386,10 +370,10 @@ TEST_F(ColorManagementTest, XYBProfile) { } ib.SetFromImage(std::move(native), c_native); const Image3F& in = *ib.color(); - Image3F opsin(kNumColors, 1); - ToXYB(ib, nullptr, &opsin, cms, nullptr); + JXL_ASSIGN_OR_DIE(Image3F opsin, Image3F::Create(kNumColors, 1)); + JXL_CHECK(ToXYB(ib, nullptr, &opsin, cms, nullptr)); - Image3F opsin2(kNumColors, 1); + JXL_ASSIGN_OR_DIE(Image3F opsin2, Image3F::Create(kNumColors, 1)); CopyImageTo(opsin, &opsin2); ScaleXYB(&opsin2); @@ -401,9 +385,9 @@ TEST_F(ColorManagementTest, XYBProfile) { } float* dst = xform.BufDst(0); - ASSERT_TRUE(xform.Run(0, src, dst)); + ASSERT_TRUE(xform.Run(0, src, dst, kNumColors)); - Image3F out(kNumColors, 1); + JXL_ASSIGN_OR_DIE(Image3F out, Image3F::Create(kNumColors, 1)); for (size_t i = 0; i < kNumColors; ++i) { for (size_t c = 0; c < 3; ++c) { out.PlaneRow(c, 0)[i] = dst[3 * i + c]; diff --git a/third_party/jpeg-xl/lib/jxl/common.h b/third_party/jpeg-xl/lib/jxl/common.h index d619711c9f..d593244433 100644 --- a/third_party/jpeg-xl/lib/jxl/common.h +++ b/third_party/jpeg-xl/lib/jxl/common.h @@ -33,6 +33,38 @@ constexpr size_t kMaxNumPasses = 11; // Maximum number of reference frames. constexpr size_t kMaxNumReferenceFrames = 4; +enum class SpeedTier { + // Try multiple combinations of Glacier flags for modular mode. Otherwise + // like kGlacier. + kTectonicPlate = -1, + // Learn a global tree in Modular mode. + kGlacier = 0, + // Turns on FindBestQuantizationHQ loop. Equivalent to "guetzli" mode. + kTortoise = 1, + // Turns on FindBestQuantization butteraugli loop. + kKitten = 2, + // Turns on dots, patches, and spline detection by default, as well as full + // context clustering. Default. + kSquirrel = 3, + // Turns on error diffusion and full AC strategy heuristics. Equivalent to + // "fast" mode. + kWombat = 4, + // Turns on gaborish by default, non-default cmap, initial quant field. + kHare = 5, + // Turns on simple heuristics for AC strategy, quant field, and clustering; + // also enables coefficient reordering. + kCheetah = 6, + // Turns off most encoder features. Does context clustering. + // Modular: uses fixed tree with Weighted predictor. + kFalcon = 7, + // Currently fastest possible setting for VarDCT. + // Modular: uses fixed tree with Gradient predictor. + kThunder = 8, + // VarDCT: same as kThunder. + // Modular: no tree, Gradient predictor, fast histograms + kLightning = 9 +}; + } // namespace jxl #endif // LIB_JXL_COMMON_H_ diff --git a/third_party/jpeg-xl/lib/jxl/compressed_dc.cc b/third_party/jpeg-xl/lib/jxl/compressed_dc.cc index b21b1da18b..250be9e9a6 100644 --- a/third_party/jpeg-xl/lib/jxl/compressed_dc.cc +++ b/third_party/jpeg-xl/lib/jxl/compressed_dc.cc @@ -10,9 +10,6 @@ #include #include -#include -#include -#include #include #undef HWY_TARGET_INCLUDE @@ -21,17 +18,9 @@ #include #include -#include "lib/jxl/ac_strategy.h" -#include "lib/jxl/ans_params.h" -#include "lib/jxl/base/bits.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/chroma_from_luma.h" -#include "lib/jxl/dec_ans.h" -#include "lib/jxl/dec_bit_reader.h" -#include "lib/jxl/dec_cache.h" -#include "lib/jxl/entropy_coder.h" #include "lib/jxl/image.h" HWY_BEFORE_NAMESPACE(); namespace jxl { @@ -131,21 +120,21 @@ JXL_INLINE void ComputePixel( Store(out, d, out_rows[2] + x); } -void AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, - ThreadPool* pool) { +Status AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, + ThreadPool* pool) { const size_t xsize = dc->xsize(); const size_t ysize = dc->ysize(); - if (ysize <= 2 || xsize <= 2) return; + if (ysize <= 2 || xsize <= 2) return true; // TODO(veluca): use tile-based processing? // TODO(veluca): decide if changes to the y channel should be propagated to // the x and b channels through color correlation. JXL_ASSERT(w1 + w2 < 0.25f); - Image3F smoothed(xsize, ysize); + JXL_ASSIGN_OR_RETURN(Image3F smoothed, Image3F::Create(xsize, ysize)); // Fill in borders that the loop below will not. First and last are unused. for (size_t c = 0; c < 3; c++) { - for (size_t y : {size_t(0), ysize - 1}) { + for (size_t y : {static_cast(0), ysize - 1}) { memcpy(smoothed.PlaneRow(c, y), dc->PlaneRow(c, y), xsize * sizeof(float)); } @@ -171,7 +160,7 @@ void AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, smoothed.PlaneRow(1, y), smoothed.PlaneRow(2, y), }; - for (size_t x : {size_t(0), xsize - 1}) { + for (size_t x : {static_cast(0), xsize - 1}) { for (size_t c = 0; c < 3; c++) { rows_out[c][x] = rows[c][x]; } @@ -197,12 +186,13 @@ void AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, JXL_CHECK(RunOnPool(pool, 1, ysize - 1, ThreadPool::NoInit, process_row, "DCSmoothingRow")); dc->Swap(smoothed); + return true; } // DC dequantization. void DequantDC(const Rect& r, Image3F* dc, ImageB* quant_dc, const Image& in, const float* dc_factors, float mul, const float* cfl_factors, - YCbCrChromaSubsampling chroma_subsampling, + const YCbCrChromaSubsampling& chroma_subsampling, const BlockCtxMap& bctx) { const HWY_FULL(float) df; const Rebind di; // assumes pixel_type <= float @@ -265,7 +255,9 @@ void DequantDC(const Rect& r, Image3F* dc, ImageB* quant_dc, const Image& in, const int32_t* quant_row_b = in.channel[2].plane.Row(y >> chroma_subsampling.VShift(2)); for (size_t x = 0; x < r.xsize(); x++) { - int bucket_x = 0, bucket_y = 0, bucket_b = 0; + int bucket_x = 0; + int bucket_y = 0; + int bucket_b = 0; for (int t : bctx.dc_thresholds[0]) { if (quant_row_x[x >> chroma_subsampling.HShift(0)] > t) bucket_x++; } @@ -296,17 +288,17 @@ namespace jxl { HWY_EXPORT(DequantDC); HWY_EXPORT(AdaptiveDCSmoothing); -void AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, - ThreadPool* pool) { +Status AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, + ThreadPool* pool) { return HWY_DYNAMIC_DISPATCH(AdaptiveDCSmoothing)(dc_factors, dc, pool); } void DequantDC(const Rect& r, Image3F* dc, ImageB* quant_dc, const Image& in, const float* dc_factors, float mul, const float* cfl_factors, - YCbCrChromaSubsampling chroma_subsampling, + const YCbCrChromaSubsampling& chroma_subsampling, const BlockCtxMap& bctx) { - return HWY_DYNAMIC_DISPATCH(DequantDC)(r, dc, quant_dc, in, dc_factors, mul, - cfl_factors, chroma_subsampling, bctx); + HWY_DYNAMIC_DISPATCH(DequantDC) + (r, dc, quant_dc, in, dc_factors, mul, cfl_factors, chroma_subsampling, bctx); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/compressed_dc.h b/third_party/jpeg-xl/lib/jxl/compressed_dc.h index b06e5931f0..30259ebd56 100644 --- a/third_party/jpeg-xl/lib/jxl/compressed_dc.h +++ b/third_party/jpeg-xl/lib/jxl/compressed_dc.h @@ -21,12 +21,12 @@ namespace jxl { // Smooth DC in already-smooth areas, to counteract banding. -void AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, - ThreadPool* pool); +Status AdaptiveDCSmoothing(const float* dc_factors, Image3F* dc, + ThreadPool* pool); void DequantDC(const Rect& r, Image3F* dc, ImageB* quant_dc, const Image& in, const float* dc_factors, float mul, const float* cfl_factors, - YCbCrChromaSubsampling chroma_subsampling, + const YCbCrChromaSubsampling& chroma_subsampling, const BlockCtxMap& bctx); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/convolve-inl.h b/third_party/jpeg-xl/lib/jxl/convolve-inl.h index cd79153a3a..949fd8ad67 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve-inl.h +++ b/third_party/jpeg-xl/lib/jxl/convolve-inl.h @@ -118,7 +118,7 @@ class Neighbors { // Returns indices for SetTableIndices such that TableLookupLanes on the // rightmost unaligned vector (rightmost sample in its most-significant lane) // returns the mirrored values, with the mirror outside the last valid sample. -static inline const int32_t* MirrorLanes(const size_t mod) { +inline const int32_t* MirrorLanes(const size_t mod) { const HWY_CAPPED(float, 16) d; constexpr size_t kN = MaxLanes(d); @@ -181,7 +181,7 @@ class ConvolveT { JXL_CHECK(SameSize(rect, *out)); JXL_CHECK(rect.xsize() >= MinWidth()); - static_assert(int64_t(kRadius) <= 3, + static_assert(static_cast(kRadius) <= 3, "Must handle [0, kRadius) and >= kRadius"); switch (rect.xsize() % Lanes(Simd())) { case 0: @@ -273,15 +273,17 @@ class ConvolveT { const Weights& weights, ThreadPool* pool, Image* out) { const int64_t ysize = rect.ysize(); - RunBorderRows(in, rect, 0, std::min(int64_t(kRadius), ysize), + RunBorderRows(in, rect, 0, + std::min(static_cast(kRadius), ysize), weights, out); - if (ysize > 2 * int64_t(kRadius)) { - RunInteriorRows(in, rect, int64_t(kRadius), - ysize - int64_t(kRadius), weights, pool, out); + if (ysize > 2 * static_cast(kRadius)) { + RunInteriorRows(in, rect, static_cast(kRadius), + ysize - static_cast(kRadius), weights, + pool, out); } - if (ysize > int64_t(kRadius)) { - RunBorderRows(in, rect, ysize - int64_t(kRadius), ysize, - weights, out); + if (ysize > static_cast(kRadius)) { + RunBorderRows(in, rect, ysize - static_cast(kRadius), + ysize, weights, out); } } }; diff --git a/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc b/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc index db533606a1..ae618b9990 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc +++ b/third_party/jpeg-xl/lib/jxl/convolve_separable5.cc @@ -185,7 +185,8 @@ class Separable5Strategy { const V l1 = LoadU(d, row + x - 1); const V l2 = LoadU(d, row + x - 2); - V r1, r2; + V r1; + V r2; #if HWY_TARGET == HWY_SCALAR r1 = LoadU(d, row + Mirror(x + 1, xsize)); r2 = LoadU(d, row + Mirror(x + 2, xsize)); @@ -236,10 +237,11 @@ void Separable5(const ImageF& in, const Rect& rect, ImageF* out) { using Conv = ConvolveT; if (rect.xsize() >= Conv::MinWidth()) { - return Conv::Run(in, rect, weights, pool, out); + Conv::Run(in, rect, weights, pool, out); + return; } - return SlowSeparable5(in, rect, weights, pool, out, Rect(*out)); + SlowSeparable5(in, rect, weights, pool, out, Rect(*out)); } // NOLINTNEXTLINE(google-readability-namespace-comments) @@ -254,7 +256,7 @@ HWY_EXPORT(Separable5); void Separable5(const ImageF& in, const Rect& rect, const WeightsSeparable5& weights, ThreadPool* pool, ImageF* out) { - return HWY_DYNAMIC_DISPATCH(Separable5)(in, rect, weights, pool, out); + HWY_DYNAMIC_DISPATCH(Separable5)(in, rect, weights, pool, out); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc b/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc index 06b59dfb60..618ad03a86 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc +++ b/third_party/jpeg-xl/lib/jxl/convolve_symmetric3.cc @@ -93,7 +93,9 @@ class Symmetric3Strategy { const V mc = LoadU(d, row_m + x); const V bc = LoadU(d, row_b + x); - V tr, mr, br; + V tr; + V mr; + V br; #if HWY_TARGET == HWY_SCALAR tr = tc; // Single-lane => mirrored right neighbor = center value. mr = mc; @@ -169,10 +171,11 @@ void Symmetric3(const ImageF& in, const Rect& rect, ImageF* out) { using Conv = ConvolveT; if (rect.xsize() >= Conv::MinWidth()) { - return Conv::Run(in, rect, weights, pool, out); + Conv::Run(in, rect, weights, pool, out); + return; } - return SlowSymmetric3(in, rect, weights, pool, out); + SlowSymmetric3(in, rect, weights, pool, out); } // NOLINTNEXTLINE(google-readability-namespace-comments) @@ -187,7 +190,7 @@ HWY_EXPORT(Symmetric3); void Symmetric3(const ImageF& in, const Rect& rect, const WeightsSymmetric3& weights, ThreadPool* pool, ImageF* out) { - return HWY_DYNAMIC_DISPATCH(Symmetric3)(in, rect, weights, pool, out); + HWY_DYNAMIC_DISPATCH(Symmetric3)(in, rect, weights, pool, out); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc b/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc index 2e203fd08f..7ed384894e 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc +++ b/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc @@ -175,14 +175,13 @@ HWY_EXPORT(Symmetric5); void Symmetric5(const ImageF& in, const Rect& in_rect, const WeightsSymmetric5& weights, ThreadPool* pool, ImageF* JXL_RESTRICT out, const Rect& out_rect) { - return HWY_DYNAMIC_DISPATCH(Symmetric5)(in, in_rect, weights, pool, out, - out_rect); + HWY_DYNAMIC_DISPATCH(Symmetric5)(in, in_rect, weights, pool, out, out_rect); } void Symmetric5(const ImageF& in, const Rect& rect, const WeightsSymmetric5& weights, ThreadPool* pool, ImageF* JXL_RESTRICT out) { - return Symmetric5(in, rect, weights, pool, out, Rect(*out)); + Symmetric5(in, rect, weights, pool, out, Rect(*out)); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/convolve_test.cc b/third_party/jpeg-xl/lib/jxl/convolve_test.cc index 6a8dc9c400..09cbdc12a6 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve_test.cc +++ b/third_party/jpeg-xl/lib/jxl/convolve_test.cc @@ -5,6 +5,7 @@ #include "lib/jxl/convolve.h" +#include #include #undef HWY_TARGET_INCLUDE @@ -68,11 +69,11 @@ void VerifySymmetric3(const size_t xsize, const size_t ysize, ThreadPool* pool, Rng* rng) { const Rect rect(0, 0, xsize, ysize); - ImageF in(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF in, ImageF::Create(xsize, ysize)); GenerateImage(*rng, &in, 0.0f, 1.0f); - ImageF out_expected(xsize, ysize); - ImageF out_actual(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF out_expected, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_DIE(ImageF out_actual, ImageF::Create(xsize, ysize)); const WeightsSymmetric3& weights = WeightsSymmetric3Lowpass(); Symmetric3(in, rect, weights, pool, &out_expected); @@ -86,7 +87,7 @@ std::vector GenerateTestRectangles(size_t xsize, size_t ysize) { for (size_t tl : {0, 1, 13}) { for (size_t br : {0, 1, 13}) { if (xsize > tl + br && ysize > tl + br) { - out.push_back(Rect(tl, tl, xsize - tl - br, ysize - tl - br)); + out.emplace_back(tl, tl, xsize - tl - br, ysize - tl - br); } } } @@ -96,7 +97,7 @@ std::vector GenerateTestRectangles(size_t xsize, size_t ysize) { // Ensures Symmetric and Separable give the same result. void VerifySymmetric5(const size_t xsize, const size_t ysize, ThreadPool* pool, Rng* rng) { - ImageF in(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF in, ImageF::Create(xsize, ysize)); GenerateImage(*rng, &in, 0.0f, 1.0f); for (const Rect& in_rect : GenerateTestRectangles(xsize, ysize)) { @@ -105,8 +106,8 @@ void VerifySymmetric5(const size_t xsize, const size_t ysize, ThreadPool* pool, in_rect.xsize(), in_rect.ysize(), in_rect.x0(), in_rect.y0()); { Rect out_rect = in_rect; - ImageF out_expected(xsize, ysize); - ImageF out_actual(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF out_expected, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_DIE(ImageF out_actual, ImageF::Create(xsize, ysize)); FillImage(-1.0f, &out_expected); FillImage(-1.0f, &out_actual); @@ -120,8 +121,10 @@ void VerifySymmetric5(const size_t xsize, const size_t ysize, ThreadPool* pool, } { Rect out_rect(0, 0, in_rect.xsize(), in_rect.ysize()); - ImageF out_expected(out_rect.xsize(), out_rect.ysize()); - ImageF out_actual(out_rect.xsize(), out_rect.ysize()); + JXL_ASSIGN_OR_DIE(ImageF out_expected, + ImageF::Create(out_rect.xsize(), out_rect.ysize())); + JXL_ASSIGN_OR_DIE(ImageF out_actual, + ImageF::Create(out_rect.xsize(), out_rect.ysize())); SlowSeparable5(in, in_rect, WeightsSeparable5Lowpass(), pool, &out_expected, out_rect); @@ -138,11 +141,11 @@ void VerifySeparable5(const size_t xsize, const size_t ysize, ThreadPool* pool, Rng* rng) { const Rect rect(0, 0, xsize, ysize); - ImageF in(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF in, ImageF::Create(xsize, ysize)); GenerateImage(*rng, &in, 0.0f, 1.0f); - ImageF out_expected(xsize, ysize); - ImageF out_actual(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF out_expected, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_DIE(ImageF out_actual, ImageF::Create(xsize, ysize)); const WeightsSeparable5& weights = WeightsSeparable5Lowpass(); SlowSeparable5(in, rect, weights, pool, &out_expected, rect); @@ -197,10 +200,10 @@ void BenchmarkConv(const char* caption, const Conv& conv, hwy::Result results[kNumInputs]; const size_t kDim = 160; // in+out fit in L2 - ImageF in(kDim, kDim); + JXL_ASSIGN_OR_DIE(ImageF in, ImageF::Create(kDim, kDim)); ZeroFillImage(&in); in.Row(kDim / 2)[kDim / 2] = unpredictable1; - ImageF out(kDim, kDim); + JXL_ASSIGN_OR_DIE(ImageF out, ImageF::Create(kDim, kDim)); hwy::Params p; p.verbose = false; @@ -239,7 +242,7 @@ struct ConvSeparable5 { }; void BenchmarkAll() { -#if 0 // disabled to avoid test timeouts, run manually on demand +#if JXL_FALSE // disabled to avoid test timeouts, run manually on demand const hwy::FuncInput unpredictable1 = time(nullptr) != 1234; BenchmarkConv("Symmetric3", ConvSymmetric3(), unpredictable1); BenchmarkConv("Separable5", ConvSeparable5(), unpredictable1); diff --git a/third_party/jpeg-xl/lib/jxl/dct-inl.h b/third_party/jpeg-xl/lib/jxl/dct-inl.h index cb6c54bc46..05cfbde553 100644 --- a/third_party/jpeg-xl/lib/jxl/dct-inl.h +++ b/third_party/jpeg-xl/lib/jxl/dct-inl.h @@ -154,12 +154,12 @@ struct DCT1DImpl; template struct DCT1DImpl<1, SZ> { - JXL_INLINE void operator()(float* JXL_RESTRICT mem, float*) {} + JXL_INLINE void operator()(float* JXL_RESTRICT mem, float* /* tmp */) {} }; template struct DCT1DImpl<2, SZ> { - JXL_INLINE void operator()(float* JXL_RESTRICT mem, float*) { + JXL_INLINE void operator()(float* JXL_RESTRICT mem, float* /* tmp */) { auto in1 = Load(FV(), mem); auto in2 = Load(FV(), mem + SZ); Store(Add(in1, in2), FV(), mem); @@ -186,7 +186,7 @@ struct IDCT1DImpl; template struct IDCT1DImpl<1, SZ> { JXL_INLINE void operator()(const float* from, size_t from_stride, float* to, - size_t to_stride, float* JXL_RESTRICT) { + size_t to_stride, float* JXL_RESTRICT /* tmp */) { StoreU(LoadU(FV(), from), FV(), to); } }; @@ -194,7 +194,7 @@ struct IDCT1DImpl<1, SZ> { template struct IDCT1DImpl<2, SZ> { JXL_INLINE void operator()(const float* from, size_t from_stride, float* to, - size_t to_stride, float* JXL_RESTRICT) { + size_t to_stride, float* JXL_RESTRICT /* tmp */) { JXL_DASSERT(from_stride >= SZ); JXL_DASSERT(to_stride >= SZ); auto in1 = LoadU(FV(), from); diff --git a/third_party/jpeg-xl/lib/jxl/dct_block-inl.h b/third_party/jpeg-xl/lib/jxl/dct_block-inl.h index 50646a737f..6db5f0e7c8 100644 --- a/third_party/jpeg-xl/lib/jxl/dct_block-inl.h +++ b/third_party/jpeg-xl/lib/jxl/dct_block-inl.h @@ -44,7 +44,7 @@ class DCTFrom { DCTFrom(const float* data, size_t stride) : stride_(stride), data_(data) {} template - HWY_INLINE Vec LoadPart(D, const size_t row, size_t i) const { + HWY_INLINE Vec LoadPart(D /* tag */, const size_t row, size_t i) const { JXL_DASSERT(Lanes(D()) <= stride_); // Since these functions are used also for DC, no alignment at all is // guaranteed in the case of floating blocks. @@ -74,7 +74,7 @@ class DCTTo { DCTTo(float* data, size_t stride) : stride_(stride), data_(data) {} template - HWY_INLINE void StorePart(D, const Vec& v, const size_t row, + HWY_INLINE void StorePart(D /* tag */, const Vec& v, const size_t row, size_t i) const { JXL_DASSERT(Lanes(D()) <= stride_); // Since these functions are used also for DC, no alignment at all is diff --git a/third_party/jpeg-xl/lib/jxl/dct_util.h b/third_party/jpeg-xl/lib/jxl/dct_util.h index 2f29449677..90a02658af 100644 --- a/third_party/jpeg-xl/lib/jxl/dct_util.h +++ b/third_party/jpeg-xl/lib/jxl/dct_util.h @@ -8,8 +8,9 @@ #include -#include "lib/jxl/base/compiler_specific.h" -#include "lib/jxl/base/data_parallel.h" +#include + +#include "lib/jxl/base/common.h" #include "lib/jxl/base/status.h" #include "lib/jxl/image.h" #include "lib/jxl/image_ops.h" @@ -50,12 +51,16 @@ template class ACImageT final : public ACImage { public: ACImageT() = default; - ACImageT(size_t xsize, size_t ysize) { + + static StatusOr> Make(size_t xsize, size_t ysize) { static_assert( std::is_same::value || std::is_same::value, "ACImage must be either 32- or 16- bit"); - img_ = Image3(xsize, ysize); + std::unique_ptr result = jxl::make_unique(); + JXL_ASSIGN_OR_RETURN(result->img_, Image3::Create(xsize, ysize)); + return result; } + ACType Type() const override { return sizeof(T) == 2 ? ACType::k16 : ACType::k32; } diff --git a/third_party/jpeg-xl/lib/jxl/dec_ans.cc b/third_party/jpeg-xl/lib/jxl/dec_ans.cc index 29d41c8062..8b7b54ce91 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_ans.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_ans.cc @@ -154,7 +154,7 @@ Status ReadHistogram(int precision_bits, std::vector* counts, (*counts)[i] = prev; numsame--; } else { - int code = logcounts[i]; + unsigned int code = logcounts[i]; // omit_pos may not be negative at this point (checked before). if (i == static_cast(omit_pos)) { continue; @@ -164,7 +164,7 @@ Status ReadHistogram(int precision_bits, std::vector* counts, (*counts)[i] = 1; } else { int bitcount = GetPopulationCountPrecision(code - 1, shift); - (*counts)[i] = (1 << (code - 1)) + + (*counts)[i] = (1u << (code - 1)) + (input->ReadBits(bitcount) << (code - 1 - bitcount)); } } @@ -260,7 +260,8 @@ Status DecodeUintConfig(size_t log_alpha_size, HybridUintConfig* uint_config, BitReader* br) { br->Refill(); size_t split_exponent = br->ReadBits(CeilLog2Nonzero(log_alpha_size + 1)); - size_t msb_in_token = 0, lsb_in_token = 0; + size_t msb_in_token = 0; + size_t lsb_in_token = 0; if (split_exponent != log_alpha_size) { // otherwise, msb/lsb don't matter. size_t nbits = CeilLog2Nonzero(split_exponent + 1); @@ -284,9 +285,8 @@ Status DecodeUintConfigs(size_t log_alpha_size, std::vector* uint_config, BitReader* br) { // TODO(veluca): RLE? - for (size_t i = 0; i < uint_config->size(); i++) { - JXL_RETURN_IF_ERROR( - DecodeUintConfig(log_alpha_size, &(*uint_config)[i], br)); + for (auto& cfg : *uint_config) { + JXL_RETURN_IF_ERROR(DecodeUintConfig(log_alpha_size, &cfg, br)); } return true; } @@ -345,7 +345,7 @@ Status DecodeHistograms(BitReader* br, size_t num_contexts, ANSCode* code, 4, "Decoded context map of size %" PRIuS " and %" PRIuS " histograms", num_contexts, num_histograms); code->lz77.nonserialized_distance_context = context_map->back(); - code->use_prefix_code = br->ReadFixedBits<1>(); + code->use_prefix_code = static_cast(br->ReadFixedBits<1>()); if (code->use_prefix_code) { code->log_alpha_size = PREFIX_MAX_BITS; } else { diff --git a/third_party/jpeg-xl/lib/jxl/dec_ans.h b/third_party/jpeg-xl/lib/jxl/dec_ans.h index 57faad25a7..cbff1deebe 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_ans.h +++ b/third_party/jpeg-xl/lib/jxl/dec_ans.h @@ -9,6 +9,7 @@ // Library to decode the ANS population counts from the bit-stream and build a // decoding table from them. +#include #include #include @@ -133,6 +134,11 @@ static constexpr int8_t kSpecialDistances[kNumSpecialDistances][2] = { {8, 0}, {4, 7}, {-4, 7}, {7, 4}, {-7, 4}, {8, 1}, {8, 2}, {6, 6}, {-6, 6}, {8, 3}, {5, 7}, {-5, 7}, {7, 5}, {-7, 5}, {8, 4}, {6, 7}, {-6, 7}, {7, 6}, {-7, 6}, {8, 5}, {7, 7}, {-7, 7}, {8, 6}, {8, 7}}; +static JXL_INLINE int SpecialDistance(size_t index, int multiplier) { + int dist = kSpecialDistances[index][0] + + static_cast(multiplier) * kSpecialDistances[index][1]; + return (dist > 1) ? dist : 1; +} struct ANSCode { CacheAlignedUniquePtr alias_tables; @@ -179,10 +185,7 @@ class ANSSymbolReader { num_special_distances_ = distance_multiplier == 0 ? 0 : kNumSpecialDistances; for (size_t i = 0; i < num_special_distances_; i++) { - int dist = kSpecialDistances[i][0]; - dist += static_cast(distance_multiplier) * kSpecialDistances[i][1]; - if (dist < 1) dist = 1; - special_distances_[i] = dist; + special_distances_[i] = SpecialDistance(i, distance_multiplier); } } @@ -196,7 +199,7 @@ class ANSSymbolReader { AliasTable::Lookup(table, res, log_entry_size_, entry_size_minus_1_); state_ = symbol.freq * (state_ >> ANS_LOG_TAB_SIZE) + symbol.offset; -#if 1 +#if JXL_TRUE // Branchless version is about equally fast on SKX. const uint32_t new_state = (state_ << 16u) | static_cast(br->PeekFixedBits<16>()); diff --git a/third_party/jpeg-xl/lib/jxl/dec_cache.cc b/third_party/jpeg-xl/lib/jxl/dec_cache.cc index 8d12bce02e..2a89420018 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_cache.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_cache.cc @@ -5,6 +5,7 @@ #include "lib/jxl/dec_cache.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/blending.h" #include "lib/jxl/common.h" // JXL_HIGH_PRECISION #include "lib/jxl/render_pipeline/stage_blending.h" @@ -247,6 +248,7 @@ Status PassesDecoderState::PreparePipeline(const FrameHeader& frame_header, } linear = false; } + (void)linear; if (main_output.callback.IsPresent() || main_output.buffer) { builder.AddStage(GetWriteToOutputStage(main_output, width, height, @@ -257,7 +259,8 @@ Status PassesDecoderState::PreparePipeline(const FrameHeader& frame_header, decoded, output_encoding_info.color_encoding)); } } - render_pipeline = std::move(builder).Finalize(shared->frame_dim); + JXL_ASSIGN_OR_RETURN(render_pipeline, + std::move(builder).Finalize(shared->frame_dim)); return render_pipeline->IsInitialized(); } diff --git a/third_party/jpeg-xl/lib/jxl/dec_cache.h b/third_party/jpeg-xl/lib/jxl/dec_cache.h index d4cc7a1957..d031074532 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_cache.h +++ b/third_party/jpeg-xl/lib/jxl/dec_cache.h @@ -52,7 +52,8 @@ struct PixelCallback { const bool has_init = init != nullptr; const bool has_run = run != nullptr; const bool has_destroy = destroy != nullptr; - JXL_ASSERT(has_init == has_run && has_run == has_destroy); + const bool healthy = (has_init == has_run) && (has_run == has_destroy); + JXL_ASSERT(healthy); #endif } @@ -128,7 +129,7 @@ struct PassesDecoderState { std::atomic used_acs{0}; // Storage for coefficients if in "accumulate" mode. - std::unique_ptr coefficients = make_unique>(0, 0); + std::unique_ptr coefficients = make_unique>(); // Rendering pipeline. std::unique_ptr render_pipeline; @@ -166,8 +167,10 @@ struct PassesDecoderState { upsampler8x = GetUpsamplingStage(shared->metadata->transform_data, 0, 3); if (frame_header.loop_filter.epf_iters > 0) { - sigma = ImageF(shared->frame_dim.xsize_blocks + 2 * kSigmaPadding, - shared->frame_dim.ysize_blocks + 2 * kSigmaPadding); + JXL_ASSIGN_OR_RETURN( + sigma, + ImageF::Create(shared->frame_dim.xsize_blocks + 2 * kSigmaPadding, + shared->frame_dim.ysize_blocks + 2 * kSigmaPadding)); } return true; } @@ -193,14 +196,16 @@ struct PassesDecoderState { // Temp images required for decoding a single group. Reduces memory allocations // for large images because we only initialize min(#threads, #groups) instances. struct GroupDecCache { - void InitOnce(size_t num_passes, size_t used_acs) { + Status InitOnce(size_t num_passes, size_t used_acs) { for (size_t i = 0; i < num_passes; i++) { if (num_nzeroes[i].xsize() == 0) { // Allocate enough for a whole group - partial groups on the // right/bottom border just use a subset. The valid size is passed via // Rect. - num_nzeroes[i] = Image3I(kGroupDimInBlocks, kGroupDimInBlocks); + JXL_ASSIGN_OR_RETURN( + num_nzeroes[i], + Image3I::Create(kGroupDimInBlocks, kGroupDimInBlocks)); } } size_t max_block_area = 0; @@ -227,13 +232,17 @@ struct GroupDecCache { scratch_space = dec_group_block + max_block_area_ * 3; dec_group_qblock = int32_memory_.get(); dec_group_qblock16 = int16_memory_.get(); + return true; } - void InitDCBufferOnce() { + Status InitDCBufferOnce() { if (dc_buffer.xsize() == 0) { - dc_buffer = ImageF(kGroupDimInBlocks + kRenderPipelineXOffset * 2, - kGroupDimInBlocks + 4); + JXL_ASSIGN_OR_RETURN( + dc_buffer, + ImageF::Create(kGroupDimInBlocks + kRenderPipelineXOffset * 2, + kGroupDimInBlocks + 4)); } + return true; } // Scratch space used by DecGroupImpl(). diff --git a/third_party/jpeg-xl/lib/jxl/dec_context_map.cc b/third_party/jpeg-xl/lib/jxl/dec_context_map.cc index 2c936722da..baff87fa49 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_context_map.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_context_map.cc @@ -6,6 +6,7 @@ #include "lib/jxl/dec_context_map.h" #include +#include #include #include "lib/jxl/ans_params.h" @@ -41,18 +42,18 @@ Status VerifyContextMap(const std::vector& context_map, Status DecodeContextMap(std::vector* context_map, size_t* num_htrees, BitReader* input) { - bool is_simple = input->ReadFixedBits<1>(); + bool is_simple = static_cast(input->ReadFixedBits<1>()); if (is_simple) { int bits_per_entry = input->ReadFixedBits<2>(); if (bits_per_entry != 0) { - for (size_t i = 0; i < context_map->size(); i++) { - (*context_map)[i] = input->ReadBits(bits_per_entry); + for (uint8_t& entry : *context_map) { + entry = input->ReadBits(bits_per_entry); } } else { std::fill(context_map->begin(), context_map->end(), 0); } } else { - bool use_mtf = input->ReadFixedBits<1>(); + bool use_mtf = static_cast(input->ReadFixedBits<1>()); ANSCode code; std::vector sink_ctx_map; // Usage of LZ77 is disallowed if decoding only two symbols. This doesn't diff --git a/third_party/jpeg-xl/lib/jxl/dec_external_image.cc b/third_party/jpeg-xl/lib/jxl/dec_external_image.cc index 06cd573378..51e12fcc81 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_external_image.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_external_image.cc @@ -9,11 +9,11 @@ #include #include -#include -#include #include #include +#include "lib/jxl/base/status.h" + #undef HWY_TARGET_INCLUDE #define HWY_TARGET_INCLUDE "lib/jxl/dec_external_image.cc" #include @@ -113,7 +113,7 @@ Status UndoOrientation(jxl::Orientation undo_orientation, const Plane& image, const size_t ysize = image.ysize(); if (undo_orientation == Orientation::kFlipHorizontal) { - out = Plane(xsize, ysize); + JXL_ASSIGN_OR_RETURN(out, Plane::Create(xsize, ysize)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), ThreadPool::NoInit, [&](const uint32_t task, size_t /*thread*/) { @@ -126,7 +126,7 @@ Status UndoOrientation(jxl::Orientation undo_orientation, const Plane& image, }, "UndoOrientation")); } else if (undo_orientation == Orientation::kRotate180) { - out = Plane(xsize, ysize); + JXL_ASSIGN_OR_RETURN(out, Plane::Create(xsize, ysize)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), ThreadPool::NoInit, [&](const uint32_t task, size_t /*thread*/) { @@ -139,7 +139,7 @@ Status UndoOrientation(jxl::Orientation undo_orientation, const Plane& image, }, "UndoOrientation")); } else if (undo_orientation == Orientation::kFlipVertical) { - out = Plane(xsize, ysize); + JXL_ASSIGN_OR_RETURN(out, Plane::Create(xsize, ysize)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), ThreadPool::NoInit, [&](const uint32_t task, size_t /*thread*/) { @@ -152,7 +152,7 @@ Status UndoOrientation(jxl::Orientation undo_orientation, const Plane& image, }, "UndoOrientation")); } else if (undo_orientation == Orientation::kTranspose) { - out = Plane(ysize, xsize); + JXL_ASSIGN_OR_RETURN(out, Plane::Create(ysize, xsize)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), ThreadPool::NoInit, [&](const uint32_t task, size_t /*thread*/) { @@ -164,7 +164,7 @@ Status UndoOrientation(jxl::Orientation undo_orientation, const Plane& image, }, "UndoOrientation")); } else if (undo_orientation == Orientation::kRotate90) { - out = Plane(ysize, xsize); + JXL_ASSIGN_OR_RETURN(out, Plane::Create(ysize, xsize)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), ThreadPool::NoInit, [&](const uint32_t task, size_t /*thread*/) { @@ -176,7 +176,7 @@ Status UndoOrientation(jxl::Orientation undo_orientation, const Plane& image, }, "UndoOrientation")); } else if (undo_orientation == Orientation::kAntiTranspose) { - out = Plane(ysize, xsize); + JXL_ASSIGN_OR_RETURN(out, Plane::Create(ysize, xsize)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), ThreadPool::NoInit, [&](const uint32_t task, size_t /*thread*/) { @@ -188,7 +188,7 @@ Status UndoOrientation(jxl::Orientation undo_orientation, const Plane& image, }, "UndoOrientation")); } else if (undo_orientation == Orientation::kRotate270) { - out = Plane(ysize, xsize); + JXL_ASSIGN_OR_RETURN(out, Plane::Create(ysize, xsize)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), ThreadPool::NoInit, [&](const uint32_t task, size_t /*thread*/) { @@ -247,7 +247,8 @@ Status ConvertChannelsToExternal(const ImageF* in_channels[], JXL_DASSERT(in_channels[0] != nullptr); JXL_CHECK(float_out ? bits_per_sample == 16 || bits_per_sample == 32 : bits_per_sample > 0 && bits_per_sample <= 16); - if (!!out_image == out_callback.IsPresent()) { + const bool has_out_image = (out_image != nullptr); + if (has_out_image == out_callback.IsPresent()) { return JXL_FAILURE( "Must provide either an out_image or an out_callback, but not both."); } @@ -309,7 +310,7 @@ Status ConvertChannelsToExternal(const ImageF* in_channels[], ImageF ones; for (size_t c = 0; c < num_channels; ++c) { if (!channels[c]) { - ones = ImageF(xsize, 1); + JXL_ASSIGN_OR_RETURN(ones, ImageF::Create(xsize, 1)); FillImage(1.0f, &ones); break; } @@ -322,9 +323,12 @@ Status ConvertChannelsToExternal(const ImageF* in_channels[], JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), [&](size_t num_threads) { - f16_cache = - Plane(xsize, num_channels * num_threads); - return InitOutCallback(num_threads); + StatusOr> f16_cache_or = + Plane::Create(xsize, + num_channels * num_threads); + if (!f16_cache_or.ok()) return false; + f16_cache = std::move(f16_cache_or).value(); + return !!InitOutCallback(num_threads); }, [&](const uint32_t task, const size_t thread) { const int64_t y = task; @@ -398,8 +402,11 @@ Status ConvertChannelsToExternal(const ImageF* in_channels[], JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, static_cast(ysize), [&](size_t num_threads) { - u32_cache = Plane(xsize, num_channels * num_threads); - return InitOutCallback(num_threads); + StatusOr> u32_cache_or = + Plane::Create(xsize, num_channels * num_threads); + if (!u32_cache_or.ok()) return false; + u32_cache = std::move(u32_cache_or).value(); + return !!InitOutCallback(num_threads); }, [&](const uint32_t task, const size_t thread) { const int64_t y = task; @@ -453,7 +460,8 @@ Status ConvertToExternal(const jxl::ImageBundle& ib, size_t bits_per_sample, // Undo premultiplied alpha. Image3F unpremul; if (ib.AlphaIsPremultiplied() && ib.HasAlpha() && unpremul_alpha) { - unpremul = Image3F(color->xsize(), color->ysize()); + JXL_ASSIGN_OR_RETURN(unpremul, + Image3F::Create(color->xsize(), color->ysize())); CopyImageTo(*color, &unpremul); for (size_t y = 0; y < unpremul.ysize(); y++) { UnpremultiplyAlpha(unpremul.PlaneRow(0, y), unpremul.PlaneRow(1, y), diff --git a/third_party/jpeg-xl/lib/jxl/dec_external_image_gbench.cc b/third_party/jpeg-xl/lib/jxl/dec_external_image_gbench.cc index c87a4d5f36..720a278fc0 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_external_image_gbench.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_external_image_gbench.cc @@ -5,6 +5,7 @@ #include "benchmark/benchmark.h" #include "lib/jxl/dec_external_image.h" +#include "lib/jxl/image.h" #include "lib/jxl/image_ops.h" namespace jxl { @@ -20,10 +21,10 @@ void BM_DecExternalImage_ConvertImageRGBA(benchmark::State& state) { ImageMetadata im; im.SetAlphaBits(8); ImageBundle ib(&im); - Image3F color(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3F color, Image3F::Create(xsize, ysize)); ZeroFillImage(&color); ib.SetFromImage(std::move(color), ColorEncoding::SRGB()); - ImageF alpha(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF alpha, ImageF::Create(xsize, ysize)); ZeroFillImage(&alpha); ib.SetAlpha(std::move(alpha)); diff --git a/third_party/jpeg-xl/lib/jxl/dec_frame.cc b/third_party/jpeg-xl/lib/jxl/dec_frame.cc index 918dbe7c37..a2a82ad1fb 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_frame.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_frame.cc @@ -331,21 +331,23 @@ Status FrameDecoder::ProcessDCGroup(size_t dc_group_id, BitReader* br) { } else if (lf.epf_iters > 0) { FillImage(kInvSigmaNum / lf.epf_sigma_for_modular, &dec_state_->sigma); } - decoded_dc_groups_[dc_group_id] = uint8_t{true}; + decoded_dc_groups_[dc_group_id] = JXL_TRUE; return true; } -void FrameDecoder::FinalizeDC() { +Status FrameDecoder::FinalizeDC() { // Do Adaptive DC smoothing if enabled. This *must* happen between all the // ProcessDCGroup and ProcessACGroup. if (frame_header_.encoding == FrameEncoding::kVarDCT && !(frame_header_.flags & FrameHeader::kSkipAdaptiveDCSmoothing) && !(frame_header_.flags & FrameHeader::kUseDcFrame)) { - AdaptiveDCSmoothing(dec_state_->shared->quantizer.MulDC(), - &dec_state_->shared_storage.dc_storage, pool_); + JXL_RETURN_IF_ERROR( + AdaptiveDCSmoothing(dec_state_->shared->quantizer.MulDC(), + &dec_state_->shared_storage.dc_storage, pool_)); } finalized_dc_ = true; + return true; } Status FrameDecoder::AllocateOutput() { @@ -410,9 +412,11 @@ Status FrameDecoder::ProcessACGlobal(BitReader* br) { size_t xs = store ? kGroupDim * kGroupDim : 0; size_t ys = store ? frame_dim_.num_groups : 0; if (use_16_bit) { - dec_state_->coefficients = make_unique>(xs, ys); + JXL_ASSIGN_OR_RETURN(dec_state_->coefficients, + ACImageT::Make(xs, ys)); } else { - dec_state_->coefficients = make_unique>(xs, ys); + JXL_ASSIGN_OR_RETURN(dec_state_->coefficients, + ACImageT::Make(xs, ys)); } if (store) { dec_state_->coefficients->ZeroFill(); @@ -482,8 +486,8 @@ Status FrameDecoder::ProcessACGroup(size_t ac_group_id, bool should_run_pipeline = true; if (frame_header_.encoding == FrameEncoding::kVarDCT) { - group_dec_caches_[thread].InitOnce(frame_header_.passes.num_passes, - dec_state_->used_acs); + JXL_RETURN_IF_ERROR(group_dec_caches_[thread].InitOnce( + frame_header_.passes.num_passes, dec_state_->used_acs)); JXL_RETURN_IF_ERROR(DecodeGroup(frame_header_, br, num_passes, ac_group_id, dec_state_, &group_dec_caches_[thread], thread, render_pipeline_input, decoded_, @@ -498,10 +502,16 @@ Status FrameDecoder::ProcessACGroup(size_t ac_group_id, size_t pass1 = force_draw ? frame_header_.passes.num_passes : pass0 + num_passes; for (size_t i = pass0; i < pass1; ++i) { - int minShift, maxShift; + int minShift; + int maxShift; frame_header_.passes.GetDownsamplingBracket(i, minShift, maxShift); bool modular_pass_ready = true; + JXL_DEBUG_V(2, "Decoding modular in group %d pass %d", + static_cast(ac_group_id), static_cast(i)); if (i < pass0 + num_passes) { + JXL_DEBUG_V(2, "Bit reader position: %" PRIuS " / %" PRIuS, + br[i - pass0]->TotalBitsConsumed(), + br[i - pass0]->TotalBytes() * kBitsPerByte); JXL_RETURN_IF_ERROR(modular_frame_decoder_.DecodeGroup( frame_header_, mrect, br[i - pass0], minShift, maxShift, ModularStreamId::ModularAC(ac_group_id, i), @@ -546,7 +556,7 @@ Status FrameDecoder::ProcessACGroup(size_t ac_group_id, if (!modular_frame_decoder_.UsesFullImage() && !decoded_->IsJPEG()) { if (should_run_pipeline && modular_ready) { - render_pipeline_input.Done(); + JXL_RETURN_IF_ERROR(render_pipeline_input.Done()); } else if (force_draw) { return JXL_FAILURE("Modular group decoding failed."); } @@ -555,11 +565,11 @@ Status FrameDecoder::ProcessACGroup(size_t ac_group_id, } void FrameDecoder::MarkSections(const SectionInfo* sections, size_t num, - SectionStatus* section_status) { + const SectionStatus* section_status) { num_sections_done_ += num; for (size_t i = 0; i < num; i++) { if (section_status[i] != SectionStatus::kDone) { - processed_section_[sections[i].id] = false; + processed_section_[sections[i].id] = JXL_FALSE; num_sections_done_--; } } @@ -583,8 +593,8 @@ Status FrameDecoder::ProcessSections(const SectionInfo* sections, size_t num, if (single_section) { JXL_ASSERT(num == 1); JXL_ASSERT(sections[0].id == 0); - if (processed_section_[0] == false) { - processed_section_[0] = true; + if (processed_section_[0] == JXL_FALSE) { + processed_section_[0] = JXL_TRUE; ac_group_sec[0].resize(1); dc_global_sec = ac_global_sec = dc_group_sec[0] = ac_group_sec[0][0] = 0; desired_num_ac_passes[0] = 1; @@ -614,7 +624,7 @@ Status FrameDecoder::ProcessSections(const SectionInfo* sections, size_t num, } ac_group_sec[acg][acp] = i; } - processed_section_[sections[i].id] = true; + processed_section_[sections[i].id] = JXL_TRUE; } // Count number of new passes per group. for (size_t g = 0; g < ac_group_sec.size(); g++) { @@ -645,9 +655,11 @@ Status FrameDecoder::ProcessSections(const SectionInfo* sections, size_t num, pool_, 0, dc_group_sec.size(), ThreadPool::NoInit, [this, &dc_group_sec, &num, §ions, §ion_status, &has_error]( size_t i, size_t thread) { + if (has_error) return; if (dc_group_sec[i] != num) { if (!ProcessDCGroup(i, sections[dc_group_sec[i]].br)) { has_error = true; + return; } else { section_status[dc_group_sec[i]] = SectionStatus::kDone; } @@ -657,8 +669,7 @@ Status FrameDecoder::ProcessSections(const SectionInfo* sections, size_t num, } if (has_error) return JXL_FAILURE("Error in DC group"); - if (*std::min_element(decoded_dc_groups_.begin(), decoded_dc_groups_.end()) && - !finalized_dc_) { + if (!HasDcGroupToDecode() && !finalized_dc_) { PassesDecoderState::PipelineOptions pipeline_options; pipeline_options.use_slow_render_pipeline = use_slow_rendering_pipeline_; pipeline_options.coalescing = coalescing_; @@ -666,7 +677,7 @@ Status FrameDecoder::ProcessSections(const SectionInfo* sections, size_t num, pipeline_options.render_noise = true; JXL_RETURN_IF_ERROR( dec_state_->PreparePipeline(frame_header_, decoded_, pipeline_options)); - FinalizeDC(); + JXL_RETURN_IF_ERROR(FinalizeDC()); JXL_RETURN_IF_ERROR(AllocateOutput()); if (progressive_detail_ >= JxlProgressiveDetail::kDC) { MarkSections(sections, num, section_status); @@ -776,21 +787,22 @@ Status FrameDecoder::Flush() { decoded_passes_per_ac_group_.size()); }, [this, &has_error](const uint32_t g, size_t thread) { + if (has_error) return; if (decoded_passes_per_ac_group_[g] == frame_header_.passes.num_passes) { // This group was drawn already, nothing to do. return; } BitReader* JXL_RESTRICT readers[kMaxNumPasses] = {}; - bool ok = ProcessACGroup( - g, readers, /*num_passes=*/0, GetStorageLocation(thread, g), - /*force_draw=*/true, /*dc_only=*/!decoded_ac_global_); - if (!ok) has_error = true; + if (!ProcessACGroup( + g, readers, /*num_passes=*/0, GetStorageLocation(thread, g), + /*force_draw=*/true, /*dc_only=*/!decoded_ac_global_)) { + has_error = true; + return; + } }, "ForceDrawGroup")); - if (has_error) { - return JXL_FAILURE("Drawing groups failed"); - } + if (has_error) return JXL_FAILURE("Drawing groups failed"); } // undo global modular transforms and copy int pixel buffers to float ones @@ -815,10 +827,8 @@ int FrameDecoder::SavedAs(const FrameHeader& header) { bool FrameDecoder::HasEverything() const { if (!decoded_dc_global_) return false; if (!decoded_ac_global_) return false; - for (auto& have_dc_group : decoded_dc_groups_) { - if (!have_dc_group) return false; - } - for (auto& nb_passes : decoded_passes_per_ac_group_) { + if (HasDcGroupToDecode()) return false; + for (const auto& nb_passes : decoded_passes_per_ac_group_) { if (nb_passes < frame_header_.passes.num_passes) return false; } return true; @@ -840,9 +850,9 @@ int FrameDecoder::References() const { result |= (1 << frame_header_.blending_info.source); } const auto& extra = frame_header_.extra_channel_blending_info; - for (size_t i = 0; i < extra.size(); ++i) { - if (cropped || extra[i].mode != BlendMode::kReplace) { - result |= (1 << extra[i].source); + for (const auto& ecbi : extra) { + if (cropped || ecbi.mode != BlendMode::kReplace) { + result |= (1 << ecbi.source); } } } diff --git a/third_party/jpeg-xl/lib/jxl/dec_frame.h b/third_party/jpeg-xl/lib/jxl/dec_frame.h index 09bdbc9675..663f1a8b33 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_frame.h +++ b/third_party/jpeg-xl/lib/jxl/dec_frame.h @@ -242,14 +242,14 @@ class FrameDecoder { private: Status ProcessDCGlobal(BitReader* br); Status ProcessDCGroup(size_t dc_group_id, BitReader* br); - void FinalizeDC(); + Status FinalizeDC(); Status AllocateOutput(); Status ProcessACGlobal(BitReader* br); Status ProcessACGroup(size_t ac_group_id, BitReader* JXL_RESTRICT* br, size_t num_passes, size_t thread, bool force_draw, bool dc_only); void MarkSections(const SectionInfo* sections, size_t num, - SectionStatus* section_status); + const SectionStatus* section_status); // Allocates storage for parallel decoding using up to `num_threads` threads // of up to `num_tasks` tasks. The value of `thread` passed to @@ -262,9 +262,10 @@ class FrameDecoder { group_dec_caches_.resize(storage_size); } use_task_id_ = num_threads > num_tasks; - bool use_group_ids = (modular_frame_decoder_.UsesFullImage() && - (frame_header_.encoding == FrameEncoding::kVarDCT || - (frame_header_.flags & FrameHeader::kNoise))); + bool use_noise = (frame_header_.flags & FrameHeader::kNoise) != 0; + bool use_group_ids = + (modular_frame_decoder_.UsesFullImage() && + (frame_header_.encoding == FrameEncoding::kVarDCT || use_noise)); if (dec_state_->render_pipeline) { JXL_RETURN_IF_ERROR(dec_state_->render_pipeline->PrepareForThreads( storage_size, use_group_ids)); @@ -272,7 +273,7 @@ class FrameDecoder { return true; } - size_t GetStorageLocation(size_t thread, size_t task) { + size_t GetStorageLocation(size_t thread, size_t task) const { if (use_task_id_) return task; return thread; } @@ -292,6 +293,11 @@ class FrameDecoder { return stride; } + bool HasDcGroupToDecode() const { + return std::any_of(decoded_dc_groups_.cbegin(), decoded_dc_groups_.cend(), + [](uint8_t ready) { return ready == 0; }); + } + PassesDecoderState* dec_state_; ThreadPool* pool_; std::vector toc_; diff --git a/third_party/jpeg-xl/lib/jxl/dec_group.cc b/third_party/jpeg-xl/lib/jxl/dec_group.cc index 186318e63d..7dc4772eba 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_group.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_group.cc @@ -27,13 +27,10 @@ #include "lib/jxl/base/status.h" #include "lib/jxl/coeff_order.h" #include "lib/jxl/common.h" // kMaxNumPasses -#include "lib/jxl/convolve.h" -#include "lib/jxl/dct_scales.h" #include "lib/jxl/dec_cache.h" #include "lib/jxl/dec_transforms-inl.h" #include "lib/jxl/dec_xyb.h" #include "lib/jxl/entropy_coder.h" -#include "lib/jxl/epf.h" #include "lib/jxl/quant_weights.h" #include "lib/jxl/quantizer-inl.h" #include "lib/jxl/quantizer.h" @@ -70,6 +67,11 @@ namespace jxl { namespace HWY_NAMESPACE { // These templates are not found via ADL. +using hwy::HWY_NAMESPACE::AllFalse; +using hwy::HWY_NAMESPACE::Gt; +using hwy::HWY_NAMESPACE::Le; +using hwy::HWY_NAMESPACE::MaskFromVec; +using hwy::HWY_NAMESPACE::Or; using hwy::HWY_NAMESPACE::Rebind; using hwy::HWY_NAMESPACE::ShiftRight; @@ -77,9 +79,11 @@ using D = HWY_FULL(float); using DU = HWY_FULL(uint32_t); using DI = HWY_FULL(int32_t); using DI16 = Rebind; +using DI16_FULL = HWY_CAPPED(int16_t, kDCTBlockSize); constexpr D d; constexpr DI di; constexpr DI16 di16; +constexpr DI16_FULL di16_full; // TODO(veluca): consider SIMDfying. void Transpose8x8InPlace(int32_t* JXL_RESTRICT block) { @@ -181,6 +185,9 @@ Status DecodeGroupImpl(const FrameHeader& frame_header, const YCbCrChromaSubsampling& cs = frame_header.chroma_subsampling; + const auto kJpegDctMin = Set(di16_full, -4095); + const auto kJpegDctMax = Set(di16_full, 4095); + size_t idct_stride[3]; for (size_t c = 0; c < 3; c++) { idct_stride[c] = render_pipeline_input.GetBuffer(c).first->PixelsPerRow(); @@ -355,7 +362,7 @@ Status DecodeGroupImpl(const FrameHeader& frame_header, int16_t* JXL_RESTRICT jpeg_pos = jpeg_row[c] + sbx[c] * kDCTBlockSize; // JPEG XL is transposed, JPEG is not. - auto transposed_dct = qblock[c].ptr32; + auto* transposed_dct = qblock[c].ptr32; Transpose8x8InPlace(transposed_dct); // No CfL - no need to store the y block converted to integers. if (!cs.Is444() || @@ -391,6 +398,16 @@ Status DecodeGroupImpl(const FrameHeader& frame_header, } jpeg_pos[0] = Clamp1(dc_rows[c][sbx[c]] - dcoff[c], -2047, 2047); + auto overflow = MaskFromVec(Set(di16_full, 0)); + auto underflow = MaskFromVec(Set(di16_full, 0)); + for (int i = 0; i < 64; i += Lanes(di16_full)) { + auto in = LoadU(di16_full, jpeg_pos + i); + overflow = Or(overflow, Gt(in, kJpegDctMax)); + underflow = Or(underflow, Lt(in, kJpegDctMin)); + } + if (!AllFalse(di16_full, Or(overflow, underflow))) { + return JXL_FAILURE("JPEG DCT coefficients out of range"); + } } } else { HWY_ALIGN float* const block = group_dec_cache->dec_group_block; @@ -683,7 +700,7 @@ Status DecodeGroup(const FrameHeader& frame_header, } if (draw == kDraw && num_passes == 0 && first_pass == 0) { - group_dec_cache->InitDCBufferOnce(); + JXL_RETURN_IF_ERROR(group_dec_cache->InitDCBufferOnce()); const YCbCrChromaSubsampling& cs = frame_header.chroma_subsampling; for (size_t c : {0, 1, 2}) { size_t hs = cs.HShift(c); @@ -726,7 +743,7 @@ Status DecodeGroup(const FrameHeader& frame_header, y++) { for (ssize_t iy = 0; iy < 5; iy++) { input_rows[0][iy] = group_dec_cache->dc_buffer.Row( - Mirror(ssize_t(y) + iy - 2, + Mirror(static_cast(y) + iy - 2, dec_state->shared->dc->Plane(c).ysize() >> vs) + 2 - src_rect.y0()); } @@ -736,9 +753,9 @@ Status DecodeGroup(const FrameHeader& frame_header, kRenderPipelineXOffset; } // Arguments set to 0/nullptr are not used. - dec_state->upsampler8x->ProcessRow(input_rows, output_rows, - /*xextra=*/0, src_rect.xsize(), 0, 0, - thread); + JXL_RETURN_IF_ERROR(dec_state->upsampler8x->ProcessRow( + input_rows, output_rows, + /*xextra=*/0, src_rect.xsize(), 0, 0, thread)); } } return true; @@ -780,9 +797,9 @@ Status DecodeGroupForRoundtrip(const FrameHeader& frame_header, ImageBundle* JXL_RESTRICT decoded, AuxOut* aux_out) { GetBlockFromEncoder get_block(ac, group_idx, frame_header.passes.shift); - group_dec_cache->InitOnce( + JXL_RETURN_IF_ERROR(group_dec_cache->InitOnce( /*num_passes=*/0, - /*used_acs=*/(1u << AcStrategy::kNumValidStrategies) - 1); + /*used_acs=*/(1u << AcStrategy::kNumValidStrategies) - 1)); return HWY_DYNAMIC_DISPATCH(DecodeGroupImpl)( frame_header, &get_block, group_dec_cache, dec_state, thread, group_idx, diff --git a/third_party/jpeg-xl/lib/jxl/dec_huffman.cc b/third_party/jpeg-xl/lib/jxl/dec_huffman.cc index 05b275773a..849b1a5f64 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_huffman.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_huffman.cc @@ -5,6 +5,7 @@ #include "lib/jxl/dec_huffman.h" +#include #include /* for memset */ #include @@ -22,9 +23,9 @@ static const uint8_t kCodeLengthCodeOrder[kCodeLengthCodes] = { static const uint8_t kDefaultCodeLength = 8; static const uint8_t kCodeLengthRepeatCode = 16; -int ReadHuffmanCodeLengths(const uint8_t* code_length_code_lengths, - int num_symbols, uint8_t* code_lengths, - BitReader* br) { +JXL_BOOL ReadHuffmanCodeLengths(const uint8_t* code_length_code_lengths, + int num_symbols, uint8_t* code_lengths, + BitReader* br) { int symbol = 0; uint8_t prev_code_len = kDefaultCodeLength; int repeat = 0; @@ -38,7 +39,7 @@ int ReadHuffmanCodeLengths(const uint8_t* code_length_code_lengths, } if (!BuildHuffmanTable(table, 5, code_length_code_lengths, kCodeLengthCodes, &counts[0])) { - return 0; + return JXL_FALSE; } while (symbol < num_symbols && space > 0) { @@ -47,7 +48,7 @@ int ReadHuffmanCodeLengths(const uint8_t* code_length_code_lengths, br->Refill(); p += br->PeekFixedBits<5>(); br->Consume(p->bits); - code_len = (uint8_t)p->value; + code_len = static_cast(p->value); if (code_len < kCodeLengthRepeatCode) { repeat = 0; code_lengths[symbol++] = code_len; @@ -72,12 +73,13 @@ int ReadHuffmanCodeLengths(const uint8_t* code_length_code_lengths, repeat -= 2; repeat <<= extra_bits; } - repeat += (int)br->ReadBits(extra_bits) + 3; + repeat += static_cast(br->ReadBits(extra_bits) + 3); repeat_delta = repeat - old_repeat; if (symbol + repeat_delta > num_symbols) { return 0; } - memset(&code_lengths[symbol], repeat_code_len, (size_t)repeat_delta); + memset(&code_lengths[symbol], repeat_code_len, + static_cast(repeat_delta)); symbol += repeat_delta; if (repeat_code_len != 0) { space -= repeat_delta << (15 - repeat_code_len); @@ -85,10 +87,10 @@ int ReadHuffmanCodeLengths(const uint8_t* code_length_code_lengths, } } if (space != 0) { - return 0; + return JXL_FALSE; } - memset(&code_lengths[symbol], 0, (size_t)(num_symbols - symbol)); - return true; + memset(&code_lengths[symbol], 0, static_cast(num_symbols - symbol)); + return JXL_TRUE; } static JXL_INLINE bool ReadSimpleCode(size_t alphabet_size, BitReader* br, @@ -176,7 +178,7 @@ static JXL_INLINE bool ReadSimpleCode(size_t alphabet_size, BitReader* br, const uint32_t goal_size = 1u << kHuffmanTableBits; while (table_size != goal_size) { memcpy(&table[table_size], &table[0], - (size_t)table_size * sizeof(table[0])); + static_cast(table_size) * sizeof(table[0])); table_size <<= 1; } @@ -212,16 +214,17 @@ bool HuffmanDecodingData::ReadFromBitStream(size_t alphabet_size, br->Refill(); p += br->PeekFixedBits<4>(); br->Consume(p->bits); - v = (uint8_t)p->value; + v = static_cast(p->value); code_length_code_lengths[code_len_idx] = v; if (v != 0) { space -= (32u >> v); ++num_codes; } } - bool ok = (num_codes == 1 || space == 0) && - ReadHuffmanCodeLengths(code_length_code_lengths, alphabet_size, - &code_lengths[0], br); + bool ok = + (num_codes == 1 || space == 0) && + FROM_JXL_BOOL(ReadHuffmanCodeLengths( + code_length_code_lengths, alphabet_size, code_lengths.data(), br)); if (!ok) return false; uint16_t counts[16] = {0}; @@ -230,7 +233,7 @@ bool HuffmanDecodingData::ReadFromBitStream(size_t alphabet_size, } table_.resize(alphabet_size + 376); uint32_t table_size = - BuildHuffmanTable(table_.data(), kHuffmanTableBits, &code_lengths[0], + BuildHuffmanTable(table_.data(), kHuffmanTableBits, code_lengths.data(), alphabet_size, &counts[0]); table_.resize(table_size); return (table_size > 0); diff --git a/third_party/jpeg-xl/lib/jxl/dec_modular.cc b/third_party/jpeg-xl/lib/jxl/dec_modular.cc index 4fcba489e2..49561e6ec2 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_modular.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_modular.cc @@ -8,7 +8,6 @@ #include #include -#include #include #include "lib/jxl/frame_header.h" @@ -18,10 +17,8 @@ #include #include -#include "lib/jxl/alpha.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/printf_macros.h" -#include "lib/jxl/base/span.h" #include "lib/jxl/base/status.h" #include "lib/jxl/compressed_dc.h" #include "lib/jxl/epf.h" @@ -189,7 +186,7 @@ Status ModularFrameDecoder::DecodeGlobalInfo(BitReader* reader, } do_color = decode_color; size_t nb_extra = metadata.extra_channel_info.size(); - bool has_tree = reader->ReadBits(1); + bool has_tree = static_cast(reader->ReadBits(1)); if (!allow_truncated_group || reader->TotalBitsConsumed() < reader->TotalBytes() * kBitsPerByte) { if (has_tree) { @@ -216,8 +213,10 @@ Status ModularFrameDecoder::DecodeGlobalInfo(BitReader* reader, } } - Image gi(frame_dim.xsize, frame_dim.ysize, metadata.bit_depth.bits_per_sample, - nb_chans + nb_extra); + JXL_ASSIGN_OR_RETURN( + Image gi, + Image::Create(frame_dim.xsize, frame_dim.ysize, + metadata.bit_depth.bits_per_sample, nb_chans + nb_extra)); all_same_shift = true; if (frame_header.color_transform == ColorTransform::kYCbCr) { @@ -228,7 +227,7 @@ Status ModularFrameDecoder::DecodeGlobalInfo(BitReader* reader, DivCeil(frame_dim.xsize, 1 << gi.channel[c].hshift); size_t ysize_shifted = DivCeil(frame_dim.ysize, 1 << gi.channel[c].vshift); - gi.channel[c].shrink(xsize_shifted, ysize_shifted); + JXL_RETURN_IF_ERROR(gi.channel[c].shrink(xsize_shifted, ysize_shifted)); if (gi.channel[c].hshift != gi.channel[0].hshift || gi.channel[c].vshift != gi.channel[0].vshift) all_same_shift = false; @@ -237,8 +236,9 @@ Status ModularFrameDecoder::DecodeGlobalInfo(BitReader* reader, for (size_t ec = 0, c = nb_chans; ec < nb_extra; ec++, c++) { size_t ecups = frame_header.extra_channel_upsampling[ec]; - gi.channel[c].shrink(DivCeil(frame_dim.xsize_upsampled, ecups), - DivCeil(frame_dim.ysize_upsampled, ecups)); + JXL_RETURN_IF_ERROR( + gi.channel[c].shrink(DivCeil(frame_dim.xsize_upsampled, ecups), + DivCeil(frame_dim.ysize_upsampled, ecups))); gi.channel[c].hshift = gi.channel[c].vshift = CeilLog2Nonzero(ecups) - CeilLog2Nonzero(frame_header.upsampling); if (gi.channel[c].hshift != gi.channel[0].hshift || @@ -306,7 +306,8 @@ Status ModularFrameDecoder::DecodeGroup( stream.kind == ModularStreamId::kModularAC); const size_t xsize = rect.xsize(); const size_t ysize = rect.ysize(); - Image gi(xsize, ysize, full_image.bitdepth, 0); + JXL_ASSIGN_OR_RETURN(Image gi, + Image::Create(xsize, ysize, full_image.bitdepth, 0)); // start at the first bigger-than-groupsize non-metachannel size_t c = full_image.nb_meta_channels; for (; c < full_image.channel.size(); c++) { @@ -328,7 +329,7 @@ Status ModularFrameDecoder::DecodeGroup( memset(row_out, 0, r.xsize() * sizeof(*row_out)); } } else { - Channel gc(r.xsize(), r.ysize()); + JXL_ASSIGN_OR_RETURN(Channel gc, Channel::Create(r.xsize(), r.ysize())); if (zerofill) ZeroFillImage(&gc.plane); gc.hshift = fc.hshift; gc.vshift = fc.vshift; @@ -398,7 +399,8 @@ Status ModularFrameDecoder::DecodeVarDCTDC(const FrameHeader& frame_header, // 3 comes from XybToRgb that cubes the values, and "magic" is // the sum of all other contributions. 2**18 is known to lead // to NaN on input found by fuzzing (see commit message). - Image image(r.xsize(), r.ysize(), full_image.bitdepth, 3); + JXL_ASSIGN_OR_RETURN( + Image image, Image::Create(r.xsize(), r.ysize(), full_image.bitdepth, 3)); size_t stream_id = ModularStreamId::VarDCTDC(group_id).ID(frame_dim); reader->Refill(); size_t extra_precision = reader->ReadFixedBits<2>(); @@ -408,12 +410,13 @@ Status ModularFrameDecoder::DecodeVarDCTDC(const FrameHeader& frame_header, Channel& ch = image.channel[c < 2 ? c ^ 1 : c]; ch.w >>= frame_header.chroma_subsampling.HShift(c); ch.h >>= frame_header.chroma_subsampling.VShift(c); - ch.shrink(); + JXL_RETURN_IF_ERROR(ch.shrink()); } if (!ModularGenericDecompress( reader, image, /*header=*/nullptr, stream_id, &options, /*undo_transforms=*/true, &tree, &code, &context_map)) { - return JXL_FAILURE("Failed to decode VarDCT DC group"); + return JXL_FAILURE("Failed to decode VarDCT DC group (DC group id %d)", + static_cast(group_id)); } DequantDC(r, &dec_state->shared_storage.dc_storage, &dec_state->shared_storage.quant_dc, image, @@ -433,12 +436,15 @@ Status ModularFrameDecoder::DecodeAcMetadata(const FrameHeader& frame_header, size_t count = reader->ReadBits(CeilLog2Nonzero(upper_bound)) + 1; size_t stream_id = ModularStreamId::ACMetadata(group_id).ID(frame_dim); // YToX, YToB, ACS + QF, EPF - Image image(r.xsize(), r.ysize(), full_image.bitdepth, 4); + JXL_ASSIGN_OR_RETURN( + Image image, Image::Create(r.xsize(), r.ysize(), full_image.bitdepth, 4)); static_assert(kColorTileDimInBlocks == 8, "Color tile size changed"); Rect cr(r.x0() >> 3, r.y0() >> 3, (r.xsize() + 7) >> 3, (r.ysize() + 7) >> 3); - image.channel[0] = Channel(cr.xsize(), cr.ysize(), 3, 3); - image.channel[1] = Channel(cr.xsize(), cr.ysize(), 3, 3); - image.channel[2] = Channel(count, 2, 0, 0); + JXL_ASSIGN_OR_RETURN(image.channel[0], + Channel::Create(cr.xsize(), cr.ysize(), 3, 3)); + JXL_ASSIGN_OR_RETURN(image.channel[1], + Channel::Create(cr.xsize(), cr.ysize(), 3, 3)); + JXL_ASSIGN_OR_RETURN(image.channel[2], Channel::Create(count, 2, 0, 0)); ModularOptions options; if (!ModularGenericDecompress( reader, image, /*header=*/nullptr, stream_id, &options, @@ -513,7 +519,7 @@ Status ModularFrameDecoder::DecodeAcMetadata(const FrameHeader& frame_header, Status ModularFrameDecoder::ModularImageToDecodedRect( const FrameHeader& frame_header, Image& gi, PassesDecoderState* dec_state, jxl::ThreadPool* pool, RenderPipelineInput& render_pipeline_input, - Rect modular_rect) { + Rect modular_rect) const { const auto* metadata = frame_header.nonserialized_metadata; JXL_CHECK(gi.transform.empty()); @@ -686,7 +692,12 @@ Status ModularFrameDecoder::FinalizeDecoding(const FrameHeader& frame_header, jxl::ThreadPool* pool, bool inplace) { if (!use_full_image) return true; - Image gi = (inplace ? std::move(full_image) : full_image.clone()); + Image gi; + if (inplace) { + gi = std::move(full_image); + } else { + JXL_ASSIGN_OR_RETURN(gi, Image::Clone(full_image)); + } size_t xsize = gi.w; size_t ysize = gi.h; @@ -714,6 +725,7 @@ Status ModularFrameDecoder::FinalizeDecoding(const FrameHeader& frame_header, use_group_ids); }, [&](const uint32_t group, size_t thread_id) { + if (has_error) return; RenderPipelineInput input = dec_state->render_pipeline->GetInputBuffers(group, thread_id); if (!ModularImageToDecodedRect( @@ -722,12 +734,13 @@ Status ModularFrameDecoder::FinalizeDecoding(const FrameHeader& frame_header, has_error = true; return; } - input.Done(); + if (!input.Done()) { + has_error = true; + return; + } }, "ModularToRect")); - if (has_error) { - return JXL_FAILURE("Error producing input to render pipeline"); - } + if (has_error) return JXL_FAILURE("Error producing input to render pipeline"); return true; } @@ -743,7 +756,8 @@ Status ModularFrameDecoder::DecodeQuantTable( // be negative. return JXL_FAILURE("Invalid qtable_den: value too small"); } - Image image(required_size_x, required_size_y, 8, 3); + JXL_ASSIGN_OR_RETURN(Image image, + Image::Create(required_size_x, required_size_y, 8, 3)); ModularOptions options; if (modular_frame_decoder) { JXL_RETURN_IF_ERROR(ModularGenericDecompress( diff --git a/third_party/jpeg-xl/lib/jxl/dec_modular.h b/third_party/jpeg-xl/lib/jxl/dec_modular.h index 58a6562740..23caad0c16 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_modular.h +++ b/third_party/jpeg-xl/lib/jxl/dec_modular.h @@ -123,7 +123,7 @@ class ModularFrameDecoder { PassesDecoderState* dec_state, jxl::ThreadPool* pool, RenderPipelineInput& render_pipeline_input, - Rect modular_rect); + Rect modular_rect) const; Image full_image; std::vector global_transform; diff --git a/third_party/jpeg-xl/lib/jxl/dec_noise.cc b/third_party/jpeg-xl/lib/jxl/dec_noise.cc index ae46b1062f..24f0136490 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_noise.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_noise.cc @@ -108,9 +108,8 @@ void Random3Planes(size_t visible_frame_index, size_t nonvisible_frame_index, size_t x0, size_t y0, const std::pair& plane0, const std::pair& plane1, const std::pair& plane2) { - return HWY_DYNAMIC_DISPATCH(Random3Planes)(visible_frame_index, - nonvisible_frame_index, x0, y0, - plane0, plane1, plane2); + HWY_DYNAMIC_DISPATCH(Random3Planes) + (visible_frame_index, nonvisible_frame_index, x0, y0, plane0, plane1, plane2); } void DecodeFloatParam(float precision, float* val, BitReader* br) { diff --git a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc index 0ae2223252..120a977ca7 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.cc @@ -10,26 +10,16 @@ #include #include -#include -#include #include #include -#include "lib/jxl/ans_params.h" -#include "lib/jxl/base/compiler_specific.h" -#include "lib/jxl/base/override.h" #include "lib/jxl/base/printf_macros.h" #include "lib/jxl/base/status.h" #include "lib/jxl/blending.h" -#include "lib/jxl/chroma_from_luma.h" #include "lib/jxl/common.h" // kMaxNumReferenceFrames #include "lib/jxl/dec_ans.h" -#include "lib/jxl/dec_frame.h" -#include "lib/jxl/entropy_coder.h" -#include "lib/jxl/frame_header.h" #include "lib/jxl/image.h" #include "lib/jxl/image_bundle.h" -#include "lib/jxl/image_ops.h" #include "lib/jxl/pack_signed.h" #include "lib/jxl/patch_dictionary_internal.h" @@ -138,7 +128,8 @@ Status PatchDictionary::Decode(BitReader* br, size_t xsize, size_t ysize, } for (size_t j = 0; j < num_ec + 1; j++) { uint32_t blend_mode = read_num(kPatchBlendModeContext); - if (blend_mode >= uint32_t(PatchBlendMode::kNumBlendModes)) { + if (blend_mode >= + static_cast(PatchBlendMode::kNumBlendModes)) { return JXL_FAILURE("Invalid patch blend mode: %u", blend_mode); } PatchBlending info; @@ -157,21 +148,22 @@ Status PatchDictionary::Decode(BitReader* br, size_t xsize, size_t ysize, return JXL_FAILURE( "Invalid alpha channel for blending: %u out of %u\n", info.alpha_channel, - (uint32_t)shared_->metadata->m.extra_channel_info.size()); + static_cast( + shared_->metadata->m.extra_channel_info.size())); } } else { info.alpha_channel = 0; } if (UsesClamp(info.mode)) { - info.clamp = read_num(kPatchClampContext); + info.clamp = static_cast(read_num(kPatchClampContext)); } else { info.clamp = false; } blendings_.push_back(info); } - positions_.push_back(std::move(pos)); + positions_.emplace_back(pos); } - ref_positions_.emplace_back(std::move(ref_pos)); + ref_positions_.emplace_back(ref_pos); } positions_.shrink_to_fit(); @@ -185,8 +177,8 @@ Status PatchDictionary::Decode(BitReader* br, size_t xsize, size_t ysize, int PatchDictionary::GetReferences() const { int result = 0; - for (size_t i = 0; i < ref_positions_.size(); ++i) { - result |= (1 << static_cast(ref_positions_[i].ref)); + for (const auto& ref_pos : ref_positions_) { + result |= (1 << static_cast(ref_pos.ref)); } return result; } @@ -263,11 +255,11 @@ void PatchDictionary::ComputePatchTree() { node.start = sorted_patches_y0_.size(); for (ssize_t i = static_cast(right_start) - 1; i >= static_cast(left_end); --i) { - sorted_patches_y1_.push_back({intervals[i].y1, intervals[i].idx}); + sorted_patches_y1_.emplace_back(intervals[i].y1, intervals[i].idx); } sort_by_y0(left_end, right_start); for (size_t i = left_end; i < right_start; ++i) { - sorted_patches_y0_.push_back({intervals[i].y0, intervals[i].idx}); + sorted_patches_y0_.emplace_back(intervals[i].y0, intervals[i].idx); } // Create the left and right nodes (if not empty). node.left_child = node.right_child = -1; @@ -294,7 +286,7 @@ std::vector PatchDictionary::GetPatchesForRow(size_t y) const { if (y < num_patches_.size() && num_patches_[y] > 0) { result.reserve(num_patches_[y]); for (ssize_t tree_idx = 0; tree_idx != -1;) { - JXL_DASSERT(tree_idx < (ssize_t)patch_tree_.size()); + JXL_DASSERT(tree_idx < static_cast(patch_tree_.size())); const auto& node = patch_tree_[tree_idx]; if (y <= node.y_center) { for (size_t i = 0; i < node.num; ++i) { @@ -322,8 +314,8 @@ std::vector PatchDictionary::GetPatchesForRow(size_t y) const { // Adds patches to a segment of `xsize` pixels, starting at `inout`, assumed // to be located at position (x0, y) in the frame. -void PatchDictionary::AddOneRow(float* const* inout, size_t y, size_t x0, - size_t xsize) const { +Status PatchDictionary::AddOneRow(float* const* inout, size_t y, size_t x0, + size_t xsize) const { size_t num_ec = shared_->metadata->m.num_extra_channels; std::vector fg_ptrs(3 + num_ec); for (size_t pos_idx : GetPatchesForRow(y)) { @@ -352,10 +344,11 @@ void PatchDictionary::AddOneRow(float* const* inout, size_t y, size_t x0, ref_pos.y0 + iy) + ref_pos.x0 + x0 - bx; } - PerformBlending(inout, fg_ptrs.data(), inout, patch_x0 - x0, - patch_x1 - patch_x0, blendings_[blending_idx], - blendings_.data() + blending_idx + 1, - shared_->metadata->m.extra_channel_info); + JXL_RETURN_IF_ERROR(PerformBlending( + inout, fg_ptrs.data(), inout, patch_x0 - x0, patch_x1 - patch_x0, + blendings_[blending_idx], blendings_.data() + blending_idx + 1, + shared_->metadata->m.extra_channel_info)); } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h index aac6111ae6..72dca8f057 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h +++ b/third_party/jpeg-xl/lib/jxl/dec_patch_dictionary.h @@ -12,12 +12,10 @@ #include #include -#include #include #include "lib/jxl/base/status.h" #include "lib/jxl/dec_bit_reader.h" -#include "lib/jxl/image.h" namespace jxl { @@ -109,7 +107,8 @@ class PatchDictionary { // Adds patches to a segment of `xsize` pixels, starting at `inout`, assumed // to be located at position (x0, y) in the frame. - void AddOneRow(float* const* inout, size_t y, size_t x0, size_t xsize) const; + Status AddOneRow(float* const* inout, size_t y, size_t x0, + size_t xsize) const; // Returns dependencies of this patch dictionary on reference frame ids as a // bit mask: bits 0-3 indicate reference frame 0-3. diff --git a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc index 2d40740262..6451c41f6d 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.cc @@ -21,21 +21,21 @@ void TransformToPixels(AcStrategy::Type strategy, float* JXL_RESTRICT coefficients, float* JXL_RESTRICT pixels, size_t pixels_stride, float* scratch_space) { - return HWY_DYNAMIC_DISPATCH(TransformToPixels)(strategy, coefficients, pixels, - pixels_stride, scratch_space); + HWY_DYNAMIC_DISPATCH(TransformToPixels) + (strategy, coefficients, pixels, pixels_stride, scratch_space); } HWY_EXPORT(LowestFrequenciesFromDC); void LowestFrequenciesFromDC(const jxl::AcStrategy::Type strategy, const float* dc, size_t dc_stride, float* llf, float* JXL_RESTRICT scratch) { - return HWY_DYNAMIC_DISPATCH(LowestFrequenciesFromDC)(strategy, dc, dc_stride, - llf, scratch); + HWY_DYNAMIC_DISPATCH(LowestFrequenciesFromDC) + (strategy, dc, dc_stride, llf, scratch); } HWY_EXPORT(AFVIDCT4x4); void AFVIDCT4x4(const float* JXL_RESTRICT coeffs, float* JXL_RESTRICT pixels) { - return HWY_DYNAMIC_DISPATCH(AFVIDCT4x4)(coeffs, pixels); + HWY_DYNAMIC_DISPATCH(AFVIDCT4x4)(coeffs, pixels); } #endif // HWY_ONCE diff --git a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h index f68481fda9..2cbf6bd5f6 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h +++ b/third_party/jpeg-xl/lib/jxl/dec_transforms_testonly.h @@ -22,8 +22,8 @@ void TransformToPixels(AcStrategy::Type strategy, float* JXL_RESTRICT scratch_space); // Equivalent of the above for DC image. -void LowestFrequenciesFromDC(const jxl::AcStrategy::Type strategy, - const float* dc, size_t dc_stride, float* llf, +void LowestFrequenciesFromDC(jxl::AcStrategy::Type strategy, const float* dc, + size_t dc_stride, float* llf, float* JXL_RESTRICT scratch); void AFVIDCT4x4(const float* JXL_RESTRICT coeffs, float* JXL_RESTRICT pixels); diff --git a/third_party/jpeg-xl/lib/jxl/dec_xyb-inl.h b/third_party/jpeg-xl/lib/jxl/dec_xyb-inl.h index 495693b257..09a8013960 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_xyb-inl.h +++ b/third_party/jpeg-xl/lib/jxl/dec_xyb-inl.h @@ -83,7 +83,7 @@ HWY_INLINE HWY_MAYBE_UNUSED void XybToRgb(D d, const V opsin_x, const V opsin_y, *linear_b = MulAdd(LoadDup128(d, &inverse_matrix[8 * 4]), mixed_b, *linear_b); } -static inline HWY_MAYBE_UNUSED bool HasFastXYBTosRGB8() { +inline HWY_MAYBE_UNUSED bool HasFastXYBTosRGB8() { #if HWY_TARGET == HWY_NEON return true; #else @@ -91,9 +91,9 @@ static inline HWY_MAYBE_UNUSED bool HasFastXYBTosRGB8() { #endif } -static inline HWY_MAYBE_UNUSED void FastXYBTosRGB8(const float* input[4], - uint8_t* output, - bool is_rgba, size_t xsize) { +inline HWY_MAYBE_UNUSED void FastXYBTosRGB8(const float* input[4], + uint8_t* output, bool is_rgba, + size_t xsize) { // This function is very NEON-specific. As such, it uses intrinsics directly. #if HWY_TARGET == HWY_NEON // WARNING: doing fixed point arithmetic correctly is very complicated. diff --git a/third_party/jpeg-xl/lib/jxl/dec_xyb.cc b/third_party/jpeg-xl/lib/jxl/dec_xyb.cc index 7010f0d813..a719b3eb8c 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_xyb.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_xyb.cc @@ -160,20 +160,19 @@ namespace jxl { HWY_EXPORT(OpsinToLinearInplace); void OpsinToLinearInplace(Image3F* JXL_RESTRICT inout, ThreadPool* pool, const OpsinParams& opsin_params) { - return HWY_DYNAMIC_DISPATCH(OpsinToLinearInplace)(inout, pool, opsin_params); + HWY_DYNAMIC_DISPATCH(OpsinToLinearInplace)(inout, pool, opsin_params); } HWY_EXPORT(OpsinToLinear); void OpsinToLinear(const Image3F& opsin, const Rect& rect, ThreadPool* pool, Image3F* JXL_RESTRICT linear, const OpsinParams& opsin_params) { - return HWY_DYNAMIC_DISPATCH(OpsinToLinear)(opsin, rect, pool, linear, - opsin_params); + HWY_DYNAMIC_DISPATCH(OpsinToLinear)(opsin, rect, pool, linear, opsin_params); } HWY_EXPORT(YcbcrToRgb); void YcbcrToRgb(const Image3F& ycbcr, Image3F* rgb, const Rect& rect) { - return HWY_DYNAMIC_DISPATCH(YcbcrToRgb)(ycbcr, rgb, rect); + HWY_DYNAMIC_DISPATCH(YcbcrToRgb)(ycbcr, rgb, rect); } HWY_EXPORT(HasFastXYBTosRGB8); @@ -182,7 +181,7 @@ bool HasFastXYBTosRGB8() { return HWY_DYNAMIC_DISPATCH(HasFastXYBTosRGB8)(); } HWY_EXPORT(FastXYBTosRGB8); void FastXYBTosRGB8(const float* input[4], uint8_t* output, bool is_rgba, size_t xsize) { - return HWY_DYNAMIC_DISPATCH(FastXYBTosRGB8)(input, output, is_rgba, xsize); + HWY_DYNAMIC_DISPATCH(FastXYBTosRGB8)(input, output, is_rgba, xsize); } void OpsinParams::Init(float intensity_target) { @@ -218,7 +217,7 @@ Status OutputEncodingInfo::SetFromMetadata(const CodecMetadata& metadata) { orig_intensity_target = metadata.m.IntensityTarget(); desired_intensity_target = orig_intensity_target; const auto& im = metadata.transform_data.opsin_inverse_matrix; - memcpy(orig_inverse_matrix, im.inverse_matrix, sizeof(orig_inverse_matrix)); + orig_inverse_matrix = im.inverse_matrix; default_transform = im.all_default; xyb_encoded = metadata.m.xyb_encoded; std::copy(std::begin(im.opsin_biases), std::end(im.opsin_biases), @@ -258,38 +257,38 @@ Status OutputEncodingInfo::SetColorEncoding(const ColorEncoding& c_desired) { // Compute the opsin inverse matrix and luminances based on primaries and // white point. - float inverse_matrix[9]; + Matrix3x3 inverse_matrix; bool inverse_matrix_is_default = default_transform; - memcpy(inverse_matrix, orig_inverse_matrix, sizeof(inverse_matrix)); - constexpr float kSRGBLuminances[3] = {0.2126, 0.7152, 0.0722}; - memcpy(luminances, kSRGBLuminances, sizeof(luminances)); + inverse_matrix = orig_inverse_matrix; + constexpr Vector3 kSRGBLuminances{0.2126, 0.7152, 0.0722}; + luminances = kSRGBLuminances; if ((c_desired.GetPrimariesType() != Primaries::kSRGB || c_desired.GetWhitePointType() != WhitePoint::kD65) && !c_desired.IsGray()) { - float srgb_to_xyzd50[9]; + Matrix3x3 srgb_to_xyzd50; const auto& srgb = ColorEncoding::SRGB(/*is_gray=*/false); PrimariesCIExy p = srgb.GetPrimaries(); CIExy w = srgb.GetWhitePoint(); JXL_CHECK(PrimariesToXYZD50(p.r.x, p.r.y, p.g.x, p.g.y, p.b.x, p.b.y, w.x, w.y, srgb_to_xyzd50)); - float original_to_xyz[3][3]; + Matrix3x3 original_to_xyz; p = c_desired.GetPrimaries(); w = c_desired.GetWhitePoint(); if (!PrimariesToXYZ(p.r.x, p.r.y, p.g.x, p.g.y, p.b.x, p.b.y, w.x, w.y, - &original_to_xyz[0][0])) { + original_to_xyz)) { return JXL_FAILURE("PrimariesToXYZ failed"); } - memcpy(luminances, original_to_xyz[1], sizeof luminances); + luminances = original_to_xyz[1]; if (xyb_encoded) { - float adapt_to_d50[9]; + Matrix3x3 adapt_to_d50; if (!AdaptToXYZD50(c_desired.GetWhitePoint().x, c_desired.GetWhitePoint().y, adapt_to_d50)) { return JXL_FAILURE("AdaptToXYZD50 failed"); } - float xyzd50_to_original[9]; - Mul3x3Matrix(adapt_to_d50, &original_to_xyz[0][0], xyzd50_to_original); + Matrix3x3 xyzd50_to_original; + Mul3x3Matrix(adapt_to_d50, original_to_xyz, xyzd50_to_original); JXL_RETURN_IF_ERROR(Inv3x3Matrix(xyzd50_to_original)); - float srgb_to_original[9]; + Matrix3x3 srgb_to_original; Mul3x3Matrix(xyzd50_to_original, srgb_to_xyzd50, srgb_to_original); Mul3x3Matrix(srgb_to_original, orig_inverse_matrix, inverse_matrix); inverse_matrix_is_default = false; @@ -297,12 +296,8 @@ Status OutputEncodingInfo::SetColorEncoding(const ColorEncoding& c_desired) { } if (c_desired.IsGray()) { - float tmp_inv_matrix[9]; - memcpy(tmp_inv_matrix, inverse_matrix, sizeof(inverse_matrix)); - float srgb_to_luma[9]; - memcpy(&srgb_to_luma[0], luminances, sizeof(luminances)); - memcpy(&srgb_to_luma[3], luminances, sizeof(luminances)); - memcpy(&srgb_to_luma[6], luminances, sizeof(luminances)); + Matrix3x3 tmp_inv_matrix = inverse_matrix; + Matrix3x3 srgb_to_luma{luminances, luminances, luminances}; Mul3x3Matrix(srgb_to_luma, tmp_inv_matrix, inverse_matrix); } diff --git a/third_party/jpeg-xl/lib/jxl/dec_xyb.h b/third_party/jpeg-xl/lib/jxl/dec_xyb.h index ddfd555632..65317f2f54 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_xyb.h +++ b/third_party/jpeg-xl/lib/jxl/dec_xyb.h @@ -39,7 +39,7 @@ struct OutputEncodingInfo { // Used for the HLG OOTF and PQ tone mapping. float orig_intensity_target; // Opsin inverse matrix taken from the metadata. - float orig_inverse_matrix[9]; + Matrix3x3 orig_inverse_matrix; bool default_transform; bool xyb_encoded; // @@ -60,7 +60,7 @@ struct OutputEncodingInfo { // Luminances of color_encoding's primaries, used for the HLG inverse OOTF and // for PQ tone mapping. // Default to sRGB's. - float luminances[3]; + Vector3 luminances; // Used for the HLG inverse OOTF and PQ tone mapping. float desired_intensity_target; bool cms_set = false; diff --git a/third_party/jpeg-xl/lib/jxl/decode.cc b/third_party/jpeg-xl/lib/jxl/decode.cc index b674d1ba88..605c2d6fd6 100644 --- a/third_party/jpeg-xl/lib/jxl/decode.cc +++ b/third_party/jpeg-xl/lib/jxl/decode.cc @@ -721,7 +721,7 @@ void JxlDecoderRewindDecodingState(JxlDecoder* dec) { dec->events_wanted = dec->orig_events_wanted; dec->basic_info_size_hint = InitialBasicInfoSizeHint(); - dec->have_container = 0; + dec->have_container = false; dec->box_count = 0; dec->downsampling_target = 8; dec->image_out_buffer_set = false; @@ -733,7 +733,7 @@ void JxlDecoderRewindDecodingState(JxlDecoder* dec) { dec->image_out_size = 0; dec->image_out_bit_depth.type = JXL_BIT_DEPTH_FROM_PIXEL_FORMAT; dec->extra_channel_output.clear(); - dec->next_in = 0; + dec->next_in = nullptr; dec->avail_in = 0; dec->input_closed = false; @@ -839,9 +839,9 @@ void JxlDecoderSkipFrames(JxlDecoder* dec, size_t amount) { internal_index, dec->frame_saved_as, dec->frame_references); dec->frame_required.resize(internal_index + 1, 0); - for (size_t i = 0; i < deps.size(); i++) { - JXL_ASSERT(deps[i] < dec->frame_required.size()); - dec->frame_required[deps[i]] = 1; + for (size_t idx : deps) { + JXL_ASSERT(idx < dec->frame_required.size()); + dec->frame_required[idx] = 1; } } } @@ -894,7 +894,7 @@ JxlDecoderStatus JxlDecoderSetKeepOrientation(JxlDecoder* dec, if (dec->stage != DecoderStage::kInited) { return JXL_API_ERROR("Must set keep_orientation option before starting"); } - dec->keep_orientation = !!skip_reorientation; + dec->keep_orientation = FROM_JXL_BOOL(skip_reorientation); return JXL_DEC_SUCCESS; } @@ -903,7 +903,7 @@ JxlDecoderStatus JxlDecoderSetUnpremultiplyAlpha(JxlDecoder* dec, if (dec->stage != DecoderStage::kInited) { return JXL_API_ERROR("Must set unpremul_alpha option before starting"); } - dec->unpremul_alpha = !!unpremul_alpha; + dec->unpremul_alpha = FROM_JXL_BOOL(unpremul_alpha); return JXL_DEC_SUCCESS; } @@ -912,7 +912,7 @@ JxlDecoderStatus JxlDecoderSetRenderSpotcolors(JxlDecoder* dec, if (dec->stage != DecoderStage::kInited) { return JXL_API_ERROR("Must set render_spotcolors option before starting"); } - dec->render_spotcolors = !!render_spotcolors; + dec->render_spotcolors = FROM_JXL_BOOL(render_spotcolors); return JXL_DEC_SUCCESS; } @@ -920,7 +920,7 @@ JxlDecoderStatus JxlDecoderSetCoalescing(JxlDecoder* dec, JXL_BOOL coalescing) { if (dec->stage != DecoderStage::kInited) { return JXL_API_ERROR("Must set coalescing option before starting"); } - dec->coalescing = !!coalescing; + dec->coalescing = FROM_JXL_BOOL(coalescing); return JXL_DEC_SUCCESS; } @@ -1076,7 +1076,7 @@ JxlDecoderStatus JxlDecoderReadAllHeaders(JxlDecoder* dec) { return JXL_DEC_ERROR; } IccBytes icc; - Bytes(decoded_icc).AppendTo(&icc); + Bytes(decoded_icc).AppendTo(icc); dec->metadata.m.color_encoding.SetICCRaw(std::move(icc)); } @@ -1118,7 +1118,7 @@ JxlDecoderStatus JxlDecoderProcessSections(JxlDecoder* dec) { if (OutOfBounds(pos, size, span.size())) { break; } - auto br = new jxl::BitReader(jxl::Bytes(span.data() + pos, size)); + auto* br = new jxl::BitReader(jxl::Bytes(span.data() + pos, size)); section_info.emplace_back(jxl::FrameDecoder::SectionInfo{br, id, i}); section_status.emplace_back(); pos += size; @@ -1263,9 +1263,9 @@ JxlDecoderStatus JxlDecoderProcessCodestream(JxlDecoder* dec) { frame_dim.ysize_upsampled_padded)) { return JXL_INPUT_ERROR("frame is too large"); } - bool output_needed = - (dec->preview_frame ? (dec->events_wanted & JXL_DEC_PREVIEW_IMAGE) - : (dec->events_wanted & JXL_DEC_FULL_IMAGE)); + int output_type = + dec->preview_frame ? JXL_DEC_PREVIEW_IMAGE : JXL_DEC_FULL_IMAGE; + bool output_needed = ((dec->events_wanted & output_type) != 0); if (output_needed) { JXL_API_RETURN_IF_ERROR(dec->frame_dec->InitFrameOutput()); } @@ -1376,7 +1376,7 @@ JxlDecoderStatus JxlDecoderProcessCodestream(JxlDecoder* dec) { } else { dec->frame_prog_detail = JxlProgressiveDetail::kFrames; } - dec->dc_frame_progression_done = 0; + dec->dc_frame_progression_done = false; dec->next_section = 0; dec->section_processed.clear(); @@ -1413,7 +1413,8 @@ JxlDecoderStatus JxlDecoderProcessCodestream(JxlDecoder* dec) { } if (dec->image_out_buffer_set) { - size_t xsize, ysize; + size_t xsize; + size_t ysize; GetCurrentDimensions(dec, xsize, ysize); size_t bits_per_sample = GetBitDepth( dec->image_out_bit_depth, dec->metadata.m, dec->image_out_format); @@ -1765,7 +1766,8 @@ static JxlDecoderStatus HandleBoxes(JxlDecoder* dec) { return JXL_DEC_SUCCESS; } - uint64_t box_size, header_size; + uint64_t box_size; + uint64_t header_size; JxlDecoderStatus status = ParseBoxHeader(dec->next_in, dec->avail_in, 0, dec->file_pos, dec->box_type, &box_size, &header_size); @@ -2042,7 +2044,7 @@ JxlDecoderStatus JxlDecoderProcessInput(JxlDecoder* dec) { dec->got_signature = true; if (sig == JXL_SIG_CONTAINER) { - dec->have_container = 1; + dec->have_container = true; } else { dec->last_codestream_seen = true; } @@ -2083,16 +2085,16 @@ JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder* dec, const jxl::ImageMetadata& meta = dec->metadata.m; - info->have_container = dec->have_container; + info->have_container = TO_JXL_BOOL(dec->have_container); info->xsize = dec->metadata.size.xsize(); info->ysize = dec->metadata.size.ysize(); - info->uses_original_profile = !meta.xyb_encoded; + info->uses_original_profile = TO_JXL_BOOL(!meta.xyb_encoded); info->bits_per_sample = meta.bit_depth.bits_per_sample; info->exponent_bits_per_sample = meta.bit_depth.exponent_bits_per_sample; - info->have_preview = meta.have_preview; - info->have_animation = meta.have_animation; + info->have_preview = TO_JXL_BOOL(meta.have_preview); + info->have_animation = TO_JXL_BOOL(meta.have_animation); info->orientation = static_cast(meta.orientation); if (!dec->keep_orientation) { @@ -2107,14 +2109,15 @@ JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder* dec, info->intensity_target = dec->desired_intensity_target; } info->min_nits = meta.tone_mapping.min_nits; - info->relative_to_max_display = meta.tone_mapping.relative_to_max_display; + info->relative_to_max_display = + TO_JXL_BOOL(meta.tone_mapping.relative_to_max_display); info->linear_below = meta.tone_mapping.linear_below; const jxl::ExtraChannelInfo* alpha = meta.Find(jxl::ExtraChannel::kAlpha); if (alpha != nullptr) { info->alpha_bits = alpha->bit_depth.bits_per_sample; info->alpha_exponent_bits = alpha->bit_depth.exponent_bits_per_sample; - info->alpha_premultiplied = alpha->alpha_associated; + info->alpha_premultiplied = TO_JXL_BOOL(alpha->alpha_associated); } else { info->alpha_bits = 0; info->alpha_exponent_bits = 0; @@ -2136,7 +2139,8 @@ JxlDecoderStatus JxlDecoderGetBasicInfo(const JxlDecoder* dec, info->animation.tps_denominator = dec->metadata.m.animation.tps_denominator; info->animation.num_loops = dec->metadata.m.animation.num_loops; - info->animation.have_timecodes = dec->metadata.m.animation.have_timecodes; + info->animation.have_timecodes = + TO_JXL_BOOL(dec->metadata.m.animation.have_timecodes); } if (meta.have_intrinsic_size) { @@ -2170,7 +2174,7 @@ JxlDecoderStatus JxlDecoderGetExtraChannelInfo(const JxlDecoder* dec, : 0; info->dim_shift = channel.dim_shift; info->name_length = channel.name.size(); - info->alpha_premultiplied = channel.alpha_associated; + info->alpha_premultiplied = TO_JXL_BOOL(channel.alpha_associated); info->spot_color[0] = channel.spot_color[0]; info->spot_color[1] = channel.spot_color[1]; info->spot_color[2] = channel.spot_color[2]; @@ -2348,29 +2352,41 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetCms(JxlDecoder* dec, return JXL_DEC_SUCCESS; } -JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize( - const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size) { +static JxlDecoderStatus GetMinSize(const JxlDecoder* dec, + const JxlPixelFormat* format, + size_t num_channels, size_t* min_size, + bool preview) { size_t bits; JxlDecoderStatus status = PrepareSizeCheck(dec, format, &bits); if (status != JXL_DEC_SUCCESS) return status; - if (format->num_channels < 3 && - !dec->image_metadata.color_encoding.IsGray()) { - return JXL_API_ERROR("Number of channels is too low for color output"); + size_t xsize; + size_t ysize; + if (preview) { + xsize = dec->metadata.oriented_preview_xsize(dec->keep_orientation); + ysize = dec->metadata.oriented_preview_ysize(dec->keep_orientation); + } else { + GetCurrentDimensions(dec, xsize, ysize); } - - size_t xsize = dec->metadata.oriented_preview_xsize(dec->keep_orientation); - size_t ysize = dec->metadata.oriented_preview_ysize(dec->keep_orientation); - + if (num_channels == 0) num_channels = format->num_channels; size_t row_size = - jxl::DivCeil(xsize * format->num_channels * bits, jxl::kBitsPerByte); + jxl::DivCeil(xsize * num_channels * bits, jxl::kBitsPerByte); size_t last_row_size = row_size; if (format->align > 1) { row_size = jxl::DivCeil(row_size, format->align) * format->align; } - *size = row_size * (ysize - 1) + last_row_size; + *min_size = row_size * (ysize - 1) + last_row_size; return JXL_DEC_SUCCESS; } +JXL_EXPORT JxlDecoderStatus JxlDecoderPreviewOutBufferSize( + const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size) { + if (format->num_channels < 3 && + !dec->image_metadata.color_encoding.IsGray()) { + return JXL_API_ERROR("Number of channels is too low for color output"); + } + return GetMinSize(dec, format, 0, size, true); +} + JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer( JxlDecoder* dec, const JxlPixelFormat* format, void* buffer, size_t size) { if (!dec->got_basic_info || !dec->metadata.m.have_preview || @@ -2401,23 +2417,12 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderSetPreviewOutBuffer( JXL_EXPORT JxlDecoderStatus JxlDecoderImageOutBufferSize( const JxlDecoder* dec, const JxlPixelFormat* format, size_t* size) { - size_t bits; - JxlDecoderStatus status = PrepareSizeCheck(dec, format, &bits); - if (status != JXL_DEC_SUCCESS) return status; if (format->num_channels < 3 && !dec->image_metadata.color_encoding.IsGray()) { return JXL_API_ERROR("Number of channels is too low for color output"); } - size_t xsize, ysize; - GetCurrentDimensions(dec, xsize, ysize); - size_t row_size = - jxl::DivCeil(xsize * format->num_channels * bits, jxl::kBitsPerByte); - if (format->align > 1) { - row_size = jxl::DivCeil(row_size, format->align) * format->align; - } - *size = row_size * ysize; - return JXL_DEC_SUCCESS; + return GetMinSize(dec, format, 0, size, false); } JxlDecoderStatus JxlDecoderSetImageOutBuffer(JxlDecoder* dec, @@ -2463,22 +2468,7 @@ JxlDecoderStatus JxlDecoderExtraChannelBufferSize(const JxlDecoder* dec, return JXL_API_ERROR("Invalid extra channel index"); } - size_t num_channels = 1; // Do not use format's num_channels - - size_t bits; - JxlDecoderStatus status = PrepareSizeCheck(dec, format, &bits); - if (status != JXL_DEC_SUCCESS) return status; - - size_t xsize, ysize; - GetCurrentDimensions(dec, xsize, ysize); - size_t row_size = - jxl::DivCeil(xsize * num_channels * bits, jxl::kBitsPerByte); - if (format->align > 1) { - row_size = jxl::DivCeil(row_size, format->align) * format->align; - } - *size = row_size * ysize; - - return JXL_DEC_SUCCESS; + return GetMinSize(dec, format, 1, size, false); } JxlDecoderStatus JxlDecoderSetExtraChannelBuffer(JxlDecoder* dec, @@ -2577,8 +2567,9 @@ JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder* dec, } } header->name_length = dec->frame_header->name.size(); - header->is_last = dec->frame_header->is_last; - size_t xsize, ysize; + header->is_last = TO_JXL_BOOL(dec->frame_header->is_last); + size_t xsize; + size_t ysize; GetCurrentDimensions(dec, xsize, ysize); header->layer_info.xsize = xsize; header->layer_info.ysize = ysize; @@ -2620,7 +2611,7 @@ JxlDecoderStatus JxlDecoderGetFrameHeader(const JxlDecoder* dec, header->layer_info.blend_info.alpha = dec->frame_header->blending_info.alpha_channel; header->layer_info.blend_info.clamp = - dec->frame_header->blending_info.clamp; + TO_JXL_BOOL(dec->frame_header->blending_info.clamp); header->layer_info.save_as_reference = dec->frame_header->save_as_reference; } return JXL_DEC_SUCCESS; @@ -2643,7 +2634,7 @@ JxlDecoderStatus JxlDecoderGetExtraChannelBlendInfo(const JxlDecoder* dec, blend_info->alpha = dec->frame_header->extra_channel_blending_info[index].alpha_channel; blend_info->clamp = - dec->frame_header->extra_channel_blending_info[index].clamp; + TO_JXL_BOOL(dec->frame_header->extra_channel_blending_info[index].clamp); return JXL_DEC_SUCCESS; } @@ -2717,7 +2708,7 @@ JxlDecoderStatus JxlDecoderSetOutputColorProfile( "setting output color profile from icc_data not yet implemented."); } JXL_API_RETURN_IF_ERROR( - (int)output_encoding.MaybeSetColorEncoding(std::move(c_dst))); + static_cast(output_encoding.MaybeSetColorEncoding(c_dst))); return JXL_DEC_SUCCESS; } @@ -2769,7 +2760,7 @@ JxlDecoderStatus JxlDecoderSetDecompressBoxes(JxlDecoder* dec, JXL_BOOL decompress) { // TODO(lode): return error if libbrotli is not compiled in the jxl decoding // library - dec->decompress_boxes = decompress; + dec->decompress_boxes = FROM_JXL_BOOL(decompress); return JXL_DEC_SUCCESS; } @@ -2798,6 +2789,17 @@ JxlDecoderStatus JxlDecoderGetBoxSizeRaw(const JxlDecoder* dec, return JXL_DEC_SUCCESS; } +JxlDecoderStatus JxlDecoderGetBoxSizeContents(const JxlDecoder* dec, + uint64_t* size) { + if (!dec->box_event) { + return JXL_API_ERROR("can only get box info after JXL_DEC_BOX event"); + } + if (size) { + *size = dec->box_contents_size; + } + return JXL_DEC_SUCCESS; +} + JxlDecoderStatus JxlDecoderSetProgressiveDetail(JxlDecoder* dec, JxlProgressiveDetail detail) { if (detail != kDC && detail != kLastPasses && detail != kPasses) { diff --git a/third_party/jpeg-xl/lib/jxl/decode_test.cc b/third_party/jpeg-xl/lib/jxl/decode_test.cc index caee6dbc56..33176cfd66 100644 --- a/third_party/jpeg-xl/lib/jxl/decode_test.cc +++ b/third_party/jpeg-xl/lib/jxl/decode_test.cc @@ -47,7 +47,6 @@ #include "lib/jxl/dec_bit_reader.h" #include "lib/jxl/dec_external_image.h" #include "lib/jxl/enc_aux_out.h" -#include "lib/jxl/enc_butteraugli_comparator.h" #include "lib/jxl/enc_external_image.h" #include "lib/jxl/enc_fields.h" #include "lib/jxl/enc_frame.h" @@ -113,23 +112,23 @@ enum CodeStreamBoxFormat { }; // Unknown boxes for testing -static const char* unk1_box_type = "unk1"; -static const char* unk1_box_contents = "abcdefghijklmnopqrstuvwxyz"; -static const size_t unk1_box_size = strlen(unk1_box_contents); -static const char* unk2_box_type = "unk2"; -static const char* unk2_box_contents = "0123456789"; -static const size_t unk2_box_size = strlen(unk2_box_contents); -static const char* unk3_box_type = "unk3"; -static const char* unk3_box_contents = "ABCDEF123456"; -static const size_t unk3_box_size = strlen(unk3_box_contents); +const char* unk1_box_type = "unk1"; +const char* unk1_box_contents = "abcdefghijklmnopqrstuvwxyz"; +const size_t unk1_box_size = strlen(unk1_box_contents); +const char* unk2_box_type = "unk2"; +const char* unk2_box_contents = "0123456789"; +const size_t unk2_box_size = strlen(unk2_box_contents); +const char* unk3_box_type = "unk3"; +const char* unk3_box_contents = "ABCDEF123456"; +const size_t unk3_box_size = strlen(unk3_box_contents); // Box with brob-compressed exif, including header -static const uint8_t* box_brob_exif = reinterpret_cast( +const uint8_t* box_brob_exif = reinterpret_cast( "\0\0\0@brobExif\241\350\2\300\177\244v\2525\304\360\27=?\267{" "\33\37\314\332\214QX17PT\"\256\0\0\202s\214\313t\333\310\320k\20\276\30" "\204\277l$\326c#\1\b"); size_t box_brob_exif_size = 64; // The uncompressed Exif data from the brob box -static const uint8_t* exif_uncompressed = reinterpret_cast( +const uint8_t* exif_uncompressed = reinterpret_cast( "\0\0\0\0MM\0*" "\0\0\0\b\0\5\1\22\0\3\0\0\0\1\0\5\0\0\1\32\0\5\0\0\0\1\0\0\0J\1\33\0\5\0\0" "\0\1\0\0\0R\1(" @@ -193,7 +192,7 @@ void AppendTestBox(const char* type, const char* contents, size_t contents_size, bytes->push_back(type[2]); bytes->push_back(type[3]); const uint8_t* contents_u = reinterpret_cast(contents); - Bytes(contents_u, contents_size).AppendTo(bytes); + Bytes(contents_u, contents_size).AppendTo(*bytes); } enum PreviewMode { @@ -214,13 +213,15 @@ void GeneratePreview(PreviewMode preview_mode, ImageBundle* ib) { } } }; - Image3F preview(ib->xsize() * 7, ib->ysize() * 7); + JXL_ASSIGN_OR_DIE(Image3F preview, + Image3F::Create(ib->xsize() * 7, ib->ysize() * 7)); for (size_t c = 0; c < 3; ++c) { upsample7(ib->color()->Plane(c), &preview.Plane(c)); } std::vector extra_channels; for (size_t i = 0; i < ib->extra_channels().size(); ++i) { - ImageF ec(ib->xsize() * 7, ib->ysize() * 7); + JXL_ASSIGN_OR_DIE(ImageF ec, + ImageF::Create(ib->xsize() * 7, ib->ysize() * 7)); upsample7(ib->extra_channels()[i], &ec); extra_channels.emplace_back(std::move(ec)); } @@ -258,7 +259,8 @@ std::vector CreateTestJXLCodestream( const TestCodestreamParams& params) { // Compress the pixels with JPEG XL. bool grayscale = (num_channels <= 2); - bool include_alpha = !(num_channels & 1) && params.jpeg_codestream == nullptr; + bool have_alpha = ((num_channels & 1) == 0); + bool include_alpha = have_alpha && params.jpeg_codestream == nullptr; size_t bitdepth = params.jpeg_codestream == nullptr ? 16 : 8; CodecInOut io; io.SetSize(xsize, ysize); @@ -296,7 +298,8 @@ std::vector CreateTestJXLCodestream( if (jxl::extras::CanDecode(jxl::extras::Codec::kJPG)) { std::vector jpeg_bytes; extras::PackedPixelFile ppf; - extras::PackedFrame frame(xsize, ysize, format); + JXL_ASSIGN_OR_DIE(extras::PackedFrame frame, + extras::PackedFrame::Create(xsize, ysize, format)); JXL_ASSERT(frame.color.pixels_size == pixels.size()); memcpy(frame.color.pixels(0, 0, 0), pixels.data(), pixels.size()); ppf.frames.emplace_back(std::move(frame)); @@ -307,9 +310,9 @@ std::vector CreateTestJXLCodestream( auto encoder = extras::GetJPEGEncoder(); encoder->SetOption("quality", "70"); extras::EncodedImage encoded; - EXPECT_TRUE(encoder->Encode(ppf, &encoded)); + EXPECT_TRUE(encoder->Encode(ppf, &encoded, nullptr)); jpeg_bytes = encoded.bitstreams[0]; - Bytes(jpeg_bytes).AppendTo(params.jpeg_codestream); + Bytes(jpeg_bytes).AppendTo(*params.jpeg_codestream); EXPECT_TRUE(jxl::jpeg::DecodeImageJPG( jxl::Bytes(jpeg_bytes.data(), jpeg_bytes.size()), &io)); EXPECT_TRUE( @@ -321,7 +324,7 @@ std::vector CreateTestJXLCodestream( } } if (params.preview_mode) { - io.preview_frame = io.Main().Copy(); + JXL_ASSIGN_OR_DIE(io.preview_frame, io.Main().Copy()); GeneratePreview(params.preview_mode, &io.preview_frame); io.metadata.m.have_preview = true; EXPECT_TRUE(io.metadata.m.preview_size.Set(io.preview_frame.xsize(), @@ -358,11 +361,11 @@ std::vector CreateTestJXLCodestream( compressed.data() + compressed.size()); std::vector c; - Bytes(header).AppendTo(&c); + Bytes(header).AppendTo(c); if (params.jpeg_codestream != nullptr) { jxl::AppendBoxHeader(jxl::MakeBoxType("jbrd"), jpeg_data.size(), false, &c); - Bytes(jpeg_data).AppendTo(&c); + Bytes(jpeg_data).AppendTo(c); } uint32_t jxlp_index = 0; if (add_container == kCSBF_Multi_First_Empty) { @@ -381,7 +384,7 @@ std::vector CreateTestJXLCodestream( c.push_back('l'); c.push_back('p'); AppendU32BE(jxlp_index++, &c); - Bytes(compressed0).AppendTo(&c); + Bytes(compressed0).AppendTo(c); // A few non-codestream boxes in between AppendTestBox(unk1_box_type, unk1_box_contents, unk1_box_size, false, &c); AppendTestBox(unk2_box_type, unk2_box_contents, unk2_box_size, false, &c); @@ -399,7 +402,7 @@ std::vector CreateTestJXLCodestream( c.push_back('l'); c.push_back('p'); AppendU32BE(jxlp_index++, &c); - Bytes(compressed1).AppendTo(&c); + Bytes(compressed1).AppendTo(c); // Third (last) codestream part AppendU32BE(add_container == kCSBF_Multi_Zero_Terminated ? 0 @@ -414,7 +417,7 @@ std::vector CreateTestJXLCodestream( } else { AppendU32BE(jxlp_index++, &c); } - Bytes(compressed2).AppendTo(&c); + Bytes(compressed2).AppendTo(c); if (add_container == kCSBF_Multi_Last_Empty_Other) { // Empty placeholder codestream part AppendU32BE(12, &c); @@ -437,14 +440,14 @@ std::vector CreateTestJXLCodestream( compressed.swap(c); } else { std::vector c; - Bytes(header).AppendTo(&c); + Bytes(header).AppendTo(c); if (params.jpeg_codestream != nullptr) { jxl::AppendBoxHeader(jxl::MakeBoxType("jbrd"), jpeg_data.size(), false, &c); - Bytes(jpeg_data).AppendTo(&c); + Bytes(jpeg_data).AppendTo(c); } if (add_container == kCSBF_Brob_Exif) { - Bytes(box_brob_exif, box_brob_exif_size).AppendTo(&c); + Bytes(box_brob_exif, box_brob_exif_size).AppendTo(c); } AppendU32BE(add_container == kCSBF_Single_Zero_Terminated ? 0 @@ -454,7 +457,7 @@ std::vector CreateTestJXLCodestream( c.push_back('x'); c.push_back('l'); c.push_back('c'); - Bytes(compressed).AppendTo(&c); + Bytes(compressed).AppendTo(c); if (add_container == kCSBF_Single_Other) { AppendTestBox(unk1_box_type, unk1_box_contents, unk1_box_size, false, &c); @@ -609,7 +612,7 @@ std::vector DecodeWithAPI(Span compressed, bool use_callback, bool set_buffer_early, bool use_resizable_runner, bool require_boxes, bool expect_success) { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); std::vector pixels = DecodeWithAPI(dec, compressed, format, use_callback, set_buffer_early, use_resizable_runner, require_boxes, expect_success); @@ -622,6 +625,11 @@ std::vector DecodeWithAPI(Span compressed, //////////////////////////////////////////////////////////////////////////////// +using jxl::Image3F; +using jxl::ImageF; +using jxl::test::BoolToCStr; +using jxl::test::ButteraugliDistance; + TEST(DecodeTest, JxlSignatureCheckTest) { std::vector>> tests = { // No JPEGXL header starts with 'a'. @@ -728,22 +736,22 @@ std::vector GetTestHeader(size_t xsize, size_t ysize, const std::vector codestream_box_header = {0, 0, 0, 0xff, 'j', 'x', 'l', 'c'}; - for (size_t i = 0; i < signature_box.size(); i++) { - writer.Write(8, signature_box[i]); + for (uint8_t c : signature_box) { + writer.Write(8, c); } - for (size_t i = 0; i < filetype_box.size(); i++) { - writer.Write(8, filetype_box[i]); + for (uint8_t c : filetype_box) { + writer.Write(8, c); } if (insert_extra_box) { - for (size_t i = 0; i < extra_box_header.size(); i++) { - writer.Write(8, extra_box_header[i]); + for (uint8_t c : extra_box_header) { + writer.Write(8, c); } for (size_t i = 0; i < 255 - 8; i++) { writer.Write(8, 0); } } - for (size_t i = 0; i < codestream_box_header.size(); i++) { - writer.Write(8, codestream_box_header[i]); + for (uint8_t c : codestream_box_header) { + writer.Write(8, c); } } @@ -794,7 +802,7 @@ TEST(DecodeTest, BasicInfoTest) { size_t bits_per_sample[2] = {8, 23}; size_t orientation[2] = {3, 5}; size_t alpha_bits[2] = {0, 8}; - JXL_BOOL have_container[2] = {0, 1}; + bool have_container[2] = {false, true}; bool xyb_encoded = false; std::vector> test_samples; @@ -823,14 +831,15 @@ TEST(DecodeTest, BasicInfoTest) { JxlDecoderStatus status = JxlDecoderProcessInput(dec); JxlBasicInfo info; - bool have_basic_info = !JxlDecoderGetBasicInfo(dec, &info); + JxlDecoderStatus bi_status = JxlDecoderGetBasicInfo(dec, &info); + bool have_basic_info = (bi_status == JXL_DEC_SUCCESS); if (size == data.size()) { EXPECT_EQ(JXL_DEC_BASIC_INFO, status); // All header bytes given so the decoder must have the basic info. EXPECT_EQ(true, have_basic_info); - EXPECT_EQ(have_container[i], info.have_container); + EXPECT_EQ(have_container[i], FROM_JXL_BOOL(info.have_container)); EXPECT_EQ(alpha_bits[i], info.alpha_bits); // Orientations 5..8 swap the dimensions if (orientation[i] >= 5) { @@ -1291,7 +1300,7 @@ class DecodeTestParam : public ::testing::TestWithParam {}; TEST_P(DecodeTestParam, PixelTest) { PixelTestConfig config = GetParam(); - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); if (config.keep_orientation) { EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetKeepOrientation(dec, JXL_TRUE)); @@ -1352,7 +1361,7 @@ TEST_P(DecodeTestParam, PixelTest) { color_encoding, 16, format_orig, nullptr, &io.Main())); - for (size_t i = 0; i < pixels.size(); i++) pixels[i] = 0; + for (uint8_t& pixel : pixels) pixel = 0; EXPECT_TRUE(ConvertToExternal( io.Main(), 16, /*float_out=*/false, orig_channels, JXL_BIG_ENDIAN, @@ -1420,7 +1429,7 @@ std::vector GeneratePixelTests() { c.add_intrinsic_size = intrinsic_size; c.xsize = xsize; c.ysize = ysize; - c.add_container = (CodeStreamBoxFormat)box; + c.add_container = box; c.output_channels = ch.output_channels; c.data_type = format.data_type; c.endianness = format.endianness; @@ -1435,7 +1444,7 @@ std::vector GeneratePixelTests() { // Test output formats and methods. for (ChannelInfo ch : ch_info) { - for (int use_callback = 0; use_callback <= 1; use_callback++) { + for (bool use_callback : {false, true}) { for (size_t upsampling : {1, 2, 4, 8}) { for (OutputFormat fmt : out_formats) { make_test(ch, 301, 33, jxl::kNoPreview, @@ -1451,8 +1460,8 @@ std::vector GeneratePixelTests() { // Test codestream formats. for (size_t box = 1; box < kCSBF_NUM_ENTRIES; ++box) { make_test(ch_info[0], 77, 33, jxl::kNoPreview, - /*add_intrinsic_size=*/false, (CodeStreamBoxFormat)box, - JXL_ORIENT_IDENTITY, + /*add_intrinsic_size=*/false, + static_cast(box), JXL_ORIENT_IDENTITY, /*keep_orientation=*/false, out_formats[0], /*use_callback=*/false, /*set_buffer_early=*/false, /*resizable_runner=*/false, 1); @@ -1460,7 +1469,7 @@ std::vector GeneratePixelTests() { // Test previews. for (int preview_mode = 0; preview_mode < jxl::kNumPreviewModes; preview_mode++) { - make_test(ch_info[0], 77, 33, (jxl::PreviewMode)preview_mode, + make_test(ch_info[0], 77, 33, static_cast(preview_mode), /*add_intrinsic_size=*/false, CodeStreamBoxFormat::kCSBF_None, JXL_ORIENT_IDENTITY, /*keep_orientation=*/false, out_formats[0], @@ -1468,8 +1477,7 @@ std::vector GeneratePixelTests() { /*resizable_runner=*/false, 1); } // Test intrinsic sizes. - for (int add_intrinsic_size = 0; add_intrinsic_size <= 1; - add_intrinsic_size++) { + for (bool add_intrinsic_size : {false, true}) { make_test(ch_info[0], 55, 34, jxl::kNoPreview, add_intrinsic_size, CodeStreamBoxFormat::kCSBF_None, JXL_ORIENT_IDENTITY, /*keep_orientation=*/false, out_formats[0], @@ -1496,8 +1504,8 @@ std::vector GeneratePixelTests() { // Test orientations. for (int orientation = 2; orientation <= 8; ++orientation) { - for (int keep_orientation = 0; keep_orientation <= 1; keep_orientation++) { - for (int use_callback = 0; use_callback <= 1; use_callback++) { + for (bool keep_orientation : {false, true}) { + for (bool use_callback : {false, true}) { for (ChannelInfo ch : ch_info) { for (OutputFormat fmt : out_formats) { make_test(ch, 280, 12, jxl::kNoPreview, @@ -1549,7 +1557,7 @@ std::ostream& operator<<(std::ostream& os, const PixelTestConfig& c) { } if (c.add_container != CodeStreamBoxFormat::kCSBF_None) { os << "Box"; - os << (size_t)c.add_container; + os << static_cast(c.add_container); } if (c.preview_mode == jxl::kSmallPreview) os << "Preview"; if (c.preview_mode == jxl::kBigPreview) os << "BigPreview"; @@ -1575,9 +1583,10 @@ JXL_GTEST_INSTANTIATE_TEST_SUITE_P(DecodeTest, DecodeTestParam, PixelTestDescription); TEST(DecodeTest, PixelTestWithICCProfileLossless) { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; size_t num_pixels = xsize * ysize; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 4, 0); JxlPixelFormat format_orig = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -1642,9 +1651,10 @@ TEST(DecodeTest, PixelTestWithICCProfileLossless) { } TEST(DecodeTest, PixelTestWithICCProfileLossy) { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; size_t num_pixels = xsize * ysize; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); JxlPixelFormat format_orig = {3, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -1678,7 +1688,7 @@ TEST(DecodeTest, PixelTestWithICCProfileLossy) { jxl::ColorEncoding color_encoding1; jxl::IccBytes icc; - jxl::Bytes(icc_data).AppendTo(&icc); + jxl::Bytes(icc_data).AppendTo(icc); EXPECT_TRUE(color_encoding1.SetICC(std::move(icc), JxlGetDefaultCms())); jxl::Span span1(pixels2.data(), pixels2.size()); jxl::CodecInOut io1; @@ -1688,10 +1698,10 @@ TEST(DecodeTest, PixelTestWithICCProfileLossy) { /*pool=*/nullptr, &io1.Main())); jxl::ButteraugliParams ba; - EXPECT_THAT( + EXPECT_SLIGHTLY_BELOW( ButteraugliDistance(io0.frames, io1.frames, ba, *JxlGetDefaultCms(), /*distmap=*/nullptr, nullptr), - IsSlightlyBelow(0.56f)); + 0.56f); JxlDecoderDestroy(dec); } @@ -1753,7 +1763,8 @@ JXL_GTEST_INSTANTIATE_TEST_SUITE_P( DecodeAllEncodingsTestInstantiation, DecodeAllEncodingsTest, ::testing::ValuesIn(jxl::test::AllEncodings())); TEST_P(DecodeAllEncodingsTest, PreserveOriginalProfileTest) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); JxlPixelFormat format = {3, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; int events = JXL_DEC_BASIC_INFO | JXL_DEC_COLOR_ENCODING | JXL_DEC_FULL_IMAGE; @@ -1796,7 +1807,8 @@ namespace { void SetPreferredColorProfileTest( const jxl::test::ColorEncodingDescriptor& from, bool icc_dst, bool use_cms) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; int events = JXL_DEC_BASIC_INFO | JXL_DEC_COLOR_ENCODING | JXL_DEC_FULL_IMAGE; jxl::ColorEncoding c_in = jxl::test::ColorEncodingFromDescriptor(from); if (c_in.GetRenderingIntent() != jxl::RenderingIntent::kRelative) return; @@ -1970,6 +1982,7 @@ void DecodeImageWithColorEncoding(const std::vector& compressed, EXPECT_EQ(JXL_DEC_BASIC_INFO, JxlDecoderProcessInput(dec)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBasicInfo(dec, &info)); EXPECT_EQ(JXL_DEC_COLOR_ENCODING, JxlDecoderProcessInput(dec)); + // TODO(eustas): why unused? std::string color_space_in = GetOrigProfile(dec); if (with_cms) { JxlDecoderSetCms(dec, *JxlGetDefaultCms()); @@ -2009,7 +2022,8 @@ JXL_GTEST_INSTANTIATE_TEST_SUITE_P( TEST_P(DecodeAllEncodingsWithCMSTest, DecodeWithCMS) { auto all_encodings = jxl::test::AllEncodings(); uint32_t num_channels = 3; - size_t xsize = 177, ysize = 123; + size_t xsize = 177; + size_t ysize = 123; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); jxl::TestCodestreamParams params; @@ -2045,9 +2059,10 @@ TEST_P(DecodeAllEncodingsWithCMSTest, DecodeWithCMS) { // and to RGBA8 TEST(DecodeTest, PixelTestOpaqueSrgbLossy) { for (unsigned channels = 3; channels <= 4; channels++) { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; size_t num_pixels = xsize * ysize; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); @@ -2082,10 +2097,10 @@ TEST(DecodeTest, PixelTestOpaqueSrgbLossy) { /*pool=*/nullptr, &io1.Main())); jxl::ButteraugliParams ba; - EXPECT_THAT( + EXPECT_SLIGHTLY_BELOW( ButteraugliDistance(io0.frames, io1.frames, ba, *JxlGetDefaultCms(), /*distmap=*/nullptr, nullptr), - IsSlightlyBelow(0.65f)); + 0.65f); JxlDecoderDestroy(dec); } @@ -2094,9 +2109,10 @@ TEST(DecodeTest, PixelTestOpaqueSrgbLossy) { // Opaque image with noise enabled, decoded to RGB8 and RGBA8. TEST(DecodeTest, PixelTestOpaqueSrgbLossyNoise) { for (unsigned channels = 3; channels <= 4; channels++) { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); - size_t xsize = 512, ysize = 300; + size_t xsize = 512; + size_t ysize = 300; size_t num_pixels = xsize * ysize; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); @@ -2132,26 +2148,28 @@ TEST(DecodeTest, PixelTestOpaqueSrgbLossyNoise) { /*pool=*/nullptr, &io1.Main())); jxl::ButteraugliParams ba; - EXPECT_THAT( + EXPECT_SLIGHTLY_BELOW( ButteraugliDistance(io0.frames, io1.frames, ba, *JxlGetDefaultCms(), /*distmap=*/nullptr, nullptr), - IsSlightlyBelow(1.3f)); + 1.3f); JxlDecoderDestroy(dec); } } TEST(DecodeTest, ProcessEmptyInputWithBoxes) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); jxl::CompressParams cparams; uint32_t channels = 3; JxlPixelFormat format = {channels, JXL_TYPE_FLOAT, JXL_LITTLE_ENDIAN, 0}; for (int i = 0; i < kCSBF_NUM_ENTRIES; ++i) { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); jxl::TestCodestreamParams params; - params.box_format = (CodeStreamBoxFormat)i; - printf("Testing empty input with box format %d\n", (int)params.box_format); + params.box_format = static_cast(i); + printf("Testing empty input with box format %d\n", + static_cast(params.box_format)); std::vector compressed = jxl::CreateTestJXLCodestream( jxl::Bytes(pixels.data(), pixels.size()), xsize, ysize, 3, params); const int events = @@ -2175,14 +2193,15 @@ TEST(DecodeTest, ProcessEmptyInputWithBoxes) { } TEST(DecodeTest, ExtraBytesAfterCompressedStream) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; size_t num_pixels = xsize * ysize; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); jxl::CompressParams cparams; for (int i = 0; i < kCSBF_NUM_ENTRIES; ++i) { - CodeStreamBoxFormat box_format = (CodeStreamBoxFormat)i; + CodeStreamBoxFormat box_format = static_cast(i); if (box_format == kCSBF_Multi_Other_Zero_Terminated) continue; - printf("Testing with box format %d\n", (int)box_format); + printf("Testing with box format %d\n", static_cast(box_format)); size_t last_unknown_box_size = 0; if (box_format == kCSBF_Single_Other) { last_unknown_box_size = unk1_box_size + 8; @@ -2201,7 +2220,7 @@ TEST(DecodeTest, ExtraBytesAfterCompressedStream) { compressed.push_back(0); compressed.push_back(1); compressed.push_back(2); - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); uint32_t channels = 3; JxlPixelFormat format = {channels, JXL_TYPE_FLOAT, JXL_LITTLE_ENDIAN, 0}; std::vector pixels2 = jxl::DecodeWithAPI( @@ -2217,14 +2236,15 @@ TEST(DecodeTest, ExtraBytesAfterCompressedStream) { } TEST(DecodeTest, ExtraBytesAfterCompressedStreamRequireBoxes) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; size_t num_pixels = xsize * ysize; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); jxl::CompressParams cparams; for (int i = 0; i < kCSBF_NUM_ENTRIES; ++i) { - CodeStreamBoxFormat box_format = (CodeStreamBoxFormat)i; + CodeStreamBoxFormat box_format = static_cast(i); if (box_format == kCSBF_Multi_Other_Zero_Terminated) continue; - printf("Testing with box format %d\n", (int)box_format); + printf("Testing with box format %d\n", static_cast(box_format)); bool expect_success = (box_format == kCSBF_None || box_format == kCSBF_Single_Zero_Terminated || box_format == kCSBF_Multi_Zero_Terminated); @@ -2236,7 +2256,7 @@ TEST(DecodeTest, ExtraBytesAfterCompressedStreamRequireBoxes) { compressed.push_back(0); compressed.push_back(1); compressed.push_back(2); - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); uint32_t channels = 3; JxlPixelFormat format = {channels, JXL_TYPE_FLOAT, JXL_LITTLE_ENDIAN, 0}; std::vector pixels2 = jxl::DecodeWithAPI( @@ -2251,35 +2271,38 @@ TEST(DecodeTest, ExtraBytesAfterCompressedStreamRequireBoxes) { } TEST(DecodeTest, ConcatenatedCompressedStreams) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; size_t num_pixels = xsize * ysize; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); jxl::CompressParams cparams; for (int i = 0; i < kCSBF_NUM_ENTRIES; ++i) { - CodeStreamBoxFormat first_box_format = (CodeStreamBoxFormat)i; + CodeStreamBoxFormat first_box_format = static_cast(i); if (first_box_format == kCSBF_Multi_Other_Zero_Terminated) continue; jxl::TestCodestreamParams params1; params1.box_format = first_box_format; std::vector compressed1 = jxl::CreateTestJXLCodestream( jxl::Bytes(pixels.data(), pixels.size()), xsize, ysize, 3, params1); for (int j = 0; j < kCSBF_NUM_ENTRIES; ++j) { - CodeStreamBoxFormat second_box_format = (CodeStreamBoxFormat)j; + CodeStreamBoxFormat second_box_format = + static_cast(j); if (second_box_format == kCSBF_Multi_Other_Zero_Terminated) continue; - printf("Testing with box format pair %d, %d\n", (int)first_box_format, - (int)second_box_format); + printf("Testing with box format pair %d, %d\n", + static_cast(first_box_format), + static_cast(second_box_format)); jxl::TestCodestreamParams params2; params2.box_format = second_box_format; std::vector compressed2 = jxl::CreateTestJXLCodestream( jxl::Bytes(pixels.data(), pixels.size()), xsize, ysize, 3, params2); std::vector concat; - jxl::Bytes(compressed1).AppendTo(&concat); - jxl::Bytes(compressed2).AppendTo(&concat); + jxl::Bytes(compressed1).AppendTo(concat); + jxl::Bytes(compressed2).AppendTo(concat); uint32_t channels = 3; JxlPixelFormat format = {channels, JXL_TYPE_FLOAT, JXL_LITTLE_ENDIAN, 0}; size_t remaining = concat.size(); for (int part = 0; part < 2; ++part) { printf(" Decoding part %d\n", part + 1); - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); size_t pos = concat.size() - remaining; bool expect_success = (part == 0 || second_box_format == kCSBF_None || @@ -2300,7 +2323,8 @@ TEST(DecodeTest, ConcatenatedCompressedStreams) { } void TestPartialStream(bool reconstructible_jpeg) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; uint32_t channels = 4; if (reconstructible_jpeg) { channels = 3; @@ -2325,7 +2349,7 @@ void TestPartialStream(bool reconstructible_jpeg) { std::vector> codestreams(kCSBF_NUM_ENTRIES); std::vector> jpeg_codestreams(kCSBF_NUM_ENTRIES); for (size_t i = 0; i < kCSBF_NUM_ENTRIES; ++i) { - params.box_format = (CodeStreamBoxFormat)i; + params.box_format = static_cast(i); if (reconstructible_jpeg) { params.jpeg_codestream = &jpeg_codestreams[i]; } @@ -2338,10 +2362,10 @@ void TestPartialStream(bool reconstructible_jpeg) { // box parsing. std::vector increments = {1, 3, 17, 23, 120, 700, 1050}; - for (size_t index = 0; index < increments.size(); index++) { + for (size_t increment : increments) { for (size_t i = 0; i < kCSBF_NUM_ENTRIES; ++i) { - if (reconstructible_jpeg && - (CodeStreamBoxFormat)i == CodeStreamBoxFormat::kCSBF_None) { + if (reconstructible_jpeg && static_cast(i) == + CodeStreamBoxFormat::kCSBF_None) { continue; } const std::vector& data = codestreams[i]; @@ -2376,7 +2400,6 @@ void TestPartialStream(bool reconstructible_jpeg) { break; } - size_t increment = increments[index]; // End of the file reached, should be the final test. if (total_size + increment > data.size()) { increment = data.size() - total_size; @@ -2467,7 +2490,7 @@ TEST(DecodeTest, DCNotGettableTest) { "\363\6\22\bp\0\200\237\34\231W2d\255$\1", 68); - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSubscribeEvents(dec, JXL_DEC_BASIC_INFO)); @@ -2487,7 +2510,8 @@ TEST(DecodeTest, DCNotGettableTest) { } TEST(DecodeTest, PreviewTest) { - size_t xsize = 77, ysize = 120; + size_t xsize = 77; + size_t ysize = 120; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); JxlPixelFormat format_orig = {3, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; for (jxl::PreviewMode mode : {jxl::kSmallPreview, jxl::kBigPreview}) { @@ -2499,7 +2523,7 @@ TEST(DecodeTest, PreviewTest) { JxlPixelFormat format = {3, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, 0}; - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); @@ -2561,7 +2585,8 @@ TEST(DecodeTest, PreviewTest) { } TEST(DecodeTest, AlignTest) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 4, 0); JxlPixelFormat format_orig = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -2575,22 +2600,27 @@ TEST(DecodeTest, AlignTest) { size_t align = 17; JxlPixelFormat format = {3, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, align}; // On purpose not using jxl::RoundUpTo to test it independently. - size_t expected_line_bytes = (1 * 3 * xsize + align - 1) / align * align; + size_t expected_line_size_last = 1 * 3 * xsize; + size_t expected_line_size = + ((expected_line_size_last + align - 1) / align) * align; + size_t expected_pixels_size = + expected_line_size * (ysize - 1) + expected_line_size_last; - for (int use_callback = 0; use_callback <= 1; ++use_callback) { + for (bool use_callback : {false, true}) { std::vector pixels2 = jxl::DecodeWithAPI( jxl::Bytes(compressed.data(), compressed.size()), format, use_callback, /*set_buffer_early=*/false, /*use_resizable_runner=*/false, /*require_boxes=*/false, /*expect_success=*/true); - EXPECT_EQ(expected_line_bytes * ysize, pixels2.size()); + EXPECT_EQ(expected_pixels_size, pixels2.size()); EXPECT_EQ(0u, jxl::test::ComparePixels(pixels.data(), pixels2.data(), xsize, ysize, format_orig, format)); } } TEST(DecodeTest, AnimationTest) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; static const size_t num_frames = 2; std::vector frames[2]; frames[0] = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); @@ -2631,12 +2661,12 @@ TEST(DecodeTest, AnimationTest) { // Decode and test the animation frames - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner(dec, JxlThreadParallelRunner, runner)); @@ -2690,7 +2720,8 @@ TEST(DecodeTest, AnimationTest) { } TEST(DecodeTest, AnimationTestStreaming) { - size_t xsize = 123, ysize = 77; + size_t xsize = 123; + size_t ysize = 77; static const size_t num_frames = 2; std::vector frames[2]; frames[0] = jxl::test::GetSomeTestImage(xsize, ysize, 3, 0); @@ -2733,7 +2764,7 @@ TEST(DecodeTest, AnimationTestStreaming) { const size_t step_size = 16; - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = 0; size_t frame_headers_seen = 0; @@ -2741,7 +2772,7 @@ TEST(DecodeTest, AnimationTestStreaming) { bool seen_basic_info = false; void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner(dec, JxlThreadParallelRunner, runner)); @@ -2805,7 +2836,7 @@ TEST(DecodeTest, AnimationTestStreaming) { frames_seen++; EXPECT_EQ(frame_headers_seen, frames_seen); } else { - fprintf(stderr, "Unexpected status: %d\n", (int)status); + fprintf(stderr, "Unexpected status: %d\n", static_cast(status)); FAIL(); } } @@ -2822,7 +2853,8 @@ TEST(DecodeTest, AnimationTestStreaming) { } TEST(DecodeTest, ExtraChannelTest) { - size_t xsize = 55, ysize = 257; + size_t xsize = 55; + size_t ysize = 257; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 4, 0); JxlPixelFormat format_orig = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -2836,7 +2868,7 @@ TEST(DecodeTest, ExtraChannelTest) { size_t align = 17; JxlPixelFormat format = {3, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, align}; - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSubscribeEvents( dec, JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE)); @@ -2899,7 +2931,8 @@ TEST(DecodeTest, ExtraChannelTest) { } TEST(DecodeTest, SkipCurrentFrameTest) { - size_t xsize = 90, ysize = 120; + size_t xsize = 90; + size_t ysize = 120; constexpr size_t num_frames = 7; std::vector frames[num_frames]; for (size_t i = 0; i < num_frames; i++) { @@ -2945,7 +2978,7 @@ TEST(DecodeTest, SkipCurrentFrameTest) { cparams.custom_progressive_mode = &progressive_mode; EXPECT_TRUE(jxl::test::EncodeFile(cparams, &io, &compressed)); - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); @@ -2964,7 +2997,7 @@ TEST(DecodeTest, SkipCurrentFrameTest) { EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBasicInfo(dec, &info)); for (size_t i = 0; i < num_frames; ++i) { - printf("Decoding frame %d\n", (int)i); + printf("Decoding frame %d\n", static_cast(i)); EXPECT_EQ(JXL_DEC_ERROR, JxlDecoderSkipCurrentFrame(dec)); std::vector pixels(buffer_size); EXPECT_EQ(JXL_DEC_FRAME, JxlDecoderProcessInput(dec)); @@ -3010,7 +3043,8 @@ TEST(DecodeTest, SkipCurrentFrameTest) { } TEST(DecodeTest, SkipFrameTest) { - size_t xsize = 90, ysize = 120; + size_t xsize = 90; + size_t ysize = 120; constexpr size_t num_frames = 16; std::vector frames[num_frames]; for (size_t i = 0; i < num_frames; i++) { @@ -3056,12 +3090,12 @@ TEST(DecodeTest, SkipFrameTest) { // Decode and test the animation frames - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner(dec, JxlThreadParallelRunner, runner)); @@ -3146,7 +3180,8 @@ TEST(DecodeTest, SkipFrameTest) { } TEST(DecodeTest, SkipFrameWithBlendingTest) { - size_t xsize = 90, ysize = 120; + size_t xsize = 90; + size_t ysize = 120; constexpr size_t num_frames = 16; std::vector frames[num_frames]; JxlPixelFormat format = {3, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -3213,23 +3248,22 @@ TEST(DecodeTest, SkipFrameWithBlendingTest) { // Independently decode all frames without any skipping, to create the // expected blended frames, for the actual tests below to compare with. { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner( dec, JxlThreadParallelRunner, runner)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSubscribeEvents(dec, JXL_DEC_FULL_IMAGE)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetInput(dec, next_in, avail_in)); - for (size_t i = 0; i < num_frames; ++i) { + for (auto& frame : frames) { EXPECT_EQ(JXL_DEC_NEED_IMAGE_OUT_BUFFER, JxlDecoderProcessInput(dec)); - frames[i].resize(xsize * ysize * 6); - EXPECT_EQ(JXL_DEC_SUCCESS, - JxlDecoderSetImageOutBuffer(dec, &format, frames[i].data(), - frames[i].size())); + frame.resize(xsize * ysize * 6); + EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetImageOutBuffer( + dec, &format, frame.data(), frame.size())); EXPECT_EQ(JXL_DEC_FULL_IMAGE, JxlDecoderProcessInput(dec)); } @@ -3240,12 +3274,12 @@ TEST(DecodeTest, SkipFrameWithBlendingTest) { JxlDecoderDestroy(dec); } - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner(dec, JxlThreadParallelRunner, runner)); @@ -3360,7 +3394,8 @@ TEST(DecodeTest, SkipFrameWithBlendingTest) { } TEST(DecodeTest, SkipFrameWithAlphaBlendingTest) { - size_t xsize = 90, ysize = 120; + size_t xsize = 90; + size_t ysize = 120; constexpr size_t num_frames = 16; std::vector frames[num_frames + 5]; JxlPixelFormat format = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -3376,7 +3411,10 @@ TEST(DecodeTest, SkipFrameWithAlphaBlendingTest) { std::vector frame_durations_c; std::vector frame_durations_nc; - std::vector frame_xsize, frame_ysize, frame_x0, frame_y0; + std::vector frame_xsize; + std::vector frame_ysize; + std::vector frame_x0; + std::vector frame_y0; for (size_t i = 0; i < num_frames; ++i) { size_t cropxsize = 1 + xsize * 2 / (i + 1); @@ -3444,12 +3482,12 @@ TEST(DecodeTest, SkipFrameWithAlphaBlendingTest) { // Independently decode all frames without any skipping, to create the // expected blended frames, for the actual tests below to compare with. { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetCoalescing(dec, coalescing)); void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner( dec, JxlThreadParallelRunner, runner)); EXPECT_EQ(JXL_DEC_SUCCESS, @@ -3479,13 +3517,13 @@ TEST(DecodeTest, SkipFrameWithAlphaBlendingTest) { JxlDecoderDestroy(dec); } - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetCoalescing(dec, coalescing)); void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner( dec, JxlThreadParallelRunner, runner)); @@ -3648,7 +3686,8 @@ TEST(DecodeTest, SkipFrameWithAlphaBlendingTest) { TEST(DecodeTest, OrientedCroppedFrameTest) { const auto test = [](bool keep_orientation, uint32_t orientation, uint32_t resampling) { - size_t xsize = 90, ysize = 120; + size_t xsize = 90; + size_t ysize = 120; JxlPixelFormat format = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; size_t oxsize = (!keep_orientation && orientation > 4 ? ysize : xsize); size_t oysize = (!keep_orientation && orientation > 4 ? xsize : ysize); @@ -3698,14 +3737,14 @@ TEST(DecodeTest, OrientedCroppedFrameTest) { // Independently decode all frames without any skipping, to create the // expected blended frames, for the actual tests below to compare with. { - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); const uint8_t* next_in = compressed.data(); size_t avail_in = compressed.size(); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetCoalescing(dec, coalescing)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetKeepOrientation(dec, keep_orientation)); void* runner = JxlThreadParallelRunnerCreate( - NULL, JxlThreadParallelRunnerDefaultNumWorkerThreads()); + nullptr, JxlThreadParallelRunnerDefaultNumWorkerThreads()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetParallelRunner( dec, JxlThreadParallelRunner, runner)); EXPECT_EQ(JXL_DEC_SUCCESS, @@ -3747,10 +3786,10 @@ TEST(DecodeTest, OrientedCroppedFrameTest) { for (int y = 0; y < static_cast(oysize); y++) { if (y < y0 || y >= y0 + h) continue; // pointers do whole 16-bit RGBA pixels at a time - uint64_t* row_merged = static_cast( - (void*)(frames[4].data() + y * oxsize * 8)); - uint64_t* row_layer = static_cast( - (void*)(frames[i].data() + (y - y0) * w * 8)); + uint64_t* row_merged = reinterpret_cast( + frames[4].data() + y * oxsize * 8); + uint64_t* row_layer = reinterpret_cast( + frames[i].data() + (y - y0) * w * 8); for (int x = 0; x < static_cast(oxsize); x++) { if (x < x0 || x >= x0 + w) continue; row_merged[x] = row_layer[x - x0]; @@ -3825,18 +3864,18 @@ void AnalyzeCodestream(const std::vector& data, codestream.insert(codestream.end(), in + pos + 8, in + pos + box_size); codestream_end = true; } else if (memcmp(in + pos + 4, "jxlp", 4) == 0) { - codestream_end = (LoadBE32(in + pos + 8) & 0x80000000); + codestream_end = ((LoadBE32(in + pos + 8) & 0x80000000) != 0); if (codestream.empty()) { streampos->codestream_start = pos + 12; } else if (box_size > 12 || !codestream_end) { - breakpoints.push_back({codestream.size(), 12}); + breakpoints.emplace_back(codestream.size(), 12); } codestream.insert(codestream.end(), in + pos + 12, in + pos + box_size); } else if (memcmp(in + pos + 4, "jbrd", 4) == 0) { EXPECT_TRUE(codestream.empty()); streampos->jbrd_end = pos + box_size; } else if (!codestream.empty() && !codestream_end) { - breakpoints.push_back({codestream.size(), box_size}); + breakpoints.emplace_back(codestream.size(), box_size); } pos += box_size; } @@ -3931,7 +3970,7 @@ void VerifyProgression(size_t xsize, size_t ysize, uint32_t num_channels, double prev_dist = 1.0; for (;;) { JxlDecoderStatus status = JxlDecoderProcessInput(dec); - printf("bp: %d status: 0x%x\n", bp, (int)status); + printf("bp: %d status: 0x%x\n", bp, static_cast(status)); if (status == JXL_DEC_BASIC_INFO) { JxlBasicInfo info; EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBasicInfo(dec, &info)); @@ -3977,7 +4016,7 @@ void VerifyProgression(size_t xsize, size_t ysize, uint32_t num_channels, avail_in = breakpoints[bp].file_pos - (next_in - data.data()); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetInput(dec, next_in, avail_in)); } else { - printf("Unexpected status: 0x%x\n", (int)status); + printf("Unexpected status: 0x%x\n", static_cast(status)); FAIL(); // unexpected returned status } } @@ -3985,7 +4024,8 @@ void VerifyProgression(size_t xsize, size_t ysize, uint32_t num_channels, } TEST(DecodeTest, ProgressionTest) { - size_t xsize = 508, ysize = 470; + size_t xsize = 508; + size_t ysize = 470; uint32_t num_channels = 3; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4020,7 +4060,8 @@ TEST(DecodeTest, ProgressionTest) { } TEST(DecodeTest, ProgressionTestLosslessAlpha) { - size_t xsize = 508, ysize = 470; + size_t xsize = 508; + size_t ysize = 470; uint32_t num_channels = 4; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4063,7 +4104,8 @@ void VerifyFilePosition(size_t expected_pos, const std::vector& data, } TEST(DecodeTest, InputHandlingTestOneShot) { - size_t xsize = 508, ysize = 470; + size_t xsize = 508; + size_t ysize = 470; uint32_t num_channels = 3; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4072,7 +4114,7 @@ TEST(DecodeTest, InputHandlingTestOneShot) { jxl::TestCodestreamParams params; params.cparams.progressive_dc = 1; params.preview_mode = jxl::kSmallPreview; - params.box_format = (CodeStreamBoxFormat)i; + params.box_format = static_cast(i); std::vector data = jxl::CreateTestJXLCodestream(jxl::Bytes(pixels.data(), pixels.size()), xsize, ysize, num_channels, params); @@ -4167,7 +4209,7 @@ TEST(DecodeTest, JXL_TRANSCODE_JPEG_TEST(InputHandlingTestJPEGOneshot)) { params.cparams.color_transform = jxl::ColorTransform::kNone; params.jpeg_codestream = &jpeg_codestream; params.preview_mode = jxl::kSmallPreview; - params.box_format = (CodeStreamBoxFormat)i; + params.box_format = static_cast(i); std::vector data = jxl::CreateTestJXLCodestream(jxl::Bytes(pixels.data(), pixels.size()), xsize, ysize, channels, params); @@ -4246,7 +4288,8 @@ TEST(DecodeTest, JXL_TRANSCODE_JPEG_TEST(InputHandlingTestJPEGOneshot)) { } TEST(DecodeTest, InputHandlingTestStreaming) { - size_t xsize = 508, ysize = 470; + size_t xsize = 508; + size_t ysize = 470; uint32_t num_channels = 3; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4255,7 +4298,7 @@ TEST(DecodeTest, InputHandlingTestStreaming) { fflush(stdout); jxl::TestCodestreamParams params; params.cparams.progressive_dc = 1; - params.box_format = (CodeStreamBoxFormat)i; + params.box_format = static_cast(i); params.preview_mode = jxl::kSmallPreview; std::vector data = jxl::CreateTestJXLCodestream(jxl::Bytes(pixels.data(), pixels.size()), @@ -4334,7 +4377,7 @@ TEST(DecodeTest, InputHandlingTestStreaming) { ASSERT_LT(box_index, streampos.box_start.size()); EXPECT_EQ(file_pos, streampos.box_start[box_index++]); } else { - printf("Unexpected status: 0x%x\n", (int)status); + printf("Unexpected status: 0x%x\n", static_cast(status)); FAIL(); } } @@ -4346,7 +4389,8 @@ TEST(DecodeTest, InputHandlingTestStreaming) { TEST(DecodeTest, FlushTest) { // Size large enough for multiple groups, required to have progressive // stages - size_t xsize = 333, ysize = 300; + size_t xsize = 333; + size_t ysize = 300; uint32_t num_channels = 3; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4421,7 +4465,8 @@ TEST(DecodeTest, FlushTest) { TEST(DecodeTest, FlushTestImageOutCallback) { // Size large enough for multiple groups, required to have progressive // stages - size_t xsize = 333, ysize = 300; + size_t xsize = 333; + size_t ysize = 300; uint32_t num_channels = 3; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4507,7 +4552,8 @@ TEST(DecodeTest, FlushTestImageOutCallback) { TEST(DecodeTest, FlushTestLossyProgressiveAlpha) { // Size large enough for multiple groups, required to have progressive // stages - size_t xsize = 333, ysize = 300; + size_t xsize = 333; + size_t ysize = 300; uint32_t num_channels = 4; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4577,7 +4623,8 @@ TEST(DecodeTest, FlushTestLossyProgressiveAlpha) { JxlDecoderDestroy(dec); } TEST(DecodeTest, FlushTestLossyProgressiveAlphaUpsampling) { - size_t xsize = 533, ysize = 401; + size_t xsize = 533; + size_t ysize = 401; uint32_t num_channels = 4; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4651,7 +4698,8 @@ TEST(DecodeTest, FlushTestLossyProgressiveAlphaUpsampling) { TEST(DecodeTest, FlushTestLosslessProgressiveAlpha) { // Size large enough for multiple groups, required to have progressive // stages - size_t xsize = 333, ysize = 300; + size_t xsize = 333; + size_t ysize = 300; uint32_t num_channels = 4; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, num_channels, 0); @@ -4731,17 +4779,19 @@ JXL_GTEST_INSTANTIATE_TEST_SUITE_P(DecodeProgressiveTestInstantiation, ::testing::Range(0, 8)); TEST_P(DecodeProgressiveTest, ProgressiveEventTest) { const int params = GetParam(); - int single_group = params & 1; - int lossless = (params >> 1) & 1; + bool single_group = ((params & 1) != 0); + bool lossless = (((params >> 1) & 1) != 0); uint32_t num_channels = 3 + ((params >> 2) & 1); + bool has_alpha = ((num_channels & 1) == 0); std::set progressive_details = {kDC, kLastPasses, kPasses}; for (auto prog_detail : progressive_details) { // Only few combinations are expected to support outputting // intermediate flushes for complete DC and complete passes. // The test can be updated if more cases are expected to support it. - bool expect_flush = (num_channels & 1) && !lossless; - size_t xsize, ysize; + bool expect_flush = !has_alpha && !lossless; + size_t xsize; + size_t ysize; if (single_group) { // An image smaller than 256x256 ensures it contains only 1 group. xsize = 99; @@ -4774,12 +4824,13 @@ TEST_P(DecodeProgressiveTest, ProgressiveEventTest) { jxl::CreateTestJXLCodestream(jxl::Bytes(pixels.data(), pixels.size()), xsize, ysize, num_channels, params); - for (size_t increment : {(size_t)1, data.size()}) { + for (size_t increment : {static_cast(1), data.size()}) { printf( - "Testing with single_group=%d, lossless=%d, " + "Testing with single_group=%s, lossless=%s, " "num_channels=%d, prog_detail=%d, increment=%d\n", - single_group, lossless, (int)num_channels, (int)prog_detail, - (int)increment); + BoolToCStr(single_group), BoolToCStr(lossless), + static_cast(num_channels), static_cast(prog_detail), + static_cast(increment)); std::vector> passes(kNumPasses + 1); for (int i = 0; i <= kNumPasses; ++i) { passes[i].resize(pixels.size()); @@ -4963,13 +5014,13 @@ TEST(DecodeTest, JXL_TRANSCODE_JPEG_TEST(JPEGReconstructionTest)) { ASSERT_TRUE( EncodeJPEGData(*orig_io.Main().jpeg_data.get(), &jpeg_data, cparams)); std::vector container; - jxl::Bytes(jxl::kContainerHeader).AppendTo(&container); + jxl::Bytes(jxl::kContainerHeader).AppendTo(container); jxl::AppendBoxHeader(jxl::MakeBoxType("jbrd"), jpeg_data.size(), false, &container); - jxl::Bytes(jpeg_data).AppendTo(&container); + jxl::Bytes(jpeg_data).AppendTo(container); jxl::AppendBoxHeader(jxl::MakeBoxType("jxlc"), 0, true, &container); jxl::PaddedBytes codestream = std::move(writer).TakeBytes(); - jxl::Bytes(codestream).AppendTo(&container); + jxl::Bytes(codestream).AppendTo(container); VerifyJPEGReconstruction(jxl::Bytes(container), jxl::Bytes(orig)); } @@ -4982,7 +5033,8 @@ TEST(DecodeTest, JXL_TRANSCODE_JPEG_TEST(JPEGReconstructionMetadataTest)) { } TEST(DecodeTest, ContinueFinalNonEssentialBoxTest) { - size_t xsize = 80, ysize = 90; + size_t xsize = 80; + size_t ysize = 90; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 4, 0); jxl::TestCodestreamParams params; params.box_format = kCSBF_Multi_Other_Terminated; @@ -5038,7 +5090,7 @@ TEST(DecodeTest, ContinueFinalNonEssentialBoxTest) { } namespace { -bool BoxTypeEquals(const std::string& type_string, JxlBoxType type) { +bool BoxTypeEquals(const std::string& type_string, const JxlBoxType type) { return type_string.size() == 4 && type_string[0] == type[0] && type_string[1] == type[1] && type_string[2] == type[2] && type_string[3] == type[3]; @@ -5054,28 +5106,38 @@ TEST(DecodeTest, ExtentedBoxSizeTest) { JxlBoxType type; uint64_t box_size; + uint64_t contents_size; EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetInput(dec, orig.data(), orig.size())); EXPECT_EQ(JXL_DEC_BOX, JxlDecoderProcessInput(dec)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxType(dec, type, JXL_FALSE)); EXPECT_TRUE(BoxTypeEquals("JXL ", type)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxSizeRaw(dec, &box_size)); EXPECT_EQ(12, box_size); + EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxSizeContents(dec, &contents_size)); + EXPECT_EQ(contents_size + 8, box_size); EXPECT_EQ(JXL_DEC_BOX, JxlDecoderProcessInput(dec)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxType(dec, type, JXL_FALSE)); EXPECT_TRUE(BoxTypeEquals("ftyp", type)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxSizeRaw(dec, &box_size)); EXPECT_EQ(20, box_size); + EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxSizeContents(dec, &contents_size)); + EXPECT_EQ(contents_size + 8, box_size); EXPECT_EQ(JXL_DEC_BOX, JxlDecoderProcessInput(dec)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxType(dec, type, JXL_FALSE)); EXPECT_TRUE(BoxTypeEquals("jxlc", type)); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxSizeRaw(dec, &box_size)); EXPECT_EQ(72, box_size); + EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBoxSizeContents(dec, &contents_size)); + // This is an extended box, hence the difference between `box_size` and + // `contents_size` is 16. + EXPECT_EQ(contents_size + 8 + 8, box_size); JxlDecoderDestroy(dec); } TEST(DecodeTest, JXL_BOXES_TEST(BoxTest)) { - size_t xsize = 1, ysize = 1; + size_t xsize = 1; + size_t ysize = 1; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 4, 0); jxl::TestCodestreamParams params; params.box_format = kCSBF_Multi_Other_Terminated; @@ -5096,6 +5158,7 @@ TEST(DecodeTest, JXL_BOXES_TEST(BoxTest)) { JxlBoxType type; uint64_t box_size; + uint64_t contents_size; std::vector contents(50); size_t expected_release_size = 0; @@ -5113,6 +5176,9 @@ TEST(DecodeTest, JXL_BOXES_TEST(BoxTest)) { EXPECT_TRUE(BoxTypeEquals(expected_box_types[i], type)); if (expected_box_sizes[i]) { EXPECT_EQ(expected_box_sizes[i], box_size); + EXPECT_EQ(JXL_DEC_SUCCESS, + JxlDecoderGetBoxSizeContents(dec, &contents_size)); + EXPECT_EQ(contents_size + 8, box_size); } if (expected_release_size > 0) { @@ -5147,7 +5213,8 @@ TEST(DecodeTest, JXL_BOXES_TEST(BoxTest)) { } TEST(DecodeTest, JXL_BOXES_TEST(ExifBrobBoxTest)) { - size_t xsize = 1, ysize = 1; + size_t xsize = 1; + size_t ysize = 1; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 4, 0); jxl::TestCodestreamParams params; // Lossless to verify pixels exactly after roundtrip. @@ -5328,7 +5395,8 @@ TEST(DecodeTest, JXL_BOXES_TEST(ExifBrobBoxTest)) { } TEST(DecodeTest, JXL_BOXES_TEST(PartialCodestreamBoxTest)) { - size_t xsize = 23, ysize = 81; + size_t xsize = 23; + size_t ysize = 81; std::vector pixels = jxl::test::GetSomeTestImage(xsize, ysize, 4, 0); JxlPixelFormat format_orig = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; // Lossless to verify pixels exactly after roundtrip. @@ -5482,10 +5550,11 @@ TEST(DecodeTest, JXL_BOXES_TEST(PartialCodestreamBoxTest)) { TEST(DecodeTest, SpotColorTest) { jxl::CodecInOut io; - size_t xsize = 55, ysize = 257; + size_t xsize = 55; + size_t ysize = 257; io.metadata.m.color_encoding = jxl::ColorEncoding::LinearSRGB(); - jxl::Image3F main(xsize, ysize); - jxl::ImageF spot(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3F main, Image3F::Create(xsize, ysize)); + JXL_ASSIGN_OR_DIE(ImageF spot, ImageF::Create(xsize, ysize)); jxl::ZeroFillImage(&main); jxl::ZeroFillImage(&spot); @@ -5508,7 +5577,7 @@ TEST(DecodeTest, SpotColorTest) { info.spot_color[3] = 0.5f; io.metadata.m.extra_channel_info.push_back(info); - std::vector ec; + std::vector ec; ec.push_back(std::move(spot)); io.frames[0].SetExtraChannels(std::move(ec)); @@ -5524,7 +5593,7 @@ TEST(DecodeTest, SpotColorTest) { for (size_t render_spot = 0; render_spot < 2; render_spot++) { JxlPixelFormat format = {3, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, 0}; - JxlDecoder* dec = JxlDecoderCreate(NULL); + JxlDecoder* dec = JxlDecoderCreate(nullptr); EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSubscribeEvents( @@ -5545,7 +5614,8 @@ TEST(DecodeTest, SpotColorTest) { JxlExtraChannelInfo extra_info; EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetExtraChannelInfo(dec, 0, &extra_info)); - EXPECT_EQ((unsigned int)jxl::ExtraChannel::kSpotColor, extra_info.type); + EXPECT_EQ(static_cast(jxl::ExtraChannel::kSpotColor), + extra_info.type); EXPECT_EQ(JXL_DEC_NEED_IMAGE_OUT_BUFFER, JxlDecoderProcessInput(dec)); size_t buffer_size; diff --git a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc index d3b5ad3269..4aafd7a5e5 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.cc @@ -18,20 +18,15 @@ #include #include "lib/jxl/ac_strategy.h" -#include "lib/jxl/ans_params.h" #include "lib/jxl/base/bits.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/fast_math-inl.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/coeff_order_fwd.h" -#include "lib/jxl/convolve.h" -#include "lib/jxl/dct_scales.h" #include "lib/jxl/dec_transforms-inl.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_debug_image.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/enc_transforms-inl.h" -#include "lib/jxl/entropy_coder.h" #include "lib/jxl/simd_util.h" // Some of the floating point constants in this file and in other @@ -215,10 +210,10 @@ const uint8_t* TypeMask(const uint8_t& raw_strategy) { return kMask[raw_strategy]; } -void DumpAcStrategy(const AcStrategyImage& ac_strategy, size_t xsize, - size_t ysize, const char* tag, AuxOut* aux_out, - const CompressParams& cparams) { - Image3F color_acs(xsize, ysize); +Status DumpAcStrategy(const AcStrategyImage& ac_strategy, size_t xsize, + size_t ysize, const char* tag, AuxOut* aux_out, + const CompressParams& cparams) { + JXL_ASSIGN_OR_RETURN(Image3F color_acs, Image3F::Create(xsize, ysize)); for (size_t y = 0; y < ysize; y++) { float* JXL_RESTRICT rows[3] = { color_acs.PlaneRow(0, y), @@ -269,7 +264,7 @@ void DumpAcStrategy(const AcStrategyImage& ac_strategy, size_t xsize, } } } - DumpImage(cparams, tag, color_acs); + return DumpImage(cparams, tag, color_acs); } } // namespace @@ -353,7 +348,9 @@ bool MultiBlockTransformCrossesVerticalBoundary( float EstimateEntropy(const AcStrategy& acs, float entropy_mul, size_t x, size_t y, const ACSConfig& config, const float* JXL_RESTRICT cmap_factors, float* block, - float* scratch_space, uint32_t* quantized) { + float* full_scratch_space, uint32_t* quantized) { + float* mem = full_scratch_space; + float* scratch_space = full_scratch_space + AcStrategy::kMaxCoeffArea; const size_t size = (1 << acs.log2_covered_blocks()) * kDCTBlockSize; // Apply transform. @@ -403,8 +400,6 @@ float EstimateEntropy(const AcStrategy& acs, float entropy_mul, size_t x, float entropy = 0.0f; const HWY_CAPPED(float, 8) df8; - auto mem_alloc = hwy::AllocateAligned(AcStrategy::kMaxCoeffArea); - float* mem = mem_alloc.get(); auto loss = Zero(df8); for (size_t c = 0; c < 3; c++) { const float* inv_matrix = config.dequant->InvMatrix(acs.RawStrategy(), c); @@ -792,6 +787,7 @@ void FindBestFirstLevelDivisionForSquare( void ProcessRectACS(const CompressParams& cparams, const ACSConfig& config, const Rect& rect, const ColorCorrelationMap& cmap, + float* JXL_RESTRICT block, uint32_t* JXL_RESTRICT quantized, AcStrategyImage* ac_strategy) { // Main philosophy here: // 1. First find best 8x8 transform for each area. @@ -804,15 +800,7 @@ void ProcessRectACS(const CompressParams& cparams, const ACSConfig& config, // integral transforms cross these boundaries leads to // additional complications. const float butteraugli_target = cparams.butteraugli_distance; - const size_t dct_scratch_size = - 3 * (MaxVectorSize() / sizeof(float)) * AcStrategy::kMaxBlockDim; - // TODO(veluca): reuse allocations - auto mem = hwy::AllocateAligned(5 * AcStrategy::kMaxCoeffArea + - dct_scratch_size); - auto qmem = hwy::AllocateAligned(AcStrategy::kMaxCoeffArea); - uint32_t* JXL_RESTRICT quantized = qmem.get(); - float* JXL_RESTRICT block = mem.get(); - float* JXL_RESTRICT scratch_space = mem.get() + 3 * AcStrategy::kMaxCoeffArea; + float* JXL_RESTRICT scratch_space = block + 3 * AcStrategy::kMaxCoeffArea; size_t bx = rect.x0(); size_t by = rect.y0(); JXL_ASSERT(rect.xsize() <= 8); @@ -1085,26 +1073,37 @@ void AcStrategyHeuristics::Init(const Image3F& src, const Rect& rect_in, static const float kPow1 = 0.33677806662454718; static const float kPow2 = 0.50990926717963703; static const float kPow3 = 0.36702940662370243; - config.info_loss_multiplier *= pow(ratio, kPow1); - config.zeros_mul *= pow(ratio, kPow2); - config.cost_delta *= pow(ratio, kPow3); + config.info_loss_multiplier *= std::pow(ratio, kPow1); + config.zeros_mul *= std::pow(ratio, kPow2); + config.cost_delta *= std::pow(ratio, kPow3); +} + +void AcStrategyHeuristics::PrepareForThreads(std::size_t num_threads) { + const size_t dct_scratch_size = + 3 * (MaxVectorSize() / sizeof(float)) * AcStrategy::kMaxBlockDim; + mem_per_thread = 6 * AcStrategy::kMaxCoeffArea + dct_scratch_size; + mem = hwy::AllocateAligned(num_threads * mem_per_thread); + qmem_per_thread = AcStrategy::kMaxCoeffArea; + qmem = hwy::AllocateAligned(num_threads * qmem_per_thread); } void AcStrategyHeuristics::ProcessRect(const Rect& rect, const ColorCorrelationMap& cmap, - AcStrategyImage* ac_strategy) { + AcStrategyImage* ac_strategy, + size_t thread) { // In Falcon mode, use DCT8 everywhere and uniform quantization. if (cparams.speed_tier >= SpeedTier::kCheetah) { ac_strategy->FillDCT8(rect); return; } HWY_DYNAMIC_DISPATCH(ProcessRectACS) - (cparams, config, rect, cmap, ac_strategy); + (cparams, config, rect, cmap, mem.get() + thread * mem_per_thread, + qmem.get() + thread * qmem_per_thread, ac_strategy); } -void AcStrategyHeuristics::Finalize(const FrameDimensions& frame_dim, - const AcStrategyImage& ac_strategy, - AuxOut* aux_out) { +Status AcStrategyHeuristics::Finalize(const FrameDimensions& frame_dim, + const AcStrategyImage& ac_strategy, + AuxOut* aux_out) { // Accounting and debug output. if (aux_out != nullptr) { aux_out->num_small_blocks = @@ -1141,9 +1140,11 @@ void AcStrategyHeuristics::Finalize(const FrameDimensions& frame_dim, // if (JXL_DEBUG_AC_STRATEGY && WantDebugOutput(aux_out)) { if (JXL_DEBUG_AC_STRATEGY && WantDebugOutput(cparams)) { - DumpAcStrategy(ac_strategy, frame_dim.xsize, frame_dim.ysize, "ac_strategy", - aux_out, cparams); + JXL_RETURN_IF_ERROR(DumpAcStrategy(ac_strategy, frame_dim.xsize, + frame_dim.ysize, "ac_strategy", aux_out, + cparams)); } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h index 9f6d92a6f7..31eb73c6a0 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h +++ b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h @@ -58,16 +58,22 @@ struct ACSConfig { }; struct AcStrategyHeuristics { - AcStrategyHeuristics(const CompressParams& cparams) : cparams(cparams) {} + explicit AcStrategyHeuristics(const CompressParams& cparams) + : cparams(cparams), mem_per_thread(0), qmem_per_thread(0) {} void Init(const Image3F& src, const Rect& rect_in, const ImageF& quant_field, const ImageF& mask, const ImageF& mask1x1, DequantMatrices* matrices); + void PrepareForThreads(std::size_t num_threads); void ProcessRect(const Rect& rect, const ColorCorrelationMap& cmap, - AcStrategyImage* ac_strategy); - void Finalize(const FrameDimensions& frame_dim, - const AcStrategyImage& ac_strategy, AuxOut* aux_out); + AcStrategyImage* ac_strategy, size_t thread); + Status Finalize(const FrameDimensions& frame_dim, + const AcStrategyImage& ac_strategy, AuxOut* aux_out); const CompressParams& cparams; - ACSConfig config; + ACSConfig config = {}; + size_t mem_per_thread; + hwy::AlignedFreeUniquePtr mem; + size_t qmem_per_thread; + hwy::AlignedFreeUniquePtr qmem; }; } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc index ae4cd3bd3b..4c2ddba95b 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -26,8 +27,6 @@ #include "lib/jxl/base/status.h" #include "lib/jxl/butteraugli/butteraugli.h" #include "lib/jxl/cms/opsin_params.h" -#include "lib/jxl/coeff_order_fwd.h" -#include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/convolve.h" #include "lib/jxl/dec_cache.h" #include "lib/jxl/dec_group.h" @@ -102,12 +101,12 @@ V ComputeMask(const D d, const V out_val) { } // mul and mul2 represent a scaling difference between jxl and butteraugli. -static const float kSGmul = 226.77216153508914f; -static const float kSGmul2 = 1.0f / 73.377132366608819f; -static const float kLog2 = 0.693147181f; +const float kSGmul = 226.77216153508914f; +const float kSGmul2 = 1.0f / 73.377132366608819f; +const float kLog2 = 0.693147181f; // Includes correction factor for std::log -> log2. -static const float kSGRetMul = kSGmul2 * 18.6580932135f * kLog2; -static const float kSGVOffset = 7.7825991679894591f; +const float kSGRetMul = kSGmul2 * 18.6580932135f * kLog2; +const float kSGVOffset = 7.7825991679894591f; template V RatioOfDerivativesOfCubicRootToSimpleGamma(const D d, V v) { @@ -131,7 +130,7 @@ V RatioOfDerivativesOfCubicRootToSimpleGamma(const D d, V v) { } template -static float RatioOfDerivativesOfCubicRootToSimpleGamma(float v) { +float RatioOfDerivativesOfCubicRootToSimpleGamma(float v) { using DScalar = HWY_CAPPED(float, 1); auto vscalar = Load(DScalar(), &v); return GetLane( @@ -396,12 +395,16 @@ void FuzzyErosion(const float butteraugli_target, const Rect& from_rect, } struct AdaptiveQuantizationImpl { - void PrepareBuffers(size_t num_threads) { - diff_buffer = ImageF(kEncTileDim + 8, num_threads); + Status PrepareBuffers(size_t num_threads) { + JXL_ASSIGN_OR_RETURN(diff_buffer, + ImageF::Create(kEncTileDim + 8, num_threads)); for (size_t i = pre_erosion.size(); i < num_threads; i++) { - pre_erosion.emplace_back(kEncTileDimInBlocks * 2 + 2, - kEncTileDimInBlocks * 2 + 2); + JXL_ASSIGN_OR_RETURN(ImageF tmp, + ImageF::Create(kEncTileDimInBlocks * 2 + 2, + kEncTileDimInBlocks * 2 + 2)); + pre_erosion.emplace_back(std::move(tmp)); } + return true; } void ComputeTile(float butteraugli_target, float scale, const Image3F& xyb, @@ -568,8 +571,7 @@ struct AdaptiveQuantizationImpl { ImageF diff_buffer; }; -static void Blur1x1Masking(ThreadPool* pool, ImageF* mask1x1, - const Rect& rect) { +Status Blur1x1Masking(ThreadPool* pool, ImageF* mask1x1, const Rect& rect) { // Blur the mask1x1 to obtain the masking image. // Before blurring it contains an image of absolute value of the // Laplacian of the intensity channel. @@ -595,30 +597,30 @@ static void Blur1x1Masking(ThreadPool* pool, ImageF* mask1x1, {HWY_REP4(normalize_mul * kFilterMask1x1[1])}, {HWY_REP4(normalize_mul * kFilterMask1x1[4])}, {HWY_REP4(normalize_mul * kFilterMask1x1[3])}}; - ImageF temp(rect.xsize(), rect.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF temp, ImageF::Create(rect.xsize(), rect.ysize())); Symmetric5(*mask1x1, rect, weights, pool, &temp); *mask1x1 = std::move(temp); + return true; } -ImageF AdaptiveQuantizationMap(const float butteraugli_target, - const Image3F& xyb, const Rect& rect, - float scale, ThreadPool* pool, ImageF* mask, - ImageF* mask1x1) { +StatusOr AdaptiveQuantizationMap(const float butteraugli_target, + const Image3F& xyb, const Rect& rect, + float scale, ThreadPool* pool, + ImageF* mask, ImageF* mask1x1) { JXL_DASSERT(rect.xsize() % kBlockDim == 0); JXL_DASSERT(rect.ysize() % kBlockDim == 0); AdaptiveQuantizationImpl impl; const size_t xsize_blocks = rect.xsize() / kBlockDim; const size_t ysize_blocks = rect.ysize() / kBlockDim; - impl.aq_map = ImageF(xsize_blocks, ysize_blocks); - *mask = ImageF(xsize_blocks, ysize_blocks); - *mask1x1 = ImageF(xyb.xsize(), xyb.ysize()); + JXL_ASSIGN_OR_RETURN(impl.aq_map, ImageF::Create(xsize_blocks, ysize_blocks)); + JXL_ASSIGN_OR_RETURN(*mask, ImageF::Create(xsize_blocks, ysize_blocks)); + JXL_ASSIGN_OR_RETURN(*mask1x1, ImageF::Create(xyb.xsize(), xyb.ysize())); JXL_CHECK(RunOnPool( pool, 0, DivCeil(xsize_blocks, kEncTileDimInBlocks) * DivCeil(ysize_blocks, kEncTileDimInBlocks), [&](const size_t num_threads) { - impl.PrepareBuffers(num_threads); - return true; + return !!impl.PrepareBuffers(num_threads); }, [&](const uint32_t tid, const size_t thread) { size_t n_enc_tiles = DivCeil(xsize_blocks, kEncTileDimInBlocks); @@ -634,7 +636,7 @@ ImageF AdaptiveQuantizationMap(const float butteraugli_target, }, "AQ DiffPrecompute")); - Blur1x1Masking(pool, mask1x1, rect); + JXL_RETURN_IF_ERROR(Blur1x1Masking(pool, mask1x1, rect)); return std::move(impl).aq_map; } @@ -654,24 +656,28 @@ namespace { // If true, prints the quantization maps at each iteration. constexpr bool FLAGS_dump_quant_state = false; -void DumpHeatmap(const CompressParams& cparams, const AuxOut* aux_out, - const std::string& label, const ImageF& image, - float good_threshold, float bad_threshold) { +Status DumpHeatmap(const CompressParams& cparams, const AuxOut* aux_out, + const std::string& label, const ImageF& image, + float good_threshold, float bad_threshold) { if (JXL_DEBUG_ADAPTIVE_QUANTIZATION) { - Image3F heatmap = CreateHeatMapImage(image, good_threshold, bad_threshold); + JXL_ASSIGN_OR_RETURN( + Image3F heatmap, + CreateHeatMapImage(image, good_threshold, bad_threshold)); char filename[200]; snprintf(filename, sizeof(filename), "%s%05d", label.c_str(), aux_out->num_butteraugli_iters); - DumpImage(cparams, filename, heatmap); + JXL_RETURN_IF_ERROR(DumpImage(cparams, filename, heatmap)); } + return true; } -void DumpHeatmaps(const CompressParams& cparams, const AuxOut* aux_out, - float ba_target, const ImageF& quant_field, - const ImageF& tile_heatmap, const ImageF& bt_diffmap) { +Status DumpHeatmaps(const CompressParams& cparams, const AuxOut* aux_out, + float ba_target, const ImageF& quant_field, + const ImageF& tile_heatmap, const ImageF& bt_diffmap) { if (JXL_DEBUG_ADAPTIVE_QUANTIZATION) { - if (!WantDebugOutput(cparams)) return; - ImageF inv_qmap(quant_field.xsize(), quant_field.ysize()); + if (!WantDebugOutput(cparams)) return true; + JXL_ASSIGN_OR_RETURN(ImageF inv_qmap, ImageF::Create(quant_field.xsize(), + quant_field.ysize())); for (size_t y = 0; y < quant_field.ysize(); ++y) { const float* JXL_RESTRICT row_q = quant_field.ConstRow(y); float* JXL_RESTRICT row_inv_q = inv_qmap.Row(y); @@ -679,21 +685,24 @@ void DumpHeatmaps(const CompressParams& cparams, const AuxOut* aux_out, row_inv_q[x] = 1.0f / row_q[x]; // never zero } } - DumpHeatmap(cparams, aux_out, "quant_heatmap", inv_qmap, 4.0f * ba_target, - 6.0f * ba_target); - DumpHeatmap(cparams, aux_out, "tile_heatmap", tile_heatmap, ba_target, - 1.5f * ba_target); + JXL_RETURN_IF_ERROR(DumpHeatmap(cparams, aux_out, "quant_heatmap", inv_qmap, + 4.0f * ba_target, 6.0f * ba_target)); + JXL_RETURN_IF_ERROR(DumpHeatmap(cparams, aux_out, "tile_heatmap", + tile_heatmap, ba_target, 1.5f * ba_target)); // matches heat maps produced by the command line tool. - DumpHeatmap(cparams, aux_out, "bt_diffmap", bt_diffmap, - ButteraugliFuzzyInverse(1.5), ButteraugliFuzzyInverse(0.5)); + JXL_RETURN_IF_ERROR(DumpHeatmap(cparams, aux_out, "bt_diffmap", bt_diffmap, + ButteraugliFuzzyInverse(1.5), + ButteraugliFuzzyInverse(0.5))); } + return true; } -ImageF TileDistMap(const ImageF& distmap, int tile_size, int margin, - const AcStrategyImage& ac_strategy) { +StatusOr TileDistMap(const ImageF& distmap, int tile_size, int margin, + const AcStrategyImage& ac_strategy) { const int tile_xsize = (distmap.xsize() + tile_size - 1) / tile_size; const int tile_ysize = (distmap.ysize() + tile_size - 1) / tile_size; - ImageF tile_distmap(tile_xsize, tile_ysize); + JXL_ASSIGN_OR_RETURN(ImageF tile_distmap, + ImageF::Create(tile_xsize, tile_ysize)); size_t distmap_stride = tile_distmap.PixelsPerRow(); for (int tile_y = 0; tile_y < tile_ysize; ++tile_y) { AcStrategyRow ac_strategy_row = ac_strategy.ConstRow(tile_y); @@ -754,14 +763,16 @@ ImageF TileDistMap(const ImageF& distmap, int tile_size, int margin, return tile_distmap; } -static const float kDcQuantPow = 0.83f; -static const float kDcQuant = 1.095924047623553f; -static const float kAcQuant = 0.7381485255235064f; +const float kDcQuantPow = 0.83f; +const float kDcQuant = 1.095924047623553f; +const float kAcQuant = 0.7381485255235064f; // Computes the decoded image for a given set of compression parameters. -ImageBundle RoundtripImage(const FrameHeader& frame_header, - const Image3F& opsin, PassesEncoderState* enc_state, - const JxlCmsInterface& cms, ThreadPool* pool) { +StatusOr RoundtripImage(const FrameHeader& frame_header, + const Image3F& opsin, + PassesEncoderState* enc_state, + const JxlCmsInterface& cms, + ThreadPool* pool) { std::unique_ptr dec_state = jxl::make_unique(); JXL_CHECK(dec_state->output_encoding_info.SetFromMetadata( @@ -775,7 +786,8 @@ ImageBundle RoundtripImage(const FrameHeader& frame_header, size_t num_special_frames = enc_state->special_frames.size(); size_t num_passes = enc_state->progressive_splitter.GetNumPasses(); - ModularFrameEncoder modular_frame_encoder(frame_header, enc_state->cparams); + ModularFrameEncoder modular_frame_encoder(frame_header, enc_state->cparams, + false); JXL_CHECK(InitializePassesEncoder(frame_header, opsin, Rect(opsin), cms, pool, enc_state, &modular_frame_encoder, nullptr)); @@ -784,7 +796,9 @@ ImageBundle RoundtripImage(const FrameHeader& frame_header, ImageBundle decoded(&enc_state->shared.metadata->m); decoded.origin = frame_header.frame_origin; - decoded.SetFromImage(Image3F(opsin.xsize(), opsin.ysize()), + JXL_ASSIGN_OR_RETURN(Image3F tmp, + Image3F::Create(opsin.xsize(), opsin.ysize())); + decoded.SetFromImage(std::move(tmp), dec_state->output_encoding_info.color_encoding); PassesDecoderState::PipelineOptions options; @@ -806,8 +820,10 @@ ImageBundle RoundtripImage(const FrameHeader& frame_header, group_dec_caches = hwy::MakeUniqueAlignedArray(num_threads); return true; }; + std::atomic has_error{false}; const auto process_group = [&](const uint32_t group_index, const size_t thread) { + if (has_error) return; if (frame_header.loop_filter.epf_iters > 0) { ComputeSigma(frame_header.loop_filter, dec_state->shared->frame_dim.BlockGroupRect(group_index), @@ -822,10 +838,14 @@ ImageBundle RoundtripImage(const FrameHeader& frame_header, std::pair ri = input.GetBuffer(3 + c); FillPlane(0.0f, ri.first, ri.second); } - input.Done(); + if (!input.Done()) { + has_error = true; + return; + } }; JXL_CHECK(RunOnPool(pool, 0, num_groups, allocate_storage, process_group, "AQ loop")); + if (has_error) return JXL_FAILURE("AQ loop failure"); // Ensure we don't create any new special frames. enc_state->special_frames.resize(num_special_frames); @@ -835,18 +855,18 @@ ImageBundle RoundtripImage(const FrameHeader& frame_header, constexpr int kMaxButteraugliIters = 4; -void FindBestQuantization(const FrameHeader& frame_header, - const Image3F& linear, const Image3F& opsin, - ImageF& quant_field, PassesEncoderState* enc_state, - const JxlCmsInterface& cms, ThreadPool* pool, - AuxOut* aux_out) { +Status FindBestQuantization(const FrameHeader& frame_header, + const Image3F& linear, const Image3F& opsin, + ImageF& quant_field, PassesEncoderState* enc_state, + const JxlCmsInterface& cms, ThreadPool* pool, + AuxOut* aux_out) { const CompressParams& cparams = enc_state->cparams; if (cparams.resampling > 1 && cparams.original_butteraugli_distance <= 4.0 * cparams.resampling) { // For downsampled opsin image, the butteraugli based adaptive quantization // loop would only make the size bigger without improving the distance much, // so in this case we enable it only for very high butteraugli targets. - return; + return true; } Quantizer& quantizer = enc_state->shared.quantizer; ImageI& raw_quant_field = enc_state->shared.raw_quant_field; @@ -863,10 +883,13 @@ void FindBestQuantization(const FrameHeader& frame_header, AdjustQuantField(enc_state->shared.ac_strategy, Rect(quant_field), original_butteraugli, &quant_field); ImageF tile_distmap; - ImageF initial_quant_field(quant_field.xsize(), quant_field.ysize()); + JXL_ASSIGN_OR_RETURN( + ImageF initial_quant_field, + ImageF::Create(quant_field.xsize(), quant_field.ysize())); CopyImageTo(quant_field, &initial_quant_field); - float initial_qf_min, initial_qf_max; + float initial_qf_min; + float initial_qf_max; ImageMinMax(initial_quant_field, &initial_qf_min, &initial_qf_max); float initial_qf_ratio = initial_qf_max / initial_qf_min; float qf_max_deviation_low = std::sqrt(250 / initial_qf_ratio); @@ -893,8 +916,9 @@ void FindBestQuantization(const FrameHeader& frame_header, } } quantizer.SetQuantField(initial_quant_dc, quant_field, &raw_quant_field); - ImageBundle dec_linear = - RoundtripImage(frame_header, opsin, enc_state, cms, pool); + JXL_ASSIGN_OR_RETURN( + ImageBundle dec_linear, + RoundtripImage(frame_header, opsin, enc_state, cms, pool)); float score; ImageF diffmap; JXL_CHECK(comparator.CompareWith(dec_linear, &diffmap, &score)); @@ -902,16 +926,19 @@ void FindBestQuantization(const FrameHeader& frame_header, score = -score; ScaleImage(-1.0f, &diffmap); } - tile_distmap = TileDistMap(diffmap, 8 * cparams.resampling, 0, - enc_state->shared.ac_strategy); + JXL_ASSIGN_OR_RETURN(tile_distmap, + TileDistMap(diffmap, 8 * cparams.resampling, 0, + enc_state->shared.ac_strategy)); if (JXL_DEBUG_ADAPTIVE_QUANTIZATION && WantDebugOutput(cparams)) { - DumpImage(cparams, ("dec" + ToString(i)).c_str(), *dec_linear.color()); - DumpHeatmaps(cparams, aux_out, butteraugli_target, quant_field, - tile_distmap, diffmap); + JXL_RETURN_IF_ERROR(DumpImage(cparams, ("dec" + ToString(i)).c_str(), + *dec_linear.color())); + JXL_RETURN_IF_ERROR(DumpHeatmaps(cparams, aux_out, butteraugli_target, + quant_field, tile_distmap, diffmap)); } if (aux_out != nullptr) ++aux_out->num_butteraugli_iters; if (JXL_DEBUG_ADAPTIVE_QUANTIZATION) { - float minval, maxval; + float minval; + float maxval; ImageMinMax(quant_field, &minval, &maxval); printf("\nButteraugli iter: %d/%d\n", i, kMaxButteraugliIters); printf("Butteraugli distance: %f (target = %f)\n", score, @@ -967,8 +994,10 @@ void FindBestQuantization(const FrameHeader& frame_header, if (diff > 1.0f) { float old = row_q[x]; row_q[x] *= diff; - int qf_old = old * quantizer.InvGlobalScale() + 0.5; - int qf_new = row_q[x] * quantizer.InvGlobalScale() + 0.5; + int qf_old = + static_cast(std::lround(old * quantizer.InvGlobalScale())); + int qf_new = static_cast( + std::lround(row_q[x] * quantizer.InvGlobalScale())); if (qf_old == qf_new) { row_q[x] = old + quantizer.Scale(); } @@ -988,8 +1017,10 @@ void FindBestQuantization(const FrameHeader& frame_header, } else { float old = row_q[x]; row_q[x] *= diff; - int qf_old = old * quantizer.InvGlobalScale() + 0.5; - int qf_new = row_q[x] * quantizer.InvGlobalScale() + 0.5; + int qf_old = + static_cast(std::lround(old * quantizer.InvGlobalScale())); + int qf_new = static_cast( + std::lround(row_q[x] * quantizer.InvGlobalScale())); if (qf_old == qf_new) { row_q[x] = old + quantizer.Scale(); } @@ -1001,13 +1032,14 @@ void FindBestQuantization(const FrameHeader& frame_header, } } quantizer.SetQuantField(initial_quant_dc, quant_field, &raw_quant_field); + return true; } -void FindBestQuantizationMaxError(const FrameHeader& frame_header, - const Image3F& opsin, ImageF& quant_field, - PassesEncoderState* enc_state, - const JxlCmsInterface& cms, ThreadPool* pool, - AuxOut* aux_out) { +Status FindBestQuantizationMaxError(const FrameHeader& frame_header, + const Image3F& opsin, ImageF& quant_field, + PassesEncoderState* enc_state, + const JxlCmsInterface& cms, + ThreadPool* pool, AuxOut* aux_out) { // TODO(szabadka): Make this work for non-opsin color spaces. const CompressParams& cparams = enc_state->cparams; Quantizer& quantizer = enc_state->shared.quantizer; @@ -1026,12 +1058,15 @@ void FindBestQuantizationMaxError(const FrameHeader& frame_header, for (int i = 0; i < kMaxButteraugliIters + 1; ++i) { quantizer.SetQuantField(initial_quant_dc, quant_field, &raw_quant_field); if (JXL_DEBUG_ADAPTIVE_QUANTIZATION && aux_out) { - DumpXybImage(cparams, ("ops" + ToString(i)).c_str(), opsin); + JXL_RETURN_IF_ERROR( + DumpXybImage(cparams, ("ops" + ToString(i)).c_str(), opsin)); } - ImageBundle decoded = - RoundtripImage(frame_header, opsin, enc_state, cms, pool); + JXL_ASSIGN_OR_RETURN( + ImageBundle decoded, + RoundtripImage(frame_header, opsin, enc_state, cms, pool)); if (JXL_DEBUG_ADAPTIVE_QUANTIZATION && aux_out) { - DumpXybImage(cparams, ("dec" + ToString(i)).c_str(), *decoded.color()); + JXL_RETURN_IF_ERROR(DumpXybImage(cparams, ("dec" + ToString(i)).c_str(), + *decoded.color())); } for (size_t by = 0; by < enc_state->shared.frame_dim.ysize_blocks; by++) { AcStrategyRow ac_strategy_row = @@ -1073,6 +1108,7 @@ void FindBestQuantizationMaxError(const FrameHeader& frame_header, } } quantizer.SetQuantField(initial_quant_dc, quant_field, &raw_quant_field); + return true; } } // namespace @@ -1142,28 +1178,31 @@ float InitialQuantDC(float butteraugli_target) { return std::min(kDcQuant / butteraugli_target_dc, 50.f); } -ImageF InitialQuantField(const float butteraugli_target, const Image3F& opsin, - const Rect& rect, ThreadPool* pool, float rescale, - ImageF* mask, ImageF* mask1x1) { +StatusOr InitialQuantField(const float butteraugli_target, + const Image3F& opsin, const Rect& rect, + ThreadPool* pool, float rescale, + ImageF* mask, ImageF* mask1x1) { const float quant_ac = kAcQuant / butteraugli_target; return HWY_DYNAMIC_DISPATCH(AdaptiveQuantizationMap)( butteraugli_target, opsin, rect, quant_ac * rescale, pool, mask, mask1x1); } -void FindBestQuantizer(const FrameHeader& frame_header, const Image3F* linear, - const Image3F& opsin, ImageF& quant_field, - PassesEncoderState* enc_state, - const JxlCmsInterface& cms, ThreadPool* pool, - AuxOut* aux_out, double rescale) { +Status FindBestQuantizer(const FrameHeader& frame_header, const Image3F* linear, + const Image3F& opsin, ImageF& quant_field, + PassesEncoderState* enc_state, + const JxlCmsInterface& cms, ThreadPool* pool, + AuxOut* aux_out, double rescale) { const CompressParams& cparams = enc_state->cparams; if (cparams.max_error_mode) { - FindBestQuantizationMaxError(frame_header, opsin, quant_field, enc_state, - cms, pool, aux_out); + JXL_RETURN_IF_ERROR(FindBestQuantizationMaxError( + frame_header, opsin, quant_field, enc_state, cms, pool, aux_out)); } else if (linear && cparams.speed_tier <= SpeedTier::kKitten) { // Normal encoding to a butteraugli score. - FindBestQuantization(frame_header, *linear, opsin, quant_field, enc_state, - cms, pool, aux_out); + JXL_RETURN_IF_ERROR(FindBestQuantization(frame_header, *linear, opsin, + quant_field, enc_state, cms, pool, + aux_out)); } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h index 6aa8b10df6..26ed3f26ca 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h +++ b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h @@ -31,10 +31,11 @@ struct AuxOut; // of the input image, while a value less than 1.0 indicates that less // fine-grained quantization should be enough. Returns a mask, too, which // can later be used to make better decisions about ac strategy. -ImageF InitialQuantField(float butteraugli_target, const Image3F& opsin, - const Rect& rect, ThreadPool* pool, float rescale, - ImageF* initial_quant_mask, - ImageF* initial_quant_mask1x1); +StatusOr InitialQuantField(float butteraugli_target, + const Image3F& opsin, const Rect& rect, + ThreadPool* pool, float rescale, + ImageF* initial_quant_mask, + ImageF* initial_quant_mask1x1); float InitialQuantDC(float butteraugli_target); @@ -45,11 +46,11 @@ void AdjustQuantField(const AcStrategyImage& ac_strategy, const Rect& rect, // quant_field. Also computes the dequant_map corresponding to the given // dequant_float_map and chosen quantization levels. // `linear` is only used in Kitten mode or slower. -void FindBestQuantizer(const FrameHeader& frame_header, const Image3F* linear, - const Image3F& opsin, ImageF& quant_field, - PassesEncoderState* enc_state, - const JxlCmsInterface& cms, ThreadPool* pool, - AuxOut* aux_out, double rescale = 1.0); +Status FindBestQuantizer(const FrameHeader& frame_header, const Image3F* linear, + const Image3F& opsin, ImageF& quant_field, + PassesEncoderState* enc_state, + const JxlCmsInterface& cms, ThreadPool* pool, + AuxOut* aux_out, double rescale = 1.0); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_ans.cc b/third_party/jpeg-xl/lib/jxl/enc_ans.cc index 3efa62d8e1..5e59790b1e 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ans.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_ans.cc @@ -5,11 +5,13 @@ #include "lib/jxl/enc_ans.h" +#include #include #include #include #include +#include #include #include #include @@ -20,12 +22,15 @@ #include "lib/jxl/ans_common.h" #include "lib/jxl/base/bits.h" #include "lib/jxl/base/fast_math-inl.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/dec_ans.h" +#include "lib/jxl/enc_ans_params.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_cluster.h" #include "lib/jxl/enc_context_map.h" #include "lib/jxl/enc_fields.h" #include "lib/jxl/enc_huffman.h" +#include "lib/jxl/enc_params.h" #include "lib/jxl/fields.h" namespace jxl { @@ -37,7 +42,7 @@ constexpr #endif bool ans_fuzzer_friendly_ = false; -static const int kMaxNumSymbolsForSmallCode = 4; +const int kMaxNumSymbolsForSmallCode = 4; void ANSBuildInfoTable(const ANSHistBin* counts, const AliasTable::Entry* table, size_t alphabet_size, size_t log_alpha_size, @@ -99,16 +104,16 @@ float EstimateDataBitsFlat(const ANSHistBin* histogram, size_t len) { // Static Huffman code for encoding logcounts. The last symbol is used as RLE // sequence. -static const uint8_t kLogCountBitLengths[ANS_LOG_TAB_SIZE + 2] = { +const uint8_t kLogCountBitLengths[ANS_LOG_TAB_SIZE + 2] = { 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 6, 7, 7, }; -static const uint8_t kLogCountSymbols[ANS_LOG_TAB_SIZE + 2] = { +const uint8_t kLogCountSymbols[ANS_LOG_TAB_SIZE + 2] = { 17, 11, 15, 3, 9, 7, 4, 2, 5, 6, 0, 33, 1, 65, }; // Returns the difference between largest count that can be represented and is // smaller than "count" and smallest representable count larger than "count". -static int SmallestIncrement(uint32_t count, uint32_t shift) { +int SmallestIncrement(uint32_t count, uint32_t shift) { int bits = count == 0 ? -1 : FloorLog2Nonzero(count); int drop_bits = bits - GetPopulationCountPrecision(bits, shift); return drop_bits < 0 ? 1 : (1 << drop_bits); @@ -148,10 +153,11 @@ bool RebalanceHistogram(const float* targets, int max_symbol, int table_size, int inc = SmallestIncrement(counts[n], shift); counts[n] -= counts[n] & (inc - 1); // TODO(robryk): Should we rescale targets[n]? - const float target = - minimize_error_of_sum ? (sum_nonrounded - sum) : targets[n]; + const int target = minimize_error_of_sum + ? (static_cast(sum_nonrounded) - sum) + : static_cast(targets[n]); if (counts[n] == 0 || - (target > counts[n] + inc / 2 && counts[n] + inc < table_size)) { + (target >= counts[n] + inc / 2 && counts[n] + inc < table_size)) { counts[n] += inc; } sum += counts[n]; @@ -203,11 +209,11 @@ Status NormalizeCounts(ANSHistBin* counts, int* omit_pos, const int length, for (size_t n = 0; n < targets.size(); ++n) { targets[n] = norm * counts[n]; } - if (!RebalanceHistogram(&targets[0], max_symbol, table_size, shift, + if (!RebalanceHistogram(targets.data(), max_symbol, table_size, shift, omit_pos, counts)) { // Use an alternative rebalancing mechanism if the one above failed // to create a histogram that is positive wherever the original one was. - if (!RebalanceHistogram(&targets[0], max_symbol, table_size, shift, + if (!RebalanceHistogram(targets.data(), max_symbol, table_size, shift, omit_pos, counts)) { return JXL_FAILURE("Logic error: couldn't rebalance a histogram"); } @@ -482,8 +488,8 @@ size_t BuildAndStoreANSEncodingData( std::vector counts(histogram, histogram + alphabet_size); if (!counts.empty()) { size_t sum = 0; - for (size_t i = 0; i < counts.size(); i++) { - sum += counts[i]; + for (int count : counts) { + sum += count; } if (sum == 0) { counts[0] = ANS_TAB_SIZE; @@ -538,8 +544,8 @@ template void EncodeUintConfigs(const std::vector& uint_config, Writer* writer, size_t log_alpha_size) { // TODO(veluca): RLE? - for (size_t i = 0; i < uint_config.size(); i++) { - EncodeUintConfig(uint_config[i], writer, log_alpha_size); + for (const auto& cfg : uint_config) { + EncodeUintConfig(cfg, writer, log_alpha_size); } } template void EncodeUintConfigs(const std::vector&, @@ -553,8 +559,7 @@ void ChooseUintConfigs(const HistogramParams& params, std::vector* clustered_histograms, EntropyEncodingData* codes, size_t* log_alpha_size) { codes->uint_config.resize(clustered_histograms->size()); - if (params.streaming_mode || - params.uint_method == HistogramParams::HybridUintMethod::kNone) { + if (params.uint_method == HistogramParams::HybridUintMethod::kNone) { return; } if (params.uint_method == HistogramParams::HybridUintMethod::k000) { @@ -570,6 +575,12 @@ void ChooseUintConfigs(const HistogramParams& params, return; } + // If the uint config is adaptive, just stick with the default in streaming + // mode. + if (params.streaming_mode) { + return; + } + // Brute-force method that tries a few options. std::vector configs; if (params.uint_method == HistogramParams::HybridUintMethod::kBest) { @@ -619,12 +630,11 @@ void ChooseUintConfigs(const HistogramParams& params, std::fill(is_valid.begin(), is_valid.end(), true); std::fill(extra_bits.begin(), extra_bits.end(), 0); - for (size_t i = 0; i < clustered_histograms->size(); i++) { - (*clustered_histograms)[i].Clear(); + for (auto& histo : *clustered_histograms) { + histo.Clear(); } - for (size_t i = 0; i < tokens.size(); ++i) { - for (size_t j = 0; j < tokens[i].size(); ++j) { - const Token token = tokens[i][j]; + for (const auto& stream : tokens) { + for (const auto& token : stream) { // TODO(veluca): do not ignore lz77 commands. if (token.is_lz77_length) continue; size_t histo = context_map[token.context]; @@ -632,7 +642,7 @@ void ChooseUintConfigs(const HistogramParams& params, cfg.Encode(token.value, &tok, &nbits, &bits); if (tok >= max_alpha || (codes->lz77.enabled && tok >= codes->lz77.min_symbol)) { - is_valid[histo] = false; + is_valid[histo] = JXL_FALSE; continue; } extra_bits[histo] += nbits; @@ -654,13 +664,12 @@ void ChooseUintConfigs(const HistogramParams& params, } // Rebuild histograms. - for (size_t i = 0; i < clustered_histograms->size(); i++) { - (*clustered_histograms)[i].Clear(); + for (auto& histo : *clustered_histograms) { + histo.Clear(); } *log_alpha_size = 4; - for (size_t i = 0; i < tokens.size(); ++i) { - for (size_t j = 0; j < tokens[i].size(); ++j) { - const Token token = tokens[i][j]; + for (const auto& stream : tokens) { + for (const auto& token : stream) { uint32_t tok, nbits, bits; size_t histo = context_map[token.context]; (token.is_lz77_length ? codes->lz77.length_uint_config @@ -771,7 +780,7 @@ class HistogramBuilder { } SizeWriter size_writer; // Used if writer == nullptr to estimate costs. cost += 1; - if (writer) writer->Write(1, codes->use_prefix_code); + if (writer) writer->Write(1, TO_JXL_BOOL(codes->use_prefix_code)); if (codes->use_prefix_code) { log_alpha_size = PREFIX_MAX_BITS; @@ -785,8 +794,8 @@ class HistogramBuilder { EncodeUintConfigs(codes->uint_config, writer, log_alpha_size); } if (codes->use_prefix_code) { - for (size_t c = 0; c < clustered_histograms.size(); ++c) { - size_t alphabet_size = clustered_histograms[c].alphabet_size(); + for (const auto& histo : clustered_histograms) { + size_t alphabet_size = histo.alphabet_size(); if (writer) { StoreVarLenUint16(alphabet_size - 1, writer); } else { @@ -832,9 +841,8 @@ class SymbolCostEstimator { HistogramBuilder builder(num_contexts); // Build histograms for estimating lz77 savings. HybridUintConfig uint_config; - for (size_t i = 0; i < tokens.size(); ++i) { - for (size_t j = 0; j < tokens[i].size(); ++j) { - const Token token = tokens[i][j]; + for (const auto& stream : tokens) { + for (const auto& token : stream) { uint32_t tok, nbits, bits; (token.is_lz77_length ? lz77.length_uint_config : uint_config) .Encode(token.value, &tok, &nbits, &bits); @@ -1025,12 +1033,7 @@ struct HashChain { // Count down, so if due to small distance multiplier multiple distances // map to the same code, the smallest code will be used in the end. for (int i = kNumSpecialDistances - 1; i >= 0; --i) { - int xi = kSpecialDistances[i][0]; - int yi = kSpecialDistances[i][1]; - int distance = yi * distance_multiplier + xi; - // Ensure that we map distance 1 to the lowest symbols. - if (distance < 1) distance = 1; - special_dist_table_[distance] = i; + special_dist_table_[SpecialDistance(i, distance_multiplier)] = i; } num_special_distances_ = kNumSpecialDistances; } @@ -1041,9 +1044,9 @@ struct HashChain { if (pos + 2 < size_) { // TODO(lode): take the MSB's of the uint32_t values into account as well, // given that the hash code itself is less than 32 bits. - result ^= (uint32_t)(data_[pos + 0] << 0u); - result ^= (uint32_t)(data_[pos + 1] << hash_shift_); - result ^= (uint32_t)(data_[pos + 2] << (hash_shift_ * 2)); + result ^= static_cast(data_[pos + 0] << 0u); + result ^= static_cast(data_[pos + 1] << hash_shift_); + result ^= static_cast(data_[pos + 2] << (hash_shift_ * 2)); } else { // No need to compute hash of last 2 bytes, the length 2 is too short. return 0; @@ -1071,7 +1074,7 @@ struct HashChain { uint32_t hashval = GetHash(pos); uint32_t wpos = pos & window_mask_; - val[wpos] = (int)hashval; + val[wpos] = static_cast(hashval); if (head[hashval] != -1) chain[wpos] = head[hashval]; head[hashval] = wpos; @@ -1142,7 +1145,10 @@ struct HashChain { } else { if (hashpos == chain[hashpos]) break; hashpos = chain[hashpos]; - if (val[hashpos] != (int)hashval) break; // outdated hash value + if (val[hashpos] != static_cast(hashval)) { + // outdated hash value + break; + } } } } @@ -1274,7 +1280,8 @@ void ApplyLZ77_LZ77(const HistogramParams& params, size_t num_contexts, HashChain chain(in.data(), in.size(), window_size, min_length, max_length, distance_multiplier); - size_t len, dist_symbol; + size_t len; + size_t dist_symbol; const size_t max_lazy_match_len = 256; // 0 to disable lazy matching @@ -1507,7 +1514,7 @@ void EncodeHistograms(const std::vector& context_map, } EncodeContextMap(context_map, codes.encoding_info.size(), writer, layer, aux_out); - writer->Write(1, codes.use_prefix_code); + writer->Write(1, TO_JXL_BOOL(codes.use_prefix_code)); size_t log_alpha_size = 8; if (codes.use_prefix_code) { log_alpha_size = PREFIX_MAX_BITS; @@ -1583,10 +1590,9 @@ size_t BuildAndEncodeHistograms(const HistogramParams& params, if (ans_fuzzer_friendly_) { uint_config = HybridUintConfig(10, 0, 0); } - for (size_t i = 0; i < tokens.size(); ++i) { + for (const auto& stream : tokens) { if (codes->lz77.enabled) { - for (size_t j = 0; j < tokens[i].size(); ++j) { - const Token& token = tokens[i][j]; + for (const auto& token : stream) { total_tokens++; uint32_t tok, nbits, bits; (token.is_lz77_length ? codes->lz77.length_uint_config : uint_config) @@ -1595,16 +1601,14 @@ size_t BuildAndEncodeHistograms(const HistogramParams& params, builder.VisitSymbol(tok, token.context); } } else if (num_contexts == 1) { - for (size_t j = 0; j < tokens[i].size(); ++j) { - const Token& token = tokens[i][j]; + for (const auto& token : stream) { total_tokens++; uint32_t tok, nbits, bits; uint_config.Encode(token.value, &tok, &nbits, &bits); builder.VisitSymbol(tok, /*token.context=*/0); } } else { - for (size_t j = 0; j < tokens[i].size(); ++j) { - const Token& token = tokens[i][j]; + for (const auto& token : stream) { total_tokens++; uint32_t tok, nbits, bits; uint_config.Encode(token.value, &tok, &nbits, &bits); @@ -1654,10 +1658,10 @@ size_t BuildAndEncodeHistograms(const HistogramParams& params, codes->encoded_histograms.emplace_back(); BitWriter* histo_writer = &codes->encoded_histograms.back(); BitWriter::Allotment allotment(histo_writer, 256 + alphabet_size * 24); - BuildAndStoreANSEncodingData(params.ans_histogram_strategy, counts.data(), - alphabet_size, log_alpha_size, - codes->use_prefix_code, - &codes->encoding_info.back()[0], histo_writer); + BuildAndStoreANSEncodingData( + params.ans_histogram_strategy, counts.data(), alphabet_size, + log_alpha_size, codes->use_prefix_code, + codes->encoding_info.back().data(), histo_writer); allotment.ReclaimAndCharge(histo_writer, 0, nullptr); } @@ -1680,9 +1684,8 @@ size_t WriteTokens(const std::vector& tokens, size_t context_offset, BitWriter* writer) { size_t num_extra_bits = 0; if (codes.use_prefix_code) { - for (size_t i = 0; i < tokens.size(); i++) { + for (const auto& token : tokens) { uint32_t tok, nbits, bits; - const Token& token = tokens[i]; size_t histo = context_map[context_offset + token.context]; (token.is_lz77_length ? codes.lz77.length_uint_config : codes.uint_config[histo]) @@ -1693,7 +1696,8 @@ size_t WriteTokens(const std::vector& tokens, // codes.encoding_info[histo][tok].bits); // writer->Write(nbits, bits); uint64_t data = codes.encoding_info[histo][tok].bits; - data |= bits << codes.encoding_info[histo][tok].depth; + data |= static_cast(bits) + << codes.encoding_info[histo][tok].depth; writer->Write(codes.encoding_info[histo][tok].depth + nbits, data); num_extra_bits += nbits; } @@ -1765,7 +1769,8 @@ void WriteTokens(const std::vector& tokens, const EntropyEncodingData& codes, const std::vector& context_map, size_t context_offset, BitWriter* writer, size_t layer, AuxOut* aux_out) { - BitWriter::Allotment allotment(writer, 32 * tokens.size() + 32 * 1024 * 4); + // Theoretically, we could have 15 prefix code bits + 31 extra bits. + BitWriter::Allotment allotment(writer, 46 * tokens.size() + 32 * 1024 * 4); size_t num_extra_bits = WriteTokens(tokens, codes, context_map, context_offset, writer); allotment.ReclaimAndCharge(writer, layer, aux_out); @@ -1779,4 +1784,51 @@ void SetANSFuzzerFriendly(bool ans_fuzzer_friendly) { ans_fuzzer_friendly_ = ans_fuzzer_friendly; #endif } + +HistogramParams HistogramParams::ForModular( + const CompressParams& cparams, + const std::vector& extra_dc_precision, bool streaming_mode) { + HistogramParams params; + params.streaming_mode = streaming_mode; + if (cparams.speed_tier > SpeedTier::kKitten) { + params.clustering = HistogramParams::ClusteringType::kFast; + params.ans_histogram_strategy = + cparams.speed_tier > SpeedTier::kThunder + ? HistogramParams::ANSHistogramStrategy::kFast + : HistogramParams::ANSHistogramStrategy::kApproximate; + params.lz77_method = + cparams.decoding_speed_tier >= 3 && cparams.modular_mode + ? (cparams.speed_tier >= SpeedTier::kFalcon + ? HistogramParams::LZ77Method::kRLE + : HistogramParams::LZ77Method::kLZ77) + : HistogramParams::LZ77Method::kNone; + // Near-lossless DC, as well as modular mode, require choosing hybrid uint + // more carefully. + if ((!extra_dc_precision.empty() && extra_dc_precision[0] != 0) || + (cparams.modular_mode && cparams.speed_tier < SpeedTier::kCheetah)) { + params.uint_method = HistogramParams::HybridUintMethod::kFast; + } else { + params.uint_method = HistogramParams::HybridUintMethod::kNone; + } + } else if (cparams.speed_tier <= SpeedTier::kTortoise) { + params.lz77_method = HistogramParams::LZ77Method::kOptimal; + } else { + params.lz77_method = HistogramParams::LZ77Method::kLZ77; + } + if (cparams.decoding_speed_tier >= 1) { + params.max_histograms = 12; + } + if (cparams.decoding_speed_tier >= 1 && cparams.responsive) { + params.lz77_method = cparams.speed_tier >= SpeedTier::kCheetah + ? HistogramParams::LZ77Method::kRLE + : cparams.speed_tier >= SpeedTier::kKitten + ? HistogramParams::LZ77Method::kLZ77 + : HistogramParams::LZ77Method::kOptimal; + } + if (cparams.decoding_speed_tier >= 2 && cparams.responsive) { + params.uint_method = HistogramParams::HybridUintMethod::k000; + params.force_huffman = true; + } + return params; +} } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_ans.h b/third_party/jpeg-xl/lib/jxl/enc_ans.h index 445a5f0c9a..ae4d955a56 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ans.h +++ b/third_party/jpeg-xl/lib/jxl/enc_ans.h @@ -84,7 +84,7 @@ struct EntropyEncodingData { // Integer to be encoded by an entropy coder, either ANS or Huffman. struct Token { - Token() {} + Token() = default; Token(uint32_t c, uint32_t value) : is_lz77_length(false), context(c), value(value) {} uint32_t is_lz77_length : 1; diff --git a/third_party/jpeg-xl/lib/jxl/enc_ans_params.h b/third_party/jpeg-xl/lib/jxl/enc_ans_params.h index 86664f593e..23921097b4 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ans_params.h +++ b/third_party/jpeg-xl/lib/jxl/enc_ans_params.h @@ -11,10 +11,15 @@ #include #include -#include "lib/jxl/enc_params.h" +#include + +#include "lib/jxl/common.h" namespace jxl { +// Forward declaration to break include cycle. +struct CompressParams; + // RebalanceHistogram requires a signed type. using ANSHistBin = int32_t; @@ -65,6 +70,10 @@ struct HistogramParams { } } + static HistogramParams ForModular( + const CompressParams& cparams, + const std::vector& extra_dc_precision, bool streaming_mode); + ClusteringType clustering = ClusteringType::kBest; HybridUintMethod uint_method = HybridUintMethod::kBest; LZ77Method lz77_method = LZ77Method::kRLE; diff --git a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc index ed8a42d299..e80771248e 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc @@ -17,16 +17,10 @@ #include "lib/jxl/ac_strategy.h" #include "lib/jxl/base/compiler_specific.h" -#include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/chroma_from_luma.h" -#include "lib/jxl/enc_adaptive_quantization.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/image.h" -#include "lib/jxl/image_bundle.h" #include "lib/jxl/image_ops.h" -#include "lib/jxl/quant_weights.h" -#include "lib/jxl/quantizer.h" HWY_BEFORE_NAMESPACE(); namespace jxl { @@ -40,11 +34,12 @@ using hwy::HWY_NAMESPACE::Mul; using hwy::HWY_NAMESPACE::MulAdd; using hwy::HWY_NAMESPACE::Sqrt; -void ProcessTile(const CompressParams& cparams, const FrameHeader& frame_header, - const Image3F& opsin, const Rect& opsin_rect, - const ImageF& quant_field, const AcStrategyImage& ac_strategy, - ImageB* epf_sharpness, const Rect& rect, - ArControlFieldHeuristics::TempImages* temp_image) { +Status ProcessTile(const CompressParams& cparams, + const FrameHeader& frame_header, const Image3F& opsin, + const Rect& opsin_rect, const ImageF& quant_field, + const AcStrategyImage& ac_strategy, ImageB* epf_sharpness, + const Rect& rect, + ArControlFieldHeuristics::TempImages* temp_image) { JXL_ASSERT(opsin_rect.x0() % 8 == 0); JXL_ASSERT(opsin_rect.y0() % 8 == 0); JXL_ASSERT(opsin_rect.xsize() % 8 == 0); @@ -54,7 +49,7 @@ void ProcessTile(const CompressParams& cparams, const FrameHeader& frame_header, cparams.speed_tier > SpeedTier::kWombat || frame_header.loop_filter.epf_iters == 0) { FillPlane(static_cast(4), epf_sharpness, rect); - return; + return true; } // Likely better to have a higher X weight, like: @@ -70,7 +65,7 @@ void ProcessTile(const CompressParams& cparams, const FrameHeader& frame_header, size_t by1 = by0 + rect.ysize(); size_t bx0 = opsin_rect.x0() / 8 + rect.x0(); size_t bx1 = bx0 + rect.xsize(); - temp_image->InitOnce(); + JXL_RETURN_IF_ERROR(temp_image->InitOnce()); ImageF& laplacian_sqrsum = temp_image->laplacian_sqrsum; // Calculate the L2 of the 3x3 Laplacian in an integral transform // (for example 32x32 dct). This relates to transforms ability @@ -295,6 +290,7 @@ void ProcessTile(const CompressParams& cparams, const FrameHeader& frame_header, } } } + return true; } } // namespace @@ -307,14 +303,14 @@ HWY_AFTER_NAMESPACE(); namespace jxl { HWY_EXPORT(ProcessTile); -void ArControlFieldHeuristics::RunRect( +Status ArControlFieldHeuristics::RunRect( const CompressParams& cparams, const FrameHeader& frame_header, const Rect& block_rect, const Image3F& opsin, const Rect& opsin_rect, const ImageF& quant_field, const AcStrategyImage& ac_strategy, ImageB* epf_sharpness, size_t thread) { - HWY_DYNAMIC_DISPATCH(ProcessTile) - (cparams, frame_header, opsin, opsin_rect, quant_field, ac_strategy, - epf_sharpness, block_rect, &temp_images[thread]); + return HWY_DYNAMIC_DISPATCH(ProcessTile)( + cparams, frame_header, opsin, opsin_rect, quant_field, ac_strategy, + epf_sharpness, block_rect, &temp_images[thread]); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h index fe602c16e3..f3c5a97a1b 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h +++ b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h @@ -21,11 +21,15 @@ struct PassesEncoderState; struct ArControlFieldHeuristics { struct TempImages { - void InitOnce() { - if (laplacian_sqrsum.xsize() != 0) return; - laplacian_sqrsum = ImageF(kEncTileDim + 4, kEncTileDim + 4); - sqrsum_00 = ImageF(kEncTileDim / 4, kEncTileDim / 4); - sqrsum_22 = ImageF(kEncTileDim / 4 + 1, kEncTileDim / 4 + 1); + Status InitOnce() { + if (laplacian_sqrsum.xsize() != 0) return true; + JXL_ASSIGN_OR_RETURN(laplacian_sqrsum, + ImageF::Create(kEncTileDim + 4, kEncTileDim + 4)); + JXL_ASSIGN_OR_RETURN(sqrsum_00, + ImageF::Create(kEncTileDim / 4, kEncTileDim / 4)); + JXL_ASSIGN_OR_RETURN( + sqrsum_22, ImageF::Create(kEncTileDim / 4 + 1, kEncTileDim / 4 + 1)); + return true; } ImageF laplacian_sqrsum; @@ -37,11 +41,11 @@ struct ArControlFieldHeuristics { temp_images.resize(num_threads); } - void RunRect(const CompressParams& cparams, const FrameHeader& frame_header, - const Rect& block_rect, const Image3F& opsin, - const Rect& opsin_rect, const ImageF& quant_field, - const AcStrategyImage& ac_strategy, ImageB* epf_sharpness, - size_t thread); + Status RunRect(const CompressParams& cparams, const FrameHeader& frame_header, + const Rect& block_rect, const Image3F& opsin, + const Rect& opsin_rect, const ImageF& quant_field, + const AcStrategyImage& ac_strategy, ImageB* epf_sharpness, + size_t thread); std::vector temp_images; }; diff --git a/third_party/jpeg-xl/lib/jxl/enc_aux_out.cc b/third_party/jpeg-xl/lib/jxl/enc_aux_out.cc index 12c8619e91..d529b381f8 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_aux_out.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_aux_out.cc @@ -5,16 +5,10 @@ #include "lib/jxl/enc_aux_out.h" -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif - #include #include #include -#include -#include // accumulate #include #include "lib/jxl/base/printf_macros.h" @@ -61,13 +55,11 @@ const char* LayerName(size_t layer) { void AuxOut::LayerTotals::Print(size_t num_inputs) const { if (JXL_DEBUG_V_LEVEL > 0) { - printf("%10" PRId64, static_cast(total_bits)); + printf("%10" PRIuS, total_bits); if (histogram_bits != 0) { - printf(" [c/i:%6.2f | hst:%8" PRId64 " | ex:%8" PRId64 - " | h+c+e:%12.3f", - num_clustered_histograms * 1.0 / num_inputs, - static_cast(histogram_bits >> 3), - static_cast(extra_bits >> 3), + printf(" [c/i:%6.2f | hst:%8" PRIuS " | ex:%8" PRIuS " | h+c+e:%12.3f", + num_clustered_histograms * 1.0 / num_inputs, histogram_bits >> 3, + extra_bits >> 3, (histogram_bits + clustered_entropy + extra_bits) / 8.0); printf("]"); } @@ -99,8 +91,8 @@ void AuxOut::Print(size_t num_inputs) const { if (num_inputs == 0) return; LayerTotals all_layers; - for (size_t i = 0; i < layers.size(); ++i) { - all_layers.Assimilate(layers[i]); + for (const auto& layer : layers) { + all_layers.Assimilate(layer); } printf("Average butteraugli iters: %10.2f\n", diff --git a/third_party/jpeg-xl/lib/jxl/enc_bit_writer.cc b/third_party/jpeg-xl/lib/jxl/enc_bit_writer.cc index a9a86dca3b..6e6e6a353c 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_bit_writer.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_bit_writer.cc @@ -5,6 +5,7 @@ #include "lib/jxl/enc_bit_writer.h" +#include #include // memcpy #include "lib/jxl/base/byte_order.h" @@ -43,10 +44,11 @@ void BitWriter::Allotment::FinishedHistogram(BitWriter* JXL_RESTRICT writer) { void BitWriter::Allotment::ReclaimAndCharge(BitWriter* JXL_RESTRICT writer, size_t layer, AuxOut* JXL_RESTRICT aux_out) { - size_t used_bits = 0, unused_bits = 0; + size_t used_bits = 0; + size_t unused_bits = 0; PrivateReclaim(writer, &used_bits, &unused_bits); -#if 0 +#if JXL_FALSE printf("Layer %s bits: max %" PRIuS " used %" PRIuS " unused %" PRIuS "\n", LayerName(layer), MaxBits(), used_bits, unused_bits); #endif @@ -77,7 +79,7 @@ void BitWriter::Allotment::PrivateReclaim(BitWriter* JXL_RESTRICT writer, writer->storage_.resize(writer->storage_.size() - unused_bytes); writer->current_allotment_ = parent_; // Ensure we don't also charge the parent for these bits. - auto parent = parent_; + auto* parent = parent_; while (parent != nullptr) { parent->prev_bits_written_ += *used_bits; parent = parent->parent_; diff --git a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc index 019d6125a2..b20fa751c1 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.cc @@ -5,9 +5,7 @@ #include "lib/jxl/enc_butteraugli_comparator.h" -#include -#include - +#include "lib/jxl/base/status.h" #include "lib/jxl/enc_image_bundle.h" namespace jxl { @@ -24,9 +22,8 @@ Status JxlButteraugliComparator::SetReferenceImage(const ImageBundle& ref) { /*pool=*/nullptr, &store, &ref_linear_srgb)) { return false; } - - comparator_.reset( - new ButteraugliComparator(ref_linear_srgb->color(), params_)); + JXL_ASSIGN_OR_RETURN(comparator_, ButteraugliComparator::Make( + ref_linear_srgb->color(), params_)); xsize_ = ref.xsize(); ysize_ = ref.ysize(); return true; @@ -34,7 +31,8 @@ Status JxlButteraugliComparator::SetReferenceImage(const ImageBundle& ref) { Status JxlButteraugliComparator::SetLinearReferenceImage( const Image3F& linear) { - comparator_.reset(new ButteraugliComparator(linear, params_)); + JXL_ASSIGN_OR_RETURN(comparator_, + ButteraugliComparator::Make(linear, params_)); xsize_ = linear.xsize(); ysize_ = linear.ysize(); return true; @@ -58,8 +56,9 @@ Status JxlButteraugliComparator::CompareWith(const ImageBundle& actual, return false; } - ImageF temp_diffmap(xsize_, ysize_); - comparator_->Diffmap(actual_linear_srgb->color(), temp_diffmap); + JXL_ASSIGN_OR_RETURN(ImageF temp_diffmap, ImageF::Create(xsize_, ysize_)); + JXL_RETURN_IF_ERROR( + comparator_->Diffmap(actual_linear_srgb->color(), temp_diffmap)); if (score != nullptr) { *score = ButteraugliScoreFromDiffmap(temp_diffmap, ¶ms_); @@ -79,29 +78,4 @@ float JxlButteraugliComparator::BadQualityScore() const { return ButteraugliFuzzyInverse(0.5); } -float ButteraugliDistance(const ImageBundle& rgb0, const ImageBundle& rgb1, - const ButteraugliParams& params, - const JxlCmsInterface& cms, ImageF* distmap, - ThreadPool* pool, bool ignore_alpha) { - JxlButteraugliComparator comparator(params, cms); - return ComputeScore(rgb0, rgb1, &comparator, cms, distmap, pool, - ignore_alpha); -} - -float ButteraugliDistance(const std::vector& frames0, - const std::vector& frames1, - const ButteraugliParams& params, - const JxlCmsInterface& cms, ImageF* distmap, - ThreadPool* pool) { - JxlButteraugliComparator comparator(params, cms); - JXL_ASSERT(frames0.size() == frames1.size()); - float max_dist = 0.0f; - for (size_t i = 0; i < frames0.size(); ++i) { - max_dist = std::max( - max_dist, - ComputeScore(frames0[i], frames1[i], &comparator, cms, distmap, pool)); - } - return max_dist; -} - } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h index 641d7732d5..4f70e21a1b 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h +++ b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h @@ -10,9 +10,7 @@ #include #include -#include -#include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" #include "lib/jxl/butteraugli/butteraugli.h" #include "lib/jxl/enc_comparator.h" @@ -43,20 +41,6 @@ class JxlButteraugliComparator : public Comparator { size_t ysize_ = 0; }; -// Returns the butteraugli distance between rgb0 and rgb1. -// If distmap is not null, it must be the same size as rgb0 and rgb1. -float ButteraugliDistance(const ImageBundle& rgb0, const ImageBundle& rgb1, - const ButteraugliParams& params, - const JxlCmsInterface& cms, ImageF* distmap = nullptr, - ThreadPool* pool = nullptr, - bool ignore_alpha = false); - -float ButteraugliDistance(const std::vector& frames0, - const std::vector& frames1, - const ButteraugliParams& params, - const JxlCmsInterface& cms, ImageF* distmap = nullptr, - ThreadPool* pool = nullptr); - } // namespace jxl #endif // LIB_JXL_ENC_BUTTERAUGLI_COMPARATOR_H_ diff --git a/third_party/jpeg-xl/lib/jxl/enc_cache.cc b/third_party/jpeg-xl/lib/jxl/enc_cache.cc index ff62c57e4d..200ec83b65 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_cache.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_cache.cc @@ -8,15 +8,14 @@ #include #include -#include +#include -#include "lib/jxl/ac_strategy.h" #include "lib/jxl/base/common.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/span.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/compressed_dc.h" -#include "lib/jxl/dct_scales.h" #include "lib/jxl/dct_util.h" #include "lib/jxl/dec_frame.h" #include "lib/jxl/enc_aux_out.h" @@ -50,8 +49,11 @@ Status InitializePassesEncoder(const FrameHeader& frame_header, for (size_t i = enc_state->coeffs.size(); i < frame_header.passes.num_passes; i++) { // Allocate enough coefficients for each group on every row. - enc_state->coeffs.emplace_back(make_unique>( - kGroupDim * kGroupDim, shared.frame_dim.num_groups)); + JXL_ASSIGN_OR_RETURN( + std::unique_ptr> coeffs, + ACImageT::Make(kGroupDim * kGroupDim, + shared.frame_dim.num_groups)); + enc_state->coeffs.emplace_back(std::move(coeffs)); } } while (enc_state->coeffs.size() > frame_header.passes.num_passes) { @@ -65,7 +67,9 @@ Status InitializePassesEncoder(const FrameHeader& frame_header, shared.quantizer.RecomputeFromGlobalScale(); } - Image3F dc(shared.frame_dim.xsize_blocks, shared.frame_dim.ysize_blocks); + JXL_ASSIGN_OR_RETURN(Image3F dc, + Image3F::Create(shared.frame_dim.xsize_blocks, + shared.frame_dim.ysize_blocks)); JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, shared.frame_dim.num_groups, ThreadPool::NoInit, [&](size_t group_idx, size_t _) { @@ -90,9 +94,9 @@ Status InitializePassesEncoder(const FrameHeader& frame_header, // and kModular for the smallest DC (first in the bitstream) if (cparams.progressive_dc == 0) { cparams.modular_mode = true; - cparams.speed_tier = - SpeedTier(std::max(static_cast(SpeedTier::kTortoise), - static_cast(cparams.speed_tier) - 1)); + cparams.speed_tier = static_cast( + std::max(static_cast(SpeedTier::kTortoise), + static_cast(cparams.speed_tier) - 1)); cparams.butteraugli_distance = std::max(kMinButteraugliDistance, enc_state->cparams.butteraugli_distance * 0.02f); @@ -120,7 +124,8 @@ Status InitializePassesEncoder(const FrameHeader& frame_header, std::vector extra_channels; extra_channels.reserve(ib.metadata()->extra_channel_info.size()); for (size_t i = 0; i < ib.metadata()->extra_channel_info.size(); i++) { - extra_channels.emplace_back(ib.xsize(), ib.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF ch, ImageF::Create(ib.xsize(), ib.ysize())); + extra_channels.emplace_back(std::move(ch)); // Must initialize the image with data to not affect blending with // uninitialized memory. // TODO(lode): dc_level must copy and use the real extra channels @@ -168,32 +173,41 @@ Status InitializePassesEncoder(const FrameHeader& frame_header, // outputs multiple frames, this assumption could be wrong. const Image3F& dc_frame = dec_state->shared->dc_frames[frame_header.dc_level]; - shared.dc_storage = Image3F(dc_frame.xsize(), dc_frame.ysize()); + JXL_ASSIGN_OR_RETURN(shared.dc_storage, + Image3F::Create(dc_frame.xsize(), dc_frame.ysize())); CopyImageTo(dc_frame, &shared.dc_storage); ZeroFillImage(&shared.quant_dc); shared.dc = &shared.dc_storage; JXL_CHECK(encoded_size == 0); } else { + std::atomic has_error{false}; auto compute_dc_coeffs = [&](int group_index, int /* thread */) { + if (has_error) return; const Rect r = enc_state->shared.frame_dim.DCGroupRect(group_index); int modular_group_index = group_index; if (enc_state->streaming_mode) { JXL_ASSERT(group_index == 0); modular_group_index = enc_state->dc_group_index; } - modular_frame_encoder->AddVarDCTDC( - frame_header, dc, r, modular_group_index, - enc_state->cparams.speed_tier < SpeedTier::kFalcon, enc_state, - /*jpeg_transcode=*/false); + if (!modular_frame_encoder->AddVarDCTDC( + frame_header, dc, r, modular_group_index, + enc_state->cparams.speed_tier < SpeedTier::kFalcon, enc_state, + /*jpeg_transcode=*/false)) { + has_error = true; + return; + } }; JXL_RETURN_IF_ERROR(RunOnPool(pool, 0, shared.frame_dim.num_dc_groups, ThreadPool::NoInit, compute_dc_coeffs, "Compute DC coeffs")); + if (has_error) return JXL_FAILURE("Compute DC coeffs failed"); // TODO(veluca): this is only useful in tests and if inspection is enabled. if (!(frame_header.flags & FrameHeader::kSkipAdaptiveDCSmoothing)) { - AdaptiveDCSmoothing(shared.quantizer.MulDC(), &shared.dc_storage, pool); + JXL_RETURN_IF_ERROR(AdaptiveDCSmoothing(shared.quantizer.MulDC(), + &shared.dc_storage, pool)); } } + std::atomic has_error{false}; auto compute_ac_meta = [&](int group_index, int /* thread */) { const Rect r = enc_state->shared.frame_dim.DCGroupRect(group_index); int modular_group_index = group_index; @@ -201,13 +215,17 @@ Status InitializePassesEncoder(const FrameHeader& frame_header, JXL_ASSERT(group_index == 0); modular_group_index = enc_state->dc_group_index; } - modular_frame_encoder->AddACMetadata(r, modular_group_index, - /*jpeg_transcode=*/false, enc_state); + if (!modular_frame_encoder->AddACMetadata(r, modular_group_index, + /*jpeg_transcode=*/false, + enc_state)) { + has_error = true; + return; + } }; JXL_RETURN_IF_ERROR(RunOnPool(pool, 0, shared.frame_dim.num_dc_groups, ThreadPool::NoInit, compute_ac_meta, "Compute AC Metadata")); - + if (has_error) return JXL_FAILURE("Compute AC Metadata failed"); return true; } diff --git a/third_party/jpeg-xl/lib/jxl/enc_cache.h b/third_party/jpeg-xl/lib/jxl/enc_cache.h index 6efcc081c1..43ee7bc9c8 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_cache.h +++ b/third_party/jpeg-xl/lib/jxl/enc_cache.h @@ -55,7 +55,7 @@ struct PassesEncoderState { }; std::vector passes; - std::vector histogram_idx; + std::vector histogram_idx; // Block sizes seen so far. uint32_t used_acs = 0; diff --git a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc index 9a894d89cc..4039da2858 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc @@ -9,7 +9,6 @@ #include #include -#include #include #undef HWY_TARGET_INCLUDE @@ -18,18 +17,13 @@ #include #include -#include "lib/jxl/base/bits.h" #include "lib/jxl/base/common.h" -#include "lib/jxl/base/span.h" #include "lib/jxl/base/status.h" #include "lib/jxl/cms/opsin_params.h" #include "lib/jxl/dec_transforms-inl.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/enc_transforms-inl.h" -#include "lib/jxl/entropy_coder.h" -#include "lib/jxl/image_ops.h" -#include "lib/jxl/modular/encoding/encoding.h" #include "lib/jxl/quantizer.h" #include "lib/jxl/simd_util.h" HWY_BEFORE_NAMESPACE(); @@ -149,7 +143,8 @@ int32_t FindBestMultiplier(const float* values_m, const float* values_s, // Derivatives are approximate due to the high amount of noise in the exact // derivatives. for (size_t i = 0; i < 20; i++) { - float dfpeps, dfmeps; + float dfpeps; + float dfmeps; float df = fn.Compute(x, eps, &dfpeps, &dfmeps); float ddf = (dfpeps - dfmeps) / (2 * eps); float kExperimentalInsignificantStabilizer = 0.85; @@ -175,12 +170,13 @@ int32_t FindBestMultiplier(const float* values_m, const float* values_s, return std::max(-128.0f, std::min(127.0f, roundf(x))); } -void InitDCStorage(size_t num_blocks, ImageF* dc_values) { +Status InitDCStorage(size_t num_blocks, ImageF* dc_values) { // First row: Y channel // Second row: X channel // Third row: Y channel // Fourth row: B channel - *dc_values = ImageF(RoundUpTo(num_blocks, Lanes(df)), 4); + JXL_ASSIGN_OR_RETURN(*dc_values, + ImageF::Create(RoundUpTo(num_blocks, Lanes(df)), 4)); JXL_ASSERT(dc_values->xsize() != 0); // Zero-fill the last lanes @@ -190,6 +186,7 @@ void InitDCStorage(size_t num_blocks, ImageF* dc_values) { dc_values->Row(y)[x] = 0; } } + return true; } void ComputeTile(const Image3F& opsin, const Rect& opsin_rect, @@ -352,11 +349,11 @@ namespace jxl { HWY_EXPORT(InitDCStorage); HWY_EXPORT(ComputeTile); -void CfLHeuristics::Init(const Rect& rect) { +Status CfLHeuristics::Init(const Rect& rect) { size_t xsize_blocks = rect.xsize() / kBlockDim; size_t ysize_blocks = rect.ysize() / kBlockDim; - HWY_DYNAMIC_DISPATCH(InitDCStorage) - (xsize_blocks * ysize_blocks, &dc_values); + return HWY_DYNAMIC_DISPATCH(InitDCStorage)(xsize_blocks * ysize_blocks, + &dc_values); } void CfLHeuristics::ComputeTile(const Rect& r, const Image3F& opsin, diff --git a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h index 04743842bf..c6481a0ec9 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h +++ b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h @@ -29,7 +29,7 @@ void ColorCorrelationMapEncodeDC(const ColorCorrelationMap& map, AuxOut* aux_out); struct CfLHeuristics { - void Init(const Rect& rect); + Status Init(const Rect& rect); void PrepareForThreads(size_t num_threads) { mem = hwy::AllocateAligned(num_threads * ItemsPerThread()); diff --git a/third_party/jpeg-xl/lib/jxl/enc_cluster.cc b/third_party/jpeg-xl/lib/jxl/enc_cluster.cc index df1b31ddf7..f7284331d9 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_cluster.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_cluster.cc @@ -236,7 +236,7 @@ void HistogramReindex(std::vector* out, size_t prev_histograms, // Clusters similar histograms in 'in' together, the selected histograms are // placed in 'out', and for each index in 'in', *histogram_symbols will // indicate which of the 'out' histograms is the best approximation. -void ClusterHistograms(const HistogramParams params, +void ClusterHistograms(const HistogramParams& params, const std::vector& in, size_t max_histograms, std::vector* out, std::vector* histogram_symbols) { @@ -252,9 +252,9 @@ void ClusterHistograms(const HistogramParams params, if (prev_histograms == 0 && params.clustering == HistogramParams::ClusteringType::kBest) { - for (size_t i = 0; i < out->size(); i++) { - (*out)[i].entropy_ = - ANSPopulationCost((*out)[i].data_.data(), (*out)[i].data_.size()); + for (auto& histo : *out) { + histo.entropy_ = + ANSPopulationCost(histo.data_.data(), histo.data_.size()); } uint32_t next_version = 2; std::vector version(out->size(), 1); @@ -308,9 +308,9 @@ void ClusterHistograms(const HistogramParams params, (*out)[first].AddHistogram((*out)[second]); (*out)[first].entropy_ = ANSPopulationCost((*out)[first].data_.data(), (*out)[first].data_.size()); - for (size_t i = 0; i < renumbering.size(); i++) { - if (renumbering[i] == second) { - renumbering[i] = first; + for (uint32_t& item : renumbering) { + if (item == second) { + item = first; } } version[second] = 0; @@ -338,9 +338,8 @@ void ClusterHistograms(const HistogramParams params, reverse_renumbering[i] = num_alive - 1; } out->resize(num_alive); - for (size_t i = 0; i < histogram_symbols->size(); i++) { - (*histogram_symbols)[i] = - reverse_renumbering[renumbering[(*histogram_symbols)[i]]]; + for (uint32_t& item : *histogram_symbols) { + item = reverse_renumbering[renumbering[item]]; } } diff --git a/third_party/jpeg-xl/lib/jxl/enc_cluster.h b/third_party/jpeg-xl/lib/jxl/enc_cluster.h index 923aaaccfe..7ddc003cf2 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_cluster.h +++ b/third_party/jpeg-xl/lib/jxl/enc_cluster.h @@ -15,6 +15,7 @@ #include #include "lib/jxl/ans_params.h" +#include "lib/jxl/base/common.h" #include "lib/jxl/enc_ans_params.h" namespace jxl { @@ -61,8 +62,9 @@ struct Histogram { static constexpr size_t kRounding = 8; }; -void ClusterHistograms(HistogramParams params, const std::vector& in, - size_t max_histograms, std::vector* out, +void ClusterHistograms(const HistogramParams& params, + const std::vector& in, size_t max_histograms, + std::vector* out, std::vector* histogram_symbols); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc b/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc index 5be012aa92..49129f5d9e 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_coeff_order.cc @@ -6,21 +6,16 @@ #include #include +#include #include #include -#include "lib/jxl/ans_params.h" -#include "lib/jxl/base/span.h" #include "lib/jxl/coeff_order.h" #include "lib/jxl/coeff_order_fwd.h" -#include "lib/jxl/dec_ans.h" -#include "lib/jxl/dec_bit_reader.h" +#include "lib/jxl/dct_util.h" #include "lib/jxl/enc_ans.h" #include "lib/jxl/enc_bit_writer.h" -#include "lib/jxl/entropy_coder.h" #include "lib/jxl/lehmer_code.h" -#include "lib/jxl/modular/encoding/encoding.h" -#include "lib/jxl/modular/modular_image.h" namespace jxl { @@ -240,7 +235,7 @@ void EncodePermutation(const coeff_order_t* JXL_RESTRICT order, size_t skip, size_t size, BitWriter* writer, int layer, AuxOut* aux_out) { std::vector> tokens(1); - TokenizePermutation(order, skip, size, &tokens[0]); + TokenizePermutation(order, skip, size, tokens.data()); std::vector context_map; EntropyEncodingData codes; BuildAndEncodeHistograms(HistogramParams(), kPermutationContexts, tokens, @@ -280,7 +275,7 @@ void EncodeCoeffOrders(uint16_t used_orders, if (natural_order_lut.size() < size) natural_order_lut.resize(size); acs.ComputeNaturalCoeffOrderLut(natural_order_lut.data()); for (size_t c = 0; c < 3; c++) { - EncodeCoeffOrder(&order[CoeffOrderOffset(ord, c)], acs, &tokens[0], + EncodeCoeffOrder(&order[CoeffOrderOffset(ord, c)], acs, tokens.data(), mem.get(), natural_order_lut); } } diff --git a/third_party/jpeg-xl/lib/jxl/enc_comparator.cc b/third_party/jpeg-xl/lib/jxl/enc_comparator.cc index 268122af06..3ef6a49b8f 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_comparator.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_comparator.cc @@ -66,9 +66,10 @@ float ComputeScoreImpl(const ImageBundle& rgb0, const ImageBundle& rgb1, } // namespace -float ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1, - Comparator* comparator, const JxlCmsInterface& cms, - ImageF* diffmap, ThreadPool* pool, bool ignore_alpha) { +Status ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1, + Comparator* comparator, const JxlCmsInterface& cms, + float* score, ImageF* diffmap, ThreadPool* pool, + bool ignore_alpha) { // Convert to linear sRGB (unless already in that space) ImageMetadata metadata0 = *rgb0.metadata(); ImageBundle store0(&metadata0); @@ -83,25 +84,28 @@ float ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1, // No alpha: skip blending, only need a single call to Butteraugli. if (ignore_alpha || (!rgb0.HasAlpha() && !rgb1.HasAlpha())) { - return ComputeScoreImpl(*linear_srgb0, *linear_srgb1, comparator, diffmap); + *score = + ComputeScoreImpl(*linear_srgb0, *linear_srgb1, comparator, diffmap); + return true; } // Blend on black and white backgrounds const float black = 0.0f; - ImageBundle blended_black0 = linear_srgb0->Copy(); - ImageBundle blended_black1 = linear_srgb1->Copy(); + JXL_ASSIGN_OR_RETURN(ImageBundle blended_black0, linear_srgb0->Copy()); + JXL_ASSIGN_OR_RETURN(ImageBundle blended_black1, linear_srgb1->Copy()); AlphaBlend(black, &blended_black0); AlphaBlend(black, &blended_black1); const float white = 1.0f; - ImageBundle blended_white0 = linear_srgb0->Copy(); - ImageBundle blended_white1 = linear_srgb1->Copy(); + JXL_ASSIGN_OR_RETURN(ImageBundle blended_white0, linear_srgb0->Copy()); + JXL_ASSIGN_OR_RETURN(ImageBundle blended_white1, linear_srgb1->Copy()); AlphaBlend(white, &blended_white0); AlphaBlend(white, &blended_white1); - ImageF diffmap_black, diffmap_white; + ImageF diffmap_black; + ImageF diffmap_white; const float dist_black = ComputeScoreImpl(blended_black0, blended_black1, comparator, &diffmap_black); const float dist_white = ComputeScoreImpl(blended_white0, blended_white1, @@ -111,7 +115,7 @@ float ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1, if (diffmap != nullptr) { const size_t xsize = rgb0.xsize(); const size_t ysize = rgb0.ysize(); - *diffmap = ImageF(xsize, ysize); + JXL_ASSIGN_OR_RETURN(*diffmap, ImageF::Create(xsize, ysize)); for (size_t y = 0; y < ysize; ++y) { const float* JXL_RESTRICT row_black = diffmap_black.ConstRow(y); const float* JXL_RESTRICT row_white = diffmap_white.ConstRow(y); @@ -121,7 +125,8 @@ float ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1, } } } - return std::max(dist_black, dist_white); + *score = std::max(dist_black, dist_white); + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_comparator.h b/third_party/jpeg-xl/lib/jxl/enc_comparator.h index c545ea6111..ee62ab6f28 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_comparator.h +++ b/third_party/jpeg-xl/lib/jxl/enc_comparator.h @@ -43,10 +43,10 @@ class Comparator { // Computes the score given images in any RGB color model, optionally with // alpha channel. -float ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1, - Comparator* comparator, const JxlCmsInterface& cms, - ImageF* diffmap = nullptr, ThreadPool* pool = nullptr, - bool ignore_alpha = false); +Status ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1, + Comparator* comparator, const JxlCmsInterface& cms, + float* score, ImageF* diffmap = nullptr, + ThreadPool* pool = nullptr, bool ignore_alpha = false); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_context_map.cc b/third_party/jpeg-xl/lib/jxl/enc_context_map.cc index 6968a6fbae..36efc4e649 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_context_map.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_context_map.cc @@ -7,6 +7,7 @@ #include "lib/jxl/enc_context_map.h" +#include #include #include @@ -18,6 +19,7 @@ #include "lib/jxl/enc_ans.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/entropy_coder.h" +#include "lib/jxl/fields.h" #include "lib/jxl/pack_signed.h" namespace jxl { @@ -69,16 +71,18 @@ void EncodeContextMap(const std::vector& context_map, } std::vector transformed_symbols = MoveToFrontTransform(context_map); - std::vector> tokens(1), mtf_tokens(1); - for (size_t i = 0; i < context_map.size(); i++) { - tokens[0].emplace_back(0, context_map[i]); + std::vector> tokens(1); + std::vector> mtf_tokens(1); + for (const uint8_t& ctx : context_map) { + tokens[0].emplace_back(0, ctx); } - for (size_t i = 0; i < transformed_symbols.size(); i++) { - mtf_tokens[0].emplace_back(0, transformed_symbols[i]); + for (const uint8_t& sym : transformed_symbols) { + mtf_tokens[0].emplace_back(0, sym); } HistogramParams params; params.uint_method = HistogramParams::HybridUintMethod::kContextMap; - size_t ans_cost, mtf_cost; + size_t ans_cost; + size_t mtf_cost; { EntropyEncodingData codes; std::vector sink_context_map; @@ -104,14 +108,14 @@ void EncodeContextMap(const std::vector& context_map, BitWriter::Allotment allotment(writer, 3 + entry_bits * context_map.size()); writer->Write(1, 1); writer->Write(2, entry_bits); - for (size_t i = 0; i < context_map.size(); i++) { - writer->Write(entry_bits, context_map[i]); + for (uint8_t entry : context_map) { + writer->Write(entry_bits, entry); } allotment.ReclaimAndCharge(writer, layer, aux_out); } else { BitWriter::Allotment allotment(writer, 2 + tokens[0].size() * 24); writer->Write(1, 0); - writer->Write(1, use_mtf); // Use/don't use MTF. + writer->Write(1, TO_JXL_BOOL(use_mtf)); // Use/don't use MTF. EntropyEncodingData codes; std::vector sink_context_map; BuildAndEncodeHistograms(params, 1, tokens, &codes, &sink_context_map, @@ -123,9 +127,9 @@ void EncodeContextMap(const std::vector& context_map, void EncodeBlockCtxMap(const BlockCtxMap& block_ctx_map, BitWriter* writer, AuxOut* aux_out) { - auto& dct = block_ctx_map.dc_thresholds; - auto& qft = block_ctx_map.qf_thresholds; - auto& ctx_map = block_ctx_map.ctx_map; + const auto& dct = block_ctx_map.dc_thresholds; + const auto& qft = block_ctx_map.qf_thresholds; + const auto& ctx_map = block_ctx_map.ctx_map; BitWriter::Allotment allotment( writer, (dct[0].size() + dct[1].size() + dct[2].size() + qft.size()) * 34 + 1 + diff --git a/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc b/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc index 261570e690..d67ab7db46 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_debug_image.cc @@ -18,32 +18,29 @@ namespace jxl { namespace { template -Plane ConvertToFloat(const Plane& from) { +StatusOr ConvertToFloat(const Image3& from) { float factor = 1.0f / std::numeric_limits::max(); if (std::is_same::value || std::is_same::value) { factor = 1.0f; } - Plane to(from.xsize(), from.ysize()); - for (size_t y = 0; y < from.ysize(); ++y) { - const From* const JXL_RESTRICT row_from = from.Row(y); - float* const JXL_RESTRICT row_to = to.Row(y); - for (size_t x = 0; x < from.xsize(); ++x) { - row_to[x] = row_from[x] * factor; + JXL_ASSIGN_OR_RETURN(Image3F to, Image3F::Create(from.xsize(), from.ysize())); + for (size_t c = 0; c < 3; ++c) { + for (size_t y = 0; y < from.ysize(); ++y) { + const From* const JXL_RESTRICT row_from = from.ConstPlaneRow(c, y); + float* const JXL_RESTRICT row_to = to.PlaneRow(c, y); + for (size_t x = 0; x < from.xsize(); ++x) { + row_to[x] = row_from[x] * factor; + } } } return to; } -template -Image3F ConvertToFloat(const Image3& from) { - return Image3F(ConvertToFloat(from.Plane(0)), ConvertToFloat(from.Plane(1)), - ConvertToFloat(from.Plane(2))); -} template -void DumpImageT(const CompressParams& cparams, const char* label, - const ColorEncoding& color_encoding, const Image3& image) { - if (!cparams.debug_image) return; - Image3F float_image = ConvertToFloat(image); +Status DumpImageT(const CompressParams& cparams, const char* label, + const ColorEncoding& color_encoding, const Image3& image) { + if (!cparams.debug_image) return true; + JXL_ASSIGN_OR_RETURN(Image3F float_image, ConvertToFloat(image)); JxlColorEncoding color = color_encoding.ToExternal(); size_t num_pixels = 3 * image.xsize() * image.ysize(); std::vector pixels(num_pixels); @@ -53,18 +50,20 @@ void DumpImageT(const CompressParams& cparams, const char* label, } JXL_CHECK(ConvertChannelsToExternal( channels, 3, 16, false, JXL_BIG_ENDIAN, 6 * image.xsize(), nullptr, - &pixels[0], 2 * num_pixels, PixelCallback(), Orientation::kIdentity)); + pixels.data(), 2 * num_pixels, PixelCallback(), Orientation::kIdentity)); (*cparams.debug_image)(cparams.debug_image_opaque, label, image.xsize(), - image.ysize(), &color, &pixels[0]); + image.ysize(), &color, pixels.data()); + return true; } template -void DumpPlaneNormalizedT(const CompressParams& cparams, const char* label, - const Plane& image) { +Status DumpPlaneNormalizedT(const CompressParams& cparams, const char* label, + const Plane& image) { T min; T max; ImageMinMax(image, &min, &max); - Image3B normalized(image.xsize(), image.ysize()); + JXL_ASSIGN_OR_RETURN(Image3B normalized, + Image3B::Create(image.xsize(), image.ysize())); for (size_t c = 0; c < 3; ++c) { float mul = min == max ? 0 : (255.0f / (max - min)); for (size_t y = 0; y < image.ysize(); ++y) { @@ -75,41 +74,42 @@ void DumpPlaneNormalizedT(const CompressParams& cparams, const char* label, } } } - DumpImageT(cparams, label, ColorEncoding::SRGB(), normalized); + return DumpImageT(cparams, label, ColorEncoding::SRGB(), normalized); } } // namespace -void DumpImage(const CompressParams& cparams, const char* label, - const Image3& image) { - DumpImageT(cparams, label, ColorEncoding::SRGB(), image); +Status DumpImage(const CompressParams& cparams, const char* label, + const Image3& image) { + return DumpImageT(cparams, label, ColorEncoding::SRGB(), image); } -void DumpImage(const CompressParams& cparams, const char* label, - const Image3& image) { - DumpImageT(cparams, label, ColorEncoding::SRGB(), image); +Status DumpImage(const CompressParams& cparams, const char* label, + const Image3& image) { + return DumpImageT(cparams, label, ColorEncoding::SRGB(), image); } -void DumpXybImage(const CompressParams& cparams, const char* label, - const Image3F& image) { - if (!cparams.debug_image) return; +Status DumpXybImage(const CompressParams& cparams, const char* label, + const Image3F& image) { + if (!cparams.debug_image) return true; - Image3F linear(image.xsize(), image.ysize()); + JXL_ASSIGN_OR_RETURN(Image3F linear, + Image3F::Create(image.xsize(), image.ysize())); OpsinParams opsin_params; opsin_params.Init(kDefaultIntensityTarget); OpsinToLinear(image, Rect(linear), nullptr, &linear, opsin_params); - DumpImageT(cparams, label, ColorEncoding::LinearSRGB(), linear); + return DumpImageT(cparams, label, ColorEncoding::LinearSRGB(), linear); } -void DumpPlaneNormalized(const CompressParams& cparams, const char* label, - const Plane& image) { - DumpPlaneNormalizedT(cparams, label, image); +Status DumpPlaneNormalized(const CompressParams& cparams, const char* label, + const Plane& image) { + return DumpPlaneNormalizedT(cparams, label, image); } -void DumpPlaneNormalized(const CompressParams& cparams, const char* label, - const Plane& image) { - DumpPlaneNormalizedT(cparams, label, image); +Status DumpPlaneNormalized(const CompressParams& cparams, const char* label, + const Plane& image) { + return DumpPlaneNormalizedT(cparams, label, image); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_debug_image.h b/third_party/jpeg-xl/lib/jxl/enc_debug_image.h index 33799a5f7f..428293f8bc 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_debug_image.h +++ b/third_party/jpeg-xl/lib/jxl/enc_debug_image.h @@ -16,16 +16,16 @@ namespace jxl { -void DumpImage(const CompressParams& cparams, const char* label, - const Image3& image); -void DumpImage(const CompressParams& cparams, const char* label, - const Image3& image); -void DumpXybImage(const CompressParams& cparams, const char* label, - const Image3& image); -void DumpPlaneNormalized(const CompressParams& cparams, const char* label, - const Plane& image); -void DumpPlaneNormalized(const CompressParams& cparams, const char* label, - const Plane& image); +Status DumpImage(const CompressParams& cparams, const char* label, + const Image3& image); +Status DumpImage(const CompressParams& cparams, const char* label, + const Image3& image); +Status DumpXybImage(const CompressParams& cparams, const char* label, + const Image3& image); +Status DumpPlaneNormalized(const CompressParams& cparams, const char* label, + const Plane& image); +Status DumpPlaneNormalized(const CompressParams& cparams, const char* label, + const Plane& image); // Used to skip image creation if they won't be written to debug directory. static inline bool WantDebugOutput(const CompressParams& cparams) { diff --git a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc index 4ee8808766..94e6fefb61 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.cc @@ -26,7 +26,6 @@ #include "lib/jxl/base/status.h" #include "lib/jxl/convolve.h" #include "lib/jxl/enc_linalg.h" -#include "lib/jxl/enc_optimize.h" #include "lib/jxl/image.h" #include "lib/jxl/image_ops.h" @@ -44,14 +43,16 @@ using hwy::HWY_NAMESPACE::Add; using hwy::HWY_NAMESPACE::Mul; using hwy::HWY_NAMESPACE::Sub; -ImageF SumOfSquareDifferences(const Image3F& forig, const Image3F& smooth, - ThreadPool* pool) { +StatusOr SumOfSquareDifferences(const Image3F& forig, + const Image3F& smooth, + ThreadPool* pool) { const HWY_FULL(float) d; const auto color_coef0 = Set(d, 0.0f); const auto color_coef1 = Set(d, 10.0f); const auto color_coef2 = Set(d, 0.0f); - ImageF sum_of_squares(forig.xsize(), forig.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF sum_of_squares, + ImageF::Create(forig.xsize(), forig.ysize())); JXL_CHECK(RunOnPool( pool, 0, forig.ysize(), ThreadPool::NoInit, [&](const uint32_t task, size_t thread) { @@ -142,11 +143,12 @@ const WeightsSeparable5& WeightsSeparable5Gaussian3() { return weights; } -ImageF ComputeEnergyImage(const Image3F& orig, Image3F* smooth, - ThreadPool* pool) { +StatusOr ComputeEnergyImage(const Image3F& orig, Image3F* smooth, + ThreadPool* pool) { // Prepare guidance images for dot selection. - Image3F forig(orig.xsize(), orig.ysize()); - *smooth = Image3F(orig.xsize(), orig.ysize()); + JXL_ASSIGN_OR_RETURN(Image3F forig, + Image3F::Create(orig.xsize(), orig.ysize())); + JXL_ASSIGN_OR_RETURN(*smooth, Image3F::Create(orig.xsize(), orig.ysize())); Rect rect(orig); const auto& weights1 = WeightsSeparable5Gaussian0_65(); @@ -176,7 +178,7 @@ const size_t kMaxCCSize = 1000; // Extracts a connected component from a Binary image where seed is part // of the component -bool ExtractComponent(ImageF* img, std::vector* pixels, +bool ExtractComponent(const Rect& rect, ImageF* img, std::vector* pixels, const Pixel& seed, double threshold) { static const std::vector neighbors{{1, -1}, {1, 0}, {1, 1}, {0, -1}, {0, 1}, {-1, -1}, {-1, 1}, {1, 0}}; @@ -188,9 +190,9 @@ bool ExtractComponent(ImageF* img, std::vector* pixels, if (pixels->size() > kMaxCCSize) return false; for (const Pixel& delta : neighbors) { Pixel child = current + delta; - if (child.x >= 0 && static_cast(child.x) < img->xsize() && - child.y >= 0 && static_cast(child.y) < img->ysize()) { - float* value = &img->Row(child.y)[child.x]; + if (child.x >= 0 && static_cast(child.x) < rect.xsize() && + child.y >= 0 && static_cast(child.y) < rect.ysize()) { + float* value = &rect.Row(img, child.y)[child.x]; if (*value > threshold) { *value = 0.0; q.push_back(child); @@ -221,7 +223,7 @@ struct ConnectedComponent { float score; Pixel mode; - void CompStats(const ImageF& energy, int extra) { + void CompStats(const ImageF& energy, const Rect& rect, int extra) { maxEnergy = 0.0; meanEnergy = 0.0; varEnergy = 0.0; @@ -234,12 +236,12 @@ struct ConnectedComponent { for (int sy = -extra; sy < (static_cast(bounds.ysize()) + extra); sy++) { int y = sy + static_cast(bounds.y0()); - if (y < 0 || static_cast(y) >= energy.ysize()) continue; - const float* JXL_RESTRICT erow = energy.ConstRow(y); + if (y < 0 || static_cast(y) >= rect.ysize()) continue; + const float* JXL_RESTRICT erow = rect.ConstRow(energy, y); for (int sx = -extra; sx < (static_cast(bounds.xsize()) + extra); sx++) { int x = sx + static_cast(bounds.x0()); - if (x < 0 || static_cast(x) >= energy.xsize()) continue; + if (x < 0 || static_cast(x) >= rect.xsize()) continue; if (erow[x] > maxEnergy) { maxEnergy = erow[x]; mode.x = x; @@ -266,7 +268,10 @@ struct ConnectedComponent { Rect BoundingRectangle(const std::vector& pixels) { JXL_ASSERT(!pixels.empty()); - int low_x, high_x, low_y, high_y; + int low_x; + int high_x; + int low_y; + int high_y; low_x = high_x = pixels[0].x; low_y = high_y = pixels[0].y; for (const Pixel& p : pixels) { @@ -278,22 +283,25 @@ Rect BoundingRectangle(const std::vector& pixels) { return Rect(low_x, low_y, high_x - low_x + 1, high_y - low_y + 1); } -std::vector FindCC(const ImageF& energy, double t_low, - double t_high, uint32_t maxWindow, - double minScore) { +StatusOr> FindCC(const ImageF& energy, + const Rect& rect, double t_low, + double t_high, + uint32_t maxWindow, + double minScore) { const int kExtraRect = 4; - ImageF img(energy.xsize(), energy.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF img, + ImageF::Create(energy.xsize(), energy.ysize())); CopyImageTo(energy, &img); std::vector ans; - for (size_t y = 0; y < img.ysize(); y++) { - float* JXL_RESTRICT row = img.Row(y); - for (size_t x = 0; x < img.xsize(); x++) { + for (size_t y = 0; y < rect.ysize(); y++) { + float* JXL_RESTRICT row = rect.Row(&img, y); + for (size_t x = 0; x < rect.xsize(); x++) { if (row[x] > t_high) { std::vector pixels; row[x] = 0.0; bool success = ExtractComponent( - &img, &pixels, Pixel{static_cast(x), static_cast(y)}, - t_low); + rect, &img, &pixels, + Pixel{static_cast(x), static_cast(y)}, t_low); if (!success) continue; #if JXL_DEBUG_DOT_DETECT for (size_t i = 0; i < pixels.size(); i++) { @@ -304,7 +312,7 @@ std::vector FindCC(const ImageF& energy, double t_low, Rect bounds = BoundingRectangle(pixels); if (bounds.xsize() < maxWindow && bounds.ysize() < maxWindow) { ConnectedComponent cc{bounds, std::move(pixels)}; - cc.CompStats(energy, kExtraRect); + cc.CompStats(energy, rect, kExtraRect); if (cc.score < minScore) continue; JXL_DEBUG(JXL_DEBUG_DOT_DETECT, "cc mode: (%d,%d), max: %f, bgMean: %f bgVar: " @@ -323,12 +331,14 @@ std::vector FindCC(const ImageF& energy, double t_low, // TODO(sggonzalez): Adapt this function for the different color spaces or // remove it if the color space with the best performance does not need it void ComputeDotLosses(GaussianEllipse* ellipse, const ConnectedComponent& cc, - const Image3F& img, const Image3F& background) { + const Rect& rect, const Image3F& img, + const Image3F& background) { const int rectBounds = 2; const double kIntensityR = 0.0; // 0.015; const double kSigmaR = 0.0; // 0.01; const double kZeroEpsilon = 0.1; // Tolerance to consider a value negative - double ct = cos(ellipse->angle), st = sin(ellipse->angle); + double ct = cos(ellipse->angle); + double st = sin(ellipse->angle); const std::array channelGains{{1.0, 1.0, 1.0}}; int N = 0; ellipse->l1_loss = 0.0; @@ -342,15 +352,15 @@ void ComputeDotLosses(GaussianEllipse* ellipse, const ConnectedComponent& cc, for (int sy = -rectBounds; sy < (static_cast(cc.bounds.ysize()) + rectBounds); sy++) { int y = sy + cc.bounds.y0(); - if (y < 0 || static_cast(y) >= img.ysize()) continue; - const float* JXL_RESTRICT row = img.ConstPlaneRow(c, y); + if (y < 0 || static_cast(y) >= rect.ysize()) continue; + const float* JXL_RESTRICT row = rect.ConstPlaneRow(img, c, y); // bgrow is only used if kOptimizeBackground is false. // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) - const float* JXL_RESTRICT bgrow = background.ConstPlaneRow(c, y); + const float* JXL_RESTRICT bgrow = rect.ConstPlaneRow(background, c, y); for (int sx = -rectBounds; sx < (static_cast(cc.bounds.xsize()) + rectBounds); sx++) { int x = sx + cc.bounds.x0(); - if (x < 0 || static_cast(x) >= img.xsize()) continue; + if (x < 0 || static_cast(x) >= rect.xsize()) continue; double target = row[x]; double dotDelta = DotGaussianModel( x - ellipse->x, y - ellipse->y, ct, st, ellipse->sigma_x, @@ -385,9 +395,8 @@ void ComputeDotLosses(GaussianEllipse* ellipse, const ConnectedComponent& cc, ellipse->ridge_loss = ellipse->l2_loss + ridgeTerm; } -GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, - const ImageF& energy, const Image3F& img, - const Image3F& background) { +GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, const Rect& rect, + const Image3F& img, const Image3F& background) { constexpr bool leastSqIntensity = true; constexpr double kEpsilon = 1e-6; GaussianEllipse ans; @@ -405,18 +414,18 @@ GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, "%" PRIuS " %" PRIuS " %" PRIuS " %" PRIuS "\n", cc.bounds.x0(), cc.bounds.y0(), cc.bounds.xsize(), cc.bounds.ysize()); for (int c = 0; c < 3; c++) { - color[c] = img.ConstPlaneRow(c, cc.mode.y)[cc.mode.x] - - background.ConstPlaneRow(c, cc.mode.y)[cc.mode.x]; + color[c] = rect.ConstPlaneRow(img, c, cc.mode.y)[cc.mode.x] - + rect.ConstPlaneRow(background, c, cc.mode.y)[cc.mode.x]; } double sign = (color[1] > 0) ? 1 : -1; for (int sy = -kRectBounds; sy <= kRectBounds; sy++) { int y = sy + cc.mode.y; - if (y < 0 || static_cast(y) >= energy.ysize()) continue; - const float* JXL_RESTRICT row = img.ConstPlaneRow(1, y); - const float* JXL_RESTRICT bgrow = background.ConstPlaneRow(1, y); + if (y < 0 || static_cast(y) >= rect.ysize()) continue; + const float* JXL_RESTRICT row = rect.ConstPlaneRow(img, 1, y); + const float* JXL_RESTRICT bgrow = rect.ConstPlaneRow(background, 1, y); for (int sx = -kRectBounds; sx <= kRectBounds; sx++) { int x = sx + cc.mode.x; - if (x < 0 || static_cast(x) >= energy.xsize()) continue; + if (x < 0 || static_cast(x) >= rect.xsize()) continue; double w = std::max(kEpsilon, sign * (row[x] - bgrow[x])); sum += w; @@ -426,7 +435,7 @@ GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, m2[1] += w * x * y; m2[2] += w * y * y; for (int c = 0; c < 3; c++) { - bgColor[c] += background.ConstPlaneRow(c, y)[x]; + bgColor[c] += rect.ConstPlaneRow(background, c, y)[x]; } N++; } @@ -450,14 +459,16 @@ GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, ans.intensity[j] = kScaleMult[j] * color[j]; } - ImageD Sigma(2, 2), D(1, 2), U(2, 2); - Sigma.Row(0)[0] = m2[0] - m1[0] * m1[0]; - Sigma.Row(1)[1] = m2[2] - m1[1] * m1[1]; - Sigma.Row(0)[1] = Sigma.Row(1)[0] = m2[1] - m1[0] * m1[1]; - ConvertToDiagonal(Sigma, &D, &U); - const double* JXL_RESTRICT d = D.ConstRow(0); - const double* JXL_RESTRICT u = U.ConstRow(1); - int p1 = 0, p2 = 1; + Matrix2x2 Sigma; + Vector2 d; + Matrix2x2 U; + Sigma[0][0] = m2[0] - m1[0] * m1[0]; + Sigma[1][1] = m2[2] - m1[1] * m1[1]; + Sigma[0][1] = Sigma[1][0] = m2[1] - m1[0] * m1[1]; + ConvertToDiagonal(Sigma, d, U); + Vector2& u = U[1]; + int p1 = 0; + int p2 = 1; if (d[0] < d[1]) std::swap(p1, p2); ans.sigma_x = kSigmaMult * d[p1]; ans.sigma_y = kSigmaMult * d[p2]; @@ -466,7 +477,8 @@ GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, ans.bgColor = bgColor; if (leastSqIntensity) { GaussianEllipse* ellipse = &ans; - double ct = cos(ans.angle), st = sin(ans.angle); + double ct = cos(ans.angle); + double st = sin(ans.angle); // Estimate intensity with least squares (fixed background) for (int c = 0; c < 3; c++) { double gg = 0.0; @@ -474,11 +486,11 @@ GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, int yc = static_cast(cc.mode.y); int xc = static_cast(cc.mode.x); for (int y = yc - kRectBounds; y <= yc + kRectBounds; y++) { - if (y < 0 || static_cast(y) >= img.ysize()) continue; - const float* JXL_RESTRICT row = img.ConstPlaneRow(c, y); - const float* JXL_RESTRICT bgrow = background.ConstPlaneRow(c, y); + if (y < 0 || static_cast(y) >= rect.ysize()) continue; + const float* JXL_RESTRICT row = rect.ConstPlaneRow(img, c, y); + const float* JXL_RESTRICT bgrow = rect.ConstPlaneRow(background, c, y); for (int x = xc - kRectBounds; x <= xc + kRectBounds; x++) { - if (x < 0 || static_cast(x) >= img.xsize()) continue; + if (x < 0 || static_cast(x) >= rect.xsize()) continue; double target = row[x] - bgrow[x]; double gaussian = DotGaussianModel(x - ellipse->x, y - ellipse->y, ct, st, @@ -490,13 +502,13 @@ GaussianEllipse FitGaussianFast(const ConnectedComponent& cc, ans.intensity[c] = gd / (gg + 1e-6); // Regularized least squares } } - ComputeDotLosses(&ans, cc, img, background); + ComputeDotLosses(&ans, cc, rect, img, background); return ans; } -GaussianEllipse FitGaussian(const ConnectedComponent& cc, const ImageF& energy, +GaussianEllipse FitGaussian(const ConnectedComponent& cc, const Rect& rect, const Image3F& img, const Image3F& background) { - auto ellipse = FitGaussianFast(cc, energy, img, background); + auto ellipse = FitGaussianFast(cc, rect, img, background); if (ellipse.sigma_x < ellipse.sigma_y) { std::swap(ellipse.sigma_x, ellipse.sigma_y); ellipse.angle += kPi / 2.0; @@ -522,14 +534,16 @@ GaussianEllipse FitGaussian(const ConnectedComponent& cc, const ImageF& energy, } // namespace -std::vector DetectGaussianEllipses( - const Image3F& opsin, const GaussianDetectParams& params, +StatusOr> DetectGaussianEllipses( + const Image3F& opsin, const Rect& rect, const GaussianDetectParams& params, const EllipseQuantParams& qParams, ThreadPool* pool) { std::vector dots; - Image3F smooth(opsin.xsize(), opsin.ysize()); - ImageF energy = ComputeEnergyImage(opsin, &smooth, pool); - std::vector components = FindCC( - energy, params.t_low, params.t_high, params.maxWinSize, params.minScore); + JXL_ASSIGN_OR_RETURN(Image3F smooth, + Image3F::Create(opsin.xsize(), opsin.ysize())); + JXL_ASSIGN_OR_RETURN(ImageF energy, ComputeEnergyImage(opsin, &smooth, pool)); + JXL_ASSIGN_OR_RETURN(std::vector components, + FindCC(energy, rect, params.t_low, params.t_high, + params.maxWinSize, params.minScore)); size_t numCC = std::min(params.maxCC, (components.size() * params.percCC) / 100); if (components.size() > numCC) { @@ -541,11 +555,11 @@ std::vector DetectGaussianEllipses( components.erase(components.begin() + numCC, components.end()); } for (const auto& cc : components) { - GaussianEllipse ellipse = FitGaussian(cc, energy, opsin, smooth); + GaussianEllipse ellipse = FitGaussian(cc, rect, opsin, smooth); if (ellipse.x < 0.0 || - std::ceil(ellipse.x) >= static_cast(opsin.xsize()) || + std::ceil(ellipse.x) >= static_cast(rect.xsize()) || ellipse.y < 0.0 || - std::ceil(ellipse.y) >= static_cast(opsin.ysize())) { + std::ceil(ellipse.y) >= static_cast(rect.ysize())) { continue; } if (ellipse.neg_pixels > params.maxNegPixels) continue; @@ -573,8 +587,8 @@ std::vector DetectGaussianEllipses( for (size_t x = 0; x < patch.xsize; x++) { for (size_t c = 0; c < 3; c++) { patch.fpixels[c][y * patch.xsize + x] = - opsin.ConstPlaneRow(c, y0 + y)[x0 + x] - - smooth.ConstPlaneRow(c, y0 + y)[x0 + x]; + rect.ConstPlaneRow(opsin, c, y0 + y)[x0 + x] - + rect.ConstPlaneRow(smooth, c, y0 + y)[x0 + x]; } } } diff --git a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h index c3071d9a2f..59def59f8f 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h +++ b/third_party/jpeg-xl/lib/jxl/enc_detect_dots.h @@ -14,7 +14,6 @@ #include #include "lib/jxl/base/data_parallel.h" -#include "lib/jxl/dec_patch_dictionary.h" #include "lib/jxl/enc_patch_dictionary.h" #include "lib/jxl/image.h" @@ -58,8 +57,8 @@ struct EllipseQuantParams { }; // Detects dots in XYB image. -std::vector DetectGaussianEllipses( - const Image3F& opsin, const GaussianDetectParams& params, +StatusOr> DetectGaussianEllipses( + const Image3F& opsin, const Rect& rect, const GaussianDetectParams& params, const EllipseQuantParams& qParams, ThreadPool* pool); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc index a5b1af63b2..7d76ba9002 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.cc @@ -9,17 +9,12 @@ #include #include -#include #include "lib/jxl/base/override.h" #include "lib/jxl/base/status.h" #include "lib/jxl/chroma_from_luma.h" -#include "lib/jxl/dec_bit_reader.h" -#include "lib/jxl/dec_xyb.h" -#include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_detect_dots.h" #include "lib/jxl/enc_params.h" -#include "lib/jxl/enc_xyb.h" #include "lib/jxl/image.h" namespace jxl { @@ -39,10 +34,9 @@ const std::array kEllipseMaxIntensity{{0.05, 1.0, 0.4}}; const std::array kEllipseIntensityQ{{10, 36, 10}}; } // namespace -std::vector FindDotDictionary(const CompressParams& cparams, - const Image3F& opsin, - const ColorCorrelationMap& cmap, - ThreadPool* pool) { +StatusOr> FindDotDictionary( + const CompressParams& cparams, const Image3F& opsin, const Rect& rect, + const ColorCorrelationMap& cmap, ThreadPool* pool) { if (ApplyOverride(cparams.dots, cparams.butteraugli_distance >= kMinButteraugliForDots)) { GaussianDetectParams ellipse_params; @@ -58,14 +52,15 @@ std::vector FindDotDictionary(const CompressParams& cparams, ellipse_params.maxCC = 100; ellipse_params.percCC = 100; EllipseQuantParams qParams{ - opsin.xsize(), opsin.ysize(), kEllipsePosQ, + rect.xsize(), rect.ysize(), kEllipsePosQ, kEllipseMinSigma, kEllipseMaxSigma, kEllipseSigmaQ, kEllipseAngleQ, kEllipseMinIntensity, kEllipseMaxIntensity, kEllipseIntensityQ, kEllipsePosQ <= 5, cmap.YtoXRatio(0), cmap.YtoBRatio(0)}; - return DetectGaussianEllipses(opsin, ellipse_params, qParams, pool); + return DetectGaussianEllipses(opsin, rect, ellipse_params, qParams, pool); } - return {}; + std::vector nothing; + return nothing; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h index 2ba4393f30..d348fb73b8 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h +++ b/third_party/jpeg-xl/lib/jxl/enc_dot_dictionary.h @@ -15,19 +15,15 @@ #include "lib/jxl/base/status.h" #include "lib/jxl/chroma_from_luma.h" -#include "lib/jxl/dec_bit_reader.h" -#include "lib/jxl/dec_patch_dictionary.h" -#include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/enc_patch_dictionary.h" #include "lib/jxl/image.h" namespace jxl { -std::vector FindDotDictionary(const CompressParams& cparams, - const Image3F& opsin, - const ColorCorrelationMap& cmap, - ThreadPool* pool); +StatusOr> FindDotDictionary( + const CompressParams& cparams, const Image3F& opsin, const Rect& rect, + const ColorCorrelationMap& cmap, ThreadPool* pool); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc index 07601a2221..b71bb07bc9 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.cc @@ -90,8 +90,8 @@ int32_t NumNonZeroExceptLLF(const size_t cx, const size_t cy, } // We want area - sum_zero, add because neg_sum_zero is already negated. - const int32_t nzeros = - int32_t(cx * cy * kDCTBlockSize) + GetLane(SumOfLanes(di, neg_sum_zero)); + const int32_t nzeros = static_cast(cx * cy * kDCTBlockSize) + + GetLane(SumOfLanes(di, neg_sum_zero)); const int32_t shifted_nzeros = static_cast( (nzeros + covered_blocks - 1) >> log2_covered_blocks); @@ -139,8 +139,8 @@ int32_t NumNonZero8x8ExceptDC(const int32_t* JXL_RESTRICT block, } // We want 64 - sum_zero, add because neg_sum_zero is already negated. - const int32_t nzeros = - int32_t(kDCTBlockSize) + GetLane(SumOfLanes(di, neg_sum_zero)); + const int32_t nzeros = static_cast(kDCTBlockSize) + + GetLane(SumOfLanes(di, neg_sum_zero)); *nzeros_pos = nzeros; @@ -157,7 +157,7 @@ void TokenizeCoefficients(const coeff_order_t* JXL_RESTRICT orders, const Rect& rect, const int32_t* JXL_RESTRICT* JXL_RESTRICT ac_rows, const AcStrategyImage& ac_strategy, - YCbCrChromaSubsampling cs, + const YCbCrChromaSubsampling& cs, Image3I* JXL_RESTRICT tmp_num_nzeroes, std::vector* JXL_RESTRICT output, const ImageB& qdc, const ImageI& qf, @@ -236,7 +236,7 @@ void TokenizeCoefficients(const coeff_order_t* JXL_RESTRICT orders, log2_covered_blocks, prev); uint32_t u_coeff = PackSigned(coeff); output->emplace_back(ctx, u_coeff); - prev = coeff != 0; + prev = (coeff != 0) ? 1 : 0; nzeros -= prev; } JXL_DASSERT(nzeros == 0); @@ -258,14 +258,14 @@ void TokenizeCoefficients(const coeff_order_t* JXL_RESTRICT orders, const Rect& rect, const int32_t* JXL_RESTRICT* JXL_RESTRICT ac_rows, const AcStrategyImage& ac_strategy, - YCbCrChromaSubsampling cs, + const YCbCrChromaSubsampling& cs, Image3I* JXL_RESTRICT tmp_num_nzeroes, std::vector* JXL_RESTRICT output, const ImageB& qdc, const ImageI& qf, const BlockCtxMap& block_ctx_map) { - return HWY_DYNAMIC_DISPATCH(TokenizeCoefficients)( - orders, rect, ac_rows, ac_strategy, cs, tmp_num_nzeroes, output, qdc, qf, - block_ctx_map); + HWY_DYNAMIC_DISPATCH(TokenizeCoefficients) + (orders, rect, ac_rows, ac_strategy, cs, tmp_num_nzeroes, output, qdc, qf, + block_ctx_map); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h index 7dfc71c726..6df3e8e770 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h +++ b/third_party/jpeg-xl/lib/jxl/enc_entropy_coder.h @@ -35,7 +35,7 @@ void TokenizeCoefficients(const coeff_order_t* JXL_RESTRICT orders, const Rect& rect, const int32_t* JXL_RESTRICT* JXL_RESTRICT ac_rows, const AcStrategyImage& ac_strategy, - YCbCrChromaSubsampling cs, + const YCbCrChromaSubsampling& cs, Image3I* JXL_RESTRICT tmp_num_nzeroes, std::vector* JXL_RESTRICT output, const ImageB& qdc, const ImageI& qf, diff --git a/third_party/jpeg-xl/lib/jxl/enc_external_image.cc b/third_party/jpeg-xl/lib/jxl/enc_external_image.cc index 680323e79a..90e4937e7b 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_external_image.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_external_image.cc @@ -8,14 +8,9 @@ #include #include -#include -#include #include -#include #include -#include -#include "lib/jxl/alpha.h" #include "lib/jxl/base/byte_order.h" #include "lib/jxl/base/common.h" #include "lib/jxl/base/float.h" @@ -114,7 +109,7 @@ Status ConvertFromExternalNoSizeCheck(const uint8_t* data, size_t xsize, color_channels, format.num_channels); } - Image3F color(xsize, ysize); + JXL_ASSIGN_OR_RETURN(Image3F color, Image3F::Create(xsize, ysize)); for (size_t c = 0; c < color_channels; ++c) { JXL_RETURN_IF_ERROR(ConvertFromExternalNoSizeCheck( data, xsize, ysize, stride, bits_per_sample, format, c, pool, @@ -129,7 +124,7 @@ Status ConvertFromExternalNoSizeCheck(const uint8_t* data, size_t xsize, // Passing an interleaved image with an alpha channel to an image that doesn't // have alpha channel just discards the passed alpha channel. if (has_alpha && ib->HasAlpha()) { - ImageF alpha(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF alpha, ImageF::Create(xsize, ysize)); JXL_RETURN_IF_ERROR(ConvertFromExternalNoSizeCheck( data, xsize, ysize, stride, bits_per_sample, format, format.num_channels - 1, pool, &alpha)); @@ -137,7 +132,7 @@ Status ConvertFromExternalNoSizeCheck(const uint8_t* data, size_t xsize, } else if (!has_alpha && ib->HasAlpha()) { // if alpha is not passed, but it is expected, then assume // it is all-opaque - ImageF alpha(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF alpha, ImageF::Create(xsize, ysize)); FillImage(1.0f, &alpha); ib->SetAlpha(std::move(alpha)); } @@ -184,7 +179,7 @@ Status ConvertFromExternal(Span bytes, size_t xsize, color_channels, format.num_channels); } - Image3F color(xsize, ysize); + JXL_ASSIGN_OR_RETURN(Image3F color, Image3F::Create(xsize, ysize)); for (size_t c = 0; c < color_channels; ++c) { JXL_RETURN_IF_ERROR(ConvertFromExternal(bytes.data(), bytes.size(), xsize, ysize, bits_per_sample, format, c, @@ -199,7 +194,7 @@ Status ConvertFromExternal(Span bytes, size_t xsize, // Passing an interleaved image with an alpha channel to an image that doesn't // have alpha channel just discards the passed alpha channel. if (has_alpha && ib->HasAlpha()) { - ImageF alpha(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF alpha, ImageF::Create(xsize, ysize)); JXL_RETURN_IF_ERROR(ConvertFromExternal( bytes.data(), bytes.size(), xsize, ysize, bits_per_sample, format, format.num_channels - 1, pool, &alpha)); @@ -207,7 +202,7 @@ Status ConvertFromExternal(Span bytes, size_t xsize, } else if (!has_alpha && ib->HasAlpha()) { // if alpha is not passed, but it is expected, then assume // it is all-opaque - ImageF alpha(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF alpha, ImageF::Create(xsize, ysize)); FillImage(1.0f, &alpha); ib->SetAlpha(std::move(alpha)); } diff --git a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc index b32d2478e0..58d0d00eaa 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc @@ -331,6 +331,8 @@ struct PrefixCode { uint8_t* min_limit, uint8_t* max_limit, uint8_t* nbits) { + assert(precision < 15); + assert(n <= kMaxNumSymbols); std::vector dynp(((1U << precision) + 1) * (n + 1), infty); auto d = [&](size_t sym, size_t off) -> T& { return dynp[sym * ((1 << precision) + 1) + off]; @@ -428,10 +430,11 @@ struct PrefixCode { } // Invalid code, used to construct arrays. - PrefixCode() {} + PrefixCode() = default; template - PrefixCode(BitDepth, uint64_t* raw_counts, uint64_t* lz77_counts) { + PrefixCode(BitDepth /* bitdepth */, uint64_t* raw_counts, + uint64_t* lz77_counts) { // "merge" together all the lz77 counts in a single symbol for the level 1 // table (containing just the raw symbols, up to length 7). uint64_t level1_counts[kNumRawSymbols + 1]; @@ -1317,7 +1320,7 @@ struct Mask32 { SIMDVec32 IfThenElse(const SIMDVec32& if_true, const SIMDVec32& if_false); size_t CountPrefix() const { return CtzNonZero(~static_cast( - (uint8_t)_mm256_movemask_ps(_mm256_castsi256_ps(mask)))); + static_cast(_mm256_movemask_ps(_mm256_castsi256_ps(mask))))); } }; @@ -1414,8 +1417,8 @@ struct Mask16 { return Mask16{_mm256_and_si256(mask, oth.mask)}; } size_t CountPrefix() const { - return CtzNonZero( - ~static_cast((uint32_t)_mm256_movemask_epi8(mask))) / + return CtzNonZero(~static_cast( + static_cast(_mm256_movemask_epi8(mask)))) / 2; } }; @@ -3151,9 +3154,9 @@ void StoreYCoCg(SIMDVec16 r, SIMDVec16 g, SIMDVec16 b, int16_t* y, int16_t* co, SIMDVec16 tmp = b.Add(co_v.SignedShiftRight<1>()); SIMDVec16 cg_v = g.Sub(tmp); SIMDVec16 y_v = tmp.Add(cg_v.SignedShiftRight<1>()); - y_v.Store((uint16_t*)y); - co_v.Store((uint16_t*)co); - cg_v.Store((uint16_t*)cg); + y_v.Store(reinterpret_cast(y)); + co_v.Store(reinterpret_cast(co)); + cg_v.Store(reinterpret_cast(cg)); } void StoreYCoCg(SIMDVec16 r, SIMDVec16 g, SIMDVec16 b, int32_t* y, int32_t* co, @@ -3169,12 +3172,12 @@ void StoreYCoCg(SIMDVec16 r, SIMDVec16 g, SIMDVec16 b, int32_t* y, int32_t* co, SIMDVec32 tmp_hi = b_up.hi.Add(co_hi_v.SignedShiftRight<1>()); SIMDVec32 cg_hi_v = g_up.hi.Sub(tmp_hi); SIMDVec32 y_hi_v = tmp_hi.Add(cg_hi_v.SignedShiftRight<1>()); - y_lo_v.Store((uint32_t*)y); - co_lo_v.Store((uint32_t*)co); - cg_lo_v.Store((uint32_t*)cg); - y_hi_v.Store((uint32_t*)y + SIMDVec32::kLanes); - co_hi_v.Store((uint32_t*)co + SIMDVec32::kLanes); - cg_hi_v.Store((uint32_t*)cg + SIMDVec32::kLanes); + y_lo_v.Store(reinterpret_cast(y)); + co_lo_v.Store(reinterpret_cast(co)); + cg_lo_v.Store(reinterpret_cast(cg)); + y_hi_v.Store(reinterpret_cast(y) + SIMDVec32::kLanes); + co_hi_v.Store(reinterpret_cast(co) + SIMDVec32::kLanes); + cg_hi_v.Store(reinterpret_cast(cg) + SIMDVec32::kLanes); } #endif @@ -3573,8 +3576,7 @@ void PrepareDCGlobalPalette(bool is_single_group, size_t width, size_t height, int16_t p[4][32 + 1024] = {}; uint8_t prgba[4]; size_t i = 0; - size_t have_zero = 0; - if (palette[pcolors - 1] == 0) have_zero = 1; + size_t have_zero = 1; for (; i < pcolors; i++) { memcpy(prgba, &palette[i], 4); p[0][16 + i + have_zero] = prgba[0]; @@ -3735,10 +3737,13 @@ JxlFastLosslessFrameState* LLPrepare(JxlChunkedFrameInputSource input, const void* buffer = input.get_color_channel_data_at(input.opaque, x0, y0, xs, ys, &stride); auto rgba = reinterpret_cast(buffer); - int y_begin = std::max(0, ys - 2 * effort) / 2; - int y_count = std::min(num_rows, y0 + ys - y_begin - 1); + int y_begin_group = + std::max( + 0, static_cast(ys) - static_cast(num_rows)) / + 2; + int y_count = std::min(num_rows, ys - y_begin_group); int x_max = xs / kChunkSize * kChunkSize; - CollectSamples(rgba, 0, y_begin, x_max, stride, y_count, raw_counts, + CollectSamples(rgba, 0, y_begin_group, x_max, stride, y_count, raw_counts, lz77_counts, onegroup, !collided, bitdepth, nb_chans, big_endian, lookup.data()); input.release_buffer(input.opaque, buffer); @@ -4020,7 +4025,7 @@ namespace default_implementation { #else // FJXL_ENABLE_NEON namespace default_implementation { -#include "lib/jxl/enc_fast_lossless.cc" +#include "lib/jxl/enc_fast_lossless.cc" // NOLINT } #if FJXL_ENABLE_AVX2 @@ -4039,7 +4044,7 @@ namespace default_implementation { namespace AVX2 { #define FJXL_AVX2 -#include "lib/jxl/enc_fast_lossless.cc" +#include "lib/jxl/enc_fast_lossless.cc" // NOLINT #undef FJXL_AVX2 } // namespace AVX2 @@ -4174,18 +4179,20 @@ void JxlFastLosslessProcessFrame( __builtin_cpu_supports("avx512vbmi") && __builtin_cpu_supports("avx512bw") && __builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512vl")) { - return AVX512::JxlFastLosslessProcessFrameImpl( - frame_state, is_last, runner_opaque, runner, output_processor); + AVX512::JxlFastLosslessProcessFrameImpl(frame_state, is_last, runner_opaque, + runner, output_processor); + return; } #endif #if FJXL_ENABLE_AVX2 if (__builtin_cpu_supports("avx2")) { - return AVX2::JxlFastLosslessProcessFrameImpl( - frame_state, is_last, runner_opaque, runner, output_processor); + AVX2::JxlFastLosslessProcessFrameImpl(frame_state, is_last, runner_opaque, + runner, output_processor); + return; } #endif - return default_implementation::JxlFastLosslessProcessFrameImpl( + default_implementation::JxlFastLosslessProcessFrameImpl( frame_state, is_last, runner_opaque, runner, output_processor); } diff --git a/third_party/jpeg-xl/lib/jxl/enc_fields.cc b/third_party/jpeg-xl/lib/jxl/enc_fields.cc index dc0cbb7913..fa513297fd 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_fields.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_fields.cc @@ -74,7 +74,8 @@ class WriteVisitor : public VisitorBase { Status Bundle::Write(const Fields& fields, BitWriter* writer, size_t layer, AuxOut* aux_out) { - size_t extension_bits, total_bits; + size_t extension_bits; + size_t total_bits; JXL_RETURN_IF_ERROR(Bundle::CanEncode(fields, &extension_bits, &total_bits)); BitWriter::Allotment allotment(writer, total_bits); @@ -173,7 +174,8 @@ Status F16Coder::Write(float value, BitWriter* JXL_RESTRICT writer) { return true; } - uint32_t biased_exp16, mantissa16; + uint32_t biased_exp16; + uint32_t mantissa16; // exp = [-24, -15] => subnormal if (JXL_UNLIKELY(exp < -14)) { diff --git a/third_party/jpeg-xl/lib/jxl/enc_frame.cc b/third_party/jpeg-xl/lib/jxl/enc_frame.cc index aae59c49a6..8587e1aed2 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_frame.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_frame.cc @@ -12,13 +12,13 @@ #include #include #include -#include +#include #include +#include #include #include "lib/jxl/ac_context.h" #include "lib/jxl/ac_strategy.h" -#include "lib/jxl/ans_params.h" #include "lib/jxl/base/bits.h" #include "lib/jxl/base/common.h" #include "lib/jxl/base/compiler_specific.h" @@ -31,7 +31,6 @@ #include "lib/jxl/coeff_order_fwd.h" #include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/common.h" // kMaxNumPasses -#include "lib/jxl/compressed_dc.h" #include "lib/jxl/dct_util.h" #include "lib/jxl/dec_external_image.h" #include "lib/jxl/enc_ac_strategy.h" @@ -47,7 +46,6 @@ #include "lib/jxl/enc_entropy_coder.h" #include "lib/jxl/enc_external_image.h" #include "lib/jxl/enc_fields.h" -#include "lib/jxl/enc_gaborish.h" #include "lib/jxl/enc_group.h" #include "lib/jxl/enc_heuristics.h" #include "lib/jxl/enc_modular.h" @@ -285,7 +283,8 @@ Status LoopFilterFromParams(const CompressParams& cparams, bool streaming_mode, if (frame_header->encoding == FrameEncoding::kModular && !cparams.IsLossless()) { // TODO(veluca): this formula is nonsense. - loop_filter->epf_sigma_for_modular = cparams.butteraugli_distance; + loop_filter->epf_sigma_for_modular = + std::max(cparams.butteraugli_distance, 1.0f); } if (frame_header->encoding == FrameEncoding::kModular && cparams.lossy_palette) { @@ -539,7 +538,7 @@ struct PixelStatsForChromacityAdjustment { float dx = 0; float db = 0; float exposed_blue = 0; - float CalcPlane(const ImageF* JXL_RESTRICT plane, const Rect& rect) const { + static float CalcPlane(const ImageF* JXL_RESTRICT plane, const Rect& rect) { float xmax = 0; float ymax = 0; for (size_t ty = 1; ty < rect.ysize(); ++ty) { @@ -583,7 +582,7 @@ struct PixelStatsForChromacityAdjustment { dx = CalcPlane(&opsin->Plane(0), rect); CalcExposedBlue(&opsin->Plane(1), &opsin->Plane(2), rect); } - int HowMuchIsXChannelPixelized() { + int HowMuchIsXChannelPixelized() const { if (dx >= 0.03) { return 2; } @@ -592,7 +591,7 @@ struct PixelStatsForChromacityAdjustment { } return 0; } - int HowMuchIsBChannelPixelized() { + int HowMuchIsBChannelPixelized() const { int add = exposed_blue >= 0.13 ? 1 : 0; if (db > 0.38) { return 2 + add; @@ -682,12 +681,12 @@ void ComputeNoiseParams(const CompressParams& cparams, bool streaming_mode, } } -void DownsampleColorChannels(const CompressParams& cparams, - const FrameHeader& frame_header, - bool color_is_jpeg, Image3F* opsin) { +Status DownsampleColorChannels(const CompressParams& cparams, + const FrameHeader& frame_header, + bool color_is_jpeg, Image3F* opsin) { if (color_is_jpeg || frame_header.upsampling == 1 || cparams.already_downsampled) { - return; + return true; } if (frame_header.encoding == FrameEncoding::kVarDCT && frame_header.upsampling == 2) { @@ -698,16 +697,18 @@ void DownsampleColorChannels(const CompressParams& cparams, // TODO(lode): DownsampleImage2_Iterative is currently too slow to // be used for squirrel, make it faster, and / or enable it only for // kitten. - DownsampleImage2_Iterative(opsin); + JXL_RETURN_IF_ERROR(DownsampleImage2_Iterative(opsin)); } else { - DownsampleImage2_Sharper(opsin); + JXL_RETURN_IF_ERROR(DownsampleImage2_Sharper(opsin)); } } else { - DownsampleImage(opsin, frame_header.upsampling); + JXL_ASSIGN_OR_RETURN(*opsin, + DownsampleImage(*opsin, frame_header.upsampling)); } if (frame_header.encoding == FrameEncoding::kVarDCT) { PadImageToBlockMultipleInPlace(opsin); } + return true; } template @@ -741,14 +742,17 @@ Status ComputeJPEGTranscodingData(const jpeg::JPEGData& jpeg_data, const size_t ysize_blocks = frame_dim.ysize_blocks; // no-op chroma from luma - shared.cmap = ColorCorrelationMap(xsize, ysize, false); + JXL_ASSIGN_OR_RETURN(shared.cmap, + ColorCorrelationMap::Create(xsize, ysize, false)); shared.ac_strategy.FillDCT8(); - FillImage(uint8_t(0), &shared.epf_sharpness); + FillImage(static_cast(0), &shared.epf_sharpness); enc_state->coeffs.clear(); while (enc_state->coeffs.size() < enc_state->passes.size()) { - enc_state->coeffs.emplace_back(make_unique>( - kGroupDim * kGroupDim, frame_dim.num_groups)); + JXL_ASSIGN_OR_RETURN( + std::unique_ptr> coeffs, + ACImageT::Make(kGroupDim * kGroupDim, frame_dim.num_groups)); + enc_state->coeffs.emplace_back(std::move(coeffs)); } // convert JPEG quantization table to a Quantizer object @@ -779,7 +783,8 @@ Status ComputeJPEGTranscodingData(const jpeg::JPEGData& jpeg_data, 1.0f / dcquantization[2]}; qe[AcStrategy::Type::DCT] = QuantEncoding::RAW(qt); - DequantMatricesSetCustom(&shared.matrices, qe, enc_modular); + JXL_RETURN_IF_ERROR( + DequantMatricesSetCustom(&shared.matrices, qe, enc_modular)); // Ensure that InvGlobalScale() is 1. shared.quantizer = Quantizer(&shared.matrices, 1, kGlobalScaleDenom); @@ -844,7 +849,8 @@ Status ComputeJPEGTranscodingData(const jpeg::JPEGData& jpeg_data, kScale * row_s[x * kDCTBlockSize + coeffpos] + (kOffset - kBase * kScale) * scaled_m; if (std::abs(scaled_m) > 1e-8f) { - float from, to; + float from; + float to; if (scaled_m > 0) { from = (scaled_s - kZeroThresh) / scaled_m; to = (scaled_s + kZeroThresh) / scaled_m; @@ -889,7 +895,7 @@ Status ComputeJPEGTranscodingData(const jpeg::JPEGData& jpeg_data, } } - Image3F dc = Image3F(xsize_blocks, ysize_blocks); + JXL_ASSIGN_OR_RETURN(Image3F dc, Image3F::Create(xsize_blocks, ysize_blocks)); if (!frame_header.chroma_subsampling.Is444()) { ZeroFillImage(&dc); for (auto& coeff : enc_state->coeffs) { @@ -944,7 +950,7 @@ Status ComputeJPEGTranscodingData(const jpeg::JPEGData& jpeg_data, idc = inputjpeg[base] + 1024 / qt[c * 64]; } dc_counts[c][std::min(static_cast(idc + 1024), - uint32_t(2047))]++; + static_cast(2047))]++; total_dc[c]++; fdc[bx >> hshift] = idc * dcquantization_r[c]; if (c == 1 || !enc_state->cparams.force_cfl_jpeg_recompression || @@ -1024,18 +1030,27 @@ Status ComputeJPEGTranscodingData(const jpeg::JPEGData& jpeg_data, *std::max_element(ctx_map.begin(), ctx_map.end()) + 1; // disable DC frame for now + std::atomic has_error{false}; auto compute_dc_coeffs = [&](const uint32_t group_index, size_t /* thread */) { + if (has_error) return; const Rect r = enc_state->shared.frame_dim.DCGroupRect(group_index); - enc_modular->AddVarDCTDC(frame_header, dc, r, group_index, - /*nl_dc=*/false, enc_state, - /*jpeg_transcode=*/true); - enc_modular->AddACMetadata(r, group_index, /*jpeg_transcode=*/true, - enc_state); + if (!enc_modular->AddVarDCTDC(frame_header, dc, r, group_index, + /*nl_dc=*/false, enc_state, + /*jpeg_transcode=*/true)) { + has_error = true; + return; + } + if (!enc_modular->AddACMetadata(r, group_index, /*jpeg_transcode=*/true, + enc_state)) { + has_error = true; + return; + } }; JXL_RETURN_IF_ERROR(RunOnPool(pool, 0, shared.frame_dim.num_dc_groups, ThreadPool::NoInit, compute_dc_coeffs, "Compute DC coeffs")); + if (has_error) return JXL_FAILURE("Compute DC coeffs failed"); return true; } @@ -1077,10 +1092,12 @@ void ComputeAllCoeffOrders(PassesEncoderState& enc_state, // Working area for TokenizeCoefficients (per-group!) struct EncCache { // Allocates memory when first called. - void InitOnce() { + Status InitOnce() { if (num_nzeroes.xsize() == 0) { - num_nzeroes = Image3I(kGroupDimInBlocks, kGroupDimInBlocks); + JXL_ASSIGN_OR_RETURN( + num_nzeroes, Image3I::Create(kGroupDimInBlocks, kGroupDimInBlocks)); } + return true; } // TokenizeCoefficients Image3I num_nzeroes; @@ -1095,8 +1112,10 @@ Status TokenizeAllCoefficients(const FrameHeader& frame_header, group_caches.resize(num_threads); return true; }; + std::atomic has_error{false}; const auto tokenize_group = [&](const uint32_t group_index, const size_t thread) { + if (has_error) return; // Tokenize coefficients. const Rect rect = shared.frame_dim.BlockGroupRect(group_index); for (size_t idx_pass = 0; idx_pass < enc_state->passes.size(); idx_pass++) { @@ -1107,7 +1126,10 @@ Status TokenizeAllCoefficients(const FrameHeader& frame_header, enc_state->coeffs[idx_pass]->PlaneRow(2, group_index, 0).ptr32, }; // Ensure group cache is initialized. - group_caches[thread].InitOnce(); + if (!group_caches[thread].InitOnce()) { + has_error = true; + return; + } TokenizeCoefficients( &shared.coeff_orders[idx_pass * shared.coeff_order_size], rect, ac_rows, shared.ac_strategy, frame_header.chroma_subsampling, @@ -1116,8 +1138,11 @@ Status TokenizeAllCoefficients(const FrameHeader& frame_header, shared.raw_quant_field, shared.block_ctx_map); } }; - return RunOnPool(pool, 0, shared.frame_dim.num_groups, tokenize_group_init, - tokenize_group, "TokenizeGroup"); + JXL_RETURN_IF_ERROR(RunOnPool(pool, 0, shared.frame_dim.num_groups, + tokenize_group_init, tokenize_group, + "TokenizeGroup")); + if (has_error) return JXL_FAILURE("TokenizeGroup failed"); + return true; } Status EncodeGlobalDCInfo(const PassesSharedState& shared, BitWriter* writer, @@ -1208,10 +1233,13 @@ Status EncodeGroups(const FrameHeader& frame_header, const size_t num_groups = frame_dim.num_groups; const size_t num_passes = enc_state->progressive_splitter.GetNumPasses(); const size_t global_ac_index = frame_dim.num_dc_groups + 1; - const bool is_small_image = frame_dim.num_groups == 1 && num_passes == 1; - - group_codes->resize( - NumTocEntries(num_groups, frame_dim.num_dc_groups, num_passes)); + const bool is_small_image = + !enc_state->streaming_mode && num_groups == 1 && num_passes == 1; + const size_t num_toc_entries = + is_small_image ? 1 + : AcGroupIndex(0, 0, num_groups, frame_dim.num_dc_groups) + + num_groups * num_passes; + group_codes->resize(num_toc_entries); const auto get_output = [&](const size_t index) { return &(*group_codes)[is_small_image ? 0 : index]; @@ -1308,35 +1336,48 @@ Status EncodeGroups(const FrameHeader& frame_header, enc_state, get_output(global_ac_index), enc_modular, aux_out)); } - std::atomic num_errors{0}; + std::atomic has_error{false}; const auto process_group = [&](const uint32_t group_index, const size_t thread) { + if (has_error) return; AuxOut* my_aux_out = aux_outs[thread].get(); + size_t ac_group_id = + enc_state->streaming_mode + ? enc_modular->ComputeStreamingAbsoluteAcGroupId( + enc_state->dc_group_index, group_index, shared.frame_dim) + : group_index; + for (size_t i = 0; i < num_passes; i++) { + JXL_DEBUG_V(2, "Encoding AC group %u [abs %" PRIuS "] pass %" PRIuS, + group_index, ac_group_id, i); if (frame_header.encoding == FrameEncoding::kVarDCT) { if (!EncodeGroupTokenizedCoefficients( group_index, i, enc_state->histogram_idx[group_index], *enc_state, ac_group_code(i, group_index), my_aux_out)) { - num_errors.fetch_add(1, std::memory_order_relaxed); + has_error = true; return; } } // Write all modular encoded data (color?, alpha, depth, extra channels) if (!enc_modular->EncodeStream( ac_group_code(i, group_index), my_aux_out, kLayerModularAcGroup, - ModularStreamId::ModularAC(group_index, i))) { - num_errors.fetch_add(1, std::memory_order_relaxed); + ModularStreamId::ModularAC(ac_group_id, i))) { + has_error = true; return; } + JXL_DEBUG_V(2, + "AC group %u [abs %" PRIuS "] pass %" PRIuS + " encoded size is %" PRIuS " bits", + group_index, ac_group_id, i, + ac_group_code(i, group_index)->BitsWritten()); } }; JXL_RETURN_IF_ERROR(RunOnPool(pool, 0, num_groups, resize_aux_outs, process_group, "EncodeGroupCoefficients")); - + if (has_error) return JXL_FAILURE("EncodeGroupCoefficients failed"); // Resizing aux_outs to 0 also Assimilates the array. static_cast(resize_aux_outs(0)); - JXL_RETURN_IF_ERROR(num_errors.load(std::memory_order_relaxed) == 0); for (BitWriter& bw : *group_codes) { BitWriter::Allotment allotment(&bw, 8); @@ -1360,29 +1401,39 @@ Status ComputeEncodingData( PassesSharedState& shared = enc_state.shared; shared.metadata = metadata; if (enc_state.streaming_mode) { - shared.frame_dim.Set(xsize, ysize, /*group_size_shift=*/1, - /*maxhshift=*/0, /*maxvshift=*/0, - /*modular_mode=*/false, /*upsampling=*/1); + shared.frame_dim.Set( + xsize, ysize, frame_header.group_size_shift, + /*max_hshift=*/0, /*max_vshift=*/0, + mutable_frame_header.encoding == FrameEncoding::kModular, + /*upsampling=*/1); } else { shared.frame_dim = frame_header.ToFrameDimensions(); } shared.image_features.patches.SetPassesSharedState(&shared); const FrameDimensions& frame_dim = shared.frame_dim; - shared.ac_strategy = - AcStrategyImage(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - shared.raw_quant_field = - ImageI(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - shared.epf_sharpness = ImageB(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - shared.cmap = ColorCorrelationMap(frame_dim.xsize, frame_dim.ysize); + JXL_ASSIGN_OR_RETURN( + shared.ac_strategy, + AcStrategyImage::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN( + shared.raw_quant_field, + ImageI::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN( + shared.epf_sharpness, + ImageB::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN(shared.cmap, ColorCorrelationMap::Create( + frame_dim.xsize, frame_dim.ysize)); shared.coeff_order_size = kCoeffOrderMaxSize; if (frame_header.encoding == FrameEncoding::kVarDCT) { shared.coeff_orders.resize(frame_header.passes.num_passes * kCoeffOrderMaxSize); } - shared.quant_dc = ImageB(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - shared.dc_storage = Image3F(frame_dim.xsize_blocks, frame_dim.ysize_blocks); + JXL_ASSIGN_OR_RETURN(shared.quant_dc, ImageB::Create(frame_dim.xsize_blocks, + frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN( + shared.dc_storage, + Image3F::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); shared.dc = &shared.dc_storage; const size_t num_extra_channels = metadata->m.num_extra_channels; @@ -1397,16 +1448,19 @@ Status ComputeEncodingData( // computing inverse Gaborish and adaptive quantization map. int max_border = enc_state.streaming_mode ? kBlockDim : 0; Rect frame_rect(0, 0, frame_data.xsize, frame_data.ysize); - Rect patch_rect = Rect(x0, y0, xsize, ysize).Extend(max_border, frame_rect); + Rect frame_area_rect = Rect(x0, y0, xsize, ysize); + Rect patch_rect = frame_area_rect.Extend(max_border, frame_rect); JXL_ASSERT(patch_rect.IsInside(frame_rect)); // Allocating a large enough image avoids a copy when padding. - Image3F color(RoundUpToBlockDim(patch_rect.xsize()), - RoundUpToBlockDim(patch_rect.ysize())); + JXL_ASSIGN_OR_RETURN(Image3F color, + Image3F::Create(RoundUpToBlockDim(patch_rect.xsize()), + RoundUpToBlockDim(patch_rect.ysize()))); color.ShrinkTo(patch_rect.xsize(), patch_rect.ysize()); std::vector extra_channels(num_extra_channels); for (auto& extra_channel : extra_channels) { - extra_channel = jxl::ImageF(patch_rect.xsize(), patch_rect.ysize()); + JXL_ASSIGN_OR_RETURN( + extra_channel, ImageF::Create(patch_rect.xsize(), patch_rect.ysize())); } ImageF* alpha = alpha_eci ? &extra_channels[alpha_idx] : nullptr; ImageF* black = black_eci ? &extra_channels[black_idx] : nullptr; @@ -1432,7 +1486,9 @@ Status ComputeEncodingData( frame_info.ib_needs_color_transform) { if (frame_header.encoding == FrameEncoding::kVarDCT && cparams.speed_tier <= SpeedTier::kKitten) { - linear_storage = Image3F(patch_rect.xsize(), patch_rect.ysize()); + JXL_ASSIGN_OR_RETURN( + linear_storage, + Image3F::Create(patch_rect.xsize(), patch_rect.ysize())); linear = &linear_storage; } ToXYB(c_enc, metadata->m.IntensityTarget(), black, pool, &color, cms, @@ -1446,7 +1502,7 @@ Status ComputeEncodingData( bool lossless = cparams.IsLossless(); if (alpha && !alpha_eci->alpha_associated && frame_header.frame_type == FrameType::kRegularFrame && - !ApplyOverride(cparams.keep_invisible, lossless) && + !ApplyOverride(cparams.keep_invisible, true) && cparams.ec_resampling == cparams.resampling) { // simplify invisible pixels SimplifyInvisible(&color, *alpha, lossless); @@ -1467,15 +1523,17 @@ Status ComputeEncodingData( &mutable_frame_header); } - ComputeNoiseParams(cparams, enc_state.streaming_mode, !!jpeg_data, color, + bool has_jpeg_data = (jpeg_data != nullptr); + ComputeNoiseParams(cparams, enc_state.streaming_mode, has_jpeg_data, color, frame_dim, &mutable_frame_header, &shared.image_features.noise_params); - DownsampleColorChannels(cparams, frame_header, !!jpeg_data, &color); + JXL_RETURN_IF_ERROR( + DownsampleColorChannels(cparams, frame_header, has_jpeg_data, &color)); if (cparams.ec_resampling != 1 && !cparams.already_downsampled) { for (ImageF& ec : extra_channels) { - DownsampleImage(&ec, cparams.ec_resampling); + JXL_ASSIGN_OR_RETURN(ec, DownsampleImage(ec, cparams.ec_resampling)); } } @@ -1505,15 +1563,21 @@ Status ComputeEncodingData( TokenizeAllCoefficients(frame_header, pool, &enc_state)); } + if (cparams.modular_mode || !extra_channels.empty()) { + JXL_RETURN_IF_ERROR(enc_modular.ComputeEncodingData( + frame_header, metadata->m, &color, extra_channels, group_rect, + frame_dim, frame_area_rect, &enc_state, cms, pool, aux_out, + /*do_color=*/cparams.modular_mode)); + } + if (!enc_state.streaming_mode) { - if (cparams.modular_mode || !extra_channels.empty()) { - JXL_RETURN_IF_ERROR(enc_modular.ComputeEncodingData( - frame_header, metadata->m, &color, extra_channels, &enc_state, cms, - pool, aux_out, /*do_color=*/cparams.modular_mode)); + if (cparams.speed_tier < SpeedTier::kTortoise || + !cparams.ModularPartIsLossless() || cparams.responsive || + !cparams.custom_fixed_tree.empty()) { + // Use local trees if doing lossless modular, unless at very slow speeds. + JXL_RETURN_IF_ERROR(enc_modular.ComputeTree(pool)); + JXL_RETURN_IF_ERROR(enc_modular.ComputeTokens(pool)); } - JXL_RETURN_IF_ERROR(enc_modular.ComputeTree(pool)); - JXL_RETURN_IF_ERROR(enc_modular.ComputeTokens(pool)); - mutable_frame_header.UpdateFlag(shared.image_features.patches.HasAny(), FrameHeader::kPatches); mutable_frame_header.UpdateFlag(shared.image_features.splines.HasAny(), @@ -1526,6 +1590,7 @@ Status ComputeEncodingData( const size_t group_index = enc_state.dc_group_index; enc_modular.ClearStreamData(ModularStreamId::VarDCTDC(group_index)); enc_modular.ClearStreamData(ModularStreamId::ACMetadata(group_index)); + enc_modular.ClearModularStreamData(); } return true; } @@ -1614,49 +1679,58 @@ bool CanDoStreamingEncoding(const CompressParams& cparams, const FrameInfo& frame_info, const CodecMetadata& metadata, const JxlEncoderChunkedFrameAdapter& frame_data) { - if (frame_data.IsJPEG()) { - return false; - } - if (cparams.noise == Override::kOn || cparams.patches == Override::kOn) { + if (cparams.buffering == 0) { return false; } - if (cparams.progressive_dc != 0 || frame_info.dc_level != 0) { - return false; + if (cparams.buffering == -1) { + if (cparams.speed_tier < SpeedTier::kTortoise) return false; + if (cparams.speed_tier < SpeedTier::kSquirrel && + cparams.butteraugli_distance > 0.5f) { + return false; + } + if (cparams.speed_tier == SpeedTier::kSquirrel && + cparams.butteraugli_distance >= 3.f) { + return false; + } } - if (cparams.resampling != 1 || cparams.ec_resampling != 1) { + + // TODO(veluca): handle different values of `buffering`. + if (frame_data.xsize <= 2048 && frame_data.ysize <= 2048) { return false; } - if (cparams.max_error_mode) { + if (frame_data.IsJPEG()) { return false; } - if (cparams.color_transform != ColorTransform::kXYB) { + if (cparams.noise == Override::kOn || cparams.patches == Override::kOn) { return false; } - if (cparams.modular_mode) { + if (cparams.progressive_dc != 0 || frame_info.dc_level != 0) { return false; } - if (metadata.m.num_extra_channels > 0) { + if (cparams.resampling != 1 || cparams.ec_resampling != 1) { return false; } - if (cparams.buffering == 0) { + if (cparams.max_error_mode) { return false; } - if (cparams.buffering == 1 && frame_data.xsize <= 2048 && - frame_data.ysize <= 2048) { - return false; + if (!cparams.ModularPartIsLossless() || cparams.responsive > 0) { + if (metadata.m.num_extra_channels > 0 || cparams.modular_mode) { + return false; + } } - if (frame_data.xsize <= 256 && frame_data.ysize <= 256) { + ColorTransform ok_color_transform = + cparams.modular_mode ? ColorTransform::kNone : ColorTransform::kXYB; + if (cparams.color_transform != ok_color_transform) { return false; } return true; } void ComputePermutationForStreaming(size_t xsize, size_t ysize, - size_t num_passes, + size_t group_size, size_t num_passes, std::vector& permutation, std::vector& dc_group_order) { // This is only valid in VarDCT mode, otherwise there can be group shift. - const size_t group_size = 256; const size_t dc_group_size = group_size * kBlockDim; const size_t group_xsize = DivCeil(xsize, group_size); const size_t group_ysize = DivCeil(ysize, group_size); @@ -1794,7 +1868,7 @@ void RemoveUnusedHistograms(std::vector& context_map, for (uint8_t histo_idx : inv_remap) { new_codes.encoding_info.emplace_back( std::move(codes.encoding_info[histo_idx])); - new_codes.uint_config.emplace_back(std::move(codes.uint_config[histo_idx])); + new_codes.uint_config.emplace_back(codes.uint_config[histo_idx]); new_codes.encoded_histograms.emplace_back( std::move(codes.encoded_histograms[histo_idx])); } @@ -1864,14 +1938,13 @@ Status EncodeFrameStreaming(const CompressParams& cparams, frame_info, jpeg_data.get(), true, &frame_header)); const size_t num_passes = enc_state.progressive_splitter.GetNumPasses(); - ModularFrameEncoder enc_modular(frame_header, cparams); + ModularFrameEncoder enc_modular(frame_header, cparams, true); std::vector permutation; std::vector dc_group_order; - ComputePermutationForStreaming(frame_data.xsize, frame_data.ysize, num_passes, - permutation, dc_group_order); + size_t group_size = frame_header.ToFrameDimensions().group_dim; + ComputePermutationForStreaming(frame_data.xsize, frame_data.ysize, group_size, + num_passes, permutation, dc_group_order); enc_state.shared.num_histograms = dc_group_order.size(); - // This is only valid in VarDCT mode, otherwise there can be group shift. - size_t group_size = 256; size_t dc_group_size = group_size * kBlockDim; size_t dc_group_xsize = DivCeil(frame_data.xsize, dc_group_size); size_t min_dc_global_size = 0; @@ -1898,8 +1971,7 @@ Status EncodeFrameStreaming(const CompressParams& cparams, enc_state.streaming_mode = true; enc_state.initialize_global_state = (i == 0); enc_state.dc_group_index = dc_ix; - enc_state.histogram_idx = - std::vector(group_xsize * group_ysize, i); + enc_state.histogram_idx = std::vector(group_xsize * group_ysize, i); std::vector group_codes; JXL_RETURN_IF_ERROR(ComputeEncodingData( cparams, frame_info, metadata, frame_data, jpeg_data.get(), x0, y0, @@ -1931,9 +2003,13 @@ Status EncodeFrameStreaming(const CompressParams& cparams, JXL_RETURN_IF_ERROR( OutputGroups(std::move(group_codes), &group_sizes, output_processor)); } - JXL_RETURN_IF_ERROR(OutputAcGlobal(enc_state, - frame_header.ToFrameDimensions(), - &group_sizes, output_processor, aux_out)); + if (frame_header.encoding == FrameEncoding::kVarDCT) { + JXL_RETURN_IF_ERROR( + OutputAcGlobal(enc_state, frame_header.ToFrameDimensions(), + &group_sizes, output_processor, aux_out)); + } else { + group_sizes.push_back(0); + } JXL_ASSERT(group_sizes.size() == permutation.size()); size_t end_pos = output_processor->CurrentPosition(); output_processor->Seek(start_pos); @@ -1975,7 +2051,7 @@ Status EncodeFrameOneShot(const CompressParams& cparams, frame_info, jpeg_data.get(), false, &frame_header)); const size_t num_passes = enc_state.progressive_splitter.GetNumPasses(); - ModularFrameEncoder enc_modular(frame_header, cparams); + ModularFrameEncoder enc_modular(frame_header, cparams, false); JXL_RETURN_IF_ERROR(ComputeEncodingData( cparams, frame_info, metadata, frame_data, jpeg_data.get(), 0, 0, frame_data.xsize, frame_data.ysize, cms, pool, frame_header, enc_modular, @@ -2008,15 +2084,21 @@ Status EncodeFrame(const CompressParams& cparams_orig, JxlEncoderOutputProcessorWrapper* output_processor, AuxOut* aux_out) { CompressParams cparams = cparams_orig; - if (cparams.speed_tier == SpeedTier::kGlacier && !cparams.IsLossless()) { - cparams.speed_tier = SpeedTier::kTortoise; + if (cparams.speed_tier == SpeedTier::kTectonicPlate && + !cparams.IsLossless()) { + cparams.speed_tier = SpeedTier::kGlacier; + } + // Lightning mode is handled externally, so switch to Thunder mode to handle + // potentially weird cases. + if (cparams.speed_tier == SpeedTier::kLightning) { + cparams.speed_tier = SpeedTier::kThunder; } - if (cparams.speed_tier == SpeedTier::kGlacier) { + if (cparams.speed_tier == SpeedTier::kTectonicPlate) { std::vector all_params; std::vector size; CompressParams cparams_attempt = cparams_orig; - cparams_attempt.speed_tier = SpeedTier::kTortoise; + cparams_attempt.speed_tier = SpeedTier::kGlacier; cparams_attempt.options.max_properties = 4; for (float x : {0.0f, 80.f}) { @@ -2027,8 +2109,9 @@ Status EncodeFrame(const CompressParams& cparams_orig, // modular headers. for (int K : {0, 1 << 10, 70000}) { cparams_attempt.palette_colors = K; - for (int tree_mode : {-1, (int)ModularOptions::TreeMode::kNoWP, - (int)ModularOptions::TreeMode::kDefault}) { + for (int tree_mode : + {-1, static_cast(ModularOptions::TreeMode::kNoWP), + static_cast(ModularOptions::TreeMode::kDefault)}) { if (tree_mode == -1) { // LZ77 only cparams_attempt.options.nb_repeats = 0; @@ -2054,11 +2137,12 @@ Status EncodeFrame(const CompressParams& cparams_orig, size.resize(all_params.size()); - std::atomic num_errors{0}; + std::atomic has_error{false}; JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, all_params.size(), ThreadPool::NoInit, [&](size_t task, size_t) { + if (has_error) return; std::vector output(64); uint8_t* next_out = output.data(); size_t avail_out = output.size(); @@ -2066,13 +2150,13 @@ Status EncodeFrame(const CompressParams& cparams_orig, local_output.SetAvailOut(&next_out, &avail_out); if (!EncodeFrame(all_params[task], frame_info, metadata, frame_data, cms, nullptr, &local_output, aux_out)) { - num_errors.fetch_add(1, std::memory_order_relaxed); + has_error = true; return; } size[task] = local_output.CurrentPosition(); }, - "Compress kGlacier")); - JXL_RETURN_IF_ERROR(num_errors.load(std::memory_order_relaxed) == 0); + "Compress kTectonicPlate")); + if (has_error) return JXL_FAILURE("Compress kTectonicPlate failed"); size_t best_idx = 0; for (size_t i = 1; i < all_params.size(); i++) { @@ -2156,7 +2240,7 @@ Status EncodeFrame(const CompressParams& cparams_orig, size_t stride = ib.xsize() * num_channels * 4; color.resize(ib.ysize() * stride); JXL_RETURN_IF_ERROR(ConvertToExternal( - ib, /*bites_per_sample=*/32, /*float_out=*/true, num_channels, + ib, /*bits_per_sample=*/32, /*float_out=*/true, num_channels, JXL_NATIVE_ENDIAN, stride, pool, color.data(), color.size(), /*out_callback=*/{}, Orientation::kIdentity)); JxlPixelFormat format{num_channels, JXL_TYPE_FLOAT, JXL_NATIVE_ENDIAN, 0}; @@ -2169,7 +2253,7 @@ Status EncodeFrame(const CompressParams& cparams_orig, const ImageF* channel = &ib.extra_channels()[ec]; JXL_RETURN_IF_ERROR(ConvertChannelsToExternal( &channel, 1, - /*bites_per_sample=*/32, + /*bits_per_sample=*/32, /*float_out=*/true, JXL_NATIVE_ENDIAN, ec_stride, pool, ec_data.data(), ec_data.size(), /*out_callback=*/{}, Orientation::kIdentity)); frame_data.SetFromBuffer(1 + ec, ec_data.data(), ec_data.size(), ec_format); diff --git a/third_party/jpeg-xl/lib/jxl/enc_frame.h b/third_party/jpeg-xl/lib/jxl/enc_frame.h index c6db64ee4e..a5b74cc648 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_frame.h +++ b/third_party/jpeg-xl/lib/jxl/enc_frame.h @@ -57,7 +57,7 @@ struct FrameInfo { // Corresponds to BlendingInfo::source from the FrameHeader. size_t source = 1; // Corresponds to BlendingInfo::clamp from the FrameHeader. - size_t clamp = 1; + bool clamp = true; // Corresponds to BlendingInfo::alpha_channel from the FrameHeader, or set to // -1 to automatically choose it as the index of the first extra channel of // type alpha. diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc b/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc index 3f2ee32afd..7467a4d669 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc @@ -15,8 +15,8 @@ namespace jxl { -void GaborishInverse(Image3F* in_out, const Rect& rect, float mul[3], - ThreadPool* pool) { +Status GaborishInverse(Image3F* in_out, const Rect& rect, const float mul[3], + ThreadPool* pool) { WeightsSymmetric5 weights[3]; // Only an approximation. One or even two 3x3, and rank-1 (separable) 5x5 // are insufficient. The numbers here have been obtained by butteraugli @@ -47,7 +47,9 @@ void GaborishInverse(Image3F* in_out, const Rect& rect, float mul[3], // Note that we cannot *allocate* a plane, as doing so might cause Image3F to // have planes of different stride. Instead, we copy one plane in a temporary // image and reuse the existing planes of the in/out image. - ImageF temp(in_out->Plane(2).xsize(), in_out->Plane(2).ysize()); + ImageF temp; + JXL_ASSIGN_OR_RETURN( + temp, ImageF::Create(in_out->Plane(2).xsize(), in_out->Plane(2).ysize())); CopyImageTo(in_out->Plane(2), &temp); Rect xrect = rect.Extend(3, Rect(*in_out)); Symmetric5(in_out->Plane(0), xrect, weights[0], pool, &in_out->Plane(2), @@ -59,6 +61,7 @@ void GaborishInverse(Image3F* in_out, const Rect& rect, float mul[3], in_out->Plane(0).Swap(in_out->Plane(1)); // 2 1 0 in_out->Plane(0).Swap(in_out->Plane(2)); + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish.h b/third_party/jpeg-xl/lib/jxl/enc_gaborish.h index ece4959f36..041edcec96 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_gaborish.h +++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish.h @@ -9,6 +9,7 @@ // Linear smoothing (3x3 convolution) for deblocking without too much blur. #include "lib/jxl/base/data_parallel.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/image.h" namespace jxl { @@ -16,8 +17,8 @@ namespace jxl { // Used in encoder to reduce the impact of the decoder's smoothing. // This is not exact. Works in-place to reduce memory use. // The input is typically in XYB space. -void GaborishInverse(Image3F* in_out, const Rect& rect, float mul[3], - ThreadPool* pool); +Status GaborishInverse(Image3F* in_out, const Rect& rect, const float mul[3], + ThreadPool* pool); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc b/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc index 426f08ecb0..0d173c5eb8 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc @@ -5,6 +5,8 @@ #include "lib/jxl/enc_gaborish.h" +#include + #include #include "lib/jxl/base/compiler_specific.h" @@ -40,7 +42,7 @@ void ConvolveGaborish(const ImageF& in, float weight1, float weight2, } void TestRoundTrip(const Image3F& in, float max_l1) { - Image3F fwd(in.xsize(), in.ysize()); + JXL_ASSIGN_OR_DIE(Image3F fwd, Image3F::Create(in.xsize(), in.ysize())); ThreadPool* null_pool = nullptr; ConvolveGaborish(in.Plane(0), 0, 0, null_pool, &fwd.Plane(0)); ConvolveGaborish(in.Plane(1), 0, 0, null_pool, &fwd.Plane(1)); @@ -51,20 +53,20 @@ void TestRoundTrip(const Image3F& in, float max_l1) { w, w, }; - GaborishInverse(&fwd, Rect(fwd), weights, null_pool); + JXL_CHECK(GaborishInverse(&fwd, Rect(fwd), weights, null_pool)); JXL_ASSERT_OK(VerifyRelativeError(in, fwd, max_l1, 1E-4f, _)); } TEST(GaborishTest, TestZero) { - Image3F in(20, 20); + JXL_ASSIGN_OR_DIE(Image3F in, Image3F::Create(20, 20)); ZeroFillImage(&in); TestRoundTrip(in, 0.0f); } // Disabled: large difference. -#if 0 +#if JXL_FALSE TEST(GaborishTest, TestDirac) { - Image3F in(20, 20); + JXL_ASSIGN_OR_DIE(Image3F in, Image3F::Create(20, 20)); ZeroFillImage(&in); in.PlaneRow(1, 10)[10] = 10.0f; TestRoundTrip(in, 0.26f); @@ -72,7 +74,7 @@ TEST(GaborishTest, TestDirac) { #endif TEST(GaborishTest, TestFlat) { - Image3F in(20, 20); + JXL_ASSIGN_OR_DIE(Image3F in, Image3F::Create(20, 20)); FillImage(1.0f, &in); TestRoundTrip(in, 1E-5f); } diff --git a/third_party/jpeg-xl/lib/jxl/enc_group.cc b/third_party/jpeg-xl/lib/jxl/enc_group.cc index 09bab534c9..1967fdaba9 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_group.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_group.cc @@ -286,10 +286,11 @@ void AdjustQuantBlockAC(const Quantizer& quantizer, size_t c, { // Reduce quant in highly active areas. int32_t div = (xsize * ysize); - int32_t activity = (hfNonZeros[0] + div / 2) / div; + int32_t activity = (static_cast(hfNonZeros[0]) + div / 2) / div; int32_t orig_qp_limit = std::max(4, *quant / 2); for (int i = 1; i < 4; ++i) { - activity = std::min(activity, (hfNonZeros[i] + div / 2) / div); + activity = std::min( + activity, (static_cast(hfNonZeros[i]) + div / 2) / div); } if (activity >= 15) { activity = 15; @@ -316,7 +317,7 @@ void QuantizeRoundtripYBlockAC(PassesEncoderState* enc_state, const size_t size, float* JXL_RESTRICT inout, int32_t* JXL_RESTRICT quantized) { float thres_y[4] = {0.58f, 0.64f, 0.64f, 0.64f}; - { + if (enc_state->cparams.speed_tier <= SpeedTier::kHare) { int32_t max_quant = 0; int quant_orig = *quant; float val[3] = {enc_state->x_qm_multiplier, 1.0f, @@ -337,6 +338,11 @@ void QuantizeRoundtripYBlockAC(PassesEncoderState* enc_state, const size_t size, max_quant = std::max(*quant, max_quant); } *quant = max_quant; + } else { + thres_y[0] = 0.56; + thres_y[1] = 0.62; + thres_y[2] = 0.62; + thres_y[3] = 0.62; } QuantizeBlockAC(quantizer, error_diffusion, 1, 1.0f, quant_kind, xsize, ysize, @@ -507,8 +513,8 @@ namespace jxl { HWY_EXPORT(ComputeCoefficients); void ComputeCoefficients(size_t group_idx, PassesEncoderState* enc_state, const Image3F& opsin, const Rect& rect, Image3F* dc) { - return HWY_DYNAMIC_DISPATCH(ComputeCoefficients)(group_idx, enc_state, opsin, - rect, dc); + HWY_DYNAMIC_DISPATCH(ComputeCoefficients) + (group_idx, enc_state, opsin, rect, dc); } Status EncodeGroupTokenizedCoefficients(size_t group_idx, size_t pass_idx, diff --git a/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc b/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc index 9d6bf11184..685558ac7c 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc @@ -149,8 +149,10 @@ void FindBestBlockEntropyModel(const CompressParams& cparams, const ImageI& rqf, std::vector remap((qft.size() + 1) * kNumOrders); std::iota(remap.begin(), remap.end(), 0); std::vector clusters(remap); - size_t nb_clusters = Clamp1((int)(tot / size_for_ctx_model / 2), 2, 9); - size_t nb_clusters_chroma = Clamp1((int)(tot / size_for_ctx_model / 3), 1, 5); + size_t nb_clusters = + Clamp1(static_cast(tot / size_for_ctx_model / 2), 2, 9); + size_t nb_clusters_chroma = + Clamp1(static_cast(tot / size_for_ctx_model / 3), 1, 5); // This is O(n^2 log n), but n is small. while (clusters.size() > nb_clusters) { std::sort(clusters.begin(), clusters.end(), @@ -181,8 +183,8 @@ void FindBestBlockEntropyModel(const CompressParams& cparams, const ImageI& rqf, // for chroma, only use up to nb_clusters_chroma separate block contexts // (those for the biggest clusters) for (size_t i = remap.size(); i < remap.size() * 3; i++) { - ctx_map[i] = num + Clamp1((int)remap[i % remap.size()], 0, - (int)nb_clusters_chroma - 1); + ctx_map[i] = num + Clamp1(static_cast(remap[i % remap.size()]), 0, + static_cast(nb_clusters_chroma) - 1); } block_ctx_map->num_ctxs = *std::max_element(ctx_map.begin(), ctx_map.end()) + 1; @@ -190,9 +192,9 @@ void FindBestBlockEntropyModel(const CompressParams& cparams, const ImageI& rqf, namespace { -void FindBestDequantMatrices(const CompressParams& cparams, - ModularFrameEncoder* modular_frame_encoder, - DequantMatrices* dequant_matrices) { +Status FindBestDequantMatrices(const CompressParams& cparams, + ModularFrameEncoder* modular_frame_encoder, + DequantMatrices* dequant_matrices) { // TODO(veluca): quant matrices for no-gaborish. // TODO(veluca): heuristics for in-bitstream quant tables. *dequant_matrices = DequantMatrices(); @@ -204,13 +206,14 @@ void FindBestDequantMatrices(const CompressParams& cparams, DctQuantWeightParams dct_params(weights); std::vector encodings(DequantMatrices::kNum, QuantEncoding::DCT(dct_params)); - DequantMatricesSetCustom(dequant_matrices, encodings, - modular_frame_encoder); + JXL_RETURN_IF_ERROR(DequantMatricesSetCustom(dequant_matrices, encodings, + modular_frame_encoder)); float dc_weights[3] = {1.0f / cparams.max_error[0], 1.0f / cparams.max_error[1], 1.0f / cparams.max_error[2]}; DequantMatricesSetCustomDC(dequant_matrices, dc_weights); } + return true; } void StoreMin2(const float v, float& min1, float& min2) { @@ -226,9 +229,9 @@ void StoreMin2(const float v, float& min1, float& min2) { void CreateMask(const ImageF& image, ImageF& mask) { for (size_t y = 0; y < image.ysize(); y++) { - auto* row_n = y > 0 ? image.Row(y - 1) : image.Row(y); - auto* row_in = image.Row(y); - auto* row_s = y + 1 < image.ysize() ? image.Row(y + 1) : image.Row(y); + const auto* row_n = y > 0 ? image.Row(y - 1) : image.Row(y); + const auto* row_in = image.Row(y); + const auto* row_s = y + 1 < image.ysize() ? image.Row(y + 1) : image.Row(y); auto* row_out = mask.Row(y); for (size_t x = 0; x < image.xsize(); x++) { // Center, west, east, north, south values and their absolute difference @@ -258,7 +261,7 @@ void CreateMask(const ImageF& image, ImageF& mask) { // by the decoder. Ringing is slightly reduced by clamping the values of the // resulting pixels within certain bounds of a small region in the original // image. -void DownsampleImage2_Sharper(const ImageF& input, ImageF* output) { +Status DownsampleImage2_Sharper(const ImageF& input, ImageF* output) { const int64_t kernelx = 12; const int64_t kernely = 12; @@ -315,11 +318,12 @@ void DownsampleImage2_Sharper(const ImageF& input, ImageF* output) { int64_t xsize = input.xsize(); int64_t ysize = input.ysize(); - ImageF box_downsample(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF box_downsample, ImageF::Create(xsize, ysize)); CopyImageTo(input, &box_downsample); - DownsampleImage(&box_downsample, 2); + JXL_ASSIGN_OR_RETURN(box_downsample, DownsampleImage(box_downsample, 2)); - ImageF mask(box_downsample.xsize(), box_downsample.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF mask, ImageF::Create(box_downsample.xsize(), + box_downsample.ysize())); CreateMask(box_downsample, mask); for (size_t y = 0; y < output->ysize(); y++) { @@ -379,50 +383,54 @@ void DownsampleImage2_Sharper(const ImageF& input, ImageF* output) { } } } + return true; } } // namespace -void DownsampleImage2_Sharper(Image3F* opsin) { +Status DownsampleImage2_Sharper(Image3F* opsin) { // Allocate extra space to avoid a reallocation when padding. - Image3F downsampled(DivCeil(opsin->xsize(), 2) + kBlockDim, - DivCeil(opsin->ysize(), 2) + kBlockDim); + JXL_ASSIGN_OR_RETURN(Image3F downsampled, + Image3F::Create(DivCeil(opsin->xsize(), 2) + kBlockDim, + DivCeil(opsin->ysize(), 2) + kBlockDim)); downsampled.ShrinkTo(downsampled.xsize() - kBlockDim, downsampled.ysize() - kBlockDim); for (size_t c = 0; c < 3; c++) { - DownsampleImage2_Sharper(opsin->Plane(c), &downsampled.Plane(c)); + JXL_RETURN_IF_ERROR( + DownsampleImage2_Sharper(opsin->Plane(c), &downsampled.Plane(c))); } *opsin = std::move(downsampled); + return true; } namespace { // The default upsampling kernels used by Upsampler in the decoder. -static const constexpr int64_t kSize = 5; +const constexpr int64_t kSize = 5; -static const float kernel00[25] = { +const float kernel00[25] = { -0.01716200f, -0.03452303f, -0.04022174f, -0.02921014f, -0.00624645f, -0.03452303f, 0.14111091f, 0.28896755f, 0.00278718f, -0.01610267f, -0.04022174f, 0.28896755f, 0.56661550f, 0.03777607f, -0.01986694f, -0.02921014f, 0.00278718f, 0.03777607f, -0.03144731f, -0.01185068f, -0.00624645f, -0.01610267f, -0.01986694f, -0.01185068f, -0.00213539f, }; -static const float kernel01[25] = { +const float kernel01[25] = { -0.00624645f, -0.01610267f, -0.01986694f, -0.01185068f, -0.00213539f, -0.02921014f, 0.00278718f, 0.03777607f, -0.03144731f, -0.01185068f, -0.04022174f, 0.28896755f, 0.56661550f, 0.03777607f, -0.01986694f, -0.03452303f, 0.14111091f, 0.28896755f, 0.00278718f, -0.01610267f, -0.01716200f, -0.03452303f, -0.04022174f, -0.02921014f, -0.00624645f, }; -static const float kernel10[25] = { +const float kernel10[25] = { -0.00624645f, -0.02921014f, -0.04022174f, -0.03452303f, -0.01716200f, -0.01610267f, 0.00278718f, 0.28896755f, 0.14111091f, -0.03452303f, -0.01986694f, 0.03777607f, 0.56661550f, 0.28896755f, -0.04022174f, -0.01185068f, -0.03144731f, 0.03777607f, 0.00278718f, -0.02921014f, -0.00213539f, -0.01185068f, -0.01986694f, -0.01610267f, -0.00624645f, }; -static const float kernel11[25] = { +const float kernel11[25] = { -0.00213539f, -0.01185068f, -0.01986694f, -0.01610267f, -0.00624645f, -0.01185068f, -0.03144731f, 0.03777607f, 0.00278718f, -0.02921014f, -0.01986694f, 0.03777607f, 0.56661550f, 0.28896755f, -0.04022174f, @@ -435,14 +443,14 @@ static const float kernel11[25] = { // TODO(lode): use Upsampler instead. However, it requires pre-initialization // and padding on the left side of the image which requires refactoring the // other code using this. -static void UpsampleImage(const ImageF& input, ImageF* output) { +void UpsampleImage(const ImageF& input, ImageF* output) { int64_t xsize = input.xsize(); int64_t ysize = input.ysize(); int64_t xsize2 = output->xsize(); int64_t ysize2 = output->ysize(); for (int64_t y = 0; y < ysize2; y++) { for (int64_t x = 0; x < xsize2; x++) { - auto kernel = kernel00; + const auto* kernel = kernel00; if ((x & 1) && (y & 1)) { kernel = kernel11; } else if (x & 1) { @@ -492,7 +500,7 @@ static void UpsampleImage(const ImageF& input, ImageF* output) { // Returns the derivative of Upsampler, with respect to input pixel x2, y2, to // output pixel x, y (ignoring the clamping). float UpsamplerDeriv(int64_t x2, int64_t y2, int64_t x, int64_t y) { - auto kernel = kernel00; + const auto* kernel = kernel00; if ((x & 1) && (y & 1)) { kernel = kernel11; } else if (x & 1) { @@ -597,11 +605,9 @@ void ReduceRinging(const ImageF& initial, const ImageF& mask, ImageF& down) { float max = initial.Row(y)[x]; for (int64_t yi = -1; yi < 2; yi++) { for (int64_t xi = -1; xi < 2; xi++) { - int64_t x2 = (int64_t)x + xi; - int64_t y2 = (int64_t)y + yi; - if (x2 < 0 || y2 < 0 || x2 >= (int64_t)xsize2 || - y2 >= (int64_t)ysize2) - continue; + int64_t x2 = static_cast(x) + xi; + int64_t y2 = static_cast(y) + yi; + if (x2 < 0 || y2 < 0 || x2 >= xsize2 || y2 >= ysize2) continue; min = std::min(min, initial.Row(y2)[x2]); max = std::max(max, initial.Row(y2)[x2]); } @@ -625,32 +631,35 @@ void ReduceRinging(const ImageF& initial, const ImageF& mask, ImageF& down) { } // TODO(lode): move this to a separate file enc_downsample.cc -void DownsampleImage2_Iterative(const ImageF& orig, ImageF* output) { +Status DownsampleImage2_Iterative(const ImageF& orig, ImageF* output) { int64_t xsize = orig.xsize(); int64_t ysize = orig.ysize(); int64_t xsize2 = DivCeil(orig.xsize(), 2); int64_t ysize2 = DivCeil(orig.ysize(), 2); - ImageF box_downsample(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF box_downsample, ImageF::Create(xsize, ysize)); CopyImageTo(orig, &box_downsample); - DownsampleImage(&box_downsample, 2); - ImageF mask(box_downsample.xsize(), box_downsample.ysize()); + JXL_ASSIGN_OR_RETURN(box_downsample, DownsampleImage(box_downsample, 2)); + JXL_ASSIGN_OR_RETURN(ImageF mask, ImageF::Create(box_downsample.xsize(), + box_downsample.ysize())); CreateMask(box_downsample, mask); output->ShrinkTo(xsize2, ysize2); // Initial result image using the sharper downsampling. // Allocate extra space to avoid a reallocation when padding. - ImageF initial(DivCeil(orig.xsize(), 2) + kBlockDim, - DivCeil(orig.ysize(), 2) + kBlockDim); + JXL_ASSIGN_OR_RETURN(ImageF initial, + ImageF::Create(DivCeil(orig.xsize(), 2) + kBlockDim, + DivCeil(orig.ysize(), 2) + kBlockDim)); initial.ShrinkTo(initial.xsize() - kBlockDim, initial.ysize() - kBlockDim); - DownsampleImage2_Sharper(orig, &initial); + JXL_RETURN_IF_ERROR(DownsampleImage2_Sharper(orig, &initial)); - ImageF down(initial.xsize(), initial.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF down, + ImageF::Create(initial.xsize(), initial.ysize())); CopyImageTo(initial, &down); - ImageF up(xsize, ysize); - ImageF corr(xsize, ysize); - ImageF corr2(xsize2, ysize2); + JXL_ASSIGN_OR_RETURN(ImageF up, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(ImageF corr, ImageF::Create(xsize, ysize)); + JXL_ASSIGN_OR_RETURN(ImageF corr2, ImageF::Create(xsize2, ysize2)); // In the weights map, relatively higher values will allow less ringing but // also less sharpness. With all constant values, it optimizes equally @@ -659,25 +668,25 @@ void DownsampleImage2_Iterative(const ImageF& orig, ImageF* output) { // TODO(lode): Make use of the weights field for anti-ringing and clamping, // the values are all set to 1 for now, but it is intended to be used for // reducing ringing based on the mask, and taking clamping into account. - ImageF weights(xsize, ysize); + JXL_ASSIGN_OR_RETURN(ImageF weights, ImageF::Create(xsize, ysize)); for (size_t y = 0; y < weights.ysize(); y++) { auto* row = weights.Row(y); for (size_t x = 0; x < weights.xsize(); x++) { row[x] = 1; } } - ImageF weights2(xsize2, ysize2); + JXL_ASSIGN_OR_RETURN(ImageF weights2, ImageF::Create(xsize2, ysize2)); AntiUpsample(weights, &weights2); const size_t num_it = 3; for (size_t it = 0; it < num_it; ++it) { UpsampleImage(down, &up); - corr = LinComb(1, orig, -1, up); + JXL_ASSIGN_OR_RETURN(corr, LinComb(1, orig, -1, up)); ElwiseMul(corr, weights, &corr); AntiUpsample(corr, &corr2); ElwiseDiv(corr2, weights2, &corr2); - down = LinComb(1, down, 1, corr2); + JXL_ASSIGN_OR_RETURN(down, LinComb(1, down, 1, corr2)); } ReduceRinging(initial, mask, down); @@ -690,32 +699,40 @@ void DownsampleImage2_Iterative(const ImageF& orig, ImageF* output) { output->Row(y)[x] = v; } } + return true; } } // namespace -void DownsampleImage2_Iterative(Image3F* opsin) { +Status DownsampleImage2_Iterative(Image3F* opsin) { // Allocate extra space to avoid a reallocation when padding. - Image3F downsampled(DivCeil(opsin->xsize(), 2) + kBlockDim, - DivCeil(opsin->ysize(), 2) + kBlockDim); + JXL_ASSIGN_OR_RETURN(Image3F downsampled, + Image3F::Create(DivCeil(opsin->xsize(), 2) + kBlockDim, + DivCeil(opsin->ysize(), 2) + kBlockDim)); downsampled.ShrinkTo(downsampled.xsize() - kBlockDim, downsampled.ysize() - kBlockDim); - Image3F rgb(opsin->xsize(), opsin->ysize()); + JXL_ASSIGN_OR_RETURN(Image3F rgb, + Image3F::Create(opsin->xsize(), opsin->ysize())); OpsinParams opsin_params; // TODO(user): use the ones that are actually used opsin_params.Init(kDefaultIntensityTarget); OpsinToLinear(*opsin, Rect(rgb), nullptr, &rgb, opsin_params); - ImageF mask(opsin->xsize(), opsin->ysize()); + JXL_ASSIGN_OR_RETURN(ImageF mask, + ImageF::Create(opsin->xsize(), opsin->ysize())); ButteraugliParams butter_params; - ButteraugliComparator butter(rgb, butter_params); - butter.Mask(&mask); - ImageF mask_fuzzy(opsin->xsize(), opsin->ysize()); + JXL_ASSIGN_OR_RETURN(std::unique_ptr butter, + ButteraugliComparator::Make(rgb, butter_params)); + JXL_RETURN_IF_ERROR(butter->Mask(&mask)); + JXL_ASSIGN_OR_RETURN(ImageF mask_fuzzy, + ImageF::Create(opsin->xsize(), opsin->ysize())); for (size_t c = 0; c < 3; c++) { - DownsampleImage2_Iterative(opsin->Plane(c), &downsampled.Plane(c)); + JXL_RETURN_IF_ERROR( + DownsampleImage2_Iterative(opsin->Plane(c), &downsampled.Plane(c))); } *opsin = std::move(downsampled); + return true; } Status LossyFrameHeuristics(const FrameHeader& frame_header, @@ -739,10 +756,11 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, BlockCtxMap& block_ctx_map = shared.block_ctx_map; // Find and subtract splines. + if (cparams.custom_splines.HasAny()) { + image_features.splines = cparams.custom_splines; + } if (!streaming_mode && cparams.speed_tier <= SpeedTier::kSquirrel) { - if (cparams.custom_splines.HasAny()) { - image_features.splines = cparams.custom_splines; - } else { + if (!cparams.custom_splines.HasAny()) { image_features.splines = FindSplines(*opsin); } JXL_RETURN_IF_ERROR(image_features.splines.InitializeDrawCache( @@ -754,7 +772,8 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, if (!streaming_mode && ApplyOverride(cparams.patches, cparams.speed_tier <= SpeedTier::kSquirrel)) { - FindBestPatchDictionary(*opsin, enc_state, cms, pool, aux_out); + JXL_RETURN_IF_ERROR( + FindBestPatchDictionary(*opsin, enc_state, cms, pool, aux_out)); PatchDictionaryEncoder::SubtractFrom(image_features.patches, opsin); } @@ -791,10 +810,12 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, // on simple heuristics in FindBestAcStrategy, or set a constant for Falcon // mode. if (cparams.speed_tier > SpeedTier::kHare) { - initial_quant_field = - ImageF(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - initial_quant_masking = - ImageF(frame_dim.xsize_blocks, frame_dim.ysize_blocks); + JXL_ASSIGN_OR_RETURN( + initial_quant_field, + ImageF::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN( + initial_quant_masking, + ImageF::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); float q = 0.79 / cparams.butteraugli_distance; FillImage(q, &initial_quant_field); FillImage(1.0f / (q + 0.001f), &initial_quant_masking); @@ -805,9 +826,11 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, if (!frame_header.loop_filter.gab) { butteraugli_distance_for_iqf *= 0.73f; } - initial_quant_field = InitialQuantField( - butteraugli_distance_for_iqf, *opsin, rect, pool, 1.0f, - &initial_quant_masking, &initial_quant_masking1x1); + JXL_ASSIGN_OR_RETURN( + initial_quant_field, + InitialQuantField(butteraugli_distance_for_iqf, *opsin, rect, pool, + 1.0f, &initial_quant_masking, + &initial_quant_masking1x1)); float q = 0.39 / cparams.butteraugli_distance; quantizer.ComputeGlobalScaleAndQuant(quant_dc, q, 0); } @@ -822,18 +845,21 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, 0.99406123118127299f, 0.99719338015886894f, }; - GaborishInverse(opsin, rect, weight, pool); + JXL_RETURN_IF_ERROR(GaborishInverse(opsin, rect, weight, pool)); } if (initialize_global_state) { - FindBestDequantMatrices(cparams, modular_frame_encoder, &matrices); + JXL_RETURN_IF_ERROR( + FindBestDequantMatrices(cparams, modular_frame_encoder, &matrices)); } - cfl_heuristics.Init(rect); + JXL_RETURN_IF_ERROR(cfl_heuristics.Init(rect)); acs_heuristics.Init(*opsin, rect, initial_quant_field, initial_quant_masking, initial_quant_masking1x1, &matrices); + std::atomic has_error{false}; auto process_tile = [&](const uint32_t tid, const size_t thread) { + if (has_error) return; size_t n_enc_tiles = DivCeil(frame_dim.xsize_blocks, kEncTileDimInBlocks); size_t tx = tid % n_enc_tiles; size_t ty = tid / n_enc_tiles; @@ -856,13 +882,16 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, } // Choose block sizes. - acs_heuristics.ProcessRect(r, cmap, &ac_strategy); + acs_heuristics.ProcessRect(r, cmap, &ac_strategy, thread); // Choose amount of post-processing smoothing. // TODO(veluca): should this go *after* AdjustQuantField? - ar_heuristics.RunRect(cparams, frame_header, r, *opsin, rect, - initial_quant_field, ac_strategy, &epf_sharpness, - thread); + if (!ar_heuristics.RunRect(cparams, frame_header, r, *opsin, rect, + initial_quant_field, ac_strategy, &epf_sharpness, + thread)) { + has_error = true; + return; + } // Always set the initial quant field, so we can compute the CfL map with // more accuracy. The initial quant field might change in slower modes, but @@ -884,18 +913,21 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, DivCeil(frame_dim.xsize_blocks, kEncTileDimInBlocks) * DivCeil(frame_dim.ysize_blocks, kEncTileDimInBlocks), [&](const size_t num_threads) { + acs_heuristics.PrepareForThreads(num_threads); ar_heuristics.PrepareForThreads(num_threads); cfl_heuristics.PrepareForThreads(num_threads); return true; }, process_tile, "Enc Heuristics")); + if (has_error) return JXL_FAILURE("Enc Heuristics failed"); - acs_heuristics.Finalize(frame_dim, ac_strategy, aux_out); + JXL_RETURN_IF_ERROR(acs_heuristics.Finalize(frame_dim, ac_strategy, aux_out)); // Refine quantization levels. if (!streaming_mode) { - FindBestQuantizer(frame_header, original_pixels, *opsin, - initial_quant_field, enc_state, cms, pool, aux_out); + JXL_RETURN_IF_ERROR(FindBestQuantizer(frame_header, original_pixels, *opsin, + initial_quant_field, enc_state, cms, + pool, aux_out)); } // Choose a context model that depends on the amount of quantization for AC. diff --git a/third_party/jpeg-xl/lib/jxl/enc_heuristics.h b/third_party/jpeg-xl/lib/jxl/enc_heuristics.h index 14cb596387..0dd93e4288 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_heuristics.h +++ b/third_party/jpeg-xl/lib/jxl/enc_heuristics.h @@ -38,8 +38,8 @@ Status LossyFrameHeuristics(const FrameHeader& frame_header, void FindBestBlockEntropyModel(PassesEncoderState& enc_state); -void DownsampleImage2_Iterative(Image3F* output); -void DownsampleImage2_Sharper(Image3F* opsin); +Status DownsampleImage2_Iterative(Image3F* opsin); +Status DownsampleImage2_Sharper(Image3F* opsin); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_huffman.cc b/third_party/jpeg-xl/lib/jxl/enc_huffman.cc index 3eab2c218a..6af92f6ed5 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_huffman.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_huffman.cc @@ -70,6 +70,7 @@ void StoreHuffmanTreeToBitMask(const size_t huffman_tree_size, for (size_t i = 0; i < huffman_tree_size; ++i) { size_t ix = huffman_tree[i]; writer->Write(code_length_bitdepth[ix], code_length_bitdepth_symbols[ix]); + JXL_ASSERT(ix <= 17); // Extra bits switch (ix) { case 16: @@ -78,6 +79,9 @@ void StoreHuffmanTreeToBitMask(const size_t huffman_tree_size, case 17: writer->Write(3, huffman_tree_extra_bits[i]); break; + default: + // no-op + break; } } } diff --git a/third_party/jpeg-xl/lib/jxl/enc_huffman_tree.cc b/third_party/jpeg-xl/lib/jxl/enc_huffman_tree.cc index 5c40dea770..82ae4bccc7 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_huffman_tree.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_huffman_tree.cc @@ -85,7 +85,8 @@ void CreateHuffmanTree(const uint32_t* data, const size_t length, size_t i = 0; // Points to the next leaf node. size_t j = n + 1; // Points to the next non-leaf node. for (size_t k = n - 1; k != 0; --k) { - size_t left, right; + size_t left; + size_t right; if (tree[i].total_count <= tree[j].total_count) { left = i; ++i; @@ -112,7 +113,7 @@ void CreateHuffmanTree(const uint32_t* data, const size_t length, tree.push_back(sentinel); } JXL_DASSERT(tree.size() == 2 * n + 1); - SetDepth(tree[2 * n - 1], &tree[0], depth, 0); + SetDepth(tree[2 * n - 1], tree.data(), depth, 0); // We need to pack the Huffman tree in tree_limit bits. // If this was not successful, add fake entities to the lowest values diff --git a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc index 8e92fe3452..a29fb3f299 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc @@ -13,6 +13,7 @@ #include #include "lib/jxl/base/byte_order.h" +#include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/enc_ans.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/fields.h" @@ -36,7 +37,8 @@ void Unshuffle(uint8_t* data, size_t size, size_t width) { size_t height = (size + width - 1) / width; // amount of rows of input PaddedBytes result(size); // i = input index, j output index - size_t s = 0, j = 0; + size_t s = 0; + size_t j = 0; for (size_t i = 0; i < size; i++) { result[j] = data[i]; j += height; @@ -71,7 +73,7 @@ Status PredictAndShuffle(size_t stride, size_t width, int order, size_t num, return true; } -static inline void EncodeVarInt(uint64_t value, PaddedBytes* data) { +inline void EncodeVarInt(uint64_t value, PaddedBytes* data) { size_t pos = data->size(); data->resize(data->size() + 9); size_t output_size = data->size(); @@ -83,13 +85,13 @@ static inline void EncodeVarInt(uint64_t value, PaddedBytes* data) { // TODO(eustas): should it be `<` ? JXL_CHECK(pos <= output_size); // |128: Set the next byte flag - output[pos++] = ((uint8_t)(value & 127)) | 128; + output[pos++] = (static_cast(value & 127)) | 128; // Remove the seven bits we just wrote value >>= 7; } // TODO(eustas): should it be `<` ? JXL_CHECK(pos <= output_size); - output[pos++] = ((uint8_t)value) & 127; + output[pos++] = static_cast(value & 127); data->resize(pos); } @@ -235,7 +237,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) { // allowed for tagged elements to overlap, e.g. the curve for R, G and B could // all point to the same one. Tag tag; - size_t tagstart = 0, tagsize = 0, clutstart = 0; + size_t tagstart = 0; + size_t tagsize = 0; + size_t clutstart = 0; // Should always check tag_sane before doing math with tagsize. const auto tag_sane = [&tagsize]() { @@ -292,7 +296,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) { commands_add.push_back(kCommandTypeStartFirst + 5); pos += 8; commands_add.push_back(kCommandPredict); - int order = 1, width = 2, stride = width; + int order = 1; + int width = 2; + int stride = width; commands_add.push_back((order << 2) | (width - 1)); EncodeVarInt(num, &commands_add); JXL_RETURN_IF_ERROR(PredictAndShuffle(stride, width, order, num, icc, @@ -310,7 +316,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) { pos += 12; last1 = pos; commands_add.push_back(kCommandPredict); - int order = 1, width = 2, stride = width; + int order = 1; + int width = 2; + int stride = width; commands_add.push_back((order << 2) | (width - 1)); EncodeVarInt(num, &commands_add); JXL_RETURN_IF_ERROR(PredictAndShuffle(stride, width, order, num, icc, @@ -352,7 +360,9 @@ Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result) { if (commands_add.empty() && data_add.empty() && tag == kGbd_Tag && tag_sane() && pos == tagstart + 8 && pos + tagsize - 8 <= size && pos > 16) { - size_t width = 4, order = 0, stride = width; + size_t width = 4; + size_t order = 0; + size_t stride = width; size_t num = tagsize - 8; uint8_t flags = (order << 2) | (width - 1) | (stride == width ? 0 : 16); commands_add.push_back(kCommandPredict); diff --git a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.h b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.h index 224c2e5316..a99e11b19c 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.h +++ b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.h @@ -15,7 +15,6 @@ #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/dec_bit_reader.h" #include "lib/jxl/enc_bit_writer.h" namespace jxl { @@ -27,9 +26,6 @@ class PaddedBytes; Status WriteICC(const std::vector& icc, BitWriter* JXL_RESTRICT writer, size_t layer, AuxOut* JXL_RESTRICT aux_out); -// Exposed only for testing -Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result); - } // namespace jxl #endif // LIB_JXL_ENC_ICC_CODEC_H_ diff --git a/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc b/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc index 1b41361320..044f763363 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_image_bundle.cc @@ -8,13 +8,10 @@ #include #include -#include #include -#include "lib/jxl/alpha.h" -#include "lib/jxl/base/byte_order.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/color_encoding_internal.h" -#include "lib/jxl/fields.h" #include "lib/jxl/image_bundle.h" namespace jxl { @@ -30,11 +27,11 @@ Status ApplyColorTransform(const ColorEncoding& c_current, JXL_CHECK(c_current.IsGray() == c_desired.IsGray()); bool is_gray = c_current.IsGray(); if (out->xsize() < rect.xsize() || out->ysize() < rect.ysize()) { - *out = Image3F(rect.xsize(), rect.ysize()); + JXL_ASSIGN_OR_RETURN(*out, Image3F::Create(rect.xsize(), rect.ysize())); } else { out->ShrinkTo(rect.xsize(), rect.ysize()); } - std::atomic ok{true}; + std::atomic has_error{false}; JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, rect.ysize(), [&](const size_t num_threads) { @@ -42,6 +39,7 @@ Status ApplyColorTransform(const ColorEncoding& c_current, rect.xsize(), num_threads); }, [&](const uint32_t y, const size_t thread) { + if (has_error) return; float* mutable_src_buf = c_transform.BufSrc(thread); const float* src_buf = mutable_src_buf; // Interleave input. @@ -49,7 +47,7 @@ Status ApplyColorTransform(const ColorEncoding& c_current, src_buf = rect.ConstPlaneRow(color, 0, y); } else if (c_current.IsCMYK()) { if (!black) { - ok.store(false); + has_error = true; return; } const float* JXL_RESTRICT row_in0 = rect.ConstPlaneRow(color, 0, y); @@ -74,8 +72,8 @@ Status ApplyColorTransform(const ColorEncoding& c_current, } } float* JXL_RESTRICT dst_buf = c_transform.BufDst(thread); - if (!c_transform.Run(thread, src_buf, dst_buf)) { - ok.store(false); + if (!c_transform.Run(thread, src_buf, dst_buf, rect.xsize())) { + has_error = true; return; } float* JXL_RESTRICT row_out0 = out->PlaneRow(0, y); @@ -97,7 +95,8 @@ Status ApplyColorTransform(const ColorEncoding& c_current, } }, "Colorspace transform")); - return ok.load(); + if (has_error) return JXL_FAILURE("Colorspace transform failed"); + return true; } namespace { @@ -133,7 +132,8 @@ Status TransformIfNeeded(const ImageBundle& in, const ColorEncoding& c_desired, } // TODO(janwas): avoid copying via createExternal+copyBackToIO // instead of copy+createExternal+copyBackToIO - Image3F color(in.color().xsize(), in.color().ysize()); + JXL_ASSIGN_OR_RETURN(Image3F color, + Image3F::Create(in.color().xsize(), in.color().ysize())); CopyImageTo(in.color(), &color); store->SetFromImage(std::move(color), in.c_current()); @@ -141,7 +141,8 @@ Status TransformIfNeeded(const ImageBundle& in, const ColorEncoding& c_desired, if (in.HasExtraChannels()) { std::vector extra_channels; for (const ImageF& extra_channel : in.extra_channels()) { - ImageF ec(extra_channel.xsize(), extra_channel.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF ec, ImageF::Create(extra_channel.xsize(), + extra_channel.ysize())); CopyImageTo(extra_channel, &ec); extra_channels.emplace_back(std::move(ec)); } diff --git a/third_party/jpeg-xl/lib/jxl/enc_linalg.cc b/third_party/jpeg-xl/lib/jxl/enc_linalg.cc index fe2090a909..452c17f4e8 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_linalg.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_linalg.cc @@ -7,46 +7,43 @@ #include -#include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/status.h" namespace jxl { -void ConvertToDiagonal(const ImageD& A, ImageD* const JXL_RESTRICT diag, - ImageD* const JXL_RESTRICT U) { +void ConvertToDiagonal(const Matrix2x2& A, Vector2& diag, Matrix2x2& U) { #if JXL_ENABLE_ASSERT - JXL_ASSERT(A.xsize() == 2); - JXL_ASSERT(A.ysize() == 2); - JXL_ASSERT(std::abs(A.Row(0)[1] - A.Row(1)[0]) < 1e-15); + // Check A is symmetric. + JXL_ASSERT(std::abs(A[0][1] - A[1][0]) < 1e-15); #endif - if (std::abs(A.ConstRow(0)[1]) < 1e-15) { + if (std::abs(A[0][1]) < 1e-15) { // Already diagonal. - diag->Row(0)[0] = A.ConstRow(0)[0]; - diag->Row(0)[1] = A.ConstRow(1)[1]; - U->Row(0)[0] = U->Row(1)[1] = 1.0; - U->Row(0)[1] = U->Row(1)[0] = 0.0; + diag[0] = A[0][0]; + diag[1] = A[1][1]; + U[0][0] = U[1][1] = 1.0; + U[0][1] = U[1][0] = 0.0; return; } - double b = -(A.Row(0)[0] + A.Row(1)[1]); - double c = A.Row(0)[0] * A.Row(1)[1] - A.Row(0)[1] * A.Row(0)[1]; + double b = -(A[0][0] + A[1][1]); + double c = A[0][0] * A[1][1] - A[0][1] * A[0][1]; double d = b * b - 4.0 * c; double sqd = std::sqrt(d); double l1 = (-b - sqd) * 0.5; double l2 = (-b + sqd) * 0.5; - double v1[2] = {A.Row(0)[0] - l1, A.Row(1)[0]}; + Vector2 v1 = {A[0][0] - l1, A[1][0]}; double v1n = 1.0 / std::hypot(v1[0], v1[1]); v1[0] = v1[0] * v1n; v1[1] = v1[1] * v1n; - diag->Row(0)[0] = l1; - diag->Row(0)[1] = l2; + diag[0] = l1; + diag[1] = l2; - U->Row(0)[0] = v1[1]; - U->Row(0)[1] = -v1[0]; - U->Row(1)[0] = v1[0]; - U->Row(1)[1] = v1[1]; + U[0][0] = v1[1]; + U[0][1] = -v1[0]; + U[1][0] = v1[0]; + U[1][1] = v1[1]; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_linalg.h b/third_party/jpeg-xl/lib/jxl/enc_linalg.h index 791770d5d4..b9a36c7ca1 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_linalg.h +++ b/third_party/jpeg-xl/lib/jxl/enc_linalg.h @@ -8,16 +8,16 @@ // Linear algebra. -#include "lib/jxl/base/compiler_specific.h" -#include "lib/jxl/image.h" +#include namespace jxl { -using ImageD = Plane; +typedef std::array Vector2; +// NB: matrix2x2[row][column] +typedef std::array Matrix2x2; // A is symmetric, U is orthogonal, and A = U * Diagonal(diag) * Transpose(U). -void ConvertToDiagonal(const ImageD& A, ImageD* JXL_RESTRICT diag, - ImageD* JXL_RESTRICT U); +void ConvertToDiagonal(const Matrix2x2& A, Vector2& diag, Matrix2x2& U); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc b/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc index 967b9a3afb..c02f009ca7 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_linalg_test.cc @@ -5,110 +5,78 @@ #include "lib/jxl/enc_linalg.h" -#include "lib/jxl/image_test_utils.h" +#include "lib/jxl/base/random.h" #include "lib/jxl/testing.h" namespace jxl { namespace { -ImageD Identity(const size_t N) { - ImageD out(N, N); - for (size_t i = 0; i < N; ++i) { - double* JXL_RESTRICT row = out.Row(i); - std::fill(row, row + N, 0); - row[i] = 1.0; - } - return out; -} +Matrix2x2 Diagonal(const Vector2& d) { return {{{d[0], 0.0}, {0.0, d[1]}}}; } -ImageD Diagonal(const ImageD& d) { - JXL_ASSERT(d.ysize() == 1); - ImageD out(d.xsize(), d.xsize()); - const double* JXL_RESTRICT row_diag = d.Row(0); - for (size_t k = 0; k < d.xsize(); ++k) { - double* JXL_RESTRICT row_out = out.Row(k); - std::fill(row_out, row_out + d.xsize(), 0.0); - row_out[k] = row_diag[k]; - } - return out; -} +Matrix2x2 Identity() { return Diagonal({1.0, 1.0}); } -ImageD MatMul(const ImageD& A, const ImageD& B) { - JXL_ASSERT(A.ysize() == B.xsize()); - ImageD out(A.xsize(), B.ysize()); - for (size_t y = 0; y < B.ysize(); ++y) { - const double* const JXL_RESTRICT row_b = B.Row(y); - double* const JXL_RESTRICT row_out = out.Row(y); - for (size_t x = 0; x < A.xsize(); ++x) { - row_out[x] = 0.0; - for (size_t k = 0; k < B.xsize(); ++k) { - row_out[x] += A.Row(k)[x] * row_b[k]; - } +Matrix2x2 MatMul(const Matrix2x2& A, const Matrix2x2& B) { + Matrix2x2 out; + for (size_t y = 0; y < 2; ++y) { + for (size_t x = 0; x < 2; ++x) { + out[y][x] = A[0][x] * B[y][0] + A[1][x] * B[y][1]; } } return out; } -ImageD Transpose(const ImageD& A) { - ImageD out(A.ysize(), A.xsize()); - for (size_t x = 0; x < A.xsize(); ++x) { - double* const JXL_RESTRICT row_out = out.Row(x); - for (size_t y = 0; y < A.ysize(); ++y) { - row_out[y] = A.Row(y)[x]; - } - } - return out; +Matrix2x2 Transpose(const Matrix2x2& A) { + return {{{A[0][0], A[1][0]}, {A[0][1], A[1][1]}}}; } -ImageD RandomSymmetricMatrix(const size_t N, Rng& rng, const double vmin, - const double vmax) { - ImageD A(N, N); - GenerateImage(rng, &A, vmin, vmax); - for (size_t i = 0; i < N; ++i) { - for (size_t j = 0; j < i; ++j) { - A.Row(j)[i] = A.Row(i)[j]; - } - } +Matrix2x2 RandomSymmetricMatrix(Rng& rng, const double vmin, + const double vmax) { + Matrix2x2 A; + A[0][0] = rng.UniformF(vmin, vmax); + A[0][1] = A[1][0] = rng.UniformF(vmin, vmax); + A[1][1] = rng.UniformF(vmin, vmax); return A; } -void VerifyMatrixEqual(const ImageD& A, const ImageD& B, const double eps) { - ASSERT_EQ(A.xsize(), B.xsize()); - ASSERT_EQ(A.ysize(), B.ysize()); - for (size_t y = 0; y < A.ysize(); ++y) { - for (size_t x = 0; x < A.xsize(); ++x) { - ASSERT_NEAR(A.Row(y)[x], B.Row(y)[x], eps); +void VerifyMatrixEqual(const Matrix2x2& A, const Matrix2x2& B, + const double eps) { + for (size_t y = 0; y < 2; ++y) { + for (size_t x = 0; x < 2; ++x) { + ASSERT_NEAR(A[y][x], B[y][x], eps); } } } -void VerifyOrthogonal(const ImageD& A, const double eps) { - VerifyMatrixEqual(Identity(A.xsize()), MatMul(Transpose(A), A), eps); +void VerifyOrthogonal(const Matrix2x2& A, const double eps) { + VerifyMatrixEqual(Identity(), MatMul(Transpose(A), A), eps); } TEST(LinAlgTest, ConvertToDiagonal) { { - ImageD I = Identity(2); - ImageD U(2, 2), d(2, 1); - ConvertToDiagonal(I, &d, &U); + Matrix2x2 I = Identity(); + Matrix2x2 U; + Vector2 d; + ConvertToDiagonal(I, d, U); VerifyMatrixEqual(I, U, 1e-15); for (size_t k = 0; k < 2; ++k) { - ASSERT_NEAR(d.Row(0)[k], 1.0, 1e-15); + ASSERT_NEAR(d[k], 1.0, 1e-15); } } { - ImageD A = Identity(2); - A.Row(0)[1] = A.Row(1)[0] = 2.0; - ImageD U(2, 2), d(2, 1); - ConvertToDiagonal(A, &d, &U); + Matrix2x2 A = Identity(); + A[0][1] = A[1][0] = 2.0; + Matrix2x2 U; + Vector2 d; + ConvertToDiagonal(A, d, U); VerifyOrthogonal(U, 1e-12); VerifyMatrixEqual(A, MatMul(U, MatMul(Diagonal(d), Transpose(U))), 1e-12); } Rng rng(0); for (size_t i = 0; i < 100; ++i) { - ImageD A = RandomSymmetricMatrix(2, rng, -1.0, 1.0); - ImageD U(2, 2), d(2, 1); - ConvertToDiagonal(A, &d, &U); + Matrix2x2 A = RandomSymmetricMatrix(rng, -1.0, 1.0); + Matrix2x2 U; + Vector2 d; + ConvertToDiagonal(A, d, U); VerifyOrthogonal(U, 1e-12); VerifyMatrixEqual(A, MatMul(U, MatMul(Diagonal(d), Transpose(U))), 1e-12); } diff --git a/third_party/jpeg-xl/lib/jxl/enc_modular.cc b/third_party/jpeg-xl/lib/jxl/enc_modular.cc index b8366953b7..dbd62d4a01 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_modular.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_modular.cc @@ -10,8 +10,8 @@ #include #include +#include #include -#include #include #include @@ -28,9 +28,9 @@ #include "lib/jxl/enc_params.h" #include "lib/jxl/enc_patch_dictionary.h" #include "lib/jxl/enc_quant_weights.h" +#include "lib/jxl/frame_dimensions.h" #include "lib/jxl/frame_header.h" #include "lib/jxl/modular/encoding/context_predict.h" -#include "lib/jxl/modular/encoding/enc_debug_tree.h" #include "lib/jxl/modular/encoding/enc_encoding.h" #include "lib/jxl/modular/encoding/encoding.h" #include "lib/jxl/modular/encoding/ma_common.h" @@ -38,7 +38,7 @@ #include "lib/jxl/modular/options.h" #include "lib/jxl/modular/transform/enc_transform.h" #include "lib/jxl/pack_signed.h" -#include "lib/jxl/toc.h" +#include "modular/options.h" namespace jxl { @@ -48,15 +48,15 @@ namespace { // Squeeze default quantization factors // these quantization factors are for -Q 50 (other qualities simply scale the // factors; things are rounded down and obviously cannot get below 1) -static const float squeeze_quality_factor = +const float squeeze_quality_factor = 0.35; // for easy tweaking of the quality range (decrease this number for // higher quality) -static const float squeeze_luma_factor = +const float squeeze_luma_factor = 1.1; // for easy tweaking of the balance between luma (or anything // non-chroma) and chroma (decrease this number for higher quality // luma) -static const float squeeze_quality_factor_xyb = 2.4f; -static const float squeeze_xyb_qtable[3][16] = { +const float squeeze_quality_factor_xyb = 2.4f; +const float squeeze_xyb_qtable[3][16] = { {163.84, 81.92, 40.96, 20.48, 10.24, 5.12, 2.56, 1.28, 0.64, 0.32, 0.16, 0.08, 0.04, 0.02, 0.01, 0.005}, // Y {1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.5, 0.5, 0.5, @@ -65,12 +65,12 @@ static const float squeeze_xyb_qtable[3][16] = { 0.5}, // B-Y }; -static const float squeeze_luma_qtable[16] = { - 163.84, 81.92, 40.96, 20.48, 10.24, 5.12, 2.56, 1.28, - 0.64, 0.32, 0.16, 0.08, 0.04, 0.02, 0.01, 0.005}; +const float squeeze_luma_qtable[16] = {163.84, 81.92, 40.96, 20.48, 10.24, 5.12, + 2.56, 1.28, 0.64, 0.32, 0.16, 0.08, + 0.04, 0.02, 0.01, 0.005}; // for 8-bit input, the range of YCoCg chroma is -255..255 so basically this // does 4:2:0 subsampling (two most fine grained layers get quantized away) -static const float squeeze_chroma_qtable[16] = { +const float squeeze_chroma_qtable[16] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.5, 0.5, 0.5, 0.5}; // Merges the trees in `trees` using nodes that decide on stream_id, as defined @@ -139,10 +139,12 @@ Status float_to_int(const float* const row_in, pixel_type* const row_out, } if (bits == 32 && fp) { JXL_ASSERT(exp_bits == 8); - memcpy((void*)row_out, (const void*)row_in, 4 * xsize); + memcpy(static_cast(row_out), static_cast(row_in), + 4 * xsize); return true; } + JXL_ASSERT(bits > 0); int exp_bias = (1 << (exp_bits - 1)) - 1; int max_exp = (1 << exp_bits) - 1; uint32_t sign = (1u << (bits - 1)); @@ -186,14 +188,144 @@ Status float_to_int(const float* const row_in, pixel_type* const row_out, f = (signbit ? sign : 0); f |= (exp << mant_bits); f |= mantissa; - row_out[x] = (pixel_type)f; + row_out[x] = static_cast(f); } return true; } + +float EstimateWPCost(const Image& img, size_t i) { + size_t extra_bits = 0; + float histo_cost = 0; + HybridUintConfig config; + int32_t cutoffs[] = {-500, -392, -255, -191, -127, -95, -63, -47, -31, + -23, -15, -11, -7, -4, -3, -1, 0, 1, + 3, 5, 7, 11, 15, 23, 31, 47, 63, + 95, 127, 191, 255, 392, 500}; + constexpr size_t nc = sizeof(cutoffs) / sizeof(*cutoffs) + 1; + Histogram histo[nc] = {}; + weighted::Header wp_header; + PredictorMode(i, &wp_header); + for (const Channel& ch : img.channel) { + const intptr_t onerow = ch.plane.PixelsPerRow(); + weighted::State wp_state(wp_header, ch.w, ch.h); + Properties properties(1); + for (size_t y = 0; y < ch.h; y++) { + const pixel_type* JXL_RESTRICT r = ch.Row(y); + for (size_t x = 0; x < ch.w; x++) { + size_t offset = 0; + pixel_type_w left = (x ? r[x - 1] : y ? *(r + x - onerow) : 0); + pixel_type_w top = (y ? *(r + x - onerow) : left); + pixel_type_w topleft = (x && y ? *(r + x - 1 - onerow) : left); + pixel_type_w topright = + (x + 1 < ch.w && y ? *(r + x + 1 - onerow) : top); + pixel_type_w toptop = (y > 1 ? *(r + x - onerow - onerow) : top); + pixel_type guess = wp_state.Predict( + x, y, ch.w, top, left, topright, topleft, toptop, &properties, + offset); + size_t ctx = 0; + for (int c : cutoffs) { + ctx += (c >= properties[0]) ? 1 : 0; + } + pixel_type res = r[x] - guess; + uint32_t token; + uint32_t nbits; + uint32_t bits; + config.Encode(PackSigned(res), &token, &nbits, &bits); + histo[ctx].Add(token); + extra_bits += nbits; + wp_state.UpdateErrors(r[x], x, y, ch.w); + } + } + for (auto& h : histo) { + histo_cost += h.ShannonEntropy(); + h.Clear(); + } + } + return histo_cost + extra_bits; +} + +float EstimateCost(const Image& img) { + // TODO(veluca): consider SIMDfication of this code. + size_t extra_bits = 0; + float histo_cost = 0; + HybridUintConfig config; + uint32_t cutoffs[] = {0, 1, 3, 5, 7, 11, 15, 23, 31, + 47, 63, 95, 127, 191, 255, 392, 500}; + constexpr size_t nc = sizeof(cutoffs) / sizeof(*cutoffs) + 1; + Histogram histo[nc] = {}; + for (const Channel& ch : img.channel) { + const intptr_t onerow = ch.plane.PixelsPerRow(); + for (size_t y = 0; y < ch.h; y++) { + const pixel_type* JXL_RESTRICT r = ch.Row(y); + for (size_t x = 0; x < ch.w; x++) { + pixel_type_w left = (x ? r[x - 1] : y ? *(r + x - onerow) : 0); + pixel_type_w top = (y ? *(r + x - onerow) : left); + pixel_type_w topleft = (x && y ? *(r + x - 1 - onerow) : left); + size_t maxdiff = std::max(std::max(left, top), topleft) - + std::min(std::min(left, top), topleft); + size_t ctx = 0; + for (uint32_t c : cutoffs) { + ctx += (c > maxdiff) ? 1 : 0; + } + pixel_type res = r[x] - ClampedGradient(top, left, topleft); + uint32_t token; + uint32_t nbits; + uint32_t bits; + config.Encode(PackSigned(res), &token, &nbits, &bits); + histo[ctx].Add(token); + extra_bits += nbits; + } + } + for (auto& h : histo) { + histo_cost += h.ShannonEntropy(); + h.Clear(); + } + } + return histo_cost + extra_bits; +} + +bool do_transform(Image& image, const Transform& tr, + const weighted::Header& wp_header, + jxl::ThreadPool* pool = nullptr, bool force_jxlart = false) { + Transform t = tr; + bool did_it = true; + if (force_jxlart) { + if (!t.MetaApply(image)) return false; + } else { + did_it = TransformForward(t, image, wp_header, pool); + } + if (did_it) image.transform.push_back(t); + return did_it; +} + +bool maybe_do_transform(Image& image, const Transform& tr, + const CompressParams& cparams, + const weighted::Header& wp_header, + jxl::ThreadPool* pool = nullptr, + bool force_jxlart = false) { + if (force_jxlart || cparams.speed_tier >= SpeedTier::kSquirrel) { + return do_transform(image, tr, wp_header, pool, force_jxlart); + } + float cost_before = EstimateCost(image); + bool did_it = do_transform(image, tr, wp_header, pool); + if (did_it) { + float cost_after = EstimateCost(image); + JXL_DEBUG_V(7, "Cost before: %f cost after: %f", cost_before, cost_after); + if (cost_after > cost_before) { + Transform t = image.transform.back(); + JXL_RETURN_IF_ERROR(t.Inverse(image, wp_header, pool)); + image.transform.pop_back(); + did_it = false; + } + } + return did_it; +} + } // namespace ModularFrameEncoder::ModularFrameEncoder(const FrameHeader& frame_header, - const CompressParams& cparams_orig) + const CompressParams& cparams_orig, + bool streaming_mode) : frame_dim_(frame_header.ToFrameDimensions()), cparams_(cparams_orig) { size_t num_streams = ModularStreamId::Num(frame_dim_, frame_header.passes.num_passes); @@ -253,10 +385,16 @@ ModularFrameEncoder::ModularFrameEncoder(const FrameHeader& frame_header, // Same, but for the non-Squeeze case. prop_order = {0, 1, 15, 9, 10, 11, 12, 13, 14, 2, 3, 4, 5, 6, 7, 8}; // if few groups, don't use group as a property - if (num_streams < 30 && cparams_.speed_tier > SpeedTier::kTortoise) { + if (num_streams < 30 && cparams_.speed_tier > SpeedTier::kTortoise && + cparams_orig.ModularPartIsLossless()) { prop_order.erase(prop_order.begin() + 1); } } + int max_properties = std::min( + cparams_.options.max_properties, + static_cast( + frame_header.nonserialized_metadata->m.num_extra_channels) + + (frame_header.encoding == FrameEncoding::kModular ? 2 : -1)); switch (cparams_.speed_tier) { case SpeedTier::kHare: cparams_.options.splitting_heuristics_properties.assign( @@ -278,6 +416,7 @@ ModularFrameEncoder::ModularFrameEncoder(const FrameHeader& frame_header, prop_order.begin(), prop_order.begin() + 10); cparams_.options.max_property_values = 96; break; + case SpeedTier::kGlacier: case SpeedTier::kTortoise: cparams_.options.splitting_heuristics_properties = prop_order; cparams_.options.max_property_values = 256; @@ -290,24 +429,36 @@ ModularFrameEncoder::ModularFrameEncoder(const FrameHeader& frame_header, } if (cparams_.speed_tier > SpeedTier::kTortoise) { // Gradient in previous channels. - for (int i = 0; i < cparams_.options.max_properties; i++) { + for (int i = 0; i < max_properties; i++) { cparams_.options.splitting_heuristics_properties.push_back( kNumNonrefProperties + i * 4 + 3); } } else { // All the extra properties in Tortoise mode. - for (int i = 0; i < cparams_.options.max_properties * 4; i++) { + for (int i = 0; i < max_properties * 4; i++) { cparams_.options.splitting_heuristics_properties.push_back( kNumNonrefProperties + i); } } } - if (cparams_.options.predictor == static_cast(-1)) { + if ((cparams_.options.predictor == Predictor::Average0 || + cparams_.options.predictor == Predictor::Average1 || + cparams_.options.predictor == Predictor::Average2 || + cparams_.options.predictor == Predictor::Average3 || + cparams_.options.predictor == Predictor::Average4 || + cparams_.options.predictor == Predictor::Weighted) && + !cparams_.ModularPartIsLossless()) { + // Lossy + Average/Weighted predictors does not work, so switch to default + // predictors. + cparams_.options.predictor = kUndefinedPredictor; + } + + if (cparams_.options.predictor == kUndefinedPredictor) { // no explicit predictor(s) given, set a good default - if ((cparams_.speed_tier <= SpeedTier::kTortoise || + if ((cparams_.speed_tier <= SpeedTier::kGlacier || cparams_.modular_mode == false) && - cparams_.IsLossless() && cparams_.responsive == false) { + cparams_.IsLossless() && cparams_.responsive == JXL_FALSE) { // TODO(veluca): allow all predictors that don't break residual // multipliers in lossy mode. cparams_.options.predictor = Predictor::Variable; @@ -354,48 +505,54 @@ ModularFrameEncoder::ModularFrameEncoder(const FrameHeader& frame_header, // TODO(veluca): figure out how to use different predictor sets per channel. stream_options_.resize(num_streams, cparams_.options); -} -bool do_transform(Image& image, const Transform& tr, - const weighted::Header& wp_header, - jxl::ThreadPool* pool = nullptr, bool force_jxlart = false) { - Transform t = tr; - bool did_it = true; - if (force_jxlart) { - if (!t.MetaApply(image)) return false; - } else { - did_it = TransformForward(t, image, wp_header, pool); + stream_options_[0] = cparams_.options; + if (cparams_.speed_tier == SpeedTier::kFalcon) { + stream_options_[0].tree_kind = ModularOptions::TreeKind::kWPFixedDC; + } else if (cparams_.speed_tier == SpeedTier::kThunder) { + stream_options_[0].tree_kind = ModularOptions::TreeKind::kGradientFixedDC; } - if (did_it) image.transform.push_back(t); - return did_it; + stream_options_[0].histogram_params = + HistogramParams::ForModular(cparams_, {}, streaming_mode); } Status ModularFrameEncoder::ComputeEncodingData( const FrameHeader& frame_header, const ImageMetadata& metadata, Image3F* JXL_RESTRICT color, const std::vector& extra_channels, - PassesEncoderState* JXL_RESTRICT enc_state, const JxlCmsInterface& cms, - ThreadPool* pool, AuxOut* aux_out, bool do_color) { + const Rect& group_rect, const FrameDimensions& patch_dim, + const Rect& frame_area_rect, PassesEncoderState* JXL_RESTRICT enc_state, + const JxlCmsInterface& cms, ThreadPool* pool, AuxOut* aux_out, + bool do_color) { JXL_DEBUG_V(6, "Computing modular encoding data for frame %s", frame_header.DebugString().c_str()); - if (do_color && frame_header.loop_filter.gab) { + bool groupwise = enc_state->streaming_mode; + + if (do_color && frame_header.loop_filter.gab && !groupwise) { float w = 0.9908511000000001f; float weights[3] = {w, w, w}; - GaborishInverse(color, Rect(*color), weights, pool); + JXL_RETURN_IF_ERROR(GaborishInverse(color, Rect(*color), weights, pool)); } if (do_color && metadata.bit_depth.bits_per_sample <= 16 && cparams_.speed_tier < SpeedTier::kCheetah && - cparams_.decoding_speed_tier < 2) { - FindBestPatchDictionary(*color, enc_state, cms, nullptr, aux_out, - cparams_.color_transform == ColorTransform::kXYB); + cparams_.decoding_speed_tier < 2 && !groupwise) { + JXL_RETURN_IF_ERROR(FindBestPatchDictionary( + *color, enc_state, cms, nullptr, aux_out, + cparams_.color_transform == ColorTransform::kXYB)); PatchDictionaryEncoder::SubtractFrom( enc_state->shared.image_features.patches, color); } + if (cparams_.custom_splines.HasAny()) { + PassesSharedState& shared = enc_state->shared; + ImageFeatures& image_features = shared.image_features; + image_features.splines = cparams_.custom_splines; + } + // Convert ImageBundle to modular Image object - const size_t xsize = frame_dim_.xsize; - const size_t ysize = frame_dim_.ysize; + const size_t xsize = patch_dim.xsize; + const size_t ysize = patch_dim.ysize; int nb_chans = 3; if (metadata.color_encoding.IsGray() && @@ -423,7 +580,9 @@ Status ModularFrameEncoder::ComputeEncodingData( int max_bitdepth = do_color ? metadata.bit_depth.bits_per_sample + (fp ? 0 : 1) : 0; Image& gi = stream_images_[0]; - gi = Image(xsize, ysize, metadata.bit_depth.bits_per_sample, nb_chans); + JXL_ASSIGN_OR_RETURN( + gi, Image::Create(xsize, ysize, metadata.bit_depth.bits_per_sample, + nb_chans)); int c = 0; if (cparams_.color_transform == ColorTransform::kXYB && cparams_.modular_mode == true) { @@ -478,17 +637,21 @@ Status ModularFrameEncoder::ComputeEncodingData( gi.channel[c_out].vshift = frame_header.chroma_subsampling.VShift(c); size_t xsize_shifted = DivCeil(xsize, 1 << gi.channel[c_out].hshift); size_t ysize_shifted = DivCeil(ysize, 1 << gi.channel[c_out].vshift); - gi.channel[c_out].shrink(xsize_shifted, ysize_shifted); + JXL_RETURN_IF_ERROR( + gi.channel[c_out].shrink(xsize_shifted, ysize_shifted)); std::atomic has_error{false}; JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, ysize_shifted, ThreadPool::NoInit, [&](const int task, const int thread) { + if (has_error) return; const size_t y = task; - const float* const JXL_RESTRICT row_in = color->PlaneRow(c, y); + const float* const JXL_RESTRICT row_in = + color->PlaneRow(c, y + group_rect.y0()) + group_rect.x0(); pixel_type* const JXL_RESTRICT row_out = gi.channel[c_out].Row(y); if (!float_to_int(row_in, row_out, xsize_shifted, bits, exp_bits, fp, factor)) { has_error = true; + return; }; }, "float2int")); @@ -505,8 +668,9 @@ Status ModularFrameEncoder::ComputeEncodingData( for (size_t ec = 0; ec < extra_channels.size(); ec++, c++) { const ExtraChannelInfo& eci = metadata.extra_channel_info[ec]; size_t ecups = frame_header.extra_channel_upsampling[ec]; - gi.channel[c].shrink(DivCeil(frame_dim_.xsize_upsampled, ecups), - DivCeil(frame_dim_.ysize_upsampled, ecups)); + JXL_RETURN_IF_ERROR( + gi.channel[c].shrink(DivCeil(patch_dim.xsize_upsampled, ecups), + DivCeil(patch_dim.ysize_upsampled, ecups))); gi.channel[c].hshift = gi.channel[c].vshift = CeilLog2Nonzero(ecups) - CeilLog2Nonzero(frame_header.upsampling); @@ -519,12 +683,15 @@ Status ModularFrameEncoder::ComputeEncodingData( JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, gi.channel[c].plane.ysize(), ThreadPool::NoInit, [&](const int task, const int thread) { + if (has_error) return; const size_t y = task; - const float* const JXL_RESTRICT row_in = extra_channels[ec].Row(y); + const float* const JXL_RESTRICT row_in = + extra_channels[ec].Row(y + group_rect.y0()) + group_rect.x0(); pixel_type* const JXL_RESTRICT row_out = gi.channel[c].Row(y); if (!float_to_int(row_in, row_out, gi.channel[c].plane.xsize(), bits, exp_bits, fp, factor)) { has_error = true; + return; }; }, "float2int")); @@ -533,11 +700,12 @@ Status ModularFrameEncoder::ComputeEncodingData( JXL_ASSERT(c == nb_chans); int level_max_bitdepth = (cparams_.level == 5 ? 16 : 32); - if (max_bitdepth > level_max_bitdepth) + if (max_bitdepth > level_max_bitdepth) { return JXL_FAILURE( "Bitdepth too high for level %i (need %i bits, have only %i in this " "level)", cparams_.level, max_bitdepth, level_max_bitdepth); + } // Set options and apply transformations if (!cparams_.ModularPartIsLossless()) { @@ -553,14 +721,14 @@ Status ModularFrameEncoder::ComputeEncodingData( } // Global palette - if (cparams_.palette_colors != 0 || cparams_.lossy_palette) { + if ((cparams_.palette_colors != 0 || cparams_.lossy_palette) && !groupwise) { // all-channel palette (e.g. RGBA) if (gi.channel.size() - gi.nb_meta_channels > 1) { Transform maybe_palette(TransformId::kPalette); maybe_palette.begin_c = gi.nb_meta_channels; maybe_palette.num_c = gi.channel.size() - gi.nb_meta_channels; - maybe_palette.nb_colors = - std::min((int)(xsize * ysize / 2), std::abs(cparams_.palette_colors)); + maybe_palette.nb_colors = std::min(static_cast(xsize * ysize / 2), + std::abs(cparams_.palette_colors)); maybe_palette.ordered_palette = cparams_.palette_colors >= 0; maybe_palette.lossy_palette = (cparams_.lossy_palette && maybe_palette.num_c == 3); @@ -569,8 +737,8 @@ Status ModularFrameEncoder::ComputeEncodingData( } // TODO(veluca): use a custom weighted header if using the weighted // predictor. - do_transform(gi, maybe_palette, weighted::Header(), pool, - cparams_.options.zero_tokens); + maybe_do_transform(gi, maybe_palette, cparams_, weighted::Header(), pool, + cparams_.options.zero_tokens); } // all-minus-one-channel palette (RGB with separate alpha, or CMY with // separate K) @@ -578,20 +746,20 @@ Status ModularFrameEncoder::ComputeEncodingData( Transform maybe_palette_3(TransformId::kPalette); maybe_palette_3.begin_c = gi.nb_meta_channels; maybe_palette_3.num_c = gi.channel.size() - gi.nb_meta_channels - 1; - maybe_palette_3.nb_colors = - std::min((int)(xsize * ysize / 3), std::abs(cparams_.palette_colors)); + maybe_palette_3.nb_colors = std::min(static_cast(xsize * ysize / 3), + std::abs(cparams_.palette_colors)); maybe_palette_3.ordered_palette = cparams_.palette_colors >= 0; maybe_palette_3.lossy_palette = cparams_.lossy_palette; if (maybe_palette_3.lossy_palette) { maybe_palette_3.predictor = delta_pred_; } - do_transform(gi, maybe_palette_3, weighted::Header(), pool, - cparams_.options.zero_tokens); + maybe_do_transform(gi, maybe_palette_3, cparams_, weighted::Header(), + pool, cparams_.options.zero_tokens); } } // Global channel palette - if (cparams_.channel_colors_pre_transform_percent > 0 && + if (!groupwise && cparams_.channel_colors_pre_transform_percent > 0 && !cparams_.lossy_palette && (cparams_.speed_tier <= SpeedTier::kThunder || (do_color && metadata.bit_depth.bits_per_sample > 8))) { @@ -600,9 +768,10 @@ Status ModularFrameEncoder::ComputeEncodingData( int orig_bitdepth = max_bitdepth; max_bitdepth = 0; for (size_t i = 0; i < nb_channels; i++) { - int32_t min, max; + int32_t min; + int32_t max; compute_minmax(gi.channel[gi.nb_meta_channels + i], &min, &max); - int64_t colors = (int64_t)max - min + 1; + int64_t colors = static_cast(max) - min + 1; JXL_DEBUG_V(10, "Channel %" PRIuS ": range=%i..%i", i, min, max); Transform maybe_palette_1(TransformId::kPalette); maybe_palette_1.begin_c = i + gi.nb_meta_channels; @@ -612,9 +781,11 @@ Status ModularFrameEncoder::ComputeEncodingData( // (but only if the channel palette is less than 6% the size of the // image itself) maybe_palette_1.nb_colors = std::min( - (int)(xsize * ysize / 16), - (int)(cparams_.channel_colors_pre_transform_percent / 100. * colors)); - if (do_transform(gi, maybe_palette_1, weighted::Header(), pool)) { + static_cast(xsize * ysize / 16), + static_cast(cparams_.channel_colors_pre_transform_percent / + 100. * colors)); + if (maybe_do_transform(gi, maybe_palette_1, cparams_, weighted::Header(), + pool)) { // effective bit depth is lower, adjust quantization accordingly compute_minmax(gi.channel[gi.nb_meta_channels + i], &min, &max); if (max < maxval) maxval = max; @@ -646,8 +817,28 @@ Status ModularFrameEncoder::ComputeEncodingData( } } + if (cparams_.move_to_front_from_channel > 0) { + for (size_t tgt = 0; + tgt + cparams_.move_to_front_from_channel < gi.channel.size(); tgt++) { + size_t pos = cparams_.move_to_front_from_channel; + while (pos > 0) { + Transform move(TransformId::kRCT); + if (pos == 1) { + move.begin_c = tgt; + move.rct_type = 28; // RGB -> GRB + pos -= 1; + } else { + move.begin_c = tgt + pos - 2; + move.rct_type = 14; // RGB -> BRG + pos -= 2; + } + do_transform(gi, move, weighted::Header(), pool); + } + } + } + // don't do squeeze if we don't have some spare bits - if (cparams_.responsive && !gi.channel.empty() && + if (!groupwise && cparams_.responsive && !gi.channel.empty() && max_bitdepth + 2 < level_max_bitdepth) { Transform t(TransformId::kSqueeze); do_transform(gi, t, weighted::Header(), pool); @@ -674,8 +865,8 @@ Status ModularFrameEncoder::ComputeEncodingData( bitdepth_correction = maxval / 255.f; } std::vector quantizers; - float dist = cparams_.butteraugli_distance; for (size_t i = 0; i < 3; i++) { + float dist = cparams_.butteraugli_distance; quantizers.push_back(quantizer * dist * bitdepth_correction); } for (size_t i = 0; i < extra_channels.size(); i++) { @@ -683,6 +874,7 @@ Status ModularFrameEncoder::ComputeEncodingData( metadata.extra_channel_info[i].bit_depth.bits_per_sample; pixel_type ec_maxval = ec_bitdepth < 32 ? (1u << ec_bitdepth) - 1 : 0; bitdepth_correction = ec_maxval / 255.f; + float dist = 0; if (i < cparams_.ec_distance.size()) dist = cparams_.ec_distance[i]; if (dist < 0) dist = cparams_.butteraugli_distance; quantizers.push_back(quantizer * dist * bitdepth_correction); @@ -722,57 +914,57 @@ Status ModularFrameEncoder::ComputeEncodingData( } // Fill other groups. - struct GroupParams { - Rect rect; - int minShift; - int maxShift; - ModularStreamId id; - }; - std::vector stream_params; - - stream_options_[0] = cparams_.options; - // DC - for (size_t group_id = 0; group_id < frame_dim_.num_dc_groups; group_id++) { - const size_t gx = group_id % frame_dim_.xsize_dc_groups; - const size_t gy = group_id / frame_dim_.xsize_dc_groups; - const Rect rect(gx * frame_dim_.dc_group_dim, gy * frame_dim_.dc_group_dim, - frame_dim_.dc_group_dim, frame_dim_.dc_group_dim); + for (size_t group_id = 0; group_id < patch_dim.num_dc_groups; group_id++) { + const size_t rgx = group_id % patch_dim.xsize_dc_groups; + const size_t rgy = group_id / patch_dim.xsize_dc_groups; + const Rect rect(rgx * patch_dim.dc_group_dim, rgy * patch_dim.dc_group_dim, + patch_dim.dc_group_dim, patch_dim.dc_group_dim); + size_t gx = rgx + frame_area_rect.x0() / 2048; + size_t gy = rgy + frame_area_rect.y0() / 2048; + size_t real_group_id = gy * frame_dim_.xsize_dc_groups + gx; // minShift==3 because (frame_dim.dc_group_dim >> 3) == frame_dim.group_dim // maxShift==1000 is infinity - stream_params.push_back( - GroupParams{rect, 3, 1000, ModularStreamId::ModularDC(group_id)}); + stream_params_.push_back( + GroupParams{rect, 3, 1000, ModularStreamId::ModularDC(real_group_id)}); } // AC global -> nothing. // AC - for (size_t group_id = 0; group_id < frame_dim_.num_groups; group_id++) { - const size_t gx = group_id % frame_dim_.xsize_groups; - const size_t gy = group_id / frame_dim_.xsize_groups; - const Rect mrect(gx * frame_dim_.group_dim, gy * frame_dim_.group_dim, - frame_dim_.group_dim, frame_dim_.group_dim); + for (size_t group_id = 0; group_id < patch_dim.num_groups; group_id++) { + const size_t rgx = group_id % patch_dim.xsize_groups; + const size_t rgy = group_id / patch_dim.xsize_groups; + const Rect mrect(rgx * patch_dim.group_dim, rgy * patch_dim.group_dim, + patch_dim.group_dim, patch_dim.group_dim); + size_t gx = rgx + frame_area_rect.x0() / (frame_dim_.group_dim); + size_t gy = rgy + frame_area_rect.y0() / (frame_dim_.group_dim); + size_t real_group_id = gy * frame_dim_.xsize_groups + gx; for (size_t i = 0; i < enc_state->progressive_splitter.GetNumPasses(); i++) { - int maxShift, minShift; + int maxShift; + int minShift; frame_header.passes.GetDownsamplingBracket(i, minShift, maxShift); - stream_params.push_back(GroupParams{ - mrect, minShift, maxShift, ModularStreamId::ModularAC(group_id, i)}); + stream_params_.push_back( + GroupParams{mrect, minShift, maxShift, + ModularStreamId::ModularAC(real_group_id, i)}); } } // if there's only one group, everything ends up in GlobalModular // in that case, also try RCTs/WP params for the one group - if (stream_params.size() == 2) { - stream_params.push_back(GroupParams{Rect(0, 0, xsize, ysize), 0, 1000, - ModularStreamId::Global()}); + if (stream_params_.size() == 2) { + stream_params_.push_back(GroupParams{Rect(0, 0, xsize, ysize), 0, 1000, + ModularStreamId::Global()}); } gi_channel_.resize(stream_images_.size()); JXL_RETURN_IF_ERROR(RunOnPool( - pool, 0, stream_params.size(), ThreadPool::NoInit, + pool, 0, stream_params_.size(), ThreadPool::NoInit, [&](const uint32_t i, size_t /* thread */) { - stream_options_[stream_params[i].id.ID(frame_dim_)] = cparams_.options; + size_t stream = stream_params_[i].id.ID(frame_dim_); + stream_options_[stream] = stream_options_[0]; JXL_CHECK(PrepareStreamParams( - stream_params[i].rect, cparams_, stream_params[i].minShift, - stream_params[i].maxShift, stream_params[i].id, do_color)); + stream_params_[i].rect, cparams_, stream_params_[i].minShift, + stream_params_[i].maxShift, stream_params_[i].id, do_color, + groupwise)); }, "ChooseParams")); { @@ -821,7 +1013,7 @@ Status ModularFrameEncoder::ComputeTree(ThreadPool* pool) { StaticPropRange range; range[0] = {{i, i + 1}}; range[1] = {{stream_id, stream_id + 1}}; - multiplier_info.push_back({range, (uint32_t)q}); + multiplier_info.push_back({range, static_cast(q)}); } else { // Previous channel in the same group had the same quantization // factor. Don't provide two different ranges, as that creates @@ -922,11 +1114,10 @@ Status ModularFrameEncoder::ComputeTree(ThreadPool* pool) { StaticPropRange range; range[0] = {{0, max_c}}; range[1] = {{start, stop}}; - auto local_multiplier_info = multiplier_info; tree_samples.PreQuantizeProperties( - range, local_multiplier_info, group_pixel_count, - channel_pixel_count, pixel_samples, diff_samples, + range, multiplier_info, group_pixel_count, channel_pixel_count, + pixel_samples, diff_samples, stream_options_[start].max_property_values); for (size_t i = start; i < stop; i++) { JXL_CHECK(ModularGenericCompress( @@ -937,7 +1128,7 @@ Status ModularFrameEncoder::ComputeTree(ThreadPool* pool) { // TODO(veluca): parallelize more. trees[chunk] = LearnTree(std::move(tree_samples), total_pixels, - stream_options_[start], local_multiplier_info, range); + stream_options_[start], multiplier_info, range); }, "LearnTrees")); if (invalid_force_wp.test_and_set(std::memory_order_acq_rel)) { @@ -966,7 +1157,7 @@ Status ModularFrameEncoder::ComputeTree(ThreadPool* pool) { tree_tokens_.resize(1); tree_tokens_[0].clear(); Tree decoded_tree; - TokenizeTree(tree_, &tree_tokens_[0], &decoded_tree); + TokenizeTree(tree_, tree_tokens_.data(), &decoded_tree); JXL_ASSERT(tree_.size() == decoded_tree.size()); tree_ = std::move(decoded_tree); @@ -1019,46 +1210,8 @@ Status ModularFrameEncoder::EncodeGlobalInfo(bool streaming_mode, allotment.ReclaimAndCharge(writer, kLayerModularTree, aux_out); // Write tree - HistogramParams params; - if (cparams_.speed_tier > SpeedTier::kKitten) { - params.clustering = HistogramParams::ClusteringType::kFast; - params.ans_histogram_strategy = - cparams_.speed_tier > SpeedTier::kThunder - ? HistogramParams::ANSHistogramStrategy::kFast - : HistogramParams::ANSHistogramStrategy::kApproximate; - params.lz77_method = - cparams_.decoding_speed_tier >= 3 && cparams_.modular_mode - ? (cparams_.speed_tier >= SpeedTier::kFalcon - ? HistogramParams::LZ77Method::kRLE - : HistogramParams::LZ77Method::kLZ77) - : HistogramParams::LZ77Method::kNone; - // Near-lossless DC, as well as modular mode, require choosing hybrid uint - // more carefully. - if ((!extra_dc_precision.empty() && extra_dc_precision[0] != 0) || - (cparams_.modular_mode && cparams_.speed_tier < SpeedTier::kCheetah)) { - params.uint_method = HistogramParams::HybridUintMethod::kFast; - } else { - params.uint_method = HistogramParams::HybridUintMethod::kNone; - } - } else if (cparams_.speed_tier <= SpeedTier::kTortoise) { - params.lz77_method = HistogramParams::LZ77Method::kOptimal; - } else { - params.lz77_method = HistogramParams::LZ77Method::kLZ77; - } - if (cparams_.decoding_speed_tier >= 1) { - params.max_histograms = 12; - } - if (cparams_.decoding_speed_tier >= 1 && cparams_.responsive) { - params.lz77_method = cparams_.speed_tier >= SpeedTier::kCheetah - ? HistogramParams::LZ77Method::kRLE - : cparams_.speed_tier >= SpeedTier::kKitten - ? HistogramParams::LZ77Method::kLZ77 - : HistogramParams::LZ77Method::kOptimal; - } - if (cparams_.decoding_speed_tier >= 2 && cparams_.responsive) { - params.uint_method = HistogramParams::HybridUintMethod::k000; - params.force_huffman = true; - } + HistogramParams params = + HistogramParams::ForModular(cparams_, extra_dc_precision, streaming_mode); { EntropyEncodingData tree_code; std::vector tree_context_map; @@ -1082,6 +1235,7 @@ Status ModularFrameEncoder::EncodeStream(BitWriter* writer, AuxOut* aux_out, const ModularStreamId& stream) { size_t stream_id = stream.ID(frame_dim_); if (stream_images_[stream_id].channel.empty()) { + JXL_DEBUG_V(10, "Modular stream %" PRIuS " is empty.", stream_id); return true; // Image with no channels, header never gets decoded. } if (tokens_.empty()) { @@ -1103,113 +1257,44 @@ void ModularFrameEncoder::ClearStreamData(const ModularStreamId& stream) { std::swap(stream_images_[stream_id], empty_image); } -namespace { -float EstimateWPCost(const Image& img, size_t i) { - size_t extra_bits = 0; - float histo_cost = 0; - HybridUintConfig config; - int32_t cutoffs[] = {-500, -392, -255, -191, -127, -95, -63, -47, -31, - -23, -15, -11, -7, -4, -3, -1, 0, 1, - 3, 5, 7, 11, 15, 23, 31, 47, 63, - 95, 127, 191, 255, 392, 500}; - constexpr size_t nc = sizeof(cutoffs) / sizeof(*cutoffs) + 1; - Histogram histo[nc] = {}; - weighted::Header wp_header; - PredictorMode(i, &wp_header); - for (const Channel& ch : img.channel) { - const intptr_t onerow = ch.plane.PixelsPerRow(); - weighted::State wp_state(wp_header, ch.w, ch.h); - Properties properties(1); - for (size_t y = 0; y < ch.h; y++) { - const pixel_type* JXL_RESTRICT r = ch.Row(y); - for (size_t x = 0; x < ch.w; x++) { - size_t offset = 0; - pixel_type_w left = (x ? r[x - 1] : y ? *(r + x - onerow) : 0); - pixel_type_w top = (y ? *(r + x - onerow) : left); - pixel_type_w topleft = (x && y ? *(r + x - 1 - onerow) : left); - pixel_type_w topright = - (x + 1 < ch.w && y ? *(r + x + 1 - onerow) : top); - pixel_type_w toptop = (y > 1 ? *(r + x - onerow - onerow) : top); - pixel_type guess = wp_state.Predict( - x, y, ch.w, top, left, topright, topleft, toptop, &properties, - offset); - size_t ctx = 0; - for (int c : cutoffs) { - ctx += c >= properties[0]; - } - pixel_type res = r[x] - guess; - uint32_t token, nbits, bits; - config.Encode(PackSigned(res), &token, &nbits, &bits); - histo[ctx].Add(token); - extra_bits += nbits; - wp_state.UpdateErrors(r[x], x, y, ch.w); - } - } - for (size_t h = 0; h < nc; h++) { - histo_cost += histo[h].ShannonEntropy(); - histo[h].Clear(); - } +void ModularFrameEncoder::ClearModularStreamData() { + for (const auto& group : stream_params_) { + ClearStreamData(group.id); } - return histo_cost + extra_bits; + stream_params_.clear(); } -float EstimateCost(const Image& img) { - // TODO(veluca): consider SIMDfication of this code. - size_t extra_bits = 0; - float histo_cost = 0; - HybridUintConfig config; - uint32_t cutoffs[] = {0, 1, 3, 5, 7, 11, 15, 23, 31, - 47, 63, 95, 127, 191, 255, 392, 500}; - constexpr size_t nc = sizeof(cutoffs) / sizeof(*cutoffs) + 1; - Histogram histo[nc] = {}; - for (const Channel& ch : img.channel) { - const intptr_t onerow = ch.plane.PixelsPerRow(); - for (size_t y = 0; y < ch.h; y++) { - const pixel_type* JXL_RESTRICT r = ch.Row(y); - for (size_t x = 0; x < ch.w; x++) { - pixel_type_w left = (x ? r[x - 1] : y ? *(r + x - onerow) : 0); - pixel_type_w top = (y ? *(r + x - onerow) : left); - pixel_type_w topleft = (x && y ? *(r + x - 1 - onerow) : left); - size_t maxdiff = std::max(std::max(left, top), topleft) - - std::min(std::min(left, top), topleft); - size_t ctx = 0; - for (uint32_t c : cutoffs) { - ctx += c > maxdiff; - } - pixel_type res = r[x] - ClampedGradient(top, left, topleft); - uint32_t token, nbits, bits; - config.Encode(PackSigned(res), &token, &nbits, &bits); - histo[ctx].Add(token); - extra_bits += nbits; - } - } - for (size_t h = 0; h < nc; h++) { - histo_cost += histo[h].ShannonEntropy(); - histo[h].Clear(); - } - } - return histo_cost + extra_bits; +size_t ModularFrameEncoder::ComputeStreamingAbsoluteAcGroupId( + size_t dc_group_id, size_t ac_group_id, + const FrameDimensions& patch_dim) const { + size_t dc_group_x = dc_group_id % frame_dim_.xsize_dc_groups; + size_t dc_group_y = dc_group_id / frame_dim_.xsize_dc_groups; + size_t ac_group_x = ac_group_id % patch_dim.xsize_groups; + size_t ac_group_y = ac_group_id / patch_dim.xsize_groups; + return (dc_group_x * 8 + ac_group_x) + + (dc_group_y * 8 + ac_group_y) * frame_dim_.xsize_groups; } -} // namespace - Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, const CompressParams& cparams_, int minShift, int maxShift, const ModularStreamId& stream, - bool do_color) { + bool do_color, bool groupwise) { size_t stream_id = stream.ID(frame_dim_); Image& full_image = stream_images_[0]; const size_t xsize = rect.xsize(); const size_t ysize = rect.ysize(); Image& gi = stream_images_[stream_id]; if (stream_id > 0) { - gi = Image(xsize, ysize, full_image.bitdepth, 0); + JXL_ASSIGN_OR_RETURN(gi, + Image::Create(xsize, ysize, full_image.bitdepth, 0)); // start at the first bigger-than-frame_dim.group_dim non-metachannel size_t c = full_image.nb_meta_channels; - for (; c < full_image.channel.size(); c++) { - Channel& fc = full_image.channel[c]; - if (fc.w > frame_dim_.group_dim || fc.h > frame_dim_.group_dim) break; + if (!groupwise) { + for (; c < full_image.channel.size(); c++) { + Channel& fc = full_image.channel[c]; + if (fc.w > frame_dim_.group_dim || fc.h > frame_dim_.group_dim) break; + } } for (; c < full_image.channel.size(); c++) { Channel& fc = full_image.channel[c]; @@ -1220,7 +1305,7 @@ Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, rect.xsize() >> fc.hshift, rect.ysize() >> fc.vshift, fc.w, fc.h); if (r.xsize() == 0 || r.ysize() == 0) continue; gi_channel_[stream_id].push_back(c); - Channel gc(r.xsize(), r.ysize()); + JXL_ASSIGN_OR_RETURN(Channel gc, Channel::Create(r.xsize(), r.ysize())); gc.hshift = fc.hshift; gc.vshift = fc.vshift; for (size_t y = 0; y < r.ysize(); ++y) { @@ -1245,7 +1330,7 @@ Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, maybe_palette.num_c = gi.channel.size() - gi.nb_meta_channels; maybe_palette.nb_colors = std::abs(cparams_.palette_colors); maybe_palette.ordered_palette = cparams_.palette_colors >= 0; - do_transform(gi, maybe_palette, weighted::Header()); + maybe_do_transform(gi, maybe_palette, cparams_, weighted::Header()); } // all-minus-one-channel palette (RGB with separate alpha, or CMY with // separate K) @@ -1259,7 +1344,7 @@ Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, if (maybe_palette_3.lossy_palette) { maybe_palette_3.predictor = Predictor::Weighted; } - do_transform(gi, maybe_palette_3, weighted::Header()); + maybe_do_transform(gi, maybe_palette_3, cparams_, weighted::Header()); } } @@ -1271,9 +1356,10 @@ Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, // single channel palette (like FLIF's ChannelCompact) size_t nb_channels = gi.channel.size() - gi.nb_meta_channels; for (size_t i = 0; i < nb_channels; i++) { - int32_t min, max; + int32_t min; + int32_t max; compute_minmax(gi.channel[gi.nb_meta_channels + i], &min, &max); - int64_t colors = (int64_t)max - min + 1; + int64_t colors = static_cast(max) - min + 1; JXL_DEBUG_V(10, "Channel %" PRIuS ": range=%i..%i", i, min, max); Transform maybe_palette_1(TransformId::kPalette); maybe_palette_1.begin_c = i + gi.nb_meta_channels; @@ -1282,10 +1368,10 @@ Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, // actually occur, it is probably worth it to do a compaction // (but only if the channel palette is less than 80% the size of the // image itself) - maybe_palette_1.nb_colors = - std::min((int)(xsize * ysize * 0.8), - (int)(cparams_.channel_colors_percent / 100. * colors)); - do_transform(gi, maybe_palette_1, weighted::Header()); + maybe_palette_1.nb_colors = std::min( + static_cast(xsize * ysize * 0.8), + static_cast(cparams_.channel_colors_percent / 100. * colors)); + maybe_do_transform(gi, maybe_palette_1, cparams_, weighted::Header()); } } } @@ -1295,7 +1381,7 @@ Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, if (cparams_.color_transform == ColorTransform::kNone && cparams_.IsLossless() && cparams_.colorspace < 0 && gi.channel.size() - gi.nb_meta_channels >= 3 && - cparams_.responsive == false && do_color && + cparams_.responsive == JXL_FALSE && do_color && cparams_.speed_tier <= SpeedTier::kHare) { Transform sg(TransformId::kRCT); sg.begin_c = gi.nb_meta_channels; @@ -1319,6 +1405,7 @@ Status ModularFrameEncoder::PrepareStreamParams(const Rect& rect, case SpeedTier::kKitten: nb_rcts_to_try = 9; break; + case SpeedTier::kTectonicPlate: case SpeedTier::kGlacier: case SpeedTier::kTortoise: nb_rcts_to_try = 19; @@ -1403,11 +1490,11 @@ int QuantizeGradient(const int32_t* qrow, size_t onerow, size_t c, size_t x, return residual + pred.guess; } -void ModularFrameEncoder::AddVarDCTDC(const FrameHeader& frame_header, - const Image3F& dc, const Rect& r, - size_t group_index, bool nl_dc, - PassesEncoderState* enc_state, - bool jpeg_transcode) { +Status ModularFrameEncoder::AddVarDCTDC(const FrameHeader& frame_header, + const Image3F& dc, const Rect& r, + size_t group_index, bool nl_dc, + PassesEncoderState* enc_state, + bool jpeg_transcode) { extra_dc_precision[group_index] = nl_dc ? 1 : 0; float mul = 1 << extra_dc_precision[group_index]; @@ -1430,8 +1517,11 @@ void ModularFrameEncoder::AddVarDCTDC(const FrameHeader& frame_header, stream_options_[stream_id].tree_kind = ModularOptions::TreeKind::kGradientFixedDC; } + stream_options_[stream_id].histogram_params = + stream_options_[0].histogram_params; - stream_images_[stream_id] = Image(r.xsize(), r.ysize(), 8, 3); + JXL_ASSIGN_OR_RETURN(stream_images_[stream_id], + Image::Create(r.xsize(), r.ysize(), 8, 3)); if (nl_dc && stream_options_[stream_id].tree_kind == ModularOptions::TreeKind::kGradientFixedDC) { JXL_ASSERT(frame_header.chroma_subsampling.Is444()); @@ -1531,7 +1621,7 @@ void ModularFrameEncoder::AddVarDCTDC(const FrameHeader& frame_header, Channel& ch = stream_images_[stream_id].channel[c < 2 ? c ^ 1 : c]; ch.w = xs; ch.h = ys; - ch.shrink(); + JXL_RETURN_IF_ERROR(ch.shrink()); for (size_t y = 0; y < ys; y++) { int32_t* quant_row = ch.plane.Row(y); const float* row = rect.ConstPlaneRow(dc, c, y); @@ -1546,14 +1636,17 @@ void ModularFrameEncoder::AddVarDCTDC(const FrameHeader& frame_header, stream_images_[stream_id], enc_state->shared.quantizer.MulDC(), 1.0 / mul, enc_state->shared.cmap.DCFactors(), frame_header.chroma_subsampling, enc_state->shared.block_ctx_map); + return true; } -void ModularFrameEncoder::AddACMetadata(const Rect& r, size_t group_index, - bool jpeg_transcode, - PassesEncoderState* enc_state) { +Status ModularFrameEncoder::AddACMetadata(const Rect& r, size_t group_index, + bool jpeg_transcode, + PassesEncoderState* enc_state) { size_t stream_id = ModularStreamId::ACMetadata(group_index).ID(frame_dim_); stream_options_[stream_id].max_chan_size = 0xFFFFFF; - stream_options_[stream_id].wp_tree_mode = ModularOptions::TreeMode::kNoWP; + if (stream_options_[stream_id].predictor != Predictor::Weighted) { + stream_options_[stream_id].wp_tree_mode = ModularOptions::TreeMode::kNoWP; + } if (jpeg_transcode) { stream_options_[stream_id].tree_kind = ModularOptions::TreeKind::kJpegTranscodeACMeta; @@ -1569,14 +1662,19 @@ void ModularFrameEncoder::AddACMetadata(const Rect& r, size_t group_index, cparams_.force_cfl_jpeg_recompression) { stream_options_[stream_id].tree_kind = ModularOptions::TreeKind::kLearn; } + stream_options_[stream_id].histogram_params = + stream_options_[0].histogram_params; // YToX, YToB, ACS + QF, EPF Image& image = stream_images_[stream_id]; - image = Image(r.xsize(), r.ysize(), 8, 4); + JXL_ASSIGN_OR_RETURN(image, Image::Create(r.xsize(), r.ysize(), 8, 4)); static_assert(kColorTileDimInBlocks == 8, "Color tile size changed"); Rect cr(r.x0() >> 3, r.y0() >> 3, (r.xsize() + 7) >> 3, (r.ysize() + 7) >> 3); - image.channel[0] = Channel(cr.xsize(), cr.ysize(), 3, 3); - image.channel[1] = Channel(cr.xsize(), cr.ysize(), 3, 3); - image.channel[2] = Channel(r.xsize() * r.ysize(), 2, 0, 0); + JXL_ASSIGN_OR_RETURN(image.channel[0], + Channel::Create(cr.xsize(), cr.ysize(), 3, 3)); + JXL_ASSIGN_OR_RETURN(image.channel[1], + Channel::Create(cr.xsize(), cr.ysize(), 3, 3)); + JXL_ASSIGN_OR_RETURN(image.channel[2], + Channel::Create(r.xsize() * r.ysize(), 2, 0, 0)); ConvertPlaneAndClamp(cr, enc_state->shared.cmap.ytox_map, Rect(image.channel[0].plane), &image.channel[0].plane); ConvertPlaneAndClamp(cr, enc_state->shared.cmap.ytob_map, @@ -1599,9 +1697,10 @@ void ModularFrameEncoder::AddACMetadata(const Rect& r, size_t group_index, } image.channel[2].w = num; ac_metadata_size[group_index] = num; + return true; } -void ModularFrameEncoder::EncodeQuantTable( +Status ModularFrameEncoder::EncodeQuantTable( size_t size_x, size_t size_y, BitWriter* writer, const QuantEncoding& encoding, size_t idx, ModularFrameEncoder* modular_frame_encoder) { @@ -1611,9 +1710,9 @@ void ModularFrameEncoder::EncodeQuantTable( if (modular_frame_encoder) { JXL_CHECK(modular_frame_encoder->EncodeStream( writer, nullptr, 0, ModularStreamId::QuantTable(idx))); - return; + return true; } - Image image(size_x, size_y, 8, 3); + JXL_ASSIGN_OR_RETURN(Image image, Image::Create(size_x, size_y, 8, 3)); for (size_t c = 0; c < 3; c++) { for (size_t y = 0; y < size_y; y++) { int32_t* JXL_RESTRICT row = image.channel[c].Row(y); @@ -1624,16 +1723,17 @@ void ModularFrameEncoder::EncodeQuantTable( } ModularOptions cfopts; JXL_CHECK(ModularGenericCompress(image, cfopts, writer)); + return true; } -void ModularFrameEncoder::AddQuantTable(size_t size_x, size_t size_y, - const QuantEncoding& encoding, - size_t idx) { +Status ModularFrameEncoder::AddQuantTable(size_t size_x, size_t size_y, + const QuantEncoding& encoding, + size_t idx) { size_t stream_id = ModularStreamId::QuantTable(idx).ID(frame_dim_); JXL_ASSERT(encoding.qraw.qtable != nullptr); JXL_ASSERT(size_x * size_y * 3 == encoding.qraw.qtable->size()); Image& image = stream_images_[stream_id]; - image = Image(size_x, size_y, 8, 3); + JXL_ASSIGN_OR_RETURN(image, Image::Create(size_x, size_y, 8, 3)); for (size_t c = 0; c < 3; c++) { for (size_t y = 0; y < size_y; y++) { int32_t* JXL_RESTRICT row = image.channel[c].Row(y); @@ -1642,5 +1742,6 @@ void ModularFrameEncoder::AddQuantTable(size_t size_x, size_t size_y, } } } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_modular.h b/third_party/jpeg-xl/lib/jxl/enc_modular.h index 2158a781af..8e2015b226 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_modular.h +++ b/third_party/jpeg-xl/lib/jxl/enc_modular.h @@ -6,18 +6,29 @@ #ifndef LIB_JXL_ENC_MODULAR_H_ #define LIB_JXL_ENC_MODULAR_H_ +#include + +#include #include +#include +#include "lib/jxl/base/compiler_specific.h" +#include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" #include "lib/jxl/dec_modular.h" +#include "lib/jxl/enc_ans.h" #include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_cache.h" #include "lib/jxl/enc_params.h" +#include "lib/jxl/frame_dimensions.h" #include "lib/jxl/frame_header.h" #include "lib/jxl/image.h" -#include "lib/jxl/image_bundle.h" +#include "lib/jxl/image_metadata.h" +#include "lib/jxl/modular/encoding/dec_ma.h" #include "lib/jxl/modular/encoding/encoding.h" #include "lib/jxl/modular/modular_image.h" +#include "lib/jxl/modular/options.h" +#include "lib/jxl/quant_weights.h" namespace jxl { @@ -26,14 +37,14 @@ struct AuxOut; class ModularFrameEncoder { public: ModularFrameEncoder(const FrameHeader& frame_header, - const CompressParams& cparams_orig); - Status ComputeEncodingData(const FrameHeader& frame_header, - const ImageMetadata& metadata, - Image3F* JXL_RESTRICT color, - const std::vector& extra_channels, - PassesEncoderState* JXL_RESTRICT enc_state, - const JxlCmsInterface& cms, ThreadPool* pool, - AuxOut* aux_out, bool do_color); + const CompressParams& cparams_orig, bool streaming_mode); + Status ComputeEncodingData( + const FrameHeader& frame_header, const ImageMetadata& metadata, + Image3F* JXL_RESTRICT color, const std::vector& extra_channels, + const Rect& group_rect, const FrameDimensions& patch_dim, + const Rect& frame_area_rect, PassesEncoderState* JXL_RESTRICT enc_state, + const JxlCmsInterface& cms, ThreadPool* pool, AuxOut* aux_out, + bool do_color); Status ComputeTree(ThreadPool* pool); Status ComputeTokens(ThreadPool* pool); // Encodes global info (tree + histograms) in the `writer`. @@ -43,28 +54,35 @@ class ModularFrameEncoder { // assigning bits to the provided `layer`. Status EncodeStream(BitWriter* writer, AuxOut* aux_out, size_t layer, const ModularStreamId& stream); + void ClearStreamData(const ModularStreamId& stream); + void ClearModularStreamData(); + size_t ComputeStreamingAbsoluteAcGroupId( + size_t dc_group_id, size_t ac_group_id, + const FrameDimensions& patch_dim) const; + // Creates a modular image for a given DC group of VarDCT mode. `dc` is the // input DC image, not quantized; the group is specified by `group_index`, and // `nl_dc` decides whether to apply a near-lossless processing to the DC or // not. - void AddVarDCTDC(const FrameHeader& frame_header, const Image3F& dc, - const Rect& r, size_t group_index, bool nl_dc, - PassesEncoderState* enc_state, bool jpeg_transcode); + Status AddVarDCTDC(const FrameHeader& frame_header, const Image3F& dc, + const Rect& r, size_t group_index, bool nl_dc, + PassesEncoderState* enc_state, bool jpeg_transcode); // Creates a modular image for the AC metadata of the given group // (`group_index`). - void AddACMetadata(const Rect& r, size_t group_index, bool jpeg_transcode, - PassesEncoderState* enc_state); + Status AddACMetadata(const Rect& r, size_t group_index, bool jpeg_transcode, + PassesEncoderState* enc_state); // Encodes a RAW quantization table in `writer`. If `modular_frame_encoder` is // null, the quantization table in `encoding` is used, with dimensions `size_x // x size_y`. Otherwise, the table with ID `idx` is encoded from the given // `modular_frame_encoder`. - static void EncodeQuantTable(size_t size_x, size_t size_y, BitWriter* writer, - const QuantEncoding& encoding, size_t idx, - ModularFrameEncoder* modular_frame_encoder); + static Status EncodeQuantTable(size_t size_x, size_t size_y, + BitWriter* writer, + const QuantEncoding& encoding, size_t idx, + ModularFrameEncoder* modular_frame_encoder); // Stores a quantization table for future usage with `EncodeQuantTable`. - void AddQuantTable(size_t size_x, size_t size_y, - const QuantEncoding& encoding, size_t idx); + Status AddQuantTable(size_t size_x, size_t size_y, + const QuantEncoding& encoding, size_t idx); std::vector ac_metadata_size; std::vector extra_dc_precision; @@ -72,7 +90,8 @@ class ModularFrameEncoder { private: Status PrepareStreamParams(const Rect& rect, const CompressParams& cparams, int minShift, int maxShift, - const ModularStreamId& stream, bool do_color); + const ModularStreamId& stream, bool do_color, + bool groupwise); std::vector stream_images_; std::vector stream_options_; std::vector quants_; @@ -89,6 +108,14 @@ class ModularFrameEncoder { std::vector> gi_channel_; std::vector image_widths_; Predictor delta_pred_ = Predictor::Average4; + + struct GroupParams { + Rect rect; + int minShift; + int maxShift; + ModularStreamId id; + }; + std::vector stream_params_; }; } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_noise.cc b/third_party/jpeg-xl/lib/jxl/enc_noise.cc index a12a9e6dc4..80b90eed2c 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_noise.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_noise.cc @@ -114,7 +114,7 @@ class NoiseHistogram { private: template T ClampX(const T x) const { - return std::min(std::max(T(0), x), T(kBins - 1)); + return std::min(std::max(static_cast(0), x), static_cast(kBins - 1)); } size_t Index(const float x) const { return ClampX(static_cast(x)); } @@ -321,7 +321,7 @@ std::vector GetNoiseLevel( void EncodeFloatParam(float val, float precision, BitWriter* writer) { JXL_ASSERT(val >= 0); - const int absval_quant = static_cast(val * precision + 0.5f); + const int absval_quant = static_cast(std::lround(val * precision)); JXL_ASSERT(absval_quant < (1 << 10)); writer->Write(10, absval_quant); } diff --git a/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc b/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc index cc65bf1a0c..9184765be2 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_optimize_test.cc @@ -12,7 +12,7 @@ namespace optimize { namespace { // The maximum number of iterations for the test. -static const size_t kMaxTestIter = 100000; +const size_t kMaxTestIter = 100000; // F(w) = (w - w_min)^2. struct SimpleQuadraticFunction { diff --git a/third_party/jpeg-xl/lib/jxl/enc_params.h b/third_party/jpeg-xl/lib/jxl/enc_params.h index 89fd2c924f..162c59d04c 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_params.h +++ b/third_party/jpeg-xl/lib/jxl/enc_params.h @@ -15,6 +15,7 @@ #include #include "lib/jxl/base/override.h" +#include "lib/jxl/common.h" #include "lib/jxl/enc_progressive_split.h" #include "lib/jxl/frame_dimensions.h" #include "lib/jxl/frame_header.h" @@ -24,36 +25,6 @@ namespace jxl { -enum class SpeedTier { - // Try multiple combinations of Tortoise flags for modular mode. Otherwise - // like kTortoise. - kGlacier = 0, - // Turns on FindBestQuantizationHQ loop. Equivalent to "guetzli" mode. - kTortoise = 1, - // Turns on FindBestQuantization butteraugli loop. - kKitten = 2, - // Turns on dots, patches, and spline detection by default, as well as full - // context clustering. Default. - kSquirrel = 3, - // Turns on error diffusion and full AC strategy heuristics. Equivalent to - // "fast" mode. - kWombat = 4, - // Turns on gaborish by default, non-default cmap, initial quant field. - kHare = 5, - // Turns on simple heuristics for AC strategy, quant field, and clustering; - // also enables coefficient reordering. - kCheetah = 6, - // Turns off most encoder features. Does context clustering. - // Modular: uses fixed tree with Weighted predictor. - kFalcon = 7, - // Currently fastest possible setting for VarDCT. - // Modular: uses fixed tree with Gradient predictor. - kThunder = 8, - // VarDCT: same as kThunder. - // Modular: no tree, Gradient predictor, fast histograms - kLightning = 9 -}; - // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding) struct CompressParams { float butteraugli_distance = 1.0f; @@ -106,7 +77,7 @@ struct CompressParams { int progressive_dc = -1; // If on: preserve color of invisible pixels (if off: don't care) - // Default: on for lossless, off for lossy + // Default: on Override keep_invisible = Override::kDefault; JxlCmsInterface cms; @@ -137,6 +108,7 @@ struct CompressParams { ModularOptions options; int responsive = -1; int colorspace = -1; + int move_to_front_from_channel = -1; // Use Global channel palette if #colors < this percentage of range float channel_colors_pre_transform_percent = 95.f; // Use Local channel palette if #colors < this percentage of range @@ -159,9 +131,6 @@ struct CompressParams { if (f > 0) return false; if (f < 0 && butteraugli_distance != 0) return false; } - // if no explicit ec_distance given, and using vardct, then the modular part - // is empty or not lossless - if (!modular_mode && ec_distance.empty()) return false; // all modular channels are encoded at distance 0 return true; } @@ -194,7 +163,7 @@ struct CompressParams { int level = -1; // See JXL_ENC_FRAME_SETTING_BUFFERING option value. - int buffering = 0; + int buffering = -1; // See JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS option value. bool use_full_image_heuristics = true; diff --git a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc index 0abd177809..f19ba0dd9e 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc @@ -5,24 +5,22 @@ #include "lib/jxl/enc_patch_dictionary.h" +#include #include #include #include #include #include -#include -#include #include #include -#include "lib/jxl/ans_params.h" #include "lib/jxl/base/common.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/override.h" +#include "lib/jxl/base/printf_macros.h" #include "lib/jxl/base/random.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/chroma_from_luma.h" #include "lib/jxl/dec_cache.h" #include "lib/jxl/dec_frame.h" #include "lib/jxl/enc_ans.h" @@ -31,7 +29,6 @@ #include "lib/jxl/enc_debug_image.h" #include "lib/jxl/enc_dot_dictionary.h" #include "lib/jxl/enc_frame.h" -#include "lib/jxl/entropy_coder.h" #include "lib/jxl/frame_header.h" #include "lib/jxl/image.h" #include "lib/jxl/image_bundle.h" @@ -100,7 +97,7 @@ void PatchDictionaryEncoder::Encode(const PatchDictionary& pdic, add_num(kPatchAlphaChannelContext, info.alpha_channel); } if (UsesClamp(info.mode)) { - add_num(kPatchClampContext, info.clamp); + add_num(kPatchClampContext, TO_JXL_BOOL(info.clamp)); } } } @@ -159,7 +156,7 @@ void PatchDictionaryEncoder::SubtractFrom(const PatchDictionary& pdic, // Nothing to do. } else { JXL_UNREACHABLE("Blending mode %u not yet implemented", - (uint32_t)mode); + static_cast(mode)); } } } @@ -208,11 +205,12 @@ struct PatchColorspaceInfo { } }; -std::vector FindTextLikePatches( +StatusOr> FindTextLikePatches( const CompressParams& cparams, const Image3F& opsin, const PassesEncoderState* JXL_RESTRICT state, ThreadPool* pool, AuxOut* aux_out, bool is_xyb) { - if (state->cparams.patches == Override::kOff) return {}; + std::vector info; + if (state->cparams.patches == Override::kOff) return info; const auto& frame_dim = state->shared.frame_dim; PatchColorspaceInfo pci(is_xyb); @@ -222,7 +220,8 @@ std::vector FindTextLikePatches( std::pair p2, const float* JXL_RESTRICT rows[3], size_t stride, float threshold) { - float v1[3], v2[3]; + float v1[3]; + float v2[3]; for (size_t c = 0; c < 3; c++) { v1[c] = rows[c][p1.second * stride + p1.first]; v2[c] = rows[c][p2.second * stride + p2.first]; @@ -258,8 +257,9 @@ std::vector FindTextLikePatches( // Look for kPatchSide size squares, naturally aligned, that all have the same // pixel values. - ImageB is_screenshot_like(DivCeil(frame_dim.xsize, kPatchSide), - DivCeil(frame_dim.ysize, kPatchSide)); + JXL_ASSIGN_OR_RETURN(ImageB is_screenshot_like, + ImageB::Create(DivCeil(frame_dim.xsize, kPatchSide), + DivCeil(frame_dim.ysize, kPatchSide))); ZeroFillImage(&is_screenshot_like); uint8_t* JXL_RESTRICT screenshot_row = is_screenshot_like.Row(0); const size_t screenshot_stride = is_screenshot_like.PixelsPerRow(); @@ -302,19 +302,22 @@ std::vector FindTextLikePatches( // TODO(veluca): also parallelize the rest of this function. if (WantDebugOutput(cparams)) { - DumpPlaneNormalized(cparams, "screenshot_like", is_screenshot_like); + JXL_RETURN_IF_ERROR( + DumpPlaneNormalized(cparams, "screenshot_like", is_screenshot_like)); } constexpr int kSearchRadius = 1; if (!ApplyOverride(state->cparams.patches, has_screenshot_areas)) { - return {}; + return info; } // Search for "similar enough" pixels near the screenshot-like areas. - ImageB is_background(frame_dim.xsize, frame_dim.ysize); + JXL_ASSIGN_OR_RETURN(ImageB is_background, + ImageB::Create(frame_dim.xsize, frame_dim.ysize)); ZeroFillImage(&is_background); - Image3F background(frame_dim.xsize, frame_dim.ysize); + JXL_ASSIGN_OR_RETURN(Image3F background, + Image3F::Create(frame_dim.xsize, frame_dim.ysize)); ZeroFillImage(&background); constexpr size_t kDistanceLimit = 50; float* JXL_RESTRICT background_rows[3] = { @@ -383,13 +386,14 @@ std::vector FindTextLikePatches( Rng rng(0); bool paint_ccs = false; if (WantDebugOutput(cparams)) { - DumpPlaneNormalized(cparams, "is_background", is_background); + JXL_RETURN_IF_ERROR( + DumpPlaneNormalized(cparams, "is_background", is_background)); if (is_xyb) { - DumpXybImage(cparams, "background", background); + JXL_RETURN_IF_ERROR(DumpXybImage(cparams, "background", background)); } else { - DumpImage(cparams, "background", background); + JXL_RETURN_IF_ERROR(DumpImage(cparams, "background", background)); } - ccs = ImageF(frame_dim.xsize, frame_dim.ysize); + JXL_ASSIGN_OR_RETURN(ccs, ImageF::Create(frame_dim.xsize, frame_dim.ysize)); ZeroFillImage(&ccs); paint_ccs = true; } @@ -407,11 +411,10 @@ std::vector FindTextLikePatches( constexpr int kMinPeak = 2; constexpr int kHasSimilarRadius = 2; - std::vector info; - // Find small CC outside the "similar enough" areas, compute bounding boxes, // and run heuristics to exclude some patches. - ImageB visited(frame_dim.xsize, frame_dim.ysize); + JXL_ASSIGN_OR_RETURN(ImageB visited, + ImageB::Create(frame_dim.xsize, frame_dim.ysize)); ZeroFillImage(&visited); uint8_t* JXL_RESTRICT visited_row = visited.Row(0); const size_t visited_stride = visited.PixelsPerRow(); @@ -525,10 +528,10 @@ std::vector FindTextLikePatches( if (paint_ccs) { JXL_ASSERT(WantDebugOutput(cparams)); - DumpPlaneNormalized(cparams, "ccs", ccs); + JXL_RETURN_IF_ERROR(DumpPlaneNormalized(cparams, "ccs", ccs)); } if (info.empty()) { - return {}; + return info; } // Remove duplicates. @@ -560,19 +563,22 @@ std::vector FindTextLikePatches( // don't use patches if all patches are smaller than this constexpr size_t kMinMaxPatchSize = 20; - if (max_patch_size < kMinMaxPatchSize) return {}; + if (max_patch_size < kMinMaxPatchSize) { + info.clear(); + } return info; } } // namespace -void FindBestPatchDictionary(const Image3F& opsin, - PassesEncoderState* JXL_RESTRICT state, - const JxlCmsInterface& cms, ThreadPool* pool, - AuxOut* aux_out, bool is_xyb) { - std::vector info = - FindTextLikePatches(state->cparams, opsin, state, pool, aux_out, is_xyb); +Status FindBestPatchDictionary(const Image3F& opsin, + PassesEncoderState* JXL_RESTRICT state, + const JxlCmsInterface& cms, ThreadPool* pool, + AuxOut* aux_out, bool is_xyb) { + JXL_ASSIGN_OR_RETURN( + std::vector info, + FindTextLikePatches(state->cparams, opsin, state, pool, aux_out, is_xyb)); // TODO(veluca): this doesn't work if both dots and patches are enabled. // For now, since dots and patches are not likely to occur in the same kind of @@ -582,10 +588,13 @@ void FindBestPatchDictionary(const Image3F& opsin, state->cparams.dots, state->cparams.speed_tier <= SpeedTier::kSquirrel && state->cparams.butteraugli_distance >= kMinButteraugliForDots)) { - info = FindDotDictionary(state->cparams, opsin, state->shared.cmap, pool); + Rect rect(0, 0, state->shared.frame_dim.xsize, + state->shared.frame_dim.ysize); + JXL_ASSIGN_OR_RETURN(info, FindDotDictionary(state->cparams, opsin, rect, + state->shared.cmap, pool)); } - if (info.empty()) return; + if (info.empty()) return true; std::sort( info.begin(), info.end(), [&](const PatchInfo& a, const PatchInfo& b) { @@ -616,7 +625,7 @@ void FindBestPatchDictionary(const Image3F& opsin, ref_xsize = ref_xsize * kBinPackingSlackness + 1; ref_ysize = ref_ysize * kBinPackingSlackness + 1; - ImageB occupied(ref_xsize, ref_ysize); + JXL_ASSIGN_OR_RETURN(ImageB occupied, ImageB::Create(ref_xsize, ref_ysize)); ZeroFillImage(&occupied); uint8_t* JXL_RESTRICT occupied_rows = occupied.Row(0); size_t occupied_stride = occupied.PixelsPerRow(); @@ -667,7 +676,7 @@ void FindBestPatchDictionary(const Image3F& opsin, ref_positions[patch] = {x0, y0}; for (size_t y = y0; y < y0 + ysize; y++) { for (size_t x = x0; x < x0 + xsize; x++) { - occupied_rows[y * occupied_stride + x] = true; + occupied_rows[y * occupied_stride + x] = JXL_TRUE; } } max_y = std::max(max_y, y0 + ysize); @@ -680,7 +689,8 @@ void FindBestPatchDictionary(const Image3F& opsin, ref_ysize = max_y; - Image3F reference_frame(ref_xsize, ref_ysize); + JXL_ASSIGN_OR_RETURN(Image3F reference_frame, + Image3F::Create(ref_xsize, ref_ysize)); // TODO(veluca): figure out a better way to fill the image. ZeroFillImage(&reference_frame); std::vector positions; @@ -710,6 +720,8 @@ void FindBestPatchDictionary(const Image3F& opsin, } } for (const auto& pos : info[i].second) { + JXL_DEBUG_V(4, "Patch %" PRIuS "x%" PRIuS " at position %u,%u", + ref_pos.xsize, ref_pos.ysize, pos.first, pos.second); positions.emplace_back( PatchPosition{pos.first, pos.second, pref_positions.size()}); // Add blending for color channels, ignore other channels. @@ -718,15 +730,16 @@ void FindBestPatchDictionary(const Image3F& opsin, blendings.push_back({PatchBlendMode::kNone, 0, false}); } } - pref_positions.emplace_back(std::move(ref_pos)); + pref_positions.emplace_back(ref_pos); } CompressParams cparams = state->cparams; // Recursive application of patches could create very weird issues. cparams.patches = Override::kOff; - RoundtripPatchFrame(&reference_frame, state, kPatchFrameReferenceId, cparams, - cms, pool, aux_out, /*subtract=*/true); + JXL_RETURN_IF_ERROR(RoundtripPatchFrame(&reference_frame, state, + kPatchFrameReferenceId, cparams, cms, + pool, aux_out, /*subtract=*/true)); // TODO(veluca): this assumes that applying patches is commutative, which is // not true for all blending modes. This code only produces kAdd patches, so @@ -734,12 +747,13 @@ void FindBestPatchDictionary(const Image3F& opsin, PatchDictionaryEncoder::SetPositions( &state->shared.image_features.patches, std::move(positions), std::move(pref_positions), std::move(blendings)); + return true; } -void RoundtripPatchFrame(Image3F* reference_frame, - PassesEncoderState* JXL_RESTRICT state, int idx, - CompressParams& cparams, const JxlCmsInterface& cms, - ThreadPool* pool, AuxOut* aux_out, bool subtract) { +Status RoundtripPatchFrame(Image3F* reference_frame, + PassesEncoderState* JXL_RESTRICT state, int idx, + CompressParams& cparams, const JxlCmsInterface& cms, + ThreadPool* pool, AuxOut* aux_out, bool subtract) { FrameInfo patch_frame_info; cparams.resampling = 1; cparams.ec_resampling = 1; @@ -768,7 +782,8 @@ void RoundtripPatchFrame(Image3F* reference_frame, std::vector extra_channels; extra_channels.reserve(ib.metadata()->extra_channel_info.size()); for (size_t i = 0; i < ib.metadata()->extra_channel_info.size(); i++) { - extra_channels.emplace_back(ib.xsize(), ib.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF ch, ImageF::Create(ib.xsize(), ib.ysize())); + extra_channels.emplace_back(std::move(ch)); // Must initialize the image with data to not affect blending with // uninitialized memory. // TODO(lode): patches must copy and use the real extra channels instead. @@ -814,6 +829,7 @@ void RoundtripPatchFrame(Image3F* reference_frame, } else { state->shared.reference_frames[idx].frame = std::move(ib); } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h index e17bfe4f04..ac236d7f17 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h +++ b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.h @@ -12,13 +12,10 @@ #include #include -#include #include #include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/chroma_from_luma.h" -#include "lib/jxl/dec_bit_reader.h" #include "lib/jxl/dec_patch_dictionary.h" #include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_cache.h" @@ -92,15 +89,15 @@ class PatchDictionaryEncoder { static void SubtractFrom(const PatchDictionary& pdic, Image3F* opsin); }; -void FindBestPatchDictionary(const Image3F& opsin, - PassesEncoderState* JXL_RESTRICT state, - const JxlCmsInterface& cms, ThreadPool* pool, - AuxOut* aux_out, bool is_xyb = true); +Status FindBestPatchDictionary(const Image3F& opsin, + PassesEncoderState* JXL_RESTRICT state, + const JxlCmsInterface& cms, ThreadPool* pool, + AuxOut* aux_out, bool is_xyb = true); -void RoundtripPatchFrame(Image3F* reference_frame, - PassesEncoderState* JXL_RESTRICT state, int idx, - CompressParams& cparams, const JxlCmsInterface& cms, - ThreadPool* pool, AuxOut* aux_out, bool subtract); +Status RoundtripPatchFrame(Image3F* reference_frame, + PassesEncoderState* JXL_RESTRICT state, int idx, + CompressParams& cparams, const JxlCmsInterface& cms, + ThreadPool* pool, AuxOut* aux_out, bool subtract); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc b/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc index be11b465ad..2e10dd5457 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_photon_noise_test.cc @@ -5,46 +5,37 @@ #include "lib/jxl/enc_photon_noise.h" -#include "lib/jxl/test_utils.h" +#include "lib/jxl/base/common.h" +#include "lib/jxl/noise.h" #include "lib/jxl/testing.h" namespace jxl { namespace { -using ::testing::FloatNear; -using ::testing::Pointwise; - -MATCHER(AreApproximatelyEqual, "") { - constexpr float kTolerance = 1e-6; - const float actual = std::get<0>(arg); - const float expected = std::get<1>(arg); - return testing::ExplainMatchResult(FloatNear(expected, kTolerance), actual, - result_listener); -} - TEST(EncPhotonNoiseTest, LUTs) { - EXPECT_THAT( + const double kTolerance = 1e-6; + EXPECT_ARRAY_NEAR( SimulatePhotonNoise(/*xsize=*/6000, /*ysize=*/4000, /*iso=*/100).lut, - Pointwise(AreApproximatelyEqual(), - {0.00259652, 0.0139648, 0.00681551, 0.00632582, 0.00694917, - 0.00803922, 0.00934574, 0.0107607})); - EXPECT_THAT( + (NoiseParams::Lut{0.00259652, 0.0139648, 0.00681551, 0.00632582, + 0.00694917, 0.00803922, 0.00934574, 0.0107607}), + kTolerance); + EXPECT_ARRAY_NEAR( SimulatePhotonNoise(/*xsize=*/6000, /*ysize=*/4000, /*iso=*/800).lut, - Pointwise(AreApproximatelyEqual(), - {0.02077220, 0.0420923, 0.01820690, 0.01439020, 0.01293670, - 0.01254030, 0.01277390, 0.0134161})); - EXPECT_THAT( + (NoiseParams::Lut{0.02077220, 0.0420923, 0.01820690, 0.01439020, + 0.01293670, 0.01254030, 0.01277390, 0.0134161}), + kTolerance); + EXPECT_ARRAY_NEAR( SimulatePhotonNoise(/*xsize=*/6000, /*ysize=*/4000, /*iso=*/6400).lut, - Pointwise(AreApproximatelyEqual(), - {0.1661770, 0.1691120, 0.05309080, 0.03963960, 0.03357410, - 0.03001650, 0.02776740, 0.0263478})); + (NoiseParams::Lut{0.1661770, 0.1691120, 0.05309080, 0.03963960, + 0.03357410, 0.03001650, 0.02776740, 0.0263478}), + kTolerance); // Lower when measured on a per-pixel basis as there are fewer of them. - EXPECT_THAT( + EXPECT_ARRAY_NEAR( SimulatePhotonNoise(/*xsize=*/4000, /*ysize=*/3000, /*iso=*/6400).lut, - Pointwise(AreApproximatelyEqual(), - {0.0830886, 0.1008720, 0.0367748, 0.0280305, 0.0240236, - 0.0218040, 0.0205771, 0.0200058})); + (NoiseParams::Lut{0.0830886, 0.1008720, 0.0367748, 0.0280305, 0.0240236, + 0.0218040, 0.0205771, 0.0200058}), + kTolerance); } } // namespace diff --git a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc index 236ddaacfd..35e49d5993 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.cc @@ -5,24 +5,18 @@ #include "lib/jxl/enc_quant_weights.h" +#include #include -#include #include -#include -#include -#include "lib/jxl/base/bits.h" #include "lib/jxl/base/common.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/dct_scales.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_modular.h" #include "lib/jxl/fields.h" -#include "lib/jxl/image.h" #include "lib/jxl/modular/encoding/encoding.h" -#include "lib/jxl/modular/options.h" namespace jxl { @@ -95,8 +89,8 @@ Status EncodeQuant(const QuantEncoding& encoding, size_t idx, size_t size_x, break; } case QuantEncoding::kQuantModeRAW: { - ModularFrameEncoder::EncodeQuantTable(size_x, size_y, writer, encoding, - idx, modular_frame_encoder); + JXL_RETURN_IF_ERROR(ModularFrameEncoder::EncodeQuantTable( + size_x, size_y, writer, encoding, idx, modular_frame_encoder)); break; } case QuantEncoding::kQuantModeAFV: { @@ -130,7 +124,7 @@ Status DequantMatricesEncode(const DequantMatrices& matrices, BitWriter* writer, } // TODO(janwas): better bound BitWriter::Allotment allotment(writer, 512 * 1024); - writer->Write(1, all_default); + writer->Write(1, TO_JXL_BOOL(all_default)); if (!all_default) { for (size_t i = 0; i < encodings.size(); i++) { JXL_RETURN_IF_ERROR(EncodeQuant( @@ -153,7 +147,7 @@ Status DequantMatricesEncodeDC(const DequantMatrices& matrices, } } BitWriter::Allotment allotment(writer, 1 + sizeof(float) * kBitsPerByte * 3); - writer->Write(1, all_default); + writer->Write(1, TO_JXL_BOOL(all_default)); if (!all_default) { for (size_t c = 0; c < 3; c++) { JXL_RETURN_IF_ERROR(F16Coder::Write(dc_quant[c] * 128.0f, writer)); @@ -195,19 +189,20 @@ void DequantMatricesRoundtrip(DequantMatrices* matrices) { JXL_CHECK(br.Close()); } -void DequantMatricesSetCustom(DequantMatrices* matrices, - const std::vector& encodings, - ModularFrameEncoder* encoder) { +Status DequantMatricesSetCustom(DequantMatrices* matrices, + const std::vector& encodings, + ModularFrameEncoder* encoder) { JXL_ASSERT(encodings.size() == DequantMatrices::kNum); matrices->SetEncodings(encodings); for (size_t i = 0; i < encodings.size(); i++) { if (encodings[i].mode == QuantEncodingInternal::kQuantModeRAW) { - encoder->AddQuantTable(DequantMatrices::required_size_x[i] * kBlockDim, - DequantMatrices::required_size_y[i] * kBlockDim, - encodings[i], i); + JXL_RETURN_IF_ERROR(encoder->AddQuantTable( + DequantMatrices::required_size_x[i] * kBlockDim, + DequantMatrices::required_size_y[i] * kBlockDim, encodings[i], i)); } } DequantMatricesRoundtrip(matrices); + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h index a47dfd4988..82d8278b72 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h +++ b/third_party/jpeg-xl/lib/jxl/enc_quant_weights.h @@ -27,9 +27,9 @@ void DequantMatricesSetCustomDC(DequantMatrices* matrices, const float* dc); void DequantMatricesScaleDC(DequantMatrices* matrices, float scale); -void DequantMatricesSetCustom(DequantMatrices* matrices, - const std::vector& encodings, - ModularFrameEncoder* encoder); +Status DequantMatricesSetCustom(DequantMatrices* matrices, + const std::vector& encodings, + ModularFrameEncoder* encoder); // Roundtrip encode/decode the matrices to ensure same values as decoder. void DequantMatricesRoundtrip(DequantMatrices* matrices); diff --git a/third_party/jpeg-xl/lib/jxl/enc_splines.cc b/third_party/jpeg-xl/lib/jxl/enc_splines.cc index de6c9670ea..fa15648ca5 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_splines.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_splines.cc @@ -73,13 +73,13 @@ void EncodeSplines(const Splines& splines, BitWriter* writer, splines.QuantizedSplines(); std::vector> tokens(1); tokens[0].emplace_back(kNumSplinesContext, quantized_splines.size() - 1); - EncodeAllStartingPoints(splines.StartingPoints(), &tokens[0]); + EncodeAllStartingPoints(splines.StartingPoints(), tokens.data()); tokens[0].emplace_back(kQuantizationAdjustmentContext, PackSigned(splines.GetQuantizationAdjustment())); for (const QuantizedSpline& spline : quantized_splines) { - QuantizedSplineEncoder::Tokenize(spline, &tokens[0]); + QuantizedSplineEncoder::Tokenize(spline, tokens.data()); } EntropyEncodingData codes; diff --git a/third_party/jpeg-xl/lib/jxl/enc_transforms.cc b/third_party/jpeg-xl/lib/jxl/enc_transforms.cc index 8978ba1dcb..d116183404 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_transforms.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_transforms.cc @@ -21,20 +21,19 @@ void TransformFromPixels(const AcStrategy::Type strategy, const float* JXL_RESTRICT pixels, size_t pixels_stride, float* JXL_RESTRICT coefficients, float* scratch_space) { - return HWY_DYNAMIC_DISPATCH(TransformFromPixels)( - strategy, pixels, pixels_stride, coefficients, scratch_space); + HWY_DYNAMIC_DISPATCH(TransformFromPixels) + (strategy, pixels, pixels_stride, coefficients, scratch_space); } HWY_EXPORT(DCFromLowestFrequencies); void DCFromLowestFrequencies(AcStrategy::Type strategy, const float* block, float* dc, size_t dc_stride) { - return HWY_DYNAMIC_DISPATCH(DCFromLowestFrequencies)(strategy, block, dc, - dc_stride); + HWY_DYNAMIC_DISPATCH(DCFromLowestFrequencies)(strategy, block, dc, dc_stride); } HWY_EXPORT(AFVDCT4x4); void AFVDCT4x4(const float* JXL_RESTRICT pixels, float* JXL_RESTRICT coeffs) { - return HWY_DYNAMIC_DISPATCH(AFVDCT4x4)(pixels, coeffs); + HWY_DYNAMIC_DISPATCH(AFVDCT4x4)(pixels, coeffs); } #endif // HWY_ONCE diff --git a/third_party/jpeg-xl/lib/jxl/enc_transforms.h b/third_party/jpeg-xl/lib/jxl/enc_transforms.h index 039ccc3893..f0ce95659d 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_transforms.h +++ b/third_party/jpeg-xl/lib/jxl/enc_transforms.h @@ -9,14 +9,13 @@ // Facade for (non-inlined) integral transforms. #include -#include #include "lib/jxl/ac_strategy.h" #include "lib/jxl/base/compiler_specific.h" namespace jxl { -void TransformFromPixels(const AcStrategy::Type strategy, +void TransformFromPixels(AcStrategy::Type strategy, const float* JXL_RESTRICT pixels, size_t pixels_stride, float* JXL_RESTRICT coefficients, float* JXL_RESTRICT scratch_space); diff --git a/third_party/jpeg-xl/lib/jxl/enc_xyb.cc b/third_party/jpeg-xl/lib/jxl/enc_xyb.cc index e538e8c91d..9fc68d8474 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_xyb.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_xyb.cc @@ -21,9 +21,7 @@ #include "lib/jxl/cms/opsin_params.h" #include "lib/jxl/cms/transfer_functions-inl.h" #include "lib/jxl/color_encoding_internal.h" -#include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_image_bundle.h" -#include "lib/jxl/fields.h" #include "lib/jxl/image_bundle.h" #include "lib/jxl/image_ops.h" @@ -44,7 +42,7 @@ JXL_INLINE void OpsinAbsorbance(const V r, const V g, const V b, const float* JXL_RESTRICT premul_absorb, V* JXL_RESTRICT mixed0, V* JXL_RESTRICT mixed1, V* JXL_RESTRICT mixed2) { - const float* bias = &jxl::cms::kOpsinAbsorbanceBias[0]; + const float* bias = jxl::cms::kOpsinAbsorbanceBias.data(); const HWY_FULL(float) d; const size_t N = Lanes(d); const auto m0 = Load(d, premul_absorb + 0 * N); @@ -77,7 +75,9 @@ void LinearRGBToXYB(const V r, const V g, const V b, const float* JXL_RESTRICT premul_absorb, float* JXL_RESTRICT valx, float* JXL_RESTRICT valy, float* JXL_RESTRICT valz) { - V mixed0, mixed1, mixed2; + V mixed0; + V mixed1; + V mixed2; OpsinAbsorbance(r, g, b, premul_absorb, &mixed0, &mixed1, &mixed2); // mixed* should be non-negative even for wide-gamut, so clamp to zero. @@ -198,9 +198,11 @@ void ComputePremulAbsorb(float intensity_target, float* premul_absorb) { const HWY_FULL(float) d; const size_t N = Lanes(d); const float mul = intensity_target / 255.0f; - for (size_t i = 0; i < 9; ++i) { - const auto absorb = Set(d, jxl::cms::kOpsinAbsorbanceMatrix[i] * mul); - Store(absorb, d, premul_absorb + i * N); + for (size_t j = 0; j < 3; ++j) { + for (size_t i = 0; i < 3; ++i) { + const auto absorb = Set(d, jxl::cms::kOpsinAbsorbanceMatrix[j][i] * mul); + Store(absorb, d, premul_absorb + (j * 3 + i) * N); + } } for (size_t i = 0; i < 3; ++i) { const auto neg_bias_cbrt = @@ -209,15 +211,16 @@ void ComputePremulAbsorb(float intensity_target, float* premul_absorb) { } } -Image3F TransformToLinearRGB(const Image3F& in, - const ColorEncoding& color_encoding, - float intensity_target, const JxlCmsInterface& cms, - ThreadPool* pool) { +StatusOr TransformToLinearRGB(const Image3F& in, + const ColorEncoding& color_encoding, + float intensity_target, + const JxlCmsInterface& cms, + ThreadPool* pool) { ColorSpaceTransform c_transform(cms); bool is_gray = color_encoding.IsGray(); const ColorEncoding& c_desired = ColorEncoding::LinearSRGB(is_gray); - Image3F out(in.xsize(), in.ysize()); - std::atomic ok{true}; + JXL_ASSIGN_OR_RETURN(Image3F out, Image3F::Create(in.xsize(), in.ysize())); + std::atomic has_error{false}; JXL_CHECK(RunOnPool( pool, 0, in.ysize(), [&](const size_t num_threads) { @@ -225,6 +228,7 @@ Image3F TransformToLinearRGB(const Image3F& in, in.xsize(), num_threads); }, [&](const uint32_t y, const size_t thread) { + if (has_error) return; float* mutable_src_buf = c_transform.BufSrc(thread); const float* src_buf = mutable_src_buf; // Interleave input. @@ -241,8 +245,8 @@ Image3F TransformToLinearRGB(const Image3F& in, } } float* JXL_RESTRICT dst_buf = c_transform.BufDst(thread); - if (!c_transform.Run(thread, src_buf, dst_buf)) { - ok.store(false); + if (!c_transform.Run(thread, src_buf, dst_buf, in.xsize())) { + has_error = true; return; } float* JXL_RESTRICT row_out0 = out.PlaneRow(0, y); @@ -264,7 +268,7 @@ Image3F TransformToLinearRGB(const Image3F& in, } }, "Colorspace transform")); - JXL_CHECK(ok.load()); + JXL_CHECK(!has_error); return out; } @@ -394,12 +398,13 @@ void ToXYB(const ColorEncoding& c_current, float intensity_target, (c_current, intensity_target, black, pool, image, cms, linear); } -void ToXYB(const ImageBundle& in, ThreadPool* pool, Image3F* JXL_RESTRICT xyb, - const JxlCmsInterface& cms, Image3F* JXL_RESTRICT linear) { - *xyb = Image3F(in.xsize(), in.ysize()); +Status ToXYB(const ImageBundle& in, ThreadPool* pool, Image3F* JXL_RESTRICT xyb, + const JxlCmsInterface& cms, Image3F* JXL_RESTRICT linear) { + JXL_ASSIGN_OR_RETURN(*xyb, Image3F::Create(in.xsize(), in.ysize())); CopyImageTo(in.color(), xyb); ToXYB(in.c_current(), in.metadata()->IntensityTarget(), in.HasBlack() ? &in.black() : nullptr, pool, xyb, cms, linear); + return true; } HWY_EXPORT(LinearRGBRowToXYB); diff --git a/third_party/jpeg-xl/lib/jxl/enc_xyb.h b/third_party/jpeg-xl/lib/jxl/enc_xyb.h index 6a2e7c4123..741d447b92 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_xyb.h +++ b/third_party/jpeg-xl/lib/jxl/enc_xyb.h @@ -27,8 +27,9 @@ void ToXYB(const ColorEncoding& c_current, float intensity_target, const ImageF* black, ThreadPool* pool, Image3F* JXL_RESTRICT image, const JxlCmsInterface& cms, Image3F* JXL_RESTRICT linear); -void ToXYB(const ImageBundle& in, ThreadPool* pool, Image3F* JXL_RESTRICT xyb, - const JxlCmsInterface& cms, Image3F* JXL_RESTRICT linear = nullptr); +Status ToXYB(const ImageBundle& in, ThreadPool* pool, Image3F* JXL_RESTRICT xyb, + const JxlCmsInterface& cms, + Image3F* JXL_RESTRICT linear = nullptr); void LinearRGBRowToXYB(float* JXL_RESTRICT row0, float* JXL_RESTRICT row1, float* JXL_RESTRICT row2, diff --git a/third_party/jpeg-xl/lib/jxl/encode.cc b/third_party/jpeg-xl/lib/jxl/encode.cc index 76f2148d62..4dbbeba4e7 100644 --- a/third_party/jpeg-xl/lib/jxl/encode.cc +++ b/third_party/jpeg-xl/lib/jxl/encode.cc @@ -595,21 +595,21 @@ JxlEncoderStatus VerifyInputBitDepth(JxlBitDepth bit_depth, return JxlErrorOrStatus::Success(); } -static inline bool EncodeVarInt(uint64_t value, size_t output_size, - size_t* output_pos, uint8_t* output) { +inline bool EncodeVarInt(uint64_t value, size_t output_size, size_t* output_pos, + uint8_t* output) { // While more than 7 bits of data are left, // store 7 bits and set the next byte flag while (value > 127) { // TODO(eustas): should it be `>=` ? if (*output_pos > output_size) return false; // |128: Set the next byte flag - output[(*output_pos)++] = ((uint8_t)(value & 127)) | 128; + output[(*output_pos)++] = (static_cast(value & 127)) | 128; // Remove the seven bits we just wrote value >>= 7; } // TODO(eustas): should it be `>=` ? if (*output_pos > output_size) return false; - output[(*output_pos)++] = ((uint8_t)value) & 127; + output[(*output_pos)++] = static_cast(value & 127); return true; } @@ -854,7 +854,7 @@ jxl::Status JxlEncoderStruct::ProcessOneEnqueuedInput() { timecode = 0; } - const bool last_frame = frames_closed && !num_queued_frames; + const bool last_frame = frames_closed && (num_queued_frames == 0); uint32_t max_bits_per_sample = metadata.m.bit_depth.bits_per_sample; for (const auto& info : metadata.m.extra_channel_info) { @@ -901,7 +901,7 @@ jxl::Status JxlEncoderStruct::ProcessOneEnqueuedInput() { return JXL_API_ERROR( this, JXL_ENC_ERR_API_USAGE, "Cannot use save_as_reference values >=3 (found: %d)", - (int)save_as_reference); + static_cast(save_as_reference)); } jxl::FrameInfo frame_info; @@ -909,8 +909,8 @@ jxl::Status JxlEncoderStruct::ProcessOneEnqueuedInput() { frame_info.save_as_reference = save_as_reference; frame_info.source = input_frame->option_values.header.layer_info.blend_info.source; - frame_info.clamp = - input_frame->option_values.header.layer_info.blend_info.clamp; + frame_info.clamp = FROM_JXL_BOOL( + input_frame->option_values.header.layer_info.blend_info.clamp); frame_info.alpha_channel = input_frame->option_values.header.layer_info.blend_info.alpha; frame_info.extra_channel_blending_info.resize( @@ -989,7 +989,7 @@ jxl::Status JxlEncoderStruct::ProcessOneEnqueuedInput() { #endif jxl::WriteBoxHeader(jxl::MakeBoxType("jxlc"), frame_codestream_size, /*unbounded=*/false, use_large_box, - &box_header[0]); + box_header.data()); JXL_ASSERT(n == box_header_size); } else { #if JXL_ENABLE_ASSERT @@ -997,7 +997,7 @@ jxl::Status JxlEncoderStruct::ProcessOneEnqueuedInput() { #endif jxl::WriteBoxHeader( jxl::MakeBoxType("jxlp"), frame_codestream_size + 4, - /*unbounded=*/false, use_large_box, &box_header[0]); + /*unbounded=*/false, use_large_box, box_header.data()); JXL_ASSERT(n == box_header_size - 4); WriteJxlpBoxCounter(jxlp_counter++, last_frame, &box_header[box_header_size - 4]); @@ -1061,15 +1061,17 @@ JxlEncoderStatus JxlEncoderSetColorEncoding(JxlEncoder* enc, } if (enc->metadata.m.color_encoding.GetColorSpace() == jxl::ColorSpace::kGray) { - if (enc->basic_info.num_color_channels != 1) + if (enc->basic_info.num_color_channels != 1) { return JXL_API_ERROR( enc, JXL_ENC_ERR_API_USAGE, "Cannot use grayscale color encoding with num_color_channels != 1"); + } } else { - if (enc->basic_info.num_color_channels != 3) + if (enc->basic_info.num_color_channels != 3) { return JXL_API_ERROR( enc, JXL_ENC_ERR_API_USAGE, "Cannot use RGB color encoding with num_color_channels != 3"); + } } enc->color_encoding_set = true; if (!enc->intensity_target_set) { @@ -1103,15 +1105,17 @@ JxlEncoderStatus JxlEncoderSetICCProfile(JxlEncoder* enc, } if (enc->metadata.m.color_encoding.GetColorSpace() == jxl::ColorSpace::kGray) { - if (enc->basic_info.num_color_channels != 1) + if (enc->basic_info.num_color_channels != 1) { return JXL_API_ERROR( enc, JXL_ENC_ERR_BAD_INPUT, "Cannot use grayscale ICC profile with num_color_channels != 1"); + } } else { - if (enc->basic_info.num_color_channels != 3) + if (enc->basic_info.num_color_channels != 3) { return JXL_API_ERROR( enc, JXL_ENC_ERR_BAD_INPUT, "Cannot use RGB ICC profile with num_color_channels != 3"); + } // TODO(jon): also check that a kBlack extra channel is provided in the CMYK // case } @@ -1210,7 +1214,8 @@ JxlEncoderStatus JxlEncoderSetBasicInfo(JxlEncoder* enc, enc->metadata.m.bit_depth.floating_point_sample = (info->exponent_bits_per_sample != 0u); enc->metadata.m.modular_16_bit_buffer_sufficient = - (!info->uses_original_profile || info->bits_per_sample <= 12) && + (!FROM_JXL_BOOL(info->uses_original_profile) || + info->bits_per_sample <= 12) && info->alpha_bits <= 12; if ((info->intrinsic_xsize > 0 || info->intrinsic_ysize > 0) && (info->intrinsic_xsize != info->xsize || @@ -1248,7 +1253,7 @@ JxlEncoderStatus JxlEncoderSetBasicInfo(JxlEncoder* enc, } } - enc->metadata.m.xyb_encoded = !info->uses_original_profile; + enc->metadata.m.xyb_encoded = !FROM_JXL_BOOL(info->uses_original_profile); if (info->orientation > 0 && info->orientation <= 8) { enc->metadata.m.orientation = info->orientation; } else { @@ -1271,12 +1276,12 @@ JxlEncoderStatus JxlEncoderSetBasicInfo(JxlEncoder* enc, } enc->metadata.m.tone_mapping.min_nits = info->min_nits; enc->metadata.m.tone_mapping.relative_to_max_display = - info->relative_to_max_display; + FROM_JXL_BOOL(info->relative_to_max_display); enc->metadata.m.tone_mapping.linear_below = info->linear_below; enc->basic_info = *info; enc->basic_info_set = true; - enc->metadata.m.have_animation = info->have_animation; + enc->metadata.m.have_animation = FROM_JXL_BOOL(info->have_animation); if (info->have_animation) { if (info->animation.tps_denominator < 1) { return JXL_API_ERROR( @@ -1290,7 +1295,8 @@ JxlEncoderStatus JxlEncoderSetBasicInfo(JxlEncoder* enc, enc->metadata.m.animation.tps_numerator = info->animation.tps_numerator; enc->metadata.m.animation.tps_denominator = info->animation.tps_denominator; enc->metadata.m.animation.num_loops = info->animation.num_loops; - enc->metadata.m.animation.have_timecodes = info->animation.have_timecodes; + enc->metadata.m.animation.have_timecodes = + FROM_JXL_BOOL(info->animation.have_timecodes); } std::string level_message; int required_level = VerifyLevelSettings(enc, &level_message); @@ -1326,14 +1332,16 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetUpsamplingMode(JxlEncoder* enc, const int64_t mode) { // for convenience, allow calling this with factor 1 and just make it a no-op if (factor == 1) return JxlErrorOrStatus::Success(); - if (factor != 2 && factor != 4 && factor != 8) + if (factor != 2 && factor != 4 && factor != 8) { return JXL_API_ERROR(enc, JXL_ENC_ERR_API_USAGE, "Invalid upsampling factor"); + } if (mode < -1) return JXL_API_ERROR(enc, JXL_ENC_ERR_API_USAGE, "Invalid upsampling mode"); - if (mode > 1) + if (mode > 1) { return JXL_API_ERROR(enc, JXL_ENC_ERR_NOT_SUPPORTED, "Unsupported upsampling mode"); + } const size_t count = (factor == 2 ? 15 : (factor == 4 ? 55 : 210)); auto& td = enc->metadata.transform_data; @@ -1436,7 +1444,7 @@ JxlEncoderFrameSettings* JxlEncoderFrameSettingsCreate( } opts->values.cparams.level = enc->codestream_level; opts->values.cparams.ec_distance.resize(enc->metadata.m.num_extra_channels, - -1); + 0); JxlEncoderFrameSettings* ret = opts.get(); enc->encoder_options.emplace_back(std::move(opts)); @@ -1451,7 +1459,7 @@ JxlEncoderStatus JxlEncoderSetFrameLossless( frame_settings->enc, JXL_ENC_ERR_API_USAGE, "Set uses_original_profile=true for lossless encoding"); } - frame_settings->values.lossless = lossless; + frame_settings->values.lossless = FROM_JXL_BOOL(lossless); return JxlErrorOrStatus::Success(); } @@ -1489,7 +1497,7 @@ JxlEncoderStatus JxlEncoderSetExtraChannelDistance( // This can only happen if JxlEncoderFrameSettingsCreate() was called before // JxlEncoderSetBasicInfo(). frame_settings->values.cparams.ec_distance.resize( - frame_settings->enc->metadata.m.num_extra_channels, -1); + frame_settings->enc->metadata.m.num_extra_channels, 0); } frame_settings->values.cparams.ec_distance[index] = distance; @@ -1537,14 +1545,14 @@ JxlEncoderStatus JxlEncoderFrameSettingsSetOption( switch (option) { case JXL_ENC_FRAME_SETTING_EFFORT: if (frame_settings->enc->allow_expert_options) { - if (value < 1 || value > 10) { + if (value < 1 || value > 11) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_NOT_SUPPORTED, - "Encode effort has to be in [1..10]"); + "Encode effort has to be in [1..11]"); } } else { - if (value < 1 || value > 9) { + if (value < 1 || value > 10) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_NOT_SUPPORTED, - "Encode effort has to be in [1..9]"); + "Encode effort has to be in [1..10]"); } } frame_settings->values.cparams.speed_tier = @@ -1747,9 +1755,9 @@ JxlEncoderStatus JxlEncoderFrameSettingsSetOption( frame_settings->values.cparams.jpeg_compress_boxes = value; break; case JXL_ENC_FRAME_SETTING_BUFFERING: - if (value < 0 || value > 3) { + if (value < -1 || value > 3) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_NOT_SUPPORTED, - "Buffering has to be in [0..3]"); + "Buffering has to be in [-1..3]"); } frame_settings->values.cparams.buffering = value; break; @@ -1934,7 +1942,7 @@ JxlEncoderStatus JxlEncoderUseContainer(JxlEncoder* enc, return JXL_API_ERROR(enc, JXL_ENC_ERR_API_USAGE, "this setting can only be set at the beginning"); } - enc->use_container = static_cast(use_container); + enc->use_container = FROM_JXL_BOOL(use_container); return JxlErrorOrStatus::Success(); } @@ -1944,7 +1952,7 @@ JxlEncoderStatus JxlEncoderStoreJPEGMetadata(JxlEncoder* enc, return JXL_API_ERROR(enc, JXL_ENC_ERR_API_USAGE, "this setting can only be set at the beginning"); } - enc->store_jpeg_metadata = static_cast(store_jpeg_metadata); + enc->store_jpeg_metadata = FROM_JXL_BOOL(store_jpeg_metadata); return JxlErrorOrStatus::Success(); } @@ -2034,7 +2042,7 @@ JxlEncoderStatus JxlEncoderAddJPEGFrame( JxlEncoderInitBasicInfo(&basic_info); basic_info.xsize = io.Main().jpeg_data->width; basic_info.ysize = io.Main().jpeg_data->height; - basic_info.uses_original_profile = true; + basic_info.uses_original_profile = JXL_TRUE; if (JxlEncoderSetBasicInfo(frame_settings->enc, &basic_info) != JXL_ENC_SUCCESS) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_GENERIC, @@ -2042,7 +2050,8 @@ JxlEncoderStatus JxlEncoderAddJPEGFrame( } } - size_t xsize, ysize; + size_t xsize; + size_t ysize; if (GetCurrentDimensions(frame_settings, xsize, ysize) != JXL_ENC_SUCCESS) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_GENERIC, "bad dimensions"); @@ -2074,21 +2083,23 @@ JxlEncoderStatus JxlEncoderAddJPEGFrame( std::vector exif(exif_size); memcpy(exif.data() + 4, io.blobs.exif.data(), io.blobs.exif.size()); JxlEncoderUseBoxes(frame_settings->enc); - JxlEncoderAddBox(frame_settings->enc, "Exif", exif.data(), exif_size, - frame_settings->values.cparams.jpeg_compress_boxes); + JxlEncoderAddBox( + frame_settings->enc, "Exif", exif.data(), exif_size, + TO_JXL_BOOL(frame_settings->values.cparams.jpeg_compress_boxes)); } if (!io.blobs.xmp.empty() && frame_settings->values.cparams.jpeg_keep_xmp) { JxlEncoderUseBoxes(frame_settings->enc); - JxlEncoderAddBox(frame_settings->enc, "xml ", io.blobs.xmp.data(), - io.blobs.xmp.size(), - frame_settings->values.cparams.jpeg_compress_boxes); + JxlEncoderAddBox( + frame_settings->enc, "xml ", io.blobs.xmp.data(), io.blobs.xmp.size(), + TO_JXL_BOOL(frame_settings->values.cparams.jpeg_compress_boxes)); } if (!io.blobs.jumbf.empty() && frame_settings->values.cparams.jpeg_keep_jumbf) { JxlEncoderUseBoxes(frame_settings->enc); - JxlEncoderAddBox(frame_settings->enc, "jumb", io.blobs.jumbf.data(), - io.blobs.jumbf.size(), - frame_settings->values.cparams.jpeg_compress_boxes); + JxlEncoderAddBox( + frame_settings->enc, "jumb", io.blobs.jumbf.data(), + io.blobs.jumbf.size(), + TO_JXL_BOOL(frame_settings->values.cparams.jpeg_compress_boxes)); } if (frame_settings->enc->store_jpeg_metadata) { if (!frame_settings->values.cparams.jpeg_keep_exif || @@ -2259,10 +2270,12 @@ JxlEncoderStatus JxlEncoderAddImageFrameInternal( pool, 0, count, jxl::ThreadPool::NoInit, [&](size_t i, size_t) { fun(opaque, i); }, "Encode fast lossless")); }; - auto frame_state = JxlFastLosslessPrepareFrame( + JXL_BOOL oneshot = TO_JXL_BOOL(!frame_data.StreamingInput()); + auto* frame_state = JxlFastLosslessPrepareFrame( frame_data.GetInputSource(), xsize, ysize, num_channels, - frame_settings->enc->metadata.m.bit_depth.bits_per_sample, big_endian, - /*effort=*/2, /*oneshot=*/!frame_data.StreamingInput()); + frame_settings->enc->metadata.m.bit_depth.bits_per_sample, + TO_JXL_BOOL(big_endian), + /*effort=*/2, oneshot); if (!streaming) { JxlFastLosslessProcessFrame(frame_state, /*is_last=*/false, frame_settings->enc->thread_pool.get(), @@ -2325,7 +2338,8 @@ JxlEncoderStatus JxlEncoderAddImageFrameInternal( JxlEncoderStatus JxlEncoderAddImageFrame( const JxlEncoderFrameSettings* frame_settings, const JxlPixelFormat* pixel_format, const void* buffer, size_t size) { - size_t xsize, ysize; + size_t xsize; + size_t ysize; if (GetCurrentDimensions(frame_settings, xsize, ysize) != JXL_ENC_SUCCESS) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_GENERIC, "bad dimensions"); @@ -2345,7 +2359,8 @@ JxlEncoderStatus JxlEncoderAddImageFrame( JxlEncoderStatus JxlEncoderAddChunkedFrame( const JxlEncoderFrameSettings* frame_settings, JXL_BOOL is_last_frame, JxlChunkedFrameInputSource chunked_frame_input) { - size_t xsize, ysize; + size_t xsize; + size_t ysize; if (GetCurrentDimensions(frame_settings, xsize, ysize) != JXL_ENC_SUCCESS) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_GENERIC, "bad dimensions"); @@ -2417,7 +2432,7 @@ JxlEncoderStatus JxlEncoderAddBox(JxlEncoder* enc, const JxlBoxType type, box->type = jxl::MakeBoxType(type); box->contents.assign(contents, contents + size); - box->compress_box = !!compress_box; + box->compress_box = FROM_JXL_BOOL(compress_box); QueueBox(enc, box); return JxlErrorOrStatus::Success(); } @@ -2450,7 +2465,7 @@ JXL_EXPORT JxlEncoderStatus JxlEncoderSetExtraChannelBuffer( return JXL_API_ERROR_NOSET("Invalid input bit depth"); } const uint8_t* uint8_buffer = reinterpret_cast(buffer); - auto queued_frame = frame_settings->enc->input_queue.back().frame.get(); + auto* queued_frame = frame_settings->enc->input_queue.back().frame.get(); if (!queued_frame->frame_data.SetFromBuffer(1 + index, uint8_buffer, size, ec_format)) { return JXL_API_ERROR(frame_settings->enc, JXL_ENC_ERR_API_USAGE, @@ -2588,12 +2603,14 @@ JxlEncoderStatus JxlEncoderSetFrameBitDepth( void JxlColorEncodingSetToSRGB(JxlColorEncoding* color_encoding, JXL_BOOL is_gray) { - *color_encoding = jxl::ColorEncoding::SRGB(is_gray).ToExternal(); + *color_encoding = + jxl::ColorEncoding::SRGB(FROM_JXL_BOOL(is_gray)).ToExternal(); } void JxlColorEncodingSetToLinearSRGB(JxlColorEncoding* color_encoding, JXL_BOOL is_gray) { - *color_encoding = jxl::ColorEncoding::LinearSRGB(is_gray).ToExternal(); + *color_encoding = + jxl::ColorEncoding::LinearSRGB(FROM_JXL_BOOL(is_gray)).ToExternal(); } void JxlEncoderAllowExpertOptions(JxlEncoder* enc) { @@ -2611,9 +2628,7 @@ JXL_EXPORT JxlEncoderStats* JxlEncoderStatsCreate() { return new JxlEncoderStats(); } -JXL_EXPORT void JxlEncoderStatsDestroy(JxlEncoderStats* stats) { - if (stats) delete stats; -} +JXL_EXPORT void JxlEncoderStatsDestroy(JxlEncoderStats* stats) { delete stats; } JXL_EXPORT void JxlEncoderCollectStats(JxlEncoderFrameSettings* frame_settings, JxlEncoderStats* stats) { diff --git a/third_party/jpeg-xl/lib/jxl/encode_internal.h b/third_party/jpeg-xl/lib/jxl/encode_internal.h index e89993f253..001df5fed5 100644 --- a/third_party/jpeg-xl/lib/jxl/encode_internal.h +++ b/third_party/jpeg-xl/lib/jxl/encode_internal.h @@ -580,12 +580,9 @@ jxl::Status AppendData(JxlEncoderOutputProcessorWrapper& output_processor, // Internal use only struct, can only be initialized correctly by // JxlEncoderCreate. struct JxlEncoderStruct { - JxlEncoderError error = JxlEncoderError::JXL_ENC_ERR_OK; JxlMemoryManager memory_manager; jxl::MemoryManagerUniquePtr thread_pool{ nullptr, jxl::MemoryManagerDeleteHelper(&memory_manager)}; - JxlCmsInterface cms; - bool cms_set; std::vector> encoder_options; @@ -603,6 +600,9 @@ struct JxlEncoderStruct { size_t codestream_bytes_written_end_of_frame; jxl::JxlEncoderFrameIndexBox frame_index_box; + JxlCmsInterface cms; + bool cms_set; + // Force using the container even if not needed bool use_container; // User declared they will add metadata boxes @@ -611,23 +611,26 @@ struct JxlEncoderStruct { // TODO(lode): move level into jxl::CompressParams since some C++ // implementation decisions should be based on it: level 10 allows more // features to be used. - int32_t codestream_level; bool store_jpeg_metadata; + int32_t codestream_level; jxl::CodecMetadata metadata; std::vector jpeg_metadata; - // Wrote any output at all, so wrote the data before the first user added - // frame or box, such as signature, basic info, ICC profile or jpeg - // reconstruction box. - bool wrote_bytes; jxl::CompressParams last_used_cparams; JxlBasicInfo basic_info; + JxlEncoderError error = JxlEncoderError::JXL_ENC_ERR_OK; + // Encoder wrote a jxlp (partial codestream) box, so any next codestream // parts must also be written in jxlp boxes, a single jxlc box cannot be // used. The counter is used for the 4-byte jxlp box index header. size_t jxlp_counter; + // Wrote any output at all, so wrote the data before the first user added + // frame or box, such as signature, basic info, ICC profile or jpeg + // reconstruction box. + bool wrote_bytes; + bool frames_closed; bool boxes_closed; bool basic_info_set; diff --git a/third_party/jpeg-xl/lib/jxl/encode_test.cc b/third_party/jpeg-xl/lib/jxl/encode_test.cc index 2c17fcab21..3e519cc45d 100644 --- a/third_party/jpeg-xl/lib/jxl/encode_test.cc +++ b/third_party/jpeg-xl/lib/jxl/encode_test.cc @@ -33,6 +33,7 @@ #include "lib/extras/packed_image.h" #include "lib/jxl/base/byte_order.h" #include "lib/jxl/base/c_callback_support.h" +#include "lib/jxl/base/override.h" #include "lib/jxl/base/span.h" #include "lib/jxl/base/status.h" #include "lib/jxl/common.h" // JXL_HIGH_PRECISION @@ -79,16 +80,16 @@ TEST(EncodeTest, AddFrameAfterCloseInputTest) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.uses_original_profile = false; + basic_info.uses_original_profile = 0; EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc.get(), 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JXL_BOOL is_gray = TO_JXL_BOOL(pixel_format.num_channels < 3); + JxlColorEncodingSetToSRGB(&color_encoding, is_gray); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderAddImageFrame(frame_settings, &pixel_format, pixels.data(), pixels.size())); @@ -104,7 +105,7 @@ TEST(EncodeTest, AddJPEGAfterCloseTest) { const std::vector orig = jxl::test::ReadTestData(jpeg_path); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderAddJPEGFrame(frame_settings, orig.data(), orig.size())); @@ -123,12 +124,12 @@ TEST(EncodeTest, AddFrameBeforeBasicInfoTest) { jxl::test::SomeTestImageToCodecInOut(pixels, 4, xsize, ysize); JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JXL_BOOL is_gray = TO_JXL_BOOL(pixel_format.num_channels < 3); + JxlColorEncodingSetToSRGB(&color_encoding, is_gray); EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderAddImageFrame(frame_settings, &pixel_format, pixels.data(), pixels.size())); @@ -188,17 +189,17 @@ void VerifyFrameEncoding(size_t xsize, size_t ysize, JxlEncoder* enc, basic_info.xsize = xsize; basic_info.ysize = ysize; if (frame_settings->values.lossless || lossy_use_original_profile) { - basic_info.uses_original_profile = true; + basic_info.uses_original_profile = JXL_TRUE; } else { - basic_info.uses_original_profile = false; + basic_info.uses_original_profile = JXL_FALSE; } // 16-bit alpha means this requires level 10 EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc, 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc, &basic_info)); JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, true); + JxlColorEncodingSetToSRGB(&color_encoding, JXL_TRUE); EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderSetColorEncoding(enc, &color_encoding)); - JxlColorEncodingSetToSRGB(&color_encoding, false); + JxlColorEncodingSetToSRGB(&color_encoding, JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc, &color_encoding)); pixel_format.num_channels = 1; EXPECT_EQ(JXL_ENC_ERROR, @@ -230,18 +231,20 @@ void VerifyFrameEncoding(size_t xsize, size_t ysize, JxlEncoder* enc, EXPECT_TRUE(jxl::test::DecodeFile( {}, jxl::Bytes(compressed.data(), compressed.size()), &decoded_io)); - EXPECT_LE( - ComputeDistance2(input_io.Main(), decoded_io.Main(), *JxlGetDefaultCms()), + static constexpr double kMaxButteraugli = #if JXL_HIGH_PRECISION - 1.84); + 1.84; #else - 8.7); + 8.7; #endif + EXPECT_LE( + ComputeDistance2(input_io.Main(), decoded_io.Main(), *JxlGetDefaultCms()), + kMaxButteraugli); } void VerifyFrameEncoding(JxlEncoder* enc, const JxlEncoderFrameSettings* frame_settings) { - VerifyFrameEncoding(63, 129, enc, frame_settings, 2700, + VerifyFrameEncoding(63, 129, enc, frame_settings, 27000, /*lossy_use_original_profile=*/false); } @@ -256,7 +259,7 @@ TEST(EncodeTest, EncoderResetTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); VerifyFrameEncoding(50, 200, enc.get(), - JxlEncoderFrameSettingsCreate(enc.get(), nullptr), 4300, + JxlEncoderFrameSettingsCreate(enc.get(), nullptr), 4550, false); // Encoder should become reusable for a new image from scratch after using // reset. @@ -293,7 +296,7 @@ TEST(EncodeTest, CmsTest) { JxlEncoderSetCms(enc.get(), cms); JxlEncoderFrameSettings* frame_settings = JxlEncoderFrameSettingsCreate(enc.get(), nullptr); - JxlEncoderSetFrameLossless(frame_settings, false); + JxlEncoderSetFrameLossless(frame_settings, JXL_FALSE); ASSERT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption(frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 8)); @@ -306,7 +309,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 5)); @@ -318,7 +321,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); const size_t nb_options = 23; const JxlEncoderFrameSettingId options[nb_options] = { JXL_ENC_FRAME_SETTING_EFFORT, @@ -346,7 +349,7 @@ TEST(EncodeTest, frame_settingsTest) { JXL_ENC_FRAME_SETTING_JPEG_KEEP_JUMBF}; const int too_low[nb_options] = {0, -2, -2, 3, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -1, -2, -1, -2, -2, -2}; + -2, -1, -2, -2, -2, -2, -2}; const int too_high[nb_options] = {11, 12, 5, 16, 6, 2, 4, -3, -3, 3, 70914, 3, 42, 4, 16, 12, 2, 2, 2, 4, 2, 2, 2}; @@ -367,14 +370,14 @@ TEST(EncodeTest, frame_settingsTest) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, options[i], in_range[i])); } - // Effort 10 should only work when expert options are allowed + // Effort 11 should only work when expert options are allowed EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderFrameSettingsSetOption( - frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 10)); + frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 11)); JxlEncoderAllowExpertOptions(enc.get()); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( - frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 10)); + frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 11)); // Non-existing option EXPECT_EQ(JXL_ENC_ERROR, @@ -438,14 +441,14 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_PHOTON_NOISE, 50.0f)); - VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 2500, false); + VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 3700, false); } { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetFrameLossless(frame_settings, JXL_TRUE)); VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 3000, false); @@ -456,16 +459,16 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetFrameDistance(frame_settings, 0.5)); - VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 3030, false); + VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 3130, false); EXPECT_EQ(0.5, enc->last_used_cparams.butteraugli_distance); } { JxlEncoderPtr enc = JxlEncoderMake(nullptr); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); // Disallowed negative distance EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderSetFrameDistance(frame_settings, -1)); } @@ -474,7 +477,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_DECODING_SPEED, 2)); @@ -486,7 +489,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_ERROR, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_GROUP_ORDER, 100)); @@ -506,7 +509,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_RESPONSIVE, 0)); @@ -519,7 +522,7 @@ TEST(EncodeTest, frame_settingsTest) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_PROGRESSIVE_DC, 2)); - VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 2830, + VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 3430, /*lossy_use_original_profile=*/false); EXPECT_EQ(false, enc->last_used_cparams.responsive); EXPECT_EQ(jxl::Override::kOn, enc->last_used_cparams.progressive_mode); @@ -530,7 +533,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ( JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetFloatOption( @@ -543,7 +546,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetFloatOption( frame_settings, @@ -571,7 +574,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ( JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( @@ -603,7 +606,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_JPEG_RECON_CFL, 0)); @@ -615,7 +618,7 @@ TEST(EncodeTest, frame_settingsTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_JPEG_RECON_CFL, 1)); @@ -629,14 +632,14 @@ TEST(EncodeTest, LossyEncoderUseOriginalProfileTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); VerifyFrameEncoding(63, 129, enc.get(), frame_settings, 7897, true); } { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_PROGRESSIVE_DC, 2)); @@ -646,7 +649,7 @@ TEST(EncodeTest, LossyEncoderUseOriginalProfileTest) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); ASSERT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption( frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 8)); @@ -787,7 +790,7 @@ TEST(EncodeTest, SingleFrameBoundedJXLCTest) { EXPECT_NE(nullptr, enc.get()); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderUseContainer(enc.get(), true)); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); size_t xsize = 71; size_t ysize = 23; @@ -798,12 +801,12 @@ TEST(EncodeTest, SingleFrameBoundedJXLCTest) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.uses_original_profile = false; + basic_info.uses_original_profile = JXL_FALSE; EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc.get(), 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); JxlColorEncoding color_encoding; JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/false); + /*is_gray=*/JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); EXPECT_EQ(JXL_ENC_SUCCESS, @@ -866,17 +869,17 @@ TEST(EncodeTest, CodestreamLevelTest) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.uses_original_profile = false; + basic_info.uses_original_profile = 0; JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc.get(), 10)); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JXL_BOOL is_gray = TO_JXL_BOOL(pixel_format.num_channels < 3); + JxlColorEncodingSetToSRGB(&color_encoding, is_gray); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); EXPECT_EQ(JXL_ENC_SUCCESS, @@ -915,7 +918,7 @@ TEST(EncodeTest, CodestreamLevelVerificationTest) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = 64; basic_info.ysize = 64; - basic_info.uses_original_profile = false; + basic_info.uses_original_profile = JXL_FALSE; JxlEncoderPtr enc = JxlEncoderMake(nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); @@ -943,7 +946,7 @@ TEST(EncodeTest, JXL_TRANSCODE_JPEG_TEST(JPEGReconstructionTest)) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderStoreJPEGMetadata(enc.get(), JXL_TRUE)); EXPECT_EQ(JXL_ENC_SUCCESS, @@ -983,7 +986,7 @@ TEST(EncodeTest, JXL_TRANSCODE_JPEG_TEST(ProgressiveJPEGReconstructionTest)) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); frame_settings->values.cparams.progressive_mode = jxl::Override::kOn; @@ -1043,7 +1046,7 @@ TEST(EncodeTest, BasicInfoTest) { EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); size_t xsize = 1; size_t ysize = 1; JxlPixelFormat pixel_format = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -1052,8 +1055,8 @@ TEST(EncodeTest, BasicInfoTest) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.uses_original_profile = false; - basic_info.have_animation = true; + basic_info.uses_original_profile = 0; + basic_info.have_animation = 1; basic_info.intensity_target = 123.4; basic_info.min_nits = 5.0; basic_info.linear_below = 12.7; @@ -1067,7 +1070,7 @@ TEST(EncodeTest, BasicInfoTest) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc.get(), 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/false); + JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); @@ -1155,7 +1158,7 @@ TEST(EncodeTest, AnimationHeaderTest) { EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); size_t xsize = 1; size_t ysize = 1; JxlPixelFormat pixel_format = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -1164,14 +1167,14 @@ TEST(EncodeTest, AnimationHeaderTest) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.have_animation = true; + basic_info.have_animation = JXL_TRUE; basic_info.animation.tps_numerator = 1000; basic_info.animation.tps_denominator = 1; basic_info.animation.have_timecodes = JXL_TRUE; EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc.get(), 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/false); + JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); @@ -1258,7 +1261,7 @@ TEST(EncodeTest, CroppedFrameTest) { EXPECT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); size_t xsize = 300; size_t ysize = 300; JxlPixelFormat pixel_format = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -1273,7 +1276,7 @@ TEST(EncodeTest, CroppedFrameTest) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc.get(), 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/false); + JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); @@ -1358,7 +1361,7 @@ TEST_P(EncodeBoxTest, JXL_BOXES_TEST(BoxTest)) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderUseBoxes(enc.get())); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); size_t xsize = 50; size_t ysize = 17; JxlPixelFormat pixel_format = {4, JXL_TYPE_UINT16, JXL_BIG_ENDIAN, 0}; @@ -1367,12 +1370,12 @@ TEST_P(EncodeBoxTest, JXL_BOXES_TEST(BoxTest)) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.uses_original_profile = false; + basic_info.uses_original_profile = JXL_FALSE; EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc.get(), 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); JxlColorEncoding color_encoding; JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/false); + /*is_gray=*/JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); @@ -1386,7 +1389,8 @@ TEST_P(EncodeBoxTest, JXL_BOXES_TEST(BoxTest)) { const uint8_t* exif_data = reinterpret_cast(exif_test_string); // Skip the 4 zeroes for strlen const size_t exif_size = 4 + strlen(exif_test_string + 4); - JxlEncoderAddBox(enc.get(), "Exif", exif_data, exif_size, compress_box); + JxlEncoderAddBox(enc.get(), "Exif", exif_data, exif_size, + TO_JXL_BOOL(compress_box)); // Write to output ProcessEncoder(enc.get(), compressed, next_out, avail_out); @@ -1405,7 +1409,8 @@ TEST_P(EncodeBoxTest, JXL_BOXES_TEST(BoxTest)) { constexpr const char* xml_test_string = ""; const uint8_t* xml_data = reinterpret_cast(xml_test_string); size_t xml_size = strlen(xml_test_string); - JxlEncoderAddBox(enc.get(), "XML ", xml_data, xml_size, compress_box); + JxlEncoderAddBox(enc.get(), "XML ", xml_data, xml_size, + TO_JXL_BOOL(compress_box)); // Indicate this is the last box JxlEncoderCloseBoxes(enc.get()); @@ -1495,7 +1500,7 @@ TEST(EncodeTest, JXL_TRANSCODE_JPEG_TEST(JPEGFrameTest)) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); JxlEncoderFrameSettingsSetOption(frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 1); if (!skip_basic_info) { @@ -1503,13 +1508,13 @@ TEST(EncodeTest, JXL_TRANSCODE_JPEG_TEST(JPEGFrameTest)) { JxlEncoderInitBasicInfo(&basic_info); basic_info.xsize = orig_io.xsize(); basic_info.ysize = orig_io.ysize(); - basic_info.uses_original_profile = true; + basic_info.uses_original_profile = JXL_TRUE; EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc.get(), &basic_info)); } if (!skip_color_encoding) { JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/false); + JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc.get(), &color_encoding)); } @@ -1696,14 +1701,16 @@ class JxlChunkedFrameInputSourceAdapter { struct StreamingTestParam { size_t bitmask; - bool use_container() const { return bitmask & 0x1; } - bool return_large_buffers() const { return bitmask & 0x2; } - bool multiple_frames() const { return bitmask & 0x4; } - bool fast_lossless() const { return bitmask & 0x8; } - bool can_seek() const { return bitmask & 0x10; } - bool with_extra_channels() const { return bitmask & 0x20; } - bool color_includes_alpha() const { return bitmask & 0x40; } - bool onegroup() const { return bitmask & 0x80; } + bool use_container() const { return static_cast(bitmask & 0x1); } + bool return_large_buffers() const { return static_cast(bitmask & 0x2); } + bool multiple_frames() const { return static_cast(bitmask & 0x4); } + bool fast_lossless() const { return static_cast(bitmask & 0x8); } + bool can_seek() const { return static_cast(bitmask & 0x10); } + bool with_extra_channels() const { return static_cast(bitmask & 0x20); } + bool color_includes_alpha() const { + return static_cast(bitmask & 0x40); + } + bool onegroup() const { return static_cast(bitmask & 0x80); } bool is_lossless() const { return fast_lossless(); } @@ -1773,8 +1780,9 @@ class EncoderStreamingTest : public testing::TestWithParam { bool include_alpha, bool is_lossless) { basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.num_extra_channels = number_extra_channels + include_alpha; - basic_info.uses_original_profile = is_lossless; + basic_info.num_extra_channels = + number_extra_channels + (include_alpha ? 1 : 0); + basic_info.uses_original_profile = TO_JXL_BOOL(is_lossless); } static void SetupEncoder(JxlEncoderFrameSettings* frame_settings, @@ -1791,7 +1799,7 @@ class EncoderStreamingTest : public testing::TestWithParam { frame_settings, JXL_ENC_FRAME_SETTING_EFFORT, 1)); } JxlColorEncoding color_encoding; - JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/false); + JxlColorEncodingSetToSRGB(&color_encoding, /*is_gray=*/JXL_FALSE); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc, &color_encoding)); EXPECT_EQ(JXL_ENC_SUCCESS, @@ -1825,7 +1833,7 @@ class EncoderStreamingTest : public testing::TestWithParam { // Copy pixel data here because it is only guaranteed to be available // during the call to JxlEncoderAddImageFrame(). std::vector pixels(frame.pixels_size); - memcpy(&pixels[0], frame.pixels(), pixels.size()); + memcpy(pixels.data(), frame.pixels(), pixels.size()); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderAddImageFrame(frame_settings, &frame.format, pixels.data(), pixels.size())); @@ -1834,7 +1842,7 @@ class EncoderStreamingTest : public testing::TestWithParam { // Copy pixel data here because it is only guaranteed to be available // during the call to JxlEncoderSetExtraChannelBuffer(). std::vector ec_pixels(ec_frame.pixels_size); - memcpy(&ec_pixels[0], ec_frame.pixels(), ec_pixels.size()); + memcpy(ec_pixels.data(), ec_frame.pixels(), ec_pixels.size()); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetExtraChannelBuffer( frame_settings, &ec_frame.format, ec_pixels.data(), ec_pixels.size(), i)); @@ -1885,7 +1893,7 @@ TEST_P(EncoderStreamingTest, OutputCallback) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); SetupEncoder(frame_settings, p, basic_info, number_extra_channels, false); SetupInputNonStreaming(frame_settings, p, number_extra_channels, frame, ec_frame); @@ -1900,7 +1908,7 @@ TEST_P(EncoderStreamingTest, OutputCallback) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); SetupEncoder(frame_settings, p, basic_info, number_extra_channels, true); SetupInputNonStreaming(frame_settings, p, number_extra_channels, frame, ec_frame); @@ -1938,7 +1946,7 @@ TEST_P(EncoderStreamingTest, ChunkedFrame) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); SetupEncoder(frame_settings, p, basic_info, number_extra_channels, false); SetupInputNonStreaming(frame_settings, p, number_extra_channels, frame, ec_frame); @@ -1952,7 +1960,7 @@ TEST_P(EncoderStreamingTest, ChunkedFrame) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); SetupEncoder(frame_settings, p, basic_info, number_extra_channels, true); SetupInputStreaming(frame_settings, p, number_extra_channels, frame, ec_frame); @@ -1988,7 +1996,7 @@ TEST_P(EncoderStreamingTest, ChunkedAndOutputCallback) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); SetupEncoder(frame_settings, p, basic_info, number_extra_channels, false); SetupInputNonStreaming(frame_settings, p, number_extra_channels, frame, ec_frame); @@ -2003,7 +2011,7 @@ TEST_P(EncoderStreamingTest, ChunkedAndOutputCallback) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); ASSERT_NE(nullptr, enc.get()); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); SetupEncoder(frame_settings, p, basic_info, number_extra_channels, true); JxlStreamingAdapter streaming_adapter = JxlStreamingAdapter(enc.get(), p.return_large_buffers(), p.can_seek()); @@ -2049,7 +2057,7 @@ TEST(EncoderTest, CMYK) { JxlEncoderStruct* enc = enc_ptr.get(); ASSERT_NE(nullptr, enc); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc, NULL); + JxlEncoderFrameSettingsCreate(enc, nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc, &basic_info)); JxlExtraChannelInfo channel_info; diff --git a/third_party/jpeg-xl/lib/jxl/entropy_coder.cc b/third_party/jpeg-xl/lib/jxl/entropy_coder.cc index a90ed0257a..5dc101b36f 100644 --- a/third_party/jpeg-xl/lib/jxl/entropy_coder.cc +++ b/third_party/jpeg-xl/lib/jxl/entropy_coder.cc @@ -33,7 +33,7 @@ Status DecodeBlockCtxMap(BitReader* br, BlockCtxMap* block_ctx_map) { auto& dct = block_ctx_map->dc_thresholds; auto& qft = block_ctx_map->qf_thresholds; auto& ctx_map = block_ctx_map->ctx_map; - bool is_default = br->ReadFixedBits<1>(); + bool is_default = static_cast(br->ReadFixedBits<1>()); if (is_default) { *block_ctx_map = BlockCtxMap(); return true; diff --git a/third_party/jpeg-xl/lib/jxl/fast_dct-inl.h b/third_party/jpeg-xl/lib/jxl/fast_dct-inl.h index de1f845901..e315200b0c 100644 --- a/third_party/jpeg-xl/lib/jxl/fast_dct-inl.h +++ b/third_party/jpeg-xl/lib/jxl/fast_dct-inl.h @@ -191,7 +191,7 @@ HWY_NOINLINE void TestFastIDCT() { } } printf("max error: %f mantissa bits: %d\n", max_error, - 14 - (int)integer_bits); + 14 - static_cast(integer_bits)); #endif } diff --git a/third_party/jpeg-xl/lib/jxl/fast_dct.cc b/third_party/jpeg-xl/lib/jxl/fast_dct.cc deleted file mode 100644 index d796018fd0..0000000000 --- a/third_party/jpeg-xl/lib/jxl/fast_dct.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) the JPEG XL Project Authors. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#undef HWY_TARGET_INCLUDE -#define HWY_TARGET_INCLUDE "lib/jxl/fast_dct.cc" -#include -#include - -#include "lib/jxl/base/random.h" -#include "lib/jxl/dct-inl.h" -#include "lib/jxl/fast_dct-inl.h" -HWY_BEFORE_NAMESPACE(); -namespace jxl { -namespace HWY_NAMESPACE { -namespace { -void BenchmarkFloatIDCT32x32() { TestFloatIDCT<32, 32>(); } -void BenchmarkFastIDCT32x32() { TestFastIDCT<32, 32>(); } -} // namespace -// NOLINTNEXTLINE(google-readability-namespace-comments) -} // namespace HWY_NAMESPACE -} // namespace jxl -HWY_AFTER_NAMESPACE(); - -#if HWY_ONCE -namespace jxl { -HWY_EXPORT(BenchmarkFloatIDCT32x32); -HWY_EXPORT(BenchmarkFastIDCT32x32); -void BenchmarkFloatIDCT32x32() { - HWY_DYNAMIC_DISPATCH(BenchmarkFloatIDCT32x32)(); -} -void BenchmarkFastIDCT32x32() { - HWY_DYNAMIC_DISPATCH(BenchmarkFastIDCT32x32)(); -} -} // namespace jxl -#endif diff --git a/third_party/jpeg-xl/lib/jxl/fast_dct.h b/third_party/jpeg-xl/lib/jxl/fast_dct.h deleted file mode 100644 index 641933d8a0..0000000000 --- a/third_party/jpeg-xl/lib/jxl/fast_dct.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) the JPEG XL Project Authors. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -namespace jxl { -void BenchmarkFloatIDCT32x32(); -void BenchmarkFastIDCT32x32(); -} // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/fast_dct_test.cc b/third_party/jpeg-xl/lib/jxl/fast_dct_test.cc index a55b67afb2..417e202988 100644 --- a/third_party/jpeg-xl/lib/jxl/fast_dct_test.cc +++ b/third_party/jpeg-xl/lib/jxl/fast_dct_test.cc @@ -12,7 +12,6 @@ #include "lib/jxl/base/random.h" #include "lib/jxl/dct-inl.h" #include "lib/jxl/fast_dct-inl.h" -#include "lib/jxl/fast_dct.h" #include "lib/jxl/testing.h" #include "lib/jxl/transpose-inl.h" @@ -21,9 +20,13 @@ #include HWY_BEFORE_NAMESPACE(); namespace jxl { + namespace HWY_NAMESPACE { namespace { +void BenchmarkFloatIDCT32x32() { TestFloatIDCT<32, 32>(); } +void BenchmarkFastIDCT32x32() { TestFastIDCT<32, 32>(); } + template HWY_NOINLINE void TestFastTranspose() { #if HWY_TARGET == HWY_NEON @@ -370,8 +373,8 @@ HWY_EXPORT_AND_TEST_P(FastDCTTargetTest, TestFloatIDCT256x256); HWY_EXPORT_AND_TEST_P(FastDCTTargetTest, TestFastIDCT256x256); */ -TEST(FastDCTTest, TestWrapperFloat) { BenchmarkFloatIDCT32x32(); } -TEST(FastDCTTest, TestWrapperFast) { BenchmarkFastIDCT32x32(); } +HWY_EXPORT_AND_TEST_P(FastDCTTargetTest, BenchmarkFloatIDCT32x32); +HWY_EXPORT_AND_TEST_P(FastDCTTargetTest, BenchmarkFastIDCT32x32); } // namespace jxl #endif // HWY_ONCE diff --git a/third_party/jpeg-xl/lib/jxl/fast_math_test.cc b/third_party/jpeg-xl/lib/jxl/fast_math_test.cc index 868e1b72f4..b242dbe575 100644 --- a/third_party/jpeg-xl/lib/jxl/fast_math_test.cc +++ b/third_party/jpeg-xl/lib/jxl/fast_math_test.cc @@ -167,7 +167,8 @@ HWY_NOINLINE void TestFastXYB() { for (int cr = 0; cr < n; cr += kChunk) { for (int cg = 0; cg < n; cg += kChunk) { for (int cb = 0; cb < n; cb += kChunk) { - Image3F chunk(kChunk * kChunk, kChunk); + JXL_ASSIGN_OR_DIE(Image3F chunk, + Image3F::Create(kChunk * kChunk, kChunk)); for (int ir = 0; ir < kChunk; ir++) { for (int ig = 0; ig < kChunk; ig++) { for (int ib = 0; ib < kChunk; ib++) { @@ -181,9 +182,10 @@ HWY_NOINLINE void TestFastXYB() { } } ib.SetFromImage(std::move(chunk), ColorEncoding::SRGB()); - Image3F xyb(kChunk * kChunk, kChunk); + JXL_ASSIGN_OR_DIE(Image3F xyb, + Image3F::Create(kChunk * kChunk, kChunk)); std::vector roundtrip(kChunk * kChunk * kChunk * 3); - ToXYB(ib, nullptr, &xyb, *JxlGetDefaultCms()); + JXL_CHECK(ToXYB(ib, nullptr, &xyb, *JxlGetDefaultCms())); for (int y = 0; y < kChunk; y++) { const float* xyba[4] = {xyb.PlaneRow(0, y), xyb.PlaneRow(1, y), xyb.PlaneRow(2, y), nullptr}; diff --git a/third_party/jpeg-xl/lib/jxl/fields.cc b/third_party/jpeg-xl/lib/jxl/fields.cc index 746d7e4d30..6bb5eae25d 100644 --- a/third_party/jpeg-xl/lib/jxl/fields.cc +++ b/third_party/jpeg-xl/lib/jxl/fields.cc @@ -109,7 +109,7 @@ struct SetDefaultVisitor : public VisitorBase { class AllDefaultVisitor : public VisitorBase { public: - explicit AllDefaultVisitor() : VisitorBase() {} + explicit AllDefaultVisitor() = default; Status Bits(const size_t bits, const uint32_t default_value, uint32_t* JXL_RESTRICT value) override { @@ -148,7 +148,7 @@ class AllDefaultVisitor : public VisitorBase { class ReadVisitor : public VisitorBase { public: - explicit ReadVisitor(BitReader* reader) : VisitorBase(), reader_(reader) {} + explicit ReadVisitor(BitReader* reader) : reader_(reader) {} Status Bits(const size_t bits, const uint32_t /*default_value*/, uint32_t* JXL_RESTRICT value) override { @@ -267,7 +267,8 @@ class ReadVisitor : public VisitorBase { uint64_t total_extension_bits_ = 0; size_t pos_after_ext_size_ = 0; // 0 iff extensions == 0. - friend Status jxl::CheckHasEnoughBits(Visitor*, size_t); + friend Status jxl::CheckHasEnoughBits(Visitor* /* visitor */, + size_t /* bits */); }; class MaxBitsVisitor : public VisitorBase { @@ -321,7 +322,7 @@ class MaxBitsVisitor : public VisitorBase { class CanEncodeVisitor : public VisitorBase { public: - explicit CanEncodeVisitor() : VisitorBase() {} + explicit CanEncodeVisitor() = default; Status Bits(const size_t bits, const uint32_t /*default_value*/, uint32_t* JXL_RESTRICT value) override { diff --git a/third_party/jpeg-xl/lib/jxl/fields.h b/third_party/jpeg-xl/lib/jxl/fields.h index d05fe4517e..a8d8d8671a 100644 --- a/third_party/jpeg-xl/lib/jxl/fields.h +++ b/third_party/jpeg-xl/lib/jxl/fields.h @@ -298,7 +298,7 @@ class ExtensionStates { class VisitorBase : public Visitor { public: - explicit VisitorBase() {} + explicit VisitorBase() = default; ~VisitorBase() override { JXL_ASSERT(depth_ == 0); } // This is the only call site of Fields::VisitFields. diff --git a/third_party/jpeg-xl/lib/jxl/fields_test.cc b/third_party/jpeg-xl/lib/jxl/fields_test.cc index b178a6bd6a..0584458d07 100644 --- a/third_party/jpeg-xl/lib/jxl/fields_test.cc +++ b/third_party/jpeg-xl/lib/jxl/fields_test.cc @@ -200,7 +200,8 @@ TEST(FieldsTest, TestRoundtripSize) { SizeHeader size; ASSERT_TRUE(size.Set(123 + 77 * i, 7 + i)); - size_t extension_bits = 999, total_bits = 999; // Initialize as garbage. + size_t extension_bits = 999; + size_t total_bits = 999; // Initialize as garbage. ASSERT_TRUE(Bundle::CanEncode(size, &extension_bits, &total_bits)); EXPECT_EQ(0u, extension_bits); @@ -230,7 +231,8 @@ TEST(FieldsTest, TestCropRect) { f.frame_origin.y0 = i; f.frame_size.xsize = 1000 + i; f.frame_size.ysize = 1000 + i; - size_t extension_bits = 0, total_bits = 0; + size_t extension_bits = 0; + size_t total_bits = 0; ASSERT_TRUE(Bundle::CanEncode(f, &extension_bits, &total_bits)); EXPECT_EQ(0u, extension_bits); EXPECT_GE(total_bits, 9u); @@ -241,7 +243,8 @@ TEST(FieldsTest, TestPreview) { for (uint32_t i = 1; i < 4360; ++i) { PreviewHeader p; ASSERT_TRUE(p.Set(i, i)); - size_t extension_bits = 0, total_bits = 0; + size_t extension_bits = 0; + size_t total_bits = 0; ASSERT_TRUE(Bundle::CanEncode(p, &extension_bits, &total_bits)); EXPECT_EQ(0u, extension_bits); EXPECT_GE(total_bits, 6u); @@ -254,7 +257,8 @@ TEST(FieldsTest, TestRoundtripFrame) { FrameHeader h(&metadata); h.extensions = 0x800; - size_t extension_bits = 999, total_bits = 999; // Initialize as garbage. + size_t extension_bits = 999; + size_t total_bits = 999; // Initialize as garbage. ASSERT_TRUE(Bundle::CanEncode(h, &extension_bits, &total_bits)); EXPECT_EQ(0u, extension_bits); BitWriter writer; @@ -277,7 +281,8 @@ TEST(FieldsTest, TestRoundtripFrame) { TEST(FieldsTest, TestOutOfRange) { SizeHeader h; ASSERT_TRUE(h.Set(0xFFFFFFFFull, 0xFFFFFFFFull)); - size_t extension_bits = 999, total_bits = 999; // Initialize as garbage. + size_t extension_bits = 999; + size_t total_bits = 999; // Initialize as garbage. ASSERT_FALSE(Bundle::CanEncode(h, &extension_bits, &total_bits)); } #endif @@ -315,12 +320,12 @@ struct NewBundle : public Fields { visitor->U32(Bits(7), Bits(12), Bits(16), Bits(32), 0, &old_large)); JXL_QUIET_RETURN_IF_ERROR(visitor->BeginExtensions(&extensions)); - if (visitor->Conditional(extensions & 1)) { + if (visitor->Conditional((extensions & 1) != 0)) { JXL_QUIET_RETURN_IF_ERROR( visitor->U32(Val(2), Bits(2), Bits(3), Bits(4), 2, &new_small)); JXL_QUIET_RETURN_IF_ERROR(visitor->F16(-2.0f, &new_f)); } - if (visitor->Conditional(extensions & 2)) { + if (visitor->Conditional((extensions & 2) != 0)) { JXL_QUIET_RETURN_IF_ERROR( visitor->U32(Bits(9), Bits(12), Bits(16), Bits(32), 0, &new_large)); } @@ -349,7 +354,8 @@ TEST(FieldsTest, TestNewDecoderOldData) { const size_t kMaxOutBytes = 999; BitWriter writer; // Make sure values are initialized by code under test. - size_t extension_bits = 12345, total_bits = 12345; + size_t extension_bits = 12345; + size_t total_bits = 12345; ASSERT_TRUE(Bundle::CanEncode(old_bundle, &extension_bits, &total_bits)); ASSERT_LE(total_bits, kMaxOutBytes * kBitsPerByte); EXPECT_EQ(0u, extension_bits); @@ -393,7 +399,8 @@ TEST(FieldsTest, TestOldDecoderNewData) { constexpr size_t kMaxOutBytes = 999; BitWriter writer; // Make sure values are initialized by code under test. - size_t extension_bits = 12345, total_bits = 12345; + size_t extension_bits = 12345; + size_t total_bits = 12345; ASSERT_TRUE(Bundle::CanEncode(new_bundle, &extension_bits, &total_bits)); EXPECT_NE(0u, extension_bits); AuxOut aux_out; diff --git a/third_party/jpeg-xl/lib/jxl/frame_header.cc b/third_party/jpeg-xl/lib/jxl/frame_header.cc index a9e79ff1b8..6648e6d8cc 100644 --- a/third_party/jpeg-xl/lib/jxl/frame_header.cc +++ b/third_party/jpeg-xl/lib/jxl/frame_header.cc @@ -397,16 +397,18 @@ Status FrameHeader::VisitFields(Visitor* JXL_RESTRICT visitor) { } else if (visitor->Conditional(frame_type == FrameType::kReferenceOnly)) { JXL_QUIET_RETURN_IF_ERROR( visitor->Bool(true, &save_before_color_transform)); + size_t xsize = custom_size_or_origin ? frame_size.xsize + : nonserialized_metadata->xsize(); + size_t ysize = custom_size_or_origin ? frame_size.ysize + : nonserialized_metadata->ysize(); if (!save_before_color_transform && - (frame_size.xsize < nonserialized_metadata->xsize() || - frame_size.ysize < nonserialized_metadata->ysize() || - frame_origin.x0 != 0 || frame_origin.y0 != 0)) { + (xsize < nonserialized_metadata->xsize() || + ysize < nonserialized_metadata->ysize() || frame_origin.x0 != 0 || + frame_origin.y0 != 0)) { return JXL_FAILURE( "non-patch reference frame with invalid crop: %" PRIuS "x%" PRIuS "%+d%+d", - static_cast(frame_size.xsize), - static_cast(frame_size.ysize), - static_cast(frame_origin.x0), + xsize, ysize, static_cast(frame_origin.x0), static_cast(frame_origin.y0)); } } diff --git a/third_party/jpeg-xl/lib/jxl/frame_header.h b/third_party/jpeg-xl/lib/jxl/frame_header.h index b246bf813e..30c62d5f27 100644 --- a/third_party/jpeg-xl/lib/jxl/frame_header.h +++ b/third_party/jpeg-xl/lib/jxl/frame_header.h @@ -82,8 +82,8 @@ struct YCbCrChromaSubsampling : public Fields { Status VisitFields(Visitor* JXL_RESTRICT visitor) override { // TODO(veluca): consider allowing 4x downsamples - for (size_t i = 0; i < 3; i++) { - JXL_QUIET_RETURN_IF_ERROR(visitor->Bits(2, 0, &channel_mode_[i])); + for (uint32_t& ch : channel_mode_) { + JXL_QUIET_RETURN_IF_ERROR(visitor->Bits(2, 0, &ch)); } Recompute(); return true; @@ -152,9 +152,9 @@ struct YCbCrChromaSubsampling : public Fields { void Recompute() { maxhs_ = 0; maxvs_ = 0; - for (size_t i = 0; i < 3; i++) { - maxhs_ = std::max(maxhs_, kHShift[channel_mode_[i]]); - maxvs_ = std::max(maxvs_, kVShift[channel_mode_[i]]); + for (uint32_t ch : channel_mode_) { + maxhs_ = std::max(maxhs_, kHShift[ch]); + maxvs_ = std::max(maxvs_, kVShift[ch]); } } static const uint8_t kHShift[4]; diff --git a/third_party/jpeg-xl/lib/jxl/gradient_test.cc b/third_party/jpeg-xl/lib/jxl/gradient_test.cc index 055a419f5b..d2c83619fc 100644 --- a/third_party/jpeg-xl/lib/jxl/gradient_test.cc +++ b/third_party/jpeg-xl/lib/jxl/gradient_test.cc @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -45,10 +44,10 @@ double PointLineDist(double x0, double y0, double x1, double y1, double x, // angle in which the change direction happens. Image3F GenerateTestGradient(uint32_t color0, uint32_t color1, double angle, size_t xsize, size_t ysize) { - Image3F image(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3F image, Image3F::Create(xsize, ysize)); - double x0 = xsize / 2; - double y0 = ysize / 2; + double x0 = xsize / 2.0; + double y0 = ysize / 2.0; double x1 = x0 + std::sin(angle / 360.0 * 2.0 * kPi); double y1 = y0 + std::cos(angle / 360.0 * 2.0 * kPi); @@ -78,63 +77,60 @@ Image3F GenerateTestGradient(uint32_t color0, uint32_t color1, double angle, // delta and right delta (top/bottom for vertical direction). // The radius over which the derivative is computed is only 1 pixel and it only // checks two angles (hor and ver), but this approximation works well enough. -static ImageF Gradient2(const ImageF& image) { +Image3F Gradient2(const Image3F& image) { size_t xsize = image.xsize(); size_t ysize = image.ysize(); - ImageF image2(image.xsize(), image.ysize()); - for (size_t y = 1; y + 1 < ysize; y++) { - const auto* JXL_RESTRICT row0 = image.Row(y - 1); - const auto* JXL_RESTRICT row1 = image.Row(y); - const auto* JXL_RESTRICT row2 = image.Row(y + 1); - auto* row_out = image2.Row(y); - for (size_t x = 1; x + 1 < xsize; x++) { - float ddx = (row1[x] - row1[x - 1]) - (row1[x + 1] - row1[x]); - float ddy = (row1[x] - row0[x]) - (row2[x] - row1[x]); - row_out[x] = std::max(fabsf(ddx), fabsf(ddy)); - } - } - // Copy to the borders - if (ysize > 2) { - auto* JXL_RESTRICT row0 = image2.Row(0); - const auto* JXL_RESTRICT row1 = image2.Row(1); - const auto* JXL_RESTRICT row2 = image2.Row(ysize - 2); - auto* JXL_RESTRICT row3 = image2.Row(ysize - 1); - for (size_t x = 1; x + 1 < xsize; x++) { - row0[x] = row1[x]; - row3[x] = row2[x]; - } - } else { - const auto* row0_in = image.Row(0); - const auto* row1_in = image.Row(ysize - 1); - auto* row0_out = image2.Row(0); - auto* row1_out = image2.Row(ysize - 1); - for (size_t x = 1; x + 1 < xsize; x++) { - // Image too narrow, take first derivative instead - row0_out[x] = row1_out[x] = fabsf(row0_in[x] - row1_in[x]); + JXL_ASSIGN_OR_DIE(Image3F image2, Image3F::Create(xsize, ysize)); + for (size_t c = 0; c < 3; ++c) { + for (size_t y = 1; y + 1 < ysize; y++) { + const auto* JXL_RESTRICT row0 = image.ConstPlaneRow(c, y - 1); + const auto* JXL_RESTRICT row1 = image.ConstPlaneRow(c, y); + const auto* JXL_RESTRICT row2 = image.ConstPlaneRow(c, y + 1); + auto* row_out = image2.PlaneRow(c, y); + for (size_t x = 1; x + 1 < xsize; x++) { + float ddx = (row1[x] - row1[x - 1]) - (row1[x + 1] - row1[x]); + float ddy = (row1[x] - row0[x]) - (row2[x] - row1[x]); + row_out[x] = std::max(fabsf(ddx), fabsf(ddy)); + } } - } - if (xsize > 2) { - for (size_t y = 0; y < ysize; y++) { - auto* row = image2.Row(y); - row[0] = row[1]; - row[xsize - 1] = row[xsize - 2]; + // Copy to the borders + if (ysize > 2) { + auto* JXL_RESTRICT row0 = image2.PlaneRow(c, 0); + const auto* JXL_RESTRICT row1 = image2.PlaneRow(c, 1); + const auto* JXL_RESTRICT row2 = image2.PlaneRow(c, ysize - 2); + auto* JXL_RESTRICT row3 = image2.PlaneRow(c, ysize - 1); + for (size_t x = 1; x + 1 < xsize; x++) { + row0[x] = row1[x]; + row3[x] = row2[x]; + } + } else { + const auto* row0_in = image.ConstPlaneRow(c, 0); + const auto* row1_in = image.ConstPlaneRow(c, ysize - 1); + auto* row0_out = image2.PlaneRow(c, 0); + auto* row1_out = image2.PlaneRow(c, ysize - 1); + for (size_t x = 1; x + 1 < xsize; x++) { + // Image too narrow, take first derivative instead + row0_out[x] = row1_out[x] = fabsf(row0_in[x] - row1_in[x]); + } } - } else { - for (size_t y = 0; y < ysize; y++) { - const auto* JXL_RESTRICT row_in = image.Row(y); - auto* row_out = image2.Row(y); - // Image too narrow, take first derivative instead - row_out[0] = row_out[xsize - 1] = fabsf(row_in[0] - row_in[xsize - 1]); + if (xsize > 2) { + for (size_t y = 0; y < ysize; y++) { + auto* row = image2.PlaneRow(c, y); + row[0] = row[1]; + row[xsize - 1] = row[xsize - 2]; + } + } else { + for (size_t y = 0; y < ysize; y++) { + const auto* JXL_RESTRICT row_in = image.ConstPlaneRow(c, y); + auto* row_out = image2.PlaneRow(c, y); + // Image too narrow, take first derivative instead + row_out[0] = row_out[xsize - 1] = fabsf(row_in[0] - row_in[xsize - 1]); + } } } return image2; } -static Image3F Gradient2(const Image3F& image) { - return Image3F(Gradient2(image.Plane(0)), Gradient2(image.Plane(1)), - Gradient2(image.Plane(2))); -} - /* Tests if roundtrip with jxl on a gradient image doesn't cause banding. Only tests if use_gradient is true. Set to false for debugging to see the @@ -173,17 +169,19 @@ void TestGradient(ThreadPool* pool, uint32_t color0, uint32_t color1, // butteraugli_distance). Image3F gradient2 = Gradient2(*io2.Main().color()); - std::array image_max; - Image3Max(gradient2, &image_max); - // TODO(jyrki): These values used to work with 0.2, 0.2, 0.2. - EXPECT_LE(image_max[0], 3.15); - EXPECT_LE(image_max[1], 1.72); - EXPECT_LE(image_max[2], 5.05); + float image_min; + float image_max; + ImageMinMax(gradient2.Plane(0), &image_min, &image_max); + EXPECT_LE(image_max, 3.15); + ImageMinMax(gradient2.Plane(1), &image_min, &image_max); + EXPECT_LE(image_max, 1.72); + ImageMinMax(gradient2.Plane(2), &image_min, &image_max); + EXPECT_LE(image_max, 5.05); } } -static constexpr bool fast_mode = true; +constexpr bool fast_mode = true; TEST(GradientTest, SteepGradient) { test::ThreadPoolForTests pool(8); diff --git a/third_party/jpeg-xl/lib/jxl/headers.cc b/third_party/jpeg-xl/lib/jxl/headers.cc index db88147687..52e7cf5db3 100644 --- a/third_party/jpeg-xl/lib/jxl/headers.cc +++ b/third_party/jpeg-xl/lib/jxl/headers.cc @@ -17,7 +17,7 @@ struct Rational { // Returns floor(multiplicand * rational). constexpr uint32_t MulTruncate(uint32_t multiplicand) const { - return uint64_t(multiplicand) * num / den; + return static_cast(multiplicand) * num / den; } uint32_t num; diff --git a/third_party/jpeg-xl/lib/jxl/icc_codec.cc b/third_party/jpeg-xl/lib/jxl/icc_codec.cc index a1f118ebfb..8501c684ac 100644 --- a/third_party/jpeg-xl/lib/jxl/icc_codec.cc +++ b/third_party/jpeg-xl/lib/jxl/icc_codec.cc @@ -33,7 +33,8 @@ void Shuffle(uint8_t* data, size_t size, size_t width) { size_t height = (size + width - 1) / width; // amount of rows of output PaddedBytes result(size); // i = output index, j input index - size_t s = 0, j = 0; + size_t s = 0; + size_t j = 0; for (size_t i = 0; i < size; i++) { result[i] = data[j]; j += height; @@ -55,7 +56,8 @@ uint64_t DecodeVarInt(const uint8_t* input, size_t inputSize, size_t* pos) { size_t i; uint64_t ret = 0; for (i = 0; *pos + i < inputSize && i < 10; ++i) { - ret |= uint64_t(input[*pos + i] & 127) << uint64_t(7 * i); + ret |= static_cast(input[*pos + i] & 127) + << static_cast(7 * i); // If the next-byte flag is not set, stop if ((input[*pos + i] & 128) == 0) break; } diff --git a/third_party/jpeg-xl/lib/jxl/icc_codec.h b/third_party/jpeg-xl/lib/jxl/icc_codec.h index 87e523a575..8b880c7d3b 100644 --- a/third_party/jpeg-xl/lib/jxl/icc_codec.h +++ b/third_party/jpeg-xl/lib/jxl/icc_codec.h @@ -39,12 +39,6 @@ struct ICCReader { PaddedBytes decompressed_; }; -// Exposed only for testing -Status PredictICC(const uint8_t* icc, size_t size, PaddedBytes* result); - -// Exposed only for testing -Status UnpredictICC(const uint8_t* enc, size_t size, PaddedBytes* result); - } // namespace jxl #endif // LIB_JXL_ICC_CODEC_H_ diff --git a/third_party/jpeg-xl/lib/jxl/icc_codec_common.cc b/third_party/jpeg-xl/lib/jxl/icc_codec_common.cc index d420567b6f..1cb4542687 100644 --- a/third_party/jpeg-xl/lib/jxl/icc_codec_common.cc +++ b/third_party/jpeg-xl/lib/jxl/icc_codec_common.cc @@ -17,7 +17,7 @@ namespace jxl { namespace { -static uint8_t ByteKind1(uint8_t b) { +uint8_t ByteKind1(uint8_t b) { if ('a' <= b && b <= 'z') return 0; if ('A' <= b && b <= 'Z') return 0; if ('0' <= b && b <= '9') return 1; @@ -30,7 +30,7 @@ static uint8_t ByteKind1(uint8_t b) { return 7; } -static uint8_t ByteKind2(uint8_t b) { +uint8_t ByteKind2(uint8_t b) { if ('a' <= b && b <= 'z') return 0; if ('A' <= b && b <= 'Z') return 0; if ('0' <= b && b <= '9') return 1; @@ -105,7 +105,7 @@ const uint8_t kIccInitialHeaderPrediction[kICCHeaderSize] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -const Span ICCInitialHeaderPrediction() { +Span ICCInitialHeaderPrediction() { return Bytes(kIccInitialHeaderPrediction); } diff --git a/third_party/jpeg-xl/lib/jxl/icc_codec_common.h b/third_party/jpeg-xl/lib/jxl/icc_codec_common.h index 702a0e7b1f..0922d74145 100644 --- a/third_party/jpeg-xl/lib/jxl/icc_codec_common.h +++ b/third_party/jpeg-xl/lib/jxl/icc_codec_common.h @@ -95,7 +95,7 @@ void AppendKeyword(const Tag& keyword, PaddedBytes* data); Status CheckOutOfBounds(uint64_t a, uint64_t b, uint64_t size); Status CheckIs32Bit(uint64_t v); -const Span ICCInitialHeaderPrediction(); +Span ICCInitialHeaderPrediction(); void ICCPredictHeader(const uint8_t* icc, size_t size, uint8_t* header, size_t pos); uint8_t LinearPredictICCValue(const uint8_t* data, size_t start, size_t i, diff --git a/third_party/jpeg-xl/lib/jxl/icc_codec_test.cc b/third_party/jpeg-xl/lib/jxl/icc_codec_test.cc index 743aa9a30e..175b4768a0 100644 --- a/third_party/jpeg-xl/lib/jxl/icc_codec_test.cc +++ b/third_party/jpeg-xl/lib/jxl/icc_codec_test.cc @@ -37,12 +37,12 @@ void TestProfile(const IccBytes& icc) { void TestProfile(const std::string& icc) { IccBytes data; - Bytes(icc).AppendTo(&data); + Bytes(icc).AppendTo(data); TestProfile(data); } // Valid profile from one of the images output by the decoder. -static const unsigned char kTestProfile[] = { +const unsigned char kTestProfile[] = { 0x00, 0x00, 0x03, 0x80, 0x6c, 0x63, 0x6d, 0x73, 0x04, 0x30, 0x00, 0x00, 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, 0x07, 0xe3, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x0f, 0x00, 0x32, 0x00, 0x2e, @@ -139,7 +139,7 @@ TEST(IccCodecTest, Icc) { { IccBytes profile; - Bytes(kTestProfile, sizeof(kTestProfile)).AppendTo(&profile); + Bytes(kTestProfile, sizeof(kTestProfile)).AppendTo(profile); TestProfile(profile); } diff --git a/third_party/jpeg-xl/lib/jxl/image.cc b/third_party/jpeg-xl/lib/jxl/image.cc index 382c957799..7468dad130 100644 --- a/third_party/jpeg-xl/lib/jxl/image.cc +++ b/third_party/jpeg-xl/lib/jxl/image.cc @@ -5,123 +5,93 @@ #include "lib/jxl/image.h" -#include // swap +#include // fill, swap +#include +#include -#undef HWY_TARGET_INCLUDE -#define HWY_TARGET_INCLUDE "lib/jxl/image.cc" -#include -#include +#include "lib/jxl/base/status.h" +#include "lib/jxl/cache_aligned.h" +#include "lib/jxl/simd_util.h" +#if defined(MEMORY_SANITIZER) #include "lib/jxl/base/common.h" -#include "lib/jxl/frame_dimensions.h" -#include "lib/jxl/image_ops.h" #include "lib/jxl/sanitizers.h" +#endif -HWY_BEFORE_NAMESPACE(); namespace jxl { +namespace detail { -namespace HWY_NAMESPACE { -size_t GetVectorSize() { return HWY_LANES(uint8_t); } -// NOLINTNEXTLINE(google-readability-namespace-comments) -} // namespace HWY_NAMESPACE - -} // namespace jxl -HWY_AFTER_NAMESPACE(); - -#if HWY_ONCE -namespace jxl { namespace { -HWY_EXPORT(GetVectorSize); // Local function. +// Initializes the minimum bytes required to suppress MSAN warnings from +// legitimate vector loads/stores on the right border, where some lanes are +// uninitialized and assumed to be unused. +void InitializePadding(PlaneBase& plane, const size_t sizeof_t) { +#if defined(MEMORY_SANITIZER) + size_t xsize = plane.xsize(); + size_t ysize = plane.ysize(); + if (xsize == 0 || ysize == 0) return; -// Returns distance [bytes] between the start of two consecutive rows, a -// multiple of vector/cache line size but NOT CacheAligned::kAlias - see below. -size_t BytesPerRow(const size_t xsize, const size_t sizeof_t) { - const size_t vec_size = VectorSize(); - size_t valid_bytes = xsize * sizeof_t; + const size_t vec_size = MaxVectorSize(); + if (vec_size == 0) return; // Scalar mode: no padding needed - // Allow unaligned accesses starting at the last valid value - this may raise - // msan errors unless the user calls InitializePaddingForUnalignedAccesses. - // Skip for the scalar case because no extra lanes will be loaded. - if (vec_size != 0) { - valid_bytes += vec_size - sizeof_t; - } + const size_t valid_size = xsize * sizeof_t; + const size_t initialize_size = RoundUpTo(valid_size, vec_size); + if (valid_size == initialize_size) return; - // Round up to vector and cache line size. - const size_t align = std::max(vec_size, CacheAligned::kAlignment); - size_t bytes_per_row = RoundUpTo(valid_bytes, align); - - // During the lengthy window before writes are committed to memory, CPUs - // guard against read after write hazards by checking the address, but - // only the lower 11 bits. We avoid a false dependency between writes to - // consecutive rows by ensuring their sizes are not multiples of 2 KiB. - // Avoid2K prevents the same problem for the planes of an Image3. - if (bytes_per_row % CacheAligned::kAlias == 0) { - bytes_per_row += align; + for (size_t y = 0; y < ysize; ++y) { + uint8_t* JXL_RESTRICT row = plane.bytes() + y * plane.bytes_per_row(); +#if defined(__clang__) && \ + ((!defined(__apple_build_version__) && __clang_major__ <= 6) || \ + (defined(__apple_build_version__) && \ + __apple_build_version__ <= 10001145)) + // There's a bug in MSAN in clang-6 when handling AVX2 operations. This + // workaround allows tests to pass on MSAN, although it is slower and + // prevents MSAN warnings from uninitialized images. + std::fill(row, msan::kSanitizerSentinelByte, initialize_size); +#else + memset(row + valid_size, msan::kSanitizerSentinelByte, + initialize_size - valid_size); +#endif // clang6 } - - JXL_ASSERT(bytes_per_row % align == 0); - return bytes_per_row; +#endif // MEMORY_SANITIZER } } // namespace -size_t VectorSize() { - static size_t bytes = HWY_DYNAMIC_DISPATCH(GetVectorSize)(); - return bytes; -} - PlaneBase::PlaneBase(const size_t xsize, const size_t ysize, const size_t sizeof_t) : xsize_(static_cast(xsize)), ysize_(static_cast(ysize)), orig_xsize_(static_cast(xsize)), - orig_ysize_(static_cast(ysize)) { + orig_ysize_(static_cast(ysize)), + bytes_per_row_(BytesPerRow(xsize_, sizeof_t)), + bytes_(nullptr), + sizeof_t_(sizeof_t) { + // TODO(eustas): turn to error instead of abort. JXL_CHECK(xsize == xsize_); JXL_CHECK(ysize == ysize_); JXL_ASSERT(sizeof_t == 1 || sizeof_t == 2 || sizeof_t == 4 || sizeof_t == 8); +} + +Status PlaneBase::Allocate() { + JXL_CHECK(!bytes_.get()); - bytes_per_row_ = 0; // Dimensions can be zero, e.g. for lazily-allocated images. Only allocate // if nonzero, because "zero" bytes still have padding/bookkeeping overhead. - if (xsize != 0 && ysize != 0) { - bytes_per_row_ = BytesPerRow(xsize, sizeof_t); - bytes_ = AllocateArray(bytes_per_row_ * ysize); - JXL_CHECK(bytes_.get()); - InitializePadding(sizeof_t, Padding::kRoundUp); + if (xsize_ == 0 || ysize_ == 0) { + return true; } -} - -void PlaneBase::InitializePadding(const size_t sizeof_t, Padding padding) { -#if defined(MEMORY_SANITIZER) || HWY_IDE - if (xsize_ == 0 || ysize_ == 0) return; - - const size_t vec_size = VectorSize(); - if (vec_size == 0) return; // Scalar mode: no padding needed - - const size_t valid_size = xsize_ * sizeof_t; - const size_t initialize_size = padding == Padding::kRoundUp - ? RoundUpTo(valid_size, vec_size) - : valid_size + vec_size - sizeof_t; - if (valid_size == initialize_size) return; - for (size_t y = 0; y < ysize_; ++y) { - uint8_t* JXL_RESTRICT row = static_cast(VoidRow(y)); -#if defined(__clang__) && \ - ((!defined(__apple_build_version__) && __clang_major__ <= 6) || \ - (defined(__apple_build_version__) && \ - __apple_build_version__ <= 10001145)) - // There's a bug in msan in clang-6 when handling AVX2 operations. This - // workaround allows tests to pass on msan, although it is slower and - // prevents msan warnings from uninitialized images. - std::fill(row, msan::kSanitizerSentinelByte, initialize_size); -#else - memset(row + valid_size, msan::kSanitizerSentinelByte, - initialize_size - valid_size); -#endif // clang6 + bytes_ = AllocateArray(bytes_per_row_ * ysize_); + if (!bytes_.get()) { + // TODO(eustas): use specialized OOM error code + return JXL_FAILURE("Failed to allocate memory for image surface"); } -#endif // MEMORY_SANITIZER + InitializePadding(*this, sizeof_t_); + + return true; } void PlaneBase::Swap(PlaneBase& other) { @@ -133,73 +103,5 @@ void PlaneBase::Swap(PlaneBase& other) { std::swap(bytes_, other.bytes_); } -void PadImageToBlockMultipleInPlace(Image3F* JXL_RESTRICT in, - size_t block_dim) { - const size_t xsize_orig = in->xsize(); - const size_t ysize_orig = in->ysize(); - const size_t xsize = RoundUpTo(xsize_orig, block_dim); - const size_t ysize = RoundUpTo(ysize_orig, block_dim); - // Expands image size to the originally-allocated size. - in->ShrinkTo(xsize, ysize); - for (size_t c = 0; c < 3; c++) { - for (size_t y = 0; y < ysize_orig; y++) { - float* JXL_RESTRICT row = in->PlaneRow(c, y); - for (size_t x = xsize_orig; x < xsize; x++) { - row[x] = row[xsize_orig - 1]; - } - } - const float* JXL_RESTRICT row_src = in->ConstPlaneRow(c, ysize_orig - 1); - for (size_t y = ysize_orig; y < ysize; y++) { - memcpy(in->PlaneRow(c, y), row_src, xsize * sizeof(float)); - } - } -} - -static void DownsampleImage(const ImageF& input, size_t factor, - ImageF* output) { - JXL_ASSERT(factor != 1); - output->ShrinkTo(DivCeil(input.xsize(), factor), - DivCeil(input.ysize(), factor)); - size_t in_stride = input.PixelsPerRow(); - for (size_t y = 0; y < output->ysize(); y++) { - float* row_out = output->Row(y); - const float* row_in = input.Row(factor * y); - for (size_t x = 0; x < output->xsize(); x++) { - size_t cnt = 0; - float sum = 0; - for (size_t iy = 0; iy < factor && iy + factor * y < input.ysize(); - iy++) { - for (size_t ix = 0; ix < factor && ix + factor * x < input.xsize(); - ix++) { - sum += row_in[iy * in_stride + x * factor + ix]; - cnt++; - } - } - row_out[x] = sum / cnt; - } - } -} - -void DownsampleImage(ImageF* image, size_t factor) { - // Allocate extra space to avoid a reallocation when padding. - ImageF downsampled(DivCeil(image->xsize(), factor) + kBlockDim, - DivCeil(image->ysize(), factor) + kBlockDim); - DownsampleImage(*image, factor, &downsampled); - *image = std::move(downsampled); -} - -void DownsampleImage(Image3F* opsin, size_t factor) { - JXL_ASSERT(factor != 1); - // Allocate extra space to avoid a reallocation when padding. - Image3F downsampled(DivCeil(opsin->xsize(), factor) + kBlockDim, - DivCeil(opsin->ysize(), factor) + kBlockDim); - downsampled.ShrinkTo(downsampled.xsize() - kBlockDim, - downsampled.ysize() - kBlockDim); - for (size_t c = 0; c < 3; c++) { - DownsampleImage(opsin->Plane(c), factor, &downsampled.Plane(c)); - } - *opsin = std::move(downsampled); -} - +} // namespace detail } // namespace jxl -#endif // HWY_ONCE diff --git a/third_party/jpeg-xl/lib/jxl/image.h b/third_party/jpeg-xl/lib/jxl/image.h index 98c387bb77..be97b929e3 100644 --- a/third_party/jpeg-xl/lib/jxl/image.h +++ b/third_party/jpeg-xl/lib/jxl/image.h @@ -28,8 +28,8 @@ namespace jxl { -// Helper function to create rows that are multiples of SIMD vector size. -size_t VectorSize(); +// DO NOT use PlaneBase outside of image.{h|cc} +namespace detail { // Type-independent parts of Plane<> - reduces code duplication and facilitates // moving member function implementations to cc file. @@ -40,8 +40,8 @@ struct PlaneBase { orig_xsize_(0), orig_ysize_(0), bytes_per_row_(0), - bytes_(nullptr) {} - PlaneBase(size_t xsize, size_t ysize, size_t sizeof_t); + bytes_(nullptr), + sizeof_t_(0) {} // Copy construction/assignment is forbidden to avoid inadvertent copies, // which can be very expensive. Use CopyImageTo() instead. @@ -88,13 +88,16 @@ struct PlaneBase { } protected: + PlaneBase(size_t xsize, size_t ysize, size_t sizeof_t); + Status Allocate(); + // Returns pointer to the start of a row. JXL_INLINE void* VoidRow(const size_t y) const { #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ defined(THREAD_SANITIZER) if (y >= ysize_) { - JXL_ABORT("Row(%" PRIu64 ") in (%u x %u) image\n", (uint64_t)y, xsize_, - ysize_); + JXL_ABORT("Row(%" PRIu64 ") in (%u x %u) image\n", + static_cast(y), xsize_, ysize_); } #endif @@ -102,21 +105,6 @@ struct PlaneBase { return JXL_ASSUME_ALIGNED(row, 64); } - enum class Padding { - // Allow Load(d, row + x) for x = 0; x < xsize(); x += Lanes(d). Default. - kRoundUp, - // Allow LoadU(d, row + x) for x = xsize() - 1. This requires an extra - // vector to be initialized. If done by default, this would suppress - // legitimate msan warnings. We therefore require users to explicitly call - // InitializePadding before using unaligned loads (e.g. convolution). - kUnaligned - }; - - // Initializes the minimum bytes required to suppress msan warnings from - // legitimate (according to Padding mode) vector loads/stores on the right - // border, where some lanes are uninitialized and assumed to be unused. - void InitializePadding(size_t sizeof_t, Padding padding); - // (Members are non-const to enable assignment during move-assignment.) uint32_t xsize_; // In valid pixels, not including any padding. uint32_t ysize_; @@ -124,8 +112,11 @@ struct PlaneBase { uint32_t orig_ysize_; size_t bytes_per_row_; // Includes padding. CacheAlignedUniquePtr bytes_; + size_t sizeof_t_; }; +} // namespace detail + // Single channel, aligned rows separated by padding. T must be POD. // // 'Single channel' (one 2D array per channel) simplifies vectorization @@ -148,17 +139,17 @@ struct PlaneBase { // provides convenient accessors for xsize/ysize, which shortens function // argument lists. Supports move-construction so it can be stored in containers. template -class Plane : public PlaneBase { +class Plane : public detail::PlaneBase { public: using T = ComponentType; static constexpr size_t kNumPlanes = 1; Plane() = default; - Plane(const size_t xsize, const size_t ysize) - : PlaneBase(xsize, ysize, sizeof(T)) {} - void InitializePaddingForUnalignedAccesses() { - InitializePadding(sizeof(T), Padding::kUnaligned); + static StatusOr Create(const size_t xsize, const size_t ysize) { + Plane plane(xsize, ysize, sizeof(T)); + JXL_RETURN_IF_ERROR(plane.Allocate()); + return plane; } JXL_INLINE T* Row(const size_t y) { return static_cast(VoidRow(y)); } @@ -179,6 +170,10 @@ class Plane : public PlaneBase { JXL_INLINE intptr_t PixelsPerRow() const { return static_cast(bytes_per_row_ / sizeof(T)); } + + private: + Plane(size_t xsize, size_t ysize, size_t sizeof_t) + : detail::PlaneBase(xsize, ysize, sizeof_t) {} }; using ImageSB = Plane; @@ -189,12 +184,6 @@ using ImageI = Plane; using ImageF = Plane; using ImageD = Plane; -// Also works for Image3 and mixed argument types. -template -bool SameSize(const Image1& image1, const Image2& image2) { - return image1.xsize() == image2.xsize() && image1.ysize() == image2.ysize(); -} - template class Image3; @@ -339,7 +328,8 @@ class RectT { template RectT As() const { - return RectT(U(x0_), U(y0_), U(xsize_), U(ysize_)); + return RectT(static_cast(x0_), static_cast(y0_), + static_cast(xsize_), static_cast(ysize_)); } private: @@ -394,24 +384,12 @@ class Image3 { Image3() : planes_{PlaneT(), PlaneT(), PlaneT()} {} - Image3(const size_t xsize, const size_t ysize) - : planes_{PlaneT(xsize, ysize), PlaneT(xsize, ysize), - PlaneT(xsize, ysize)} {} - Image3(Image3&& other) noexcept { for (size_t i = 0; i < kNumPlanes; i++) { planes_[i] = std::move(other.planes_[i]); } } - Image3(PlaneT&& plane0, PlaneT&& plane1, PlaneT&& plane2) { - JXL_CHECK(SameSize(plane0, plane1)); - JXL_CHECK(SameSize(plane0, plane2)); - planes_[0] = std::move(plane0); - planes_[1] = std::move(plane1); - planes_[2] = std::move(plane2); - } - // Copy construction/assignment is forbidden to avoid inadvertent copies, // which can be very expensive. Use CopyImageTo instead. Image3(const Image3& other) = delete; @@ -424,6 +402,17 @@ class Image3 { return *this; } + static StatusOr Create(const size_t xsize, const size_t ysize) { + StatusOr plane0 = PlaneT::Create(xsize, ysize); + JXL_RETURN_IF_ERROR(plane0.status()); + StatusOr plane1 = PlaneT::Create(xsize, ysize); + JXL_RETURN_IF_ERROR(plane1.status()); + StatusOr plane2 = PlaneT::Create(xsize, ysize); + JXL_RETURN_IF_ERROR(plane2.status()); + return Image3(std::move(plane0).value(), std::move(plane1).value(), + std::move(plane2).value()); + } + // Returns row pointer; usage: PlaneRow(idx_plane, y)[x] = val. JXL_INLINE T* PlaneRow(const size_t c, const size_t y) { // Custom implementation instead of calling planes_[c].Row ensures only a @@ -481,6 +470,12 @@ class Image3 { JXL_INLINE intptr_t PixelsPerRow() const { return planes_[0].PixelsPerRow(); } private: + Image3(PlaneT&& plane0, PlaneT&& plane1, PlaneT&& plane2) { + planes_[0] = std::move(plane0); + planes_[1] = std::move(plane1); + planes_[2] = std::move(plane2); + } + void PlaneRowBoundsCheck(const size_t c, const size_t y) const { #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ defined(THREAD_SANITIZER) @@ -493,7 +488,6 @@ class Image3 { #endif } - private: PlaneT planes_[kNumPlanes]; }; diff --git a/third_party/jpeg-xl/lib/jxl/image_bundle.h b/third_party/jpeg-xl/lib/jxl/image_bundle.h index 2eea496d5e..c8a76a9f59 100644 --- a/third_party/jpeg-xl/lib/jxl/image_bundle.h +++ b/third_party/jpeg-xl/lib/jxl/image_bundle.h @@ -42,14 +42,16 @@ class ImageBundle { ImageBundle(ImageBundle&&) = default; ImageBundle& operator=(ImageBundle&&) = default; - ImageBundle Copy() const { + StatusOr Copy() const { ImageBundle copy(metadata_); - copy.color_ = Image3F(color_.xsize(), color_.ysize()); + JXL_ASSIGN_OR_RETURN(copy.color_, + Image3F::Create(color_.xsize(), color_.ysize())); CopyImageTo(color_, ©.color_); copy.c_current_ = c_current_; copy.extra_channels_.reserve(extra_channels_.size()); for (const ImageF& plane : extra_channels_) { - ImageF ec(plane.xsize(), plane.ysize()); + JXL_ASSIGN_OR_RETURN(ImageF ec, + ImageF::Create(plane.xsize(), plane.ysize())); CopyImageTo(plane, &ec); copy.extra_channels_.emplace_back(std::move(ec)); } diff --git a/third_party/jpeg-xl/lib/jxl/image_metadata.cc b/third_party/jpeg-xl/lib/jxl/image_metadata.cc index 4cca910753..91d27ff44e 100644 --- a/third_party/jpeg-xl/lib/jxl/image_metadata.cc +++ b/third_party/jpeg-xl/lib/jxl/image_metadata.cc @@ -10,6 +10,7 @@ #include "lib/jxl/alpha.h" #include "lib/jxl/base/byte_order.h" +#include "lib/jxl/base/matrix_ops.h" #include "lib/jxl/cms/opsin_params.h" #include "lib/jxl/fields.h" #include "lib/jxl/frame_header.h" @@ -245,8 +246,8 @@ Status ExtraChannelInfo::VisitFields(Visitor* JXL_RESTRICT visitor) { } if (type == ExtraChannel::kUnknown || - (int(ExtraChannel::kReserved0) <= int(type) && - int(type) <= int(ExtraChannel::kReserved7))) { + (static_cast(ExtraChannel::kReserved0) <= static_cast(type) && + static_cast(type) <= static_cast(ExtraChannel::kReserved7))) { return JXL_FAILURE("Unknown extra channel (bits %u, shift %u, name '%s')\n", bit_depth.bits_per_sample, dim_shift, name.c_str()); } @@ -354,10 +355,13 @@ Status OpsinInverseMatrix::VisitFields(Visitor* JXL_RESTRICT visitor) { visitor->SetDefault(this); return true; } - for (int i = 0; i < 9; ++i) { - JXL_QUIET_RETURN_IF_ERROR( - visitor->F16(jxl::cms::DefaultInverseOpsinAbsorbanceMatrix()[i], - &inverse_matrix[i])); + const Matrix3x3& default_inverse = + jxl::cms::DefaultInverseOpsinAbsorbanceMatrix(); + for (int j = 0; j < 3; ++j) { + for (int i = 0; i < 3; ++i) { + JXL_QUIET_RETURN_IF_ERROR( + visitor->F16(default_inverse[j][i], &inverse_matrix[j][i])); + } } for (int i = 0; i < 3; ++i) { JXL_QUIET_RETURN_IF_ERROR(visitor->F16( diff --git a/third_party/jpeg-xl/lib/jxl/image_metadata.h b/third_party/jpeg-xl/lib/jxl/image_metadata.h index be603a49f3..2b647cfa30 100644 --- a/third_party/jpeg-xl/lib/jxl/image_metadata.h +++ b/third_party/jpeg-xl/lib/jxl/image_metadata.h @@ -138,7 +138,7 @@ struct OpsinInverseMatrix : public Fields { mutable bool all_default; - float inverse_matrix[9]; + Matrix3x3 inverse_matrix; float opsin_biases[3]; float quant_biases[4]; }; diff --git a/third_party/jpeg-xl/lib/jxl/image_ops.cc b/third_party/jpeg-xl/lib/jxl/image_ops.cc new file mode 100644 index 0000000000..36d19df938 --- /dev/null +++ b/third_party/jpeg-xl/lib/jxl/image_ops.cc @@ -0,0 +1,91 @@ +// Copyright (c) the JPEG XL Project Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "lib/jxl/image_ops.h" + +#include +#include + +#include "lib/jxl/base/common.h" +#include "lib/jxl/base/compiler_specific.h" +#include "lib/jxl/base/status.h" +#include "lib/jxl/frame_dimensions.h" +#include "lib/jxl/image.h" + +namespace jxl { + +void PadImageToBlockMultipleInPlace(Image3F* JXL_RESTRICT in, + size_t block_dim) { + const size_t xsize_orig = in->xsize(); + const size_t ysize_orig = in->ysize(); + const size_t xsize = RoundUpTo(xsize_orig, block_dim); + const size_t ysize = RoundUpTo(ysize_orig, block_dim); + // Expands image size to the originally-allocated size. + in->ShrinkTo(xsize, ysize); + for (size_t c = 0; c < 3; c++) { + for (size_t y = 0; y < ysize_orig; y++) { + float* JXL_RESTRICT row = in->PlaneRow(c, y); + for (size_t x = xsize_orig; x < xsize; x++) { + row[x] = row[xsize_orig - 1]; + } + } + const float* JXL_RESTRICT row_src = in->ConstPlaneRow(c, ysize_orig - 1); + for (size_t y = ysize_orig; y < ysize; y++) { + memcpy(in->PlaneRow(c, y), row_src, xsize * sizeof(float)); + } + } +} + +static void DoDownsampleImage(const ImageF& input, size_t factor, + ImageF* output) { + JXL_ASSERT(factor != 1); + output->ShrinkTo(DivCeil(input.xsize(), factor), + DivCeil(input.ysize(), factor)); + size_t in_stride = input.PixelsPerRow(); + for (size_t y = 0; y < output->ysize(); y++) { + float* row_out = output->Row(y); + const float* row_in = input.Row(factor * y); + for (size_t x = 0; x < output->xsize(); x++) { + size_t cnt = 0; + float sum = 0; + for (size_t iy = 0; iy < factor && iy + factor * y < input.ysize(); + iy++) { + for (size_t ix = 0; ix < factor && ix + factor * x < input.xsize(); + ix++) { + sum += row_in[iy * in_stride + x * factor + ix]; + cnt++; + } + } + row_out[x] = sum / cnt; + } + } +} + +StatusOr DownsampleImage(const ImageF& image, size_t factor) { + ImageF downsampled; + // Allocate extra space to avoid a reallocation when padding. + JXL_ASSIGN_OR_RETURN( + downsampled, ImageF::Create(DivCeil(image.xsize(), factor) + kBlockDim, + DivCeil(image.ysize(), factor) + kBlockDim)); + DoDownsampleImage(image, factor, &downsampled); + return downsampled; +} + +StatusOr DownsampleImage(const Image3F& opsin, size_t factor) { + JXL_ASSERT(factor != 1); + // Allocate extra space to avoid a reallocation when padding. + Image3F downsampled; + JXL_ASSIGN_OR_RETURN( + downsampled, Image3F::Create(DivCeil(opsin.xsize(), factor) + kBlockDim, + DivCeil(opsin.ysize(), factor) + kBlockDim)); + downsampled.ShrinkTo(downsampled.xsize() - kBlockDim, + downsampled.ysize() - kBlockDim); + for (size_t c = 0; c < 3; c++) { + DoDownsampleImage(opsin.Plane(c), factor, &downsampled.Plane(c)); + } + return downsampled; +} + +} // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/image_ops.h b/third_party/jpeg-xl/lib/jxl/image_ops.h index b2ce23f13d..84cf7dad76 100644 --- a/third_party/jpeg-xl/lib/jxl/image_ops.h +++ b/third_party/jpeg-xl/lib/jxl/image_ops.h @@ -9,16 +9,23 @@ // Operations on images. #include -#include +#include +#include #include -#include +#include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/status.h" #include "lib/jxl/frame_dimensions.h" #include "lib/jxl/image.h" namespace jxl { +// Works for mixed image-like argument types. +template +bool SameSize(const Image1& image1, const Image2& image2) { + return image1.xsize() == image2.xsize() && image1.ysize() == image2.ysize(); +} + template void CopyImageTo(const Plane& from, Plane* JXL_RESTRICT to) { JXL_ASSERT(SameSize(from, *to)); @@ -102,76 +109,15 @@ void CopyImageToWithPadding(const Rect& from_rect, const T& from, to); } -template -void Subtract(const ImageIn& image1, const ImageIn& image2, ImageOut* out) { - using T = typename ImageIn::T; - const size_t xsize = image1.xsize(); - const size_t ysize = image1.ysize(); - JXL_CHECK(xsize == image2.xsize()); - JXL_CHECK(ysize == image2.ysize()); - - for (size_t y = 0; y < ysize; ++y) { - const T* const JXL_RESTRICT row1 = image1.Row(y); - const T* const JXL_RESTRICT row2 = image2.Row(y); - T* const JXL_RESTRICT row_out = out->Row(y); - for (size_t x = 0; x < xsize; ++x) { - row_out[x] = row1[x] - row2[x]; - } - } -} - -// In-place. -template -void SubtractFrom(const Plane& what, Plane* to) { - const size_t xsize = what.xsize(); - const size_t ysize = what.ysize(); - for (size_t y = 0; y < ysize; ++y) { - const Tin* JXL_RESTRICT row_what = what.ConstRow(y); - Tout* JXL_RESTRICT row_to = to->Row(y); - for (size_t x = 0; x < xsize; ++x) { - row_to[x] -= row_what[x]; - } - } -} - -// In-place. -template -void AddTo(const Plane& what, Plane* to) { - const size_t xsize = what.xsize(); - const size_t ysize = what.ysize(); - for (size_t y = 0; y < ysize; ++y) { - const Tin* JXL_RESTRICT row_what = what.ConstRow(y); - Tout* JXL_RESTRICT row_to = to->Row(y); - for (size_t x = 0; x < xsize; ++x) { - row_to[x] += row_what[x]; - } - } -} - -template -void AddTo(Rect rectFrom, const Plane& what, Rect rectTo, - Plane* to) { - JXL_ASSERT(SameSize(rectFrom, rectTo)); - const size_t xsize = rectTo.xsize(); - const size_t ysize = rectTo.ysize(); - for (size_t y = 0; y < ysize; ++y) { - const Tin* JXL_RESTRICT row_what = rectFrom.ConstRow(what, y); - Tout* JXL_RESTRICT row_to = rectTo.Row(to, y); - for (size_t x = 0; x < xsize; ++x) { - row_to[x] += row_what[x]; - } - } -} - // Returns linear combination of two grayscale images. template -Plane LinComb(const T lambda1, const Plane& image1, const T lambda2, - const Plane& image2) { +StatusOr> LinComb(const T lambda1, const Plane& image1, + const T lambda2, const Plane& image2) { const size_t xsize = image1.xsize(); const size_t ysize = image1.ysize(); JXL_CHECK(xsize == image2.xsize()); JXL_CHECK(ysize == image2.ysize()); - Plane out(xsize, ysize); + JXL_ASSIGN_OR_RETURN(Plane out, Plane::Create(xsize, ysize)); for (size_t y = 0; y < ysize; ++y) { const T* const JXL_RESTRICT row1 = image1.Row(y); const T* const JXL_RESTRICT row2 = image2.Row(y); @@ -291,35 +237,6 @@ struct WrapRowUnchanged { } }; -// Sets "thickness" pixels on each border to "value". This is faster than -// initializing the entire image and overwriting valid/interior pixels. -template -void SetBorder(const size_t thickness, const T value, Plane* image) { - const size_t xsize = image->xsize(); - const size_t ysize = image->ysize(); - // Top: fill entire row - for (size_t y = 0; y < std::min(thickness, ysize); ++y) { - T* const JXL_RESTRICT row = image->Row(y); - std::fill(row, row + xsize, value); - } - - // Bottom: fill entire row - for (size_t y = ysize - thickness; y < ysize; ++y) { - T* const JXL_RESTRICT row = image->Row(y); - std::fill(row, row + xsize, value); - } - - // Left/right: fill the 'columns' on either side, but only if the image is - // big enough that they don't already belong to the top/bottom rows. - if (ysize >= 2 * thickness) { - for (size_t y = thickness; y < ysize - thickness; ++y) { - T* const JXL_RESTRICT row = image->Row(y); - std::fill(row, row + thickness, value); - std::fill(row + xsize - thickness, row + xsize, value); - } - } -} - // Computes the minimum and maximum pixel value. template void ImageMinMax(const Plane& image, T* const JXL_RESTRICT min, @@ -335,48 +252,6 @@ void ImageMinMax(const Plane& image, T* const JXL_RESTRICT min, } } -template -Plane ImageFromPacked(const std::vector& packed, const size_t xsize, - const size_t ysize) { - Plane out(xsize, ysize); - for (size_t y = 0; y < ysize; ++y) { - T* const JXL_RESTRICT row = out.Row(y); - const T* const JXL_RESTRICT packed_row = &packed[y * xsize]; - memcpy(row, packed_row, xsize * sizeof(T)); - } - return out; -} - -template -void Image3Max(const Image3& image, std::array* out_max) { - for (size_t c = 0; c < 3; ++c) { - T max = std::numeric_limits::min(); - for (size_t y = 0; y < image.ysize(); ++y) { - const T* JXL_RESTRICT row = image.ConstPlaneRow(c, y); - for (size_t x = 0; x < image.xsize(); ++x) { - max = std::max(max, row[x]); - } - } - (*out_max)[c] = max; - } -} - -template -std::vector PackedFromImage(const Plane& image, const Rect& rect) { - const size_t xsize = rect.xsize(); - const size_t ysize = rect.ysize(); - std::vector packed(xsize * ysize); - for (size_t y = 0; y < rect.ysize(); ++y) { - memcpy(&packed[y * xsize], rect.ConstRow(image, y), xsize * sizeof(T)); - } - return packed; -} - -template -std::vector PackedFromImage(const Plane& image) { - return PackedFromImage(image, Rect(image)); -} - // Initializes all planes to the same "value". template void FillImage(const T value, Image3* image) { @@ -390,28 +265,6 @@ void FillImage(const T value, Image3* image) { } } -template -void FillPlane(const T value, Plane* image) { - for (size_t y = 0; y < image->ysize(); ++y) { - T* JXL_RESTRICT row = image->Row(y); - for (size_t x = 0; x < image->xsize(); ++x) { - row[x] = value; - } - } -} - -template -void FillImage(const T value, Image3* image, Rect rect) { - for (size_t c = 0; c < 3; ++c) { - for (size_t y = 0; y < rect.ysize(); ++y) { - T* JXL_RESTRICT row = rect.PlaneRow(image, c, y); - for (size_t x = 0; x < rect.xsize(); ++x) { - row[x] = value; - } - } - } -} - template void FillPlane(const T value, Plane* image, Rect rect) { for (size_t y = 0; y < rect.ysize(); ++y) { @@ -432,22 +285,14 @@ void ZeroFillImage(Image3* image) { } } -template -void ZeroFillPlane(Plane* image, Rect rect) { - for (size_t y = 0; y < rect.ysize(); ++y) { - T* JXL_RESTRICT row = rect.Row(image, y); - memset(row, 0, rect.xsize() * sizeof(T)); - } -} - // Same as above, but operates in-place. Assumes that the `in` image was // allocated large enough. void PadImageToBlockMultipleInPlace(Image3F* JXL_RESTRICT in, size_t block_dim = kBlockDim); // Downsamples an image by a given factor. -void DownsampleImage(Image3F* opsin, size_t factor); -void DownsampleImage(ImageF* image, size_t factor); +StatusOr DownsampleImage(const Image3F& opsin, size_t factor); +StatusOr DownsampleImage(const ImageF& image, size_t factor); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/image_ops_test.cc b/third_party/jpeg-xl/lib/jxl/image_ops_test.cc index dfcb2292c5..6b308baab4 100644 --- a/third_party/jpeg-xl/lib/jxl/image_ops_test.cc +++ b/third_party/jpeg-xl/lib/jxl/image_ops_test.cc @@ -8,43 +8,19 @@ #include #include -#include +#include +#include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/printf_macros.h" +#include "lib/jxl/base/random.h" +#include "lib/jxl/base/status.h" +#include "lib/jxl/cache_aligned.h" #include "lib/jxl/image.h" -#include "lib/jxl/image_test_utils.h" #include "lib/jxl/testing.h" namespace jxl { namespace { -template -void TestPacked(const size_t xsize, const size_t ysize) { - Plane image1(xsize, ysize); - RandomFillImage(&image1); - const std::vector& packed = PackedFromImage(image1); - const Plane& image2 = ImageFromPacked(packed, xsize, ysize); - JXL_EXPECT_OK(SamePixels(image1, image2, _)); -} - -TEST(ImageTest, TestPacked) { - TestPacked(1, 1); - TestPacked(7, 1); - TestPacked(1, 7); - - TestPacked(1, 1); - TestPacked(7, 1); - TestPacked(1, 7); - - TestPacked(1, 1); - TestPacked(7, 1); - TestPacked(1, 7); - - TestPacked(1, 1); - TestPacked(7, 1); - TestPacked(1, 7); -} - // Ensure entire payload is readable/writable for various size/offset combos. TEST(ImageTest, TestAllocator) { Rng rng(0); @@ -70,18 +46,18 @@ TEST(ImageTest, TestAllocator) { template void TestFillImpl(Image3* img, const char* layout) { - FillImage(T(1), img); + FillImage(static_cast(1), img); for (size_t y = 0; y < img->ysize(); ++y) { for (size_t c = 0; c < 3; ++c) { T* JXL_RESTRICT row = img->PlaneRow(c, y); for (size_t x = 0; x < img->xsize(); ++x) { - if (row[x] != T(1)) { + if (row[x] != static_cast(1)) { printf("Not 1 at c=%" PRIuS " %" PRIuS ", %" PRIuS " (%" PRIuS " x %" PRIuS ") (%s)\n", c, x, y, img->xsize(), img->ysize(), layout); abort(); } - row[x] = T(2); + row[x] = static_cast(2); } } } @@ -92,13 +68,13 @@ void TestFillImpl(Image3* img, const char* layout) { for (size_t y = 0; y < img->ysize(); ++y) { T* JXL_RESTRICT row = img->PlaneRow(c, y); for (size_t x = 0; x < img->xsize(); ++x) { - if (row[x] != T(0)) { + if (row[x] != static_cast(0)) { printf("Not 0 at c=%" PRIuS " %" PRIuS ", %" PRIuS " (%" PRIuS " x %" PRIuS ") (%s)\n", c, x, y, img->xsize(), img->ysize(), layout); abort(); } - row[x] = T(3); + row[x] = static_cast(3); } } } @@ -108,12 +84,8 @@ template void TestFillT() { for (uint32_t xsize : {0, 1, 15, 16, 31, 32}) { for (uint32_t ysize : {0, 1, 15, 16, 31, 32}) { - Image3 image(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3 image, Image3::Create(xsize, ysize)); TestFillImpl(&image, "size ctor"); - - Image3 planar(Plane(xsize, ysize), Plane(xsize, ysize), - Plane(xsize, ysize)); - TestFillImpl(&planar, "planar"); } } } @@ -127,7 +99,7 @@ TEST(ImageTest, TestFill) { } TEST(ImageTest, CopyImageToWithPaddingTest) { - Plane src(100, 61); + JXL_ASSIGN_OR_DIE(Plane src, Plane::Create(100, 61)); for (size_t y = 0; y < src.ysize(); y++) { for (size_t x = 0; x < src.xsize(); x++) { src.Row(y)[x] = x * 1000 + y; @@ -136,7 +108,7 @@ TEST(ImageTest, CopyImageToWithPaddingTest) { Rect src_rect(10, 20, 30, 40); EXPECT_TRUE(src_rect.IsInside(src)); - Plane dst(60, 50); + JXL_ASSIGN_OR_DIE(Plane dst, Plane::Create(60, 50)); FillImage(0u, &dst); Rect dst_rect(20, 5, 30, 40); EXPECT_TRUE(dst_rect.IsInside(dst)); diff --git a/third_party/jpeg-xl/lib/jxl/image_test_utils.h b/third_party/jpeg-xl/lib/jxl/image_test_utils.h index e7d72285e6..7bb146866e 100644 --- a/third_party/jpeg-xl/lib/jxl/image_test_utils.h +++ b/third_party/jpeg-xl/lib/jxl/image_test_utils.h @@ -6,10 +6,6 @@ #ifndef LIB_JXL_IMAGE_TEST_UTILS_H_ #define LIB_JXL_IMAGE_TEST_UTILS_H_ -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif - #include #include #include @@ -37,7 +33,8 @@ bool SamePixels(const Plane& image1, const Plane& image2, for (size_t x = rect.x0(); x < rect.xsize(); ++x) { if (row1[x] != row2[x]) { failures << "pixel mismatch" << x << ", " << y << ": " - << double(row1[x]) << " != " << double(row2[x]) << "\n"; + << static_cast(row1[x]) + << " != " << static_cast(row2[x]) << "\n"; if (++mismatches > 4) { return false; } @@ -66,7 +63,7 @@ bool VerifyRelativeError(const Plane& expected, const Plane& actual, const double threshold_l1, const double threshold_relative, std::stringstream& failures, const intptr_t border = 0, - const size_t c = 0) { + const int c = 0) { JXL_CHECK(SameSize(expected, actual)); const intptr_t xsize = expected.xsize(); const intptr_t ysize = expected.ysize(); @@ -89,7 +86,8 @@ bool VerifyRelativeError(const Plane& expected, const Plane& actual, max_l1 = std::max(max_l1, l1); } } else { - const double relative = l1 / std::abs(double(row_expected[x])); + const double relative = + l1 / std::abs(static_cast(row_expected[x])); if (l1 > threshold_l1 && relative > threshold_relative) { // Fails both tolerances => will exit below, update max_*. any_bad = true; @@ -104,13 +102,11 @@ bool VerifyRelativeError(const Plane& expected, const Plane& actual, } // Never had a valid relative value, don't print it. if (max_relative < 0) { - fprintf(stderr, "c=%" PRIu64 ": max +/- %E exceeds +/- %.2E\n", - static_cast(c), max_l1, threshold_l1); + fprintf(stderr, "c=%d: max +/- %E exceeds +/- %.2E\n", c, max_l1, + threshold_l1); } else { - fprintf(stderr, - "c=%" PRIu64 ": max +/- %E, x %E exceeds +/- %.2E, x %.2E\n", - static_cast(c), max_l1, max_relative, threshold_l1, - threshold_relative); + fprintf(stderr, "c=%d: max +/- %E, x %E exceeds +/- %.2E, x %.2E\n", c, + max_l1, max_relative, threshold_l1, threshold_relative); } // Dump the expected image and actual image if the region is small enough. const intptr_t kMaxTestDumpSize = 16; @@ -134,7 +130,8 @@ bool VerifyRelativeError(const Plane& expected, const Plane& actual, bool bad = l1 > threshold_l1; if (row_expected[x] > 1E-10) { - const double relative = l1 / std::abs(double(row_expected[x])); + const double relative = + l1 / std::abs(static_cast(row_expected[x])); bad &= relative > threshold_relative; } if (bad) { @@ -157,7 +154,8 @@ bool VerifyRelativeError(const Plane& expected, const Plane& actual, bool bad = l1 > threshold_l1; if (row_expected[x] > 1E-10) { - const double relative = l1 / std::abs(double(row_expected[x])); + const double relative = + l1 / std::abs(static_cast(row_expected[x])); bad &= relative > threshold_relative; } if (bad) { @@ -179,9 +177,9 @@ bool VerifyRelativeError(const Image3& expected, const Image3& actual, std::stringstream& failures, const intptr_t border = 0) { for (size_t c = 0; c < 3; ++c) { - bool ok = - VerifyRelativeError(expected.Plane(c), actual.Plane(c), threshold_l1, - threshold_relative, failures, border, c); + bool ok = VerifyRelativeError(expected.Plane(c), actual.Plane(c), + threshold_l1, threshold_relative, failures, + border, static_cast(c)); if (!ok) { return false; } @@ -216,8 +214,8 @@ template typename std::enable_if::value>::type RandomFillImage( Plane* image) { Rng rng(129); - GenerateImage(rng, image, int64_t(0), - int64_t(std::numeric_limits::max()) + 1); + GenerateImage(rng, image, static_cast(0), + static_cast(std::numeric_limits::max()) + 1); } JXL_INLINE void RandomFillImage(Plane* image) { @@ -236,8 +234,8 @@ template typename std::enable_if::value>::type RandomFillImage( Image3* image) { Rng rng(129); - GenerateImage(rng, image, int64_t(0), - int64_t(std::numeric_limits::max()) + 1); + GenerateImage(rng, image, static_cast(0), + static_cast(std::numeric_limits::max()) + 1); } JXL_INLINE void RandomFillImage(Image3F* image) { diff --git a/third_party/jpeg-xl/lib/jxl/inverse_mtf-inl.h b/third_party/jpeg-xl/lib/jxl/inverse_mtf-inl.h index fcb01d7396..60ea69ddbd 100644 --- a/third_party/jpeg-xl/lib/jxl/inverse_mtf-inl.h +++ b/third_party/jpeg-xl/lib/jxl/inverse_mtf-inl.h @@ -82,7 +82,7 @@ HWY_AFTER_NAMESPACE(); namespace jxl { inline void InverseMoveToFrontTransform(uint8_t* v, int v_len) { - return HWY_STATIC_DISPATCH(InverseMoveToFrontTransform)(v, v_len); + HWY_STATIC_DISPATCH(InverseMoveToFrontTransform)(v, v_len); } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc b/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc index 64560d9ab0..31bb2dda23 100644 --- a/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc +++ b/third_party/jpeg-xl/lib/jxl/jpeg/dec_jpeg_data_writer.cc @@ -18,6 +18,7 @@ #include "lib/jxl/base/bits.h" #include "lib/jxl/base/byte_order.h" #include "lib/jxl/base/common.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/frame_dimensions.h" #include "lib/jxl/image_bundle.h" #include "lib/jxl/jpeg/dec_jpeg_serialization_state.h" @@ -42,7 +43,7 @@ const size_t kJpegBitWriterChunkSize = 16384; // Returns non-zero if and only if x has a zero byte, i.e. one of // x & 0xff, x & 0xff00, ..., x & 0xff00000000000000 is zero. -static JXL_INLINE uint64_t HasZeroByte(uint64_t x) { +JXL_INLINE uint64_t HasZeroByte(uint64_t x) { return (x - 0x0101010101010101ULL) & ~x & 0x8080808080808080ULL; } @@ -57,7 +58,7 @@ void JpegBitWriterInit(JpegBitWriter* bw, bw->data = bw->chunk.buffer->data(); } -static JXL_NOINLINE void SwapBuffer(JpegBitWriter* bw) { +JXL_NOINLINE void SwapBuffer(JpegBitWriter* bw) { bw->chunk.len = bw->pos; bw->output->emplace_back(std::move(bw->chunk)); bw->chunk = OutputChunk(kJpegBitWriterChunkSize); @@ -65,7 +66,7 @@ static JXL_NOINLINE void SwapBuffer(JpegBitWriter* bw) { bw->pos = 0; } -static JXL_INLINE void Reserve(JpegBitWriter* bw, size_t n_bytes) { +JXL_INLINE void Reserve(JpegBitWriter* bw, size_t n_bytes) { if (JXL_UNLIKELY((bw->pos + n_bytes) > kJpegBitWriterChunkSize)) { SwapBuffer(bw); } @@ -77,14 +78,14 @@ static JXL_INLINE void Reserve(JpegBitWriter* bw, size_t n_bytes) { * This method is "careless" - caller must make sure that there is enough * space in the output buffer. Emits up to 2 bytes to buffer. */ -static JXL_INLINE void EmitByte(JpegBitWriter* bw, int byte) { +JXL_INLINE void EmitByte(JpegBitWriter* bw, int byte) { bw->data[bw->pos] = byte; bw->data[bw->pos + 1] = 0; bw->pos += (byte != 0xFF ? 1 : 2); } -static JXL_INLINE void DischargeBitBuffer(JpegBitWriter* bw, int nbits, - uint64_t bits) { +JXL_INLINE void DischargeBitBuffer(JpegBitWriter* bw, int nbits, + uint64_t bits) { // At this point we are ready to emit the put_buffer to the output. // The JPEG format requires that after every 0xff byte in the entropy // coded section, there is a zero byte, therefore we first check if any of @@ -111,7 +112,7 @@ static JXL_INLINE void DischargeBitBuffer(JpegBitWriter* bw, int nbits, bw->put_buffer = bits << bw->put_bits; } -static JXL_INLINE void WriteBits(JpegBitWriter* bw, int nbits, uint64_t bits) { +JXL_INLINE void WriteBits(JpegBitWriter* bw, int nbits, uint64_t bits) { JXL_DASSERT(nbits > 0); bw->put_bits -= nbits; if (JXL_UNLIKELY(bw->put_bits < 0)) { @@ -142,12 +143,14 @@ bool JumpToByteBoundary(JpegBitWriter* bw, const uint8_t** pad_bits, } else { pad_pattern = 0; const uint8_t* src = *pad_bits; - // TODO(eustas): bitwise reading looks insanely ineffective... + // TODO(eustas): bitwise reading looks insanely ineffective! while (n_bits--) { pad_pattern <<= 1; if (src >= pad_bits_end) return false; - // TODO(eustas): DCHECK *src == {0, 1} - pad_pattern |= !!*(src++); + uint8_t bit = *src; + src++; + JXL_ASSERT(bit <= 1); + pad_pattern |= bit; } *pad_bits = src; } @@ -187,21 +190,20 @@ void DCTCodingStateInit(DCTCodingState* s) { s->refinement_bits_.reserve(64); } -static JXL_INLINE void WriteSymbol(int symbol, HuffmanCodeTable* table, - JpegBitWriter* bw) { +JXL_INLINE void WriteSymbol(int symbol, HuffmanCodeTable* table, + JpegBitWriter* bw) { WriteBits(bw, table->depth[symbol], table->code[symbol]); } -static JXL_INLINE void WriteSymbolBits(int symbol, HuffmanCodeTable* table, - JpegBitWriter* bw, int nbits, - uint64_t bits) { +JXL_INLINE void WriteSymbolBits(int symbol, HuffmanCodeTable* table, + JpegBitWriter* bw, int nbits, uint64_t bits) { WriteBits(bw, nbits + table->depth[symbol], bits | (table->code[symbol] << nbits)); } // Emit all buffered data to the bit stream using the given Huffman code and // bit writer. -static JXL_INLINE void Flush(DCTCodingState* s, JpegBitWriter* bw) { +JXL_INLINE void Flush(DCTCodingState* s, JpegBitWriter* bw) { if (s->eob_run_ > 0) { Reserve(bw, 16); int nbits = FloorLog2Nonzero(s->eob_run_); @@ -233,11 +235,9 @@ static JXL_INLINE void Flush(DCTCodingState* s, JpegBitWriter* bw) { // Buffer some more data at the end-of-band (the last non-zero or newly // non-zero coefficient within the [Ss, Se] spectral band). -static JXL_INLINE void BufferEndOfBand(DCTCodingState* s, - HuffmanCodeTable* ac_huff, - const int* new_bits_array, - size_t new_bits_count, - JpegBitWriter* bw) { +JXL_INLINE void BufferEndOfBand(DCTCodingState* s, HuffmanCodeTable* ac_huff, + const int* new_bits_array, + size_t new_bits_count, JpegBitWriter* bw) { if (s->eob_run_ == 0) { s->cur_ac_huff_ = ac_huff; } @@ -530,7 +530,7 @@ bool EncodeDCTBlockSequential(const coeff_t* coeffs, HuffmanCodeTable* dc_huff, int dc_nbits = (temp2 == 0) ? 0 : (FloorLog2Nonzero(temp2) + 1); WriteSymbol(dc_nbits, dc_huff, bw); -#if false +#if JXL_FALSE // If the input is corrupt, this could be triggered. Checking is // costly though, so it makes more sense to avoid this branch. // (producing a corrupt JPEG when the input is corrupt, instead @@ -543,7 +543,8 @@ bool EncodeDCTBlockSequential(const coeff_t* coeffs, HuffmanCodeTable* dc_huff, int16_t r = 0; for (size_t i = 1; i < 64; i++) { - if ((temp = coeffs[kJPEGNaturalOrder[i]]) == 0) { + temp = coeffs[kJPEGNaturalOrder[i]]; + if (temp == 0) { r++; } else { temp2 = temp >> (8 * sizeof(coeff_t) - 1); @@ -611,7 +612,8 @@ bool EncodeDCTBlockProgressive(const coeff_t* coeffs, HuffmanCodeTable* dc_huff, } int r = 0; for (int k = Ss; k <= Se; ++k) { - if ((temp = coeffs[kJPEGNaturalOrder[k]]) == 0) { + temp = coeffs[kJPEGNaturalOrder[k]]; + if (temp == 0) { r++; continue; } @@ -884,8 +886,8 @@ SerializationStatus JXL_NOINLINE DoEncodeScan(const JPEGData& jpg, return SerializationStatus::DONE; } -static SerializationStatus JXL_INLINE EncodeScan(const JPEGData& jpg, - SerializationState* state) { +SerializationStatus JXL_INLINE EncodeScan(const JPEGData& jpg, + SerializationState* state) { const JPEGScanInfo& scan_info = jpg.scan_info[state->scan_index]; const bool is_progressive = state->is_progressive; const int Al = is_progressive ? scan_info.Al : 0; diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc index 97342553e5..d311908415 100644 --- a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc +++ b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data.cc @@ -8,7 +8,7 @@ #include #include "lib/jxl/codec_in_out.h" -#include "lib/jxl/enc_fields.h" +#include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/image_bundle.h" #include "lib/jxl/jpeg/enc_jpeg_data_reader.h" #include "lib/jxl/luminance.h" @@ -76,7 +76,8 @@ bool GetMarkerPayload(const uint8_t* data, size_t size, ByteSpan* payload) { Status DetectBlobs(jpeg::JPEGData& jpeg_data) { JXL_DASSERT(jpeg_data.app_data.size() == jpeg_data.app_marker_type.size()); - bool have_exif = false, have_xmp = false; + bool have_exif = false; + bool have_xmp = false; for (size_t i = 0; i < jpeg_data.app_data.size(); i++) { auto& marker = jpeg_data.app_data[i]; if (marker.empty() || marker[0] != kApp1) { @@ -165,7 +166,7 @@ Status ParseChunkedMarker(const jpeg::JPEGData& src, uint8_t marker_type, if (!presence[index]) { return JXL_FAILURE("Missing chunk."); } - chunks[index].AppendTo(output); + chunks[index].AppendTo(*output); } return true; @@ -173,7 +174,7 @@ Status ParseChunkedMarker(const jpeg::JPEGData& src, uint8_t marker_type, Status SetBlobsFromJpegData(const jpeg::JPEGData& jpeg_data, Blobs* blobs) { for (size_t i = 0; i < jpeg_data.app_data.size(); i++) { - auto& marker = jpeg_data.app_data[i]; + const auto& marker = jpeg_data.app_data[i]; if (marker.empty() || marker[0] != kApp1) { continue; } @@ -210,7 +211,7 @@ Status SetBlobsFromJpegData(const jpeg::JPEGData& jpeg_data, Blobs* blobs) { return true; } -static inline bool IsJPG(const Span bytes) { +inline bool IsJPG(const Span bytes) { return bytes.size() >= 2 && bytes[0] == 0xFF && bytes[1] == 0xD8; } @@ -239,14 +240,16 @@ Status SetChromaSubsamplingFromJpegData(const JPEGData& jpg, return JXL_FAILURE("Cannot recompress JPEGs with neither 1 nor 3 channels"); } if (nbcomp == 3) { - uint8_t hsample[3], vsample[3]; + uint8_t hsample[3]; + uint8_t vsample[3]; for (size_t i = 0; i < nbcomp; i++) { hsample[i] = jpg.components[i].h_samp_factor; vsample[i] = jpg.components[i].v_samp_factor; } JXL_RETURN_IF_ERROR(cs->Set(hsample, vsample)); } else if (nbcomp == 1) { - uint8_t hsample[3], vsample[3]; + uint8_t hsample[3]; + uint8_t vsample[3]; for (size_t i = 0; i < 3; i++) { hsample[i] = jpg.components[0].h_samp_factor; vsample[i] = jpg.components[0].v_samp_factor; @@ -330,7 +333,7 @@ Status EncodeJPEGData(JPEGData& jpeg_data, std::vector* bytes, { PaddedBytes serialized_jpeg_data = std::move(writer).TakeBytes(); bytes->reserve(serialized_jpeg_data.size() + brotli_capacity); - Bytes(serialized_jpeg_data).AppendTo(bytes); + Bytes(serialized_jpeg_data).AppendTo(*bytes); } BrotliEncoderState* brotli_enc = @@ -394,8 +397,9 @@ Status DecodeImageJPG(const Span bytes, CodecInOut* io) { io->metadata.m.SetIntensityTarget(kDefaultIntensityTarget); io->metadata.m.SetUintSamples(BITS_IN_JSAMPLE); - io->SetFromImage(Image3F(jpeg_data->width, jpeg_data->height), - io->metadata.m.color_encoding); + JXL_ASSIGN_OR_RETURN(Image3F tmp, + Image3F::Create(jpeg_data->width, jpeg_data->height)); + io->SetFromImage(std::move(tmp), io->metadata.m.color_encoding); SetIntensityTarget(&io->metadata.m); return true; } diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc index ce64dae47b..d1e8476db6 100644 --- a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc +++ b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.cc @@ -23,7 +23,7 @@ namespace jxl { namespace jpeg { namespace { -static const int kBrunsliMaxSampling = 15; +const int kBrunsliMaxSampling = 15; // Macros for commonly used error conditions. @@ -234,7 +234,7 @@ bool ProcessDHT(const uint8_t* data, const size_t len, JpegReadMode mode, JPEGHuffmanCode huff; huff.slot_id = ReadUint8(data, pos); int huffman_index = huff.slot_id; - int is_ac_table = (huff.slot_id & 0x10) != 0; + bool is_ac_table = ((huff.slot_id & 0x10) != 0); HuffmanTableEntry* huff_lut; if (is_ac_table) { huffman_index -= 0x10; @@ -292,7 +292,7 @@ bool ProcessDHT(const uint8_t* data, const size_t len, JpegReadMode mode, } huff.is_last = (*pos == start_pos + marker_len); if (mode == JpegReadMode::kReadAll) { - BuildJpegHuffmanTable(&huff.counts[0], &huff.values[0], huff_lut); + BuildJpegHuffmanTable(huff.counts.data(), huff.values.data(), huff_lut); } jpg->huffman_code.push_back(huff); } @@ -419,7 +419,7 @@ struct BitReaderState { if (bits_left_ <= 16) { while (bits_left_ <= 56) { val_ <<= 8; - val_ |= (uint64_t)GetNextByte(); + val_ |= static_cast(GetNextByte()); bits_left_ += 8; } } diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.h b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.h index 3fad820e9d..4389b2ffe3 100644 --- a/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.h +++ b/third_party/jpeg-xl/lib/jxl/jpeg/enc_jpeg_data_reader.h @@ -27,7 +27,7 @@ enum class JpegReadMode { // If mode is kReadHeader, it fills in only the image dimensions in *jpg. // Returns false if the data is not valid JPEG, or if it contains an unsupported // JPEG feature. -bool ReadJpeg(const uint8_t* data, const size_t len, JpegReadMode mode, +bool ReadJpeg(const uint8_t* data, size_t len, JpegReadMode mode, JPEGData* jpg); } // namespace jpeg diff --git a/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc b/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc index 6744e6935a..aeb9914cca 100644 --- a/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc +++ b/third_party/jpeg-xl/lib/jxl/jpeg/jpeg_data.cc @@ -5,6 +5,8 @@ #include "lib/jxl/jpeg/jpeg_data.h" +#include + #include "lib/jxl/base/printf_macros.h" #include "lib/jxl/base/status.h" #include "lib/jxl/common.h" // kMaxNumPasses, JPEGXL_ENABLE_TRANSCODE_JPEG @@ -214,7 +216,7 @@ Status JPEGData::VisitFields(Visitor* visitor) { huffman_code.resize(num_huff); } for (JPEGHuffmanCode& hc : huffman_code) { - bool is_ac = hc.slot_id >> 4; + bool is_ac = ((hc.slot_id >> 4) != 0); uint32_t id = hc.slot_id & 0xF; JXL_RETURN_IF_ERROR(visitor->Bool(false, &is_ac)); JXL_RETURN_IF_ERROR(visitor->Bits(2, 0, &id)); @@ -240,7 +242,8 @@ Status JPEGData::VisitFields(Visitor* visitor) { JXL_RETURN_IF_ERROR(visitor->U32(Bits(2), BitsOffset(2, 4), BitsOffset(4, 8), BitsOffset(8, 1), 0, &hc.values[i])); - value_slots[hc.values[i] >> 6] |= (uint64_t)1 << (hc.values[i] & 0x3F); + value_slots[hc.values[i] >> 6] |= static_cast(1) + << (hc.values[i] & 0x3F); } if (hc.values[num_symbols - 1] != kJpegHuffmanAlphabetSize) { return JXL_FAILURE("Missing EOI symbol"); @@ -361,13 +364,13 @@ Status JPEGData::VisitFields(Visitor* visitor) { for (uint32_t i = 0; i < nbit; i++) { bool bbit = false; JXL_RETURN_IF_ERROR(visitor->Bool(false, &bbit)); - padding_bits.push_back(bbit); + padding_bits.push_back(TO_JXL_BOOL(bbit)); } } else { for (uint8_t& bit : padding_bits) { - bool bbit = bit; + bool bbit = FROM_JXL_BOOL(bit); JXL_RETURN_IF_ERROR(visitor->Bool(false, &bbit)); - bit = bbit; + bit = TO_JXL_BOOL(bbit); } } } diff --git a/third_party/jpeg-xl/lib/jxl/jxl_test.cc b/third_party/jpeg-xl/lib/jxl/jxl_test.cc index a91dbd0672..b0933d5d50 100644 --- a/third_party/jpeg-xl/lib/jxl/jxl_test.cc +++ b/third_party/jpeg-xl/lib/jxl/jxl_test.cc @@ -33,7 +33,6 @@ #include "lib/jxl/codec_in_out.h" #include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/common.h" // JXL_HIGH_PRECISION -#include "lib/jxl/enc_butteraugli_comparator.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/fake_parallel_runner_testonly.h" #include "lib/jxl/image.h" @@ -72,7 +71,7 @@ TEST(JxlTest, RoundtripSinglePixelWithAlpha) { TestImage t; t.SetDimensions(1, 1).SetChannels(4).AddFrame().ZeroFill(); PackedPixelFile ppf_out; - EXPECT_EQ(Roundtrip(t.ppf(), {}, {}, nullptr, &ppf_out), 59); + EXPECT_EQ(Roundtrip(t.ppf(), {}, {}, nullptr, &ppf_out), 58); } // Changing serialized signature causes Decode to fail. @@ -87,7 +86,7 @@ TEST(JxlTest, RoundtripMarker) { compressed[i] ^= 0xFF; PackedPixelFile ppf_out; EXPECT_FALSE(extras::DecodeImageJXL(compressed.data(), compressed.size(), - {}, /*decodec_bytes=*/nullptr, + {}, /* decoded_bytes */ nullptr, &ppf_out)); } } @@ -121,7 +120,7 @@ TEST(JxlTest, RoundtripSmallD1) { { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), {}, {}, pool, &ppf_out), 916, 40); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(0.888)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.888); } // With a lower intensity target than the default, the bitrate should be @@ -131,7 +130,7 @@ TEST(JxlTest, RoundtripSmallD1) { { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), {}, {}, pool, &ppf_out), 745, 20); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.3)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.3); EXPECT_EQ(ppf_out.info.intensity_target, t.ppf().info.intensity_target); } } @@ -147,8 +146,8 @@ TEST(JxlTest, RoundtripResample2) { cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 3); // kFalcon PackedPixelFile ppf_out; - EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 18500, 200); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(90)); + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 17300, 500); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 90); } TEST(JxlTest, RoundtripResample2Slow) { @@ -165,7 +164,7 @@ TEST(JxlTest, RoundtripResample2Slow) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 3888, 200); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(250)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 250); } TEST(JxlTest, RoundtripResample2MT) { @@ -180,8 +179,8 @@ TEST(JxlTest, RoundtripResample2MT) { cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 3); // kFalcon PackedPixelFile ppf_out; - EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 223310, 2000); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(340)); + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 203300, 2000); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 340); } // Roundtrip the image using a parallel runner that executes single-threaded but @@ -237,7 +236,7 @@ TEST(JxlTest, RoundtripResample4) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 5758, 100); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(22)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 22); } TEST(JxlTest, RoundtripResample8) { @@ -252,7 +251,7 @@ TEST(JxlTest, RoundtripResample8) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 2036, 50); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(50)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 50); } TEST(JxlTest, RoundtripUnalignedD2) { @@ -270,7 +269,7 @@ TEST(JxlTest, RoundtripUnalignedD2) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 506, 30); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.72)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.72); } TEST(JxlTest, RoundtripMultiGroup) { @@ -289,8 +288,8 @@ TEST(JxlTest, RoundtripMultiGroup) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), expected_size, 700); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), - IsSlightlyBelow(expected_distance)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), + expected_distance); }; auto run_kitten = std::async(std::launch::async, test, SpeedTier::kKitten, @@ -339,10 +338,11 @@ TEST(JxlTest, RoundtripRGBToGrayscale) { ASSERT_TRUE(io.frames[0].TransformTo(srgb_gamma, *JxlGetDefaultCms())); io.metadata.m.color_encoding = io2.Main().c_current(); io.Main().OverrideProfile(io2.Main().c_current()); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr, &pool), - IsSlightlyBelow(1.36)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr, &pool), + 1.4); } TEST(JxlTest, RoundtripLargeFast) { @@ -355,8 +355,57 @@ TEST(JxlTest, RoundtripLargeFast) { cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 7); // kSquirrel PackedPixelFile ppf_out; - EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 492867, 5000); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(78)); + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 503000, 12000); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 78); +} + +TEST(JxlTest, JXL_X86_64_TEST(RoundtripLargeEmptyModular)) { + ThreadPoolForTests pool(8); + TestImage t; + t.SetDimensions(4096, 4096).SetDataType(JXL_TYPE_UINT8).SetChannels(4); + TestImage::Frame frame = t.AddFrame(); + frame.ZeroFill(); + for (size_t c = 0; c < 4; ++c) { + for (size_t y = 0; y < 1024; y += (c + 1)) { + for (size_t x = 0; x < 1024; x += ((y % 4) + 3)) { + frame.SetValue(y, x, c, 0.88); + } + } + } + + JXLCompressParams cparams; + cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 1); + cparams.AddOption(JXL_ENC_FRAME_SETTING_MODULAR, 1); + cparams.AddOption(JXL_ENC_FRAME_SETTING_RESPONSIVE, 1); + cparams.AddOption(JXL_ENC_FRAME_SETTING_DECODING_SPEED, 2); + + PackedPixelFile ppf_out; + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 3474795, + 100000); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), +#if JXL_HIGH_PRECISION + 2050 +#else + 12100 +#endif + ); +} + +TEST(JxlTest, RoundtripOutputColorSpace) { + ThreadPoolForTests pool(8); + const std::vector orig = ReadTestData("jxl/flower/flower.png"); + TestImage t; + t.DecodeFromBytes(orig).ClearMetadata(); + + JXLCompressParams cparams; + cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 7); // kSquirrel + + JXLDecompressParams dparams; + dparams.color_space = "RGB_D65_DCI_Rel_709"; + PackedPixelFile ppf_out; + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, dparams, &pool, &ppf_out), 503000, + 12000); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 78); } TEST(JxlTest, RoundtripDotsForceEpf) { @@ -373,7 +422,7 @@ TEST(JxlTest, RoundtripDotsForceEpf) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 41355, 300); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(18)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 18); } // Checks for differing size/distance in two consecutive runs of distance 2, @@ -453,7 +502,7 @@ TEST(JxlTest, RoundtripSmallNL) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), {}, {}, pool, &ppf_out), 916, 45); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(0.82)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.82); } TEST(JxlTest, RoundtripNoGaborishNoAR) { @@ -469,7 +518,7 @@ TEST(JxlTest, RoundtripNoGaborishNoAR) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 41142, 400); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.8)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.8); } TEST(JxlTest, RoundtripSmallNoGaborish) { @@ -487,7 +536,7 @@ TEST(JxlTest, RoundtripSmallNoGaborish) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 1006, 20); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.1)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.1); } TEST(JxlTest, RoundtripSmallPatchesAlpha) { @@ -513,7 +562,7 @@ TEST(JxlTest, RoundtripSmallPatchesAlpha) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 597, 100); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(0.018f)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.018f); } TEST(JxlTest, RoundtripSmallPatches) { @@ -538,17 +587,17 @@ TEST(JxlTest, RoundtripSmallPatches) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 486, 100); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(0.018f)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.018f); } // TODO(szabadka) Add encoder and decoder API functions that accept frame // buffers in arbitrary unsigned and floating point formats, and then roundtrip // test the lossless codepath to make sure the exact binary representations // are preserved. -#if 0 +#if JXL_FALSE TEST(JxlTest, RoundtripImageBundleOriginalBits) { // Image does not matter, only io.metadata.m and io2.metadata.m are tested. - Image3F image(1, 1); + JXL_ASSIGN_OR_DIE(Image3F image, Image3F::Create(1, 1)); ZeroFillImage(&image); CodecInOut io; io.metadata.m.color_encoding = ColorEncoding::LinearSRGB(); @@ -639,10 +688,11 @@ TEST(JxlTest, RoundtripGrayscale) { EXPECT_TRUE(io2.Main().IsGray()); EXPECT_LE(compressed.size(), 7000u); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(1.6)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 1.6); } // Test with larger butteraugli distance and other settings enabled so @@ -658,10 +708,11 @@ TEST(JxlTest, RoundtripGrayscale) { EXPECT_TRUE(io2.Main().IsGray()); EXPECT_LE(compressed.size(), 1300u); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(6.7)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 6.7); } { @@ -678,10 +729,11 @@ TEST(JxlTest, RoundtripGrayscale) { EXPECT_FALSE(io2.Main().IsGray()); EXPECT_LE(compressed.size(), 7000u); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(1.6)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 1.6); } } @@ -706,7 +758,7 @@ TEST(JxlTest, RoundtripAlpha) { std::vector compressed; EXPECT_TRUE(test::EncodeFile(cparams, &io, &compressed)); - EXPECT_LE(compressed.size(), 10077u); + EXPECT_LE(compressed.size(), 20000u); for (bool use_image_callback : {false, true}) { for (bool unpremul_alpha : {false, true}) { @@ -715,10 +767,11 @@ TEST(JxlTest, RoundtripAlpha) { dparams.use_image_callback = use_image_callback; dparams.unpremultiply_alpha = unpremul_alpha; EXPECT_TRUE(test::DecodeFile(dparams, Bytes(compressed), &io2)); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, - ButteraugliParams(), *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(1.15)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 1.15); } } } @@ -781,7 +834,8 @@ bool UnpremultiplyAlpha(CodecInOut& io) { TEST(JxlTest, RoundtripAlphaPremultiplied) { const std::vector orig = ReadTestData("external/wesaturate/500px/tmshre_riaphotographs_alpha.png"); - CodecInOut io, io_nopremul; + CodecInOut io; + CodecInOut io_nopremul; ASSERT_TRUE(SetFromBytes(Bytes(orig), &io)); ASSERT_TRUE(SetFromBytes(Bytes(orig), &io_nopremul)); @@ -803,7 +857,7 @@ TEST(JxlTest, RoundtripAlphaPremultiplied) { std::vector compressed; EXPECT_TRUE(test::EncodeFile(cparams, &io, &compressed)); - EXPECT_LE(compressed.size(), 10000u); + EXPECT_LE(compressed.size(), 18000u); for (bool use_image_callback : {false, true}) { for (bool unpremul_alpha : {false, true}) { @@ -826,19 +880,19 @@ TEST(JxlTest, RoundtripAlphaPremultiplied) { EXPECT_EQ(unpremul_alpha, !io2.Main().AlphaIsPremultiplied()); if (!unpremul_alpha) { - EXPECT_THAT( + EXPECT_SLIGHTLY_BELOW( ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), *JxlGetDefaultCms(), /*distmap=*/nullptr), - IsSlightlyBelow(1.111)); + 1.111); EXPECT_TRUE(UnpremultiplyAlpha(io2)); EXPECT_FALSE(io2.Main().AlphaIsPremultiplied()); } - EXPECT_THAT( + EXPECT_SLIGHTLY_BELOW( ButteraugliDistance(io_nopremul.frames, io2.frames, ButteraugliParams(), *JxlGetDefaultCms(), /*distmap=*/nullptr), - IsSlightlyBelow(1.55)); + 1.0); } } } @@ -854,13 +908,14 @@ TEST(JxlTest, RoundtripAlphaResampling) { ASSERT_TRUE(t.ppf().info.alpha_bits > 0); JXLCompressParams cparams; + cparams.alpha_distance = 1.0; cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 5); // kHare cparams.AddOption(JXL_ENC_FRAME_SETTING_RESAMPLING, 2); cparams.AddOption(JXL_ENC_FRAME_SETTING_EXTRA_CHANNEL_RESAMPLING, 2); PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 13507, 130); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(5.2)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 5.2); } TEST(JxlTest, RoundtripAlphaResamplingOnlyAlpha) { @@ -873,12 +928,13 @@ TEST(JxlTest, RoundtripAlphaResamplingOnlyAlpha) { ASSERT_TRUE(t.ppf().info.alpha_bits > 0); JXLCompressParams cparams; + cparams.alpha_distance = 1.0; cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 3); // kFalcon cparams.AddOption(JXL_ENC_FRAME_SETTING_EXTRA_CHANNEL_RESAMPLING, 2); PackedPixelFile ppf_out; - EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 33571, 400); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.49)); + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 32000, 1000); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.52); } TEST(JxlTest, RoundtripAlphaNonMultipleOf8) { @@ -893,13 +949,14 @@ TEST(JxlTest, RoundtripAlphaNonMultipleOf8) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), {}, {}, pool, &ppf_out), 107, 10); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(0.95)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.006); } TEST(JxlTest, RoundtripAlpha16) { ThreadPoolForTests pool(4); // The image is wider than 512 pixels to ensure multiple groups are tested. - size_t xsize = 1200, ysize = 160; + size_t xsize = 1200; + size_t ysize = 160; TestImage t; t.SetDimensions(xsize, ysize).SetChannels(4).SetAllBitDepths(16); TestImage::Frame frame = t.AddFrame(); @@ -923,12 +980,13 @@ TEST(JxlTest, RoundtripAlpha16) { JXLCompressParams cparams; cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 6); // kWombat cparams.distance = 0.5; + cparams.alpha_distance = 0.5; PackedPixelFile ppf_out; // TODO(szabadka) Investigate big size difference on i686 // This still keeps happening (2023-04-18). EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 3666, 120); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(0.65)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.65); } namespace { @@ -990,8 +1048,8 @@ TEST(JxlTest, JXL_SLOW_TEST(RoundtripLossless8LightningGradient)) { PackedPixelFile ppf_out; // Lax comparison because different SIMD will cause different compression. - EXPECT_THAT(Roundtrip(t.ppf(), cparams, dparams, &pool, &ppf_out), - IsSlightlyBelow(286848u)); + EXPECT_SLIGHTLY_BELOW(Roundtrip(t.ppf(), cparams, dparams, &pool, &ppf_out), + 286848u); EXPECT_EQ(ComputeDistance2(t.ppf(), ppf_out), 0.0); } @@ -1035,7 +1093,8 @@ TEST(JxlTest, RoundtripLossless8Alpha) { TEST(JxlTest, RoundtripLossless16Alpha) { ThreadPool* pool = nullptr; - size_t xsize = 1200, ysize = 160; + size_t xsize = 1200; + size_t ysize = 160; TestImage t; t.SetDimensions(xsize, ysize).SetChannels(4).SetAllBitDepths(16); TestImage::Frame frame = t.AddFrame(); @@ -1062,7 +1121,7 @@ TEST(JxlTest, RoundtripLossless16Alpha) { PackedPixelFile ppf_out; // TODO(szabadka) Investigate big size difference on i686 - EXPECT_NEAR(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), 4884, 100); + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), 4665, 100); EXPECT_EQ(ComputeDistance2(t.ppf(), ppf_out), 0.0); EXPECT_EQ(ppf_out.info.alpha_bits, 16); EXPECT_TRUE(test::SameAlpha(t.ppf(), ppf_out)); @@ -1070,7 +1129,8 @@ TEST(JxlTest, RoundtripLossless16Alpha) { TEST(JxlTest, RoundtripLossless16AlphaNotMisdetectedAs8Bit) { ThreadPool* pool = nullptr; - size_t xsize = 128, ysize = 128; + size_t xsize = 128; + size_t ysize = 128; TestImage t; t.SetDimensions(xsize, ysize).SetChannels(4).SetAllBitDepths(16); TestImage::Frame frame = t.AddFrame(); @@ -1098,7 +1158,7 @@ TEST(JxlTest, RoundtripLossless16AlphaNotMisdetectedAs8Bit) { dparams.accepted_formats.push_back(t.ppf().frames[0].color.format); PackedPixelFile ppf_out; - EXPECT_NEAR(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), 591, 50); + EXPECT_NEAR(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), 280, 50); EXPECT_EQ(ComputeDistance2(t.ppf(), ppf_out), 0.0); EXPECT_EQ(ppf_out.info.bits_per_sample, 16); EXPECT_EQ(ppf_out.info.alpha_bits, 16); @@ -1123,7 +1183,7 @@ TEST(JxlTest, RoundtripDots) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 280333, 4000); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(0.35)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 0.35); } TEST(JxlTest, RoundtripNoise) { @@ -1143,7 +1203,7 @@ TEST(JxlTest, RoundtripNoise) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, pool, &ppf_out), 41009, 750); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.42)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.42); } TEST(JxlTest, RoundtripLossless8Gray) { @@ -1182,17 +1242,17 @@ TEST(JxlTest, RoundtripAnimation) { dparams.accepted_formats.push_back(t.ppf().frames[0].color.format); PackedPixelFile ppf_out; - EXPECT_THAT(Roundtrip(t.ppf(), {}, dparams, pool, &ppf_out), - IsSlightlyBelow(2888)); + EXPECT_SLIGHTLY_BELOW(Roundtrip(t.ppf(), {}, dparams, pool, &ppf_out), 3350); t.CoalesceGIFAnimationWithAlpha(); ASSERT_EQ(ppf_out.frames.size(), t.ppf().frames.size()); - EXPECT_LE(ButteraugliDistance(t.ppf(), ppf_out), + static constexpr double kMaxButteraugli = #if JXL_HIGH_PRECISION - 1.55); + 1.55; #else - 1.75); + 1.75; #endif + EXPECT_LE(ButteraugliDistance(t.ppf(), ppf_out), kMaxButteraugli); } TEST(JxlTest, RoundtripLosslessAnimation) { @@ -1212,8 +1272,8 @@ TEST(JxlTest, RoundtripLosslessAnimation) { dparams.accepted_formats.push_back(t.ppf().frames[0].color.format); PackedPixelFile ppf_out; - EXPECT_THAT(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), - IsSlightlyBelow(958)); + EXPECT_SLIGHTLY_BELOW(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), + 958); t.CoalesceGIFAnimationWithAlpha(); ASSERT_EQ(ppf_out.frames.size(), t.ppf().frames.size()); @@ -1240,11 +1300,11 @@ TEST(JxlTest, RoundtripAnimationPatches) { PackedPixelFile ppf_out; // 40k with no patches, 27k with patch frames encoded multiple times. - EXPECT_THAT(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), - IsSlightlyBelow(19300)); + EXPECT_SLIGHTLY_BELOW(Roundtrip(t.ppf(), cparams, dparams, pool, &ppf_out), + 19300); EXPECT_EQ(ppf_out.frames.size(), t.ppf().frames.size()); // >10 with broken patches; not all patches are detected on borders. - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.9)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.9); } size_t RoundtripJpeg(const std::vector& jpeg_in, ThreadPool* pool) { @@ -1293,7 +1353,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression444)) { const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_444.jpg"); // JPEG size is 696,659 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 568940u, 20); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 568891u, 20); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionToPixels)) { @@ -1306,7 +1366,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionToPixels)) { PackedPixelFile ppf_out; RoundtripJpegToPixels(orig, {}, &pool, &ppf_out); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(12)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 12); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionToPixels420)) { @@ -1319,7 +1379,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionToPixels420)) { PackedPixelFile ppf_out; RoundtripJpegToPixels(orig, {}, &pool, &ppf_out); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(11)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 11); } TEST(JxlTest, @@ -1336,7 +1396,7 @@ TEST(JxlTest, PackedPixelFile ppf_out; RoundtripJpegToPixels(orig, dparams, &pool, &ppf_out); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(4410)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 4410); } TEST(JxlTest, @@ -1350,7 +1410,7 @@ TEST(JxlTest, PackedPixelFile ppf_out; RoundtripJpegToPixels(orig, {}, &pool, &ppf_out); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(4)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 4); } TEST(JxlTest, @@ -1364,7 +1424,7 @@ TEST(JxlTest, PackedPixelFile ppf_out; RoundtripJpegToPixels(orig, {}, &pool, &ppf_out); - EXPECT_THAT(ComputeDistance2(t.ppf(), ppf_out), IsSlightlyBelow(10)); + EXPECT_SLIGHTLY_BELOW(ComputeDistance2(t.ppf(), ppf_out), 10); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionGray)) { @@ -1380,7 +1440,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression420)) { const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_420.jpg"); // JPEG size is 546,797 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 455560u, 10); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 455510u, 20); } TEST(JxlTest, @@ -1389,7 +1449,7 @@ TEST(JxlTest, const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_luma_subsample.jpg"); // JPEG size is 400,724 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 325354u, 15); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 325310u, 20); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression444_12)) { @@ -1398,7 +1458,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression444_12)) { const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_444_1x2.jpg"); // JPEG size is 703,874 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 569679u, 10); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 569630u, 20); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression422)) { @@ -1406,7 +1466,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression422)) { const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_422.jpg"); // JPEG size is 522,057 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 499282u, 10); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 499236u, 20); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression440)) { @@ -1414,7 +1474,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression440)) { const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_440.jpg"); // JPEG size is 603,623 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 501151u, 10); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 501101u, 20); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression_asymmetric)) { @@ -1424,7 +1484,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression_asymmetric)) { const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_asymmetric.jpg"); // JPEG size is 604,601 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 500602u, 10); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 500548u, 20); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression420Progr)) { @@ -1432,7 +1492,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompression420Progr)) { const std::vector orig = ReadTestData("jxl/flower/flower.png.im_q85_420_progr.jpg"); // JPEG size is 522,057 bytes. - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 455499u, 10); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 455454u, 20); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionMetadata)) { @@ -1440,7 +1500,8 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionMetadata)) { const std::vector orig = ReadTestData("jxl/jpeg_reconstruction/1x1_exif_xmp.jpg"); // JPEG size is 4290 bytes - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 1400u, 30); + // 1370 on 386, so higher margin. + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 1334u, 100); } TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionRestarts)) { @@ -1448,7 +1509,7 @@ TEST(JxlTest, JXL_TRANSCODE_JPEG_TEST(RoundtripJpegRecompressionRestarts)) { const std::vector orig = ReadTestData("jxl/jpeg_reconstruction/bicycles_restarts.jpg"); // JPEG size is 87478 bytes - EXPECT_NEAR(RoundtripJpeg(orig, &pool), 76125u, 30); + EXPECT_NEAR(RoundtripJpeg(orig, &pool), 76054u, 30); } TEST(JxlTest, @@ -1475,7 +1536,7 @@ TEST(JxlTest, RoundtripProgressive) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 70544, 750); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.4)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.4); } TEST(JxlTest, RoundtripProgressiveLevel2Slow) { @@ -1492,7 +1553,7 @@ TEST(JxlTest, RoundtripProgressiveLevel2Slow) { PackedPixelFile ppf_out; EXPECT_NEAR(Roundtrip(t.ppf(), cparams, {}, &pool, &ppf_out), 76666, 1000); - EXPECT_THAT(ButteraugliDistance(t.ppf(), ppf_out), IsSlightlyBelow(1.17)); + EXPECT_SLIGHTLY_BELOW(ButteraugliDistance(t.ppf(), ppf_out), 1.17); } TEST(JxlTest, RoundtripUnsignedCustomBitdepthLossless) { @@ -1509,9 +1570,9 @@ TEST(JxlTest, RoundtripUnsignedCustomBitdepthLossless) { t.SetAllBitDepths(bitdepth).SetEndianness(endianness); TestImage::Frame frame = t.AddFrame(); frame.RandomFill(); + t.ppf().input_bitdepth.type = JXL_BIT_DEPTH_FROM_CODESTREAM; JXLCompressParams cparams = CompressParamsForLossless(); - cparams.input_bitdepth.type = JXL_BIT_DEPTH_FROM_CODESTREAM; JXLDecompressParams dparams; dparams.accepted_formats.push_back(t.ppf().frames[0].color.format); @@ -1543,7 +1604,6 @@ TEST(JxlTest, LosslessPNMRoundtrip) { JXLCompressParams cparams = CompressParamsForLossless(); cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 1); // kLightning - cparams.input_bitdepth.type = JXL_BIT_DEPTH_FROM_CODESTREAM; JXLDecompressParams dparams; dparams.accepted_formats.push_back(t.ppf().frames[0].color.format); @@ -1592,10 +1652,13 @@ struct StreamingTestParam { size_t xsize; size_t ysize; bool is_grey; + bool has_alpha; int effort; bool progressive; - size_t num_channels() const { return is_grey ? 1 : 3; } + size_t num_channels() const { + return (is_grey ? 1 : 3) + (has_alpha ? 1 : 0); + } float max_psnr() const { return is_grey ? 90 : 50; } @@ -1603,11 +1666,13 @@ struct StreamingTestParam { std::vector params; for (int e : {1, 3, 4, 7}) { for (bool g : {false, true}) { - params.push_back(StreamingTestParam{357, 517, g, e, false}); - params.push_back(StreamingTestParam{2247, 2357, g, e, false}); + params.push_back(StreamingTestParam{357, 517, g, false, e, false}); + params.push_back(StreamingTestParam{2247, 2357, g, false, e, false}); } } - params.push_back(StreamingTestParam{2247, 2357, false, 1, true}); + params.push_back(StreamingTestParam{2247, 2357, false, false, 1, true}); + params.push_back(StreamingTestParam{2247, 2157, false, false, 5, false}); + params.push_back(StreamingTestParam{2247, 2157, false, true, 5, false}); return params; } }; @@ -1651,15 +1716,66 @@ JXL_GTEST_INSTANTIATE_TEST_SUITE_P( JxlStreamingTest, JxlStreamingTest, testing::ValuesIn(StreamingTestParam::All())); +struct StreamingEncodingTestParam { + std::string file; + int effort; + float distance; + int group_size; + float palette_percent; + + static std::vector All() { + std::vector params; + for (const auto* file : + {"jxl/flower/flower.png", "jxl/flower/flower_alpha.png"}) { + for (int effort : {1, 3, 5, 6}) { + if (effort != 1) { + params.push_back( + StreamingEncodingTestParam{file, effort, 1.0, 1, -1}); + params.push_back( + StreamingEncodingTestParam{file, effort, 4.0, 1, -1}); + } + for (auto group_size : {-1, 0}) { + for (float palette_percent : {-1, 50, 100}) { + params.push_back(StreamingEncodingTestParam{ + file, effort, 0.0, group_size, palette_percent}); + } + } + } + } + return params; + } +}; + +std::ostream& operator<<(std::ostream& out, + const StreamingEncodingTestParam& p) { + out << p.file << "-"; + out << "e" << p.effort; + if (p.distance == 0) { + out << "Lossless"; + out << "G" << p.group_size << "P" << p.palette_percent; + } else { + out << "D" << p.distance; + } + return out; +} + +class JxlStreamingEncodingTest + : public ::testing::TestWithParam {}; + // This is broken on mingw32, so we only enable it for x86_64 now. -TEST(JxlTest, JXL_X86_64_TEST(StreamingSamePixels)) { - const std::vector orig = ReadTestData("jxl/flower/flower.png"); +TEST_P(JxlStreamingEncodingTest, JXL_X86_64_TEST(StreamingSamePixels)) { + const auto param = GetParam(); + const std::vector orig = ReadTestData(param.file); jxl::test::TestImage image; image.DecodeFromBytes(orig); + JXLCompressParams cparams; - cparams.distance = 1.0; - cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, 6); + cparams.distance = param.distance; + cparams.AddOption(JXL_ENC_FRAME_SETTING_EFFORT, param.effort); + cparams.AddOption(JXL_ENC_FRAME_SETTING_MODULAR_GROUP_SIZE, param.group_size); + cparams.AddFloatOption(JXL_ENC_FRAME_SETTING_CHANNEL_COLORS_GROUP_PERCENT, + param.palette_percent); cparams.AddOption(JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS, 0); ThreadPoolForTests pool(8); @@ -1673,5 +1789,9 @@ TEST(JxlTest, JXL_X86_64_TEST(StreamingSamePixels)) { EXPECT_TRUE(jxl::test::SamePixels(ppf_out, ppf_out_streaming)); } +JXL_GTEST_INSTANTIATE_TEST_SUITE_P( + JxlStreamingTest, JxlStreamingEncodingTest, + testing::ValuesIn(StreamingEncodingTestParam::All())); + } // namespace } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/libjxl.pc.in b/third_party/jpeg-xl/lib/jxl/libjxl.pc.in index 58b6941305..f5a9c43650 100644 --- a/third_party/jpeg-xl/lib/jxl/libjxl.pc.in +++ b/third_party/jpeg-xl/lib/jxl/libjxl.pc.in @@ -7,7 +7,7 @@ Name: libjxl Description: Loads and saves JPEG XL files Version: @JPEGXL_LIBRARY_VERSION@ @JPEGXL_REQUIRES_TYPE@: @JPEGXL_LIBRARY_REQUIRES@ -Libs: -L${libdir} -ljxl -Libs.private: -lm +Libs: -L${libdir} -ljxl @JPEGXL_PUBLIC_LIBS@ +Libs.private: @JPEGXL_PRIVATE_LIBS@ Cflags: -I${includedir} Cflags.private: -DJXL_STATIC_DEFINE diff --git a/third_party/jpeg-xl/lib/jxl/libjxl_cms.pc.in b/third_party/jpeg-xl/lib/jxl/libjxl_cms.pc.in index 9aaa3f4dbe..deab7367ac 100644 --- a/third_party/jpeg-xl/lib/jxl/libjxl_cms.pc.in +++ b/third_party/jpeg-xl/lib/jxl/libjxl_cms.pc.in @@ -7,7 +7,7 @@ Name: libjxl_cms Description: CMS support library for libjxl Version: @JPEGXL_LIBRARY_VERSION@ @JPEGXL_REQUIRES_TYPE@: @JPEGXL_CMS_LIBRARY_REQUIRES@ -Libs: -L${libdir} -ljxl_cms -Libs.private: -lm +Libs: -L${libdir} -ljxl_cms @JPEGXL_CMS_PUBLIC_LIBS@ +Libs.private: @JPEGXL_CMS_PRIVATE_LIBS@ Cflags: -I${includedir} Cflags.private: -DJXL_CMS_STATIC_DEFINE diff --git a/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h b/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h index c728d62e35..e578e91f8e 100644 --- a/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h +++ b/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h @@ -36,11 +36,13 @@ static JXL_INLINE Status MemoryManagerInit( } else { memset(self, 0, sizeof(*self)); } - if (!self->alloc != !self->free) { + bool is_default_alloc = (self->alloc == nullptr); + bool is_default_free = (self->free == nullptr); + if (is_default_alloc != is_default_free) { return false; } - if (!self->alloc) self->alloc = jxl::MemoryManagerDefaultAlloc; - if (!self->free) self->free = jxl::MemoryManagerDefaultFree; + if (is_default_alloc) self->alloc = jxl::MemoryManagerDefaultAlloc; + if (is_default_free) self->free = jxl::MemoryManagerDefaultFree; return true; } @@ -52,7 +54,7 @@ static JXL_INLINE void* MemoryManagerAlloc( static JXL_INLINE void MemoryManagerFree(const JxlMemoryManager* memory_manager, void* address) { - return memory_manager->free(memory_manager->opaque, address); + memory_manager->free(memory_manager->opaque, address); } // Helper class to be used as a deleter in a unique_ptr call. diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h b/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h index 4c3a33a52a..7bec5128fc 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/context_predict.h @@ -10,6 +10,7 @@ #include #include "lib/jxl/fields.h" +#include "lib/jxl/image_ops.h" #include "lib/jxl/modular/modular_image.h" #include "lib/jxl/modular/options.h" @@ -78,14 +79,14 @@ struct State { 294337, 289262, 284359, 279620, 275036, 270600, 266305, 262144}; constexpr static pixel_type_w AddBits(pixel_type_w x) { - return uint64_t(x) << kPredExtraBits; + return static_cast(x) << kPredExtraBits; } State(Header header, size_t xsize, size_t ysize) : header(header) { // Extra margin to avoid out-of-bounds writes. // All have space for two rows of data. - for (size_t i = 0; i < 4; i++) { - pred_errors[i].resize((xsize + 2) * 2); + for (auto &pred_error : pred_errors) { + pred_error.resize((xsize + 2) * 2); } error.resize((xsize + 2) * 2); } @@ -538,8 +539,9 @@ JXL_INLINE PredictionResult Predict( } if (mode & kAllPredictions) { for (size_t i = 0; i < kNumModularPredictors; i++) { - predictions[i] = PredictOne((Predictor)i, left, top, toptop, topleft, - topright, leftleft, toprightright, wp_pred); + predictions[i] = + PredictOne(static_cast(i), left, top, toptop, topleft, + topright, leftleft, toprightright, wp_pred); } } result.guess += PredictOne(predictor, left, top, toptop, topleft, topright, diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/dec_ma.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/dec_ma.cc index ee7177bcd6..b53b9a9103 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/dec_ma.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/dec_ma.cc @@ -5,6 +5,8 @@ #include "lib/jxl/modular/encoding/dec_ma.h" +#include + #include "lib/jxl/base/printf_macros.h" #include "lib/jxl/dec_ans.h" #include "lib/jxl/modular/encoding/ma_common.h" diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc index bd27f28458..f863823629 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_debug_tree.cc @@ -95,7 +95,7 @@ std::string PropertyName(size_t i) { case 15: return "WGH"; default: - return "ch[" + ToString(15 - (int)i) + "]"; + return "ch[" + ToString(15 - static_cast(i)) + "]"; } } diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc index fc2e69e4a6..84d8137d21 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc @@ -6,35 +6,24 @@ #include #include -#include #include -#include #include -#include -#include -#include #include "lib/jxl/base/common.h" #include "lib/jxl/base/printf_macros.h" #include "lib/jxl/base/status.h" -#include "lib/jxl/dec_ans.h" -#include "lib/jxl/dec_bit_reader.h" #include "lib/jxl/enc_ans.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_bit_writer.h" #include "lib/jxl/enc_fields.h" -#include "lib/jxl/entropy_coder.h" #include "lib/jxl/fields.h" #include "lib/jxl/image_ops.h" #include "lib/jxl/modular/encoding/context_predict.h" -#include "lib/jxl/modular/encoding/enc_debug_tree.h" #include "lib/jxl/modular/encoding/enc_ma.h" #include "lib/jxl/modular/encoding/encoding.h" #include "lib/jxl/modular/encoding/ma_common.h" #include "lib/jxl/modular/options.h" -#include "lib/jxl/modular/transform/transform.h" #include "lib/jxl/pack_signed.h" -#include "lib/jxl/toc.h" namespace jxl { @@ -61,7 +50,7 @@ inline std::array PredictorColor(Predictor p) { return {{255, 0, 255}}; case Predictor::Weighted: return {{0, 255, 255}}; - // TODO + // TODO(jon) default: return {{255, 255, 255}}; }; @@ -101,17 +90,17 @@ Tree MakeFixedTree(int property, const std::vector &cutoffs, } // namespace -void GatherTreeData(const Image &image, pixel_type chan, size_t group_id, - const weighted::Header &wp_header, - const ModularOptions &options, TreeSamples &tree_samples, - size_t *total_pixels) { +Status GatherTreeData(const Image &image, pixel_type chan, size_t group_id, + const weighted::Header &wp_header, + const ModularOptions &options, TreeSamples &tree_samples, + size_t *total_pixels) { const Channel &channel = image.channel[chan]; JXL_DEBUG_V(7, "Learning %" PRIuS "x%" PRIuS " channel %d", channel.w, channel.h, chan); std::array static_props = { - {chan, (int)group_id}}; + {chan, static_cast(group_id)}}; Properties properties(kNumNonrefProperties + kExtraPropsPerChannel * options.max_properties); double pixel_fraction = std::min(1.0f, options.nb_repeats); @@ -137,7 +126,9 @@ void GatherTreeData(const Image &image, pixel_type chan, size_t group_id, }; const intptr_t onerow = channel.plane.PixelsPerRow(); - Channel references(properties.size() - kNumNonrefProperties, channel.w); + JXL_ASSIGN_OR_RETURN( + Channel references, + Channel::Create(properties.size() - kNumNonrefProperties, channel.w)); weighted::State wp_state(wp_header, channel.w, channel.h); tree_samples.PrepareForSamples(pixel_fraction * channel.h * channel.w + 64); const bool multiple_predictors = tree_samples.NumPredictors() != 1; @@ -198,6 +189,7 @@ void GatherTreeData(const Image &image, pixel_type chan, size_t group_id, } } } + return true; } Tree PredefinedTree(ModularOptions::TreeKind tree_kind, size_t total_pixels) { @@ -316,7 +308,9 @@ Status EncodeModularChannelMAANS(const Image &image, pixel_type chan, JXL_ASSERT(channel.w != 0 && channel.h != 0); Image3F predictor_img; - if (kWantDebug) predictor_img = Image3F(channel.w, channel.h); + if (kWantDebug) { + JXL_ASSIGN_OR_RETURN(predictor_img, Image3F::Create(channel.w, channel.h)); + } JXL_DEBUG_V(6, "Encoding %" PRIuS "x%" PRIuS @@ -325,8 +319,9 @@ Status EncodeModularChannelMAANS(const Image &image, pixel_type chan, channel.w, channel.h, chan, channel.hshift, channel.vshift); std::array static_props = { - {chan, (int)group_id}}; - bool use_wp, is_wp_only; + {chan, static_cast(group_id)}}; + bool use_wp; + bool is_wp_only; bool is_gradient_only; size_t num_props; FlatTree tree = FilterTree(global_tree, static_props, &num_props, &use_wp, @@ -439,7 +434,8 @@ Status EncodeModularChannelMAANS(const Image &image, pixel_type chan, FillImage(static_cast(PredictorColor(tree[0].predictor)[c]), &predictor_img.Plane(c)); } - uint32_t mul_shift = FloorLog2Nonzero((uint32_t)tree[0].multiplier); + uint32_t mul_shift = + FloorLog2Nonzero(static_cast(tree[0].multiplier)); const intptr_t onerow = channel.plane.PixelsPerRow(); for (size_t y = 0; y < channel.h; y++) { const pixel_type *JXL_RESTRICT r = channel.Row(y); @@ -454,7 +450,9 @@ Status EncodeModularChannelMAANS(const Image &image, pixel_type chan, } else if (!use_wp && !skip_encoder_fast_path) { const intptr_t onerow = channel.plane.PixelsPerRow(); - Channel references(properties.size() - kNumNonrefProperties, channel.w); + JXL_ASSIGN_OR_RETURN( + Channel references, + Channel::Create(properties.size() - kNumNonrefProperties, channel.w)); for (size_t y = 0; y < channel.h; y++) { const pixel_type *JXL_RESTRICT p = channel.Row(y); PrecomputeReferences(channel, y, image, chan, &references); @@ -481,7 +479,9 @@ Status EncodeModularChannelMAANS(const Image &image, pixel_type chan, } } else { const intptr_t onerow = channel.plane.PixelsPerRow(); - Channel references(properties.size() - kNumNonrefProperties, channel.w); + JXL_ASSIGN_OR_RETURN( + Channel references, + Channel::Create(properties.size() - kNumNonrefProperties, channel.w)); weighted::State wp_state(wp_header, channel.w, channel.h); for (size_t y = 0; y < channel.h; y++) { const pixel_type *JXL_RESTRICT p = channel.Row(y); @@ -556,8 +556,20 @@ Status ModularEncode(const Image &image, const ModularOptions &options, TreeSamples tree_samples_storage; size_t total_pixels_storage = 0; if (!total_pixels) total_pixels = &total_pixels_storage; + if (*total_pixels == 0) { + for (size_t i = 0; i < nb_channels; i++) { + if (i >= image.nb_meta_channels && + (image.channel[i].w > options.max_chan_size || + image.channel[i].h > options.max_chan_size)) { + break; + } + *total_pixels += image.channel[i].w * image.channel[i].h; + } + *total_pixels = std::max(*total_pixels, 1); + } // If there's no tree, compute one (or gather data to). - if (tree == nullptr) { + if (tree == nullptr && + options.tree_kind == ModularOptions::TreeKind::kLearn) { bool gather_data = tree_samples != nullptr; if (tree_samples == nullptr) { JXL_RETURN_IF_ERROR(tree_samples_storage.SetPredictor( @@ -586,9 +598,9 @@ Status ModularEncode(const Image &image, const ModularOptions &options, image.channel[i].h > options.max_chan_size)) { break; } - GatherTreeData(image, i, group_id, header->wp_header, options, - gather_data ? *tree_samples : tree_samples_storage, - total_pixels); + JXL_RETURN_IF_ERROR(GatherTreeData( + image, i, group_id, header->wp_header, options, + gather_data ? *tree_samples : tree_samples_storage, total_pixels)); } if (gather_data) return true; } @@ -609,10 +621,10 @@ Status ModularEncode(const Image &image, const ModularOptions &options, ? LearnTree(std::move(tree_samples_storage), *total_pixels, options) : PredefinedTree(options.tree_kind, *total_pixels); tree = &tree_storage; - tokens = &tokens_storage[0]; + tokens = tokens_storage.data(); Tree decoded_tree; - TokenizeTree(*tree, &tree_tokens[0], &decoded_tree); + TokenizeTree(*tree, tree_tokens.data(), &decoded_tree); JXL_ASSERT(tree->size() == decoded_tree.size()); tree_storage = std::move(decoded_tree); @@ -622,9 +634,9 @@ Status ModularEncode(const Image &image, const ModularOptions &options, } */ // Write tree - BuildAndEncodeHistograms(HistogramParams(), kNumTreeContexts, tree_tokens, - &code, &context_map, writer, kLayerModularTree, - aux_out); + BuildAndEncodeHistograms(options.histogram_params, kNumTreeContexts, + tree_tokens, &code, &context_map, writer, + kLayerModularTree, aux_out); WriteTokens(tree_tokens[0], code, context_map, 0, writer, kLayerModularTree, aux_out); } @@ -669,7 +681,7 @@ Status ModularEncode(const Image &image, const ModularOptions &options, if (!header->use_global_tree) { EntropyEncodingData code; std::vector context_map; - HistogramParams histo_params; + HistogramParams histo_params = options.histogram_params; histo_params.image_widths.push_back(image_width); BuildAndEncodeHistograms(histo_params, (tree->size() + 1) / 2, tokens_storage, &code, &context_map, writer, layer, @@ -691,7 +703,7 @@ Status ModularGenericCompress(Image &image, const ModularOptions &opts, if (image.w == 0 || image.h == 0) return true; ModularOptions options = opts; // Make a copy to modify it. - if (options.predictor == static_cast(-1)) { + if (options.predictor == kUndefinedPredictor) { options.predictor = Predictor::Gradient; } diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc index ef72b2477b..de629ad038 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_ma.cc @@ -109,8 +109,8 @@ IntersectionType BoxIntersects(StaticPropRange needle, StaticPropRange haystack, void SplitTreeSamples(TreeSamples &tree_samples, size_t begin, size_t pos, size_t end, size_t prop) { auto cmp = [&](size_t a, size_t b) { - return int32_t(tree_samples.Property(prop, a)) - - int32_t(tree_samples.Property(prop, b)); + return static_cast(tree_samples.Property(prop, a)) - + static_cast(tree_samples.Property(prop, b)); }; Rng rng(0); while (end > begin + 1) { @@ -243,7 +243,8 @@ void FindBestSplit(TreeSamples &tree_samples, float threshold, // properties. We do this even if the current node is not a leaf, to // minimize the number of nodes in the resulting tree. for (size_t i = 0; i < mul_info.size(); i++) { - uint32_t axis, val; + uint32_t axis; + uint32_t val; IntersectionType t = BoxIntersects(static_prop_range, mul_info[i].range, axis, val); if (t == IntersectionType::kNone) continue; @@ -696,7 +697,11 @@ void TreeSamples::Swap(size_t a, size_t b) { } void TreeSamples::ThreeShuffle(size_t a, size_t b, size_t c) { - if (b == c) return Swap(a, b); + if (b == c) { + Swap(a, b); + return; + } + for (auto &r : residuals) { auto tmp = r[a]; r[a] = r[c]; @@ -966,7 +971,7 @@ void CollectPixelSamples(const Image &image, const ModularOptions &options, const pixel_type *row = image.channel[channel_ids[i]].Row(y); pixel_samples.push_back(row[x]); size_t xp = x == 0 ? 1 : x - 1; - diff_samples.push_back((int64_t)row[x] - row[xp]); + diff_samples.push_back(static_cast(row[x]) - row[xp]); } } diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc index a6abdcfc91..bb690b74ba 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/encoding.cc @@ -14,6 +14,8 @@ #include "lib/jxl/base/scope_guard.h" #include "lib/jxl/dec_ans.h" #include "lib/jxl/dec_bit_reader.h" +#include "lib/jxl/frame_dimensions.h" +#include "lib/jxl/image_ops.h" #include "lib/jxl/modular/encoding/context_predict.h" #include "lib/jxl/modular/options.h" #include "lib/jxl/pack_signed.h" @@ -141,7 +143,7 @@ Status DecodeModularChannelMAANS(BitReader *br, ANSSymbolReader *reader, Channel &channel = image->channel[chan]; std::array static_props = { - {chan, (int)group_id}}; + {chan, static_cast(group_id)}}; // TODO(veluca): filter the tree according to static_props. // zero pixel channel? could happen @@ -376,7 +378,9 @@ Status DecodeModularChannelMAANS(BitReader *br, ANSSymbolReader *reader, MATreeLookup tree_lookup(tree); Properties properties = Properties(num_props); const intptr_t onerow = channel.plane.PixelsPerRow(); - Channel references(properties.size() - kNumNonrefProperties, channel.w); + JXL_ASSIGN_OR_RETURN( + Channel references, + Channel::Create(properties.size() - kNumNonrefProperties, channel.w)); for (size_t y = 0; y < channel.h; y++) { pixel_type *JXL_RESTRICT p = channel.Row(y); PrecomputeReferences(channel, y, *image, chan, &references); @@ -422,7 +426,9 @@ Status DecodeModularChannelMAANS(BitReader *br, ANSSymbolReader *reader, MATreeLookup tree_lookup(tree); Properties properties = Properties(num_props); const intptr_t onerow = channel.plane.PixelsPerRow(); - Channel references(properties.size() - kNumNonrefProperties, channel.w); + JXL_ASSIGN_OR_RETURN( + Channel references, + Channel::Create(properties.size() - kNumNonrefProperties, channel.w)); weighted::State wp_state(wp_header, channel.w, channel.h); for (size_t y = 0; y < channel.h; y++) { pixel_type *JXL_RESTRICT p = channel.Row(y); diff --git a/third_party/jpeg-xl/lib/jxl/modular/modular_image.cc b/third_party/jpeg-xl/lib/jxl/modular/modular_image.cc index 746d7c87fd..32a5531080 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/modular_image.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/modular_image.cc @@ -8,6 +8,7 @@ #include #include "lib/jxl/base/status.h" +#include "lib/jxl/image_ops.h" #include "lib/jxl/modular/transform/transform.h" namespace jxl { @@ -28,9 +29,18 @@ void Image::undo_transforms(const weighted::Header &wp_header, } } -Image::Image(size_t iw, size_t ih, int bitdepth, int nb_chans) - : w(iw), h(ih), bitdepth(bitdepth), nb_meta_channels(0), error(false) { - for (int i = 0; i < nb_chans; i++) channel.emplace_back(Channel(iw, ih)); +Image::Image(size_t iw, size_t ih, int bitdepth) + : w(iw), h(ih), bitdepth(bitdepth), nb_meta_channels(0), error(false) {} + +StatusOr Image::Create(size_t iw, size_t ih, int bitdepth, + int nb_chans) { + Image result(iw, ih, bitdepth); + for (int i = 0; i < nb_chans; i++) { + StatusOr channel_or = Channel::Create(iw, ih); + JXL_RETURN_IF_ERROR(channel_or.status()); + result.channel.emplace_back(std::move(channel_or).value()); + } + return result; } Image::Image() : w(0), h(0), bitdepth(8), nb_meta_channels(0), error(true) {} @@ -46,17 +56,18 @@ Image &Image::operator=(Image &&other) noexcept { return *this; } -Image Image::clone() { - Image c(w, h, bitdepth, 0); - c.nb_meta_channels = nb_meta_channels; - c.error = error; - c.transform = transform; - for (Channel &ch : channel) { - Channel a(ch.w, ch.h, ch.hshift, ch.vshift); +StatusOr Image::Clone(const Image &that) { + Image clone(that.w, that.h, that.bitdepth); + clone.nb_meta_channels = that.nb_meta_channels; + clone.error = that.error; + clone.transform = that.transform; + for (const Channel &ch : that.channel) { + JXL_ASSIGN_OR_RETURN(Channel a, + Channel::Create(ch.w, ch.h, ch.hshift, ch.vshift)); CopyImageTo(ch.plane, &a.plane); - c.channel.push_back(std::move(a)); + clone.channel.push_back(std::move(a)); } - return c; + return clone; } #if JXL_DEBUG_V_LEVEL >= 1 diff --git a/third_party/jpeg-xl/lib/jxl/modular/modular_image.h b/third_party/jpeg-xl/lib/jxl/modular/modular_image.h index 56e80d823a..eb95b1cb6c 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/modular_image.h +++ b/third_party/jpeg-xl/lib/jxl/modular/modular_image.h @@ -18,7 +18,6 @@ #include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" #include "lib/jxl/image.h" -#include "lib/jxl/image_ops.h" namespace jxl { @@ -36,12 +35,16 @@ class Channel { jxl::Plane plane; size_t w, h; int hshift, vshift; // w ~= image.w >> hshift; h ~= image.h >> vshift - Channel(size_t iw, size_t ih, int hsh = 0, int vsh = 0) - : plane(iw, ih), w(iw), h(ih), hshift(hsh), vshift(vsh) {} - Channel(const Channel& other) = delete; Channel& operator=(const Channel& other) = delete; + static StatusOr Create(size_t iw, size_t ih, int hsh = 0, + int vsh = 0) { + JXL_ASSIGN_OR_RETURN(Plane plane, + Plane::Create(iw, ih)); + return Channel(std::move(plane), iw, ih, hsh, vsh); + } + // Move assignment Channel& operator=(Channel&& other) noexcept { w = other.w; @@ -55,21 +58,25 @@ class Channel { // Move constructor Channel(Channel&& other) noexcept = default; - void shrink() { - if (plane.xsize() == w && plane.ysize() == h) return; - jxl::Plane resizedplane(w, h); - plane = std::move(resizedplane); + Status shrink() { + if (plane.xsize() == w && plane.ysize() == h) return true; + JXL_ASSIGN_OR_RETURN(plane, Plane::Create(w, h)); + return true; } - void shrink(int nw, int nh) { + Status shrink(int nw, int nh) { w = nw; h = nh; - shrink(); + return shrink(); } JXL_INLINE pixel_type* Row(const size_t y) { return plane.Row(y); } JXL_INLINE const pixel_type* Row(const size_t y) const { return plane.Row(y); } + + private: + Channel(jxl::Plane&& p, size_t iw, size_t ih, int hsh, int vsh) + : plane(std::move(p)), w(iw), h(ih), hshift(hsh), vshift(vsh) {} }; class Transform; @@ -88,7 +95,6 @@ class Image { size_t nb_meta_channels; // first few channels might contain palette(s) bool error; // true if a fatal error occurred, false otherwise - Image(size_t iw, size_t ih, int bitdepth, int nb_chans); Image(); Image(const Image& other) = delete; @@ -97,6 +103,9 @@ class Image { Image& operator=(Image&& other) noexcept; Image(Image&& other) noexcept = default; + static StatusOr Create(size_t iw, size_t ih, int bitdepth, + int nb_chans); + bool empty() const { for (const auto& ch : channel) { if (ch.w && ch.h) return false; @@ -104,12 +113,15 @@ class Image { return true; } - Image clone(); + static StatusOr Clone(const Image& that); void undo_transforms(const weighted::Header& wp_header, jxl::ThreadPool* pool = nullptr); std::string DebugString() const; + + private: + Image(size_t iw, size_t ih, int bitdepth); }; } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/modular/options.h b/third_party/jpeg-xl/lib/jxl/modular/options.h index ce6596b912..6613b513de 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/options.h +++ b/third_party/jpeg-xl/lib/jxl/modular/options.h @@ -11,6 +11,8 @@ #include #include +#include "lib/jxl/enc_ans_params.h" + namespace jxl { using PropertyVal = int32_t; @@ -37,6 +39,8 @@ enum class Predictor : uint32_t { 15, // Find the best decision tree for predictors/predictor per row }; +constexpr Predictor kUndefinedPredictor = static_cast(~0u); + constexpr size_t kNumModularPredictors = static_cast(Predictor::Average4) + 1; constexpr size_t kNumModularEncoderPredictors = @@ -80,7 +84,7 @@ struct ModularOptions { size_t max_property_values = 32; // Predictor to use for each channel. - Predictor predictor = static_cast(-1); + Predictor predictor = kUndefinedPredictor; int wp_mode = 0; @@ -108,6 +112,8 @@ struct ModularOptions { }; TreeKind tree_kind = TreeKind::kLearn; + HistogramParams histogram_params; + // Ignore the image and just pretend all tokens are zeroes bool zero_tokens = false; }; diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc b/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc index f5172aa126..24c64f5aad 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/transform/enc_palette.cc @@ -10,8 +10,8 @@ #include #include "lib/jxl/base/common.h" -#include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/status.h" +#include "lib/jxl/image_ops.h" #include "lib/jxl/modular/encoding/context_predict.h" #include "lib/jxl/modular/modular_image.h" #include "lib/jxl/modular/transform/enc_transform.h" @@ -34,7 +34,8 @@ float ColorDistance(const std::vector &JXL_RESTRICT a, if (a.size() >= 3) { ave3 = (a[0] + b[0] + a[1] + b[1] + a[2] + b[2]) * (1.21f / 3.0f); } - float sum_a = 0, sum_b = 0; + float sum_a = 0; + float sum_b = 0; for (size_t c = 0; c < a.size(); ++c) { const float difference = static_cast(a[c]) - static_cast(b[c]); @@ -132,7 +133,8 @@ struct PaletteIterationData { delta_frequency.first[1], delta_frequency.first[2]}; float delta_distance = - sqrt(palette_internal::ColorDistance({0, 0, 0}, current_delta)) + 1; + std::sqrt(palette_internal::ColorDistance({0, 0, 0}, current_delta)) + + 1; delta_frequency.second *= delta_distance * delta_distance_multiplier; } @@ -174,7 +176,8 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, // Channel palette special case if (nb_colors == 0) return false; std::vector lookup; - pixel_type minval, maxval; + pixel_type minval; + pixel_type maxval; compute_minmax(input.channel[begin_c], &minval, &maxval); size_t lookup_table_size = static_cast(maxval) - static_cast(minval) + 1; @@ -189,12 +192,12 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, const bool new_color = chpalette.insert(p[x]).second; if (new_color) { idx++; - if (idx > (int)nb_colors) return false; + if (idx > static_cast(nb_colors)) return false; } } } JXL_DEBUG_V(6, "Channel %i uses only %i colors.", begin_c, idx); - Channel pch(idx, 1); + JXL_ASSIGN_OR_RETURN(Channel pch, Channel::Create(idx, 1)); pch.hshift = -1; pch.vshift = -1; nb_colors = idx; @@ -206,9 +209,12 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, for (size_t y = 0; y < h; y++) { pixel_type *p = input.channel[begin_c].Row(y); for (size_t x = 0; x < w; x++) { - for (idx = 0; p[x] != p_palette[idx] && idx < (int)nb_colors; idx++) { + for (idx = 0; + p[x] != p_palette[idx] && idx < static_cast(nb_colors); + idx++) { + // no-op } - JXL_DASSERT(idx < (int)nb_colors); + JXL_DASSERT(idx < static_cast(nb_colors)); p[x] = idx; } } @@ -226,12 +232,12 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, if (lookup[p[x] - minval] == 0) { lookup[p[x] - minval] = 1; idx++; - if (idx > (int)nb_colors) return false; + if (idx > static_cast(nb_colors)) return false; } } } JXL_DEBUG_V(6, "Channel %i uses only %i colors.", begin_c, idx); - Channel pch(idx, 1); + JXL_ASSIGN_OR_RETURN(Channel pch, Channel::Create(idx, 1)); pch.hshift = -1; pch.vshift = -1; nb_colors = idx; @@ -256,7 +262,8 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, Image quantized_input; if (lossy) { - quantized_input = Image(w, h, input.bitdepth, nb); + JXL_ASSIGN_OR_RETURN(quantized_input, + Image::Create(w, h, input.bitdepth, nb)); for (size_t c = 0; c < nb; c++) { CopyImageTo(input.channel[begin_c + c].plane, &quantized_input.channel[c].plane); @@ -337,7 +344,7 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, JXL_DEBUG_V(6, "Channels %i-%i can be represented using a %i-color palette.", begin_c, end_c, nb_colors); - Channel pch(nb_colors, nb); + JXL_ASSIGN_OR_RETURN(Channel pch, Channel::Create(nb_colors, nb)); pch.hshift = -1; pch.vshift = -1; pixel_type *JXL_RESTRICT p_palette = pch.Row(0); @@ -361,7 +368,8 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, std::sort(candidate_palette_imageorder.begin(), candidate_palette_imageorder.end(), [](std::vector ap, std::vector bp) { - float ay, by; + float ay; + float by; ay = (0.299f * ap[0] + 0.587f * ap[1] + 0.114f * ap[2] + 0.1f); if (ap.size() > 3) ay *= 1.f + ap[3]; by = (0.299f * bp[0] + 0.587f * bp[1] + 0.114f * bp[2] + 0.1f); @@ -420,7 +428,7 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, for (int diffusion_index = 0; diffusion_index < 2; ++diffusion_index) { for (size_t c = 0; c < nb; c++) { color_with_error[c] = - p_in[c][x] + palette_iteration_data.final_run * + p_in[c][x] + (palette_iteration_data.final_run ? 1 : 0) * kDiffusionMultiplier[diffusion_index] * error_row[0][c][x + 2]; color[c] = Clamp1(lroundf(color_with_error[c]), 0l, @@ -503,7 +511,7 @@ Status FwdPaletteIteration(Image &input, uint32_t begin_c, uint32_t end_c, float local_error = color_with_error[c] - best_val[c]; len_error += local_error * local_error; } - len_error = sqrt(len_error); + len_error = std::sqrt(len_error); float modulate = 1.0; int len_limit = 38 << std::max(0, bit_depth - 8); if (len_error > len_limit) { diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/enc_squeeze.cc b/third_party/jpeg-xl/lib/jxl/modular/transform/enc_squeeze.cc index 489f72a90d..0d924c0ace 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/transform/enc_squeeze.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/transform/enc_squeeze.cc @@ -14,15 +14,20 @@ namespace jxl { -void FwdHSqueeze(Image &input, int c, int rc) { +#define AVERAGE(X, Y) (((X) + (Y) + (((X) > (Y)) ? 1 : 0)) >> 1) + +Status FwdHSqueeze(Image &input, int c, int rc) { const Channel &chin = input.channel[c]; JXL_DEBUG_V(4, "Doing horizontal squeeze of channel %i to new channel %i", c, rc); - Channel chout((chin.w + 1) / 2, chin.h, chin.hshift + 1, chin.vshift); - Channel chout_residual(chin.w - chout.w, chout.h, chin.hshift + 1, - chin.vshift); + JXL_ASSIGN_OR_RETURN( + Channel chout, + Channel::Create((chin.w + 1) / 2, chin.h, chin.hshift + 1, chin.vshift)); + JXL_ASSIGN_OR_RETURN( + Channel chout_residual, + Channel::Create(chin.w - chout.w, chout.h, chin.hshift + 1, chin.vshift)); for (size_t y = 0; y < chout.h; y++) { const pixel_type *JXL_RESTRICT p_in = chin.Row(y); @@ -31,18 +36,19 @@ void FwdHSqueeze(Image &input, int c, int rc) { for (size_t x = 0; x < chout_residual.w; x++) { pixel_type A = p_in[x * 2]; pixel_type B = p_in[x * 2 + 1]; - pixel_type avg = (A + B + (A > B)) >> 1; + pixel_type avg = AVERAGE(A, B); p_out[x] = avg; pixel_type diff = A - B; pixel_type next_avg = avg; if (x + 1 < chout_residual.w) { - next_avg = (p_in[x * 2 + 2] + p_in[x * 2 + 3] + - (p_in[x * 2 + 2] > p_in[x * 2 + 3])) >> - 1; // which will be chout.value(y,x+1) - } else if (chin.w & 1) + pixel_type C = p_in[x * 2 + 2]; + pixel_type D = p_in[x * 2 + 3]; + next_avg = AVERAGE(C, D); // which will be chout.value(y,x+1) + } else if (chin.w & 1) { next_avg = p_in[x * 2 + 2]; + } pixel_type left = (x > 0 ? p_in[x * 2 - 1] : avg); pixel_type tendency = SmoothTendency(left, avg, next_avg); @@ -55,17 +61,21 @@ void FwdHSqueeze(Image &input, int c, int rc) { } input.channel[c] = std::move(chout); input.channel.insert(input.channel.begin() + rc, std::move(chout_residual)); + return true; } -void FwdVSqueeze(Image &input, int c, int rc) { +Status FwdVSqueeze(Image &input, int c, int rc) { const Channel &chin = input.channel[c]; JXL_DEBUG_V(4, "Doing vertical squeeze of channel %i to new channel %i", c, rc); - Channel chout(chin.w, (chin.h + 1) / 2, chin.hshift, chin.vshift + 1); - Channel chout_residual(chin.w, chin.h - chout.h, chin.hshift, - chin.vshift + 1); + JXL_ASSIGN_OR_RETURN( + Channel chout, + Channel::Create(chin.w, (chin.h + 1) / 2, chin.hshift, chin.vshift + 1)); + JXL_ASSIGN_OR_RETURN( + Channel chout_residual, + Channel::Create(chin.w, chin.h - chout.h, chin.hshift, chin.vshift + 1)); intptr_t onerow_in = chin.plane.PixelsPerRow(); for (size_t y = 0; y < chout_residual.h; y++) { const pixel_type *JXL_RESTRICT p_in = chin.Row(y * 2); @@ -74,16 +84,16 @@ void FwdVSqueeze(Image &input, int c, int rc) { for (size_t x = 0; x < chout.w; x++) { pixel_type A = p_in[x]; pixel_type B = p_in[x + onerow_in]; - pixel_type avg = (A + B + (A > B)) >> 1; + pixel_type avg = AVERAGE(A, B); p_out[x] = avg; pixel_type diff = A - B; pixel_type next_avg = avg; if (y + 1 < chout_residual.h) { - next_avg = (p_in[x + 2 * onerow_in] + p_in[x + 3 * onerow_in] + - (p_in[x + 2 * onerow_in] > p_in[x + 3 * onerow_in])) >> - 1; // which will be chout.value(y+1,x) + pixel_type C = p_in[x + 2 * onerow_in]; + pixel_type D = p_in[x + 3 * onerow_in]; + next_avg = AVERAGE(C, D); // which will be chout.value(y+1,x) } else if (chin.h & 1) { next_avg = p_in[x + 2 * onerow_in]; } @@ -104,6 +114,7 @@ void FwdVSqueeze(Image &input, int c, int rc) { } input.channel[c] = std::move(chout); input.channel.insert(input.channel.begin() + rc, std::move(chout_residual)); + return true; } Status FwdSqueeze(Image &input, std::vector parameters, @@ -128,9 +139,9 @@ Status FwdSqueeze(Image &input, std::vector parameters, } for (uint32_t c = beginc; c <= endc; c++) { if (horizontal) { - FwdHSqueeze(input, c, offset + c - beginc); + JXL_RETURN_IF_ERROR(FwdHSqueeze(input, c, offset + c - beginc)); } else { - FwdVSqueeze(input, c, offset + c - beginc); + JXL_RETURN_IF_ERROR(FwdVSqueeze(input, c, offset + c - beginc)); } } } diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc index bffbacf160..1ab499ccf6 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.cc @@ -23,9 +23,11 @@ Status InvPalette(Image &input, uint32_t begin_c, uint32_t nb_colors, size_t h = input.channel[c0].h; if (nb < 1) return JXL_FAILURE("Corrupted transforms"); for (int i = 1; i < nb; i++) { - input.channel.insert( - input.channel.begin() + c0 + 1, - Channel(w, h, input.channel[c0].hshift, input.channel[c0].vshift)); + StatusOr channel_or = Channel::Create( + w, h, input.channel[c0].hshift, input.channel[c0].vshift); + JXL_RETURN_IF_ERROR(channel_or.status()); + input.channel.insert(input.channel.begin() + c0 + 1, + std::move(channel_or).value()); } const Channel &palette = input.channel[0]; const pixel_type *JXL_RESTRICT p_palette = input.channel[0].Row(0); @@ -44,7 +46,8 @@ Status InvPalette(Image &input, uint32_t begin_c, uint32_t nb_colors, const size_t y = task; pixel_type *p = input.channel[c0].Row(y); for (size_t x = 0; x < w; x++) { - const int index = Clamp1(p[x], 0, (pixel_type)palette.w - 1); + const int index = + Clamp1(p[x], 0, static_cast(palette.w) - 1); p[x] = palette_internal::GetPaletteValue( p_palette, index, /*c=*/0, /*palette_size=*/palette.w, @@ -75,8 +78,10 @@ Status InvPalette(Image &input, uint32_t begin_c, uint32_t nb_colors, } } else { // Parallelized per channel. - ImageI indices = std::move(input.channel[c0].plane); - input.channel[c0].plane = ImageI(indices.xsize(), indices.ysize()); + ImageI indices; + ImageI &plane = input.channel[c0].plane; + JXL_ASSIGN_OR_RETURN(indices, ImageI::Create(plane.xsize(), plane.ysize())); + plane.Swap(indices); if (predictor == Predictor::Weighted) { JXL_RETURN_IF_ERROR(RunOnPool( pool, 0, nb, ThreadPool::NoInit, @@ -167,7 +172,7 @@ Status MetaPalette(Image &input, uint32_t begin_c, uint32_t end_c, } input.channel.erase(input.channel.begin() + begin_c + 1, input.channel.begin() + end_c + 1); - Channel pch(nb_colors + nb_deltas, nb); + JXL_ASSIGN_OR_RETURN(Channel pch, Channel::Create(nb_colors + nb_deltas, nb)); pch.hshift = -1; pch.vshift = -1; input.channel.insert(input.channel.begin(), std::move(pch)); diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h index 279ef04568..e0405a2162 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h +++ b/third_party/jpeg-xl/lib/jxl/modular/transform/palette.h @@ -101,6 +101,7 @@ GetPaletteValue(const pixel_type *const palette, int index, const size_t c, // index >= kLargeCube ** 3 ? switch (c) { case 0: + default: break; case 1: index /= kLargeCube; diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.cc b/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.cc index e9892ea48f..580829741a 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.cc @@ -113,7 +113,9 @@ Status InvHSqueeze(Image &input, uint32_t c, uint32_t rc, ThreadPool *pool) { } // Note: chin.w >= chin_residual.w and at most 1 different. - Channel chout(chin.w + chin_residual.w, chin.h, chin.hshift - 1, chin.vshift); + JXL_ASSIGN_OR_RETURN(Channel chout, + Channel::Create(chin.w + chin_residual.w, chin.h, + chin.hshift - 1, chin.vshift)); JXL_DEBUG_V(4, "Undoing horizontal squeeze of channel %i using residuals in " "channel %i (going from width %" PRIuS " to %" PRIuS ")", @@ -222,7 +224,9 @@ Status InvVSqueeze(Image &input, uint32_t c, uint32_t rc, ThreadPool *pool) { } // Note: chin.h >= chin_residual.h and at most 1 different. - Channel chout(chin.w, chin.h + chin_residual.h, chin.hshift, chin.vshift - 1); + JXL_ASSIGN_OR_RETURN(Channel chout, + Channel::Create(chin.w, chin.h + chin_residual.h, + chin.hshift, chin.vshift - 1)); JXL_DEBUG_V( 4, "Undoing vertical squeeze of channel %i using residuals in channel " @@ -238,7 +242,8 @@ Status InvVSqueeze(Image &input, uint32_t c, uint32_t rc, ThreadPool *pool) { static constexpr const int kColsPerThread = 64; const auto unsqueeze_slice = [&](const uint32_t task, size_t /* thread */) { const size_t x0 = task * kColsPerThread; - const size_t x1 = std::min((size_t)(task + 1) * kColsPerThread, chin.w); + const size_t x1 = + std::min(static_cast(task + 1) * kColsPerThread, chin.w); const size_t w = x1 - x0; // We only iterate up to std::min(chin_residual.h, chin.h) which is // always chin_residual.h. @@ -289,7 +294,7 @@ Status InvVSqueeze(Image &input, uint32_t c, uint32_t rc, ThreadPool *pool) { return true; } -Status InvSqueeze(Image &input, std::vector parameters, +Status InvSqueeze(Image &input, const std::vector ¶meters, ThreadPool *pool) { for (int i = parameters.size() - 1; i >= 0; i--) { JXL_RETURN_IF_ERROR( @@ -340,7 +345,7 @@ HWY_AFTER_NAMESPACE(); namespace jxl { HWY_EXPORT(InvSqueeze); -Status InvSqueeze(Image &input, std::vector parameters, +Status InvSqueeze(Image &input, const std::vector ¶meters, ThreadPool *pool) { return HWY_DYNAMIC_DISPATCH(InvSqueeze)(input, parameters, pool); } @@ -459,8 +464,8 @@ Status MetaSqueeze(Image &image, std::vector *parameters) { if (image.channel[c].vshift >= 0) image.channel[c].vshift++; h = h - (h + 1) / 2; } - image.channel[c].shrink(); - Channel placeholder(w, h); + JXL_RETURN_IF_ERROR(image.channel[c].shrink()); + JXL_ASSIGN_OR_RETURN(Channel placeholder, Channel::Create(w, h)); placeholder.hshift = image.channel[c].hshift; placeholder.vshift = image.channel[c].vshift; diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h b/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h index 305a0ca3ec..bbd16c59c0 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h +++ b/third_party/jpeg-xl/lib/jxl/modular/transform/squeeze.h @@ -81,7 +81,7 @@ Status CheckMetaSqueezeParams(const SqueezeParams ¶meter, int num_channels); Status MetaSqueeze(Image &image, std::vector *parameters); -Status InvSqueeze(Image &input, std::vector parameters, +Status InvSqueeze(Image &input, const std::vector ¶meters, ThreadPool *pool); } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h b/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h index d5d3259f7a..b68861706f 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h +++ b/third_party/jpeg-xl/lib/jxl/modular/transform/transform.h @@ -77,11 +77,13 @@ class Transform : public Fields { Transform() : Transform(TransformId::kInvalid) {} Status VisitFields(Visitor *JXL_RESTRICT visitor) override { - JXL_QUIET_RETURN_IF_ERROR(visitor->U32( - Val((uint32_t)TransformId::kRCT), Val((uint32_t)TransformId::kPalette), - Val((uint32_t)TransformId::kSqueeze), - Val((uint32_t)TransformId::kInvalid), (uint32_t)TransformId::kRCT, - reinterpret_cast(&id))); + JXL_QUIET_RETURN_IF_ERROR( + visitor->U32(Val(static_cast(TransformId::kRCT)), + Val(static_cast(TransformId::kPalette)), + Val(static_cast(TransformId::kSqueeze)), + Val(static_cast(TransformId::kInvalid)), + static_cast(TransformId::kRCT), + reinterpret_cast(&id))); if (id == TransformId::kInvalid) { return JXL_FAILURE("Invalid transform ID"); } @@ -109,7 +111,7 @@ class Transform : public Fields { visitor->U32(Val(0), BitsOffset(8, 1), BitsOffset(10, 257), BitsOffset(16, 1281), 0, &nb_deltas)); JXL_QUIET_RETURN_IF_ERROR( - visitor->Bits(4, (uint32_t)Predictor::Zero, + visitor->Bits(4, static_cast(Predictor::Zero), reinterpret_cast(&predictor))); if (predictor >= Predictor::Best) { return JXL_FAILURE("Invalid predictor"); diff --git a/third_party/jpeg-xl/lib/jxl/modular_test.cc b/third_party/jpeg-xl/lib/jxl/modular_test.cc index 689063ce95..bd1a947493 100644 --- a/third_party/jpeg-xl/lib/jxl/modular_test.cc +++ b/third_party/jpeg-xl/lib/jxl/modular_test.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include "lib/jxl/dec_bit_reader.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_bit_writer.h" -#include "lib/jxl/enc_butteraugli_comparator.h" #include "lib/jxl/enc_fields.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/enc_toc.h" @@ -54,6 +54,7 @@ namespace jxl { namespace { +using test::ButteraugliDistance; using test::ReadTestData; using test::Roundtrip; using test::TestImage; @@ -130,10 +131,11 @@ TEST(ModularTest, RoundtripLossyDeltaPalette) { size_t compressed_size; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io_out, _, &compressed_size)); EXPECT_LE(compressed_size, 6800u); - EXPECT_THAT(ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(1.5)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 1.5); } TEST(ModularTest, RoundtripLossyDeltaPaletteWP) { const std::vector orig = @@ -153,10 +155,11 @@ TEST(ModularTest, RoundtripLossyDeltaPaletteWP) { size_t compressed_size; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io_out, _, &compressed_size)); EXPECT_LE(compressed_size, 7000u); - EXPECT_THAT(ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(10.1)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 10.1); } TEST(ModularTest, RoundtripLossy) { @@ -175,10 +178,11 @@ TEST(ModularTest, RoundtripLossy) { size_t compressed_size; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io_out, _, &compressed_size)); EXPECT_LE(compressed_size, 30000u); - EXPECT_THAT(ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(2.3)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 2.3); } TEST(ModularTest, RoundtripLossy16) { @@ -201,15 +205,17 @@ TEST(ModularTest, RoundtripLossy16) { size_t compressed_size; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io_out, _, &compressed_size)); EXPECT_LE(compressed_size, 300u); - EXPECT_THAT(ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(1.6)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io_out.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 1.6); } TEST(ModularTest, RoundtripExtraProperties) { constexpr size_t kSize = 250; - Image image(kSize, kSize, /*bitdepth=*/8, 3); + JXL_ASSIGN_OR_DIE(Image image, + Image::Create(kSize, kSize, /*bitdepth=*/8, 3)); ModularOptions options; options.max_properties = 4; options.predictor = Predictor::Zero; @@ -224,10 +230,12 @@ TEST(ModularTest, RoundtripExtraProperties) { BitWriter writer; ASSERT_TRUE(ModularGenericCompress(image, options, &writer)); writer.ZeroPadToByte(); - Image decoded(kSize, kSize, /*bitdepth=*/8, image.channel.size()); + JXL_ASSIGN_OR_DIE(Image decoded, Image::Create(kSize, kSize, /*bitdepth=*/8, + image.channel.size())); for (size_t i = 0; i < image.channel.size(); i++) { const Channel& ch = image.channel[i]; - decoded.channel[i] = Channel(ch.w, ch.h, ch.hshift, ch.vshift); + JXL_ASSIGN_OR_DIE(decoded.channel[i], + Channel::Create(ch.w, ch.h, ch.hshift, ch.vshift)); } Status status = true; { @@ -302,7 +310,7 @@ TEST_P(ModularTestParam, RoundtripLossless) { double factor = ((1lu << bitdepth) - 1lu); double ifactor = 1.0 / factor; - Image3F noise_added(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3F noise_added, Image3F::Create(xsize, ysize)); for (size_t c = 0; c < 3; c++) { for (size_t y = 0; y < ysize; y++) { @@ -313,7 +321,7 @@ TEST_P(ModularTestParam, RoundtripLossless) { float f = in[x] + generator.UniformF(0.0f, 1.f / 255.f); if (f > 1.f) f = 1.f; // quantize to the bitdepth we're testing - unsigned int u = f * factor + 0.5; + unsigned int u = static_cast(std::lround(f * factor)); out[x] = u * ifactor; } } @@ -330,7 +338,7 @@ TEST_P(ModularTestParam, RoundtripLossless) { CodecInOut io2; size_t compressed_size; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io2, _, &compressed_size)); - EXPECT_LE(compressed_size, bitdepth * xsize * ysize / 3); + EXPECT_LE(compressed_size, bitdepth * xsize * ysize / 3.0 * 1.1); EXPECT_LE(0, ComputeDistance2(io.Main(), io2.Main(), *JxlGetDefaultCms())); size_t different = 0; for (size_t c = 0; c < 3; c++) { @@ -350,7 +358,8 @@ TEST_P(ModularTestParam, RoundtripLossless) { TEST(ModularTest, RoundtripLosslessCustomFloat) { CodecInOut io; - size_t xsize = 100, ysize = 300; + size_t xsize = 100; + size_t ysize = 300; io.SetSize(xsize, ysize); io.metadata.m.bit_depth.bits_per_sample = 18; io.metadata.m.bit_depth.exponent_bits_per_sample = 6; @@ -359,7 +368,7 @@ TEST(ModularTest, RoundtripLosslessCustomFloat) { ColorEncoding color_encoding; color_encoding.Tf().SetTransferFunction(TransferFunction::kLinear); color_encoding.SetColorSpace(ColorSpace::kRGB); - Image3F testimage(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3F testimage, Image3F::Create(xsize, ysize)); float factor = 1.f / (1 << 14); for (size_t c = 0; c < 3; c++) { for (size_t y = 0; y < ysize; y++) { @@ -442,7 +451,7 @@ TEST(ModularTest, PredictorIntegerOverflow) { WriteHeaders(&writer, xsize, ysize); std::vector group_codes(1); { - BitWriter* bw = &group_codes[0]; + BitWriter* bw = group_codes.data(); BitWriter::Allotment allotment(bw, 1 << 20); WriteHistograms(bw); GroupHeader header; @@ -466,7 +475,7 @@ TEST(ModularTest, PredictorIntegerOverflow) { nullptr, &ppf)); ASSERT_EQ(1, ppf.frames.size()); const auto& img = ppf.frames[0].color; - const auto pixels = reinterpret_cast(img.pixels()); + const auto* pixels = reinterpret_cast(img.pixels()); EXPECT_EQ(-1.0f, pixels[0]); } @@ -478,7 +487,7 @@ TEST(ModularTest, UnsqueezeIntegerOverflow) { WriteHeaders(&writer, xsize, ysize); std::vector group_codes(1); { - BitWriter* bw = &group_codes[0]; + BitWriter* bw = group_codes.data(); BitWriter::Allotment allotment(bw, 1 << 20); WriteHistograms(bw); GroupHeader header; @@ -514,7 +523,7 @@ TEST(ModularTest, UnsqueezeIntegerOverflow) { nullptr, &ppf)); ASSERT_EQ(1, ppf.frames.size()); const auto& img = ppf.frames[0].color; - const auto pixels = reinterpret_cast(img.pixels()); + const float* pixels = reinterpret_cast(img.pixels()); for (size_t x = 0; x < xsize; ++x) { EXPECT_NEAR(-0.5f, pixels[x], 1e-10); EXPECT_NEAR(0.5f, pixels[xsize + x], 1e-10); diff --git a/third_party/jpeg-xl/lib/jxl/noise.h b/third_party/jpeg-xl/lib/jxl/noise.h index 585fab0d42..c588c59d33 100644 --- a/third_party/jpeg-xl/lib/jxl/noise.h +++ b/third_party/jpeg-xl/lib/jxl/noise.h @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -23,7 +24,9 @@ const float kNoisePrecision = 1 << 10; struct NoiseParams { // LUT index is an intensity of pixel / mean intensity of patch static constexpr size_t kNumNoisePoints = 8; - float lut[kNumNoisePoints]; + using Lut = std::array; + + Lut lut; void Clear() { for (float& i : lut) i = 0.f; @@ -39,7 +42,7 @@ struct NoiseParams { static inline std::pair IndexAndFrac(float x) { constexpr size_t kScaleNumerator = NoiseParams::kNumNoisePoints - 2; // TODO(user): instead of 1, this should be a proper Y range. - constexpr float kScale = kScaleNumerator / 1; + constexpr float kScale = kScaleNumerator / 1.0f; float scaled_x = std::max(0.f, x * kScale); float floor_x; float frac_x = std::modf(scaled_x, &floor_x); diff --git a/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc b/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc index f7842c32e4..b8ea839b9e 100644 --- a/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc +++ b/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc @@ -27,7 +27,7 @@ namespace { void LinearSrgbToOpsin(float rgb_r, float rgb_g, float rgb_b, float* JXL_RESTRICT xyb_x, float* JXL_RESTRICT xyb_y, float* JXL_RESTRICT xyb_b) { - Image3F linear(1, 1); + JXL_ASSIGN_OR_DIE(Image3F linear, Image3F::Create(1, 1)); linear.PlaneRow(0, 0)[0] = rgb_r; linear.PlaneRow(1, 0)[0] = rgb_g; linear.PlaneRow(2, 0)[0] = rgb_b; @@ -37,7 +37,7 @@ void LinearSrgbToOpsin(float rgb_r, float rgb_g, float rgb_b, metadata.color_encoding = ColorEncoding::LinearSRGB(); ImageBundle ib(&metadata); ib.SetFromImage(std::move(linear), metadata.color_encoding); - Image3F opsin(1, 1); + JXL_ASSIGN_OR_DIE(Image3F opsin, Image3F::Create(1, 1)); (void)ToXYB(ib, /*pool=*/nullptr, &opsin, *JxlGetDefaultCms()); *xyb_x = opsin.PlaneRow(0, 0)[0]; @@ -50,11 +50,11 @@ void LinearSrgbToOpsin(float rgb_r, float rgb_g, float rgb_b, void OpsinToLinearSrgb(float xyb_x, float xyb_y, float xyb_b, float* JXL_RESTRICT rgb_r, float* JXL_RESTRICT rgb_g, float* JXL_RESTRICT rgb_b) { - Image3F opsin(1, 1); + JXL_ASSIGN_OR_DIE(Image3F opsin, Image3F::Create(1, 1)); opsin.PlaneRow(0, 0)[0] = xyb_x; opsin.PlaneRow(1, 0)[0] = xyb_y; opsin.PlaneRow(2, 0)[0] = xyb_b; - Image3F linear(1, 1); + JXL_ASSIGN_OR_DIE(Image3F linear, Image3F::Create(1, 1)); OpsinParams opsin_params; opsin_params.Init(/*intensity_target=*/255.0f); OpsinToLinear(opsin, Rect(opsin), nullptr, &linear, opsin_params); @@ -64,9 +64,13 @@ void OpsinToLinearSrgb(float xyb_x, float xyb_y, float xyb_b, } void OpsinRoundtripTestRGB(float r, float g, float b) { - float xyb_x, xyb_y, xyb_b; + float xyb_x; + float xyb_y; + float xyb_b; LinearSrgbToOpsin(r, g, b, &xyb_x, &xyb_y, &xyb_b); - float r2, g2, b2; + float r2; + float g2; + float b2; OpsinToLinearSrgb(xyb_x, xyb_y, xyb_b, &r2, &g2, &b2); EXPECT_NEAR(r, r2, 1e-3); EXPECT_NEAR(g, g2, 1e-3); @@ -74,13 +78,13 @@ void OpsinRoundtripTestRGB(float r, float g, float b) { } TEST(OpsinImageTest, VerifyOpsinAbsorbanceInverseMatrix) { - float matrix[9]; // writable copy - for (int i = 0; i < 9; i++) { - matrix[i] = GetOpsinAbsorbanceInverseMatrix()[i]; - } + Matrix3x3 matrix; // writable copy + matrix = GetOpsinAbsorbanceInverseMatrix(); EXPECT_TRUE(Inv3x3Matrix(matrix)); - for (int i = 0; i < 9; i++) { - EXPECT_NEAR(matrix[i], jxl::cms::kOpsinAbsorbanceMatrix[i], 1e-6); + for (int j = 0; j < 3; j++) { + for (int i = 0; i < 3; i++) { + EXPECT_NEAR(matrix[j][i], jxl::cms::kOpsinAbsorbanceMatrix[j][i], 1e-6); + } } } @@ -105,7 +109,9 @@ TEST(OpsinImageTest, OpsinRoundtrip) { TEST(OpsinImageTest, VerifyZero) { // Test that black color (zero energy) is 0,0,0 in xyb. - float x, y, b; + float x; + float y; + float b; LinearSrgbToOpsin(0, 0, 0, &x, &y, &b); EXPECT_NEAR(0, x, 1e-9); EXPECT_NEAR(0, y, 1e-7); @@ -115,7 +121,9 @@ TEST(OpsinImageTest, VerifyZero) { TEST(OpsinImageTest, VerifyGray) { // Test that grayscale colors have a fixed y/b ratio and x==0. for (size_t i = 1; i < 255; i++) { - float x, y, b; + float x; + float y; + float b; LinearSrgbToOpsin(i / 255., i / 255., i / 255., &x, &y, &b); EXPECT_NEAR(0, x, 1e-6); EXPECT_NEAR(jxl::cms::kYToBRatio, b / y, 3e-5); diff --git a/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc index b8c151fbea..b8f9aa13df 100644 --- a/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc +++ b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc @@ -21,17 +21,17 @@ namespace jxl { namespace { TEST(OpsinInverseTest, LinearInverseInverts) { - Image3F linear(128, 128); + JXL_ASSIGN_OR_DIE(Image3F linear, Image3F::Create(128, 128)); RandomFillImage(&linear, 0.0f, 1.0f); CodecInOut io; io.metadata.m.SetFloat32Samples(); io.metadata.m.color_encoding = ColorEncoding::LinearSRGB(); - Image3F linear2(128, 128); + JXL_ASSIGN_OR_DIE(Image3F linear2, Image3F::Create(128, 128)); CopyImageTo(linear, &linear2); io.SetFromImage(std::move(linear2), io.metadata.m.color_encoding); ThreadPool* null_pool = nullptr; - Image3F opsin(io.xsize(), io.ysize()); + JXL_ASSIGN_OR_DIE(Image3F opsin, Image3F::Create(io.xsize(), io.ysize())); (void)ToXYB(io.Main(), null_pool, &opsin, *JxlGetDefaultCms()); OpsinParams opsin_params; @@ -42,16 +42,16 @@ TEST(OpsinInverseTest, LinearInverseInverts) { } TEST(OpsinInverseTest, YcbCrInverts) { - Image3F rgb(128, 128); + JXL_ASSIGN_OR_DIE(Image3F rgb, Image3F::Create(128, 128)); RandomFillImage(&rgb, 0.0f, 1.0f); ThreadPool* null_pool = nullptr; - Image3F ycbcr(rgb.xsize(), rgb.ysize()); + JXL_ASSIGN_OR_DIE(Image3F ycbcr, Image3F::Create(rgb.xsize(), rgb.ysize())); EXPECT_TRUE(RgbToYcbcr(rgb.Plane(0), rgb.Plane(1), rgb.Plane(2), &ycbcr.Plane(1), &ycbcr.Plane(0), &ycbcr.Plane(2), null_pool)); - Image3F rgb2(rgb.xsize(), rgb.ysize()); + JXL_ASSIGN_OR_DIE(Image3F rgb2, Image3F::Create(rgb.xsize(), rgb.ysize())); YcbcrToRgb(ycbcr, &rgb2, Rect(rgb)); JXL_ASSERT_OK(VerifyRelativeError(rgb, rgb2, 4E-5, 4E-7, _)); diff --git a/third_party/jpeg-xl/lib/jxl/opsin_params.cc b/third_party/jpeg-xl/lib/jxl/opsin_params.cc index e1fdda5322..8aae4e3597 100644 --- a/third_party/jpeg-xl/lib/jxl/opsin_params.cc +++ b/third_party/jpeg-xl/lib/jxl/opsin_params.cc @@ -9,24 +9,19 @@ #define INVERSE_OPSIN_FROM_SPEC 1 -#if not(INVERSE_OPSIN_FROM_SPEC) #include "lib/jxl/base/matrix_ops.h" -#endif namespace jxl { -const float* GetOpsinAbsorbanceInverseMatrix() { +const Matrix3x3& GetOpsinAbsorbanceInverseMatrix() { #if INVERSE_OPSIN_FROM_SPEC return jxl::cms::DefaultInverseOpsinAbsorbanceMatrix(); #else // INVERSE_OPSIN_FROM_SPEC // Compute the inverse opsin matrix from the forward matrix. Less precise // than taking the values from the specification, but must be used if the // forward transform is changed and the spec will require updating. - static const float* const kInverse = [] { - static float inverse[9]; - for (int i = 0; i < 9; i++) { - inverse[i] = kOpsinAbsorbanceMatrix[i]; - } + static const Matrix3x3 const kInverse = [] { + static Matrix3x3 inverse = kOpsinAbsorbanceMatrix; Inv3x3Matrix(inverse); return inverse; }(); @@ -34,12 +29,15 @@ const float* GetOpsinAbsorbanceInverseMatrix() { #endif // INVERSE_OPSIN_FROM_SPEC } -void InitSIMDInverseMatrix(const float* JXL_RESTRICT inverse, +void InitSIMDInverseMatrix(const Matrix3x3& inverse, float* JXL_RESTRICT simd_inverse, float intensity_target) { - for (size_t i = 0; i < 9; ++i) { - simd_inverse[4 * i] = simd_inverse[4 * i + 1] = simd_inverse[4 * i + 2] = - simd_inverse[4 * i + 3] = inverse[i] * (255.0f / intensity_target); + for (size_t j = 0; j < 3; ++j) { + for (size_t i = 0; i < 3; ++i) { + size_t idx = (j * 3 + i) * 4; + simd_inverse[idx] = simd_inverse[idx + 1] = simd_inverse[idx + 2] = + simd_inverse[idx + 3] = inverse[j][i] * (255.0f / intensity_target); + } } } diff --git a/third_party/jpeg-xl/lib/jxl/opsin_params.h b/third_party/jpeg-xl/lib/jxl/opsin_params.h index fc285ac208..4ed2124fd7 100644 --- a/third_party/jpeg-xl/lib/jxl/opsin_params.h +++ b/third_party/jpeg-xl/lib/jxl/opsin_params.h @@ -9,14 +9,15 @@ // Constants that define the XYB color space. #include "lib/jxl/base/compiler_specific.h" +#include "lib/jxl/base/matrix_ops.h" namespace jxl { // Returns 3x3 row-major matrix inverse of kOpsinAbsorbanceMatrix. // opsin_image_test verifies this is actually the inverse. -const float* GetOpsinAbsorbanceInverseMatrix(); +const Matrix3x3& GetOpsinAbsorbanceInverseMatrix(); -void InitSIMDInverseMatrix(const float* JXL_RESTRICT inverse, +void InitSIMDInverseMatrix(const Matrix3x3& inverse, float* JXL_RESTRICT simd_inverse, float intensity_target); diff --git a/third_party/jpeg-xl/lib/jxl/padded_bytes.h b/third_party/jpeg-xl/lib/jxl/padded_bytes.h index 0d696475fa..38167ed408 100644 --- a/third_party/jpeg-xl/lib/jxl/padded_bytes.h +++ b/third_party/jpeg-xl/lib/jxl/padded_bytes.h @@ -71,7 +71,7 @@ class PaddedBytes { return *this; } - void swap(PaddedBytes& other) { + void swap(PaddedBytes& other) noexcept { std::swap(size_, other.size_); std::swap(capacity_, other.capacity_); std::swap(data_, other.data_); diff --git a/third_party/jpeg-xl/lib/jxl/passes_state.cc b/third_party/jpeg-xl/lib/jxl/passes_state.cc index 12cc6a0c93..5da731b48e 100644 --- a/third_party/jpeg-xl/lib/jxl/passes_state.cc +++ b/third_party/jpeg-xl/lib/jxl/passes_state.cc @@ -5,6 +5,7 @@ #include "lib/jxl/passes_state.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/chroma_from_luma.h" #include "lib/jxl/coeff_order.h" #include "lib/jxl/frame_dimensions.h" @@ -21,13 +22,17 @@ Status InitializePassesSharedState(const FrameHeader& frame_header, const FrameDimensions& frame_dim = shared->frame_dim; - shared->ac_strategy = - AcStrategyImage(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - shared->raw_quant_field = - ImageI(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - shared->epf_sharpness = - ImageB(frame_dim.xsize_blocks, frame_dim.ysize_blocks); - shared->cmap = ColorCorrelationMap(frame_dim.xsize, frame_dim.ysize); + JXL_ASSIGN_OR_RETURN( + shared->ac_strategy, + AcStrategyImage::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN( + shared->raw_quant_field, + ImageI::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN( + shared->epf_sharpness, + ImageB::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); + JXL_ASSIGN_OR_RETURN(shared->cmap, ColorCorrelationMap::Create( + frame_dim.xsize, frame_dim.ysize)); // In the decoder, we allocate coeff orders afterwards, when we know how many // we will actually need. @@ -40,9 +45,11 @@ Status InitializePassesSharedState(const FrameHeader& frame_header, kCoeffOrderMaxSize); } - shared->quant_dc = ImageB(frame_dim.xsize_blocks, frame_dim.ysize_blocks); + JXL_ASSIGN_OR_RETURN( + shared->quant_dc, + ImageB::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); - bool use_dc_frame = !!(frame_header.flags & FrameHeader::kUseDcFrame); + bool use_dc_frame = ((frame_header.flags & FrameHeader::kUseDcFrame) != 0u); if (!encoder && use_dc_frame) { if (frame_header.dc_level == 4) { return JXL_FAILURE("Invalid DC level for kUseDcFrame: %u", @@ -58,8 +65,9 @@ Status InitializePassesSharedState(const FrameHeader& frame_header, } ZeroFillImage(&shared->quant_dc); } else { - shared->dc_storage = - Image3F(frame_dim.xsize_blocks, frame_dim.ysize_blocks); + JXL_ASSIGN_OR_RETURN( + shared->dc_storage, + Image3F::Create(frame_dim.xsize_blocks, frame_dim.ysize_blocks)); shared->dc = &shared->dc_storage; } diff --git a/third_party/jpeg-xl/lib/jxl/passes_test.cc b/third_party/jpeg-xl/lib/jxl/passes_test.cc index a47134cd00..cb9164706f 100644 --- a/third_party/jpeg-xl/lib/jxl/passes_test.cc +++ b/third_party/jpeg-xl/lib/jxl/passes_test.cc @@ -17,7 +17,6 @@ #include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/override.h" #include "lib/jxl/base/span.h" -#include "lib/jxl/enc_butteraugli_comparator.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/image.h" #include "lib/jxl/image_bundle.h" @@ -27,6 +26,7 @@ namespace jxl { +using test::ButteraugliDistance; using test::ReadTestData; using test::Roundtrip; using test::ThreadPoolForTests; @@ -47,10 +47,11 @@ TEST(PassesTest, RoundtripSmallPasses) { CodecInOut io2; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io2, _)); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(0.8222)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 0.8222); } TEST(PassesTest, RoundtripUnalignedPasses) { @@ -67,10 +68,11 @@ TEST(PassesTest, RoundtripUnalignedPasses) { CodecInOut io2; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io2, _)); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(1.72)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 1.72); } TEST(PassesTest, RoundtripMultiGroupPasses) { @@ -91,10 +93,11 @@ TEST(PassesTest, RoundtripMultiGroupPasses) { CodecInOut io2; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io2, _, /* compressed_size */ nullptr, &pool)); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr, &pool), - IsSlightlyBelow(target_distance + threshold)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr, &pool), + target_distance + threshold); }; auto run1 = std::async(std::launch::async, test, 1.0f, 0.15f); @@ -256,7 +259,7 @@ TEST(PassesTest, ProgressiveDownsample2DegradesCorrectlyGrayscale) { ASSERT_TRUE(SetFromBytes(Bytes(orig), &io_orig, &pool)); Rect rect(0, 0, io_orig.xsize(), 128); // need 2 DC groups for the DC frame to actually be progressive. - Image3F large(4242, rect.ysize()); + JXL_ASSIGN_OR_DIE(Image3F large, Image3F::Create(4242, rect.ysize())); ZeroFillImage(&large); CopyImageTo(rect, *io_orig.Main().color(), rect, &large); CodecInOut io; @@ -268,7 +271,7 @@ TEST(PassesTest, ProgressiveDownsample2DegradesCorrectlyGrayscale) { CompressParams cparams; cparams.speed_tier = SpeedTier::kSquirrel; cparams.progressive_dc = 1; - cparams.responsive = true; + cparams.responsive = JXL_TRUE; cparams.qprogressive_mode = Override::kOn; cparams.butteraugli_distance = 1.0; ASSERT_TRUE(test::EncodeFile(cparams, &io, &compressed, &pool)); @@ -300,7 +303,7 @@ TEST(PassesTest, ProgressiveDownsample2DegradesCorrectly) { ASSERT_TRUE(SetFromBytes(Bytes(orig), &io_orig, &pool)); Rect rect(0, 0, io_orig.xsize(), 128); // need 2 DC groups for the DC frame to actually be progressive. - Image3F large(4242, rect.ysize()); + JXL_ASSIGN_OR_DIE(Image3F large, Image3F::Create(4242, rect.ysize())); ZeroFillImage(&large); CopyImageTo(rect, *io_orig.Main().color(), rect, &large); CodecInOut io; @@ -311,7 +314,7 @@ TEST(PassesTest, ProgressiveDownsample2DegradesCorrectly) { CompressParams cparams; cparams.speed_tier = SpeedTier::kSquirrel; cparams.progressive_dc = 1; - cparams.responsive = true; + cparams.responsive = JXL_TRUE; cparams.qprogressive_mode = Override::kOn; cparams.butteraugli_distance = 1.0; ASSERT_TRUE(test::EncodeFile(cparams, &io, &compressed, &pool)); @@ -375,10 +378,11 @@ TEST(PassesTest, RoundtripSmallNoGaborishPasses) { CodecInOut io2; JXL_EXPECT_OK(Roundtrip(&io, cparams, {}, &io2, _)); - EXPECT_THAT(ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), - *JxlGetDefaultCms(), - /*distmap=*/nullptr), - IsSlightlyBelow(1.2)); + EXPECT_SLIGHTLY_BELOW( + ButteraugliDistance(io.frames, io2.frames, ButteraugliParams(), + *JxlGetDefaultCms(), + /*distmap=*/nullptr), + 1.2); } } // namespace diff --git a/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc b/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc index 60f7c32229..fd04b7fc2e 100644 --- a/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc +++ b/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc @@ -12,7 +12,6 @@ #include "lib/extras/codec.h" #include "lib/jxl/base/override.h" #include "lib/jxl/base/span.h" -#include "lib/jxl/enc_butteraugli_comparator.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/image_test_utils.h" #include "lib/jxl/test_utils.h" @@ -21,6 +20,7 @@ namespace jxl { namespace { +using test::ButteraugliDistance; using test::ReadTestData; using test::Roundtrip; diff --git a/third_party/jpeg-xl/lib/jxl/preview_test.cc b/third_party/jpeg-xl/lib/jxl/preview_test.cc index b7fe855d4d..c482db9fd8 100644 --- a/third_party/jpeg-xl/lib/jxl/preview_test.cc +++ b/third_party/jpeg-xl/lib/jxl/preview_test.cc @@ -13,7 +13,6 @@ #include "lib/extras/codec.h" #include "lib/jxl/base/span.h" #include "lib/jxl/codec_in_out.h" -#include "lib/jxl/enc_butteraugli_comparator.h" #include "lib/jxl/enc_params.h" #include "lib/jxl/headers.h" #include "lib/jxl/image_bundle.h" @@ -22,6 +21,7 @@ namespace jxl { namespace { +using test::ButteraugliDistance; using test::ReadTestData; using test::Roundtrip; @@ -32,7 +32,7 @@ TEST(PreviewTest, RoundtripGivenPreview) { ASSERT_TRUE(SetFromBytes(Bytes(orig), &io)); io.ShrinkTo(io.xsize() / 8, io.ysize() / 8); // Same as main image - io.preview_frame = io.Main().Copy(); + JXL_ASSIGN_OR_DIE(io.preview_frame, io.Main().Copy()); const size_t preview_xsize = 15; const size_t preview_ysize = 27; io.preview_frame.ShrinkTo(preview_xsize, preview_ysize); diff --git a/third_party/jpeg-xl/lib/jxl/quant_weights.cc b/third_party/jpeg-xl/lib/jxl/quant_weights.cc index 70b3b9e451..00563c5cbd 100644 --- a/third_party/jpeg-xl/lib/jxl/quant_weights.cc +++ b/third_party/jpeg-xl/lib/jxl/quant_weights.cc @@ -160,8 +160,8 @@ Status ComputeQuantTable(const QuantEncoding& encoding, float* JXL_RESTRICT inv_table, size_t table_num, DequantMatrices::QuantTable kind, size_t* pos) { constexpr size_t N = kBlockDim; - size_t wrows = 8 * DequantMatrices::required_size_x[kind], - wcols = 8 * DequantMatrices::required_size_y[kind]; + size_t wrows = 8 * DequantMatrices::required_size_x[kind]; + size_t wcols = 8 * DequantMatrices::required_size_y[kind]; size_t num = wrows * wcols; std::vector weights(3 * num); @@ -361,7 +361,7 @@ namespace { HWY_EXPORT(ComputeQuantTable); -static constexpr const float kAlmostZero = 1e-8f; +constexpr const float kAlmostZero = 1e-8f; Status DecodeDctParams(BitReader* br, DctQuantWeightParams* params) { params->num_distance_bands = @@ -474,16 +474,16 @@ Status Decode(BitReader* br, QuantEncoding* encoding, size_t required_size_x, default: return JXL_FAILURE("Invalid quantization table encoding"); } - encoding->mode = QuantEncoding::Mode(mode); + encoding->mode = static_cast(mode); return true; } } // namespace // These definitions are needed before C++17. -constexpr size_t DequantMatrices::required_size_[]; -constexpr size_t DequantMatrices::required_size_x[]; -constexpr size_t DequantMatrices::required_size_y[]; +constexpr const std::array DequantMatrices::required_size_x; +constexpr const std::array DequantMatrices::required_size_y; +constexpr const size_t DequantMatrices::kSumRequiredXy; constexpr DequantMatrices::QuantTable DequantMatrices::kQuantTable[]; Status DequantMatrices::Decode(BitReader* br, @@ -502,7 +502,7 @@ Status DequantMatrices::Decode(BitReader* br, } Status DequantMatrices::DecodeDC(BitReader* br) { - bool all_default = br->ReadBits(1); + bool all_default = static_cast(br->ReadBits(1)); if (!br->AllReadsWithinBounds()) return JXL_FAILURE("EOS during DecodeDC"); if (!all_default) { for (size_t c = 0; c < 3; c++) { @@ -1162,11 +1162,12 @@ const QuantEncoding* DequantMatrices::Library() { } DequantMatrices::DequantMatrices() { - encodings_.resize(size_t(QuantTable::kNum), QuantEncoding::Library(0)); + encodings_.resize(static_cast(QuantTable::kNum), + QuantEncoding::Library(0)); size_t pos = 0; size_t offsets[kNum * 3]; - for (size_t i = 0; i < size_t(QuantTable::kNum); i++) { - size_t num = required_size_[i] * kDCTBlockSize; + for (size_t i = 0; i < static_cast(QuantTable::kNum); i++) { + size_t num = required_size_x[i] * required_size_y[i] * kDCTBlockSize; for (size_t c = 0; c < 3; c++) { offsets[3 * i + c] = pos + c * num; } @@ -1191,7 +1192,7 @@ Status DequantMatrices::EnsureComputed(uint32_t acs_mask) { size_t offsets[kNum * 3 + 1]; size_t pos = 0; for (size_t i = 0; i < kNum; i++) { - size_t num = required_size_[i] * kDCTBlockSize; + size_t num = required_size_x[i] * required_size_y[i] * kDCTBlockSize; for (size_t c = 0; c < 3; c++) { offsets[3 * i + c] = pos + c * num; } diff --git a/third_party/jpeg-xl/lib/jxl/quant_weights.h b/third_party/jpeg-xl/lib/jxl/quant_weights.h index 3004176aba..0fa23ffddb 100644 --- a/third_party/jpeg-xl/lib/jxl/quant_weights.h +++ b/third_party/jpeg-xl/lib/jxl/quant_weights.h @@ -15,6 +15,7 @@ #include #include "lib/jxl/ac_strategy.h" +#include "lib/jxl/base/common.h" #include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/span.h" #include "lib/jxl/base/status.h" @@ -23,12 +24,6 @@ namespace jxl { -template -constexpr T ArraySum(T (&a)[N], size_t i = N - 1) { - static_assert(N > 0, "Trying to compute the sum of an empty array"); - return i == 0 ? a[0] : a[i] + ArraySum(a, i - 1); -} - static constexpr size_t kMaxQuantTableSize = AcStrategy::kMaxCoeffArea; static constexpr size_t kNumPredefinedTables = 1; static constexpr size_t kCeilLog2NumPredefinedTables = 0; @@ -410,25 +405,23 @@ class DequantMatrices { const std::vector& encodings() const { return encodings_; } - static constexpr size_t required_size_x[] = {1, 1, 1, 1, 2, 4, 1, 1, 2, - 1, 1, 8, 4, 16, 8, 32, 16}; - static_assert(kNum == sizeof(required_size_x) / sizeof(*required_size_x), + static constexpr auto required_size_x = + to_array({1, 1, 1, 1, 2, 4, 1, 1, 2, 1, 1, 8, 4, 16, 8, 32, 16}); + static_assert(kNum == required_size_x.size(), "Update this array when adding or removing quant tables."); - static constexpr size_t required_size_y[] = {1, 1, 1, 1, 2, 4, 2, 4, 4, - 1, 1, 8, 8, 16, 16, 32, 32}; - static_assert(kNum == sizeof(required_size_y) / sizeof(*required_size_y), + static constexpr auto required_size_y = + to_array({1, 1, 1, 1, 2, 4, 2, 4, 4, 1, 1, 8, 8, 16, 16, 32, 32}); + static_assert(kNum == required_size_y.size(), "Update this array when adding or removing quant tables."); + // MUST be equal `sum(dot(required_size_x, required_size_y))`. + static constexpr size_t kSumRequiredXy = 2056; + Status EnsureComputed(uint32_t acs_mask); private: - static constexpr size_t required_size_[] = { - 1, 1, 1, 1, 4, 16, 2, 4, 8, 1, 1, 64, 32, 256, 128, 1024, 512}; - static_assert(kNum == sizeof(required_size_) / sizeof(*required_size_), - "Update this array when adding or removing quant tables."); - static constexpr size_t kTotalTableSize = - ArraySum(required_size_) * kDCTBlockSize * 3; + static constexpr size_t kTotalTableSize = kSumRequiredXy * kDCTBlockSize * 3; uint32_t computed_mask_ = 0; // kTotalTableSize entries followed by kTotalTableSize for inv_table diff --git a/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc b/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc index 2dd513804c..e92cbf2151 100644 --- a/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc +++ b/third_party/jpeg-xl/lib/jxl/quant_weights_test.cc @@ -23,6 +23,18 @@ namespace jxl { namespace { +// This should have been static assert; not compiling though with C++<17. +TEST(QuantWeightsTest, Invariant) { + size_t sum = 0; + ASSERT_EQ(DequantMatrices::required_size_x.size(), + DequantMatrices::required_size_y.size()); + for (size_t i = 0; i < DequantMatrices::required_size_x.size(); ++i) { + sum += DequantMatrices::required_size_x[i] * + DequantMatrices::required_size_y[i]; + } + ASSERT_EQ(DequantMatrices::kSumRequiredXy, sum); +} + template void CheckSimilar(T a, T b) { EXPECT_EQ(a, b); @@ -50,8 +62,8 @@ void RoundtripMatrices(const std::vector& encodings) { DequantMatrices mat; CodecMetadata metadata; FrameHeader frame_header(&metadata); - ModularFrameEncoder encoder(frame_header, CompressParams{}); - DequantMatricesSetCustom(&mat, encodings, &encoder); + ModularFrameEncoder encoder(frame_header, CompressParams{}, false); + JXL_CHECK(DequantMatricesSetCustom(&mat, encodings, &encoder)); const std::vector& encodings_dec = mat.encodings(); for (size_t i = 0; i < encodings.size(); i++) { const QuantEncoding& e = encodings[i]; @@ -172,8 +184,8 @@ TEST_P(QuantWeightsTargetTest, DCTUniform) { DequantMatrices dequant_matrices; CodecMetadata metadata; FrameHeader frame_header(&metadata); - ModularFrameEncoder encoder(frame_header, CompressParams{}); - DequantMatricesSetCustom(&dequant_matrices, encodings, &encoder); + ModularFrameEncoder encoder(frame_header, CompressParams{}, false); + JXL_CHECK(DequantMatricesSetCustom(&dequant_matrices, encodings, &encoder)); JXL_CHECK(dequant_matrices.EnsureComputed(~0u)); const float dc_quant[3] = {1.0f / kUniformQuant, 1.0f / kUniformQuant, diff --git a/third_party/jpeg-xl/lib/jxl/quantizer.h b/third_party/jpeg-xl/lib/jxl/quantizer.h index 4e34ac78e8..602d12bdfa 100644 --- a/third_party/jpeg-xl/lib/jxl/quantizer.h +++ b/third_party/jpeg-xl/lib/jxl/quantizer.h @@ -73,7 +73,7 @@ class Quantizer { } float ScaleGlobalScale(const float scale) { - int new_global_scale = static_cast(global_scale_ * scale + 0.5f); + int new_global_scale = static_cast(std::lround(global_scale_ * scale)); float scale_out = new_global_scale * 1.0f / global_scale_; global_scale_ = new_global_scale; RecomputeFromGlobalScale(); diff --git a/third_party/jpeg-xl/lib/jxl/quantizer_test.cc b/third_party/jpeg-xl/lib/jxl/quantizer_test.cc index aff19f42c1..eeaac9ba53 100644 --- a/third_party/jpeg-xl/lib/jxl/quantizer_test.cc +++ b/third_party/jpeg-xl/lib/jxl/quantizer_test.cc @@ -5,10 +5,8 @@ #include "lib/jxl/quantizer.h" -#include "lib/jxl/base/span.h" #include "lib/jxl/dec_bit_reader.h" #include "lib/jxl/enc_fields.h" -#include "lib/jxl/image_ops.h" #include "lib/jxl/image_test_utils.h" #include "lib/jxl/testing.h" @@ -24,7 +22,8 @@ TEST(QuantizerTest, QuantizerParams) { for (uint32_t i = 1; i < 10000; ++i) { QuantizerParams p; p.global_scale = i; - size_t extension_bits = 0, total_bits = 0; + size_t extension_bits = 0; + size_t total_bits = 0; EXPECT_TRUE(Bundle::CanEncode(p, &extension_bits, &total_bits)); EXPECT_EQ(0u, extension_bits); EXPECT_GE(total_bits, 4u); @@ -36,7 +35,7 @@ TEST(QuantizerTest, BitStreamRoundtripSameQuant) { const int qysize = 8; DequantMatrices dequant; Quantizer quantizer1(&dequant); - ImageI raw_quant_field(qxsize, qysize); + JXL_ASSIGN_OR_DIE(ImageI raw_quant_field, ImageI::Create(qxsize, qysize)); quantizer1.SetQuant(0.17f, 0.17f, &raw_quant_field); BitWriter writer; QuantizerParams params = quantizer1.GetParams(); @@ -57,10 +56,10 @@ TEST(QuantizerTest, BitStreamRoundtripRandomQuant) { const int qysize = 8; DequantMatrices dequant; Quantizer quantizer1(&dequant); - ImageI raw_quant_field(qxsize, qysize); + JXL_ASSIGN_OR_DIE(ImageI raw_quant_field, ImageI::Create(qxsize, qysize)); quantizer1.SetQuant(0.17f, 0.17f, &raw_quant_field); float quant_dc = 0.17f; - ImageF qf(qxsize, qysize); + JXL_ASSIGN_OR_DIE(ImageF qf, ImageF::Create(qxsize, qysize)); RandomFillImage(&qf, 0.0f, 1.0f); quantizer1.SetQuantField(quant_dc, qf, &raw_quant_field); BitWriter writer; diff --git a/third_party/jpeg-xl/lib/jxl/rational_polynomial_test.cc b/third_party/jpeg-xl/lib/jxl/rational_polynomial_test.cc index bc31cdd092..e5211cda7a 100644 --- a/third_party/jpeg-xl/lib/jxl/rational_polynomial_test.cc +++ b/third_party/jpeg-xl/lib/jxl/rational_polynomial_test.cc @@ -158,8 +158,8 @@ void TestExp() { const T q[4 * (2 + 1)] = {HWY_REP4(9.6259895571622622E-01), HWY_REP4(-4.7272457588933831E-01), HWY_REP4(7.4802088567547664E-02)}; - const T err = - RunApproximation(-1, 1, p, q, EvalPoly(), [](T x) { return T(exp(x)); }); + const T err = RunApproximation(-1, 1, p, q, EvalPoly(), + [](T x) { return static_cast(exp(x)); }); EXPECT_LT(err, 1E-4); } @@ -174,8 +174,8 @@ void TestNegExp() { HWY_REP4(5.9579108238812878E-02), HWY_REP4(3.4542074345478582E-02), HWY_REP4(8.7263562483501714E-03), HWY_REP4(1.4095109143061216E-03)}; - const T err = - RunApproximation(0, 10, p, q, EvalPoly(), [](T x) { return T(exp(-x)); }); + const T err = RunApproximation(0, 10, p, q, EvalPoly(), + [](T x) { return static_cast(exp(-x)); }); EXPECT_LT(err, sizeof(T) == 8 ? 2E-5 : 3E-5); } @@ -191,7 +191,7 @@ void TestSin() { HWY_REP4(3.1546157932479282E-03), HWY_REP4(-1.6692542019380155E-04)}; const T err = RunApproximation(0, Pi(1) * 2, p, q, EvalPoly(), - [](T x) { return T(sin(x)); }); + [](T x) { return static_cast(sin(x)); }); EXPECT_LT(err, sizeof(T) == 8 ? 5E-4 : 7E-4); } diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc index 9aefdd007d..27718e6413 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.cc @@ -6,10 +6,9 @@ #include "lib/jxl/render_pipeline/low_memory_render_pipeline.h" #include -#include -#include #include "lib/jxl/base/arch_macros.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/image_ops.h" namespace jxl { @@ -174,7 +173,7 @@ size_t LowMemoryRenderPipeline::GroupInputYSize(size_t c) const { channel_shifts_[0][c].second; } -void LowMemoryRenderPipeline::EnsureBordersStorage() { +Status LowMemoryRenderPipeline::EnsureBordersStorage() { const auto& shifts = channel_shifts_[0]; if (borders_horizontal_.size() < shifts.size()) { borders_horizontal_.resize(shifts.size()); @@ -194,16 +193,20 @@ void LowMemoryRenderPipeline::EnsureBordersStorage() { 1 << shifts[c].second); Rect horizontal = Rect(0, 0, downsampled_xsize, bordery * num_yborders); if (!SameSize(horizontal, borders_horizontal_[c])) { - borders_horizontal_[c] = ImageF(horizontal.xsize(), horizontal.ysize()); + JXL_ASSIGN_OR_RETURN( + borders_horizontal_[c], + ImageF::Create(horizontal.xsize(), horizontal.ysize())); } Rect vertical = Rect(0, 0, borderx * num_xborders, downsampled_ysize); if (!SameSize(vertical, borders_vertical_[c])) { - borders_vertical_[c] = ImageF(vertical.xsize(), vertical.ysize()); + JXL_ASSIGN_OR_RETURN(borders_vertical_[c], + ImageF::Create(vertical.xsize(), vertical.ysize())); } } + return true; } -void LowMemoryRenderPipeline::Init() { +Status LowMemoryRenderPipeline::Init() { group_border_ = {0, 0}; base_color_shift_ = CeilLog2Nonzero(frame_dimensions_.xsize_upsampled_padded / frame_dimensions_.xsize_padded); @@ -255,7 +258,7 @@ void LowMemoryRenderPipeline::Init() { group_data_x_border_ = RoundUpTo(max_border.first, kGroupXAlign); group_data_y_border_ = max_border.second; - EnsureBordersStorage(); + JXL_RETURN_IF_ERROR(EnsureBordersStorage()); group_border_assigner_.Init(frame_dimensions_); for (first_trailing_stage_ = stages_.size(); first_trailing_stage_ > 0; @@ -282,7 +285,7 @@ void LowMemoryRenderPipeline::Init() { DivCeil(frame_dimensions_.ysize_upsampled, 1 << channel_shifts_[i][c].second)); } - stages_[i]->SetInputSizes(input_sizes); + JXL_RETURN_IF_ERROR(stages_[i]->SetInputSizes(input_sizes)); if (stages_[i]->SwitchToImageDimensions()) { // We don't allow kInOut after switching to image dimensions. JXL_ASSERT(i >= first_trailing_stage_); @@ -300,7 +303,7 @@ void LowMemoryRenderPipeline::Init() { for (size_t c = 0; c < shifts.size(); c++) { input_sizes[c] = {full_image_xsize_, full_image_ysize_}; } - stages_[i]->SetInputSizes(input_sizes); + JXL_RETURN_IF_ERROR(stages_[i]->SetInputSizes(input_sizes)); } anyc_.resize(stages_.size()); @@ -355,10 +358,11 @@ void LowMemoryRenderPipeline::Init() { } } } + return true; } -void LowMemoryRenderPipeline::PrepareForThreadsInternal(size_t num, - bool use_group_ids) { +Status LowMemoryRenderPipeline::PrepareForThreadsInternal(size_t num, + bool use_group_ids) { const auto& shifts = channel_shifts_[0]; use_group_ids_ = use_group_ids; size_t num_buffers = use_group_ids_ ? frame_dimensions_.num_groups : num; @@ -366,8 +370,10 @@ void LowMemoryRenderPipeline::PrepareForThreadsInternal(size_t num, group_data_.emplace_back(); group_data_[t].resize(shifts.size()); for (size_t c = 0; c < shifts.size(); c++) { - group_data_[t][c] = ImageF(GroupInputXSize(c) + group_data_x_border_ * 2, - GroupInputYSize(c) + group_data_y_border_ * 2); + JXL_ASSIGN_OR_RETURN( + group_data_[t][c], + ImageF::Create(GroupInputXSize(c) + group_data_x_border_ * 2, + GroupInputYSize(c) + group_data_y_border_ * 2)); } } // TODO(veluca): avoid reallocating buffers if not needed. @@ -390,7 +396,9 @@ void LowMemoryRenderPipeline::PrepareForThreadsInternal(size_t num, 2 * next_y_border + (1 << stages_[i]->settings_.shift_y); stage_buffer_ysize = 1 << CeilLog2Nonzero(stage_buffer_ysize); next_y_border = stages_[i]->settings_.border_y; - stage_data_[t][c][i] = ImageF(stage_buffer_xsize, stage_buffer_ysize); + JXL_ASSIGN_OR_RETURN( + stage_data_[t][c][i], + ImageF::Create(stage_buffer_xsize, stage_buffer_ysize)); } } } @@ -412,9 +420,11 @@ void LowMemoryRenderPipeline::PrepareForThreadsInternal(size_t num, std::max(left_padding, std::max(middle_padding, right_padding)); out_of_frame_data_.resize(num); for (size_t t = 0; t < num; t++) { - out_of_frame_data_[t] = ImageF(out_of_frame_xsize, shifts.size()); + JXL_ASSIGN_OR_RETURN(out_of_frame_data_[t], + ImageF::Create(out_of_frame_xsize, shifts.size())); } } + return true; } std::vector> LowMemoryRenderPipeline::PrepareBuffers( @@ -520,7 +530,8 @@ class Rows { .Translate(-group_data_x_border, -group_data_y_border) .ShiftLeft(base_color_shift) .CeilShiftRight(group_data_shift[c]) - .Translate(group_data_x_border - ssize_t(kRenderPipelineXOffset), + .Translate(group_data_x_border - + static_cast(kRenderPipelineXOffset), group_data_y_border); rows_[0][c].base_ptr = channel_group_data_rect.Row(&input_data[c], 0); rows_[0][c].stride = input_data[c].PixelsPerRow(); @@ -533,7 +544,8 @@ class Rows { JXL_INLINE float* GetBuffer(int stage, int y, size_t c) const { JXL_DASSERT(stage >= -1); const RowInfo& info = rows_[stage + 1][c]; - return info.base_ptr + ssize_t(info.stride) * (y & info.ymod_minus_1); + return info.base_ptr + + static_cast(info.stride) * (y & info.ymod_minus_1); } private: @@ -551,10 +563,10 @@ class Rows { } // namespace -void LowMemoryRenderPipeline::RenderRect(size_t thread_id, - std::vector& input_data, - Rect data_max_color_channel_rect, - Rect image_max_color_channel_rect) { +Status LowMemoryRenderPipeline::RenderRect(size_t thread_id, + std::vector& input_data, + Rect data_max_color_channel_rect, + Rect image_max_color_channel_rect) { // For each stage, the rect corresponding to the image area currently being // processed, in the coordinates of that stage (i.e. with the scaling factor // that that stage has). @@ -599,7 +611,7 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, // is no point in proceeding. Note: this uses the assumption that if there is // a stage with observable effects (i.e. a kInput stage), it only appears // after the stage that switches to image dimensions. - if (full_image_x1 <= full_image_x0) return; + if (full_image_x1 <= full_image_x0) return true; // Data structures to hold information about input/output rows and their // buffers. @@ -643,7 +655,7 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, } // If we already have rows from a previous iteration, we can just shift // the rows by 1 and insert the new one. - if (input_rows[i][c].size() == 2 * size_t(bordery) + 1) { + if (input_rows[i][c].size() == 2 * static_cast(bordery) + 1) { for (ssize_t iy = 0; iy < 2 * bordery; iy++) { input_rows[i][c][iy] = input_rows[i][c][iy + 1]; } @@ -674,7 +686,7 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, virtual_ypadding_for_output_.end()); for (int vy = -num_extra_rows; - vy < int(image_area_rect.ysize()) + num_extra_rows; vy++) { + vy < static_cast(image_area_rect.ysize()) + num_extra_rows; vy++) { for (size_t i = 0; i < first_trailing_stage_; i++) { int stage_vy = vy - num_extra_rows + virtual_ypadding_for_output_[i]; @@ -688,9 +700,10 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, int y = stage_vy >> channel_shifts_[i][anyc_[i]].second; - ssize_t image_y = ssize_t(group_rect[i].y0()) + y; + ssize_t image_y = static_cast(group_rect[i].y0()) + y; // Do not produce rows in out-of-bounds areas. - if (image_y < 0 || image_y >= ssize_t(image_rect_[i].ysize())) { + if (image_y < 0 || + image_y >= static_cast(image_rect_[i].ysize())) { continue; } @@ -698,9 +711,9 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, prepare_io_rows(y, i); // Produce output rows. - stages_[i]->ProcessRow(input_rows[i], output_rows, - xpadding_for_output_[i], group_rect[i].xsize(), - group_rect[i].x0(), image_y, thread_id); + JXL_RETURN_IF_ERROR(stages_[i]->ProcessRow( + input_rows[i], output_rows, xpadding_for_output_[i], + group_rect[i].xsize(), group_rect[i].x0(), image_y, thread_id)); } // Process trailing stages, i.e. the final set of non-kInOut stages; they @@ -719,7 +732,7 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, // Check that we are not outside of the bounds for the current rendering // rect. Not doing so might result in overwriting some rows that have been // written (or will be written) by other threads. - if (y < 0 || y >= ssize_t(image_area_rect.ysize())) { + if (y < 0 || y >= static_cast(image_area_rect.ysize())) { continue; } @@ -728,7 +741,8 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, // (and may be necessary for correctness, as some stages assume coordinates // are within bounds). ssize_t full_image_y = frame_y0 + image_area_rect.y0() + y; - if (full_image_y < 0 || full_image_y >= ssize_t(full_image_ysize)) { + if (full_image_y < 0 || + full_image_y >= static_cast(full_image_ysize)) { continue; } @@ -739,15 +753,16 @@ void LowMemoryRenderPipeline::RenderRect(size_t thread_id, i < first_image_dim_stage_ ? full_image_x0 - frame_x0 : full_image_x0; size_t y = i < first_image_dim_stage_ ? full_image_y - frame_y0 : full_image_y; - stages_[i]->ProcessRow(input_rows[first_trailing_stage_], output_rows, - /*xextra=*/0, full_image_x1 - full_image_x0, x0, y, - thread_id); + JXL_RETURN_IF_ERROR(stages_[i]->ProcessRow( + input_rows[first_trailing_stage_], output_rows, + /*xextra=*/0, full_image_x1 - full_image_x0, x0, y, thread_id)); } } + return true; } -void LowMemoryRenderPipeline::RenderPadding(size_t thread_id, Rect rect) { - if (rect.xsize() == 0) return; +Status LowMemoryRenderPipeline::RenderPadding(size_t thread_id, Rect rect) { + if (rect.xsize() == 0) return true; size_t numc = channel_shifts_[0].size(); RenderPipelineStage::RowInfo input_rows(numc, std::vector(1)); RenderPipelineStage::RowInfo output_rows; @@ -760,15 +775,16 @@ void LowMemoryRenderPipeline::RenderPadding(size_t thread_id, Rect rect) { stages_[first_image_dim_stage_ - 1]->ProcessPaddingRow( input_rows, rect.xsize(), rect.x0(), rect.y0() + y); for (size_t i = first_image_dim_stage_; i < stages_.size(); i++) { - stages_[i]->ProcessRow(input_rows, output_rows, - /*xextra=*/0, rect.xsize(), rect.x0(), - rect.y0() + y, thread_id); + JXL_RETURN_IF_ERROR(stages_[i]->ProcessRow( + input_rows, output_rows, + /*xextra=*/0, rect.xsize(), rect.x0(), rect.y0() + y, thread_id)); } } + return true; } -void LowMemoryRenderPipeline::ProcessBuffers(size_t group_id, - size_t thread_id) { +Status LowMemoryRenderPipeline::ProcessBuffers(size_t group_id, + size_t thread_id) { std::vector& input_data = group_data_[use_group_ids_ ? group_id : thread_id]; @@ -804,38 +820,43 @@ void LowMemoryRenderPipeline::ProcessBuffers(size_t group_id, if (group_id == 0 && (image_rect.xsize() == 0 || image_rect.ysize() == 0)) { // If this frame does not intersect with the full image, we have to // initialize the whole image area with RenderPadding. - RenderPadding(thread_id, - Rect(0, 0, full_image_xsize_, full_image_ysize_)); + JXL_RETURN_IF_ERROR(RenderPadding( + thread_id, Rect(0, 0, full_image_xsize_, full_image_ysize_))); } // Render padding for groups that intersect with the full image. The case // where no groups intersect was handled above. if (group_rect.xsize() > 0 && group_rect.ysize() > 0) { if (gx == 0 && gy == 0) { - RenderPadding(thread_id, Rect(0, 0, x0, y0)); + JXL_RETURN_IF_ERROR(RenderPadding(thread_id, Rect(0, 0, x0, y0))); } if (gy == 0) { - RenderPadding(thread_id, Rect(x0, 0, x1 - x0, y0)); + JXL_RETURN_IF_ERROR(RenderPadding(thread_id, Rect(x0, 0, x1 - x0, y0))); } if (gx == 0) { - RenderPadding(thread_id, Rect(0, y0, x0, y1 - y0)); + JXL_RETURN_IF_ERROR(RenderPadding(thread_id, Rect(0, y0, x0, y1 - y0))); } if (gx == 0 && gy + 1 == frame_dimensions_.ysize_groups) { - RenderPadding(thread_id, Rect(0, y1, x0, full_image_ysize_ - y1)); + JXL_RETURN_IF_ERROR( + RenderPadding(thread_id, Rect(0, y1, x0, full_image_ysize_ - y1))); } if (gy + 1 == frame_dimensions_.ysize_groups) { - RenderPadding(thread_id, Rect(x0, y1, x1 - x0, full_image_ysize_ - y1)); + JXL_RETURN_IF_ERROR(RenderPadding( + thread_id, Rect(x0, y1, x1 - x0, full_image_ysize_ - y1))); } if (gy == 0 && gx + 1 == frame_dimensions_.xsize_groups) { - RenderPadding(thread_id, Rect(x1, 0, full_image_xsize_ - x1, y0)); + JXL_RETURN_IF_ERROR( + RenderPadding(thread_id, Rect(x1, 0, full_image_xsize_ - x1, y0))); } if (gx + 1 == frame_dimensions_.xsize_groups) { - RenderPadding(thread_id, Rect(x1, y0, full_image_xsize_ - x1, y1 - y0)); + JXL_RETURN_IF_ERROR(RenderPadding( + thread_id, Rect(x1, y0, full_image_xsize_ - x1, y1 - y0))); } if (gy + 1 == frame_dimensions_.ysize_groups && gx + 1 == frame_dimensions_.xsize_groups) { - RenderPadding(thread_id, Rect(x1, y1, full_image_xsize_ - x1, - full_image_ysize_ - y1)); + JXL_RETURN_IF_ERROR(RenderPadding( + thread_id, + Rect(x1, y1, full_image_xsize_ - x1, full_image_ysize_ - y1))); } } } @@ -857,8 +878,10 @@ void LowMemoryRenderPipeline::ProcessBuffers(size_t group_id, gy * frame_dimensions_.group_dim, image_max_color_channel_rect.xsize(), image_max_color_channel_rect.ysize()); - RenderRect(thread_id, input_data, data_max_color_channel_rect, - image_max_color_channel_rect); + JXL_RETURN_IF_ERROR(RenderRect(thread_id, input_data, + data_max_color_channel_rect, + image_max_color_channel_rect)); } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h index b386f7c078..f0b21d3dca 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/low_memory_render_pipeline.h @@ -20,21 +20,21 @@ class LowMemoryRenderPipeline final : public RenderPipeline { std::vector> PrepareBuffers( size_t group_id, size_t thread_id) override; - void PrepareForThreadsInternal(size_t num, bool use_group_ids) override; + Status PrepareForThreadsInternal(size_t num, bool use_group_ids) override; - void ProcessBuffers(size_t group_id, size_t thread_id) override; + Status ProcessBuffers(size_t group_id, size_t thread_id) override; void ClearDone(size_t i) override { group_border_assigner_.ClearDone(i); } - void Init() override; + Status Init() override; - void EnsureBordersStorage(); + Status EnsureBordersStorage(); size_t GroupInputXSize(size_t c) const; size_t GroupInputYSize(size_t c) const; - void RenderRect(size_t thread_id, std::vector& input_data, - Rect data_max_color_channel_rect, - Rect image_max_color_channel_rect); - void RenderPadding(size_t thread_id, Rect rect); + Status RenderRect(size_t thread_id, std::vector& input_data, + Rect data_max_color_channel_rect, + Rect image_max_color_channel_rect); + Status RenderPadding(size_t thread_id, Rect rect); void SaveBorders(size_t group_id, size_t c, const ImageF& in); void LoadBorders(size_t group_id, size_t c, const Rect& r, ImageF* out); diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc index 68b6ef613f..14bd363110 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.cc @@ -5,8 +5,7 @@ #include "lib/jxl/render_pipeline/render_pipeline.h" -#include - +#include "lib/jxl/base/status.h" #include "lib/jxl/render_pipeline/low_memory_render_pipeline.h" #include "lib/jxl/render_pipeline/simple_render_pipeline.h" #include "lib/jxl/sanitizers.h" @@ -18,7 +17,7 @@ void RenderPipeline::Builder::AddStage( stages_.push_back(std::move(stage)); } -std::unique_ptr RenderPipeline::Builder::Finalize( +StatusOr> RenderPipeline::Builder::Finalize( FrameDimensions frame_dimensions) && { #if JXL_ENABLE_ASSERT // Check that the last stage is not an kInOut stage for any channel, and that @@ -88,7 +87,7 @@ std::unique_ptr RenderPipeline::Builder::Finalize( } } res->stages_ = std::move(stages_); - res->Init(); + JXL_RETURN_IF_ERROR(res->Init()); return res; } @@ -103,7 +102,7 @@ RenderPipelineInput RenderPipeline::GetInputBuffers(size_t group_id, return ret; } -void RenderPipeline::InputReady( +Status RenderPipeline::InputReady( size_t group_id, size_t thread_id, const std::vector>& buffers) { JXL_DASSERT(group_id < group_completed_passes_.size()); @@ -113,20 +112,22 @@ void RenderPipeline::InputReady( JXL_CHECK_PLANE_INITIALIZED(*buffers[i].first, buffers[i].second, i); } - ProcessBuffers(group_id, thread_id); + JXL_RETURN_IF_ERROR(ProcessBuffers(group_id, thread_id)); + return true; } Status RenderPipeline::PrepareForThreads(size_t num, bool use_group_ids) { for (const auto& stage : stages_) { JXL_RETURN_IF_ERROR(stage->PrepareForThreads(num)); } - PrepareForThreadsInternal(num, use_group_ids); + JXL_RETURN_IF_ERROR(PrepareForThreadsInternal(num, use_group_ids)); return true; } -void RenderPipelineInput::Done() { +Status RenderPipelineInput::Done() { JXL_ASSERT(pipeline_); - pipeline_->InputReady(group_id_, thread_id_, buffers_); + JXL_RETURN_IF_ERROR(pipeline_->InputReady(group_id_, thread_id_, buffers_)); + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h index bf3ad4975e..c61420be4b 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline.h @@ -32,7 +32,7 @@ class RenderPipelineInput { } RenderPipelineInput() = default; - void Done(); + Status Done(); const std::pair& GetBuffer(size_t c) const { JXL_ASSERT(c < buffers_.size()); @@ -63,7 +63,7 @@ class RenderPipeline { // Finalizes setup of the pipeline. Shifts for all channels should be 0 at // this point. - std::unique_ptr Finalize( + StatusOr> Finalize( FrameDimensions frame_dimensions) &&; private: @@ -118,20 +118,20 @@ class RenderPipeline { friend class RenderPipelineInput; private: - void InputReady(size_t group_id, size_t thread_id, - const std::vector>& buffers); + Status InputReady(size_t group_id, size_t thread_id, + const std::vector>& buffers); virtual std::vector> PrepareBuffers( size_t group_id, size_t thread_id) = 0; - virtual void ProcessBuffers(size_t group_id, size_t thread_id) = 0; + virtual Status ProcessBuffers(size_t group_id, size_t thread_id) = 0; // Note that this method may be called multiple times with different (or // equal) `num`. - virtual void PrepareForThreadsInternal(size_t num, bool use_group_ids) = 0; + virtual Status PrepareForThreadsInternal(size_t num, bool use_group_ids) = 0; // Called once frame dimensions and stages are known. - virtual void Init() {} + virtual Status Init() { return true; } }; } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h index d1a0074161..d054027ba7 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_stage.h @@ -9,6 +9,7 @@ #include #include "lib/jxl/base/arch_macros.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/frame_header.h" namespace jxl { @@ -99,9 +100,10 @@ class RenderPipelineStage { // `GroupBorderAssigner::kPaddingXRound`. If `settings_.temp_buffer_size` is // nonzero, `temp` will point to an HWY-aligned buffer of at least that number // of floats; concurrent calls will have different buffers. - virtual void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const = 0; + virtual Status ProcessRow(const RowInfo& input_rows, + const RowInfo& output_rows, size_t xextra, + size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const = 0; // How each channel will be processed. Channels are numbered starting from // color channels (always 3) and followed by all other channels. @@ -114,8 +116,10 @@ class RenderPipelineStage { // Informs the stage about the total size of each channel. Few stages will // actually need to use this information. - virtual void SetInputSizes( - const std::vector>& input_sizes) {} + virtual Status SetInputSizes( + const std::vector>& input_sizes) { + return true; + } virtual Status PrepareForThreads(size_t num_threads) { return true; } diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc index 51b9f273f8..e9cb913983 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc @@ -111,7 +111,7 @@ TEST(RenderPipelineTest, Build) { frame_dimensions.Set(/*xsize=*/1024, /*ysize=*/1024, /*group_size_shift=*/0, /*max_hshift=*/0, /*max_vshift=*/0, /*modular_mode=*/false, /*upsampling=*/1); - std::move(builder).Finalize(frame_dimensions); + std::move(builder).Finalize(frame_dimensions).value(); } TEST(RenderPipelineTest, CallAllGroups) { @@ -124,14 +124,14 @@ TEST(RenderPipelineTest, CallAllGroups) { frame_dimensions.Set(/*xsize=*/1024, /*ysize=*/1024, /*group_size_shift=*/0, /*max_hshift=*/0, /*max_vshift=*/0, /*modular_mode=*/false, /*upsampling=*/1); - auto pipeline = std::move(builder).Finalize(frame_dimensions); + auto pipeline = std::move(builder).Finalize(frame_dimensions).value(); ASSERT_TRUE(pipeline->PrepareForThreads(1, /*use_group_ids=*/false)); for (size_t i = 0; i < frame_dimensions.num_groups; i++) { auto input_buffers = pipeline->GetInputBuffers(i, 0); FillPlane(0.0f, input_buffers.GetBuffer(0).first, input_buffers.GetBuffer(0).second); - input_buffers.Done(); + JXL_CHECK(input_buffers.Done()); } EXPECT_EQ(pipeline->PassesWithAllInput(), 1); @@ -146,7 +146,7 @@ TEST(RenderPipelineTest, BuildFast) { frame_dimensions.Set(/*xsize=*/1024, /*ysize=*/1024, /*group_size_shift=*/0, /*max_hshift=*/0, /*max_vshift=*/0, /*modular_mode=*/false, /*upsampling=*/1); - std::move(builder).Finalize(frame_dimensions); + std::move(builder).Finalize(frame_dimensions).value(); } TEST(RenderPipelineTest, CallAllGroupsFast) { @@ -159,14 +159,14 @@ TEST(RenderPipelineTest, CallAllGroupsFast) { frame_dimensions.Set(/*xsize=*/1024, /*ysize=*/1024, /*group_size_shift=*/0, /*max_hshift=*/0, /*max_vshift=*/0, /*modular_mode=*/false, /*upsampling=*/1); - auto pipeline = std::move(builder).Finalize(frame_dimensions); + auto pipeline = std::move(builder).Finalize(frame_dimensions).value(); ASSERT_TRUE(pipeline->PrepareForThreads(1, /*use_group_ids=*/false)); for (size_t i = 0; i < frame_dimensions.num_groups; i++) { auto input_buffers = pipeline->GetInputBuffers(i, 0); FillPlane(0.0f, input_buffers.GetBuffer(0).first, input_buffers.GetBuffer(0).second); - input_buffers.Done(); + JXL_CHECK(input_buffers.Done()); } EXPECT_EQ(pipeline->PassesWithAllInput(), 1); @@ -208,7 +208,7 @@ TEST_P(RenderPipelineTestParam, PipelineTest) { io.ShrinkTo(config.xsize, config.ysize); if (config.add_spot_color) { - jxl::ImageF spot(config.xsize, config.ysize); + JXL_ASSIGN_OR_DIE(ImageF spot, ImageF::Create(config.xsize, config.ysize)); jxl::ZeroFillImage(&spot); for (size_t y = 0; y < config.ysize; y++) { @@ -227,7 +227,7 @@ TEST_P(RenderPipelineTestParam, PipelineTest) { info.spot_color[3] = 0.5f; io.metadata.m.extra_channel_info.push_back(info); - std::vector ec; + std::vector ec; ec.push_back(std::move(spot)); io.frames[0].SetExtraChannels(std::move(ec)); } @@ -267,11 +267,11 @@ Splines CreateTestSplines() { const ColorCorrelationMap cmap; std::vector control_points{{9, 54}, {118, 159}, {97, 3}, {10, 40}, {150, 25}, {120, 300}}; - const Spline spline{ - control_points, - /*color_dct=*/ - {{0.03125f, 0.00625f, 0.003125f}, {1.f, 0.321875f}, {1.f, 0.24375f}}, - /*sigma_dct=*/{0.3125f, 0.f, 0.f, 0.0625f}}; + const Spline spline{control_points, + /*color_dct=*/ + {Dct32{0.03125f, 0.00625f, 0.003125f}, + Dct32{1.f, 0.321875f}, Dct32{1.f, 0.24375f}}, + /*sigma_dct=*/{0.3125f, 0.f, 0.f, 0.0625f}}; std::vector spline_data = {spline}; std::vector quantized_splines; std::vector starting_points; @@ -522,7 +522,7 @@ std::ostream& operator<<(std::ostream& os, filename = c.input_path.substr(pos + 1); } std::replace_if( - filename.begin(), filename.end(), [](char c) { return !isalnum(c); }, + filename.begin(), filename.end(), [](char c) { return isalnum(c) == 0; }, '_'); os << filename << "_" << (c.jpeg_transcode ? "JPEG_" : "") << c.xsize << "x" << c.ysize << "_" << c.cparams_descr; diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc index 4495288860..7f5a8ef00f 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.cc @@ -7,27 +7,31 @@ #include +#include "lib/jxl/base/status.h" #include "lib/jxl/image_ops.h" #include "lib/jxl/render_pipeline/render_pipeline_stage.h" #include "lib/jxl/sanitizers.h" namespace jxl { -void SimpleRenderPipeline::PrepareForThreadsInternal(size_t num, - bool use_group_ids) { +Status SimpleRenderPipeline::PrepareForThreadsInternal(size_t num, + bool use_group_ids) { if (!channel_data_.empty()) { - return; + return true; } auto ch_size = [](size_t frame_size, size_t shift) { return DivCeil(frame_size, 1 << shift) + kRenderPipelineXOffset * 2; }; for (size_t c = 0; c < channel_shifts_[0].size(); c++) { - channel_data_.push_back(ImageF( - ch_size(frame_dimensions_.xsize_upsampled, channel_shifts_[0][c].first), - ch_size(frame_dimensions_.ysize_upsampled, - channel_shifts_[0][c].second))); + JXL_ASSIGN_OR_RETURN( + ImageF ch, ImageF::Create(ch_size(frame_dimensions_.xsize_upsampled, + channel_shifts_[0][c].first), + ch_size(frame_dimensions_.ysize_upsampled, + channel_shifts_[0][c].second))); + channel_data_.push_back(std::move(ch)); msan::PoisonImage(channel_data_.back()); } + return true; } Rect SimpleRenderPipeline::MakeChannelRect(size_t group_id, size_t channel) { @@ -60,14 +64,14 @@ std::vector> SimpleRenderPipeline::PrepareBuffers( return ret; } -void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { +Status SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { for (size_t c = 0; c < channel_data_.size(); c++) { Rect r = MakeChannelRect(group_id, c); (void)r; JXL_CHECK_PLANE_INITIALIZED(channel_data_[c], r, c); } - if (PassesWithAllInput() <= processed_passes_) return; + if (PassesWithAllInput() <= processed_passes_) return true; processed_passes_++; for (size_t stage_id = 0; stage_id < stages_.size(); stage_id++) { @@ -89,11 +93,13 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { } // Ensure that the newly allocated channels are large enough to avoid // problems with padding. - new_channels[c] = - ImageF(frame_dimensions_.xsize_upsampled_padded + - kRenderPipelineXOffset * 2 + hwy::kMaxVectorSize * 8, - frame_dimensions_.ysize_upsampled_padded + - kRenderPipelineXOffset * 2); + JXL_ASSIGN_OR_RETURN( + new_channels[c], + ImageF::Create(frame_dimensions_.xsize_upsampled_padded + + kRenderPipelineXOffset * 2 + + hwy::kMaxVectorSize * 8, + frame_dimensions_.ysize_upsampled_padded + + kRenderPipelineXOffset * 2)); new_channels[c].ShrinkTo( (input_sizes[c].first << stage->settings_.shift_x) + kRenderPipelineXOffset * 2, @@ -116,7 +122,8 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { for (size_t y = 0; y < input_sizes[c].second; y++) { float* row = get_row(c, y); for (size_t ix = 0; ix < stage->settings_.border_x; ix++) { - *(row - ix - 1) = row[Mirror(-ssize_t(ix) - 1, input_sizes[c].first)]; + *(row - ix - 1) = + row[Mirror(-static_cast(ix) - 1, input_sizes[c].first)]; } for (size_t ix = 0; ix < stage->settings_.border_x; ix++) { *(row + ix + input_sizes[c].first) = @@ -126,7 +133,8 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { // Vertical mirroring. for (int y = 0; y < static_cast(stage->settings_.border_y); y++) { memcpy(get_row(c, -y - 1) - stage->settings_.border_x, - get_row(c, Mirror(-ssize_t(y) - 1, input_sizes[c].second)) - + get_row(c, Mirror(-static_cast(y) - 1, + input_sizes[c].second)) - stage->settings_.border_x, sizeof(float) * (input_sizes[c].first + 2 * stage->settings_.border_x)); @@ -160,7 +168,7 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { // Run the pipeline. { - stage->SetInputSizes(input_sizes); + JXL_RETURN_IF_ERROR(stage->SetInputSizes(input_sizes)); int border_y = stage->settings_.border_y; for (size_t y = 0; y < ysize; y++) { // Prepare input rows. @@ -183,8 +191,9 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { (y << stage->settings_.shift_y) + iy + kRenderPipelineXOffset); } } - stage->ProcessRow(input_rows, output_rows, /*xextra=*/0, xsize, - /*xpos=*/0, y, thread_id); + JXL_RETURN_IF_ERROR(stage->ProcessRow(input_rows, output_rows, + /*xextra=*/0, xsize, + /*xpos=*/0, y, thread_id)); } } @@ -210,7 +219,8 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { } if (stage->SwitchToImageDimensions()) { - size_t image_xsize, image_ysize; + size_t image_xsize; + size_t image_ysize; FrameOrigin frame_origin; stage->GetImageDimensions(&image_xsize, &image_ysize, &frame_origin); frame_dimensions_.Set(image_xsize, image_ysize, 0, 0, 0, false, 1); @@ -218,8 +228,11 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { channel_data_.clear(); channel_data_.reserve(old_channels.size()); for (size_t c = 0; c < old_channels.size(); c++) { - channel_data_.emplace_back(2 * kRenderPipelineXOffset + image_xsize, - 2 * kRenderPipelineXOffset + image_ysize); + JXL_ASSIGN_OR_RETURN( + ImageF ch, + ImageF::Create(2 * kRenderPipelineXOffset + image_xsize, + 2 * kRenderPipelineXOffset + image_ysize)); + channel_data_.emplace_back(std::move(ch)); } for (size_t y = 0; y < image_ysize; ++y) { for (size_t c = 0; c < channel_data_.size(); c++) { @@ -262,5 +275,6 @@ void SimpleRenderPipeline::ProcessBuffers(size_t group_id, size_t thread_id) { } } } + return true; } } // namespace jxl diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h index 10f4505912..1240b9fa46 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/simple_render_pipeline.h @@ -19,9 +19,9 @@ class SimpleRenderPipeline : public RenderPipeline { std::vector> PrepareBuffers( size_t group_id, size_t thread_id) override; - void ProcessBuffers(size_t group_id, size_t thread_id) override; + Status ProcessBuffers(size_t group_id, size_t thread_id) override; - void PrepareForThreadsInternal(size_t num, bool use_group_ids) override; + Status PrepareForThreadsInternal(size_t num, bool use_group_ids) override; // Full frame buffers. Both X and Y dimensions are padded by // kRenderPipelineXOffset. diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_blending.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_blending.cc index b68105f4c9..ef3899d1b3 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_blending.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_blending.cc @@ -109,7 +109,7 @@ class BlendingStage : public RenderPipelineStage { } } }; - make_blending(info_, &blending_info_[0]); + make_blending(info_, blending_info_.data()); for (size_t i = 0; i < ec_info.size(); i++) { make_blending(ec_info[i], &blending_info_[1 + i]); } @@ -117,9 +117,9 @@ class BlendingStage : public RenderPipelineStage { Status IsInitialized() const override { return initialized_; } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { JXL_ASSERT(initialized_); const FrameOrigin& frame_origin = frame_header_.frame_origin; ssize_t bg_xpos = frame_origin.x0 + static_cast(xpos); @@ -128,7 +128,8 @@ class BlendingStage : public RenderPipelineStage { if (bg_xpos + static_cast(xsize) <= 0 || frame_origin.x0 >= static_cast(image_xsize_) || bg_ypos < 0 || bg_ypos >= static_cast(image_ysize_)) { - return; + // TODO(eustas): or fail? + return true; } if (bg_xpos < 0) { offset -= bg_xpos; @@ -160,9 +161,9 @@ class BlendingStage : public RenderPipelineStage { : zeroes_.data(); } } - PerformBlending(bg_row_ptrs_.data(), fg_row_ptrs_.data(), - fg_row_ptrs_.data(), 0, xsize, blending_info_[0], - blending_info_.data() + 1, *extra_channel_info_); + return PerformBlending(bg_row_ptrs_.data(), fg_row_ptrs_.data(), + fg_row_ptrs_.data(), 0, xsize, blending_info_[0], + blending_info_.data() + 1, *extra_channel_info_); } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_chroma_upsampling.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_chroma_upsampling.cc index 936fbd3a44..2bc88ada67 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_chroma_upsampling.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_chroma_upsampling.cc @@ -27,9 +27,9 @@ class HorizontalChromaUpsamplingStage : public RenderPipelineStage { /*shift=*/1, /*border=*/1)), c_(channel) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { HWY_FULL(float) df; xextra = RoundUpTo(xextra, Lanes(df)); auto threefour = Set(df, 0.75f); @@ -45,6 +45,7 @@ class HorizontalChromaUpsamplingStage : public RenderPipelineStage { auto right = MulAdd(onefour, next, current); StoreInterleaved(df, left, right, row_out + x * 2); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -65,9 +66,9 @@ class VerticalChromaUpsamplingStage : public RenderPipelineStage { /*shift=*/1, /*border=*/1)), c_(channel) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { HWY_FULL(float) df; xextra = RoundUpTo(xextra, Lanes(df)); auto threefour = Set(df, 0.75f); @@ -86,6 +87,7 @@ class VerticalChromaUpsamplingStage : public RenderPipelineStage { Store(MulAdd(it, onefour, im_scaled), df, row_out0 + x); Store(MulAdd(ib, onefour, im_scaled), df, row_out1 + x); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_cms.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_cms.cc index 2465146b47..3202a03e44 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_cms.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_cms.cc @@ -7,10 +7,8 @@ #include -#include "jxl/cms_interface.h" -#include "jxl/color_encoding.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/color_encoding_internal.h" -#include "lib/jxl/common.h" #include "lib/jxl/dec_xyb.h" #undef HWY_TARGET_INCLUDE @@ -19,7 +17,6 @@ #include #include "lib/jxl/dec_xyb-inl.h" -#include "lib/jxl/sanitizers.h" HWY_BEFORE_NAMESPACE(); namespace jxl { @@ -44,10 +41,10 @@ class CmsStage : public RenderPipelineStage { not_mixing_color_and_grey; } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { - JXL_ASSERT(xsize == xsize_); + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { + JXL_ASSERT(xsize <= xsize_); // TODO(firsching): handle grey case seperately // interleave float* JXL_RESTRICT row0 = GetInputRow(input_rows, 0, 0); @@ -62,16 +59,15 @@ class CmsStage : public RenderPipelineStage { } const float* buf_src = mutable_buf_src; float* JXL_RESTRICT buf_dst = color_space_transform->BufDst(thread_id); - if (!color_space_transform->Run(thread_id, buf_src, buf_dst)) { - // TODO(firsching): somehow mark failing here? - return; - } + JXL_RETURN_IF_ERROR( + color_space_transform->Run(thread_id, buf_src, buf_dst, xsize)); // de-interleave for (size_t x = 0; x < xsize; x++) { row0[x] = buf_dst[3 * x + 0]; row1[x] = buf_dst[3 * x + 1]; row2[x] = buf_dst[3 * x + 2]; } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { return c < 3 ? RenderPipelineChannelMode::kInPlace @@ -86,7 +82,7 @@ class CmsStage : public RenderPipelineStage { std::unique_ptr color_space_transform; ColorEncoding c_src_; - void SetInputSizes( + Status SetInputSizes( const std::vector>& input_sizes) override { #if JXL_ENABLE_ASSERT JXL_ASSERT(input_sizes.size() >= 3); @@ -96,6 +92,7 @@ class CmsStage : public RenderPipelineStage { } #endif xsize_ = input_sizes[0].first; + return true; } Status PrepareForThreads(size_t num_threads) override { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_epf.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_epf.cc index 5d1a379ede..d3030b02cb 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_epf.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_epf.cc @@ -8,7 +8,6 @@ #include "lib/jxl/base/common.h" #include "lib/jxl/common.h" // JXL_HIGH_PRECISION #include "lib/jxl/epf.h" -#include "lib/jxl/sanitizers.h" #undef HWY_TARGET_INCLUDE #define HWY_TARGET_INCLUDE "lib/jxl/render_pipeline/stage_epf.cc" @@ -67,9 +66,9 @@ class EPF0Stage : public RenderPipelineStage { *B = MulAdd(weight, cb, *B); } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { DF df; using V = decltype(Zero(df)); @@ -163,6 +162,7 @@ class EPF0Stage : public RenderPipelineStage { StoreU(Mul(Y, inv_w), df, GetOutputRow(output_rows, 1, 0) + x); StoreU(Mul(B, inv_w), df, GetOutputRow(output_rows, 2, 0) + x); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -207,9 +207,9 @@ class EPF1Stage : public RenderPipelineStage { *B = MulAdd(weight, cb, *B); } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { DF df; xextra = RoundUpTo(xextra, Lanes(df)); const float* JXL_RESTRICT row_sigma = @@ -343,6 +343,7 @@ class EPF1Stage : public RenderPipelineStage { Store(Mul(Y, inv_w), df, GetOutputRow(output_rows, 1, 0) + x); Store(Mul(B, inv_w), df, GetOutputRow(output_rows, 2, 0) + x); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -392,9 +393,9 @@ class EPF2Stage : public RenderPipelineStage { *B = MulAdd(weight, cb, *B); } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { DF df; xextra = RoundUpTo(xextra, Lanes(df)); const float* JXL_RESTRICT row_sigma = @@ -465,6 +466,7 @@ class EPF2Stage : public RenderPipelineStage { Store(Mul(Y, inv_w), df, GetOutputRow(output_rows, 1, 0) + x); Store(Mul(B, inv_w), df, GetOutputRow(output_rows, 2, 0) + x); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_from_linear.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_from_linear.cc index 6b1f646cd5..922c7da366 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_from_linear.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_from_linear.cc @@ -68,7 +68,7 @@ struct OpPq { }; struct OpHlg { - explicit OpHlg(const float luminances[3], const float intensity_target) + explicit OpHlg(const Vector3& luminances, const float intensity_target) : hlg_ootf_(HlgOOTF::ToSceneLight(/*display_luminance=*/intensity_target, luminances)) {} @@ -105,9 +105,9 @@ class FromLinearStage : public RenderPipelineStage { : RenderPipelineStage(RenderPipelineStage::Settings()), op_(std::move(op)) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { const HWY_FULL(float) d; const size_t xsize_v = RoundUpTo(xsize, Lanes(d)); float* JXL_RESTRICT row0 = GetInputRow(input_rows, 0, 0); @@ -119,7 +119,8 @@ class FromLinearStage : public RenderPipelineStage { msan::UnpoisonMemory(row0 + xsize, sizeof(float) * (xsize_v - xsize)); msan::UnpoisonMemory(row1 + xsize, sizeof(float) * (xsize_v - xsize)); msan::UnpoisonMemory(row2 + xsize, sizeof(float) * (xsize_v - xsize)); - for (ssize_t x = -xextra; x < (ssize_t)(xsize + xextra); x += Lanes(d)) { + for (ssize_t x = -xextra; x < static_cast(xsize + xextra); + x += Lanes(d)) { auto r = LoadU(d, row0 + x); auto g = LoadU(d, row1 + x); auto b = LoadU(d, row2 + x); @@ -131,6 +132,7 @@ class FromLinearStage : public RenderPipelineStage { msan::PoisonMemory(row0 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row1 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row2 + xsize, sizeof(float) * (xsize_v - xsize)); + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_gaborish.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_gaborish.cc index 0917db3f9a..6fcd5e14df 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_gaborish.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_gaborish.cc @@ -44,9 +44,9 @@ class GaborishStage : public RenderPipelineStage { } } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { const HWY_FULL(float) d; for (size_t c = 0; c < 3; c++) { float* JXL_RESTRICT row_t = GetInputRow(input_rows, c, -1); @@ -66,7 +66,7 @@ class GaborishStage : public RenderPipelineStage { // Since GetInputRow(input_rows, c, {-1, 0, 1}) is aligned, rounding // xextra up to Lanes(d) doesn't access anything problematic. for (ssize_t x = -RoundUpTo(xextra, Lanes(d)); - x < (ssize_t)(xsize + xextra); x += Lanes(d)) { + x < static_cast(xsize + xextra); x += Lanes(d)) { const auto t = LoadMaybeU(d, row_t + x); const auto tl = LoadU(d, row_t + x - 1); const auto tr = LoadU(d, row_t + x + 1); @@ -83,6 +83,7 @@ class GaborishStage : public RenderPipelineStage { Store(pixels, d, row_out + x); } } + return true; } #undef LoadMaybeU diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.cc index 5cf8a6ed51..eca679b948 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_noise.cc @@ -5,6 +5,8 @@ #include "lib/jxl/render_pipeline/stage_noise.h" +#include "lib/jxl/noise.h" + #undef HWY_TARGET_INCLUDE #define HWY_TARGET_INCLUDE "lib/jxl/render_pipeline/stage_noise.cc" #include @@ -61,9 +63,10 @@ class StrengthEvalLut { #endif { #if HWY_TARGET != HWY_SCALAR - uint32_t lut[8]; - memcpy(lut, noise_params.lut, sizeof(lut)); - for (size_t i = 0; i < 8; i++) { + uint32_t lut[NoiseParams::kNumNoisePoints]; + memcpy(lut, noise_params.lut.data(), + NoiseParams::kNumNoisePoints * sizeof(uint32_t)); + for (size_t i = 0; i < NoiseParams::kNumNoisePoints; i++) { low16_lut[2 * i] = (lut[i] >> 0) & 0xFF; low16_lut[2 * i + 1] = (lut[i] >> 8) & 0xFF; high16_lut[2 * i] = (lut[i] >> 16) & 0xFF; @@ -161,10 +164,10 @@ class AddNoiseStage : public RenderPipelineStage { cmap_(cmap), first_c_(first_c) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { - if (!noise_params_.HasAny()) return; + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { + if (!noise_params_.HasAny()) return true; const StrengthEvalLut noise_model(noise_params_); D d; const auto half = Set(d, 0.5f); @@ -212,6 +215,7 @@ class AddNoiseStage : public RenderPipelineStage { msan::PoisonMemory(row_x + xsize, (xsize_v - xsize) * sizeof(float)); msan::PoisonMemory(row_y + xsize, (xsize_v - xsize) * sizeof(float)); msan::PoisonMemory(row_b + xsize, (xsize_v - xsize) * sizeof(float)); + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -241,9 +245,9 @@ class ConvolveNoiseStage : public RenderPipelineStage { /*shift=*/0, /*border=*/2)), first_c_(first_c) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { const HWY_FULL(float) d; for (size_t c = first_c_; c < first_c_ + 3; c++) { float* JXL_RESTRICT rows[5]; @@ -252,7 +256,7 @@ class ConvolveNoiseStage : public RenderPipelineStage { } float* JXL_RESTRICT row_out = GetOutputRow(output_rows, c, 0); for (ssize_t x = -RoundUpTo(xextra, Lanes(d)); - x < (ssize_t)(xsize + xextra); x += Lanes(d)) { + x < static_cast(xsize + xextra); x += Lanes(d)) { const auto p00 = LoadU(d, rows[2] + x); auto others = Zero(d); // TODO(eustas): sum loaded values to reduce the calculation chain @@ -271,6 +275,7 @@ class ConvolveNoiseStage : public RenderPipelineStage { StoreU(pixels, d, row_out + x); } } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_patches.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_patches.cc index c5a75b09f7..e0a66167d4 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_patches.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_patches.cc @@ -14,16 +14,17 @@ class PatchDictionaryStage : public RenderPipelineStage { patches_(*patches), num_channels_(num_channels) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { JXL_ASSERT(xpos == 0 || xpos >= xextra); size_t x0 = xpos ? xpos - xextra : 0; std::vector row_ptrs(num_channels_); for (size_t i = 0; i < num_channels_; i++) { row_ptrs[i] = GetInputRow(input_rows, i, 0) + x0 - xpos; } - patches_.AddOneRow(row_ptrs.data(), ypos, x0, xsize + xextra + xpos - x0); + return patches_.AddOneRow(row_ptrs.data(), ypos, x0, + xsize + xextra + xpos - x0); } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc index 4a0529ce2c..92a13090a7 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_splines.cc @@ -20,13 +20,14 @@ class SplineStage : public RenderPipelineStage { : RenderPipelineStage(RenderPipelineStage::Settings()), splines_(*splines) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { float* row_x = GetInputRow(input_rows, 0, 0); float* row_y = GetInputRow(input_rows, 1, 0); float* row_b = GetInputRow(input_rows, 2, 0); splines_.AddToRow(row_x, row_y, row_b, Rect(xpos, ypos, xsize, 1)); + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_spot.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_spot.cc index a43cb4e1ab..18588e2012 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_spot.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_spot.cc @@ -15,19 +15,20 @@ class SpotColorStage : public RenderPipelineStage { JXL_ASSERT(spot_c_ >= 3); } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { // TODO(veluca): add SIMD. float scale = spot_color_[3]; for (size_t c = 0; c < 3; c++) { float* JXL_RESTRICT p = GetInputRow(input_rows, c, 0); const float* JXL_RESTRICT s = GetInputRow(input_rows, spot_c_, 0); - for (ssize_t x = -xextra; x < ssize_t(xsize + xextra); x++) { + for (ssize_t x = -xextra; x < static_cast(xsize + xextra); x++) { float mix = scale * s[x]; p[x] = mix * spot_color_[c] + (1.0f - mix) * p[x]; } } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_to_linear.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_to_linear.cc index 85eca2f039..c2c5ac484b 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_to_linear.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_to_linear.cc @@ -63,7 +63,7 @@ struct OpPq { }; struct OpHlg { - explicit OpHlg(const float luminances[3], const float intensity_target) + explicit OpHlg(const Vector3& luminances, const float intensity_target) : hlg_ootf_(HlgOOTF::FromSceneLight( /*display_luminance=*/intensity_target, luminances)) {} @@ -113,9 +113,9 @@ class ToLinearStage : public RenderPipelineStage { explicit ToLinearStage() : RenderPipelineStage(RenderPipelineStage::Settings()), valid_(false) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { const HWY_FULL(float) d; const size_t xsize_v = RoundUpTo(xsize, Lanes(d)); float* JXL_RESTRICT row0 = GetInputRow(input_rows, 0, 0); @@ -127,7 +127,8 @@ class ToLinearStage : public RenderPipelineStage { msan::UnpoisonMemory(row0 + xsize, sizeof(float) * (xsize_v - xsize)); msan::UnpoisonMemory(row1 + xsize, sizeof(float) * (xsize_v - xsize)); msan::UnpoisonMemory(row2 + xsize, sizeof(float) * (xsize_v - xsize)); - for (ssize_t x = -xextra; x < (ssize_t)(xsize + xextra); x += Lanes(d)) { + for (ssize_t x = -xextra; x < static_cast(xsize + xextra); + x += Lanes(d)) { auto r = LoadU(d, row0 + x); auto g = LoadU(d, row1 + x); auto b = LoadU(d, row2 + x); @@ -139,6 +140,7 @@ class ToLinearStage : public RenderPipelineStage { msan::PoisonMemory(row0 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row1 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row2 + xsize, sizeof(float) * (xsize_v - xsize)); + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_tone_mapping.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_tone_mapping.cc index 2a272e15dc..e8cd90b244 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_tone_mapping.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_tone_mapping.cc @@ -56,10 +56,10 @@ class ToneMappingStage : public RenderPipelineStage { bool IsNeeded() const { return tone_mapper_ || hlg_ootf_; } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { - if (!(tone_mapper_ || hlg_ootf_)) return; + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { + if (!(tone_mapper_ || hlg_ootf_)) return true; const HWY_FULL(float) d; const size_t xsize_v = RoundUpTo(xsize, Lanes(d)); @@ -72,7 +72,8 @@ class ToneMappingStage : public RenderPipelineStage { msan::UnpoisonMemory(row0 + xsize, sizeof(float) * (xsize_v - xsize)); msan::UnpoisonMemory(row1 + xsize, sizeof(float) * (xsize_v - xsize)); msan::UnpoisonMemory(row2 + xsize, sizeof(float) * (xsize_v - xsize)); - for (ssize_t x = -xextra; x < (ssize_t)(xsize + xextra); x += Lanes(d)) { + for (ssize_t x = -xextra; x < static_cast(xsize + xextra); + x += Lanes(d)) { auto r = LoadU(d, row0 + x); auto g = LoadU(d, row1 + x); auto b = LoadU(d, row2 + x); @@ -100,6 +101,7 @@ class ToneMappingStage : public RenderPipelineStage { msan::PoisonMemory(row0 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row1 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row2 + xsize, sizeof(float) * (xsize_v - xsize)); + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc index ade37d59a6..897b20c4c6 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc @@ -46,9 +46,9 @@ class UpsamplingStage : public RenderPipelineStage { } } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { static HWY_FULL(float) df; size_t shift = settings_.shift_x; size_t N = 1 << shift; @@ -74,6 +74,7 @@ class UpsamplingStage : public RenderPipelineStage { msan::PoisonMemory(dst_row + xsize * N, sizeof(float) * (xsize_v - xsize) * N); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.cc index 847972acc8..c5a91e8efd 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_write.cc @@ -9,7 +9,9 @@ #include "lib/jxl/alpha.h" #include "lib/jxl/base/common.h" +#include "lib/jxl/base/status.h" #include "lib/jxl/dec_cache.h" +#include "lib/jxl/image.h" #include "lib/jxl/image_bundle.h" #include "lib/jxl/sanitizers.h" @@ -150,13 +152,13 @@ class WriteToOutputStage : public RenderPipelineStage { } } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { JXL_DASSERT(xextra == 0); JXL_DASSERT(main_.run_opaque_ || main_.buffer_); - if (ypos >= height_) return; - if (xpos >= width_) return; + if (ypos >= height_) return true; + if (xpos >= width_) return true; if (flip_y_) { ypos = height_ - 1u - ypos; } @@ -184,6 +186,7 @@ class WriteToOutputStage : public RenderPipelineStage { OutputBuffers(extra, thread_id, ypos, xstart, len, line_buffers); } } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -202,7 +205,7 @@ class WriteToOutputStage : public RenderPipelineStage { private: struct Output { - Output(const ImageOutput& image_out) + explicit Output(const ImageOutput& image_out) : pixel_callback_(image_out.callback), buffer_(image_out.buffer), buffer_size_(image_out.buffer_size), @@ -406,8 +409,8 @@ class WriteToOutputStage : public RenderPipelineStage { sizeof(output[0]) * out.num_channels_ * padding); } - void StoreFloat16Row(const Output& out, const float* input[4], size_t len, - uint16_t* output) const { + static void StoreFloat16Row(const Output& out, const float* input[4], + size_t len, uint16_t* output) { const HWY_FULL(float) d; const Rebind du; const Rebind df16; @@ -452,8 +455,8 @@ class WriteToOutputStage : public RenderPipelineStage { sizeof(output[0]) * out.num_channels_ * padding); } - void StoreFloatRow(const Output& out, const float* input[4], size_t len, - float* output) const { + static void StoreFloatRow(const Output& out, const float* input[4], + size_t len, float* output) { const HWY_FULL(float) d; if (out.num_channels_ == 1) { memcpy(output, input[0], len * sizeof(output[0])); @@ -559,7 +562,7 @@ class WriteToImageBundleStage : public RenderPipelineStage { image_bundle_(image_bundle), color_encoding_(std::move(color_encoding)) {} - void SetInputSizes( + Status SetInputSizes( const std::vector>& input_sizes) override { #if JXL_ENABLE_ASSERT JXL_ASSERT(input_sizes.size() >= 3); @@ -569,19 +572,22 @@ class WriteToImageBundleStage : public RenderPipelineStage { } #endif // TODO(eustas): what should we do in the case of "want only ECs"? - image_bundle_->SetFromImage( - Image3F(input_sizes[0].first, input_sizes[0].second), color_encoding_); + JXL_ASSIGN_OR_RETURN(Image3F tmp, Image3F::Create(input_sizes[0].first, + input_sizes[0].second)); + image_bundle_->SetFromImage(std::move(tmp), color_encoding_); // TODO(veluca): consider not reallocating ECs if not needed. image_bundle_->extra_channels().clear(); for (size_t c = 3; c < input_sizes.size(); c++) { - image_bundle_->extra_channels().emplace_back(input_sizes[c].first, - input_sizes[c].second); + JXL_ASSIGN_OR_RETURN(ImageF ch, ImageF::Create(input_sizes[c].first, + input_sizes[c].second)); + image_bundle_->extra_channels().emplace_back(std::move(ch)); } + return true; } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { for (size_t c = 0; c < 3; c++) { memcpy(image_bundle_->color()->PlaneRow(c, ypos) + xpos - xextra, GetInputRow(input_rows, c, 0) - xextra, @@ -594,6 +600,7 @@ class WriteToImageBundleStage : public RenderPipelineStage { GetInputRow(input_rows, 3 + ec, 0) - xextra, sizeof(float) * (xsize + 2 * xextra)); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -612,7 +619,7 @@ class WriteToImage3FStage : public RenderPipelineStage { explicit WriteToImage3FStage(Image3F* image) : RenderPipelineStage(RenderPipelineStage::Settings()), image_(image) {} - void SetInputSizes( + Status SetInputSizes( const std::vector>& input_sizes) override { #if JXL_ENABLE_ASSERT JXL_ASSERT(input_sizes.size() >= 3); @@ -621,17 +628,20 @@ class WriteToImage3FStage : public RenderPipelineStage { JXL_ASSERT(input_sizes[c].second == input_sizes[0].second); } #endif - *image_ = Image3F(input_sizes[0].first, input_sizes[0].second); + JXL_ASSIGN_OR_RETURN( + *image_, Image3F::Create(input_sizes[0].first, input_sizes[0].second)); + return true; } - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { for (size_t c = 0; c < 3; c++) { memcpy(image_->PlaneRow(c, ypos) + xpos - xextra, GetInputRow(input_rows, c, 0) - xextra, sizeof(float) * (xsize + 2 * xextra)); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_xyb.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_xyb.cc index 56e86e6095..a20e686de6 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_xyb.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_xyb.cc @@ -28,9 +28,9 @@ class XYBStage : public RenderPipelineStage { output_is_xyb_(output_encoding_info.color_encoding.GetColorSpace() == ColorSpace::kXYB) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { const HWY_FULL(float) d; JXL_ASSERT(xextra == 0); const size_t xsize_v = RoundUpTo(xsize, Lanes(d)); @@ -52,7 +52,8 @@ class XYBStage : public RenderPipelineStage { const auto offset_x = Set(d, jxl::cms::kScaledXYBOffset[0]); const auto offset_y = Set(d, jxl::cms::kScaledXYBOffset[1]); const auto offset_bmy = Set(d, jxl::cms::kScaledXYBOffset[2]); - for (ssize_t x = -xextra; x < (ssize_t)(xsize + xextra); x += Lanes(d)) { + for (ssize_t x = -xextra; x < static_cast(xsize + xextra); + x += Lanes(d)) { const auto in_x = LoadU(d, row0 + x); const auto in_y = LoadU(d, row1 + x); const auto in_b = LoadU(d, row2 + x); @@ -64,7 +65,8 @@ class XYBStage : public RenderPipelineStage { StoreU(out_b, d, row2 + x); } } else { - for (ssize_t x = -xextra; x < (ssize_t)(xsize + xextra); x += Lanes(d)) { + for (ssize_t x = -xextra; x < static_cast(xsize + xextra); + x += Lanes(d)) { const auto in_opsin_x = LoadU(d, row0 + x); const auto in_opsin_y = LoadU(d, row1 + x); const auto in_opsin_b = LoadU(d, row2 + x); @@ -81,6 +83,7 @@ class XYBStage : public RenderPipelineStage { msan::PoisonMemory(row0 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row1 + xsize, sizeof(float) * (xsize_v - xsize)); msan::PoisonMemory(row2 + xsize, sizeof(float) * (xsize_v - xsize)); + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -130,10 +133,10 @@ class FastXYBStage : public RenderPipelineStage { has_alpha_(has_alpha), alpha_c_(alpha_c) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { - if (ypos >= height_) return; + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { + if (ypos >= height_) return true; JXL_ASSERT(xextra == 0); const float* xyba[4] = { GetInputRow(input_rows, 0, 0), GetInputRow(input_rows, 1, 0), @@ -142,6 +145,7 @@ class FastXYBStage : public RenderPipelineStage { uint8_t* out_buf = rgb_ + stride_ * ypos + (rgba_ ? 4 : 3) * xpos; FastXYBTosRGB8(xyba, out_buf, rgba_, xsize + xpos <= width_ ? xsize : width_ - xpos); + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_ycbcr.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_ycbcr.cc index 30ad327221..f21a00c728 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_ycbcr.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_ycbcr.cc @@ -22,9 +22,9 @@ class kYCbCrStage : public RenderPipelineStage { public: kYCbCrStage() : RenderPipelineStage(RenderPipelineStage::Settings()) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { const HWY_FULL(float) df; // Full-range BT.601 as defined by JFIF Clause 7: @@ -51,6 +51,7 @@ class kYCbCrStage : public RenderPipelineStage { StoreU(g_vec, df, row1 + x); StoreU(b_vec, df, row2 + x); } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h b/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h index 789a52f8b2..c2c25c46c3 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/test_render_pipeline_stages.h @@ -7,10 +7,7 @@ #include #include -#include -#include -#include - +#include "lib/jxl/base/status.h" #include "lib/jxl/render_pipeline/render_pipeline_stage.h" namespace jxl { @@ -20,13 +17,13 @@ class UpsampleXSlowStage : public RenderPipelineStage { UpsampleXSlowStage() : RenderPipelineStage(RenderPipelineStage::Settings::ShiftX(1, 1)) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { for (size_t c = 0; c < input_rows.size(); c++) { const float* row = GetInputRow(input_rows, c, 0); float* row_out = GetOutputRow(output_rows, c, 0); - for (int64_t x = -xextra; x < (int64_t)(xsize + xextra); x++) { + for (int64_t x = -xextra; x < static_cast(xsize + xextra); x++) { float xp = *(row + x - 1); float xc = *(row + x); float xn = *(row + x + 1); @@ -36,6 +33,7 @@ class UpsampleXSlowStage : public RenderPipelineStage { *(row_out + 2 * x + 1) = xout1; } } + return true; } const char* GetName() const override { return "TEST::UpsampleXSlowStage"; } @@ -50,16 +48,16 @@ class UpsampleYSlowStage : public RenderPipelineStage { UpsampleYSlowStage() : RenderPipelineStage(RenderPipelineStage::Settings::ShiftY(1, 1)) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { for (size_t c = 0; c < input_rows.size(); c++) { const float* rowp = GetInputRow(input_rows, c, -1); const float* rowc = GetInputRow(input_rows, c, 0); const float* rown = GetInputRow(input_rows, c, 1); float* row_out0 = GetOutputRow(output_rows, c, 0); float* row_out1 = GetOutputRow(output_rows, c, 1); - for (int64_t x = -xextra; x < (int64_t)(xsize + xextra); x++) { + for (int64_t x = -xextra; x < static_cast(xsize + xextra); x++) { float xp = *(rowp + x); float xc = *(rowc + x); float xn = *(rown + x); @@ -69,6 +67,7 @@ class UpsampleYSlowStage : public RenderPipelineStage { *(row_out1 + x) = yout1; } } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { @@ -82,14 +81,15 @@ class Check0FinalStage : public RenderPipelineStage { public: Check0FinalStage() : RenderPipelineStage(RenderPipelineStage::Settings()) {} - void ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, - size_t xextra, size_t xsize, size_t xpos, size_t ypos, - size_t thread_id) const final { + Status ProcessRow(const RowInfo& input_rows, const RowInfo& output_rows, + size_t xextra, size_t xsize, size_t xpos, size_t ypos, + size_t thread_id) const final { for (size_t c = 0; c < input_rows.size(); c++) { for (size_t x = 0; x < xsize; x++) { JXL_CHECK(fabsf(GetInputRow(input_rows, c, 0)[x]) < 1e-8); } } + return true; } RenderPipelineChannelMode GetChannelMode(size_t c) const final { diff --git a/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc b/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc index c00fda0de1..a4a87bebb7 100644 --- a/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc +++ b/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc @@ -26,7 +26,6 @@ #include "lib/jxl/butteraugli/butteraugli.h" #include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/dec_bit_reader.h" -#include "lib/jxl/enc_butteraugli_comparator.h" #include "lib/jxl/enc_external_image.h" #include "lib/jxl/encode_internal.h" #include "lib/jxl/image.h" @@ -37,6 +36,9 @@ namespace { +using jxl::ImageF; +using jxl::test::ButteraugliDistance; + // Converts a test image to a CodecInOut. // icc_profile can be empty to automatically deduce profile from the pixel // format, or filled in to force this ICC profile @@ -94,7 +96,7 @@ jxl::CodecInOut ConvertTestImage(const std::vector& buf, jxl::ColorEncoding color_encoding; if (!icc_profile.empty()) { jxl::IccBytes icc_profile_copy; - icc_profile.AppendTo(&icc_profile_copy); + icc_profile.AppendTo(icc_profile_copy); EXPECT_TRUE( color_encoding.SetICC(std::move(icc_profile_copy), JxlGetDefaultCms())); } else if (pixel_format.data_type == JXL_TYPE_FLOAT) { @@ -118,12 +120,12 @@ float ConvertTestPixel(const float val) { template <> uint16_t ConvertTestPixel(const float val) { - return (uint16_t)(val * UINT16_MAX); + return static_cast(val * UINT16_MAX); } template <> uint8_t ConvertTestPixel(const float val) { - return (uint8_t)(val * UINT8_MAX); + return static_cast(val * UINT8_MAX); } // Returns a test image. @@ -146,6 +148,7 @@ std::vector GetTestImage(const size_t xsize, const size_t ysize, val = static_cast(x + y) / static_cast(xsize + ysize); break; case 3: + default: val = static_cast(x * y) / static_cast(xsize * ysize); break; } @@ -233,7 +236,7 @@ void VerifyRoundtripCompression( } } if (alpha_in_extra_channels_vector && !has_interleaved_alpha) { - jxl::ImageF alpha_channel(xsize, ysize); + JXL_ASSIGN_OR_DIE(ImageF alpha_channel, ImageF::Create(xsize, ysize)); EXPECT_TRUE(jxl::ConvertFromExternal( extra_channel_bytes.data(), extra_channel_bytes.size(), xsize, ysize, basic_info.bits_per_sample, extra_channel_pixel_format, 0, @@ -298,17 +301,18 @@ void VerifyRoundtripCompression( frame_settings, JXL_ENC_FRAME_SETTING_ALREADY_DOWNSAMPLED, already_downsampled)); } - EXPECT_EQ(JXL_ENC_SUCCESS, - JxlEncoderAddImageFrame(frame_settings, &input_pixel_format, - (void*)original_bytes.data(), - original_bytes.size())); + EXPECT_EQ( + JXL_ENC_SUCCESS, + JxlEncoderAddImageFrame(frame_settings, &input_pixel_format, + static_cast(original_bytes.data()), + original_bytes.size())); EXPECT_EQ(frame_settings->enc->input_queue.empty(), false); for (size_t index = 0; index < channel_infos.size(); index++) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetExtraChannelBuffer( frame_settings, &extra_channel_pixel_format, - (void*)extra_channel_bytes.data(), extra_channel_bytes.size(), - index + has_interleaved_alpha)); + static_cast(extra_channel_bytes.data()), + extra_channel_bytes.size(), index + has_interleaved_alpha)); } JxlEncoderCloseInput(enc); std::vector compressed; @@ -412,10 +416,10 @@ void VerifyRoundtripCompression( if (already_downsampled) { jxl::Image3F* color = decoded_io.Main().color(); - jxl::DownsampleImage(color, resampling); + JXL_ASSIGN_OR_DIE(*color, jxl::DownsampleImage(*color, resampling)); if (decoded_io.Main().HasAlpha()) { - jxl::ImageF* alpha = decoded_io.Main().alpha(); - jxl::DownsampleImage(alpha, resampling); + ImageF* alpha = decoded_io.Main().alpha(); + JXL_ASSIGN_OR_DIE(*alpha, jxl::DownsampleImage(*alpha, resampling)); } decoded_io.SetSize(color->xsize(), color->ysize()); } @@ -463,8 +467,8 @@ TEST(RoundtripTest, FloatFrameRoundtripTest) { {JXL_CHANNEL_CFA, "my cfa channel"}, {JXL_CHANNEL_OPTIONAL, "optional channel"}}, {{JXL_CHANNEL_DEPTH, "very deep"}}}; - for (int use_container = 0; use_container < 2; use_container++) { - for (int lossless = 0; lossless < 2; lossless++) { + for (bool use_container : {false, true}) { + for (bool lossless : {false, true}) { for (uint32_t num_channels = 1; num_channels < 5; num_channels++) { for (auto& extra_channels : extra_channels_cases) { uint32_t has_alpha = static_cast(num_channels % 2 == 0); @@ -475,8 +479,8 @@ TEST(RoundtripTest, FloatFrameRoundtripTest) { JxlPixelFormat pixel_format = JxlPixelFormat{ num_channels, JXL_TYPE_FLOAT, JXL_NATIVE_ENDIAN, 0}; VerifyRoundtripCompression( - 63, 129, pixel_format, pixel_format, (bool)lossless, - (bool)use_container, 1, false, extra_channels); + 63, 129, pixel_format, pixel_format, lossless, use_container, 1, + false, extra_channels); } } } @@ -499,8 +503,8 @@ TEST(RoundtripTest, Uint16FrameRoundtripTest) { JxlPixelFormat pixel_format = JxlPixelFormat{ num_channels, JXL_TYPE_UINT16, JXL_NATIVE_ENDIAN, 0}; VerifyRoundtripCompression( - 63, 129, pixel_format, pixel_format, (bool)lossless, - (bool)use_container, 1, false, extra_channels); + 63, 129, pixel_format, pixel_format, static_cast(lossless), + static_cast(use_container), 1, false, extra_channels); } } } @@ -523,8 +527,8 @@ TEST(RoundtripTest, Uint8FrameRoundtripTest) { JxlPixelFormat pixel_format = JxlPixelFormat{ num_channels, JXL_TYPE_UINT8, JXL_NATIVE_ENDIAN, 0}; VerifyRoundtripCompression( - 63, 129, pixel_format, pixel_format, (bool)lossless, - (bool)use_container, 1, false, extra_channels); + 63, 129, pixel_format, pixel_format, static_cast(lossless), + static_cast(use_container), 1, false, extra_channels); } } } @@ -540,7 +544,7 @@ TEST(RoundtripTest, TestNonlinearSrgbAsXybEncoded) { JxlPixelFormat{num_channels, JXL_TYPE_FLOAT, JXL_NATIVE_ENDIAN, 0}; VerifyRoundtripCompression( 63, 129, pixel_format_in, pixel_format_out, - /*lossless=*/false, (bool)use_container, 1, false, {}); + /*lossless=*/false, static_cast(use_container), 1, false, {}); } } } @@ -586,25 +590,25 @@ TEST(RoundtripTest, ExtraBoxesTest) { jxl::test::JxlBasicInfoSetFromPixelFormat(&basic_info, &pixel_format); basic_info.xsize = xsize; basic_info.ysize = ysize; - basic_info.uses_original_profile = false; + basic_info.uses_original_profile = JXL_FALSE; EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetCodestreamLevel(enc, 10)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc, &basic_info)); JxlColorEncoding color_encoding; + JXL_BOOL is_gray = TO_JXL_BOOL(pixel_format.num_channels < 3); if (pixel_format.data_type == JXL_TYPE_FLOAT) { - JxlColorEncodingSetToLinearSRGB(&color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JxlColorEncodingSetToLinearSRGB(&color_encoding, is_gray); } else { - JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JxlColorEncodingSetToSRGB(&color_encoding, is_gray); } EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc, &color_encoding)); JxlEncoderFrameSettings* frame_settings = JxlEncoderFrameSettingsCreate(enc, nullptr); - JxlEncoderSetFrameLossless(frame_settings, false); - EXPECT_EQ(JXL_ENC_SUCCESS, - JxlEncoderAddImageFrame(frame_settings, &pixel_format, - (void*)original_bytes.data(), - original_bytes.size())); + JxlEncoderSetFrameLossless(frame_settings, JXL_FALSE); + EXPECT_EQ( + JXL_ENC_SUCCESS, + JxlEncoderAddImageFrame(frame_settings, &pixel_format, + static_cast(original_bytes.data()), + original_bytes.size())); JxlEncoderCloseInput(enc); std::vector compressed; @@ -703,19 +707,17 @@ TEST(RoundtripTest, MultiFrameTest) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetBasicInfo(enc, &basic_info)); JxlColorEncoding color_encoding; + JXL_BOOL is_gray = TO_JXL_BOOL(pixel_format.num_channels < 3); if (pixel_format.data_type == JXL_TYPE_FLOAT) { - JxlColorEncodingSetToLinearSRGB( - &color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JxlColorEncodingSetToLinearSRGB(&color_encoding, is_gray); } else { - JxlColorEncodingSetToSRGB(&color_encoding, - /*is_gray=*/pixel_format.num_channels < 3); + JxlColorEncodingSetToSRGB(&color_encoding, is_gray); } EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderSetColorEncoding(enc, &color_encoding)); JxlEncoderFrameSettings* frame_settings = JxlEncoderFrameSettingsCreate(enc, nullptr); - JxlEncoderSetFrameLossless(frame_settings, false); + JxlEncoderSetFrameLossless(frame_settings, JXL_FALSE); if (index_frames == 1) { EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderFrameSettingsSetOption(frame_settings, @@ -733,9 +735,10 @@ TEST(RoundtripTest, MultiFrameTest) { JxlEncoderSetFrameHeader(frame_settings, &frame_header); EXPECT_EQ( JXL_ENC_SUCCESS, - JxlEncoderAddImageFrame( - frame_settings, &pixel_format, - (void*)(original_bytes.data() + oneframesize * i), oneframesize)); + JxlEncoderAddImageFrame(frame_settings, &pixel_format, + static_cast( + original_bytes.data() + oneframesize * i), + oneframesize)); } JxlEncoderCloseInput(enc); @@ -877,10 +880,11 @@ TEST(RoundtripTest, TestICCProfile) { JxlEncoderSetICCProfile(enc, icc.data(), icc.size())); JxlEncoderFrameSettings* frame_settings = JxlEncoderFrameSettingsCreate(enc, nullptr); - EXPECT_EQ(JXL_ENC_SUCCESS, - JxlEncoderAddImageFrame(frame_settings, &format, - (void*)original_bytes.data(), - original_bytes.size())); + EXPECT_EQ( + JXL_ENC_SUCCESS, + JxlEncoderAddImageFrame(frame_settings, &format, + static_cast(original_bytes.data()), + original_bytes.size())); JxlEncoderCloseInput(enc); std::vector compressed; @@ -946,7 +950,7 @@ TEST(RoundtripTest, JXL_TRANSCODE_JPEG_TEST(TestJPEGReconstruction)) { JxlEncoderPtr enc = JxlEncoderMake(nullptr); JxlEncoderFrameSettings* frame_settings = - JxlEncoderFrameSettingsCreate(enc.get(), NULL); + JxlEncoderFrameSettingsCreate(enc.get(), nullptr); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderUseContainer(enc.get(), JXL_TRUE)); EXPECT_EQ(JXL_ENC_SUCCESS, JxlEncoderStoreJPEGMetadata(enc.get(), JXL_TRUE)); diff --git a/third_party/jpeg-xl/lib/jxl/sanitizers.h b/third_party/jpeg-xl/lib/jxl/sanitizers.h index adeaea67ed..bb133e9203 100644 --- a/third_party/jpeg-xl/lib/jxl/sanitizers.h +++ b/third_party/jpeg-xl/lib/jxl/sanitizers.h @@ -43,28 +43,18 @@ static JXL_INLINE JXL_MAYBE_UNUSED void UnpoisonMemory(const volatile void* m, __msan_unpoison(m, size); } -static JXL_INLINE JXL_MAYBE_UNUSED void UnpoisonCStr(const char* c) { - do { - UnpoisonMemory(c, 1); - } while (*c++); -} - static JXL_INLINE JXL_MAYBE_UNUSED void MemoryIsInitialized( const volatile void* m, size_t size) { __msan_check_mem_is_initialized(m, size); } // Mark all the bytes of an image (including padding) as poisoned bytes. -static JXL_INLINE JXL_MAYBE_UNUSED void PoisonImage(const PlaneBase& im) { +template +static JXL_INLINE JXL_MAYBE_UNUSED void PoisonImage(const Plane& im) { PoisonMemory(im.bytes(), im.bytes_per_row() * im.ysize()); } -template -static JXL_INLINE JXL_MAYBE_UNUSED void PoisonImage(const Image3& im) { - PoisonImage(im.Plane(0)); - PoisonImage(im.Plane(1)); - PoisonImage(im.Plane(2)); -} +namespace { // Print the uninitialized regions of an image. template @@ -210,6 +200,8 @@ static JXL_INLINE JXL_MAYBE_UNUSED void CheckImageInitialized( } } +} // namespace + #define JXL_CHECK_IMAGE_INITIALIZED(im, r) \ ::jxl::msan::CheckImageInitialized(im, r, "im=" #im ", r=" #r); @@ -221,13 +213,13 @@ static JXL_INLINE JXL_MAYBE_UNUSED void CheckImageInitialized( // In non-msan mode these functions don't use volatile since it is not needed // for the empty functions. -static JXL_INLINE JXL_MAYBE_UNUSED void PoisonMemory(const void*, size_t) {} -static JXL_INLINE JXL_MAYBE_UNUSED void UnpoisonMemory(const void*, size_t) {} -static JXL_INLINE JXL_MAYBE_UNUSED void UnpoisonCStr(const char*) {} -static JXL_INLINE JXL_MAYBE_UNUSED void MemoryIsInitialized(const void*, - size_t) {} +static JXL_INLINE JXL_MAYBE_UNUSED void PoisonMemory(const void* m, + size_t size) {} +static JXL_INLINE JXL_MAYBE_UNUSED void UnpoisonMemory(const void* m, + size_t size) {} +static JXL_INLINE JXL_MAYBE_UNUSED void MemoryIsInitialized(const void* m, + size_t size) {} -static JXL_INLINE JXL_MAYBE_UNUSED void PoisonImage(const PlaneBase& im) {} template static JXL_INLINE JXL_MAYBE_UNUSED void PoisonImage(const Plane& im) {} diff --git a/third_party/jpeg-xl/lib/jxl/simd_util.cc b/third_party/jpeg-xl/lib/jxl/simd_util.cc index a3971ff900..6515daaa2b 100644 --- a/third_party/jpeg-xl/lib/jxl/simd_util.cc +++ b/third_party/jpeg-xl/lib/jxl/simd_util.cc @@ -5,11 +5,18 @@ #include "lib/jxl/simd_util.h" +#include +#include + #undef HWY_TARGET_INCLUDE #define HWY_TARGET_INCLUDE "lib/jxl/simd_util.cc" #include #include +#include "lib/jxl/base/common.h" +#include "lib/jxl/base/status.h" +#include "lib/jxl/cache_aligned.h" + HWY_BEFORE_NAMESPACE(); namespace jxl { namespace HWY_NAMESPACE { @@ -36,5 +43,37 @@ size_t MaxVectorSize() { return HWY_DYNAMIC_DISPATCH(MaxVectorSize)(); } +size_t BytesPerRow(const size_t xsize, const size_t sizeof_t) { + // Special case: we don't allow any ops -> don't need extra padding/ + if (xsize == 0) { + return 0; + } + + const size_t vec_size = MaxVectorSize(); + size_t valid_bytes = xsize * sizeof_t; + + // Allow unaligned accesses starting at the last valid value. + // Skip for the scalar case because no extra lanes will be loaded. + if (vec_size != 0) { + valid_bytes += vec_size - sizeof_t; + } + + // Round up to vector and cache line size. + const size_t align = std::max(vec_size, CacheAligned::kAlignment); + size_t bytes_per_row = RoundUpTo(valid_bytes, align); + + // During the lengthy window before writes are committed to memory, CPUs + // guard against read after write hazards by checking the address, but + // only the lower 11 bits. We avoid a false dependency between writes to + // consecutive rows by ensuring their sizes are not multiples of 2 KiB. + // Avoid2K prevents the same problem for the planes of an Image3. + if (bytes_per_row % CacheAligned::kAlias == 0) { + bytes_per_row += align; + } + + JXL_ASSERT(bytes_per_row % align == 0); + return bytes_per_row; +} + } // namespace jxl #endif diff --git a/third_party/jpeg-xl/lib/jxl/simd_util.h b/third_party/jpeg-xl/lib/jxl/simd_util.h index 84938a931a..62b68c989c 100644 --- a/third_party/jpeg-xl/lib/jxl/simd_util.h +++ b/third_party/jpeg-xl/lib/jxl/simd_util.h @@ -12,6 +12,10 @@ namespace jxl { // Maximal vector size in bytes. size_t MaxVectorSize(); +// Returns distance [bytes] between the start of two consecutive rows, a +// multiple of vector/cache line size but NOT CacheAligned::kAlias - see below. +size_t BytesPerRow(size_t xsize, size_t sizeof_t); + } // namespace jxl #endif // LIB_JXL_SIMD_UTIL_H_ diff --git a/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc b/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc index 7874bdc158..381367b54d 100644 --- a/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc +++ b/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc @@ -105,7 +105,7 @@ TEST_P(SpeedTierTest, Roundtrip) { { extras::PackedPixelFile ppf_out; test::Roundtrip(t.ppf(), cparams, dparams, nullptr, &ppf_out); - EXPECT_LE(test::ButteraugliDistance(t.ppf(), ppf_out), 1.6); + EXPECT_LE(test::ButteraugliDistance(t.ppf(), ppf_out), 2.0); } if (params.shrink8) { cparams.distance = 0.0f; diff --git a/third_party/jpeg-xl/lib/jxl/splines.cc b/third_party/jpeg-xl/lib/jxl/splines.cc index acbaf38428..1d4fc69e3e 100644 --- a/third_party/jpeg-xl/lib/jxl/splines.cc +++ b/third_party/jpeg-xl/lib/jxl/splines.cc @@ -40,7 +40,7 @@ using hwy::HWY_NAMESPACE::Sub; // Given a set of DCT coefficients, this returns the result of performing cosine // interpolation on the original samples. -float ContinuousIDCT(const float dct[32], const float t) { +float ContinuousIDCT(const Dct32& dct, const float t) { // We compute here the DCT-3 of the `dct` vector, rescaled by a factor of // sqrt(32). This is such that an input vector vector {x, 0, ..., 0} produces // a constant result of x. dct[0] was scaled in Dequantize() to allow uniform @@ -60,7 +60,7 @@ float ContinuousIDCT(const float dct[32], const float t) { for (int i = 0; i < 32; i += Lanes(df)) { auto cos_arg = Mul(LoadU(df, kMultipliers + i), tandhalf); auto cos = FastCosf(df, cos_arg); - auto local_res = Mul(LoadU(df, dct + i), cos); + auto local_res = Mul(LoadU(df, dct.data() + i), cos); result = MulAdd(Set(df, kSqrt2), local_res, result); } return GetLane(SumOfLanes(df, result)); @@ -140,8 +140,9 @@ void ComputeSegments(const Spline::Point& center, const float intensity, segment.inv_sigma = 1.0f / sigma; segment.sigma_over_4_times_intensity = .25f * sigma * intensity; segment.maximum_distance = maximum_distance; - ssize_t y0 = center.y - maximum_distance + .5f; - ssize_t y1 = center.y + maximum_distance + 1.5f; // one-past-the-end + ssize_t y0 = std::llround(center.y - maximum_distance); + ssize_t y1 = + std::llround(center.y + maximum_distance) + 1; // one-past-the-end for (ssize_t y = std::max(y0, 0); y < y1; y++) { segments_by_y.emplace_back(y, segments.size()); } @@ -227,7 +228,7 @@ float InvAdjustedQuant(const int32_t adjustment) { } // X, Y, B, sigma. -static constexpr float kChannelWeight[] = {0.0042f, 0.075f, 0.07f, .3333f}; +constexpr float kChannelWeight[] = {0.0042f, 0.075f, 0.07f, .3333f}; Status DecodeAllStartingPoints(std::vector* const points, BitReader* const br, ANSSymbolReader* reader, @@ -366,7 +367,8 @@ QuantizedSpline::QuantizedSpline(const Spline& original, const Spline::Point& starting_point = original.control_points.front(); int previous_x = static_cast(std::roundf(starting_point.x)); int previous_y = static_cast(std::roundf(starting_point.y)); - int previous_delta_x = 0, previous_delta_y = 0; + int previous_delta_x = 0; + int previous_delta_y = 0; for (auto it = original.control_points.begin() + 1; it != original.control_points.end(); ++it) { const int new_x = static_cast(std::roundf(it->x)); @@ -426,9 +428,10 @@ Status QuantizedSpline::Dequantize(const Spline::Point& starting_point, JXL_RETURN_IF_ERROR(ValidateSplinePointPos(px, py)); int current_x = static_cast(px); int current_y = static_cast(py); - result.control_points.push_back(Spline::Point{static_cast(current_x), - static_cast(current_y)}); - int current_delta_x = 0, current_delta_y = 0; + result.control_points.emplace_back(static_cast(current_x), + static_cast(current_y)); + int current_delta_x = 0; + int current_delta_y = 0; uint64_t manhattan_distance = 0; for (const auto& point : control_points_) { current_delta_x += point.first; @@ -443,8 +446,8 @@ Status QuantizedSpline::Dequantize(const Spline::Point& starting_point, current_x += current_delta_x; current_y += current_delta_y; JXL_RETURN_IF_ERROR(ValidateSplinePointPos(current_x, current_y)); - result.control_points.push_back(Spline::Point{ - static_cast(current_x), static_cast(current_y)}); + result.control_points.emplace_back(static_cast(current_x), + static_cast(current_y)); } const auto inv_quant = InvAdjustedQuant(quantization_adjustment); @@ -605,15 +608,15 @@ Status Splines::Decode(jxl::BitReader* br, const size_t num_pixels) { void Splines::AddTo(Image3F* const opsin, const Rect& opsin_rect, const Rect& image_rect) const { - return Apply(opsin, opsin_rect, image_rect); + Apply(opsin, opsin_rect, image_rect); } void Splines::AddToRow(float* JXL_RESTRICT row_x, float* JXL_RESTRICT row_y, float* JXL_RESTRICT row_b, const Rect& image_row) const { - return ApplyToRow(row_x, row_y, row_b, image_row); + ApplyToRow(row_x, row_y, row_b, image_row); } void Splines::SubtractFrom(Image3F* const opsin) const { - return Apply(opsin, Rect(*opsin), Rect(*opsin)); + Apply(opsin, Rect(*opsin), Rect(*opsin)); } Status Splines::InitializeDrawCache(const size_t image_xsize, @@ -646,8 +649,9 @@ Status Splines::InitializeDrawCache(const size_t image_xsize, } // TODO(firsching) Change this into a JXL_FAILURE for level 5 codestreams. if (total_estimated_area_reached > - std::min((8 * image_xsize * image_ysize + (uint64_t(1) << 25)), - (uint64_t(1) << 30))) { + std::min( + (8 * image_xsize * image_ysize + (static_cast(1) << 25)), + (static_cast(1) << 30))) { JXL_WARNING( "Large total_estimated_area_reached, expect slower decoding: %" PRIu64, total_estimated_area_reached); diff --git a/third_party/jpeg-xl/lib/jxl/splines.h b/third_party/jpeg-xl/lib/jxl/splines.h index acdd0857d0..af51ec937e 100644 --- a/third_party/jpeg-xl/lib/jxl/splines.h +++ b/third_party/jpeg-xl/lib/jxl/splines.h @@ -6,6 +6,7 @@ #ifndef LIB_JXL_SPLINES_H_ #define LIB_JXL_SPLINES_H_ +#include #include #include #include @@ -24,6 +25,8 @@ class BitReader; static constexpr float kDesiredRenderingDistance = 1.f; +typedef std::array Dct32; + enum SplineEntropyContexts : size_t { kQuantizationAdjustmentContext = 0, kStartingPositionContext, @@ -45,10 +48,10 @@ struct Spline { }; std::vector control_points; // X, Y, B. - float color_dct[3][32]; + std::array color_dct; // Splines are draws by normalized Gaussian splatting. This controls the // Gaussian's parameter along the spline. - float sigma_dct[32]; + Dct32 sigma_dct; }; class QuantizedSplineEncoder; diff --git a/third_party/jpeg-xl/lib/jxl/splines_gbench.cc b/third_party/jpeg-xl/lib/jxl/splines_gbench.cc index 78ff6d41c0..903c5b6328 100644 --- a/third_party/jpeg-xl/lib/jxl/splines_gbench.cc +++ b/third_party/jpeg-xl/lib/jxl/splines_gbench.cc @@ -3,7 +3,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include + #include "benchmark/benchmark.h" +#include "lib/jxl/image_ops.h" #include "lib/jxl/splines.h" namespace jxl { @@ -17,12 +20,14 @@ const float kYToB = cmap->YtoBRatio(0); void BM_Splines(benchmark::State& state) { const size_t n = state.range(); - std::vector spline_data = { - {/*control_points=*/{ - {9, 54}, {118, 159}, {97, 3}, {10, 40}, {150, 25}, {120, 300}}, - /*color_dct=*/ - {{0.03125f, 0.00625f, 0.003125f}, {1.f, 0.321875f}, {1.f, 0.24375f}}, - /*sigma_dct=*/{0.3125f, 0.f, 0.f, 0.0625f}}}; + Spline spline1{ + /*control_points=*/{ + {9, 54}, {118, 159}, {97, 3}, {10, 40}, {150, 25}, {120, 300}}, + /*color_dct=*/ + {Dct32{0.03125f, 0.00625f, 0.003125f}, Dct32{1.f, 0.321875f}, + Dct32{1.f, 0.24375f}}, + /*sigma_dct=*/{0.3125f, 0.f, 0.f, 0.0625f}}; + std::vector spline_data = {spline1}; std::vector quantized_splines; std::vector starting_points; for (const Spline& spline : spline_data) { @@ -33,7 +38,7 @@ void BM_Splines(benchmark::State& state) { Splines splines(kQuantizationAdjustment, std::move(quantized_splines), std::move(starting_points)); - Image3F drawing_area(320, 320); + JXL_ASSIGN_OR_DIE(Image3F drawing_area, Image3F::Create(320, 320)); ZeroFillImage(&drawing_area); for (auto _ : state) { for (size_t i = 0; i < n; ++i) { diff --git a/third_party/jpeg-xl/lib/jxl/splines_test.cc b/third_party/jpeg-xl/lib/jxl/splines_test.cc index d812545a37..83cc524234 100644 --- a/third_party/jpeg-xl/lib/jxl/splines_test.cc +++ b/third_party/jpeg-xl/lib/jxl/splines_test.cc @@ -23,7 +23,6 @@ #include "lib/jxl/chroma_from_luma.h" #include "lib/jxl/enc_aux_out.h" #include "lib/jxl/enc_bit_writer.h" -#include "lib/jxl/enc_params.h" #include "lib/jxl/enc_splines.h" #include "lib/jxl/image.h" #include "lib/jxl/image_ops.h" @@ -45,10 +44,6 @@ std::ostream& operator<<(std::ostream& os, const Spline& spline) { namespace { using test::ReadTestData; -using ::testing::AllOf; -using ::testing::Field; -using ::testing::FloatNear; -using ::testing::Pointwise; constexpr int kQuantizationAdjustment = 0; const ColorCorrelationMap* const cmap = new ColorCorrelationMap; @@ -73,127 +68,75 @@ std::vector DequantizeSplines(const Splines& splines) { return dequantized; } -MATCHER(ControlPointIs, "") { - const Spline::Point& actual = std::get<0>(arg); - const Spline::Point& expected = std::get<1>(arg); - return testing::ExplainMatchResult( - AllOf(Field(&Spline::Point::x, FloatNear(expected.x, kTolerance)), - Field(&Spline::Point::y, FloatNear(expected.y, kTolerance))), - actual, result_listener); -} - -MATCHER(ControlPointsMatch, "") { - const Spline& actual = std::get<0>(arg); - const Spline& expected = std::get<1>(arg); - return testing::ExplainMatchResult( - Field(&Spline::control_points, - Pointwise(ControlPointIs(), expected.control_points)), - actual, result_listener); -} - -MATCHER(SplinesMatch, "") { - const Spline& actual = std::get<0>(arg); - const Spline& expected = std::get<1>(arg); - if (!testing::ExplainMatchResult(ControlPointsMatch(), arg, - result_listener)) { - return false; - } - for (int i = 0; i < 3; ++i) { - size_t color_dct_size = - sizeof(expected.color_dct[i]) / sizeof(expected.color_dct[i][0]); - for (size_t j = 0; j < color_dct_size; j++) { - testing::StringMatchResultListener color_dct_listener; - if (!testing::ExplainMatchResult( - FloatNear(expected.color_dct[i][j], kTolerance), - actual.color_dct[i][j], &color_dct_listener)) { - *result_listener << ", where color_dct[" << i << "][" << j - << "] don't match, " << color_dct_listener.str(); - return false; - } - } - } - size_t sigma_dct_size = - sizeof(expected.sigma_dct) / sizeof(expected.sigma_dct[0]); - for (size_t i = 0; i < sigma_dct_size; i++) { - testing::StringMatchResultListener sigma_listener; - if (!testing::ExplainMatchResult( - FloatNear(expected.sigma_dct[i], kTolerance), actual.sigma_dct[i], - &sigma_listener)) { - *result_listener << ", where sigma_dct[" << i << "] don't match, " - << sigma_listener.str(); - return false; - } - } - return true; -} - } // namespace TEST(SplinesTest, Serialization) { - std::vector spline_data = { - {/*control_points=*/{ - {109, 54}, {218, 159}, {80, 3}, {110, 274}, {94, 185}, {17, 277}}, - /*color_dct=*/ - {{36.3, 39.7, 23.2, 67.5, 4.4, 71.5, 62.3, 32.3, 92.2, 10.1, 10.8, - 9.2, 6.1, 10.5, 79.1, 7, 24.6, 90.8, 5.5, 84, 43.8, 49, - 33.5, 78.9, 54.5, 77.9, 62.1, 51.4, 36.4, 14.3, 83.7, 35.4}, - {9.4, 53.4, 9.5, 74.9, 72.7, 26.7, 7.9, 0.9, 84.9, 23.2, 26.5, - 31.1, 91, 11.7, 74.1, 39.3, 23.7, 82.5, 4.8, 2.7, 61.2, 96.4, - 13.7, 66.7, 62.9, 82.4, 5.9, 98.7, 21.5, 7.9, 51.7, 63.1}, - {48, 39.3, 6.9, 26.3, 33.3, 6.2, 1.7, 98.9, 59.9, 59.6, 95, - 61.3, 82.7, 53, 6.1, 30.4, 34.7, 96.9, 93.4, 17, 38.8, 80.8, - 63, 18.6, 43.6, 32.3, 61, 20.2, 24.3, 28.3, 69.1, 62.4}}, - /*sigma_dct=*/{32.7, 21.5, 44.4, 1.8, 45.8, 90.6, 29.3, 59.2, - 23.7, 85.2, 84.8, 27.2, 42.1, 84.1, 50.6, 17.6, - 93.7, 4.9, 2.6, 69.8, 94.9, 52, 24.3, 18.8, - 12.1, 95.7, 28.5, 81.4, 89.9, 31.4, 74.8, 52}}, - {/*control_points=*/{{172, 309}, - {196, 277}, - {42, 238}, - {114, 350}, - {307, 290}, - {316, 269}, - {124, 66}, - {233, 267}}, - /*color_dct=*/ - {{15, 28.9, 22, 6.6, 41.8, 83, 8.6, 56.8, 68.9, 9.7, 5.4, - 19.8, 70.8, 90, 52.5, 65.2, 7.8, 23.5, 26.4, 72.2, 64.7, 87.1, - 1.3, 67.5, 46, 68.4, 65.4, 35.5, 29.1, 13, 41.6, 23.9}, - {47.7, 79.4, 62.7, 29.1, 96.8, 18.5, 17.6, 15.2, 80.5, 56, 96.2, - 59.9, 26.7, 96.1, 92.3, 42.1, 35.8, 54, 23.2, 55, 76, 35.8, - 58.4, 88.7, 2.4, 78.1, 95.6, 27.5, 6.6, 78.5, 24.1, 69.8}, - {43.8, 96.5, 0.9, 95.1, 49.1, 71.2, 25.1, 33.6, 75.2, 95, 82.1, - 19.7, 10.5, 44.9, 50, 93.3, 83.5, 99.5, 64.6, 54, 3.5, 99.7, - 45.3, 82.1, 22.4, 37.9, 60, 32.2, 12.6, 4.6, 65.5, 96.4}}, - /*sigma_dct=*/{72.5, 2.6, 41.7, 2.2, 39.7, 79.1, 69.6, 19.9, - 92.3, 71.5, 41.9, 62.1, 30, 49.4, 70.3, 45.3, - 62.5, 47.2, 46.7, 41.2, 90.8, 46.8, 91.2, 55, - 8.1, 69.6, 25.4, 84.7, 61.7, 27.6, 3.7, 46.9}}, - {/*control_points=*/{{100, 186}, - {257, 97}, - {170, 49}, - {25, 169}, - {309, 104}, - {232, 237}, - {385, 101}, - {122, 168}, - {26, 300}, - {390, 88}}, - /*color_dct=*/ - {{16.9, 64.8, 4.2, 10.6, 23.5, 17, 79.3, 5.7, 60.4, 16.6, 94.9, - 63.7, 87.6, 10.5, 3.8, 61.1, 22.9, 81.9, 80.4, 40.5, 45.9, 25.4, - 39.8, 30, 50.2, 90.4, 27.9, 93.7, 65.1, 48.2, 22.3, 43.9}, - {24.9, 66, 3.5, 90.2, 97.1, 15.8, 35.6, 0.6, 68, 39.6, 24.4, - 85.9, 57.7, 77.6, 47.5, 67.9, 4.3, 5.4, 91.2, 58.5, 0.1, 52.2, - 3.5, 47.8, 63.2, 43.5, 85.8, 35.8, 50.2, 35.9, 19.2, 48.2}, - {82.8, 44.9, 76.4, 39.5, 94.1, 14.3, 89.8, 10, 10.5, 74.5, 56.3, - 65.8, 7.8, 23.3, 52.8, 99.3, 56.8, 46, 76.7, 13.5, 67, 22.4, - 29.9, 43.3, 70.3, 26, 74.3, 53.9, 62, 19.1, 49.3, 46.7}}, - /*sigma_dct=*/{83.5, 1.7, 25.1, 18.7, 46.5, 75.3, 28, 62.3, - 50.3, 23.3, 85.6, 96, 45.8, 33.1, 33.4, 52.9, - 26.3, 58.5, 19.6, 70, 92.6, 22.5, 57, 21.6, - 76.8, 87.5, 22.9, 66.3, 35.7, 35.6, 56.8, 67.2}}, - }; + Spline spline1{ + /*control_points=*/{ + {109, 54}, {218, 159}, {80, 3}, {110, 274}, {94, 185}, {17, 277}}, + /*color_dct=*/ + {Dct32{36.3, 39.7, 23.2, 67.5, 4.4, 71.5, 62.3, 32.3, 92.2, 10.1, 10.8, + 9.2, 6.1, 10.5, 79.1, 7, 24.6, 90.8, 5.5, 84, 43.8, 49, + 33.5, 78.9, 54.5, 77.9, 62.1, 51.4, 36.4, 14.3, 83.7, 35.4}, + Dct32{9.4, 53.4, 9.5, 74.9, 72.7, 26.7, 7.9, 0.9, 84.9, 23.2, 26.5, + 31.1, 91, 11.7, 74.1, 39.3, 23.7, 82.5, 4.8, 2.7, 61.2, 96.4, + 13.7, 66.7, 62.9, 82.4, 5.9, 98.7, 21.5, 7.9, 51.7, 63.1}, + Dct32{48, 39.3, 6.9, 26.3, 33.3, 6.2, 1.7, 98.9, 59.9, 59.6, 95, + 61.3, 82.7, 53, 6.1, 30.4, 34.7, 96.9, 93.4, 17, 38.8, 80.8, + 63, 18.6, 43.6, 32.3, 61, 20.2, 24.3, 28.3, 69.1, 62.4}}, + /*sigma_dct=*/{32.7, 21.5, 44.4, 1.8, 45.8, 90.6, 29.3, 59.2, + 23.7, 85.2, 84.8, 27.2, 42.1, 84.1, 50.6, 17.6, + 93.7, 4.9, 2.6, 69.8, 94.9, 52, 24.3, 18.8, + 12.1, 95.7, 28.5, 81.4, 89.9, 31.4, 74.8, 52}}; + Spline spline2{ + /*control_points=*/{{172, 309}, + {196, 277}, + {42, 238}, + {114, 350}, + {307, 290}, + {316, 269}, + {124, 66}, + {233, 267}}, + /*color_dct=*/ + {Dct32{15, 28.9, 22, 6.6, 41.8, 83, 8.6, 56.8, 68.9, 9.7, 5.4, + 19.8, 70.8, 90, 52.5, 65.2, 7.8, 23.5, 26.4, 72.2, 64.7, 87.1, + 1.3, 67.5, 46, 68.4, 65.4, 35.5, 29.1, 13, 41.6, 23.9}, + Dct32{47.7, 79.4, 62.7, 29.1, 96.8, 18.5, 17.6, 15.2, 80.5, 56, 96.2, + 59.9, 26.7, 96.1, 92.3, 42.1, 35.8, 54, 23.2, 55, 76, 35.8, + 58.4, 88.7, 2.4, 78.1, 95.6, 27.5, 6.6, 78.5, 24.1, 69.8}, + Dct32{43.8, 96.5, 0.9, 95.1, 49.1, 71.2, 25.1, 33.6, 75.2, 95, 82.1, + 19.7, 10.5, 44.9, 50, 93.3, 83.5, 99.5, 64.6, 54, 3.5, 99.7, + 45.3, 82.1, 22.4, 37.9, 60, 32.2, 12.6, 4.6, 65.5, 96.4}}, + /*sigma_dct=*/{72.5, 2.6, 41.7, 2.2, 39.7, 79.1, 69.6, 19.9, + 92.3, 71.5, 41.9, 62.1, 30, 49.4, 70.3, 45.3, + 62.5, 47.2, 46.7, 41.2, 90.8, 46.8, 91.2, 55, + 8.1, 69.6, 25.4, 84.7, 61.7, 27.6, 3.7, 46.9}}; + Spline spline3{ + /*control_points=*/{{100, 186}, + {257, 97}, + {170, 49}, + {25, 169}, + {309, 104}, + {232, 237}, + {385, 101}, + {122, 168}, + {26, 300}, + {390, 88}}, + /*color_dct=*/ + {Dct32{16.9, 64.8, 4.2, 10.6, 23.5, 17, 79.3, 5.7, 60.4, 16.6, 94.9, + 63.7, 87.6, 10.5, 3.8, 61.1, 22.9, 81.9, 80.4, 40.5, 45.9, 25.4, + 39.8, 30, 50.2, 90.4, 27.9, 93.7, 65.1, 48.2, 22.3, 43.9}, + Dct32{24.9, 66, 3.5, 90.2, 97.1, 15.8, 35.6, 0.6, 68, 39.6, 24.4, + 85.9, 57.7, 77.6, 47.5, 67.9, 4.3, 5.4, 91.2, 58.5, 0.1, 52.2, + 3.5, 47.8, 63.2, 43.5, 85.8, 35.8, 50.2, 35.9, 19.2, 48.2}, + Dct32{82.8, 44.9, 76.4, 39.5, 94.1, 14.3, 89.8, 10, 10.5, 74.5, 56.3, + 65.8, 7.8, 23.3, 52.8, 99.3, 56.8, 46, 76.7, 13.5, 67, 22.4, + 29.9, 43.3, 70.3, 26, 74.3, 53.9, 62, 19.1, 49.3, 46.7}}, + /*sigma_dct=*/{83.5, 1.7, 25.1, 18.7, 46.5, 75.3, 28, 62.3, + 50.3, 23.3, 85.6, 96, 45.8, 33.1, 33.4, 52.9, + 26.3, 58.5, 19.6, 70, 92.6, 22.5, 57, 21.6, + 76.8, 87.5, 22.9, 66.3, 35.7, 35.6, 56.8, 67.2}}; + std::vector spline_data{spline1, spline2, spline3}; std::vector quantized_splines; std::vector starting_points; @@ -206,8 +149,20 @@ TEST(SplinesTest, Serialization) { Splines splines(kQuantizationAdjustment, std::move(quantized_splines), std::move(starting_points)); const std::vector quantized_spline_data = DequantizeSplines(splines); - EXPECT_THAT(quantized_spline_data, - Pointwise(ControlPointsMatch(), spline_data)); + EXPECT_EQ(quantized_spline_data.size(), spline_data.size()); + for (size_t i = 0; i < quantized_spline_data.size(); ++i) { + const Spline& actual = quantized_spline_data[i]; + const Spline& expected = spline_data[i]; + const auto& actual_points = actual.control_points; + const auto& expected_points = expected.control_points; + EXPECT_EQ(actual_points.size(), expected_points.size()); + for (size_t j = 0; j < actual_points.size(); ++j) { + EXPECT_NEAR(actual_points[j].x, expected_points[j].x, kTolerance) + << "spline " << i << " point " << j; + EXPECT_NEAR(actual_points[j].y, expected_points[j].y, kTolerance) + << "spline " << i << " point " << j; + } + } BitWriter writer; EncodeSplines(splines, &writer, kLayerSplines, HistogramParams(), nullptr); @@ -225,8 +180,28 @@ TEST(SplinesTest, Serialization) { const std::vector decoded_spline_data = DequantizeSplines(decoded_splines); - EXPECT_THAT(decoded_spline_data, - Pointwise(SplinesMatch(), quantized_spline_data)); + + EXPECT_EQ(decoded_spline_data.size(), quantized_spline_data.size()); + for (size_t i = 0; i < decoded_spline_data.size(); ++i) { + const Spline& actual = decoded_spline_data[i]; + const Spline& expected = quantized_spline_data[i]; + const auto& actual_points = actual.control_points; + const auto& expected_points = expected.control_points; + EXPECT_EQ(actual_points.size(), expected_points.size()); + for (size_t j = 0; j < actual_points.size(); ++j) { + EXPECT_NEAR(actual_points[j].x, expected_points[j].x, kTolerance) + << "spline " << i << " point " << j; + EXPECT_NEAR(actual_points[j].y, expected_points[j].y, kTolerance) + << "spline " << i << " point " << j; + } + + const auto& actual_color_dct = actual.color_dct; + const auto& expected_color_dct = expected.color_dct; + for (size_t j = 0; j < actual_color_dct.size(); ++j) { + EXPECT_ARRAY_NEAR(actual_color_dct[j], expected_color_dct[j], kTolerance); + } + EXPECT_ARRAY_NEAR(actual.sigma_dct, expected.sigma_dct, kTolerance); + } } #ifdef JXL_CRASH_ON_ERROR @@ -240,10 +215,10 @@ TEST(SplinesTest, TooManySplinesTest) { std::vector quantized_splines; std::vector starting_points; for (size_t i = 0; i < kNumSplines; i++) { - Spline spline = { + Spline spline{ /*control_points=*/{{1.f + i, 2}, {10.f + i, 25}, {30.f + i, 300}}, /*color_dct=*/ - {{1.f, 0.2f, 0.1f}, {35.7f, 10.3f}, {35.7f, 7.8f}}, + {Dct32{1.f, 0.2f, 0.1f}, Dct32{35.7f, 10.3f}, Dct32{35.7f, 7.8f}}, /*sigma_dct=*/{10.f, 0.f, 0.f, 2.f}}; quantized_splines.emplace_back(spline, kQuantizationAdjustment, kYToX, kYToB); @@ -271,10 +246,11 @@ TEST(SplinesTest, DuplicatePoints) { std::vector control_points{ {9, 54}, {118, 159}, {97, 3}, // Repeated. {97, 3}, {10, 40}, {150, 25}, {120, 300}}; - Spline spline{control_points, - /*color_dct=*/ - {{1.f, 0.2f, 0.1f}, {35.7f, 10.3f}, {35.7f, 7.8f}}, - /*sigma_dct=*/{10.f, 0.f, 0.f, 2.f}}; + Spline spline{ + control_points, + /*color_dct=*/ + {Dct32{1.f, 0.2f, 0.1f}, Dct32{35.7f, 10.3f}, Dct32{35.7f, 7.8f}}, + /*sigma_dct=*/{10.f, 0.f, 0.f, 2.f}}; std::vector spline_data{spline}; std::vector quantized_splines; std::vector starting_points; @@ -286,7 +262,7 @@ TEST(SplinesTest, DuplicatePoints) { Splines splines(kQuantizationAdjustment, std::move(quantized_splines), std::move(starting_points)); - Image3F image(320, 320); + JXL_ASSIGN_OR_DIE(Image3F image, Image3F::Create(320, 320)); ZeroFillImage(&image); EXPECT_FALSE( splines.InitializeDrawCache(image.xsize(), image.ysize(), *cmap)); @@ -304,10 +280,10 @@ TEST(SplinesTest, Drawing) { const Spline spline{ control_points, /*color_dct=*/ - {{0.4989345073699951171875000f, 0.4997999966144561767578125f}, - {0.4772970676422119140625000f, 0.f, 0.5250000357627868652343750f}, - {-0.0176776945590972900390625f, 0.4900000095367431640625000f, - 0.5250000357627868652343750f}}, + {Dct32{0.4989345073699951171875000f, 0.4997999966144561767578125f}, + Dct32{0.4772970676422119140625000f, 0.f, 0.5250000357627868652343750f}, + Dct32{-0.0176776945590972900390625f, 0.4900000095367431640625000f, + 0.5250000357627868652343750f}}, /*sigma_dct=*/ {0.9427147507667541503906250f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.6665999889373779296875000f}}; @@ -322,13 +298,13 @@ TEST(SplinesTest, Drawing) { Splines splines(kQuantizationAdjustment, std::move(quantized_splines), std::move(starting_points)); - Image3F image(320, 320); + JXL_ASSIGN_OR_DIE(Image3F image, Image3F::Create(320, 320)); ZeroFillImage(&image); ASSERT_TRUE(splines.InitializeDrawCache(image.xsize(), image.ysize(), *cmap)); splines.AddTo(&image, Rect(image), Rect(image)); CodecInOut io_actual; - Image3F image2(320, 320); + JXL_ASSIGN_OR_DIE(Image3F image2, Image3F::Create(320, 320)); CopyImageTo(image, &image2); io_actual.SetFromImage(std::move(image2), ColorEncoding::SRGB()); ASSERT_TRUE(io_actual.frames[0].TransformTo(io_expected.Main().c_current(), diff --git a/third_party/jpeg-xl/lib/jxl/test_image.cc b/third_party/jpeg-xl/lib/jxl/test_image.cc index 098e9c25a1..42f028d53a 100644 --- a/third_party/jpeg-xl/lib/jxl/test_image.cc +++ b/third_party/jpeg-xl/lib/jxl/test_image.cc @@ -323,7 +323,7 @@ TestImage& TestImage::SetColorEncoding(const std::string& description) { } TestImage& TestImage::CoalesceGIFAnimationWithAlpha() { - extras::PackedFrame canvas = ppf_.frames[0].Copy(); + JXL_ASSIGN_OR_DIE(extras::PackedFrame canvas, ppf_.frames[0].Copy()); JXL_CHECK(canvas.color.format.num_channels == 3); JXL_CHECK(canvas.color.format.data_type == JXL_TYPE_UINT8); JXL_CHECK(canvas.extra_channels.size() == 1); @@ -331,7 +331,7 @@ TestImage& TestImage::CoalesceGIFAnimationWithAlpha() { const extras::PackedFrame& frame = ppf_.frames[i]; JXL_CHECK(frame.extra_channels.size() == 1); const JxlLayerInfo& layer_info = frame.frame_info.layer_info; - extras::PackedFrame rendered = canvas.Copy(); + JXL_ASSIGN_OR_DIE(extras::PackedFrame rendered, canvas.Copy()); uint8_t* pixels_rendered = reinterpret_cast(rendered.color.pixels()); const uint8_t* pixels_frame = @@ -353,7 +353,7 @@ TestImage& TestImage::CoalesceGIFAnimationWithAlpha() { } } if (layer_info.save_as_reference != 0) { - canvas = rendered.Copy(); + JXL_ASSIGN_OR_DIE(canvas, rendered.Copy()); } ppf_.frames[i] = std::move(rendered); } @@ -393,10 +393,14 @@ void TestImage::Frame::SetValue(size_t y, size_t x, size_t c, float val) { TestImage::Frame TestImage::AddFrame() { size_t index = ppf_.frames.size(); - extras::PackedFrame frame(ppf_.info.xsize, ppf_.info.ysize, format_); + JXL_ASSIGN_OR_DIE( + extras::PackedFrame frame, + extras::PackedFrame::Create(ppf_.info.xsize, ppf_.info.ysize, format_)); for (size_t i = 0; i < ppf_.extra_channels_info.size(); ++i) { JxlPixelFormat ec_format = {1, format_.data_type, format_.endianness, 0}; - extras::PackedImage image(ppf_.info.xsize, ppf_.info.ysize, ec_format); + JXL_ASSIGN_OR_DIE(extras::PackedImage image, + extras::PackedImage::Create(ppf_.info.xsize, + ppf_.info.ysize, ec_format)); frame.extra_channels.emplace_back(std::move(image)); } ppf_.frames.emplace_back(std::move(frame)); @@ -404,10 +408,12 @@ TestImage::Frame TestImage::AddFrame() { } TestImage::Frame TestImage::AddPreview(size_t xsize, size_t ysize) { - extras::PackedFrame frame(xsize, ysize, format_); + JXL_ASSIGN_OR_DIE(extras::PackedFrame frame, + extras::PackedFrame::Create(xsize, ysize, format_)); for (size_t i = 0; i < ppf_.extra_channels_info.size(); ++i) { JxlPixelFormat ec_format = {1, format_.data_type, format_.endianness, 0}; - extras::PackedImage image(xsize, ysize, ec_format); + JXL_ASSIGN_OR_DIE(extras::PackedImage image, + extras::PackedImage::Create(xsize, ysize, ec_format)); frame.extra_channels.emplace_back(std::move(image)); } ppf_.preview_frame = make_unique(std::move(frame)); diff --git a/third_party/jpeg-xl/lib/jxl/test_utils.cc b/third_party/jpeg-xl/lib/jxl/test_utils.cc index 451f2a0a03..308efb9a13 100644 --- a/third_party/jpeg-xl/lib/jxl/test_utils.cc +++ b/third_party/jpeg-xl/lib/jxl/test_utils.cc @@ -228,7 +228,7 @@ bool Roundtrip(const CodecInOut* io, const CompressParams& cparams, } size_t Roundtrip(const extras::PackedPixelFile& ppf_in, - extras::JXLCompressParams cparams, + const extras::JXLCompressParams& cparams, extras::JXLDecompressParams dparams, ThreadPool* pool, extras::PackedPixelFile* ppf_out) { DefaultAcceptedFormats(dparams); @@ -303,12 +303,12 @@ bool Near(double expected, double value, double max_dist) { float LoadLEFloat16(const uint8_t* p) { uint16_t bits16 = LoadLE16(p); - return LoadFloat16(bits16); + return detail::LoadFloat16(bits16); } float LoadBEFloat16(const uint8_t* p) { uint16_t bits16 = LoadBE16(p); - return LoadFloat16(bits16); + return detail::LoadFloat16(bits16); } size_t GetPrecision(JxlDataType data_type) { @@ -385,7 +385,10 @@ std::vector ConvertToRGBA32(const uint8_t* pixels, size_t xsize, for (size_t x = 0; x < xsize; ++x) { size_t j = (y * xsize + x) * 4; size_t i = y * stride + x * num_channels * 2; - double r, g, b, a; + double r; + double g; + double b; + double a; if (endianness == JXL_BIG_ENDIAN) { r = (pixels[i + 0] << 8) + pixels[i + 1]; g = gray ? r : (pixels[i + 2] << 8) + pixels[i + 3]; @@ -413,7 +416,10 @@ std::vector ConvertToRGBA32(const uint8_t* pixels, size_t xsize, for (size_t x = 0; x < xsize; ++x) { size_t j = (y * xsize + x) * 4; size_t i = y * stride + x * num_channels * 4; - double r, g, b, a; + double r; + double g; + double b; + double a; if (endianness == JXL_BIG_ENDIAN) { r = LoadBEFloat(pixels + i); g = gray ? r : LoadBEFloat(pixels + i + 4); @@ -437,7 +443,10 @@ std::vector ConvertToRGBA32(const uint8_t* pixels, size_t xsize, for (size_t x = 0; x < xsize; ++x) { size_t j = (y * xsize + x) * 4; size_t i = y * stride + x * num_channels * 2; - double r, g, b, a; + double r; + double g; + double b; + double a; if (endianness == JXL_BIG_ENDIAN) { r = LoadBEFloat16(pixels + i); g = gray ? r : LoadBEFloat16(pixels + i + 2); @@ -470,8 +479,8 @@ size_t ComparePixels(const uint8_t* a, const uint8_t* b, size_t xsize, std::vector b_full = ConvertToRGBA32(b, xsize, ysize, format_b); bool gray_a = format_a.num_channels < 3; bool gray_b = format_b.num_channels < 3; - bool alpha_a = !(format_a.num_channels & 1); - bool alpha_b = !(format_b.num_channels & 1); + bool alpha_a = ((format_a.num_channels & 1) == 0); + bool alpha_b = ((format_b.num_channels & 1) == 0); size_t bits_a = GetPrecision(format_a.data_type); size_t bits_b = GetPrecision(format_b.data_type); size_t bits = std::min(bits_a, bits_b); @@ -558,6 +567,34 @@ float ButteraugliDistance(const extras::PackedPixelFile& a, /*distmap=*/nullptr, pool); } +float ButteraugliDistance(const ImageBundle& rgb0, const ImageBundle& rgb1, + const ButteraugliParams& params, + const JxlCmsInterface& cms, ImageF* distmap, + ThreadPool* pool, bool ignore_alpha) { + JxlButteraugliComparator comparator(params, cms); + float distance; + JXL_CHECK(ComputeScore(rgb0, rgb1, &comparator, cms, &distance, distmap, pool, + ignore_alpha)); + return distance; +} + +float ButteraugliDistance(const std::vector& frames0, + const std::vector& frames1, + const ButteraugliParams& params, + const JxlCmsInterface& cms, ImageF* distmap, + ThreadPool* pool) { + JxlButteraugliComparator comparator(params, cms); + JXL_ASSERT(frames0.size() == frames1.size()); + float max_dist = 0.0f; + for (size_t i = 0; i < frames0.size(); ++i) { + float frame_score; + JXL_CHECK(ComputeScore(frames0[i], frames1[i], &comparator, cms, + &frame_score, distmap, pool)); + max_dist = std::max(max_dist, frame_score); + } + return max_dist; +} + float Butteraugli3Norm(const extras::PackedPixelFile& a, const extras::PackedPixelFile& b, ThreadPool* pool) { CodecInOut io0; @@ -683,7 +720,7 @@ Status ReadICC(BitReader* JXL_RESTRICT reader, PaddedBytes icc_buffer; JXL_RETURN_IF_ERROR(icc_reader.Init(reader, output_limit)); JXL_RETURN_IF_ERROR(icc_reader.Process(reader, &icc_buffer)); - Bytes(icc_buffer).AppendTo(icc); + Bytes(icc_buffer).AppendTo(*icc); return true; } @@ -787,7 +824,7 @@ Status EncodeFile(const CompressParams& params, const CodecInOut* io, } PaddedBytes output = std::move(writer).TakeBytes(); - Bytes(output).AppendTo(compressed); + Bytes(output).AppendTo(*compressed); return true; } diff --git a/third_party/jpeg-xl/lib/jxl/test_utils.h b/third_party/jpeg-xl/lib/jxl/test_utils.h index 6734380bf5..15057cc92d 100644 --- a/third_party/jpeg-xl/lib/jxl/test_utils.h +++ b/third_party/jpeg-xl/lib/jxl/test_utils.h @@ -18,13 +18,13 @@ #include #include -#include "lib/extras/dec/decode.h" #include "lib/extras/dec/jxl.h" #include "lib/extras/enc/jxl.h" #include "lib/extras/packed_image.h" #include "lib/jxl/base/data_parallel.h" #include "lib/jxl/base/span.h" #include "lib/jxl/base/status.h" +#include "lib/jxl/butteraugli/butteraugli.h" #include "lib/jxl/codec_in_out.h" #include "lib/jxl/color_encoding_internal.h" #include "lib/jxl/enc_params.h" @@ -63,9 +63,8 @@ void SetThreadParallelRunner(Params params, ThreadPool* pool) { } } -Status DecodeFile(extras::JXLDecompressParams dparams, - const Span file, CodecInOut* JXL_RESTRICT io, - ThreadPool* pool = nullptr); +Status DecodeFile(extras::JXLDecompressParams dparams, Span file, + CodecInOut* JXL_RESTRICT io, ThreadPool* pool = nullptr); bool Roundtrip(const CodecInOut* io, const CompressParams& cparams, extras::JXLDecompressParams dparams, @@ -74,7 +73,7 @@ bool Roundtrip(const CodecInOut* io, const CompressParams& cparams, // Returns compressed size [bytes]. size_t Roundtrip(const extras::PackedPixelFile& ppf_in, - extras::JXLCompressParams cparams, + const extras::JXLCompressParams& cparams, extras::JXLDecompressParams dparams, ThreadPool* pool, extras::PackedPixelFile* ppf_out); @@ -141,6 +140,18 @@ float ButteraugliDistance(const extras::PackedPixelFile& a, const extras::PackedPixelFile& b, ThreadPool* pool = nullptr); +float ButteraugliDistance(const ImageBundle& rgb0, const ImageBundle& rgb1, + const ButteraugliParams& params, + const JxlCmsInterface& cms, ImageF* distmap = nullptr, + ThreadPool* pool = nullptr, + bool ignore_alpha = false); + +float ButteraugliDistance(const std::vector& frames0, + const std::vector& frames1, + const ButteraugliParams& params, + const JxlCmsInterface& cms, ImageF* distmap = nullptr, + ThreadPool* pool = nullptr); + float Butteraugli3Norm(const extras::PackedPixelFile& a, const extras::PackedPixelFile& b, ThreadPool* pool = nullptr); @@ -169,6 +180,7 @@ class ThreadPoolForTests { } ThreadPoolForTests(const ThreadPoolForTests&) = delete; ThreadPoolForTests& operator&(const ThreadPoolForTests&) = delete; + // TODO(eustas): avoid unary `&` overload? ThreadPool* operator&() { return pool_.get(); } private: @@ -188,6 +200,8 @@ Status ReadICC(BitReader* JXL_RESTRICT reader, Status EncodeFile(const CompressParams& params, const CodecInOut* io, std::vector* compressed, ThreadPool* pool = nullptr); +constexpr const char* BoolToCStr(bool b) { return b ? "true" : "false"; } + } // namespace test bool operator==(const jxl::Bytes& a, const jxl::Bytes& b); diff --git a/third_party/jpeg-xl/lib/jxl/testing.h b/third_party/jpeg-xl/lib/jxl/testing.h index 5344399c4c..1fac352a78 100644 --- a/third_party/jpeg-xl/lib/jxl/testing.h +++ b/third_party/jpeg-xl/lib/jxl/testing.h @@ -6,15 +6,7 @@ #ifndef LIB_JXL_TESTING_H_ #define LIB_JXL_TESTING_H_ -// GTest/GMock specific macros / wrappers. - -// gmock unconditionally redefines those macros (to wrong values). -// Lets include it only here and mitigate the problem. -#pragma push_macro("PRIdS") -#pragma push_macro("PRIuS") -#include "gmock/gmock.h" -#pragma pop_macro("PRIuS") -#pragma pop_macro("PRIdS") +// GTest specific macros / wrappers. #include "gtest/gtest.h" // JPEGXL_ENABLE_BOXES, JPEGXL_ENABLE_TRANSCODE_JPEG @@ -60,9 +52,26 @@ // Ensures that we don't make our test bounds too lax, effectively disabling the // tests. -MATCHER_P(IsSlightlyBelow, max, "") { - return max * 0.75 <= arg && arg <= max * 1.0; -} +#define EXPECT_SLIGHTLY_BELOW(A, E) \ + { \ + double _actual = (A); \ + double _expected = (E); \ + EXPECT_LE(_actual, _expected); \ + EXPECT_GE(_actual, 0.75 * _expected); \ + } + +#define EXPECT_ARRAY_NEAR(A, E, T) \ + { \ + const auto _actual = (A); \ + const auto _expected = (E); \ + const auto _tolerance = (T); \ + size_t _n = _expected.size(); \ + ASSERT_EQ(_actual.size(), _n); \ + for (size_t _i = 0; _i < _n; ++_i) { \ + EXPECT_NEAR(_actual[_i], _expected[_i], _tolerance) \ + << "@" << _i << ": " << _actual[_i] << " !~= " << _expected[_i]; \ + } \ + } #define JXL_EXPECT_OK(F) \ { \ diff --git a/third_party/jpeg-xl/lib/jxl/toc.h b/third_party/jpeg-xl/lib/jxl/toc.h index 00006440b7..f5b9c65763 100644 --- a/third_party/jpeg-xl/lib/jxl/toc.h +++ b/third_party/jpeg-xl/lib/jxl/toc.h @@ -24,7 +24,7 @@ namespace jxl { constexpr U32Enc kTocDist(Bits(10), BitsOffset(14, 1024), BitsOffset(22, 17408), BitsOffset(30, 4211712)); -size_t MaxBits(const size_t num_sizes); +size_t MaxBits(size_t num_sizes); // TODO(veluca): move these to FrameDimensions. static JXL_INLINE size_t AcGroupIndex(size_t pass, size_t group, diff --git a/third_party/jpeg-xl/lib/jxl/transpose-inl.h b/third_party/jpeg-xl/lib/jxl/transpose-inl.h index 4674420737..efe7d90569 100644 --- a/third_party/jpeg-xl/lib/jxl/transpose-inl.h +++ b/third_party/jpeg-xl/lib/jxl/transpose-inl.h @@ -45,9 +45,9 @@ struct TransposeSimdTag {}; // TODO(veluca): it's not super useful to have this in the SIMD namespace. template -JXL_INLINE_TRANSPOSE void GenericTransposeBlock(TransposeSimdTag, - const From& from, const To& to, - size_t ROWSp, size_t COLSp) { +JXL_INLINE_TRANSPOSE void GenericTransposeBlock( + TransposeSimdTag /* tag */, const From& from, const To& to, + size_t ROWSp, size_t COLSp) { size_t ROWS = ROWS_or_0 == 0 ? ROWSp : ROWS_or_0; size_t COLS = COLS_or_0 == 0 ? COLSp : COLS_or_0; for (size_t n = 0; n < ROWS; ++n) { @@ -64,9 +64,9 @@ constexpr bool TransposeUseSimd(size_t ROWS, size_t COLS) { } template -JXL_INLINE_TRANSPOSE void GenericTransposeBlock(TransposeSimdTag, - const From& from, const To& to, - size_t ROWSp, size_t COLSp) { +JXL_INLINE_TRANSPOSE void GenericTransposeBlock( + TransposeSimdTag /* tag */, const From& from, const To& to, + size_t ROWSp, size_t COLSp) { size_t ROWS = ROWS_or_0 == 0 ? ROWSp : ROWS_or_0; size_t COLS = COLS_or_0 == 0 ? COLSp : COLS_or_0; static_assert(MaxLanes(BlockDesc<8>()) == 8, "Invalid descriptor size"); @@ -128,9 +128,9 @@ constexpr bool TransposeUseSimd(size_t ROWS, size_t COLS) { } template -JXL_INLINE_TRANSPOSE void GenericTransposeBlock(TransposeSimdTag, - const From& from, const To& to, - size_t ROWSp, size_t COLSp) { +JXL_INLINE_TRANSPOSE void GenericTransposeBlock( + TransposeSimdTag /* tag */, const From& from, const To& to, + size_t ROWSp, size_t COLSp) { size_t ROWS = ROWS_or_0 == 0 ? ROWSp : ROWS_or_0; size_t COLS = COLS_or_0 == 0 ? COLSp : COLS_or_0; static_assert(MaxLanes(BlockDesc<4>()) == 4, "Invalid descriptor size"); diff --git a/third_party/jpeg-xl/lib/jxl/version.h.in b/third_party/jpeg-xl/lib/jxl/version.h.in index d077abec79..ad1eb24409 100644 --- a/third_party/jpeg-xl/lib/jxl/version.h.in +++ b/third_party/jpeg-xl/lib/jxl/version.h.in @@ -29,7 +29,7 @@ * #endif * @endcode */ -#define JPEGXL_COMPUTE_NUMERIC_VERSION(major,minor,patch) ((major<<24) | (minor<<16) | (patch<<8) | 0) +#define JPEGXL_COMPUTE_NUMERIC_VERSION(major,minor,patch) (((major)<<24) | ((minor)<<16) | ((patch)<<8) | 0) /* Numeric representation of the version */ #define JPEGXL_NUMERIC_VERSION JPEGXL_COMPUTE_NUMERIC_VERSION(JPEGXL_MAJOR_VERSION,JPEGXL_MINOR_VERSION,JPEGXL_PATCH_VERSION) diff --git a/third_party/jpeg-xl/lib/jxl_cms.cmake b/third_party/jpeg-xl/lib/jxl_cms.cmake index 47757c8f3b..04980066c1 100644 --- a/third_party/jpeg-xl/lib/jxl_cms.cmake +++ b/third_party/jpeg-xl/lib/jxl_cms.cmake @@ -62,8 +62,10 @@ install(TARGETS jxl_cms if (BUILD_SHARED_LIBS) set(JPEGXL_REQUIRES_TYPE "Requires.private") + set(JPEGXL_CMS_PRIVATE_LIBS "-lm ${PKGCONFIG_CXX_LIB}") else() set(JPEGXL_REQUIRES_TYPE "Requires") + set(JPEGXL_CMS_PRIVATE_LIBS "-lm ${PKGCONFIG_CXX_LIB}") endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/jxl/libjxl_cms.pc.in" diff --git a/third_party/jpeg-xl/lib/jxl_lists.bzl b/third_party/jpeg-xl/lib/jxl_lists.bzl index bbbc444b36..6c98ca15ed 100644 --- a/third_party/jpeg-xl/lib/jxl_lists.bzl +++ b/third_party/jpeg-xl/lib/jxl_lists.bzl @@ -188,8 +188,6 @@ libjxl_dec_sources = [ "jxl/epf.cc", "jxl/epf.h", "jxl/fast_dct-inl.h", - "jxl/fast_dct.cc", - "jxl/fast_dct.h", "jxl/fast_dct128-inl.h", "jxl/fast_dct16-inl.h", "jxl/fast_dct256-inl.h", @@ -216,6 +214,7 @@ libjxl_dec_sources = [ "jxl/image_bundle.h", "jxl/image_metadata.cc", "jxl/image_metadata.h", + "jxl/image_ops.cc", "jxl/image_ops.h", "jxl/inverse_mtf-inl.h", "jxl/lehmer_code.h", diff --git a/third_party/jpeg-xl/lib/jxl_lists.cmake b/third_party/jpeg-xl/lib/jxl_lists.cmake index e6bf4e5e22..d1a56f9ca8 100644 --- a/third_party/jpeg-xl/lib/jxl_lists.cmake +++ b/third_party/jpeg-xl/lib/jxl_lists.cmake @@ -185,8 +185,6 @@ set(JPEGXL_INTERNAL_DEC_SOURCES jxl/epf.cc jxl/epf.h jxl/fast_dct-inl.h - jxl/fast_dct.cc - jxl/fast_dct.h jxl/fast_dct128-inl.h jxl/fast_dct16-inl.h jxl/fast_dct256-inl.h @@ -213,6 +211,7 @@ set(JPEGXL_INTERNAL_DEC_SOURCES jxl/image_bundle.h jxl/image_metadata.cc jxl/image_metadata.h + jxl/image_ops.cc jxl/image_ops.h jxl/inverse_mtf-inl.h jxl/lehmer_code.h diff --git a/third_party/jpeg-xl/lib/jxl_tests.cmake b/third_party/jpeg-xl/lib/jxl_tests.cmake index eec4149fba..64f807cb82 100644 --- a/third_party/jpeg-xl/lib/jxl_tests.cmake +++ b/third_party/jpeg-xl/lib/jxl_tests.cmake @@ -76,7 +76,6 @@ foreach (TESTFILE IN LISTS JPEGXL_INTERNAL_TESTS) ${JPEGXL_COVERAGE_FLAGS} ) target_link_libraries(${TESTNAME} - gmock GTest::GTest GTest::Main jxl_testlib-internal diff --git a/third_party/jpeg-xl/lib/jxl_vars.bzl b/third_party/jpeg-xl/lib/jxl_vars.bzl index 2c8bccfdf2..fb00f6e34c 100644 --- a/third_party/jpeg-xl/lib/jxl_vars.bzl +++ b/third_party/jpeg-xl/lib/jxl_vars.bzl @@ -8,17 +8,18 @@ libjxl_root_package = "libjxl" libjxl_deps_brotli = ["@brotli//:brotlidec", "@brotli//:brotlienc"] -libjxl_deps_gif = ["@gif//:gif"] +libjxl_deps_exr = ["@openexr//:OpenEXR"] +libjxl_deps_gif = ["@giflib//:giflib"] libjxl_deps_gtest = ["@googletest//:gtest_main"] libjxl_deps_hwy = ["@highway//:hwy"] libjxl_deps_hwy_nanobenchmark = ["@highway//:nanobenchmark"] libjxl_deps_hwy_test_util = ["@highway//:hwy_test_util"] libjxl_deps_jpeg = ["@libjpeg_turbo//:jpeg"] -libjxl_deps_exr = ["@openexr//:OpenEXR"] libjxl_deps_png = ["@libpng//:png"] libjxl_deps_runfiles = ["@bazel_tools//tools/cpp/runfiles"] libjxl_deps_skcms = ["@skcms//:skcms"] libjxl_deps_testdata = ["//:testdata"] +libjxl_deps_webp = ["@libwebp//:webp"] libjxl_test_shards = { "jpegli/decode_api_test": 10, diff --git a/third_party/jpeg-xl/lib/nothing.cc b/third_party/jpeg-xl/lib/nothing.cc new file mode 100644 index 0000000000..e65f587da6 --- /dev/null +++ b/third_party/jpeg-xl/lib/nothing.cc @@ -0,0 +1,7 @@ +/* Copyright (c) the JPEG XL Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file. + */ + +// Nothing at all. Just a compilation unit. diff --git a/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc b/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc index d12947ce55..558c9dbe42 100644 --- a/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc +++ b/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc @@ -41,11 +41,13 @@ bool ThreadMemoryManagerInit(JxlMemoryManager* self, } else { memset(self, 0, sizeof(*self)); } - if (!self->alloc != !self->free) { + bool is_default_alloc = (self->alloc == nullptr); + bool is_default_free = (self->free == nullptr); + if (is_default_alloc != is_default_free) { return false; } - if (!self->alloc) self->alloc = ThreadMemoryManagerDefaultAlloc; - if (!self->free) self->free = ThreadMemoryManagerDefaultFree; + if (is_default_alloc) self->alloc = ThreadMemoryManagerDefaultAlloc; + if (is_default_free) self->free = ThreadMemoryManagerDefaultFree; return true; } @@ -57,7 +59,7 @@ void* ThreadMemoryManagerAlloc(const JxlMemoryManager* memory_manager, void ThreadMemoryManagerFree(const JxlMemoryManager* memory_manager, void* address) { - return memory_manager->free(memory_manager->opaque, address); + memory_manager->free(memory_manager->opaque, address); } } // namespace diff --git a/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc b/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc index 5f73d94897..7ffcb34428 100644 --- a/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc +++ b/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc @@ -6,6 +6,7 @@ #include "lib/threads/thread_parallel_runner_internal.h" #include +#include #include #include @@ -120,9 +121,9 @@ void ThreadParallelRunner::RunRange(ThreadParallelRunner* self, // because it avoids user-specified parameters. for (;;) { -#if 0 - // dynamic - const uint32_t my_size = std::max(num_tasks / (num_worker_threads * 4), 1); +#if JXL_FALSE + // dynamic + const uint32_t my_size = std::max(num_tasks / (num_worker_threads * 4), 1); #else // guided const uint32_t num_reserved = diff --git a/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.h b/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.h index 199a5f2a8b..5b28384bf0 100644 --- a/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.h +++ b/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.h @@ -132,8 +132,8 @@ class ThreadParallelRunner { // Attempts to reserve and perform some work from the global range of tasks, // which is encoded within "command". Returns after all tasks are reserved. - static void RunRange(ThreadParallelRunner* self, const WorkerCommand command, - const int thread); + static void RunRange(ThreadParallelRunner* self, WorkerCommand command, + int thread); static void ThreadFunc(ThreadParallelRunner* self, int thread); diff --git a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c index bafa57b167..6a0de0486b 100644 --- a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c +++ b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader-jxl.c @@ -331,9 +331,8 @@ static gboolean load_increment(gpointer context, const guchar *buf, guint size, GError **error) { GdkPixbufJxlAnimation *decoder_state = context; if (decoder_state->done == TRUE) { - g_set_error(error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED, - "JXL decoder load_increment called after end of file"); - return FALSE; + g_warning_once("Trailing data found at end of JXL file"); + return TRUE; } JxlDecoderStatus status; @@ -491,9 +490,8 @@ static gboolean load_increment(gpointer context, const guchar *buf, guint size, decoder_state->frames->len - 1) .data; decoder_state->pixel_format.align = gdk_pixbuf_get_rowstride(output); - guchar *dst = gdk_pixbuf_get_pixels(output); - size_t num_pixels = decoder_state->xsize * decoder_state->ysize; - size_t size = num_pixels * decoder_state->pixel_format.num_channels; + guint size; + guchar *dst = gdk_pixbuf_get_pixels_with_length(output, &size); if (JXL_DEC_SUCCESS != JxlDecoderSetImageOutBuffer( decoder_state->decoder, &decoder_state->pixel_format, dst, size)) { diff --git a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc index 5e5642d491..a2e5dc9703 100644 --- a/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc +++ b/third_party/jpeg-xl/plugins/gdk-pixbuf/pixbufloader_test.cc @@ -16,12 +16,13 @@ int main(int argc, char* argv[]) { const char* loaders_cache = argv[1]; const char* filename = argv[2]; - setenv("GDK_PIXBUF_MODULE_FILE", loaders_cache, true); + const int kDoOverwrite = 1; + setenv("GDK_PIXBUF_MODULE_FILE", loaders_cache, kDoOverwrite); // XDG_DATA_HOME is the path where we look for the mime cache. // XDG_DATA_DIRS directories are used in addition to XDG_DATA_HOME. - setenv("XDG_DATA_HOME", ".", true); - setenv("XDG_DATA_DIRS", "", true); + setenv("XDG_DATA_HOME", ".", kDoOverwrite); + setenv("XDG_DATA_DIRS", "", kDoOverwrite); if (!gdk_init_check(nullptr, nullptr)) { fprintf(stderr, "This test requires a DISPLAY\n"); diff --git a/third_party/jpeg-xl/plugins/gimp/common.cc b/third_party/jpeg-xl/plugins/gimp/common.cc index 1a884570cb..a40340aaca 100644 --- a/third_party/jpeg-xl/plugins/gimp/common.cc +++ b/third_party/jpeg-xl/plugins/gimp/common.cc @@ -15,13 +15,10 @@ JpegXlGimpProgress::JpegXlGimpProgress(const char *message) { } void JpegXlGimpProgress::update() { - gimp_progress_update((float)++cur_progress / (float)max_progress); - return; + gimp_progress_update(static_cast(++cur_progress) / + static_cast(max_progress)); } -void JpegXlGimpProgress::finished() { - gimp_progress_update(1.0); - return; -} +void JpegXlGimpProgress::finished() { gimp_progress_update(1.0); } } // namespace jxl diff --git a/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc b/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc index 4796c1708c..07acd524d2 100644 --- a/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc +++ b/third_party/jpeg-xl/plugins/gimp/file-jxl-load.cc @@ -39,11 +39,14 @@ bool LoadJpegXlImage(const gchar *const filename, gint32 *const image_id) { GimpColorProfile *profile_icc = nullptr; GimpColorProfile *profile_int = nullptr; bool is_linear = false; - unsigned long xsize = 0, ysize = 0; - long crop_x0 = 0, crop_y0 = 0; + unsigned long xsize = 0; + unsigned long ysize = 0; + long crop_x0 = 0; + long crop_y0 = 0; size_t layer_idx = 0; uint32_t frame_duration = 0; - double tps_denom = 1.f, tps_numer = 1.f; + double tps_denom = 1.f; + double tps_numer = 1.f; gint32 layer; @@ -356,13 +359,13 @@ bool LoadJpegXlImage(const gchar *const filename, gint32 *const image_id) { const GString *blend_null_flag = g_string_new(""); const GString *blend_replace_flag = g_string_new(" (replace)"); const GString *blend_combine_flag = g_string_new(" (combine)"); - GString *blend; + const GString *blend; if (blend_mode == JXL_BLEND_REPLACE) { - blend = (GString *)blend_replace_flag; + blend = blend_replace_flag; } else if (blend_mode == JXL_BLEND_BLEND) { - blend = (GString *)blend_combine_flag; + blend = blend_combine_flag; } else { - blend = (GString *)blend_null_flag; + blend = blend_null_flag; } char *temp_frame_name = nullptr; bool must_free_frame_name = false; @@ -433,8 +436,10 @@ bool LoadJpegXlImage(const gchar *const filename, gint32 *const image_id) { " Warning: JxlDecoderGetFrameHeader: Unhandled blend mode: %d\n", blend_mode); } - if ((frame_name_len = frame_header.name_length) > 0) { - frame_name = (char *)realloc(frame_name, frame_name_len); + frame_name_len = frame_header.name_length; + if (frame_name_len > 0) { + frame_name = + reinterpret_cast(realloc(frame_name, frame_name_len)); if (JXL_DEC_SUCCESS != JxlDecoderGetFrameName(dec.get(), frame_name, frame_name_len)) { g_printerr(LOAD_PROC "Error: JxlDecoderGetFrameName failed"); diff --git a/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc b/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc index 45aaa1f8df..284a9f2771 100644 --- a/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc +++ b/third_party/jpeg-xl/plugins/gimp/file-jxl-save.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -229,7 +230,7 @@ bool JpegXlSaveGui::GuiOnChangeAdvancedMode(GtkWidget* toggle, gtk_widget_set_sensitive(self->frame_advanced, jxl_save_opts.advanced_mode); if (!jxl_save_opts.advanced_mode) { - jxl_save_opts.basic_info.uses_original_profile = false; + jxl_save_opts.basic_info.uses_original_profile = JXL_FALSE; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->toggle_no_xyb), false); jxl_save_opts.use_container = true; @@ -290,19 +291,20 @@ bool JpegXlSaveGui::SaveDialog() { "\n\td\u00A0=\u00A03\tFair" "\n\td\u00A0=\u00A06\tPoor"; - entry_distance = (GtkAdjustment*)gimp_scale_entry_new( - GTK_TABLE(table), 0, 0, "Distance", SCALE_WIDTH, 0, - jxl_save_opts.distance, 0.0, 15.0, 0.001, 1.0, 3, true, 0.0, 0.0, - distance_help, SAVE_PROC); - gimp_scale_entry_set_logarithmic((GtkObject*)entry_distance, true); + entry_distance = reinterpret_cast( + gimp_scale_entry_new(GTK_TABLE(table), 0, 0, "Distance", SCALE_WIDTH, 0, + jxl_save_opts.distance, 0.0, 15.0, 0.001, 1.0, 3, + true, 0.0, 0.0, distance_help, SAVE_PROC)); + gimp_scale_entry_set_logarithmic(reinterpret_cast(entry_distance), + true); // Quality Slider static gchar quality_help[] = "JPEG-style Quality is remapped to distance. " "Values roughly match libjpeg quality settings."; - entry_quality = (GtkAdjustment*)gimp_scale_entry_new( + entry_quality = reinterpret_cast(gimp_scale_entry_new( GTK_TABLE(table), 0, 1, "Quality", SCALE_WIDTH, 0, jxl_save_opts.quality, - 8.26, 100.0, 1.0, 10.0, 2, true, 0.0, 0.0, quality_help, SAVE_PROC); + 8.26, 100.0, 1.0, 10.0, 2, true, 0.0, 0.0, quality_help, SAVE_PROC)); // Distance and Quality Signals handle_entry_distance = g_signal_connect( @@ -322,10 +324,10 @@ bool JpegXlSaveGui::SaveDialog() { "the encoder uses less effort to hit distance targets. " "As\u00A0a\u00A0result, image quality may be decreased. " "Default\u00A0=\u00A03."; - entry_effort = (GtkAdjustment*)gimp_scale_entry_new( - GTK_TABLE(table), 0, 3, "Speed", SCALE_WIDTH, 0, - 10 - jxl_save_opts.encoding_effort, 1, 9, 1, 2, 0, true, 0.0, 0.0, - effort_help, SAVE_PROC); + entry_effort = reinterpret_cast( + gimp_scale_entry_new(GTK_TABLE(table), 0, 3, "Speed", SCALE_WIDTH, 0, + 10 - jxl_save_opts.encoding_effort, 1, 9, 1, 2, 0, + true, 0.0, 0.0, effort_help, SAVE_PROC)); // effort signal g_signal_connect(entry_effort, "value-changed", G_CALLBACK(GuiOnChangeEffort), @@ -415,10 +417,10 @@ bool JpegXlSaveGui::SaveDialog() { gtk_container_add(GTK_CONTAINER(vbox), table); gtk_widget_show(table); - entry_faster = (GtkAdjustment*)gimp_scale_entry_new( - GTK_TABLE(table), 0, 0, "Faster Decoding", SCALE_WIDTH, 0, - jxl_save_opts.faster_decoding, 0, 4, 1, 1, 0, true, 0.0, 0.0, faster_help, - SAVE_PROC); + entry_faster = reinterpret_cast( + gimp_scale_entry_new(GTK_TABLE(table), 0, 0, "Faster Decoding", + SCALE_WIDTH, 0, jxl_save_opts.faster_decoding, 0, 4, + 1, 1, 0, true, 0.0, 0.0, faster_help, SAVE_PROC)); // Faster Decoding Signals g_signal_connect(entry_faster, "value-changed", @@ -472,7 +474,6 @@ JpegXlSaveOpts::JpegXlSaveOpts() { pixel_format.align = 0; JxlEncoderInitBasicInfo(&basic_info); - return; } // JpegXlSaveOpts constructor bool JpegXlSaveOpts::SetModel(bool is_linear_) { @@ -568,7 +569,8 @@ bool JpegXlSaveOpts::SetNumChannels(int channels) { pixel_format.num_channels = 2; basic_info.num_color_channels = 1; basic_info.num_extra_channels = 1; - basic_info.alpha_bits = int(std::fmin(16, basic_info.bits_per_sample)); + basic_info.alpha_bits = + static_cast(std::fmin(16, basic_info.bits_per_sample)); basic_info.alpha_exponent_bits = 0; break; case 3: @@ -582,7 +584,8 @@ bool JpegXlSaveOpts::SetNumChannels(int channels) { pixel_format.num_channels = 4; basic_info.num_color_channels = 3; basic_info.num_extra_channels = 1; - basic_info.alpha_bits = int(std::fmin(16, basic_info.bits_per_sample)); + basic_info.alpha_bits = + static_cast(std::fmin(16, basic_info.bits_per_sample)); basic_info.alpha_exponent_bits = 0; break; default: @@ -698,7 +701,7 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, // treat layers as animation frames, for now if (nlayers > 1) { - jxl_save_opts.basic_info.have_animation = true; + jxl_save_opts.basic_info.have_animation = JXL_TRUE; jxl_save_opts.basic_info.animation.tps_numerator = 100; } @@ -738,12 +741,12 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, jxl_save_opts.icc_attached = true; } else { g_printerr(SAVE_PROC " Warning: JxlEncoderSetICCProfile failed.\n"); - jxl_save_opts.basic_info.uses_original_profile = false; + jxl_save_opts.basic_info.uses_original_profile = JXL_FALSE; jxl_save_opts.lossless = false; } } else { g_printerr(SAVE_PROC " Warning: Using internal profile.\n"); - jxl_save_opts.basic_info.uses_original_profile = false; + jxl_save_opts.basic_info.uses_original_profile = JXL_FALSE; jxl_save_opts.lossless = false; } @@ -751,9 +754,11 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, JxlColorEncoding color_encoding = {}; if (jxl_save_opts.is_linear) { - JxlColorEncodingSetToLinearSRGB(&color_encoding, jxl_save_opts.is_gray); + JxlColorEncodingSetToLinearSRGB(&color_encoding, + TO_JXL_BOOL(jxl_save_opts.is_gray)); } else { - JxlColorEncodingSetToSRGB(&color_encoding, jxl_save_opts.is_gray); + JxlColorEncodingSetToSRGB(&color_encoding, + TO_JXL_BOOL(jxl_save_opts.is_gray)); } if (JXL_ENC_SUCCESS != @@ -777,15 +782,15 @@ bool SaveJpegXlImage(const gint32 image_id, const gint32 drawable_id, // lossless mode doesn't work well with floating point jxl_save_opts.distance = 0.01; jxl_save_opts.lossless = false; - JxlEncoderSetFrameLossless(frame_settings, false); + JxlEncoderSetFrameLossless(frame_settings, JXL_FALSE); JxlEncoderSetFrameDistance(frame_settings, 0.01); } else { JxlEncoderSetFrameDistance(frame_settings, 0); - JxlEncoderSetFrameLossless(frame_settings, true); + JxlEncoderSetFrameLossless(frame_settings, JXL_TRUE); } } else { jxl_save_opts.lossless = false; - JxlEncoderSetFrameLossless(frame_settings, false); + JxlEncoderSetFrameLossless(frame_settings, JXL_FALSE); JxlEncoderSetFrameDistance(frame_settings, jxl_save_opts.distance); } diff --git a/third_party/jpeg-xl/plugins/mime/README.md b/third_party/jpeg-xl/plugins/mime/README.md index 4d398c7b90..6954a91e48 100644 --- a/third_party/jpeg-xl/plugins/mime/README.md +++ b/third_party/jpeg-xl/plugins/mime/README.md @@ -1,6 +1,6 @@ ## :warning: Not needed anymore -As `image/jxl` is now supported by [shared-mine-info 2.2](https://gitlab.freedesktop.org/xdg/shared-mime-info/-/releases/2.2), it should not be necessary anymore to install this plugin. +As `image/jxl` is now supported by [shared-mime-info 2.2](https://gitlab.freedesktop.org/xdg/shared-mime-info/-/releases/2.2), it should not be necessary anymore to install this plugin. You can test if your system correctly understand the MIME type of JPEG XL image by obtaining a JPEG XL image, e.g. with ```bash diff --git a/third_party/libwebrtc/BUILD.gn b/third_party/libwebrtc/BUILD.gn index 612483cef8..7feca08e60 100644 --- a/third_party/libwebrtc/BUILD.gn +++ b/third_party/libwebrtc/BUILD.gn @@ -509,6 +509,7 @@ if (!build_with_chromium) { deps = [ "api:create_peerconnection_factory", + "api:enable_media", "api:libjingle_peerconnection_api", "api:rtc_error", "api:transport_api", @@ -544,6 +545,7 @@ if (!build_with_chromium) { if (build_with_mozilla) { deps -= [ "api:create_peerconnection_factory", + "api:enable_media", "api:rtc_error", "api:transport_api", "api/crypto", @@ -657,6 +659,7 @@ if (rtc_include_tests && !build_with_chromium) { "p2p:libstunprober_unittests", "p2p:rtc_p2p_unittests", "rtc_base:async_dns_resolver_unittests", + "rtc_base:async_packet_socket_unittest", "rtc_base:callback_list_unittests", "rtc_base:rtc_base_approved_unittests", "rtc_base:rtc_base_unittests", @@ -850,10 +853,10 @@ rtc_static_library("dcsctp") { group("poison_audio_codecs") { } -group("poison_default_task_queue") { +group("poison_default_echo_detector") { } -group("poison_default_echo_detector") { +group("poison_environment_construction") { } group("poison_software_video_codecs") { diff --git a/third_party/libwebrtc/DEPS b/third_party/libwebrtc/DEPS index 0b5b97252c..0f25b04412 100644 --- a/third_party/libwebrtc/DEPS +++ b/third_party/libwebrtc/DEPS @@ -10,7 +10,7 @@ vars = { # chromium waterfalls. More info at: crbug.com/570091. 'checkout_configuration': 'default', 'checkout_instrumented_libraries': 'checkout_linux and checkout_configuration == "default"', - 'chromium_revision': 'c89d7a6d7f77a1afc1e3759f0e66a49eca1ee1d7', + 'chromium_revision': '60cf2ce5ba3417695d02754c90bd919eb438e4b5', # Fetch the prebuilt binaries for llvm-cov and llvm-profdata. Needed to # process the raw profiles produced by instrumented targets (built with @@ -25,14 +25,14 @@ vars = { # By default, download the fuchsia sdk from the public sdk directory. 'fuchsia_sdk_cipd_prefix': 'fuchsia/sdk/core/', - 'fuchsia_version': 'version:15.20231022.3.1', + 'fuchsia_version': 'version:16.20231129.1.1', # By default, download the fuchsia images from the fuchsia GCS bucket. 'fuchsia_images_bucket': 'fuchsia', 'checkout_fuchsia': False, # Since the images are hundreds of MB, default to only downloading the image # most commonly useful for developers. Bots and developers that need to use # other images can override this with additional images. - 'checkout_fuchsia_boot_images': "terminal.qemu-x64,terminal.x64", + 'checkout_fuchsia_boot_images': "terminal.x64", 'checkout_fuchsia_product_bundles': '"{checkout_fuchsia_boot_images}" != ""', # Fetch configuration files required for the 'use_remoteexec' gn arg @@ -40,7 +40,7 @@ vars = { # RBE instance to use for running remote builds 'rbe_instance': 'projects/rbe-webrtc-developer/instances/default_instance', # reclient CIPD package version - 'reclient_version': 're_client_version:0.117.1.21520c6-gomaip', + 'reclient_version': 're_client_version:0.121.0.e622934-gomaip', # ninja CIPD package version # https://chrome-infra-packages.appspot.com/p/infra/3pp/tools/ninja @@ -50,30 +50,30 @@ vars = { deps = { # TODO(kjellander): Move this to be Android-only. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@1546e3adb67bb711ca2fd39c3913cb56bd889748', + 'https://chromium.googlesource.com/chromium/src/base@f0b935140fa4d6c206b3419056f8e647ec7e6583', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@a21fc6065131d0442e8a54c3ca2638e393b69438', + 'https://chromium.googlesource.com/chromium/src/build@bb826aaf00833bb61244a7ab5c4ca8c69c51314a', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@6f834e2039daedfc68a2749c217922b26d5e8497', + 'https://chromium.googlesource.com/chromium/src/buildtools@b17c7e870e1d722d81f59738707392accf633011', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. 'src/examples/androidtests/third_party/gradle': { 'url': 'https://chromium.googlesource.com/external/github.com/gradle/gradle.git@f2d1fb54a951d8b11d25748e4711bec8d128d7e3', 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@5139a7efd464e4514a6df1054e44e0e4fac67536', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@f85ff5cfa70484822ca7181012597114ae7ad125', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@46366a7e4d08bf9fceeb3c1c3b5eab8a6a5024b5', + 'https://chromium.googlesource.com/chromium/src/testing@189d923e10bfcb856eff08164d6140f93938d854', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@64d9ec3158b4629163f88b779a53e16f1cc24f81', + 'https://chromium.googlesource.com/chromium/src/third_party@c35e8a3c66aaeb31689af01f6ef63509504b68ff', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-${{arch}}', - 'version': 'git_revision:e4702d7409069c4f12d45ea7b7f0890717ca3f4b', + 'version': 'git_revision:7367b0df0a0aa25440303998d54045bda73935a5', } ], 'dep_type': 'cipd', @@ -83,7 +83,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:e4702d7409069c4f12d45ea7b7f0890717ca3f4b', + 'version': 'git_revision:7367b0df0a0aa25440303998d54045bda73935a5', } ], 'dep_type': 'cipd', @@ -93,7 +93,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:e4702d7409069c4f12d45ea7b7f0890717ca3f4b', + 'version': 'git_revision:7367b0df0a0aa25440303998d54045bda73935a5', } ], 'dep_type': 'cipd', @@ -115,11 +115,11 @@ deps = { 'src/third_party/clang-format/script': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/clang/tools/clang-format.git@e5337933f2951cacd3aeacd238ce4578163ca0b9', 'src/third_party/libc++/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@a429c26ae25c26a569ff12390d5f9be70c5e286b', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@0ad014cff4509d293e62d1d8c7ffd080bcb2f2d6', 'src/third_party/libc++abi/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@2ca9f38714b1465b9f55b5fbd0da5e4342811e2b', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@4cb5c2cefedc025433f81735bacbc0f773fdcd8f', 'src/third_party/libunwind/src': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@7686b5d38c69d14932abfb1c1a66ba56c78791ad', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@bbe2764382995e4ec9a8c26c50018afc9520ea4f', 'src/third_party/ninja': { 'packages': [ @@ -166,7 +166,18 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/bundletool', - 'version': 'xOeKyLIaK_RRHU0Qv0EdxTrRlq_22HAwoOr1xn5yoOcC', + 'version': 'XoK0RwIzanpFScg7dU_8th5zMvLgKvk7c_PmhZ5LSEQC', + }, + ], + 'condition': 'checkout_android', + 'dep_type': 'cipd', + }, + + 'src/third_party/aosp_dalvik': { + 'packages': [ + { + 'package': 'chromium/third_party/aosp_dalvik/linux-amd64', + 'version': 'version:2@13.0.0_r24.cr1', }, ], 'condition': 'checkout_android', @@ -174,11 +185,11 @@ deps = { }, 'src/third_party/boringssl/src': - 'https://boringssl.googlesource.com/boringssl.git@c38dc29860a72540eb2c4fdb8a8bfb27ef94ddf3', + 'https://boringssl.googlesource.com/boringssl.git@1b7fdbd9101dedc3e0aa3fcf4ff74eacddb34ecc', 'src/third_party/breakpad/breakpad': - 'https://chromium.googlesource.com/breakpad/breakpad.git@8988364bcddd9b194b0bf931c10bc125987330ed', + 'https://chromium.googlesource.com/breakpad/breakpad.git@f49c2f1a2023da0cb055874fba050563dfea57db', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@47efdb4b1428e549c58a6d6c2fa79c4a8ceaf9b4', + 'https://chromium.googlesource.com/catapult.git@ee967548fe6a699fc295d81bd05c8116bcaf5e7e', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -191,9 +202,9 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@9f3b33a275e7a5b19d8ce4aba7960d2a38858681', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@b5393e57bb81eb1b6fbecbd7f466abcb61d278b4', 'src/third_party/ffmpeg': - 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@e1ca3f06adec15150a171bc38f550058b4bbb23b', + 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@866768f35c2226f4c805844207fd11c049ebe962', 'src/third_party/flatbuffers/src': 'https://chromium.googlesource.com/external/github.com/google/flatbuffers.git@bcb9ef187628fe07514e57756d05e6a6296f7dc5', 'src/third_party/grpc/src': { @@ -205,9 +216,9 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@55d0287cfc31115760cb13caa346b407ef0c0ceb', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@8f255c89e14219ca2489043f699797ee106ec6e9', 'src/third_party/harfbuzz-ng/src': - 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@f26fd69d858642d76413b8f4068eaf9b57c40a5f', + 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@920c40cd43dd7b10b7ecba3d82a46f5fea88536f', 'src/third_party/google_benchmark/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/benchmark.git@b177433f3ee2513b1075140c723d73ab8901790f', }, @@ -256,7 +267,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/kotlin_stdlib', - 'version': 'ZwEhbBOU3zJ8iFzea34zthR0d1a1LlfSPjfsblxKbSgC', + 'version': 'QEHg036Jc2HWG4-ao7usl1QUexRidGFFSgqqWUpmK-YC', }, ], 'condition': 'checkout_android', @@ -267,7 +278,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/kotlinc', - 'version': '6Hdj5fkzcomS1cNTWnXoeTZj0wvCG4zdyLtZ23eK-U4C', + 'version': 'WKNG-_aQcnsBG-F7SS-yUGLlN9roxcWYt1K_8uw27zQC', }, ], 'condition': 'checkout_android', @@ -276,6 +287,8 @@ deps = { # Used for building libFuzzers (only supports Linux). 'src/third_party/libFuzzer/src': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/compiler-rt/lib/fuzzer.git@758bd21f103a501b362b1ca46fa8fcb692eaa303', + 'src/third_party/fuzztest/src': + 'https://chromium.googlesource.com/external/github.com/google/fuzztest.git@9e3dbc646516772c70f7a100be53967323d310cb', 'src/third_party/libjpeg_turbo': 'https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@9b894306ec3b28cea46e84c32b56773a98c483da', 'src/third_party/libsrtp': @@ -283,15 +296,15 @@ deps = { 'src/third_party/dav1d/libdav1d': 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@47107e384bd1dc25674acf04d000a8cdc6195234', 'src/third_party/libaom/source/libaom': - 'https://aomedia.googlesource.com/aom.git@1dbe1c7fae2456f91ccc79fecb919e9ffea0727a', + 'https://aomedia.googlesource.com/aom.git@af3d2a707b5a89d5ffc77260698230505d9bcd35', 'src/third_party/libunwindstack': { 'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@4dbfa0e8c844c8e243b297bc185e54a99ff94f9e', 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@cefa83de08a0851cc0b0edee8801cf860a3bc1ed', + 'https://android.googlesource.com/platform/external/perfetto.git@d8a8260e8a08b166547eecd5b6ffcbdb30421109', 'src/third_party/libvpx/source/libvpx': - 'https://chromium.googlesource.com/webm/libvpx.git@424723dc025ce451dab9568239a46b18d0919b4d', + 'https://chromium.googlesource.com/webm/libvpx.git@741b8f6228984e888c99849d7675ea4132eaf268', 'src/third_party/libyuv': 'https://chromium.googlesource.com/libyuv/libyuv.git@04821d1e7d60845525e8db55c7bcd41ef5be9406', 'src/third_party/lss': { @@ -310,11 +323,15 @@ deps = { 'src/third_party/openh264/src': 'https://chromium.googlesource.com/external/github.com/cisco/openh264@09a4f3ec842a8932341b195c5b01e141c8a16eb7', + + 'src/third_party/re2/src': + 'https://chromium.googlesource.com/external/github.com/google/re2.git@7e0c1a9e2417e70e5f0efc323267ac71d1fa0685', + 'src/third_party/r8': { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'jj098_uPn3EKB7YisD1VAQXkZWNtSa6Qxz3vpMQkPR4C', + 'version': 'wtFJRWzGTig_UR3UW82YW63l-sTznrAPEatq-o7zNqYC', }, ], 'condition': 'checkout_android', @@ -338,7 +355,7 @@ deps = { 'condition': 'checkout_android', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@d7f60c3fd236aee6695f04187b6c128536a2bc9f', + 'https://chromium.googlesource.com/chromium/src/tools@bcc6c5bc9871bcf8842e6a42397939235fa04860', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -351,28 +368,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/byte_buddy': { - 'packages': [ - { - 'package': 'chromium/third_party/byte_buddy', - 'version': 'c9b53316603fc2d997c899c7ca1707f809b918cd', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/byte_buddy/android_sdk_build_tools_25_0_2': { - 'packages': [ - { - 'package': 'chromium/third_party/android_sdk/public/build-tools', - 'version': 'kwIs2vdfTm93yEP8LG5aSnchN4BVEdVxbqQtF4XpPdkC', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - 'src/third_party/espresso': { 'packages': [ { @@ -410,7 +405,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'F-habe4EUUBiRQmzyGAB5oOUtnTNQkhvpoUe4vVZuegC', + 'version': 'fBcslNfNCVI61lUhYka626dfmzui_5hT7AWrfFSdkgMC', }, ], 'condition': 'checkout_android', @@ -421,7 +416,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/manifest_merger', - 'version': 'V90mMwKNdDvQaZ-2eMjmdkHQdGrDn3w4DxA-fGMA8y0C', + 'version': 'SdNR04V227YL22FMmKoS4AdLYwv6MJe8HBAZKNhXoCsC', }, ], 'condition': 'checkout_android', @@ -438,10 +433,6 @@ deps = { 'package': 'chromium/third_party/android_sdk/public/emulator', 'version': '9lGp8nTUCRRWGMnI_96HcKfzjnxEJKUcfvfwmA3wXNkC', }, - { - 'package': 'chromium/third_party/android_sdk/public/patcher', - 'version': 'I6FNMhrXlpB-E1lOhMlvld7xt9lBVNOO83KIluXDyA0C', - }, { 'package': 'chromium/third_party/android_sdk/public/platform-tools', 'version': 'HWVsGs2HCKgSVv41FsOcsfJbNcB0UFiNrF6Tc4yRArYC', @@ -450,14 +441,6 @@ deps = { 'package': 'chromium/third_party/android_sdk/public/platforms/android-34', 'version': 'u-bhWbTME6u-DjypTgr3ZikCyeAeU6txkR9ET6Uudc8C', }, - { - 'package': 'chromium/third_party/android_sdk/public/platforms/android-tiramisuprivacysandbox', - 'version': 'YWMYkzyxGBgVsty0GhXL1oxbY0pGXQIgFc0Rh7ZMRPYC', - }, - { - 'package': 'chromium/third_party/android_sdk/public/sources/android-31', - 'version': '_a_BcnANjPYw5mSKlNHa7GFY8yc1kdqj2rmQgac7yUcC', - }, { 'package': 'chromium/third_party/android_sdk/public/cmdline-tools', 'version': 'Sy00LuyBIUJdRGYKwg0zjWH8eAIUvgnnNiPkI8etaZYC', @@ -515,7 +498,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/turbine', - 'version': 'VRQ9UNP0lvjDXJ4DhORCj66go0TLg5uuGnHWkNN_hgUC', + 'version': 'e8ccyNXO5wVjI0vv5W8kfA101BaaLNjNiVH1JddpdWkC', }, ], 'condition': 'checkout_android', @@ -526,11 +509,11 @@ deps = { 'packages': [ { 'package': 'infra/tools/luci/isolate/${{platform}}', - 'version': 'git_revision:924cfd2323a9192361b765f81fffc135026c1fee', + 'version': 'git_revision:1ea45c1829514ff20c476f083462e7b8fdfaf9ae', }, { 'package': 'infra/tools/luci/swarming/${{platform}}', - 'version': 'git_revision:924cfd2323a9192361b765f81fffc135026c1fee', + 'version': 'git_revision:1ea45c1829514ff20c476f083462e7b8fdfaf9ae', }, ], 'dep_type': 'cipd', @@ -1152,7 +1135,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_material_material', - 'version': 'version:2@1.7.0-alpha02.cr1', + 'version': 'version:2@1.11.0-beta01.cr1', }, ], 'condition': 'checkout_android', @@ -1218,7 +1201,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_auto_value_auto_value_annotations', - 'version': 'version:2@1.10.1.cr1', + 'version': 'version:2@1.10.4.cr1', }, ], 'condition': 'checkout_android', @@ -1295,7 +1278,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_annotation', - 'version': 'version:2@2.11.0.cr1', + 'version': 'version:2@2.19.1.cr1', }, ], 'condition': 'checkout_android', @@ -1515,7 +1498,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_guava_guava', - 'version': 'version:2@31.1-jre.cr1', + 'version': 'version:2@32.1.3-jre.cr1', }, ], 'condition': 'checkout_android', @@ -1526,18 +1509,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_guava_guava_android', - 'version': 'version:2@31.1-android.cr1', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/com_google_guava_listenablefuture': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_guava_listenablefuture', - 'version': 'version:2@1.0.cr1', + 'version': 'version:2@32.1.3-android.cr1', }, ], 'condition': 'checkout_android', @@ -1548,7 +1520,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_j2objc_j2objc_annotations', - 'version': 'version:2@1.3.cr1', + 'version': 'version:2@2.8.cr1', }, ], 'condition': 'checkout_android', @@ -1790,7 +1762,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_bouncycastle_bcprov_jdk18on', - 'version': 'version:2@1.72.cr1', + 'version': 'version:2@1.76.cr1', }, ], 'condition': 'checkout_android', @@ -1823,7 +1795,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_checker_qual', - 'version': 'version:2@3.25.0.cr1', + 'version': 'version:2@3.37.0.cr1', }, ], 'condition': 'checkout_android', @@ -2021,7 +1993,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm', - 'version': 'version:2@9.5.cr1', + 'version': 'version:2@9.6.cr1', }, ], 'condition': 'checkout_android', @@ -2032,7 +2004,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_analysis', - 'version': 'version:2@9.5.cr1', + 'version': 'version:2@9.6.cr1', }, ], 'condition': 'checkout_android', @@ -2043,7 +2015,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_commons', - 'version': 'version:2@9.5.cr1', + 'version': 'version:2@9.6.cr1', }, ], 'condition': 'checkout_android', @@ -2054,7 +2026,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_tree', - 'version': 'version:2@9.5.cr1', + 'version': 'version:2@9.6.cr1', }, ], 'condition': 'checkout_android', @@ -2065,7 +2037,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_util', - 'version': 'version:2@9.5.cr1', + 'version': 'version:2@9.6.cr1', }, ], 'condition': 'checkout_android', @@ -2087,7 +2059,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_annotations', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2098,7 +2070,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_junit', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2109,7 +2081,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_nativeruntime', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2120,7 +2092,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_nativeruntime_dist_compat', - 'version': 'version:2@1.0.1.cr1', + 'version': 'version:2@1.0.2.cr1', }, ], 'condition': 'checkout_android', @@ -2131,7 +2103,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_pluginapi', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2142,7 +2114,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_plugins_maven_dependency_resolver', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2153,7 +2125,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_resources', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2164,7 +2136,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_robolectric', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2175,7 +2147,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_sandbox', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2186,7 +2158,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadowapi', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2197,7 +2169,18 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_framework', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', + }, + ], + 'condition': 'checkout_android', + 'dep_type': 'cipd', + }, + + 'src/third_party/android_deps/libs/org_robolectric_shadows_versioning': { + 'packages': [ + { + 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_versioning', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2208,7 +2191,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', @@ -2219,7 +2202,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils_reflector', - 'version': 'version:2@4.10.3.cr1', + 'version': 'version:2@4.11.1.cr1', }, ], 'condition': 'checkout_android', diff --git a/third_party/libwebrtc/README.moz-ff-commit b/third_party/libwebrtc/README.moz-ff-commit index 90b20483fb..4a3b8c67ea 100644 --- a/third_party/libwebrtc/README.moz-ff-commit +++ b/third_party/libwebrtc/README.moz-ff-commit @@ -26853,3 +26853,840 @@ c3b7a50720 # MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh # base of lastest vendoring b0cc68e612 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +56d45b35f1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +783f1d850e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +51b93a5417 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e920073a68 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9682f4be7d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d6bac61b64 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +082cb56ee7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e8a2b3c834 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +86f09ae3f6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +cf2fe18daa +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3ee8117856 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d7fb7e4a5f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +93214073f1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7d1693f1c5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +766e658665 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +efeeba0864 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +554f7db01c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4f4ae8a8f9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8039cdbe48 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b78e6a9305 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a6ce338a2c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +166111da62 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7e21b0ca9d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9aa115358e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +78f905e5cc +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b29ff000da +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +779c9dede9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c68da75d04 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +414ffac4b7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +23cecc1d43 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d2098933e1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +37f5172f6e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c63120a092 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4fd1cc70da +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +97f3fb08a0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2931ddd2e9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4be5927dc7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +37df1c07b2 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +386873b7cc +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7fbcc8cef7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +99ea7c3eaa +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2bb48727a0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +24f1ff77e5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9272771418 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0873faae00 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2b58ec2938 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0a33589db1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +be04c98d64 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +eba274a63b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +5dbfe9621a +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7946be7429 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +bd523afd3a +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e925db88c1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +03457f6891 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +03bc3a0fa6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +795a2ca30f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ad9c4773f4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +644025c51f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4397482d71 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8ed4b4d314 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3e436d4ee4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +80056062f5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +977b56c9e9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +916ec25eed +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +bd396fdffa +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ce627d4f44 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d3414d9688 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +534374ad57 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0ece6706c8 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +698e0bec17 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +36ed560339 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3ea9fc4cd8 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2d43014acb +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +be23ea4bb9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +fa4d7c92b7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e567d8a112 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +6324919690 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +283a5fd7ec +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3e3881ae3c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +cc7861afb3 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +32052ed002 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +176eda9019 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7d62fe5702 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2baa7ae9e0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2d43ab8508 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b237f1be56 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1b4a91d8bb +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +dd45ab650e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f52faf2114 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +93ec8048b2 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +369111bf30 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0cb9b28e5b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9c69c4625b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d28b6fdf49 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +5820a7f6f6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +82cbbcc179 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +dfe62c8ad4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9f0d10b1f4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a6544377bc +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +393cc11ca1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9c91e48599 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d431156c0e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e75cd0c704 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9305b108bd +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2a33e0ae84 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8a99fdaed5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e76f837c8d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +5a6f022c93 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7d2e616968 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f268afd791 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1ae700a923 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +59eced6244 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +26e5a82ec7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +6f4e34472e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +25c2344b06 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d0ce0a69aa +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0552f8f7f6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +86944c40b3 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +117d847901 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +eb6106e9d0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8b54e37cac +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4ac371883e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +02ce5887b6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ebc4d3edd5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +12c502428d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9dac048f17 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ad44ceb52e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4cc7ff65c0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +68ea746993 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9c5ea7e64c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +6e8e4c43a5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +75a3ba216e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e5251ab6a8 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0c501a1302 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +72defe459b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b6d69708fe +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +496893e89e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d07900c848 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +db1d4281d4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +cf2e08b798 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +20724ae1b7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +6e956053b7 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +988179a4c3 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4e1e5eae9e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0967247662 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e35daf2978 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +35d3656ec6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ee80ad28c5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1568f1b133 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7e6315a619 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f0907c6f5b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2d86b258e0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c09cc4f961 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f124572ec0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +136d3b0df3 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a9d497b52d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0418e55761 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8f36855c6c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a37b29f3a9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f7cdcbd477 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c4f8eeb213 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +15b12dc96c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8acabc7039 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +6f72008cd6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a39206020c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +baaedc624e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f5ea66eea6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +572502c2ab +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2f7512819b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +502afbf510 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3a15ba6fbf +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7dd6ea234d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f1df16ceea +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d0269937a0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +08d81bd4ee +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0b78094234 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +14630a7e37 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e7b48a1e80 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0322493aed +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +518e181ab5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8dea465dfd +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +28ea9ba80d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +254e23071c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +84c016a024 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +23ac2c0133 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2e3a2a8392 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8c0f55857e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b803e851fc +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +15c04f98e9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7a841ce116 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +01859d41bf +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +e0ec125dae +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +cd42e347c1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +5116ad58b1 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +211daadb66 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2561dd307e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +92fcb56797 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b65913024f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +62aa821c2d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +5c9caa310b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1a5d474825 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +d0f0f38f72 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +264547d084 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f921d25320 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9fdceb80b5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a1a05e259d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +50a238fbd4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +abc5066bd9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +fa1e7d2bae +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7eaa9dc170 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9d9d03b3f9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b202bc1db2 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +357947f2f0 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3c5850148e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +680f103baa +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +db329edf40 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4b196371ab +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +75aa7e94dd +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +702820d087 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2798c2bfe6 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +09b2fb65da +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8490273226 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +69d1d3ec40 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +bac9ed1dcd +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +6417e7b721 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f99c355a75 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +96e14c82b9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +526187708d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ad3e66138d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +49c35d377b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2e3152654a +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +fc60c7836f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1a82d31cb5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ee46340054 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1131f24d2b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c534a94bf2 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8eeb8facb9 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7b4b29a13f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +59d0b8de33 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +13834cfacd +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3bdb49b483 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +4a2ea71a0f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +a5c8ee1672 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +530b243a1d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1939c43355 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +f665f7faf4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +924f716b7a +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +24510d43dc +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +b506d68f2a +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c0eac979ca +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3a530abb0e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3ff90f3580 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c03d8b6cf3 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +034120ea70 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +cd1bd57f5f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +5b11df789f +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8f530e8d78 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ad631f0d35 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +09aa812968 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +2ca1d0f809 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +032805068c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +1682a7f411 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +623bcd7daa +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +be02328f0e +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c925f50c1c +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +8f16ce98c2 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +fe66dda733 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9abc4865a4 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +7b5741c94d +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c176175f01 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9a2e32b9f2 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +c93f4f98a5 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +ece5cb8371 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +004a624023 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +9f1e1925f3 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +3df661f798 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +0f741da200 +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +79ba9b0b2b +# MOZ_LIBWEBRTC_SRC=/Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh +# base of lastest vendoring +6713461a2f diff --git a/third_party/libwebrtc/README.mozilla b/third_party/libwebrtc/README.mozilla index 40802a149a..655cb25566 100644 --- a/third_party/libwebrtc/README.mozilla +++ b/third_party/libwebrtc/README.mozilla @@ -17926,3 +17926,561 @@ libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-01-03T19:00:15.797265. # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-01-03T19:01:15.317447. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T19:44:55.905747. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T19:46:00.218563. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T19:47:00.554472. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T19:48:03.058947. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T19:49:07.378452. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T19:50:11.223493. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T20:14:48.156793. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:51:20.902176. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:53:06.976918. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:54:08.744534. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:55:13.713193. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:56:13.179594. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:57:15.505232. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:58:48.903961. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T22:59:54.059123. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T23:00:58.984053. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T23:19:35.877061. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-02T23:21:14.008453. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-07T16:54:34.731867. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-07T17:14:13.319492. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-07T17:15:43.952896. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-07T17:16:46.383099. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-07T17:18:16.542611. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-07T17:19:51.976286. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-08T14:05:27.919737. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-08T14:07:09.764953. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T20:30:40.483326. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T20:34:37.811983. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T20:35:42.451804. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T20:36:45.776017. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:03:27.507278. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:04:33.199342. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:06:12.178279. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:07:47.462618. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:09:24.487307. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:10:28.051579. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:11:34.384700. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:12:42.269503. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:13:48.443983. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:14:54.098587. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:15:57.458981. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:17:02.899884. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:18:04.109660. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:19:07.119444. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:20:07.820590. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:21:12.334777. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:22:21.225889. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:23:25.842835. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:24:30.353108. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:25:34.136165. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:26:41.125388. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:27:46.210328. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:28:51.881032. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:29:56.850952. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:31:07.072922. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:32:14.581346. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:33:15.921734. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:34:20.156659. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:35:25.608669. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:37:06.230592. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:38:10.130917. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:39:21.184661. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:40:34.458900. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:41:44.885527. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:42:48.110996. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:44:25.982264. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:45:26.028417. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:46:27.486850. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:47:30.570708. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:48:35.069291. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:50:12.044318. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:51:15.757430. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:52:22.840516. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:53:24.281023. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:54:29.104315. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:55:50.315392. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:56:56.308309. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:57:59.268469. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T21:59:01.465622. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:00:26.228912. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:01:31.179251. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:02:38.024425. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:03:53.673864. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:05:35.448595. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:06:38.082845. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:08:16.461695. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:09:19.597718. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:10:23.082366. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:11:28.732540. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:12:37.369857. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:13:41.929042. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:14:46.743557. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:16:02.359613. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:17:07.085453. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:18:12.974920. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:19:15.818173. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:20:57.910033. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:22:01.389791. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:23:07.163864. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:24:13.040228. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:25:16.187893. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:26:23.021272. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:28:04.537226. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:29:16.110238. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:30:22.802688. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:31:27.080327. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:32:31.787228. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:33:35.803190. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:34:43.250760. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:35:51.647400. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:56:38.527287. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:57:47.725151. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T22:58:50.386708. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T23:00:26.884209. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T23:01:28.874686. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T23:02:30.831910. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T23:03:34.052591. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T23:04:38.490163. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-09T23:05:40.553204. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T16:01:06.679978. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T16:02:16.128634. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T16:03:23.311677. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T16:05:01.742803. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T16:06:04.737338. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T16:07:45.746730. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:22:51.975611. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:23:52.833620. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:24:56.715603. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:26:00.310209. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:27:00.594852. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:28:03.070897. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:29:02.405355. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:30:04.659375. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:31:05.384516. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:32:08.881315. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:33:18.252033. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:34:21.783122. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:35:24.498277. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:37:03.791567. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:38:09.533883. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:39:48.752393. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:50:30.621653. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:51:50.774808. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:52:51.219018. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:53:53.946569. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:55:00.777858. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:56:07.745554. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:57:12.151550. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T17:58:18.944762. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:05:57.939568. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:07:34.720882. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:08:42.041512. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:10:21.702355. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:11:23.739544. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:12:24.626609. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:13:21.737726. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:14:23.269926. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:15:22.882396. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:16:21.928697. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:17:23.632655. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:18:26.350293. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:19:26.456307. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:20:26.466246. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:21:25.413538. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:22:26.115572. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:23:25.913622. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:24:27.037421. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:25:28.464175. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:26:34.740807. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:27:33.896142. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:28:34.845082. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:29:41.616614. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:30:45.923126. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:31:48.931338. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:32:48.261373. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:33:49.172661. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:34:51.240146. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:36:23.909708. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:37:57.381599. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:46:32.922731. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:47:32.390920. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:48:31.858797. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:49:37.383099. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:50:57.261186. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:52:03.681372. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:53:03.746754. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:54:03.690925. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:55:05.072694. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:56:34.420581. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:58:04.932566. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T18:59:05.555881. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:00:02.965760. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:01:14.107916. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:02:15.144558. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:03:19.471572. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:04:23.269430. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:05:24.629526. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:06:26.398447. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:07:28.902297. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:08:29.177907. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:09:30.301669. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:10:29.786641. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:11:30.859152. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:12:33.101461. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:14:05.732783. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:15:36.859926. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:16:39.272510. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:17:39.373346. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:18:41.661121. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:19:47.115457. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:21:17.270156. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:22:16.336640. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:23:28.993582. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T19:24:30.970337. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:32:08.538342. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:33:42.399359. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:34:50.675233. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:35:52.943079. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:37:26.872946. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:38:58.467500. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:40:00.943671. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:41:03.279379. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:42:04.436699. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:43:07.535471. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:44:07.891957. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:45:08.249396. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:46:40.800251. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:47:46.308158. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:48:48.273644. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:49:51.183686. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:50:54.851520. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:51:59.267702. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:53:03.386824. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:54:35.846993. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:55:42.595744. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:56:42.806910. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:57:42.568386. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:58:45.401496. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T21:59:49.225676. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:01:22.077332. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:02:25.351470. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:03:56.958382. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:05:26.681111. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:06:32.718403. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:08:07.441258. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:09:15.383300. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:10:18.957781. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:11:21.604091. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:33:14.259514. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:34:15.688491. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:35:19.870407. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:36:24.337450. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:37:27.076521. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:38:59.734968. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:40:03.492276. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:41:07.365560. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:42:10.815028. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:43:14.914049. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:44:20.092341. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:45:21.888312. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:46:50.576297. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:47:52.285966. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:48:55.690166. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:50:29.893614. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:51:31.146312. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:52:35.581207. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:53:42.375552. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:55:15.720276. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:56:16.127843. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:57:51.742036. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:58:51.252021. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T22:59:52.445909. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T23:01:26.358981. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T23:02:30.081484. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-10T23:04:03.473809. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-11T17:10:57.292037. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-11T17:12:06.916591. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-12T16:42:26.420193. +# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc +libwebrtc updated from /Users/jan-ivar/moz/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-02-12T16:43:32.839122. diff --git a/third_party/libwebrtc/api/BUILD.gn b/third_party/libwebrtc/api/BUILD.gn index d2b7f06c87..10a4c8c95f 100644 --- a/third_party/libwebrtc/api/BUILD.gn +++ b/third_party/libwebrtc/api/BUILD.gn @@ -35,21 +35,62 @@ rtc_source_set("callfactory_api") { ] } +rtc_source_set("enable_media") { + visibility = [ "*" ] + sources = [ + "enable_media.cc", + "enable_media.h", + ] + deps = [ + ":libjingle_peerconnection_api", + "../call", + "../media:rtc_audio_video", + "../pc:media_factory", + "../rtc_base/system:rtc_export", + "environment", + ] + if (build_with_mozilla) { + deps -= [ "../pc:media_factory" ] + } +} + +rtc_source_set("enable_media_with_defaults") { + visibility = [ "*" ] + allow_poison = [ + "audio_codecs", + "environment_construction", + "software_video_codecs", + ] + sources = [ + "enable_media_with_defaults.cc", + "enable_media_with_defaults.h", + ] + deps = [ + ":enable_media", + ":libjingle_peerconnection_api", + "../modules/audio_processing:api", + "../rtc_base/system:rtc_export", + "audio_codecs:builtin_audio_decoder_factory", + "audio_codecs:builtin_audio_encoder_factory", + "task_queue:default_task_queue_factory", + "video_codecs:builtin_video_decoder_factory", + "video_codecs:builtin_video_encoder_factory", + ] +} + if (!build_with_chromium && !build_with_mozilla) { rtc_library("create_peerconnection_factory") { visibility = [ "*" ] - allow_poison = [ "default_task_queue" ] + allow_poison = [ "environment_construction" ] sources = [ "create_peerconnection_factory.cc", "create_peerconnection_factory.h", ] deps = [ - ":callfactory_api", + ":enable_media", ":libjingle_peerconnection_api", ":scoped_refptr", "../api/rtc_event_log:rtc_event_log_factory", - "../media:rtc_audio_video", - "../media:rtc_media_base", "../modules/audio_device:audio_device_api", "../modules/audio_processing:api", "../pc:peer_connection_factory", @@ -127,13 +168,14 @@ rtc_library("media_stream_interface") { deps = [ ":audio_options_api", ":make_ref_counted", + ":ref_count", + ":ref_count", ":rtp_parameters", ":scoped_refptr", ":sequence_checker", ":video_track_source_constraints", "../modules/audio_processing:audio_processing_statistics", "../rtc_base:checks", - "../rtc_base:refcount", "../rtc_base/system:no_unique_address", "../rtc_base/system:rtc_export", "video:recordable_encoded_frame", @@ -181,9 +223,9 @@ rtc_source_set("ice_transport_interface") { deps = [ ":async_dns_resolver", ":packet_socket_factory", + ":ref_count", ":rtc_error", ":scoped_refptr", - "../rtc_base:refcount", "rtc_event_log:rtc_event_log", ] } @@ -201,9 +243,9 @@ if (!build_with_mozilla) { ] deps = [ ":ice_transport_interface", + ":ref_count", ":rtc_error", ":scoped_refptr", - "../rtc_base:refcount", "../rtc_base:ssl", "../rtc_base/system:rtc_export", ] @@ -217,7 +259,7 @@ rtc_library("dtmf_sender_interface") { sources = [ "dtmf_sender_interface.h" ] deps = [ ":media_stream_interface", - "../rtc_base:refcount", + ":ref_count", ] } @@ -237,11 +279,12 @@ if (!build_with_mozilla) { ":dtmf_sender_interface", ":frame_transformer_interface", ":media_stream_interface", + ":ref_count", + ":rtc_error", ":rtp_parameters", ":rtp_sender_setparameters_callback", ":scoped_refptr", "../rtc_base:checks", - "../rtc_base:refcount", "../rtc_base/system:rtc_export", "crypto:frame_encryptor_interface", "video_codecs:video_codecs_api", @@ -303,7 +346,6 @@ if (!build_with_mozilla) { ":array_view", ":async_dns_resolver", ":audio_options_api", - ":callfactory_api", ":candidate", ":dtls_transport_interface", ":fec_controller_api", @@ -317,6 +359,7 @@ if (!build_with_mozilla) { ":network_state_predictor_api", ":packet_socket_factory", ":priority", + ":ref_count", ":rtc_error", ":rtc_stats_api", ":rtp_packet_info", @@ -328,11 +371,11 @@ if (!build_with_mozilla) { ":turn_customizer", "../call:rtp_interfaces", "../p2p:rtc_p2p", + "../pc:media_factory", "../rtc_base:copy_on_write_buffer", "../rtc_base:logging", "../rtc_base:network", "../rtc_base:network_constants", - "../rtc_base:refcount", "../rtc_base:rtc_certificate_generator", "../rtc_base:ssl", "../rtc_base:stringutils", @@ -387,8 +430,8 @@ rtc_source_set("frame_transformer_interface") { sources = [ "frame_transformer_interface.h" ] deps = [ ":make_ref_counted", + ":ref_count", ":scoped_refptr", - "../rtc_base:refcount", "video:encoded_frame", "video:video_frame_metadata", ] @@ -414,15 +457,10 @@ rtc_library("rtc_error") { rtc_source_set("packet_socket_factory") { visibility = [ "*" ] - sources = [ - "async_resolver_factory.h", - "packet_socket_factory.h", - ] + sources = [ "packet_socket_factory.h" ] deps = [ ":async_dns_resolver", - ":wrapping_async_dns_resolver", "../rtc_base:async_packet_socket", - "../rtc_base:async_resolver_interface", "../rtc_base:proxy_info", "../rtc_base:socket_address", "../rtc_base/system:rtc_export", @@ -440,26 +478,9 @@ rtc_source_set("async_dns_resolver") { absl_deps = [ "//third_party/abseil-cpp/absl/functional:any_invocable" ] } -rtc_source_set("wrapping_async_dns_resolver") { - visibility = [ - ":*", - "../p2p:rtc_p2p", - ] - sources = [ - "wrapping_async_dns_resolver.cc", - "wrapping_async_dns_resolver.h", - ] - deps = [ - ":async_dns_resolver", - ":sequence_checker", - "../rtc_base:async_resolver_interface", - "../rtc_base:checks", - "../rtc_base:macromagic", - "../rtc_base:socket_address", - "../rtc_base:threading", - "../rtc_base/third_party/sigslot", - ] - absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] +rtc_source_set("ref_count") { + visibility = [ "*" ] + sources = [ "ref_count.h" ] } rtc_source_set("scoped_refptr") { @@ -470,7 +491,10 @@ rtc_source_set("scoped_refptr") { rtc_source_set("make_ref_counted") { visibility = [ "*" ] sources = [ "make_ref_counted.h" ] - deps = [ "../rtc_base:refcount" ] + deps = [ + ":ref_count", + "../rtc_base:refcount", + ] } rtc_source_set("video_quality_analyzer_api") { @@ -795,6 +819,7 @@ rtc_source_set("rtc_stats_api") { deps = [ ":make_ref_counted", + ":ref_count", ":scoped_refptr", "../api:refcountedbase", "../rtc_base:checks", @@ -927,6 +952,7 @@ rtc_source_set("refcountedbase") { visibility = [ "*" ] sources = [ "ref_counted_base.h" ] deps = [ + ":ref_count", "../rtc_base:macromagic", "../rtc_base:refcount", ] @@ -1052,24 +1078,6 @@ if (rtc_include_tests) { absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } - rtc_library("video_codec_stats_api") { - visibility = [ "*" ] - testonly = true - sources = [ - "test/video_codec_stats.cc", - "test/video_codec_stats.h", - ] - deps = [ - "../api/numerics:numerics", - "../api/units:data_rate", - "../api/units:data_size", - "../api/units:frequency", - "test/metrics:metric", - "test/metrics:metrics_logger", - ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] - } - rtc_library("videocodec_test_fixture_api") { visibility = [ "*" ] testonly = true @@ -1081,23 +1089,6 @@ if (rtc_include_tests) { ] } - rtc_library("video_codec_tester_api") { - visibility = [ "*" ] - testonly = true - sources = [ "test/video_codec_tester.h" ] - deps = [ - ":video_codec_stats_api", - "../modules/video_coding/svc:scalability_mode_util", - "video:encoded_image", - "video:resolution", - "video:video_frame", - ] - absl_deps = [ - "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/types:optional", - ] - } - rtc_library("create_videocodec_test_fixture_api") { visibility = [ "*" ] testonly = true @@ -1113,19 +1104,6 @@ if (rtc_include_tests) { ] } - rtc_library("create_video_codec_tester_api") { - visibility = [ "*" ] - testonly = true - sources = [ - "test/create_video_codec_tester.cc", - "test/create_video_codec_tester.h", - ] - deps = [ - ":video_codec_tester_api", - "../modules/video_coding:video_codec_tester", - ] - } - rtc_source_set("mock_audio_mixer") { visibility = [ "*" ] testonly = true @@ -1227,6 +1205,7 @@ if (rtc_include_tests) { ":array_view", ":libjingle_peerconnection_api", ":make_ref_counted", + ":ref_count", ":rtp_parameters", "../rtc_base:checks", "../rtc_base:refcount", @@ -1280,6 +1259,7 @@ if (rtc_include_tests) { deps = [ ":libjingle_peerconnection_api", + ":ref_count", "../api:scoped_refptr", "../rtc_base:refcount", "../test:test_support", @@ -1307,6 +1287,18 @@ if (rtc_include_tests) { ] } + rtc_source_set("mock_transformable_frame") { + visibility = [ "*" ] + testonly = true + sources = [ "test/mock_transformable_frame.h" ] + deps = [ + ":array_view", + ":frame_transformer_interface", + "../test:test_support", + "units:timestamp", + ] + } + rtc_source_set("mock_async_dns_resolver") { visibility = [ "*" ] testonly = true @@ -1420,6 +1412,7 @@ if (rtc_include_tests) { sources = [ "test/mock_video_track.h" ] deps = [ + ":ref_count", "../api:media_stream_interface", "../api:scoped_refptr", "../rtc_base:refcount", @@ -1436,13 +1429,19 @@ if (rtc_include_tests) { ] deps = [ - ":callfactory_api", + ":enable_media_with_defaults", + ":libjingle_peerconnection_api", ":time_controller", "../call", "../call:call_interfaces", "../call:rtp_interfaces", + "../pc:media_factory", + "../rtc_base:checks", + "../system_wrappers", "../test/time_controller", + "environment", ] + absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ] } rtc_library("rtc_api_unittests") { @@ -1492,6 +1491,7 @@ if (rtc_include_tests) { "../test:fileutils", "../test:rtc_expect_death", "../test:test_support", + "environment:environment_unittests", "task_queue:task_queue_default_factory_unittests", "test/pclf:media_configuration", "test/video:video_frame_writer", @@ -1531,6 +1531,7 @@ if (rtc_include_tests) { ":mock_rtp", ":mock_session_description_interface", ":mock_transformable_audio_frame", + ":mock_transformable_frame", ":mock_transformable_video_frame", ":mock_video_bitrate_allocator", ":mock_video_bitrate_allocator_factory", @@ -1600,10 +1601,10 @@ rtc_library("frame_transformer_factory") { ] deps = [ ":frame_transformer_interface", + ":ref_count", ":scoped_refptr", "../audio:audio", "../modules/rtp_rtcp", - "../rtc_base:refcount", "video:encoded_frame", "video:video_frame_metadata", ] diff --git a/third_party/libwebrtc/api/DEPS b/third_party/libwebrtc/api/DEPS index bcfd705741..3a650b6253 100644 --- a/third_party/libwebrtc/api/DEPS +++ b/third_party/libwebrtc/api/DEPS @@ -81,7 +81,6 @@ specific_include_rules = { "data_channel_interface\.h": [ "+rtc_base/copy_on_write_buffer.h", - "+rtc_base/ref_count.h", ], "data_channel_transport_interface\.h": [ @@ -89,33 +88,15 @@ specific_include_rules = { ], "dtls_transport_interface\.h": [ - "+rtc_base/ref_count.h", "+rtc_base/ssl_certificate.h", ], - "dtmf_sender_interface\.h": [ - "+rtc_base/ref_count.h", - ], - "fec_controller\.h": [ "+modules/include/module_fec_types.h", ], - "frame_transformer_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "ice_transport_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "jsep\.h": [ - "+rtc_base/ref_count.h", - ], - "media_stream_interface\.h": [ "+modules/audio_processing/include/audio_processing_statistics.h", - "+rtc_base/ref_count.h", ], "packet_socket_factory\.h": [ @@ -132,7 +113,6 @@ specific_include_rules = { "+rtc_base/network.h", "+rtc_base/network_constants.h", "+rtc_base/network_monitor_factory.h", - "+rtc_base/ref_count.h", "+rtc_base/rtc_certificate.h", "+rtc_base/rtc_certificate_generator.h", "+rtc_base/socket_address.h", @@ -148,7 +128,6 @@ specific_include_rules = { ], "ref_counted_base\.h": [ - "+rtc_base/ref_count.h", "+rtc_base/ref_counter.h", ], @@ -159,74 +138,19 @@ specific_include_rules = { # For private member and constructor. "+rtc_base/system/file_wrapper.h", ], - "rtp_receiver_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "rtp_sender_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "rtp_transceiver_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "sctp_transport_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "set_local_description_observer_interface\.h": [ - "+rtc_base/ref_count.h", - ], - "set_remote_description_observer_interface\.h": [ - "+rtc_base/ref_count.h", - ], "legacy_stats_types\.h": [ - "+rtc_base/ref_count.h", "+rtc_base/thread_checker.h", ], - "uma_metrics\.h": [ - "+rtc_base/ref_count.h", - ], - - "audio_mixer\.h": [ - "+rtc_base/ref_count.h", - ], - "audio_decoder\.h": [ "+rtc_base/buffer.h", ], - "audio_decoder_factory\.h": [ - "+rtc_base/ref_count.h", - ], - "audio_encoder\.h": [ "+rtc_base/buffer.h", ], - "audio_encoder_factory\.h": [ - "+rtc_base/ref_count.h", - ], - - "frame_decryptor_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "frame_encryptor_interface\.h": [ - "+rtc_base/ref_count.h", - ], - - "rtc_stats_collector_callback\.h": [ - "+rtc_base/ref_count.h", - ], - - "rtc_stats_report\.h": [ - "+rtc_base/ref_count.h", - ], - "audioproc_float\.h": [ "+modules/audio_processing/include/audio_processing.h", ], @@ -279,10 +203,6 @@ specific_include_rules = { "+modules/video_coding/include/video_codec_interface.h" ], - "video_encoder_config\.h": [ - "+rtc_base/ref_count.h", - ], - "sequence_checker\.h": [ "+rtc_base/synchronization/sequence_checker_internal.h", "+rtc_base/thread_annotations.h", diff --git a/third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build b/third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build index c06f943d1b..b0671b5d4a 100644 --- a/third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build +++ b/third_party/libwebrtc/api/adaptation/resource_adaptation_api_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/array_view_gn/moz.build b/third_party/libwebrtc/api/array_view_gn/moz.build index e89811c36f..e090bcdfc5 100644 --- a/third_party/libwebrtc/api/array_view_gn/moz.build +++ b/third_party/libwebrtc/api/array_view_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/async_dns_resolver_gn/moz.build b/third_party/libwebrtc/api/async_dns_resolver_gn/moz.build index 5e31fd1734..6a2d55b776 100644 --- a/third_party/libwebrtc/api/async_dns_resolver_gn/moz.build +++ b/third_party/libwebrtc/api/async_dns_resolver_gn/moz.build @@ -188,16 +188,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/async_resolver_factory.h b/third_party/libwebrtc/api/async_resolver_factory.h deleted file mode 100644 index 997fe5ce57..0000000000 --- a/third_party/libwebrtc/api/async_resolver_factory.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_ASYNC_RESOLVER_FACTORY_H_ -#define API_ASYNC_RESOLVER_FACTORY_H_ - -#include "rtc_base/async_resolver_interface.h" - -namespace webrtc { - -// An abstract factory for creating AsyncResolverInterfaces. This allows -// client applications to provide WebRTC with their own mechanism for -// performing DNS resolution. -// TODO(bugs.webrtc.org/12598): Deprecate and remove. -class [[deprecated("Use AsyncDnsResolverFactory")]] AsyncResolverFactory { - public: - AsyncResolverFactory() = default; - virtual ~AsyncResolverFactory() = default; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - // The caller should call Destroy on the returned object to delete it. - virtual rtc::AsyncResolverInterface* Create() = 0; -#pragma clang diagnostic pop -}; - -} // namespace webrtc - -#endif // API_ASYNC_RESOLVER_FACTORY_H_ diff --git a/third_party/libwebrtc/api/audio/aec3_config_gn/moz.build b/third_party/libwebrtc/api/audio/aec3_config_gn/moz.build index 4b96910919..ee6df1d36f 100644 --- a/third_party/libwebrtc/api/audio/aec3_config_gn/moz.build +++ b/third_party/libwebrtc/api/audio/aec3_config_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build b/third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build index de044719cc..0c3ce503ad 100644 --- a/third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build +++ b/third_party/libwebrtc/api/audio/aec3_factory_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build b/third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build index ca2c90ecfa..1317ad89b0 100644 --- a/third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build +++ b/third_party/libwebrtc/api/audio/audio_frame_api_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build b/third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build index 87847bb863..e04682bee3 100644 --- a/third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build +++ b/third_party/libwebrtc/api/audio/audio_frame_processor_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build b/third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build index 27baf1a796..c74637daa3 100644 --- a/third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build +++ b/third_party/libwebrtc/api/audio/audio_mixer_api_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio/echo_control_gn/moz.build b/third_party/libwebrtc/api/audio/echo_control_gn/moz.build index 6a5ce44f46..eb9e4ec669 100644 --- a/third_party/libwebrtc/api/audio/echo_control_gn/moz.build +++ b/third_party/libwebrtc/api/audio/echo_control_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/BUILD.gn b/third_party/libwebrtc/api/audio_codecs/BUILD.gn index 82ed31a5da..158ab74cce 100644 --- a/third_party/libwebrtc/api/audio_codecs/BUILD.gn +++ b/third_party/libwebrtc/api/audio_codecs/BUILD.gn @@ -32,6 +32,7 @@ rtc_library("audio_codecs_api") { "..:array_view", "..:bitrate_allocation", "..:make_ref_counted", + "..:ref_count", "..:scoped_refptr", "../../api:field_trials_view", "../../rtc_base:buffer", diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build index 9ab87e6a0e..9dcc9826de 100644 --- a/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_decoder_L16_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build index 0efa8c28a2..b5c7fe8b37 100644 --- a/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/L16/audio_encoder_L16_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build index 6c8b6b3b2b..8eaebf875c 100644 --- a/third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/audio_codecs_api_gn/moz.build @@ -198,7 +198,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -208,10 +207,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h b/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h index 2811f6704b..19b921a97f 100644 --- a/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h +++ b/third_party/libwebrtc/api/audio_codecs/audio_decoder_factory.h @@ -18,12 +18,12 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" -#include "rtc_base/ref_count.h" +#include "api/ref_count.h" namespace webrtc { // A factory that creates AudioDecoders. -class AudioDecoderFactory : public rtc::RefCountInterface { +class AudioDecoderFactory : public RefCountInterface { public: virtual std::vector GetSupportedDecoders() = 0; diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build index f64e3e3340..3ce5ad2d5d 100644 --- a/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_decoder_factory_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build index 6965c4298f..e8acc1186e 100644 --- a/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/builtin_audio_encoder_factory_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build index e0dcf8f032..2dbe0fd6bc 100644 --- a/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_decoder_g711_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build index 708744cf3b..a1b1f8e9fc 100644 --- a/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/g711/audio_encoder_g711_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build index 4b96ef2068..838977ba10 100644 --- a/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_decoder_g722_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build index bddf7d5571..2b1c0d220c 100644 --- a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_config_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build index e35ace4e0a..367caa077f 100644 --- a/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/g722/audio_encoder_g722_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build index 123ba8eb1c..b8bf808d3d 100644 --- a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_decoder_ilbc_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build index 843a9aee3b..909cc8c26f 100644 --- a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_config_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build index a01bbe78d5..08b426b9ab 100644 --- a/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/ilbc/audio_encoder_ilbc_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build index fec5701696..c36b4324e4 100644 --- a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_multiopus_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build index 41887d1871..a9896dd203 100644 --- a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_config_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build index 9c9bbb415b..7c7ed25cbc 100644 --- a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build index ec36454e9f..7a8b6dc2e6 100644 --- a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_multiopus_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build index 6c061ce58f..f68dce0d9d 100644 --- a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_config_gn/moz.build @@ -189,7 +189,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -199,10 +198,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build index b5c0f484ad..f44d8836ef 100644 --- a/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build +++ b/third_party/libwebrtc/api/audio_codecs/opus/audio_encoder_opus_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/audio_options_api_gn/moz.build b/third_party/libwebrtc/api/audio_options_api_gn/moz.build index f31b230650..5e169a3ffe 100644 --- a/third_party/libwebrtc/api/audio_options_api_gn/moz.build +++ b/third_party/libwebrtc/api/audio_options_api_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/bitrate_allocation_gn/moz.build b/third_party/libwebrtc/api/bitrate_allocation_gn/moz.build index dcf9b27ca3..530662eb2f 100644 --- a/third_party/libwebrtc/api/bitrate_allocation_gn/moz.build +++ b/third_party/libwebrtc/api/bitrate_allocation_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/call/call_factory_interface.h b/third_party/libwebrtc/api/call/call_factory_interface.h index fde8cba66e..db53d724a6 100644 --- a/third_party/libwebrtc/api/call/call_factory_interface.h +++ b/third_party/libwebrtc/api/call/call_factory_interface.h @@ -24,6 +24,9 @@ struct CallConfig; // This interface exists to allow webrtc to be optionally built without media // support (i.e., if only being used for data channels). PeerConnectionFactory // is constructed with a CallFactoryInterface, which may or may not be null. +// TODO(bugs.webrtc.org/15574): Delete this interface when +// `PeerConnectionFactoryDependencies::call_factory` is removed in favor of +// `PeerConnectionFactoryDependencies::media_factory`. class CallFactoryInterface { public: virtual ~CallFactoryInterface() = default; @@ -31,7 +34,9 @@ class CallFactoryInterface { virtual std::unique_ptr CreateCall(const CallConfig& config) = 0; }; -RTC_EXPORT std::unique_ptr CreateCallFactory(); +[[deprecated("bugs.webrtc.org/15574")]] // +RTC_EXPORT std::unique_ptr +CreateCallFactory(); } // namespace webrtc diff --git a/third_party/libwebrtc/api/call_api_gn/moz.build b/third_party/libwebrtc/api/call_api_gn/moz.build index 5c4a7f29a0..5656999ecb 100644 --- a/third_party/libwebrtc/api/call_api_gn/moz.build +++ b/third_party/libwebrtc/api/call_api_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/callfactory_api_gn/moz.build b/third_party/libwebrtc/api/callfactory_api_gn/moz.build index a671079943..157a34ec8e 100644 --- a/third_party/libwebrtc/api/callfactory_api_gn/moz.build +++ b/third_party/libwebrtc/api/callfactory_api_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/create_peerconnection_factory.cc b/third_party/libwebrtc/api/create_peerconnection_factory.cc index b7f9eb7f30..5d3aace05f 100644 --- a/third_party/libwebrtc/api/create_peerconnection_factory.cc +++ b/third_party/libwebrtc/api/create_peerconnection_factory.cc @@ -13,14 +13,12 @@ #include #include -#include "api/call/call_factory_interface.h" +#include "api/enable_media.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/transport/field_trial_based_config.h" -#include "media/base/media_engine.h" -#include "media/engine/webrtc_media_engine.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" #include "rtc_base/thread.h" @@ -38,8 +36,7 @@ rtc::scoped_refptr CreatePeerConnectionFactory( std::unique_ptr video_decoder_factory, rtc::scoped_refptr audio_mixer, rtc::scoped_refptr audio_processing, - AudioFrameProcessor* audio_frame_processor, - std::unique_ptr owned_audio_frame_processor, + std::unique_ptr audio_frame_processor, std::unique_ptr field_trials) { if (!field_trials) { field_trials = std::make_unique(); @@ -51,7 +48,6 @@ rtc::scoped_refptr CreatePeerConnectionFactory( dependencies.signaling_thread = signaling_thread; dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(field_trials.get()); - dependencies.call_factory = CreateCallFactory(); dependencies.event_log_factory = std::make_unique( dependencies.task_queue_factory.get()); dependencies.trials = std::move(field_trials); @@ -60,70 +56,21 @@ rtc::scoped_refptr CreatePeerConnectionFactory( // TODO(bugs.webrtc.org/13145): Add an rtc::SocketFactory* argument. dependencies.socket_factory = network_thread->socketserver(); } - cricket::MediaEngineDependencies media_dependencies; - media_dependencies.task_queue_factory = dependencies.task_queue_factory.get(); - media_dependencies.adm = std::move(default_adm); - media_dependencies.audio_encoder_factory = std::move(audio_encoder_factory); - media_dependencies.audio_decoder_factory = std::move(audio_decoder_factory); - if (audio_frame_processor) { - media_dependencies.audio_frame_processor = audio_frame_processor; - } else if (owned_audio_frame_processor) { - media_dependencies.owned_audio_frame_processor = - std::move(owned_audio_frame_processor); - } + dependencies.adm = std::move(default_adm); + dependencies.audio_encoder_factory = std::move(audio_encoder_factory); + dependencies.audio_decoder_factory = std::move(audio_decoder_factory); + dependencies.audio_frame_processor = std::move(audio_frame_processor); if (audio_processing) { - media_dependencies.audio_processing = std::move(audio_processing); + dependencies.audio_processing = std::move(audio_processing); } else { - media_dependencies.audio_processing = AudioProcessingBuilder().Create(); + dependencies.audio_processing = AudioProcessingBuilder().Create(); } - media_dependencies.audio_mixer = std::move(audio_mixer); - media_dependencies.video_encoder_factory = std::move(video_encoder_factory); - media_dependencies.video_decoder_factory = std::move(video_decoder_factory); - media_dependencies.trials = dependencies.trials.get(); - dependencies.media_engine = - cricket::CreateMediaEngine(std::move(media_dependencies)); + dependencies.audio_mixer = std::move(audio_mixer); + dependencies.video_encoder_factory = std::move(video_encoder_factory); + dependencies.video_decoder_factory = std::move(video_decoder_factory); + EnableMedia(dependencies); return CreateModularPeerConnectionFactory(std::move(dependencies)); } -rtc::scoped_refptr CreatePeerConnectionFactory( - rtc::Thread* network_thread, - rtc::Thread* worker_thread, - rtc::Thread* signaling_thread, - rtc::scoped_refptr default_adm, - rtc::scoped_refptr audio_encoder_factory, - rtc::scoped_refptr audio_decoder_factory, - std::unique_ptr video_encoder_factory, - std::unique_ptr video_decoder_factory, - rtc::scoped_refptr audio_mixer, - rtc::scoped_refptr audio_processing, - AudioFrameProcessor* audio_frame_processor) { - return CreatePeerConnectionFactory( - network_thread, worker_thread, signaling_thread, default_adm, - audio_encoder_factory, audio_decoder_factory, - std::move(video_encoder_factory), std::move(video_decoder_factory), - audio_mixer, audio_processing, audio_frame_processor, nullptr, nullptr); -} - -rtc::scoped_refptr CreatePeerConnectionFactory( - rtc::Thread* network_thread, - rtc::Thread* worker_thread, - rtc::Thread* signaling_thread, - rtc::scoped_refptr default_adm, - rtc::scoped_refptr audio_encoder_factory, - rtc::scoped_refptr audio_decoder_factory, - std::unique_ptr video_encoder_factory, - std::unique_ptr video_decoder_factory, - rtc::scoped_refptr audio_mixer, - rtc::scoped_refptr audio_processing, - std::unique_ptr owned_audio_frame_processor, - std::unique_ptr field_trials) { - return CreatePeerConnectionFactory( - network_thread, worker_thread, signaling_thread, default_adm, - audio_encoder_factory, audio_decoder_factory, - std::move(video_encoder_factory), std::move(video_decoder_factory), - audio_mixer, audio_processing, nullptr, - std::move(owned_audio_frame_processor), std::move(field_trials)); -} - } // namespace webrtc diff --git a/third_party/libwebrtc/api/create_peerconnection_factory.h b/third_party/libwebrtc/api/create_peerconnection_factory.h index f8f52a0869..d829bc19be 100644 --- a/third_party/libwebrtc/api/create_peerconnection_factory.h +++ b/third_party/libwebrtc/api/create_peerconnection_factory.h @@ -37,9 +37,6 @@ class AudioProcessing; // Create a new instance of PeerConnectionFactoryInterface with optional video // codec factories. These video factories represents all video codecs, i.e. no // extra internal video codecs will be added. -// TODO(bugs.webrtc.org/15111): -// Remove the method with the raw AudioFrameProcessor pointer in the -// follow-up. RTC_EXPORT rtc::scoped_refptr CreatePeerConnectionFactory( rtc::Thread* network_thread, @@ -52,21 +49,7 @@ CreatePeerConnectionFactory( std::unique_ptr video_decoder_factory, rtc::scoped_refptr audio_mixer, rtc::scoped_refptr audio_processing, - AudioFrameProcessor* audio_frame_processor = nullptr); - -RTC_EXPORT rtc::scoped_refptr -CreatePeerConnectionFactory( - rtc::Thread* network_thread, - rtc::Thread* worker_thread, - rtc::Thread* signaling_thread, - rtc::scoped_refptr default_adm, - rtc::scoped_refptr audio_encoder_factory, - rtc::scoped_refptr audio_decoder_factory, - std::unique_ptr video_encoder_factory, - std::unique_ptr video_decoder_factory, - rtc::scoped_refptr audio_mixer, - rtc::scoped_refptr audio_processing, - std::unique_ptr owned_audio_frame_processor, + std::unique_ptr audio_frame_processor = nullptr, std::unique_ptr field_trials = nullptr); } // namespace webrtc diff --git a/third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build b/third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build index 65794fbdd2..4147b3868b 100644 --- a/third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build +++ b/third_party/libwebrtc/api/crypto/frame_decryptor_interface_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build b/third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build index 19352a6da4..93034ef6e2 100644 --- a/third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build +++ b/third_party/libwebrtc/api/crypto/frame_encryptor_interface_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/crypto/options_gn/moz.build b/third_party/libwebrtc/api/crypto/options_gn/moz.build index 3219fce47f..9b5cca4f8b 100644 --- a/third_party/libwebrtc/api/crypto/options_gn/moz.build +++ b/third_party/libwebrtc/api/crypto/options_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/data_channel_interface.h b/third_party/libwebrtc/api/data_channel_interface.h index bf27c6c4f3..d2deace2e6 100644 --- a/third_party/libwebrtc/api/data_channel_interface.h +++ b/third_party/libwebrtc/api/data_channel_interface.h @@ -22,10 +22,10 @@ #include "absl/functional/any_invocable.h" #include "absl/types/optional.h" #include "api/priority.h" +#include "api/ref_count.h" #include "api/rtc_error.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -116,7 +116,7 @@ class DataChannelObserver { virtual ~DataChannelObserver() = default; }; -class RTC_EXPORT DataChannelInterface : public rtc::RefCountInterface { +class RTC_EXPORT DataChannelInterface : public RefCountInterface { public: // C++ version of: https://www.w3.org/TR/webrtc/#idl-def-rtcdatachannelstate // Unlikely to change, but keep in sync with DataChannel.java:State and diff --git a/third_party/libwebrtc/api/dtls_transport_interface.h b/third_party/libwebrtc/api/dtls_transport_interface.h index 7b0151249c..fe64fb1947 100644 --- a/third_party/libwebrtc/api/dtls_transport_interface.h +++ b/third_party/libwebrtc/api/dtls_transport_interface.h @@ -16,9 +16,9 @@ #include "absl/types/optional.h" #include "api/ice_transport_interface.h" +#include "api/ref_count.h" #include "api/rtc_error.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_count.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/system/rtc_export.h" @@ -107,7 +107,7 @@ class DtlsTransportObserverInterface { // accessed on that thread, except for functions explicitly marked otherwise. // References can be held by other threads, and destruction can therefore // be initiated by other threads. -class DtlsTransportInterface : public rtc::RefCountInterface { +class DtlsTransportInterface : public webrtc::RefCountInterface { public: // Returns a pointer to the ICE transport that is owned by the DTLS transport. virtual rtc::scoped_refptr ice_transport() = 0; diff --git a/third_party/libwebrtc/api/dtmf_sender_interface.h b/third_party/libwebrtc/api/dtmf_sender_interface.h index d63e66bbf7..4aed3382ed 100644 --- a/third_party/libwebrtc/api/dtmf_sender_interface.h +++ b/third_party/libwebrtc/api/dtmf_sender_interface.h @@ -14,7 +14,7 @@ #include #include "api/media_stream_interface.h" -#include "rtc_base/ref_count.h" +#include "api/ref_count.h" namespace webrtc { @@ -42,7 +42,7 @@ class DtmfSenderObserverInterface { // The interface of native implementation of the RTCDTMFSender defined by the // WebRTC W3C Editor's Draft. // See: https://www.w3.org/TR/webrtc/#peer-to-peer-dtmf -class DtmfSenderInterface : public rtc::RefCountInterface { +class DtmfSenderInterface : public webrtc::RefCountInterface { public: // Provides the spec compliant default 2 second delay for the ',' character. static const int kDtmfDefaultCommaDelayMs = 2000; diff --git a/third_party/libwebrtc/api/enable_media.cc b/third_party/libwebrtc/api/enable_media.cc new file mode 100644 index 0000000000..a05b1b328a --- /dev/null +++ b/third_party/libwebrtc/api/enable_media.cc @@ -0,0 +1,72 @@ +/* + * Copyright 2023 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "api/enable_media.h" + +#include +#include + +#include "api/environment/environment.h" +#include "api/peer_connection_interface.h" +#include "call/call_factory.h" +#include "media/engine/webrtc_media_engine.h" +#include "media/engine/webrtc_video_engine.h" +#include "media/engine/webrtc_voice_engine.h" +#include "pc/media_factory.h" + +namespace webrtc { +namespace { + +using ::cricket::CompositeMediaEngine; +using ::cricket::MediaEngineInterface; +using ::cricket::WebRtcVideoEngine; +using ::cricket::WebRtcVoiceEngine; + +class MediaFactoryImpl : public MediaFactory { + public: + MediaFactoryImpl() = default; + MediaFactoryImpl(const MediaFactoryImpl&) = delete; + MediaFactoryImpl& operator=(const MediaFactoryImpl&) = delete; + ~MediaFactoryImpl() override = default; + + std::unique_ptr CreateCall(const CallConfig& config) override { + CallFactory call_factory; + return static_cast(call_factory).CreateCall(config); + } + + std::unique_ptr CreateMediaEngine( + const Environment& env, + PeerConnectionFactoryDependencies& deps) override { + auto audio_engine = std::make_unique( + &env.task_queue_factory(), deps.adm.get(), + std::move(deps.audio_encoder_factory), + std::move(deps.audio_decoder_factory), std::move(deps.audio_mixer), + std::move(deps.audio_processing), std::move(deps.audio_frame_processor), + env.field_trials()); + auto video_engine = std::make_unique( + std::move(deps.video_encoder_factory), + std::move(deps.video_decoder_factory), env.field_trials()); + return std::make_unique(std::move(audio_engine), + std::move(video_engine)); + } +}; + +} // namespace + +void EnableMedia(PeerConnectionFactoryDependencies& deps) { + if (deps.media_factory != nullptr) { + // Do nothing if media is already enabled. Overwriting media_factory can be + // harmful when a different (e.g. test-only) implementation is used. + return; + } + deps.media_factory = std::make_unique(); +} + +} // namespace webrtc diff --git a/third_party/libwebrtc/api/enable_media.h b/third_party/libwebrtc/api/enable_media.h new file mode 100644 index 0000000000..85183963cf --- /dev/null +++ b/third_party/libwebrtc/api/enable_media.h @@ -0,0 +1,27 @@ +/* + * Copyright 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_ENABLE_MEDIA_H_ +#define API_ENABLE_MEDIA_H_ + +#include "api/peer_connection_interface.h" +#include "rtc_base/system/rtc_export.h" + +namespace webrtc { + +// Enables media support for PeerConnnectionFactory created from `deps` +// This function is located in its own build target to allow webrtc users that +// do not need any media to avoid linking media specific code and thus to reduce +// binary size. +RTC_EXPORT void EnableMedia(PeerConnectionFactoryDependencies& deps); + +} // namespace webrtc + +#endif // API_ENABLE_MEDIA_H_ diff --git a/third_party/libwebrtc/api/enable_media_with_defaults.cc b/third_party/libwebrtc/api/enable_media_with_defaults.cc new file mode 100644 index 0000000000..81462f703e --- /dev/null +++ b/third_party/libwebrtc/api/enable_media_with_defaults.cc @@ -0,0 +1,46 @@ +/* + * Copyright 2023 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "api/enable_media_with_defaults.h" + +#include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/enable_media.h" +#include "api/task_queue/default_task_queue_factory.h" +#include "api/video_codecs/builtin_video_decoder_factory.h" +#include "api/video_codecs/builtin_video_encoder_factory.h" +#include "modules/audio_processing/include/audio_processing.h" + +namespace webrtc { + +void EnableMediaWithDefaults(PeerConnectionFactoryDependencies& deps) { + if (deps.task_queue_factory == nullptr) { + deps.task_queue_factory = CreateDefaultTaskQueueFactory(); + } + if (deps.audio_encoder_factory == nullptr) { + deps.audio_encoder_factory = CreateBuiltinAudioEncoderFactory(); + } + if (deps.audio_decoder_factory == nullptr) { + deps.audio_decoder_factory = CreateBuiltinAudioDecoderFactory(); + } + if (deps.audio_processing == nullptr) { + deps.audio_processing = AudioProcessingBuilder().Create(); + } + + if (deps.video_encoder_factory == nullptr) { + deps.video_encoder_factory = CreateBuiltinVideoEncoderFactory(); + } + if (deps.video_decoder_factory == nullptr) { + deps.video_decoder_factory = CreateBuiltinVideoDecoderFactory(); + } + EnableMedia(deps); +} + +} // namespace webrtc diff --git a/third_party/libwebrtc/api/enable_media_with_defaults.h b/third_party/libwebrtc/api/enable_media_with_defaults.h new file mode 100644 index 0000000000..1b13a98fc9 --- /dev/null +++ b/third_party/libwebrtc/api/enable_media_with_defaults.h @@ -0,0 +1,28 @@ +/* + * Copyright 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_ENABLE_MEDIA_WITH_DEFAULTS_H_ +#define API_ENABLE_MEDIA_WITH_DEFAULTS_H_ + +#include "api/peer_connection_interface.h" +#include "rtc_base/system/rtc_export.h" + +namespace webrtc { + +// Fills unset media related dependencies in `deps` and enables media support +// for a PeerConnectionFactory created from `deps`. +// This function is located in its own build target as it pulls additional +// dependencies compared to `EnableMedia`, and thus may add extra binary size. +RTC_EXPORT void EnableMediaWithDefaults( + PeerConnectionFactoryDependencies& deps); + +} // namespace webrtc + +#endif // API_ENABLE_MEDIA_WITH_DEFAULTS_H_ diff --git a/third_party/libwebrtc/api/environment/BUILD.gn b/third_party/libwebrtc/api/environment/BUILD.gn new file mode 100644 index 0000000000..c2b73b327e --- /dev/null +++ b/third_party/libwebrtc/api/environment/BUILD.gn @@ -0,0 +1,63 @@ +# Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +import("../../webrtc.gni") + +rtc_source_set("environment") { + visibility = [ "*" ] + sources = [ "environment.h" ] + deps = [ + "..:refcountedbase", + "..:scoped_refptr", + "../../rtc_base/system:rtc_export", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ] +} + +rtc_library("environment_factory") { + visibility = [ "*" ] + poisonous = [ "environment_construction" ] + sources = [ + "environment_factory.cc", + "environment_factory.h", + ] + deps = [ + ":environment", + "..:make_ref_counted", + "..:refcountedbase", + "..:scoped_refptr", + "../../rtc_base:checks", + "../../rtc_base/system:rtc_export", + "../../system_wrappers", + "../rtc_event_log", + "../task_queue:default_task_queue_factory", + "../transport:field_trial_based_config", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ] +} + +if (rtc_include_tests) { + rtc_library("environment_unittests") { + testonly = true + sources = [ "environment_unittest.cc" ] + deps = [ + ":environment", + ":environment_factory", + "..:field_trials_view", + "../../system_wrappers", + "../../test:test_support", + "../rtc_event_log", + "../task_queue", + "../units:timestamp", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/functional:any_invocable", + "//third_party/abseil-cpp/absl/types:optional", + ] + } +} diff --git a/third_party/libwebrtc/api/environment/OWNERS b/third_party/libwebrtc/api/environment/OWNERS new file mode 100644 index 0000000000..a8af6b5b26 --- /dev/null +++ b/third_party/libwebrtc/api/environment/OWNERS @@ -0,0 +1,15 @@ +# Environment has a limited visibility for stronger control what utilities are +# exposed through it. +# Utilities exposed through environemnt +# - should be helpful for various WebRTC sub components. +# - should be thread safe. +# - should have a default implementation. +# - should provide functionality different to existing utilities in the +# environemnt. +# - should need at most one instance per peer connection. +set noparent +include ../../OWNERS_INFRA + +danilchap@webrtc.org +hta@webrtc.org +mbonadei@webrtc.org diff --git a/third_party/libwebrtc/api/environment/environment.h b/third_party/libwebrtc/api/environment/environment.h new file mode 100644 index 0000000000..d86b7ae780 --- /dev/null +++ b/third_party/libwebrtc/api/environment/environment.h @@ -0,0 +1,148 @@ +/* + * Copyright 2023 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +// This header file provides wrapper for common WebRTC utilities. +// Different application may need different implementations of these utilities, +// Moreover, single application may need to use WebRTC for multiple purposes, +// and thus would need to provide different utilities implementations for +// different peer connections. +// The main purpose of the `Environment` class below is to propagate references +// to those utilities to all WebRTC classes that need them. + +#ifndef API_ENVIRONMENT_ENVIRONMENT_H_ +#define API_ENVIRONMENT_ENVIRONMENT_H_ + +#include + +#include "absl/base/nullability.h" +#include "api/ref_counted_base.h" +#include "api/scoped_refptr.h" +#include "rtc_base/system/rtc_export.h" + +namespace webrtc { + +// These classes are forward declared to keep Environment dependencies +// lightweight. Users who need any of the types below should include their +// header explicitely. +class Clock; +class TaskQueueFactory; +class FieldTrialsView; +class RtcEventLog; + +// Contains references to WebRTC utilities. Object of this class should be +// passed as a construction parameter and saved by value in each class that +// needs it. Most classes shouldn't create a new instance of the `Environment`, +// but instead should use a propagated copy. +// Usually Environment should be the first parameter in a constructor or a +// factory, and the first member in the class. Keeping Environment as the first +// member in the class ensures utilities (e.g. clock) are still valid during +// destruction of other members. +// +// Example: +// class PeerConnection { +// public: +// PeerConnection(const Environment& env, ...) +// : env_(env), +// log_duration_on_destruction_(&env_.clock()), +// rtp_manager_(env_, ...), +// ... +// +// const FieldTrialsView& trials() const { return env_.field_trials(); } +// +// scoped_refptr AddTransceiver(...) { +// return make_ref_counted(env_, ...); +// } +// +// private: +// const Environment env_; +// Stats log_duration_on_destruction_; +// RtpTransmissionManager rtp_manager_; +// }; +// This class is thread safe. +class RTC_EXPORT Environment final { + public: + // Default constructor is deleted in favor of creating this object using + // `EnvironmentFactory`. To create the default environment use + // `EnvironmentFactory().Create()` or `CreateEnvironment()`. + Environment() = delete; + + Environment(const Environment&) = default; + Environment(Environment&&) = default; + Environment& operator=(const Environment&) = default; + Environment& operator=(Environment&&) = default; + + ~Environment() = default; + + // Provides means to alter behavior, mostly for A/B testing new features. + // See ../../g3doc/field-trials.md + const FieldTrialsView& field_trials() const; + + // Provides an interface to query current time. + // See ../../g3doc/implementation_basics.md#time + Clock& clock() const; + + // Provides a factory for task queues, WebRTC threading primitives. + // See ../../g3doc/implementation_basics.md#threads + TaskQueueFactory& task_queue_factory() const; + + // Provides an interface for collecting structured logs. + // See ../../logging/g3doc/rtc_event_log.md + RtcEventLog& event_log() const; + + private: + friend class EnvironmentFactory; + Environment(scoped_refptr storage, + absl::Nonnull field_trials, + absl::Nonnull clock, + absl::Nonnull task_queue_factory, + absl::Nonnull event_log) + : storage_(std::move(storage)), + field_trials_(field_trials), + clock_(clock), + task_queue_factory_(task_queue_factory), + event_log_(event_log) {} + + // Container that keeps ownership of the utilities below. + // Defining this as a RefCountedBase allows `Environment` to share this + // storage with another `Environment`, in particular allows `Environment` to + // be copyable. It is up to the `EnvironmentFactory` to provide an object that + // ensures references to utilties below are valid while object in the + // `storage_` is alive. + scoped_refptr storage_; + + absl::Nonnull field_trials_; + absl::Nonnull clock_; + absl::Nonnull task_queue_factory_; + absl::Nonnull event_log_; +}; + +//------------------------------------------------------------------------------ +// Implementation details follow +//------------------------------------------------------------------------------ + +inline const FieldTrialsView& Environment::field_trials() const { + return *field_trials_; +} + +inline Clock& Environment::clock() const { + return *clock_; +} + +inline TaskQueueFactory& Environment::task_queue_factory() const { + return *task_queue_factory_; +} + +inline RtcEventLog& Environment::event_log() const { + return *event_log_; +} + +} // namespace webrtc + +#endif // API_ENVIRONMENT_ENVIRONMENT_H_ diff --git a/third_party/libwebrtc/api/environment/environment_factory.cc b/third_party/libwebrtc/api/environment/environment_factory.cc new file mode 100644 index 0000000000..c0b681aa08 --- /dev/null +++ b/third_party/libwebrtc/api/environment/environment_factory.cc @@ -0,0 +1,123 @@ +/* + * Copyright 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "api/environment/environment_factory.h" + +#include +#include +#include + +#include "api/make_ref_counted.h" +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/task_queue/default_task_queue_factory.h" +#include "api/transport/field_trial_based_config.h" +#include "rtc_base/checks.h" +#include "system_wrappers/include/clock.h" + +namespace webrtc { +namespace { + +template +void Store(absl::Nonnull> value, + scoped_refptr& leaf) { + class StorageNode : public rtc::RefCountedBase { + public: + StorageNode(scoped_refptr parent, + absl::Nonnull> value) + : parent_(std::move(parent)), value_(std::move(value)) {} + + StorageNode(const StorageNode&) = delete; + StorageNode& operator=(const StorageNode&) = delete; + + ~StorageNode() override = default; + + private: + scoped_refptr parent_; + absl::Nonnull> value_; + }; + + // Utilities provided with ownership form a tree: + // Root is nullptr, each node keeps an ownership of one utility. + // Each child node has a link to the parent, but parent is unaware of its + // children. Each `EnvironmentFactory` and `Environment` keep a reference to a + // 'leaf_' - node with the last provided utility. This way `Environment` keeps + // ownership of a single branch of the storage tree with each used utiltity + // owned by one of the nodes on that branch. + leaf = rtc::make_ref_counted(std::move(leaf), std::move(value)); +} + +} // namespace + +EnvironmentFactory::EnvironmentFactory(const Environment& env) + : leaf_(env.storage_), + field_trials_(env.field_trials_), + clock_(env.clock_), + task_queue_factory_(env.task_queue_factory_), + event_log_(env.event_log_) {} + +void EnvironmentFactory::Set( + absl::Nullable> utility) { + if (utility != nullptr) { + field_trials_ = utility.get(); + Store(std::move(utility), leaf_); + } +} + +void EnvironmentFactory::Set(absl::Nullable> utility) { + if (utility != nullptr) { + clock_ = utility.get(); + Store(std::move(utility), leaf_); + } +} + +void EnvironmentFactory::Set( + absl::Nullable> utility) { + if (utility != nullptr) { + task_queue_factory_ = utility.get(); + Store(std::move(utility), leaf_); + } +} + +void EnvironmentFactory::Set( + absl::Nullable> utility) { + if (utility != nullptr) { + event_log_ = utility.get(); + Store(std::move(utility), leaf_); + } +} + +Environment EnvironmentFactory::CreateWithDefaults() && { + if (field_trials_ == nullptr) { + Set(std::make_unique()); + } + if (clock_ == nullptr) { + Set(Clock::GetRealTimeClock()); + } + if (task_queue_factory_ == nullptr) { + Set(CreateDefaultTaskQueueFactory(field_trials_)); + } + if (event_log_ == nullptr) { + Set(std::make_unique()); + } + + RTC_DCHECK(field_trials_ != nullptr); + RTC_DCHECK(clock_ != nullptr); + RTC_DCHECK(task_queue_factory_ != nullptr); + RTC_DCHECK(event_log_ != nullptr); + return Environment(std::move(leaf_), // + field_trials_, clock_, task_queue_factory_, event_log_); +} + +Environment EnvironmentFactory::Create() const { + // Create a temporary copy to avoid mutating `this` with default utilities. + return EnvironmentFactory(*this).CreateWithDefaults(); +} + +} // namespace webrtc diff --git a/third_party/libwebrtc/api/environment/environment_factory.h b/third_party/libwebrtc/api/environment/environment_factory.h new file mode 100644 index 0000000000..a0fc3effdb --- /dev/null +++ b/third_party/libwebrtc/api/environment/environment_factory.h @@ -0,0 +1,148 @@ +/* + * Copyright 2023 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_ENVIRONMENT_ENVIRONMENT_FACTORY_H_ +#define API_ENVIRONMENT_ENVIRONMENT_FACTORY_H_ + +#include +#include + +#include "absl/base/nullability.h" +#include "api/environment/environment.h" +#include "api/ref_counted_base.h" +#include "api/scoped_refptr.h" +#include "rtc_base/system/rtc_export.h" + +namespace webrtc { + +// These classes are forward declared to reduce amount of headers exposed +// through api header. +class Clock; +class TaskQueueFactory; +class FieldTrialsView; +class RtcEventLog; + +// Constructs `Environment`. +// Individual utilities are provided using one of the `Set` functions. +// `Set` functions do nothing when nullptr value is passed. +// Creates default implementations for utilities that are not provided. +// +// Examples: +// Environment default_env = EnvironmentFactory().Create(); +// +// EnvironmentFactory factory; +// factory.Set(std::make_unique()); +// factory.Set(std::make_unique()); +// Environment custom_env = factory.Create(); +// +class RTC_EXPORT EnvironmentFactory final { + public: + EnvironmentFactory() = default; + explicit EnvironmentFactory(const Environment& env); + + EnvironmentFactory(const EnvironmentFactory&) = default; + EnvironmentFactory(EnvironmentFactory&&) = default; + EnvironmentFactory& operator=(const EnvironmentFactory&) = default; + EnvironmentFactory& operator=(EnvironmentFactory&&) = default; + + ~EnvironmentFactory() = default; + + void Set(absl::Nullable> utility); + void Set(absl::Nullable> utility); + void Set(absl::Nullable> utility); + void Set(absl::Nullable> utility); + + void Set(absl::Nullable utility); + void Set(absl::Nullable utility); + void Set(absl::Nullable utility); + void Set(absl::Nullable utility); + + Environment Create() const; + + private: + Environment CreateWithDefaults() &&; + + scoped_refptr leaf_; + + absl::Nullable field_trials_ = nullptr; + absl::Nullable clock_ = nullptr; + absl::Nullable task_queue_factory_ = nullptr; + absl::Nullable event_log_ = nullptr; +}; + +// Helper for concise way to create an environment. +// `Environment env = CreateEnvironment(utility1, utility2)` is a shortcut to +// `EnvironmentFactory factory; +// factory.Set(utility1); +// factory.Set(utility2); +// Environment env = factory.Create();` +// +// Examples: +// Environment default_env = CreateEnvironment(); +// Environment custom_env = +// CreateEnvironment(std::make_unique(), +// std::make_unique()); +template +Environment CreateEnvironment(Utilities&&... utilities); + +//------------------------------------------------------------------------------ +// Implementation details follow +//------------------------------------------------------------------------------ + +inline void EnvironmentFactory::Set( + absl::Nullable utility) { + if (utility != nullptr) { + field_trials_ = utility; + } +} + +inline void EnvironmentFactory::Set(absl::Nullable utility) { + if (utility != nullptr) { + clock_ = utility; + } +} + +inline void EnvironmentFactory::Set(absl::Nullable utility) { + if (utility != nullptr) { + task_queue_factory_ = utility; + } +} + +inline void EnvironmentFactory::Set(absl::Nullable utility) { + if (utility != nullptr) { + event_log_ = utility; + } +} + +namespace webrtc_create_environment_internal { + +inline void Set(EnvironmentFactory& factory) {} + +template +void Set(EnvironmentFactory& factory, + FirstUtility&& first, + Utilities&&... utilities) { + factory.Set(std::forward(first)); + Set(factory, std::forward(utilities)...); +} + +} // namespace webrtc_create_environment_internal + +template +Environment CreateEnvironment(Utilities&&... utilities) { + EnvironmentFactory factory; + webrtc_create_environment_internal::Set( + factory, std::forward(utilities)...); + return factory.Create(); +} + +} // namespace webrtc + +#endif // API_ENVIRONMENT_ENVIRONMENT_FACTORY_H_ diff --git a/third_party/libwebrtc/api/environment/environment_gn/moz.build b/third_party/libwebrtc/api/environment/environment_gn/moz.build new file mode 100644 index 0000000000..e7105ff573 --- /dev/null +++ b/third_party/libwebrtc/api/environment/environment_gn/moz.build @@ -0,0 +1,198 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + + ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ### + ### DO NOT edit it by hand. ### + +COMPILE_FLAGS["OS_INCLUDES"] = [] +AllowCompilerWarnings() + +DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1" +DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True +DEFINES["RTC_ENABLE_VP9"] = True +DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0" +DEFINES["WEBRTC_LIBRARY_IMPL"] = True +DEFINES["WEBRTC_MOZILLA_BUILD"] = True +DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0" +DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0" + +FINAL_LIBRARY = "webrtc" + + +LOCAL_INCLUDES += [ + "!/ipc/ipdl/_ipdlheaders", + "!/third_party/libwebrtc/gen", + "/ipc/chromium/src", + "/third_party/libwebrtc/", + "/third_party/libwebrtc/third_party/abseil-cpp/", + "/tools/profiler/public" +] + +if not CONFIG["MOZ_DEBUG"]: + + DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0" + DEFINES["NDEBUG"] = True + DEFINES["NVALGRIND"] = True + +if CONFIG["MOZ_DEBUG"] == "1": + + DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1" + +if CONFIG["OS_TARGET"] == "Android": + + DEFINES["ANDROID"] = True + DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1" + DEFINES["HAVE_SYS_UIO_H"] = True + DEFINES["WEBRTC_ANDROID"] = True + DEFINES["WEBRTC_ANDROID_OPENSLES"] = True + DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True + DEFINES["WEBRTC_LINUX"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_GNU_SOURCE"] = True + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "Darwin": + + DEFINES["WEBRTC_MAC"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True + DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0" + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "Linux": + + DEFINES["USE_AURA"] = "1" + DEFINES["USE_GLIB"] = "1" + DEFINES["USE_NSS_CERTS"] = "1" + DEFINES["USE_OZONE"] = "1" + DEFINES["USE_UDEV"] = True + DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True + DEFINES["WEBRTC_LINUX"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + DEFINES["_LARGEFILE64_SOURCE"] = True + DEFINES["_LARGEFILE_SOURCE"] = True + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "OpenBSD": + + DEFINES["USE_GLIB"] = "1" + DEFINES["USE_OZONE"] = "1" + DEFINES["USE_X11"] = "1" + DEFINES["WEBRTC_BSD"] = True + DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + DEFINES["_LARGEFILE64_SOURCE"] = True + DEFINES["_LARGEFILE_SOURCE"] = True + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "WINNT": + + DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True + DEFINES["NOMINMAX"] = True + DEFINES["NTDDI_VERSION"] = "0x0A000000" + DEFINES["PSAPI_VERSION"] = "2" + DEFINES["RTC_ENABLE_WIN_WGC"] = True + DEFINES["UNICODE"] = True + DEFINES["USE_AURA"] = "1" + DEFINES["WEBRTC_WIN"] = True + DEFINES["WIN32"] = True + DEFINES["WIN32_LEAN_AND_MEAN"] = True + DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP" + DEFINES["WINVER"] = "0x0A00" + DEFINES["_ATL_NO_OPENGL"] = True + DEFINES["_CRT_RAND_S"] = True + DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True + DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True + DEFINES["_HAS_EXCEPTIONS"] = "0" + DEFINES["_HAS_NODISCARD"] = True + DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True + DEFINES["_SECURE_ATL"] = True + DEFINES["_UNICODE"] = True + DEFINES["_WIN32_WINNT"] = "0x0A00" + DEFINES["_WINDOWS"] = True + DEFINES["__STD_C"] = True + +if CONFIG["TARGET_CPU"] == "aarch64": + + DEFINES["WEBRTC_ARCH_ARM64"] = True + DEFINES["WEBRTC_HAS_NEON"] = True + +if CONFIG["TARGET_CPU"] == "arm": + + DEFINES["WEBRTC_ARCH_ARM"] = True + DEFINES["WEBRTC_ARCH_ARM_V7"] = True + DEFINES["WEBRTC_HAS_NEON"] = True + +if CONFIG["TARGET_CPU"] == "mips32": + + DEFINES["MIPS32_LE"] = True + DEFINES["MIPS_FPU_LE"] = True + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["TARGET_CPU"] == "mips64": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["TARGET_CPU"] == "x86": + + DEFINES["WEBRTC_ENABLE_AVX2"] = True + +if CONFIG["TARGET_CPU"] == "x86_64": + + DEFINES["WEBRTC_ENABLE_AVX2"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT": + + DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0" + +if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": + + DEFINES["USE_X11"] = "1" + +if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": + + OS_LIBS += [ + "unwind" + ] + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64": + + DEFINES["_GNU_SOURCE"] = True + +Library("environment_gn") diff --git a/third_party/libwebrtc/api/environment/environment_unittest.cc b/third_party/libwebrtc/api/environment/environment_unittest.cc new file mode 100644 index 0000000000..07bd8793bc --- /dev/null +++ b/third_party/libwebrtc/api/environment/environment_unittest.cc @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "api/environment/environment.h" + +#include +#include +#include +#include + +#include "absl/functional/any_invocable.h" +#include "absl/types/optional.h" +#include "api/environment/environment_factory.h" +#include "api/field_trials_view.h" +#include "api/rtc_event_log/rtc_event_log.h" +#include "api/task_queue/task_queue_factory.h" +#include "api/units/timestamp.h" +#include "system_wrappers/include/clock.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { +namespace { + +using ::testing::ElementsAre; +using ::testing::IsEmpty; +using ::testing::Not; +using ::testing::NotNull; +using ::testing::Ref; + +class FakeEvent : public RtcEvent { + public: + Type GetType() const override { return RtcEvent::Type::FakeEvent; } + bool IsConfigEvent() const override { return false; } +}; + +class FakeFieldTrials : public FieldTrialsView { + public: + explicit FakeFieldTrials(absl::AnyInvocable on_destroyed = nullptr) + : on_destroyed_(std::move(on_destroyed)) {} + ~FakeFieldTrials() override { + if (on_destroyed_ != nullptr) { + std::move(on_destroyed_)(); + } + } + + std::string Lookup(absl::string_view key) const override { return "fake"; } + + private: + absl::AnyInvocable on_destroyed_; +}; + +class FakeTaskQueueFactory : public TaskQueueFactory { + public: + explicit FakeTaskQueueFactory( + absl::AnyInvocable on_destroyed = nullptr) + : on_destroyed_(std::move(on_destroyed)) {} + ~FakeTaskQueueFactory() override { + if (on_destroyed_ != nullptr) { + std::move(on_destroyed_)(); + } + } + + std::unique_ptr CreateTaskQueue( + absl::string_view name, + Priority priority) const override { + return nullptr; + } + + private: + absl::AnyInvocable on_destroyed_; +}; + +TEST(EnvironmentTest, DefaultEnvironmentHasAllUtilities) { + Environment env = EnvironmentFactory().Create(); + + // Try to use each utility, expect no crashes. + env.clock().CurrentTime(); + EXPECT_THAT(env.task_queue_factory().CreateTaskQueue( + "test", TaskQueueFactory::Priority::NORMAL), + NotNull()); + env.event_log().Log(std::make_unique()); + env.field_trials().Lookup("WebRTC-Debugging-RtpDump"); +} + +TEST(EnvironmentTest, UsesProvidedUtilitiesWithOwnership) { + auto owned_field_trials = std::make_unique(); + auto owned_task_queue_factory = std::make_unique(); + auto owned_clock = std::make_unique(Timestamp::Zero()); + auto owned_event_log = std::make_unique(); + + FieldTrialsView& field_trials = *owned_field_trials; + TaskQueueFactory& task_queue_factory = *owned_task_queue_factory; + Clock& clock = *owned_clock; + RtcEventLog& event_log = *owned_event_log; + + Environment env = CreateEnvironment( + std::move(owned_field_trials), std::move(owned_clock), + std::move(owned_task_queue_factory), std::move(owned_event_log)); + + EXPECT_THAT(env.field_trials(), Ref(field_trials)); + EXPECT_THAT(env.task_queue_factory(), Ref(task_queue_factory)); + EXPECT_THAT(env.clock(), Ref(clock)); + EXPECT_THAT(env.event_log(), Ref(event_log)); +} + +TEST(EnvironmentTest, UsesProvidedUtilitiesWithoutOwnership) { + FakeFieldTrials field_trials; + FakeTaskQueueFactory task_queue_factory; + SimulatedClock clock(Timestamp::Zero()); + RtcEventLogNull event_log; + + Environment env = + CreateEnvironment(&field_trials, &clock, &task_queue_factory, &event_log); + + EXPECT_THAT(env.field_trials(), Ref(field_trials)); + EXPECT_THAT(env.task_queue_factory(), Ref(task_queue_factory)); + EXPECT_THAT(env.clock(), Ref(clock)); + EXPECT_THAT(env.event_log(), Ref(event_log)); +} + +TEST(EnvironmentTest, UsesLastProvidedUtility) { + auto owned_field_trials1 = std::make_unique(); + auto owned_field_trials2 = std::make_unique(); + FieldTrialsView& field_trials2 = *owned_field_trials2; + + Environment env = CreateEnvironment(std::move(owned_field_trials1), + std::move(owned_field_trials2)); + + EXPECT_THAT(env.field_trials(), Ref(field_trials2)); +} + +// Utilities can be provided from different sources, and when some source +// choose not to provide an utility, it is usually expressed with nullptr. +// When utility is not provided, it is natural to use previously set one. +// E.g. Both PeerConnectionFactoryDependencies and PeerConnectionDependencies +// provide field trials. When PeerConnectionDependencies::trials == nullptr, +// then trials from the PeerConnectionFactoryDependencies should be used. +// With nullptr accepted and ignored this can be expressed by +// `Environemt env = CreateEnvironment(pcf_deps.trials, pc_deps.trials);` +// That would use pc_deps.trials when not nullptr, pcf_deps.trials when +// pc_deps.trials is nullptr, but pcf_deps.trials is not, and default field +// trials when both are nullptr. +TEST(EnvironmentTest, IgnoresProvidedNullptrUtility) { + auto owned_field_trials = std::make_unique(); + std::unique_ptr null_field_trials = nullptr; + FieldTrialsView& field_trials = *owned_field_trials; + + Environment env = CreateEnvironment(std::move(owned_field_trials), + std::move(null_field_trials)); + + EXPECT_THAT(env.field_trials(), Ref(field_trials)); +} + +TEST(EnvironmentTest, KeepsUtilityAliveWhileEnvironmentIsAlive) { + bool utility_destroyed = false; + auto field_trials = std::make_unique( + /*on_destroyed=*/[&] { utility_destroyed = true; }); + + // Wrap Environment into optional to have explicit control when it is deleted. + absl::optional env = CreateEnvironment(std::move(field_trials)); + + EXPECT_FALSE(utility_destroyed); + env = absl::nullopt; + EXPECT_TRUE(utility_destroyed); +} + +TEST(EnvironmentTest, KeepsUtilityAliveWhileCopyOfEnvironmentIsAlive) { + bool utility_destroyed = false; + auto field_trials = std::make_unique( + /*on_destroyed=*/[&] { utility_destroyed = true; }); + + absl::optional env1 = CreateEnvironment(std::move(field_trials)); + absl::optional env2 = env1; + + EXPECT_FALSE(utility_destroyed); + env1 = absl::nullopt; + EXPECT_FALSE(utility_destroyed); + env2 = absl::nullopt; + EXPECT_TRUE(utility_destroyed); +} + +TEST(EnvironmentTest, FactoryCanBeReusedToCreateDifferentEnvironments) { + auto owned_task_queue_factory = std::make_unique(); + auto owned_field_trials1 = std::make_unique(); + auto owned_field_trials2 = std::make_unique(); + TaskQueueFactory& task_queue_factory = *owned_task_queue_factory; + FieldTrialsView& field_trials1 = *owned_field_trials1; + FieldTrialsView& field_trials2 = *owned_field_trials2; + + EnvironmentFactory factory; + factory.Set(std::move(owned_task_queue_factory)); + factory.Set(std::move(owned_field_trials1)); + Environment env1 = factory.Create(); + factory.Set(std::move(owned_field_trials2)); + Environment env2 = factory.Create(); + + // Environments share the same custom task queue factory. + EXPECT_THAT(env1.task_queue_factory(), Ref(task_queue_factory)); + EXPECT_THAT(env2.task_queue_factory(), Ref(task_queue_factory)); + + // Environments have different field trials. + EXPECT_THAT(env1.field_trials(), Ref(field_trials1)); + EXPECT_THAT(env2.field_trials(), Ref(field_trials2)); +} + +TEST(EnvironmentTest, FactoryCanCreateNewEnvironmentFromExistingOne) { + Environment env1 = + CreateEnvironment(std::make_unique()); + EnvironmentFactory factory(env1); + factory.Set(std::make_unique()); + Environment env2 = factory.Create(); + + // Environments share the same default clock. + EXPECT_THAT(env2.clock(), Ref(env1.clock())); + + // Environments share the same custom task queue factory. + EXPECT_THAT(env2.task_queue_factory(), Ref(env1.task_queue_factory())); + + // Environments have different field trials. + EXPECT_THAT(env2.field_trials(), Not(Ref(env1.field_trials()))); +} + +TEST(EnvironmentTest, KeepsOwnershipsWhenCreateNewEnvironmentFromExistingOne) { + bool utility1_destroyed = false; + bool utility2_destroyed = false; + absl::optional env1 = + CreateEnvironment(std::make_unique( + /*on_destroyed=*/[&] { utility1_destroyed = true; })); + + absl::optional factory = EnvironmentFactory(*env1); + + // Destroy env1, check utility1 it was using is still alive. + env1 = absl::nullopt; + EXPECT_FALSE(utility1_destroyed); + + factory->Set(std::make_unique( + /*on_destroyed=*/[&] { utility2_destroyed = true; })); + absl::optional env2 = factory->Create(); + + // Destroy the factory, check all utilities used by env2 are alive. + factory = absl::nullopt; + EXPECT_FALSE(utility1_destroyed); + EXPECT_FALSE(utility2_destroyed); + + // Once last Environment object is deleted, utilties should be deleted too. + env2 = absl::nullopt; + EXPECT_TRUE(utility1_destroyed); + EXPECT_TRUE(utility2_destroyed); +} + +TEST(EnvironmentTest, DestroysUtilitiesInReverseProvidedOrder) { + std::vector destroyed; + auto field_trials = std::make_unique( + /*on_destroyed=*/[&] { destroyed.push_back("field_trials"); }); + auto task_queue_factory = std::make_unique( + /*on_destroyed=*/[&] { destroyed.push_back("task_queue_factory"); }); + + absl::optional env = + CreateEnvironment(std::move(field_trials), std::move(task_queue_factory)); + + ASSERT_THAT(destroyed, IsEmpty()); + env = absl::nullopt; + EXPECT_THAT(destroyed, ElementsAre("task_queue_factory", "field_trials")); +} + +} // namespace +} // namespace webrtc diff --git a/third_party/libwebrtc/api/fec_controller_api_gn/moz.build b/third_party/libwebrtc/api/fec_controller_api_gn/moz.build index a0129cce5a..619ea937f0 100644 --- a/third_party/libwebrtc/api/fec_controller_api_gn/moz.build +++ b/third_party/libwebrtc/api/fec_controller_api_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/field_trials_registry_gn/moz.build b/third_party/libwebrtc/api/field_trials_registry_gn/moz.build index 5133134fc2..01ce20c5a6 100644 --- a/third_party/libwebrtc/api/field_trials_registry_gn/moz.build +++ b/third_party/libwebrtc/api/field_trials_registry_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/field_trials_view_gn/moz.build b/third_party/libwebrtc/api/field_trials_view_gn/moz.build index 0e5ed09f70..967e416aad 100644 --- a/third_party/libwebrtc/api/field_trials_view_gn/moz.build +++ b/third_party/libwebrtc/api/field_trials_view_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/frame_transformer_interface.h b/third_party/libwebrtc/api/frame_transformer_interface.h index d1ea15a54e..afa79b92ea 100644 --- a/third_party/libwebrtc/api/frame_transformer_interface.h +++ b/third_party/libwebrtc/api/frame_transformer_interface.h @@ -13,12 +13,11 @@ #include #include -#include +#include "api/ref_count.h" #include "api/scoped_refptr.h" #include "api/video/encoded_frame.h" #include "api/video/video_frame_metadata.h" -#include "rtc_base/ref_count.h" namespace webrtc { @@ -54,11 +53,7 @@ class TransformableFrameInterface { // sender frames to allow received frames to be directly re-transmitted on // other PeerConnectionss. virtual Direction GetDirection() const { return Direction::kUnknown; } - virtual std::string GetMimeType() const { - // TODO(bugs.webrtc.org/15579): Change this to pure virtual after it - // is implemented everywhere. - return "unknown/unknown"; - } + virtual std::string GetMimeType() const = 0; }; class TransformableVideoFrameInterface : public TransformableFrameInterface { @@ -100,6 +95,12 @@ class TransformedFrameCallback : public rtc::RefCountInterface { virtual void OnTransformedFrame( std::unique_ptr frame) = 0; + // Request to no longer be called on each frame, instead having frames be + // sent directly to OnTransformedFrame without additional work. + // TODO(crbug.com/1502781): Make pure virtual once all mocks have + // implementations. + virtual void StartShortCircuiting() {} + protected: ~TransformedFrameCallback() override = default; }; diff --git a/third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build b/third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build index 20da3e9cdb..ea4cac1276 100644 --- a/third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build +++ b/third_party/libwebrtc/api/frame_transformer_interface_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/function_view_gn/moz.build b/third_party/libwebrtc/api/function_view_gn/moz.build index 0854c1f771..980c9d9ca6 100644 --- a/third_party/libwebrtc/api/function_view_gn/moz.build +++ b/third_party/libwebrtc/api/function_view_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/ice_transport_interface.h b/third_party/libwebrtc/api/ice_transport_interface.h index 001395c215..f4c7613fa8 100644 --- a/third_party/libwebrtc/api/ice_transport_interface.h +++ b/third_party/libwebrtc/api/ice_transport_interface.h @@ -14,11 +14,10 @@ #include #include "api/async_dns_resolver.h" -#include "api/async_resolver_factory.h" +#include "api/ref_count.h" #include "api/rtc_error.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_count.h" namespace cricket { class IceTransportInternal; @@ -33,7 +32,7 @@ class FieldTrialsView; // An ICE transport, as represented to the outside world. // This object is refcounted, and is therefore alive until the // last holder has released it. -class IceTransportInterface : public rtc::RefCountInterface { +class IceTransportInterface : public webrtc::RefCountInterface { public: // Accessor for the internal representation of an ICE transport. // The returned object can only be safely used on the signalling thread. @@ -61,19 +60,8 @@ struct IceTransportInit final { } void set_async_dns_resolver_factory( AsyncDnsResolverFactoryInterface* async_dns_resolver_factory) { - RTC_DCHECK(!async_resolver_factory_); async_dns_resolver_factory_ = async_dns_resolver_factory; } - [[deprecated("Use async_dns_resolver_factory")]] AsyncResolverFactory* - async_resolver_factory() { - return async_resolver_factory_; - } - ABSL_DEPRECATED("bugs.webrtc.org/12598") - void set_async_resolver_factory( - AsyncResolverFactory* async_resolver_factory) { - RTC_DCHECK(!async_dns_resolver_factory_); - async_resolver_factory_ = async_resolver_factory; - } RtcEventLog* event_log() { return event_log_; } void set_event_log(RtcEventLog* event_log) { event_log_ = event_log; } @@ -115,11 +103,6 @@ struct IceTransportInit final { private: cricket::PortAllocator* port_allocator_ = nullptr; AsyncDnsResolverFactoryInterface* async_dns_resolver_factory_ = nullptr; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - // For backwards compatibility. Only one resolver factory can be set. - AsyncResolverFactory* async_resolver_factory_ = nullptr; -#pragma clang diagnostic pop RtcEventLog* event_log_ = nullptr; cricket::IceControllerFactoryInterface* ice_controller_factory_ = nullptr; cricket::ActiveIceControllerFactoryInterface* active_ice_controller_factory_ = diff --git a/third_party/libwebrtc/api/jsep.h b/third_party/libwebrtc/api/jsep.h index d2aa57c784..643a99d315 100644 --- a/third_party/libwebrtc/api/jsep.h +++ b/third_party/libwebrtc/api/jsep.h @@ -27,8 +27,8 @@ #include #include "absl/types/optional.h" +#include "api/ref_count.h" #include "api/rtc_error.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" namespace cricket { @@ -219,7 +219,7 @@ std::unique_ptr CreateSessionDescription( // CreateOffer and CreateAnswer callback interface. class RTC_EXPORT CreateSessionDescriptionObserver - : public rtc::RefCountInterface { + : public webrtc::RefCountInterface { public: // This callback transfers the ownership of the `desc`. // TODO(deadbeef): Make this take an std::unique_ptr<> to avoid confusion @@ -238,7 +238,8 @@ class RTC_EXPORT CreateSessionDescriptionObserver }; // SetLocalDescription and SetRemoteDescription callback interface. -class RTC_EXPORT SetSessionDescriptionObserver : public rtc::RefCountInterface { +class RTC_EXPORT SetSessionDescriptionObserver + : public webrtc::RefCountInterface { public: virtual void OnSuccess() = 0; // See description in CreateSessionDescriptionObserver for OnFailure. diff --git a/third_party/libwebrtc/api/legacy_stats_types.h b/third_party/libwebrtc/api/legacy_stats_types.h index e49cb6d6dd..70f21d4ad9 100644 --- a/third_party/libwebrtc/api/legacy_stats_types.h +++ b/third_party/libwebrtc/api/legacy_stats_types.h @@ -20,9 +20,9 @@ #include #include +#include "api/ref_count.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -240,7 +240,7 @@ class RTC_EXPORT StatsReport { kStatsValueNameLocalCandidateRelayProtocol, }; - class RTC_EXPORT IdBase : public rtc::RefCountInterface { + class RTC_EXPORT IdBase : public webrtc::RefCountInterface { public: ~IdBase() override; StatsType type() const; diff --git a/third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build b/third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build index 3a6a8537c2..b3a3b0ee1b 100644 --- a/third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build +++ b/third_party/libwebrtc/api/libjingle_logging_api_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build b/third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build index b4ff24a0b5..fbbb882ebf 100644 --- a/third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build +++ b/third_party/libwebrtc/api/libjingle_peerconnection_api_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/location_gn/moz.build b/third_party/libwebrtc/api/location_gn/moz.build index 5e7de58f06..dcdca04077 100644 --- a/third_party/libwebrtc/api/location_gn/moz.build +++ b/third_party/libwebrtc/api/location_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/make_ref_counted_gn/moz.build b/third_party/libwebrtc/api/make_ref_counted_gn/moz.build index 2eb6226bfb..f90e274916 100644 --- a/third_party/libwebrtc/api/make_ref_counted_gn/moz.build +++ b/third_party/libwebrtc/api/make_ref_counted_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/media_stream_interface.h b/third_party/libwebrtc/api/media_stream_interface.h index 9d336739e4..4f9bffac85 100644 --- a/third_party/libwebrtc/api/media_stream_interface.h +++ b/third_party/libwebrtc/api/media_stream_interface.h @@ -23,6 +23,7 @@ #include "absl/types/optional.h" #include "api/audio_options.h" +#include "api/ref_count.h" #include "api/scoped_refptr.h" #include "api/video/recordable_encoded_frame.h" #include "api/video/video_frame.h" @@ -30,7 +31,6 @@ #include "api/video/video_source_interface.h" #include "api/video_track_source_constraints.h" #include "modules/audio_processing/include/audio_processing_statistics.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -54,7 +54,7 @@ class NotifierInterface { // Base class for sources. A MediaStreamTrack has an underlying source that // provides media. A source can be shared by multiple tracks. -class RTC_EXPORT MediaSourceInterface : public rtc::RefCountInterface, +class RTC_EXPORT MediaSourceInterface : public webrtc::RefCountInterface, public NotifierInterface { public: enum SourceState { kInitializing, kLive, kEnded, kMuted }; @@ -69,7 +69,7 @@ class RTC_EXPORT MediaSourceInterface : public rtc::RefCountInterface, // C++ version of MediaStreamTrack. // See: https://www.w3.org/TR/mediacapture-streams/#mediastreamtrack -class RTC_EXPORT MediaStreamTrackInterface : public rtc::RefCountInterface, +class RTC_EXPORT MediaStreamTrackInterface : public webrtc::RefCountInterface, public NotifierInterface { public: enum TrackState { @@ -267,7 +267,7 @@ class RTC_EXPORT AudioSourceInterface : public MediaSourceInterface { // Interface of the audio processor used by the audio track to collect // statistics. -class AudioProcessorInterface : public rtc::RefCountInterface { +class AudioProcessorInterface : public webrtc::RefCountInterface { public: struct AudioProcessorStatistics { bool typing_noise_detected = false; @@ -321,7 +321,7 @@ typedef std::vector > VideoTrackVector; // must be pushed down. // // Thus, this interface acts as simply a container for tracks. -class MediaStreamInterface : public rtc::RefCountInterface, +class MediaStreamInterface : public webrtc::RefCountInterface, public NotifierInterface { public: virtual std::string id() const = 0; diff --git a/third_party/libwebrtc/api/media_stream_interface_gn/moz.build b/third_party/libwebrtc/api/media_stream_interface_gn/moz.build index b066645cd2..759c156fb7 100644 --- a/third_party/libwebrtc/api/media_stream_interface_gn/moz.build +++ b/third_party/libwebrtc/api/media_stream_interface_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/metronome/metronome.cc b/third_party/libwebrtc/api/metronome/metronome.cc deleted file mode 100644 index 8d74f928a0..0000000000 --- a/third_party/libwebrtc/api/metronome/metronome.cc +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "api/metronome/metronome.h" - -namespace webrtc { - -// TODO(crbug.com/1381982): Remove outdated methods. -void Metronome::AddListener(TickListener* listener) {} -void Metronome::RemoveListener(TickListener* listener) {} - -} // namespace webrtc diff --git a/third_party/libwebrtc/api/metronome/metronome_gn/moz.build b/third_party/libwebrtc/api/metronome/metronome_gn/moz.build index d89c86ef4b..ede22e4998 100644 --- a/third_party/libwebrtc/api/metronome/metronome_gn/moz.build +++ b/third_party/libwebrtc/api/metronome/metronome_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build b/third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build index 75602ac512..5d18a89d19 100644 --- a/third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build +++ b/third_party/libwebrtc/api/neteq/default_neteq_controller_factory_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build b/third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build index 7c4e1c550a..7ed92b8183 100644 --- a/third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build +++ b/third_party/libwebrtc/api/neteq/neteq_api_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build b/third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build index 617ffd753e..c08d59e8ac 100644 --- a/third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build +++ b/third_party/libwebrtc/api/neteq/neteq_controller_api_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build b/third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build index 8106b395ca..ef3938ecf2 100644 --- a/third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build +++ b/third_party/libwebrtc/api/neteq/tick_timer_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build b/third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build index 0ffd6a2406..1cfd2c0837 100644 --- a/third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build +++ b/third_party/libwebrtc/api/network_state_predictor_api_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/packet_socket_factory.h b/third_party/libwebrtc/api/packet_socket_factory.h index e389ccb2ff..78b93b539c 100644 --- a/third_party/libwebrtc/api/packet_socket_factory.h +++ b/third_party/libwebrtc/api/packet_socket_factory.h @@ -16,7 +16,6 @@ #include #include "api/async_dns_resolver.h" -#include "api/wrapping_async_dns_resolver.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/proxy_info.h" #include "rtc_base/system/rtc_export.h" @@ -72,26 +71,8 @@ class RTC_EXPORT PacketSocketFactory { const std::string& user_agent, const PacketSocketTcpOptions& tcp_options) = 0; - // The AsyncResolverInterface is deprecated; users are encouraged - // to switch to the AsyncDnsResolverInterface. - // TODO(bugs.webrtc.org/12598): Remove once all downstream users - // are converted. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [[deprecated]] virtual AsyncResolverInterface* CreateAsyncResolver() { - // Default implementation, so that downstream users can remove this - // immediately after changing to CreateAsyncDnsResolver - RTC_DCHECK_NOTREACHED(); - return nullptr; - } - virtual std::unique_ptr - CreateAsyncDnsResolver() { - // Default implementation, to aid in transition to AsyncDnsResolverInterface - return std::make_unique( - CreateAsyncResolver()); - } -#pragma clang diagnostic pop + CreateAsyncDnsResolver() = 0; private: PacketSocketFactory(const PacketSocketFactory&) = delete; diff --git a/third_party/libwebrtc/api/peer_connection_interface.cc b/third_party/libwebrtc/api/peer_connection_interface.cc index 050b61da95..dedfd355d6 100644 --- a/third_party/libwebrtc/api/peer_connection_interface.cc +++ b/third_party/libwebrtc/api/peer_connection_interface.cc @@ -12,6 +12,8 @@ #include +#include "pc/media_factory.h" + namespace webrtc { PeerConnectionInterface::IceServer::IceServer() = default; diff --git a/third_party/libwebrtc/api/peer_connection_interface.h b/third_party/libwebrtc/api/peer_connection_interface.h index 9243190c10..74c4702cd2 100644 --- a/third_party/libwebrtc/api/peer_connection_interface.h +++ b/third_party/libwebrtc/api/peer_connection_interface.h @@ -80,12 +80,10 @@ #include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/async_dns_resolver.h" -#include "api/async_resolver_factory.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_options.h" -#include "api/call/call_factory_interface.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/data_channel_interface.h" @@ -120,17 +118,19 @@ #include "api/transport/sctp_transport_factory_interface.h" #include "api/turn_customizer.h" #include "api/video/video_bitrate_allocator_factory.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder_factory.h" #include "call/rtp_transport_controller_send_factory_interface.h" #include "media/base/media_config.h" #include "media/base/media_engine.h" // TODO(bugs.webrtc.org/7447): We plan to provide a way to let applications // inject a PacketSocketFactory and/or NetworkManager, and not expose // PortAllocator in the PeerConnection api. +#include "api/ref_count.h" #include "p2p/base/port_allocator.h" #include "rtc_base/network.h" #include "rtc_base/network_constants.h" #include "rtc_base/network_monitor_factory.h" -#include "rtc_base/ref_count.h" #include "rtc_base/rtc_certificate.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/socket_address.h" @@ -145,8 +145,11 @@ class Thread; namespace webrtc { +// MediaFactory class definition is not part of the api. +class MediaFactory; + // MediaStream container interface. -class StreamCollectionInterface : public rtc::RefCountInterface { +class StreamCollectionInterface : public webrtc::RefCountInterface { public: // TODO(ronghuawu): Update the function names to c++ style, e.g. find -> Find. virtual size_t count() = 0; @@ -160,7 +163,7 @@ class StreamCollectionInterface : public rtc::RefCountInterface { ~StreamCollectionInterface() override = default; }; -class StatsObserver : public rtc::RefCountInterface { +class StatsObserver : public webrtc::RefCountInterface { public: virtual void OnComplete(const StatsReports& reports) = 0; @@ -175,7 +178,7 @@ enum class SdpSemantics { kUnifiedPlan, }; -class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { +class RTC_EXPORT PeerConnectionInterface : public webrtc::RefCountInterface { public: // See https://w3c.github.io/webrtc-pc/#dom-rtcsignalingstate enum SignalingState { @@ -683,6 +686,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { PortAllocatorConfig port_allocator_config; // The burst interval of the pacer, see TaskQueuePacedSender constructor. + // TODO(hbos): Deprecated, Remove once Chromium is not setting it. absl::optional pacer_burst_interval; // @@ -1382,13 +1386,6 @@ struct RTC_EXPORT PeerConnectionDependencies final { // Factory for creating resolvers that look up hostnames in DNS std::unique_ptr async_dns_resolver_factory; - // Deprecated - use async_dns_resolver_factory -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [[deprecated("Use async_dns_resolver_factory")]] std::unique_ptr< - webrtc::AsyncResolverFactory> - async_resolver_factory; -#pragma clang diagnostic pop std::unique_ptr ice_transport_factory; std::unique_ptr cert_generator; std::unique_ptr tls_cert_verifier; @@ -1427,8 +1424,6 @@ struct RTC_EXPORT PeerConnectionFactoryDependencies final { // called without a `port_allocator`. std::unique_ptr packet_socket_factory; std::unique_ptr task_queue_factory; - std::unique_ptr media_engine; - std::unique_ptr call_factory; std::unique_ptr event_log_factory; std::unique_ptr fec_controller_factory; std::unique_ptr @@ -1447,6 +1442,23 @@ struct RTC_EXPORT PeerConnectionFactoryDependencies final { std::unique_ptr transport_controller_send_factory; std::unique_ptr metronome; + + // Media specific dependencies. Unused when `media_factory == nullptr`. + rtc::scoped_refptr adm; + rtc::scoped_refptr audio_encoder_factory; + rtc::scoped_refptr audio_decoder_factory; + rtc::scoped_refptr audio_mixer; + rtc::scoped_refptr audio_processing; + std::unique_ptr audio_frame_processor; + std::unique_ptr video_encoder_factory; + std::unique_ptr video_decoder_factory; + + // The `media_factory` members allows webrtc to be optionally built without + // media support (i.e., if only being used for data channels). + // By default media is disabled. To enable media call + // `EnableMedia(PeerConnectionFactoryDependencies&)`. Definition of the + // `MediaFactory` interface is a webrtc implementation detail. + std::unique_ptr media_factory; }; // PeerConnectionFactoryInterface is the factory interface used for creating @@ -1463,7 +1475,7 @@ struct RTC_EXPORT PeerConnectionFactoryDependencies final { // CreatePeerConnectionFactory method which accepts threads as input, and use // the CreatePeerConnection version that takes a PortAllocator as an argument. class RTC_EXPORT PeerConnectionFactoryInterface - : public rtc::RefCountInterface { + : public webrtc::RefCountInterface { public: class Options { public: diff --git a/third_party/libwebrtc/api/priority_gn/moz.build b/third_party/libwebrtc/api/priority_gn/moz.build index 090d23dd76..5cac655d90 100644 --- a/third_party/libwebrtc/api/priority_gn/moz.build +++ b/third_party/libwebrtc/api/priority_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/ref_count.h b/third_party/libwebrtc/api/ref_count.h new file mode 100644 index 0000000000..5209277038 --- /dev/null +++ b/third_party/libwebrtc/api/ref_count.h @@ -0,0 +1,67 @@ +/* + * Copyright 2011 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#ifndef API_REF_COUNT_H_ +#define API_REF_COUNT_H_ + +namespace webrtc { + +// Refcounted objects should implement the following informal interface: +// +// void AddRef() const ; +// RefCountReleaseStatus Release() const; +// +// You may access members of a reference-counted object, including the AddRef() +// and Release() methods, only if you already own a reference to it, or if +// you're borrowing someone else's reference. (A newly created object is a +// special case: the reference count is zero on construction, and the code that +// creates the object should immediately call AddRef(), bringing the reference +// count from zero to one, e.g., by constructing an rtc::scoped_refptr). +// +// AddRef() creates a new reference to the object. +// +// Release() releases a reference to the object; the caller now has one less +// reference than before the call. Returns kDroppedLastRef if the number of +// references dropped to zero because of this (in which case the object destroys +// itself). Otherwise, returns kOtherRefsRemained, to signal that at the precise +// time the caller's reference was dropped, other references still remained (but +// if other threads own references, this may of course have changed by the time +// Release() returns). +// +// The caller of Release() must treat it in the same way as a delete operation: +// Regardless of the return value from Release(), the caller mustn't access the +// object. The object might still be alive, due to references held by other +// users of the object, but the object can go away at any time, e.g., as the +// result of another thread calling Release(). +// +// Calling AddRef() and Release() manually is discouraged. It's recommended to +// use rtc::scoped_refptr to manage all pointers to reference counted objects. +// Note that rtc::scoped_refptr depends on compile-time duck-typing; formally +// implementing the below RefCountInterface is not required. + +enum class RefCountReleaseStatus { kDroppedLastRef, kOtherRefsRemained }; + +// Interfaces where refcounting is part of the public api should +// inherit this abstract interface. The implementation of these +// methods is usually provided by the RefCountedObject template class, +// applied as a leaf in the inheritance tree. +class RefCountInterface { + public: + virtual void AddRef() const = 0; + virtual RefCountReleaseStatus Release() const = 0; + + // Non-public destructor, because Release() has exclusive responsibility for + // destroying the object. + protected: + virtual ~RefCountInterface() {} +}; + +} // namespace webrtc + +#endif // API_REF_COUNT_H_ diff --git a/third_party/libwebrtc/api/ref_count_gn/moz.build b/third_party/libwebrtc/api/ref_count_gn/moz.build new file mode 100644 index 0000000000..0fcde97e6b --- /dev/null +++ b/third_party/libwebrtc/api/ref_count_gn/moz.build @@ -0,0 +1,198 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + + ### This moz.build was AUTOMATICALLY GENERATED from a GN config, ### + ### DO NOT edit it by hand. ### + +COMPILE_FLAGS["OS_INCLUDES"] = [] +AllowCompilerWarnings() + +DEFINES["ABSL_ALLOCATOR_NOTHROW"] = "1" +DEFINES["RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY"] = True +DEFINES["RTC_ENABLE_VP9"] = True +DEFINES["WEBRTC_ENABLE_PROTOBUF"] = "0" +DEFINES["WEBRTC_LIBRARY_IMPL"] = True +DEFINES["WEBRTC_MOZILLA_BUILD"] = True +DEFINES["WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS"] = "0" +DEFINES["WEBRTC_STRICT_FIELD_TRIALS"] = "0" + +FINAL_LIBRARY = "webrtc" + + +LOCAL_INCLUDES += [ + "!/ipc/ipdl/_ipdlheaders", + "!/third_party/libwebrtc/gen", + "/ipc/chromium/src", + "/third_party/libwebrtc/", + "/third_party/libwebrtc/third_party/abseil-cpp/", + "/tools/profiler/public" +] + +if not CONFIG["MOZ_DEBUG"]: + + DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "0" + DEFINES["NDEBUG"] = True + DEFINES["NVALGRIND"] = True + +if CONFIG["MOZ_DEBUG"] == "1": + + DEFINES["DYNAMIC_ANNOTATIONS_ENABLED"] = "1" + +if CONFIG["OS_TARGET"] == "Android": + + DEFINES["ANDROID"] = True + DEFINES["ANDROID_NDK_VERSION_ROLL"] = "r22_1" + DEFINES["HAVE_SYS_UIO_H"] = True + DEFINES["WEBRTC_ANDROID"] = True + DEFINES["WEBRTC_ANDROID_OPENSLES"] = True + DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True + DEFINES["WEBRTC_LINUX"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_GNU_SOURCE"] = True + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "Darwin": + + DEFINES["WEBRTC_MAC"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_LIBCPP_HAS_NO_ALIGNED_ALLOCATION"] = True + DEFINES["__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES"] = "0" + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "Linux": + + DEFINES["USE_AURA"] = "1" + DEFINES["USE_GLIB"] = "1" + DEFINES["USE_NSS_CERTS"] = "1" + DEFINES["USE_OZONE"] = "1" + DEFINES["USE_UDEV"] = True + DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True + DEFINES["WEBRTC_LINUX"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + DEFINES["_LARGEFILE64_SOURCE"] = True + DEFINES["_LARGEFILE_SOURCE"] = True + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "OpenBSD": + + DEFINES["USE_GLIB"] = "1" + DEFINES["USE_OZONE"] = "1" + DEFINES["USE_X11"] = "1" + DEFINES["WEBRTC_BSD"] = True + DEFINES["WEBRTC_ENABLE_LIBEVENT"] = True + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + DEFINES["_LARGEFILE64_SOURCE"] = True + DEFINES["_LARGEFILE_SOURCE"] = True + DEFINES["__STDC_CONSTANT_MACROS"] = True + DEFINES["__STDC_FORMAT_MACROS"] = True + +if CONFIG["OS_TARGET"] == "WINNT": + + DEFINES["CERT_CHAIN_PARA_HAS_EXTRA_FIELDS"] = True + DEFINES["NOMINMAX"] = True + DEFINES["NTDDI_VERSION"] = "0x0A000000" + DEFINES["PSAPI_VERSION"] = "2" + DEFINES["RTC_ENABLE_WIN_WGC"] = True + DEFINES["UNICODE"] = True + DEFINES["USE_AURA"] = "1" + DEFINES["WEBRTC_WIN"] = True + DEFINES["WIN32"] = True + DEFINES["WIN32_LEAN_AND_MEAN"] = True + DEFINES["WINAPI_FAMILY"] = "WINAPI_FAMILY_DESKTOP_APP" + DEFINES["WINVER"] = "0x0A00" + DEFINES["_ATL_NO_OPENGL"] = True + DEFINES["_CRT_RAND_S"] = True + DEFINES["_CRT_SECURE_NO_DEPRECATE"] = True + DEFINES["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True + DEFINES["_HAS_EXCEPTIONS"] = "0" + DEFINES["_HAS_NODISCARD"] = True + DEFINES["_SCL_SECURE_NO_DEPRECATE"] = True + DEFINES["_SECURE_ATL"] = True + DEFINES["_UNICODE"] = True + DEFINES["_WIN32_WINNT"] = "0x0A00" + DEFINES["_WINDOWS"] = True + DEFINES["__STD_C"] = True + +if CONFIG["TARGET_CPU"] == "aarch64": + + DEFINES["WEBRTC_ARCH_ARM64"] = True + DEFINES["WEBRTC_HAS_NEON"] = True + +if CONFIG["TARGET_CPU"] == "arm": + + DEFINES["WEBRTC_ARCH_ARM"] = True + DEFINES["WEBRTC_ARCH_ARM_V7"] = True + DEFINES["WEBRTC_HAS_NEON"] = True + +if CONFIG["TARGET_CPU"] == "mips32": + + DEFINES["MIPS32_LE"] = True + DEFINES["MIPS_FPU_LE"] = True + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["TARGET_CPU"] == "mips64": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["TARGET_CPU"] == "x86": + + DEFINES["WEBRTC_ENABLE_AVX2"] = True + +if CONFIG["TARGET_CPU"] == "x86_64": + + DEFINES["WEBRTC_ENABLE_AVX2"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Android": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Darwin": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "Linux": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "OpenBSD": + + DEFINES["_DEBUG"] = True + +if CONFIG["MOZ_DEBUG"] == "1" and CONFIG["OS_TARGET"] == "WINNT": + + DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0" + +if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": + + DEFINES["USE_X11"] = "1" + +if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": + + OS_LIBS += [ + "unwind" + ] + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "arm": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86": + + DEFINES["_GNU_SOURCE"] = True + +if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86_64": + + DEFINES["_GNU_SOURCE"] = True + +Library("ref_count_gn") diff --git a/third_party/libwebrtc/api/refcountedbase_gn/moz.build b/third_party/libwebrtc/api/refcountedbase_gn/moz.build index c18c17de99..96c04d1258 100644 --- a/third_party/libwebrtc/api/refcountedbase_gn/moz.build +++ b/third_party/libwebrtc/api/refcountedbase_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtc_error_gn/moz.build b/third_party/libwebrtc/api/rtc_error_gn/moz.build index 19bee50072..3c9d5f7f9b 100644 --- a/third_party/libwebrtc/api/rtc_error_gn/moz.build +++ b/third_party/libwebrtc/api/rtc_error_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtc_event_log/BUILD.gn b/third_party/libwebrtc/api/rtc_event_log/BUILD.gn index 158dc06a7b..073c91a5e8 100644 --- a/third_party/libwebrtc/api/rtc_event_log/BUILD.gn +++ b/third_party/libwebrtc/api/rtc_event_log/BUILD.gn @@ -22,8 +22,10 @@ rtc_library("rtc_event_log") { "..:libjingle_logging_api", "../../rtc_base:checks", "../../rtc_base:timeutils", + "../environment", "../task_queue", ] + absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ] } rtc_library("rtc_event_log_factory") { @@ -35,12 +37,14 @@ rtc_library("rtc_event_log_factory") { deps = [ ":rtc_event_log", - "../../rtc_base:checks", + "..:field_trials_view", "../../rtc_base/system:rtc_export", - "../../system_wrappers:field_trial", + "../environment", "../task_queue", ] + absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ] + if (rtc_enable_protobuf) { defines = [ "WEBRTC_ENABLE_RTC_EVENT_LOG" ] deps += [ "../../logging:rtc_event_log_impl" ] diff --git a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.cc b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.cc index a3cb68cf54..30fc6f126f 100644 --- a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.cc +++ b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.cc @@ -11,10 +11,11 @@ #include "api/rtc_event_log/rtc_event_log_factory.h" #include -#include -#include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" +#include "absl/base/nullability.h" +#include "api/environment/environment.h" +#include "api/field_trials_view.h" +#include "api/rtc_event_log/rtc_event_log.h" #ifdef WEBRTC_ENABLE_RTC_EVENT_LOG #include "logging/rtc_event_log/rtc_event_log_impl.h" @@ -22,27 +23,21 @@ namespace webrtc { -RtcEventLogFactory::RtcEventLogFactory(TaskQueueFactory* task_queue_factory) - : task_queue_factory_(task_queue_factory) { - RTC_DCHECK(task_queue_factory_); -} - -std::unique_ptr RtcEventLogFactory::Create( - RtcEventLog::EncodingType encoding_type) const { -#ifdef WEBRTC_ENABLE_RTC_EVENT_LOG - if (field_trial::IsEnabled("WebRTC-RtcEventLogKillSwitch")) { +absl::Nonnull> RtcEventLogFactory::Create( + const Environment& env) const { +#ifndef WEBRTC_ENABLE_RTC_EVENT_LOG + return std::make_unique(); +#else + if (env.field_trials().IsEnabled("WebRTC-RtcEventLogKillSwitch")) { return std::make_unique(); } + RtcEventLog::EncodingType encoding_type = + env.field_trials().IsDisabled("WebRTC-RtcEventLogNewFormat") + ? RtcEventLog::EncodingType::Legacy + : RtcEventLog::EncodingType::NewFormat; return std::make_unique( - RtcEventLogImpl::CreateEncoder(encoding_type), task_queue_factory_); -#else - return std::make_unique(); + RtcEventLogImpl::CreateEncoder(encoding_type), &env.task_queue_factory()); #endif } -std::unique_ptr RtcEventLogFactory::CreateRtcEventLog( - RtcEventLog::EncodingType encoding_type) { - return Create(encoding_type); -} - } // namespace webrtc diff --git a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.h b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.h index fd1db3c728..21a670e1a7 100644 --- a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.h +++ b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory.h @@ -13,6 +13,8 @@ #include +#include "absl/base/nullability.h" +#include "api/environment/environment.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "api/task_queue/task_queue_factory.h" @@ -22,16 +24,16 @@ namespace webrtc { class RTC_EXPORT RtcEventLogFactory : public RtcEventLogFactoryInterface { public: - explicit RtcEventLogFactory(TaskQueueFactory* task_queue_factory); - ~RtcEventLogFactory() override {} + RtcEventLogFactory() = default; - std::unique_ptr Create( - RtcEventLog::EncodingType encoding_type) const override; - std::unique_ptr CreateRtcEventLog( - RtcEventLog::EncodingType encoding_type) override; + // TODO(bugs.webrtc.org/15656): deprecate and delete constructor taking + // task queue factory in favor of using task queue factory provided through + // the Environment parameter in Create function. + explicit RtcEventLogFactory(TaskQueueFactory* task_queue_factory) {} + ~RtcEventLogFactory() override = default; - private: - TaskQueueFactory* const task_queue_factory_; + absl::Nonnull> Create( + const Environment& env) const override; }; } // namespace webrtc diff --git a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory_interface.h b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory_interface.h index a6f4dee92f..3135584966 100644 --- a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory_interface.h +++ b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_factory_interface.h @@ -13,6 +13,8 @@ #include +#include "absl/base/nullability.h" +#include "api/environment/environment.h" #include "api/rtc_event_log/rtc_event_log.h" namespace webrtc { @@ -24,10 +26,8 @@ class RtcEventLogFactoryInterface { public: virtual ~RtcEventLogFactoryInterface() = default; - virtual std::unique_ptr Create( - RtcEventLog::EncodingType encoding_type) const = 0; - [[deprecated]] virtual std::unique_ptr CreateRtcEventLog( - RtcEventLog::EncodingType encoding_type) = 0; + virtual absl::Nonnull> Create( + const Environment& env) const = 0; }; } // namespace webrtc diff --git a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build index 1965bc7a12..991c0366b6 100644 --- a/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build +++ b/third_party/libwebrtc/api/rtc_event_log/rtc_event_log_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtp_headers_gn/moz.build b/third_party/libwebrtc/api/rtp_headers_gn/moz.build index 7328eb81c0..24f4f8fb24 100644 --- a/third_party/libwebrtc/api/rtp_headers_gn/moz.build +++ b/third_party/libwebrtc/api/rtp_headers_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtp_packet_info_gn/moz.build b/third_party/libwebrtc/api/rtp_packet_info_gn/moz.build index 92eb6cb369..fda93e184e 100644 --- a/third_party/libwebrtc/api/rtp_packet_info_gn/moz.build +++ b/third_party/libwebrtc/api/rtp_packet_info_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtp_parameters_gn/moz.build b/third_party/libwebrtc/api/rtp_parameters_gn/moz.build index 480114ad07..09590e547d 100644 --- a/third_party/libwebrtc/api/rtp_parameters_gn/moz.build +++ b/third_party/libwebrtc/api/rtp_parameters_gn/moz.build @@ -189,7 +189,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -199,10 +198,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtp_receiver_interface.h b/third_party/libwebrtc/api/rtp_receiver_interface.h index e4ec9b5986..0bf1af972b 100644 --- a/third_party/libwebrtc/api/rtp_receiver_interface.h +++ b/third_party/libwebrtc/api/rtp_receiver_interface.h @@ -22,10 +22,10 @@ #include "api/frame_transformer_interface.h" #include "api/media_stream_interface.h" #include "api/media_types.h" +#include "api/ref_count.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" #include "api/transport/rtp/rtp_source.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -44,7 +44,7 @@ class RtpReceiverObserverInterface { virtual ~RtpReceiverObserverInterface() {} }; -class RTC_EXPORT RtpReceiverInterface : public rtc::RefCountInterface { +class RTC_EXPORT RtpReceiverInterface : public webrtc::RefCountInterface { public: virtual rtc::scoped_refptr track() const = 0; diff --git a/third_party/libwebrtc/api/rtp_sender_interface.h b/third_party/libwebrtc/api/rtp_sender_interface.h index 619b601f1f..7090c233cd 100644 --- a/third_party/libwebrtc/api/rtp_sender_interface.h +++ b/third_party/libwebrtc/api/rtp_sender_interface.h @@ -25,18 +25,18 @@ #include "api/frame_transformer_interface.h" #include "api/media_stream_interface.h" #include "api/media_types.h" +#include "api/ref_count.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" #include "api/video_codecs/video_encoder_factory.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" #include "api/rtp_sender_setparameters_callback.h" namespace webrtc { -class RTC_EXPORT RtpSenderInterface : public rtc::RefCountInterface { +class RTC_EXPORT RtpSenderInterface : public webrtc::RefCountInterface { public: // Returns true if successful in setting the track. // Fails if an audio track is set on a video RtpSender, or vice-versa. diff --git a/third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build b/third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build index 9938ecca35..e7259b40e0 100644 --- a/third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build +++ b/third_party/libwebrtc/api/rtp_sender_interface_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build b/third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build index f8cd38576d..c493f010c8 100644 --- a/third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build +++ b/third_party/libwebrtc/api/rtp_sender_setparameters_callback_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build b/third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build index 9f3a7424ae..66b863defb 100644 --- a/third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build +++ b/third_party/libwebrtc/api/rtp_transceiver_direction_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/rtp_transceiver_interface.h b/third_party/libwebrtc/api/rtp_transceiver_interface.h index 7d0d1a18bf..940264ef51 100644 --- a/third_party/libwebrtc/api/rtp_transceiver_interface.h +++ b/third_party/libwebrtc/api/rtp_transceiver_interface.h @@ -18,12 +18,12 @@ #include "absl/types/optional.h" #include "api/array_view.h" #include "api/media_types.h" +#include "api/ref_count.h" #include "api/rtp_parameters.h" #include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" #include "api/rtp_transceiver_direction.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -58,7 +58,7 @@ struct RTC_EXPORT RtpTransceiverInit final { // // WebRTC specification for RTCRtpTransceiver, the JavaScript analog: // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver -class RTC_EXPORT RtpTransceiverInterface : public rtc::RefCountInterface { +class RTC_EXPORT RtpTransceiverInterface : public webrtc::RefCountInterface { public: // Media type of the transceiver. Any sender(s)/receiver(s) will have this // type as well. diff --git a/third_party/libwebrtc/api/scoped_refptr.h b/third_party/libwebrtc/api/scoped_refptr.h index e145509127..61b2eb1f20 100644 --- a/third_party/libwebrtc/api/scoped_refptr.h +++ b/third_party/libwebrtc/api/scoped_refptr.h @@ -66,7 +66,7 @@ #include #include -namespace rtc { +namespace webrtc { template class scoped_refptr { @@ -162,61 +162,66 @@ class scoped_refptr { }; template -bool operator==(const rtc::scoped_refptr& a, - const rtc::scoped_refptr& b) { +bool operator==(const scoped_refptr& a, const scoped_refptr& b) { return a.get() == b.get(); } template -bool operator!=(const rtc::scoped_refptr& a, - const rtc::scoped_refptr& b) { +bool operator!=(const scoped_refptr& a, const scoped_refptr& b) { return !(a == b); } template -bool operator==(const rtc::scoped_refptr& a, std::nullptr_t) { +bool operator==(const scoped_refptr& a, std::nullptr_t) { return a.get() == nullptr; } template -bool operator!=(const rtc::scoped_refptr& a, std::nullptr_t) { +bool operator!=(const scoped_refptr& a, std::nullptr_t) { return !(a == nullptr); } template -bool operator==(std::nullptr_t, const rtc::scoped_refptr& a) { +bool operator==(std::nullptr_t, const scoped_refptr& a) { return a.get() == nullptr; } template -bool operator!=(std::nullptr_t, const rtc::scoped_refptr& a) { +bool operator!=(std::nullptr_t, const scoped_refptr& a) { return !(a == nullptr); } // Comparison with raw pointer. template -bool operator==(const rtc::scoped_refptr& a, const U* b) { +bool operator==(const scoped_refptr& a, const U* b) { return a.get() == b; } template -bool operator!=(const rtc::scoped_refptr& a, const U* b) { +bool operator!=(const scoped_refptr& a, const U* b) { return !(a == b); } template -bool operator==(const T* a, const rtc::scoped_refptr& b) { +bool operator==(const T* a, const scoped_refptr& b) { return a == b.get(); } template -bool operator!=(const T* a, const rtc::scoped_refptr& b) { +bool operator!=(const T* a, const scoped_refptr& b) { return !(a == b); } // Ordered comparison, needed for use as a std::map key. template -bool operator<(const rtc::scoped_refptr& a, const rtc::scoped_refptr& b) { +bool operator<(const scoped_refptr& a, const scoped_refptr& b) { return a.get() < b.get(); } +} // namespace webrtc + +namespace rtc { +// Backwards compatible alias. +// TODO(bugs.webrtc.org/15622): Deprecate and remove. +template +using scoped_refptr = webrtc::scoped_refptr; } // namespace rtc #endif // API_SCOPED_REFPTR_H_ diff --git a/third_party/libwebrtc/api/scoped_refptr_gn/moz.build b/third_party/libwebrtc/api/scoped_refptr_gn/moz.build index c2f167533d..6593008ce6 100644 --- a/third_party/libwebrtc/api/scoped_refptr_gn/moz.build +++ b/third_party/libwebrtc/api/scoped_refptr_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/sctp_transport_interface.h b/third_party/libwebrtc/api/sctp_transport_interface.h index 7080889fcf..23169ddb2b 100644 --- a/third_party/libwebrtc/api/sctp_transport_interface.h +++ b/third_party/libwebrtc/api/sctp_transport_interface.h @@ -13,9 +13,9 @@ #include "absl/types/optional.h" #include "api/dtls_transport_interface.h" +#include "api/ref_count.h" #include "api/rtc_error.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_count.h" namespace webrtc { @@ -75,7 +75,7 @@ class SctpTransportObserverInterface { // accessed on that thread, except for functions explicitly marked otherwise. // References can be held by other threads, and destruction can therefore // be initiated by other threads. -class SctpTransportInterface : public rtc::RefCountInterface { +class SctpTransportInterface : public webrtc::RefCountInterface { public: // This function can be called from other threads. virtual rtc::scoped_refptr dtls_transport() const = 0; diff --git a/third_party/libwebrtc/api/sequence_checker_gn/moz.build b/third_party/libwebrtc/api/sequence_checker_gn/moz.build index a45bc8e9c1..d50c0f4f32 100644 --- a/third_party/libwebrtc/api/sequence_checker_gn/moz.build +++ b/third_party/libwebrtc/api/sequence_checker_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/set_local_description_observer_interface.h b/third_party/libwebrtc/api/set_local_description_observer_interface.h index 8e7b6258d3..40f85b944e 100644 --- a/third_party/libwebrtc/api/set_local_description_observer_interface.h +++ b/third_party/libwebrtc/api/set_local_description_observer_interface.h @@ -11,15 +11,15 @@ #ifndef API_SET_LOCAL_DESCRIPTION_OBSERVER_INTERFACE_H_ #define API_SET_LOCAL_DESCRIPTION_OBSERVER_INTERFACE_H_ +#include "api/ref_count.h" #include "api/rtc_error.h" -#include "rtc_base/ref_count.h" namespace webrtc { // OnSetLocalDescriptionComplete() invokes as soon as // PeerConnectionInterface::SetLocalDescription() operation completes, allowing // the observer to examine the effects of the operation without delay. -class SetLocalDescriptionObserverInterface : public rtc::RefCountInterface { +class SetLocalDescriptionObserverInterface : public webrtc::RefCountInterface { public: // On success, `error.ok()` is true. virtual void OnSetLocalDescriptionComplete(RTCError error) = 0; diff --git a/third_party/libwebrtc/api/set_remote_description_observer_interface.h b/third_party/libwebrtc/api/set_remote_description_observer_interface.h index d1c075309f..c1625410df 100644 --- a/third_party/libwebrtc/api/set_remote_description_observer_interface.h +++ b/third_party/libwebrtc/api/set_remote_description_observer_interface.h @@ -11,8 +11,8 @@ #ifndef API_SET_REMOTE_DESCRIPTION_OBSERVER_INTERFACE_H_ #define API_SET_REMOTE_DESCRIPTION_OBSERVER_INTERFACE_H_ +#include "api/ref_count.h" #include "api/rtc_error.h" -#include "rtc_base/ref_count.h" namespace webrtc { @@ -20,7 +20,7 @@ namespace webrtc { // callback is invoked such that the state of the peer connection can be // examined to accurately reflect the effects of the SetRemoteDescription // operation. -class SetRemoteDescriptionObserverInterface : public rtc::RefCountInterface { +class SetRemoteDescriptionObserverInterface : public webrtc::RefCountInterface { public: // On success, `error.ok()` is true. virtual void OnSetRemoteDescriptionComplete(RTCError error) = 0; diff --git a/third_party/libwebrtc/api/simulated_network_api_gn/moz.build b/third_party/libwebrtc/api/simulated_network_api_gn/moz.build index b46ec1656b..1f52ba37d7 100644 --- a/third_party/libwebrtc/api/simulated_network_api_gn/moz.build +++ b/third_party/libwebrtc/api/simulated_network_api_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/stats/rtc_stats_report.h b/third_party/libwebrtc/api/stats/rtc_stats_report.h index 1dce4d89b2..632226ef0d 100644 --- a/third_party/libwebrtc/api/stats/rtc_stats_report.h +++ b/third_party/libwebrtc/api/stats/rtc_stats_report.h @@ -124,7 +124,7 @@ class RTC_EXPORT RTCStatsReport final std::string ToJson() const; protected: - friend class rtc::RefCountedNonVirtual; + friend class RefCountedNonVirtual; ~RTCStatsReport() = default; private: diff --git a/third_party/libwebrtc/api/task_queue/BUILD.gn b/third_party/libwebrtc/api/task_queue/BUILD.gn index 760ceaa3ef..9b2f747e78 100644 --- a/third_party/libwebrtc/api/task_queue/BUILD.gn +++ b/third_party/libwebrtc/api/task_queue/BUILD.gn @@ -90,7 +90,10 @@ rtc_library("task_queue_test") { rtc_library("default_task_queue_factory") { visibility = [ "*" ] if (!is_ios && !is_android) { - poisonous = [ "default_task_queue" ] + # Internally webrtc shouldn't rely on any specific TaskQueue implementation + # and should create TaskQueue using TaskQueueFactory interface. + # TaskQueueFactory interface can be propagated with Environment. + poisonous = [ "environment_construction" ] } sources = [ "default_task_queue_factory.h" ] deps = [ diff --git a/third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build b/third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build index 52a2e5003b..43229b22ed 100644 --- a/third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build +++ b/third_party/libwebrtc/api/task_queue/pending_task_safety_flag_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build b/third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build index 73630a2ad9..8c04d40cf5 100644 --- a/third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build +++ b/third_party/libwebrtc/api/task_queue/task_queue_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/task_queue/task_queue_test.cc b/third_party/libwebrtc/api/task_queue/task_queue_test.cc index b02333ec58..cac7cd77cc 100644 --- a/third_party/libwebrtc/api/task_queue/task_queue_test.cc +++ b/third_party/libwebrtc/api/task_queue/task_queue_test.cc @@ -268,7 +268,7 @@ TEST_P(TaskQueueTest, PostALot) { explicit BlockingCounter(int initial_count) : count_(initial_count) {} void DecrementCount() { - if (count_.DecRef() == rtc::RefCountReleaseStatus::kDroppedLastRef) { + if (count_.DecRef() == webrtc::RefCountReleaseStatus::kDroppedLastRef) { event_.Set(); } } diff --git a/third_party/libwebrtc/api/test/compile_all_headers.cc b/third_party/libwebrtc/api/test/compile_all_headers.cc index 1fcf63e97b..9d375a19f2 100644 --- a/third_party/libwebrtc/api/test/compile_all_headers.cc +++ b/third_party/libwebrtc/api/test/compile_all_headers.cc @@ -43,6 +43,7 @@ #include "api/test/mock_rtpreceiver.h" #include "api/test/mock_rtpsender.h" #include "api/test/mock_session_description_interface.h" +#include "api/test/mock_transformable_frame.h" #include "api/test/mock_transformable_video_frame.h" #include "api/test/mock_video_bitrate_allocator.h" #include "api/test/mock_video_bitrate_allocator_factory.h" diff --git a/third_party/libwebrtc/api/test/create_time_controller.cc b/third_party/libwebrtc/api/test/create_time_controller.cc index 2c356cb887..7523e05208 100644 --- a/third_party/libwebrtc/api/test/create_time_controller.cc +++ b/third_party/libwebrtc/api/test/create_time_controller.cc @@ -11,10 +11,18 @@ #include "api/test/create_time_controller.h" #include +#include +#include "absl/base/nullability.h" +#include "api/enable_media_with_defaults.h" +#include "api/environment/environment.h" +#include "api/peer_connection_interface.h" #include "call/call.h" #include "call/rtp_transport_config.h" #include "call/rtp_transport_controller_send_factory_interface.h" +#include "pc/media_factory.h" +#include "rtc_base/checks.h" +#include "system_wrappers/include/clock.h" #include "test/time_controller/external_time_controller.h" #include "test/time_controller/simulated_time_controller.h" @@ -30,24 +38,37 @@ std::unique_ptr CreateSimulatedTimeController() { Timestamp::Seconds(10000)); } -std::unique_ptr CreateTimeControllerBasedCallFactory( - TimeController* time_controller) { - class TimeControllerBasedCallFactory : public CallFactoryInterface { +void EnableMediaWithDefaultsAndTimeController( + TimeController& time_controller, + PeerConnectionFactoryDependencies& deps) { + class TimeControllerBasedFactory : public MediaFactory { public: - explicit TimeControllerBasedCallFactory(TimeController* time_controller) - : time_controller_(time_controller) {} - std::unique_ptr CreateCall(const CallConfig& config) override { - RtpTransportConfig transportConfig = config.ExtractTransportConfig(); + TimeControllerBasedFactory( + absl::Nonnull clock, + absl::Nonnull> media_factory) + : clock_(clock), media_factory_(std::move(media_factory)) {} - return Call::Create(config, time_controller_->GetClock(), + std::unique_ptr CreateCall(const CallConfig& config) override { + return Call::Create(config, clock_, config.rtp_transport_controller_send_factory->Create( - transportConfig, time_controller_->GetClock())); + config.ExtractTransportConfig(), clock_)); + } + + std::unique_ptr CreateMediaEngine( + const Environment& env, + PeerConnectionFactoryDependencies& dependencies) override { + return media_factory_->CreateMediaEngine(env, dependencies); } private: - TimeController* time_controller_; + absl::Nonnull clock_; + absl::Nonnull> media_factory_; }; - return std::make_unique(time_controller); + + EnableMediaWithDefaults(deps); + RTC_CHECK(deps.media_factory); + deps.media_factory = std::make_unique( + time_controller.GetClock(), std::move(deps.media_factory)); } } // namespace webrtc diff --git a/third_party/libwebrtc/api/test/create_time_controller.h b/third_party/libwebrtc/api/test/create_time_controller.h index e7bc9cb465..c8257da650 100644 --- a/third_party/libwebrtc/api/test/create_time_controller.h +++ b/third_party/libwebrtc/api/test/create_time_controller.h @@ -12,7 +12,7 @@ #include -#include "api/call/call_factory_interface.h" +#include "api/peer_connection_interface.h" #include "api/test/time_controller.h" namespace webrtc { @@ -24,10 +24,12 @@ std::unique_ptr CreateTimeController( // Creates a time controller that runs in simulated time. std::unique_ptr CreateSimulatedTimeController(); -// This is creates a call factory that creates Call instances that are backed by -// a time controller. -std::unique_ptr CreateTimeControllerBasedCallFactory( - TimeController* time_controller); +// Adjusts media `deps` to use clock `time_controller` provides, fills media +// related dependencies, and enables media support for a PeerConnectionFactory +// created from `deps`. +void EnableMediaWithDefaultsAndTimeController( + TimeController& time_controller, + PeerConnectionFactoryDependencies& deps); } // namespace webrtc diff --git a/third_party/libwebrtc/api/test/create_video_codec_tester.cc b/third_party/libwebrtc/api/test/create_video_codec_tester.cc deleted file mode 100644 index a1efefdb48..0000000000 --- a/third_party/libwebrtc/api/test/create_video_codec_tester.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "api/test/create_video_codec_tester.h" - -#include -#include - -#include "api/test/video_codec_tester.h" -#include "modules/video_coding/codecs/test/video_codec_tester_impl.h" - -namespace webrtc { -namespace test { - -std::unique_ptr CreateVideoCodecTester() { - return std::make_unique(); -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/api/test/create_video_codec_tester.h b/third_party/libwebrtc/api/test/create_video_codec_tester.h deleted file mode 100644 index c68864ce85..0000000000 --- a/third_party/libwebrtc/api/test/create_video_codec_tester.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_TEST_CREATE_VIDEO_CODEC_TESTER_H_ -#define API_TEST_CREATE_VIDEO_CODEC_TESTER_H_ - -#include - -#include "api/test/video_codec_tester.h" - -namespace webrtc { -namespace test { - -std::unique_ptr CreateVideoCodecTester(); - -} // namespace test -} // namespace webrtc - -#endif // API_TEST_CREATE_VIDEO_CODEC_TESTER_H_ diff --git a/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h b/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h index be703006ea..584c77fa54 100644 --- a/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h +++ b/third_party/libwebrtc/api/test/mock_transformable_audio_frame.h @@ -11,6 +11,8 @@ #ifndef API_TEST_MOCK_TRANSFORMABLE_AUDIO_FRAME_H_ #define API_TEST_MOCK_TRANSFORMABLE_AUDIO_FRAME_H_ +#include + #include "api/frame_transformer_interface.h" #include "test/gmock.h" @@ -24,6 +26,7 @@ class MockTransformableAudioFrame : public TransformableAudioFrameInterface { MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override)); MOCK_METHOD(uint32_t, GetSsrc, (), (const, override)); MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override)); + MOCK_METHOD(std::string, GetMimeType, (), (const, override)); MOCK_METHOD(rtc::ArrayView, GetContributingSources, (), diff --git a/third_party/libwebrtc/api/test/mock_transformable_frame.h b/third_party/libwebrtc/api/test/mock_transformable_frame.h new file mode 100644 index 0000000000..df20b62295 --- /dev/null +++ b/third_party/libwebrtc/api/test/mock_transformable_frame.h @@ -0,0 +1,45 @@ +/* + * Copyright 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_TEST_MOCK_TRANSFORMABLE_FRAME_H_ +#define API_TEST_MOCK_TRANSFORMABLE_FRAME_H_ + +#include + +#include +#include + +#include "api/array_view.h" +#include "api/frame_transformer_interface.h" +#include "api/units/timestamp.h" +#include "test/gmock.h" + +namespace webrtc { + +class MockTransformableFrame : public webrtc::TransformableFrameInterface { + public: + MOCK_METHOD(rtc::ArrayView, GetData, (), (const, override)); + MOCK_METHOD(void, SetData, (rtc::ArrayView), (override)); + MOCK_METHOD(uint8_t, GetPayloadType, (), (const, override)); + MOCK_METHOD(uint32_t, GetSsrc, (), (const, override)); + MOCK_METHOD(uint32_t, GetTimestamp, (), (const, override)); + MOCK_METHOD(void, SetRTPTimestamp, (uint32_t), (override)); + MOCK_METHOD(std::optional, + GetCaptureTimeIdentifier, + (), + (const, override)); + MOCK_METHOD(std::string, GetMimeType, (), (const, override)); +}; + +static_assert(!std::is_abstract_v, ""); + +} // namespace webrtc + +#endif // API_TEST_MOCK_TRANSFORMABLE_FRAME_H_ diff --git a/third_party/libwebrtc/api/test/pclf/media_configuration.h b/third_party/libwebrtc/api/test/pclf/media_configuration.h index 5bcb308c83..5c3440c293 100644 --- a/third_party/libwebrtc/api/test/pclf/media_configuration.h +++ b/third_party/libwebrtc/api/test/pclf/media_configuration.h @@ -24,7 +24,6 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/array_view.h" -#include "api/async_resolver_factory.h" #include "api/audio/audio_mixer.h" #include "api/audio_options.h" #include "api/call/call_factory_interface.h" diff --git a/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h b/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h index b2ccdf18c5..aad04c3eb6 100644 --- a/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h +++ b/third_party/libwebrtc/api/test/pclf/media_quality_test_params.h @@ -49,8 +49,6 @@ struct PeerConnectionFactoryComponents { std::unique_ptr network_controller_factory; std::unique_ptr neteq_factory; - // Will be passed to MediaEngineInterface, that will be used in - // PeerConnectionFactory. std::unique_ptr video_encoder_factory; std::unique_ptr video_decoder_factory; rtc::scoped_refptr audio_encoder_factory; diff --git a/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h b/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h index 74470cdf86..034e13ff3b 100644 --- a/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h +++ b/third_party/libwebrtc/api/test/peerconnection_quality_test_fixture.h @@ -25,7 +25,6 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/array_view.h" -#include "api/async_resolver_factory.h" #include "api/audio/audio_mixer.h" #include "api/call/call_factory_interface.h" #include "api/fec_controller.h" diff --git a/third_party/libwebrtc/api/test/video_codec_stats.cc b/third_party/libwebrtc/api/test/video_codec_stats.cc deleted file mode 100644 index fb7226701e..0000000000 --- a/third_party/libwebrtc/api/test/video_codec_stats.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "api/test/video_codec_stats.h" - -namespace webrtc { -namespace test { - -void VideoCodecStats::Stream::LogMetrics( - MetricsLogger* logger, - std::string test_case_name, - std::map metadata) const { - logger->LogMetric("width", test_case_name, width, Unit::kCount, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric("height", test_case_name, height, Unit::kCount, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric( - "frame_size_bytes", test_case_name, frame_size_bytes, Unit::kBytes, - webrtc::test::ImprovementDirection::kNeitherIsBetter, metadata); - - logger->LogMetric("keyframe", test_case_name, keyframe, Unit::kCount, - webrtc::test::ImprovementDirection::kSmallerIsBetter, - metadata); - - logger->LogMetric("qp", test_case_name, qp, Unit::kUnitless, - webrtc::test::ImprovementDirection::kSmallerIsBetter, - metadata); - - logger->LogMetric( - "encode_time_ms", test_case_name, encode_time_ms, Unit::kMilliseconds, - webrtc::test::ImprovementDirection::kSmallerIsBetter, metadata); - - logger->LogMetric( - "decode_time_ms", test_case_name, decode_time_ms, Unit::kMilliseconds, - webrtc::test::ImprovementDirection::kSmallerIsBetter, metadata); - - logger->LogMetric("target_bitrate_kbps", test_case_name, target_bitrate_kbps, - Unit::kKilobitsPerSecond, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric("target_framerate_fps", test_case_name, - target_framerate_fps, Unit::kHertz, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric("encoded_bitrate_kbps", test_case_name, - encoded_bitrate_kbps, Unit::kKilobitsPerSecond, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric("encoded_framerate_fps", test_case_name, - encoded_framerate_fps, Unit::kHertz, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric("bitrate_mismatch_pct", test_case_name, - bitrate_mismatch_pct, Unit::kPercent, - webrtc::test::ImprovementDirection::kSmallerIsBetter, - metadata); - - logger->LogMetric("framerate_mismatch_pct", test_case_name, - framerate_mismatch_pct, Unit::kPercent, - webrtc::test::ImprovementDirection::kSmallerIsBetter, - metadata); - - logger->LogMetric("transmission_time_ms", test_case_name, - transmission_time_ms, Unit::kMilliseconds, - webrtc::test::ImprovementDirection::kSmallerIsBetter, - metadata); - - logger->LogMetric("psnr_y_db", test_case_name, psnr.y, Unit::kUnitless, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric("psnr_u_db", test_case_name, psnr.u, Unit::kUnitless, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); - - logger->LogMetric("psnr_v_db", test_case_name, psnr.v, Unit::kUnitless, - webrtc::test::ImprovementDirection::kBiggerIsBetter, - metadata); -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/api/test/video_codec_stats.h b/third_party/libwebrtc/api/test/video_codec_stats.h deleted file mode 100644 index 80f8287848..0000000000 --- a/third_party/libwebrtc/api/test/video_codec_stats.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_TEST_VIDEO_CODEC_STATS_H_ -#define API_TEST_VIDEO_CODEC_STATS_H_ - -#include -#include -#include - -#include "absl/types/optional.h" -#include "api/numerics/samples_stats_counter.h" -#include "api/test/metrics/metric.h" -#include "api/test/metrics/metrics_logger.h" -#include "api/units/data_rate.h" -#include "api/units/data_size.h" -#include "api/units/frequency.h" - -namespace webrtc { -namespace test { - -// Interface for encoded and/or decoded video frame and stream statistics. -class VideoCodecStats { - public: - // Filter for slicing frames. - struct Filter { - absl::optional first_frame; - absl::optional last_frame; - absl::optional spatial_idx; - absl::optional temporal_idx; - }; - - struct Frame { - int frame_num = 0; - uint32_t timestamp_rtp = 0; - - int spatial_idx = 0; - int temporal_idx = 0; - - int width = 0; - int height = 0; - DataSize frame_size = DataSize::Zero(); - bool keyframe = false; - absl::optional qp; - absl::optional base_spatial_idx; - - Timestamp encode_start = Timestamp::Zero(); - TimeDelta encode_time = TimeDelta::Zero(); - Timestamp decode_start = Timestamp::Zero(); - TimeDelta decode_time = TimeDelta::Zero(); - - struct Psnr { - double y = 0.0; - double u = 0.0; - double v = 0.0; - }; - absl::optional psnr; - - absl::optional target_bitrate; - absl::optional target_framerate; - - bool encoded = false; - bool decoded = false; - }; - - struct Stream { - SamplesStatsCounter width; - SamplesStatsCounter height; - SamplesStatsCounter frame_size_bytes; - SamplesStatsCounter keyframe; - SamplesStatsCounter qp; - - SamplesStatsCounter encode_time_ms; - SamplesStatsCounter decode_time_ms; - - SamplesStatsCounter target_bitrate_kbps; - SamplesStatsCounter target_framerate_fps; - - SamplesStatsCounter encoded_bitrate_kbps; - SamplesStatsCounter encoded_framerate_fps; - - SamplesStatsCounter bitrate_mismatch_pct; - SamplesStatsCounter framerate_mismatch_pct; - - SamplesStatsCounter transmission_time_ms; - - struct Psnr { - SamplesStatsCounter y; - SamplesStatsCounter u; - SamplesStatsCounter v; - } psnr; - - // Logs `Stream` metrics to provided `MetricsLogger`. - void LogMetrics(MetricsLogger* logger, - std::string test_case_name, - std::map metadata = {}) const; - }; - - virtual ~VideoCodecStats() = default; - - // Returns frames from interval, spatial and temporal layer specified by given - // `filter`. - virtual std::vector Slice( - absl::optional filter = absl::nullopt) const = 0; - - // Returns video statistics aggregated for given `frames`. - virtual Stream Aggregate(const std::vector& frames) const = 0; -}; - -} // namespace test -} // namespace webrtc - -#endif // API_TEST_VIDEO_CODEC_STATS_H_ diff --git a/third_party/libwebrtc/api/test/video_codec_tester.h b/third_party/libwebrtc/api/test/video_codec_tester.h deleted file mode 100644 index c2fb89e2cb..0000000000 --- a/third_party/libwebrtc/api/test/video_codec_tester.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_TEST_VIDEO_CODEC_TESTER_H_ -#define API_TEST_VIDEO_CODEC_TESTER_H_ - -#include -#include - -#include "absl/functional/any_invocable.h" -#include "absl/types/optional.h" -#include "api/test/video_codec_stats.h" -#include "api/video/encoded_image.h" -#include "api/video/resolution.h" -#include "api/video/video_frame.h" - -namespace webrtc { -namespace test { - -// Interface for a video codec tester. The interface provides minimalistic set -// of data structures that enables implementation of decode-only, encode-only -// and encode-decode tests. -class VideoCodecTester { - public: - // Pacing settings for codec input. - struct PacingSettings { - enum PacingMode { - // Pacing is not used. Frames are sent to codec back-to-back. - kNoPacing, - // Pace with the rate equal to the target video frame rate. Pacing time is - // derived from RTP timestamp. - kRealTime, - // Pace with the explicitly provided rate. - kConstantRate, - }; - PacingMode mode = PacingMode::kNoPacing; - // Pacing rate for `kConstantRate` mode. - Frequency constant_rate = Frequency::Zero(); - }; - - struct DecoderSettings { - PacingSettings pacing; - absl::optional decoder_input_base_path; - absl::optional decoder_output_base_path; - }; - - struct EncoderSettings { - PacingSettings pacing; - absl::optional encoder_input_base_path; - absl::optional encoder_output_base_path; - }; - - virtual ~VideoCodecTester() = default; - - // Interface for a raw video frames source. - class RawVideoSource { - public: - virtual ~RawVideoSource() = default; - - // Returns next frame. If no more frames to pull, returns `absl::nullopt`. - // For analysis and pacing purposes, frame must have RTP timestamp set. The - // timestamp must represent the target video frame rate and be unique. - virtual absl::optional PullFrame() = 0; - - // Returns early pulled frame with RTP timestamp equal to `timestamp_rtp`. - virtual VideoFrame GetFrame(uint32_t timestamp_rtp, - Resolution resolution) = 0; - }; - - // Interface for a coded video frames source. - class CodedVideoSource { - public: - virtual ~CodedVideoSource() = default; - - // Returns next frame. If no more frames to pull, returns `absl::nullopt`. - // For analysis and pacing purposes, frame must have RTP timestamp set. The - // timestamp must represent the target video frame rate and be unique. - virtual absl::optional PullFrame() = 0; - }; - - // Interface for a video encoder. - class Encoder { - public: - using EncodeCallback = - absl::AnyInvocable; - - virtual ~Encoder() = default; - - virtual void Initialize() = 0; - - virtual void Encode(const VideoFrame& frame, EncodeCallback callback) = 0; - - virtual void Flush() = 0; - }; - - // Interface for a video decoder. - class Decoder { - public: - using DecodeCallback = - absl::AnyInvocable; - - virtual ~Decoder() = default; - - virtual void Initialize() = 0; - - virtual void Decode(const EncodedImage& frame, DecodeCallback callback) = 0; - - virtual void Flush() = 0; - }; - - // Pulls coded video frames from `video_source` and passes them to `decoder`. - // Returns `VideoCodecTestStats` object that contains collected per-frame - // metrics. - virtual std::unique_ptr RunDecodeTest( - CodedVideoSource* video_source, - Decoder* decoder, - const DecoderSettings& decoder_settings) = 0; - - // Pulls raw video frames from `video_source` and passes them to `encoder`. - // Returns `VideoCodecTestStats` object that contains collected per-frame - // metrics. - virtual std::unique_ptr RunEncodeTest( - RawVideoSource* video_source, - Encoder* encoder, - const EncoderSettings& encoder_settings) = 0; - - // Pulls raw video frames from `video_source`, passes them to `encoder` and - // then passes encoded frames to `decoder`. Returns `VideoCodecTestStats` - // object that contains collected per-frame metrics. - virtual std::unique_ptr RunEncodeDecodeTest( - RawVideoSource* video_source, - Encoder* encoder, - Decoder* decoder, - const EncoderSettings& encoder_settings, - const DecoderSettings& decoder_settings) = 0; -}; - -} // namespace test -} // namespace webrtc - -#endif // API_TEST_VIDEO_CODEC_TESTER_H_ diff --git a/third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build b/third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build index d99d149fa3..2b732ca51e 100644 --- a/third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build +++ b/third_party/libwebrtc/api/transport/bitrate_settings_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build b/third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build index 9168cf9156..dba9cee6bd 100644 --- a/third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build +++ b/third_party/libwebrtc/api/transport/datagram_transport_interface_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build b/third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build index fd2b2dd12b..dd3370838d 100644 --- a/third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build +++ b/third_party/libwebrtc/api/transport/field_trial_based_config_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/goog_cc_gn/moz.build b/third_party/libwebrtc/api/transport/goog_cc_gn/moz.build index 4a7c84915c..80dee942e0 100644 --- a/third_party/libwebrtc/api/transport/goog_cc_gn/moz.build +++ b/third_party/libwebrtc/api/transport/goog_cc_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/network_control_gn/moz.build b/third_party/libwebrtc/api/transport/network_control_gn/moz.build index 76dd117a86..e11b34ba71 100644 --- a/third_party/libwebrtc/api/transport/network_control_gn/moz.build +++ b/third_party/libwebrtc/api/transport/network_control_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build b/third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build index a2fe75e60e..568c7d9768 100644 --- a/third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build +++ b/third_party/libwebrtc/api/transport/rtp/dependency_descriptor_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build b/third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build index 9a7b0b69bf..9d993f6f68 100644 --- a/third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build +++ b/third_party/libwebrtc/api/transport/rtp/rtp_source_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/stun.cc b/third_party/libwebrtc/api/transport/stun.cc index 35a65fd8e8..7ef6852260 100644 --- a/third_party/libwebrtc/api/transport/stun.cc +++ b/third_party/libwebrtc/api/transport/stun.cc @@ -41,7 +41,9 @@ uint32_t ReduceTransactionId(absl::string_view transaction_id) { RTC_DCHECK(transaction_id.length() == cricket::kStunTransactionIdLength || transaction_id.length() == cricket::kStunLegacyTransactionIdLength) << transaction_id.length(); - ByteBufferReader reader(transaction_id.data(), transaction_id.size()); + ByteBufferReader reader(rtc::MakeArrayView( + reinterpret_cast(transaction_id.data()), + transaction_id.size())); uint32_t result = 0; uint32_t next; while (reader.ReadUInt32(&next)) { @@ -912,7 +914,8 @@ bool StunAddressAttribute::Read(ByteBufferReader* buf) { if (length() != SIZE_IP4) { return false; } - if (!buf->ReadBytes(reinterpret_cast(&v4addr), sizeof(v4addr))) { + if (!buf->ReadBytes(rtc::MakeArrayView(reinterpret_cast(&v4addr), + sizeof(v4addr)))) { return false; } rtc::IPAddress ipaddr(v4addr); @@ -922,7 +925,8 @@ bool StunAddressAttribute::Read(ByteBufferReader* buf) { if (length() != SIZE_IP6) { return false; } - if (!buf->ReadBytes(reinterpret_cast(&v6addr), sizeof(v6addr))) { + if (!buf->ReadBytes(rtc::MakeArrayView(reinterpret_cast(&v6addr), + sizeof(v6addr)))) { return false; } rtc::IPAddress ipaddr(v6addr); @@ -1128,13 +1132,13 @@ StunAttributeValueType StunByteStringAttribute::value_type() const { } void StunByteStringAttribute::CopyBytes(absl::string_view bytes) { - char* new_bytes = new char[bytes.size()]; + uint8_t* new_bytes = new uint8_t[bytes.size()]; memcpy(new_bytes, bytes.data(), bytes.size()); SetBytes(new_bytes, bytes.size()); } void StunByteStringAttribute::CopyBytes(const void* bytes, size_t length) { - char* new_bytes = new char[length]; + uint8_t* new_bytes = new uint8_t[length]; memcpy(new_bytes, bytes, length); SetBytes(new_bytes, length); } @@ -1142,7 +1146,7 @@ void StunByteStringAttribute::CopyBytes(const void* bytes, size_t length) { uint8_t StunByteStringAttribute::GetByte(size_t index) const { RTC_DCHECK(bytes_ != NULL); RTC_DCHECK(index < length()); - return static_cast(bytes_[index]); + return bytes_[index]; } void StunByteStringAttribute::SetByte(size_t index, uint8_t value) { @@ -1152,8 +1156,8 @@ void StunByteStringAttribute::SetByte(size_t index, uint8_t value) { } bool StunByteStringAttribute::Read(ByteBufferReader* buf) { - bytes_ = new char[length()]; - if (!buf->ReadBytes(bytes_, length())) { + bytes_ = new uint8_t[length()]; + if (!buf->ReadBytes(rtc::ArrayView(bytes_, length()))) { return false; } @@ -1166,12 +1170,12 @@ bool StunByteStringAttribute::Write(ByteBufferWriter* buf) const { if (!LengthValid(type(), length())) { return false; } - buf->WriteBytes(bytes_, length()); + buf->WriteBytes(reinterpret_cast(bytes_), length()); WritePadding(buf); return true; } -void StunByteStringAttribute::SetBytes(char* bytes, size_t length) { +void StunByteStringAttribute::SetBytes(uint8_t* bytes, size_t length) { delete[] bytes_; bytes_ = bytes; SetLength(static_cast(length)); diff --git a/third_party/libwebrtc/api/transport/stun.h b/third_party/libwebrtc/api/transport/stun.h index 4a04db33cf..62d98f71e0 100644 --- a/third_party/libwebrtc/api/transport/stun.h +++ b/third_party/libwebrtc/api/transport/stun.h @@ -519,13 +519,22 @@ class StunByteStringAttribute : public StunAttribute { StunAttributeValueType value_type() const override; - const char* bytes() const { return bytes_; } + [[deprecated("Use array_view")]] const char* bytes() const { + return reinterpret_cast(bytes_); + } + // Returns the attribute value as a string. + // Use this for attributes that are text or text-compatible. absl::string_view string_view() const { - return absl::string_view(bytes_, length()); + return absl::string_view(reinterpret_cast(bytes_), length()); + } + // Returns the attribute value as an uint8_t view. + // Use this function for values that are not text. + rtc::ArrayView array_view() const { + return rtc::MakeArrayView(bytes_, length()); } [[deprecated]] std::string GetString() const { - return std::string(bytes_, length()); + return std::string(reinterpret_cast(bytes_), length()); } void CopyBytes(const void* bytes, size_t length); @@ -538,9 +547,9 @@ class StunByteStringAttribute : public StunAttribute { bool Write(rtc::ByteBufferWriter* buf) const override; private: - void SetBytes(char* bytes, size_t length); + void SetBytes(uint8_t* bytes, size_t length); - char* bytes_; + uint8_t* bytes_; }; // Implements STUN attributes that record an error code. diff --git a/third_party/libwebrtc/api/transport/stun_types_gn/moz.build b/third_party/libwebrtc/api/transport/stun_types_gn/moz.build index 36750a2f18..ad873a1796 100644 --- a/third_party/libwebrtc/api/transport/stun_types_gn/moz.build +++ b/third_party/libwebrtc/api/transport/stun_types_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/transport/stun_unittest.cc b/third_party/libwebrtc/api/transport/stun_unittest.cc index 96ad45843b..9ad4da9a4c 100644 --- a/third_party/libwebrtc/api/transport/stun_unittest.cc +++ b/third_party/libwebrtc/api/transport/stun_unittest.cc @@ -35,7 +35,7 @@ class StunTest : public ::testing::Test { } void CheckStunTransactionID(const StunMessage& msg, - const unsigned char* expectedID, + const uint8_t* expectedID, size_t length) { ASSERT_EQ(length, msg.transaction_id().size()); ASSERT_EQ(length == kStunTransactionIdLength + 4, msg.IsLegacy()); @@ -65,10 +65,9 @@ class StunTest : public ::testing::Test { } size_t ReadStunMessageTestCase(StunMessage* msg, - const unsigned char* testcase, + const uint8_t* testcase, size_t size) { - const char* input = reinterpret_cast(testcase); - rtc::ByteBufferReader buf(input, size); + rtc::ByteBufferReader buf(rtc::MakeArrayView(testcase, size)); if (msg->Read(&buf)) { // Returns the size the stun message should report itself as being return (size - 20); @@ -85,7 +84,7 @@ class StunTest : public ::testing::Test { // clang-format off // clang formatting doesn't respect inline comments. -static const unsigned char kStunMessageWithIPv6MappedAddress[] = { +static const uint8_t kStunMessageWithIPv6MappedAddress[] = { 0x00, 0x01, 0x00, 0x18, // message header 0x21, 0x12, 0xa4, 0x42, // transaction id 0x29, 0x1f, 0xcd, 0x7c, @@ -99,7 +98,7 @@ static const unsigned char kStunMessageWithIPv6MappedAddress[] = { 0xfe, 0xe5, 0x00, 0xc3 }; -static const unsigned char kStunMessageWithIPv4MappedAddress[] = { +static const uint8_t kStunMessageWithIPv4MappedAddress[] = { 0x01, 0x01, 0x00, 0x0c, // binding response, length 12 0x21, 0x12, 0xa4, 0x42, // magic cookie 0x29, 0x1f, 0xcd, 0x7c, // transaction ID @@ -111,7 +110,7 @@ static const unsigned char kStunMessageWithIPv4MappedAddress[] = { }; // Test XOR-mapped IP addresses: -static const unsigned char kStunMessageWithIPv6XorMappedAddress[] = { +static const uint8_t kStunMessageWithIPv6XorMappedAddress[] = { 0x01, 0x01, 0x00, 0x18, // message header (binding response) 0x21, 0x12, 0xa4, 0x42, // magic cookie (rfc5389) 0xe3, 0xa9, 0x46, 0xe1, // transaction ID @@ -125,7 +124,7 @@ static const unsigned char kStunMessageWithIPv6XorMappedAddress[] = { 0xaa, 0xed, 0x01, 0xc3 }; -static const unsigned char kStunMessageWithIPv4XorMappedAddress[] = { +static const uint8_t kStunMessageWithIPv4XorMappedAddress[] = { 0x01, 0x01, 0x00, 0x0c, // message header (binding response) 0x21, 0x12, 0xa4, 0x42, // magic cookie 0x29, 0x1f, 0xcd, 0x7c, // transaction ID @@ -137,7 +136,7 @@ static const unsigned char kStunMessageWithIPv4XorMappedAddress[] = { }; // ByteString Attribute (username) -static const unsigned char kStunMessageWithByteStringAttribute[] = { +static const uint8_t kStunMessageWithByteStringAttribute[] = { 0x00, 0x01, 0x00, 0x0c, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -150,7 +149,7 @@ static const unsigned char kStunMessageWithByteStringAttribute[] = { // Message with an unknown but comprehensible optional attribute. // Parsing should succeed despite this unknown attribute. -static const unsigned char kStunMessageWithUnknownAttribute[] = { +static const uint8_t kStunMessageWithUnknownAttribute[] = { 0x00, 0x01, 0x00, 0x14, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -164,7 +163,7 @@ static const unsigned char kStunMessageWithUnknownAttribute[] = { }; // ByteString Attribute (username) with padding byte -static const unsigned char kStunMessageWithPaddedByteStringAttribute[] = { +static const uint8_t kStunMessageWithPaddedByteStringAttribute[] = { 0x00, 0x01, 0x00, 0x08, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -175,7 +174,7 @@ static const unsigned char kStunMessageWithPaddedByteStringAttribute[] = { }; // Message with an Unknown Attributes (uint16_t list) attribute. -static const unsigned char kStunMessageWithUInt16ListAttribute[] = { +static const uint8_t kStunMessageWithUInt16ListAttribute[] = { 0x00, 0x01, 0x00, 0x0c, 0x21, 0x12, 0xa4, 0x42, 0xe3, 0xa9, 0x46, 0xe1, @@ -187,7 +186,7 @@ static const unsigned char kStunMessageWithUInt16ListAttribute[] = { }; // Error response message (unauthorized) -static const unsigned char kStunMessageWithErrorAttribute[] = { +static const uint8_t kStunMessageWithErrorAttribute[] = { 0x01, 0x11, 0x00, 0x14, 0x21, 0x12, 0xa4, 0x42, 0x29, 0x1f, 0xcd, 0x7c, @@ -205,7 +204,7 @@ static const unsigned char kStunMessageWithErrorAttribute[] = { // The actual length in bytes of the invalid messages (including STUN header) static const int kRealLengthOfInvalidLengthTestCases = 32; -static const unsigned char kStunMessageWithZeroLength[] = { +static const uint8_t kStunMessageWithZeroLength[] = { 0x00, 0x01, 0x00, 0x00, // length of 0 (last 2 bytes) 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -216,7 +215,7 @@ static const unsigned char kStunMessageWithZeroLength[] = { 0x21, 0x12, 0xA4, 0x53, }; -static const unsigned char kStunMessageWithExcessLength[] = { +static const uint8_t kStunMessageWithExcessLength[] = { 0x00, 0x01, 0x00, 0x55, // length of 85 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -227,7 +226,7 @@ static const unsigned char kStunMessageWithExcessLength[] = { 0x21, 0x12, 0xA4, 0x53, }; -static const unsigned char kStunMessageWithSmallLength[] = { +static const uint8_t kStunMessageWithSmallLength[] = { 0x00, 0x01, 0x00, 0x03, // length of 3 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -238,7 +237,7 @@ static const unsigned char kStunMessageWithSmallLength[] = { 0x21, 0x12, 0xA4, 0x53, }; -static const unsigned char kStunMessageWithBadHmacAtEnd[] = { +static const uint8_t kStunMessageWithBadHmacAtEnd[] = { 0x00, 0x01, 0x00, 0x14, // message length exactly 20 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction ID @@ -253,7 +252,7 @@ static const unsigned char kStunMessageWithBadHmacAtEnd[] = { // RTCP packet, for testing we correctly ignore non stun packet types. // V=2, P=false, RC=0, Type=200, Len=6, Sender-SSRC=85, etc -static const unsigned char kRtcpPacket[] = { +static const uint8_t kRtcpPacket[] = { 0x80, 0xc8, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0xce, 0xa5, 0x18, 0x3a, 0x39, 0xcc, 0x7d, 0x09, 0x23, 0xed, 0x19, 0x07, 0x00, 0x00, 0x01, 0x56, @@ -266,7 +265,7 @@ static const unsigned char kRtcpPacket[] = { // Software name (response): "test vector" (without quotes) // Username: "evtj:h6vY" (without quotes) // Password: "VOkJxbRl1RmTxUk/WvJxBt" (without quotes) -static const unsigned char kRfc5769SampleMsgTransactionId[] = { +static const uint8_t kRfc5769SampleMsgTransactionId[] = { 0xb7, 0xe7, 0xa7, 0x01, 0xbc, 0x34, 0xd6, 0x86, 0xfa, 0x87, 0xdf, 0xae }; static const char kRfc5769SampleMsgClientSoftware[] = "STUN test client"; @@ -278,7 +277,7 @@ static const rtc::SocketAddress kRfc5769SampleMsgMappedAddress( static const rtc::SocketAddress kRfc5769SampleMsgIPv6MappedAddress( "2001:db8:1234:5678:11:2233:4455:6677", 32853); -static const unsigned char kRfc5769SampleMsgWithAuthTransactionId[] = { +static const uint8_t kRfc5769SampleMsgWithAuthTransactionId[] = { 0x78, 0xad, 0x34, 0x33, 0xc6, 0xad, 0x72, 0xc0, 0x29, 0xda, 0x41, 0x2e }; static const char kRfc5769SampleMsgWithAuthUsername[] = @@ -289,7 +288,7 @@ static const char kRfc5769SampleMsgWithAuthNonce[] = static const char kRfc5769SampleMsgWithAuthRealm[] = "example.org"; // 2.1. Sample Request -static const unsigned char kRfc5769SampleRequest[] = { +static const uint8_t kRfc5769SampleRequest[] = { 0x00, 0x01, 0x00, 0x58, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -320,7 +319,7 @@ static const unsigned char kRfc5769SampleRequest[] = { }; // 2.1. Sample Request -static const unsigned char kSampleRequestMI32[] = { +static const uint8_t kSampleRequestMI32[] = { 0x00, 0x01, 0x00, 0x48, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -347,7 +346,7 @@ static const unsigned char kSampleRequestMI32[] = { }; // 2.2. Sample IPv4 Response -static const unsigned char kRfc5769SampleResponse[] = { +static const uint8_t kRfc5769SampleResponse[] = { 0x01, 0x01, 0x00, 0x3c, // Response type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -371,7 +370,7 @@ static const unsigned char kRfc5769SampleResponse[] = { }; // 2.3. Sample IPv6 Response -static const unsigned char kRfc5769SampleResponseIPv6[] = { +static const uint8_t kRfc5769SampleResponseIPv6[] = { 0x01, 0x01, 0x00, 0x48, // Response type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -398,7 +397,7 @@ static const unsigned char kRfc5769SampleResponseIPv6[] = { }; // 2.4. Sample Request with Long-Term Authentication -static const unsigned char kRfc5769SampleRequestLongTermAuth[] = { +static const uint8_t kRfc5769SampleRequestLongTermAuth[] = { 0x00, 0x01, 0x00, 0x60, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0x78, 0xad, 0x34, 0x33, // } @@ -433,7 +432,7 @@ static const unsigned char kRfc5769SampleRequestLongTermAuth[] = { // Length parameter is changed to 0x38 from 0x58. // AddMessageIntegrity will add MI information and update the length param // accordingly. -static const unsigned char kRfc5769SampleRequestWithoutMI[] = { +static const uint8_t kRfc5769SampleRequestWithoutMI[] = { 0x00, 0x01, 0x00, 0x38, // Request type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -457,7 +456,7 @@ static const unsigned char kRfc5769SampleRequestWithoutMI[] = { // This HMAC differs from the RFC 5769 SampleRequest message. This differs // because spec uses 0x20 for the padding where as our implementation uses 0. -static const unsigned char kCalculatedHmac1[] = { +static const uint8_t kCalculatedHmac1[] = { 0x79, 0x07, 0xc2, 0xd2, // } 0xed, 0xbf, 0xea, 0x48, // } 0x0e, 0x4c, 0x76, 0xd8, // } HMAC-SHA1 fingerprint @@ -469,14 +468,14 @@ static const unsigned char kCalculatedHmac1[] = { // above since the sum is computed including header // and the header is different since the message is shorter // than when MESSAGE-INTEGRITY is used. -static const unsigned char kCalculatedHmac1_32[] = { +static const uint8_t kCalculatedHmac1_32[] = { 0xda, 0x39, 0xde, 0x5d, // } }; // Length parameter is changed to 0x1c from 0x3c. // AddMessageIntegrity will add MI information and update the length param // accordingly. -static const unsigned char kRfc5769SampleResponseWithoutMI[] = { +static const uint8_t kRfc5769SampleResponseWithoutMI[] = { 0x01, 0x01, 0x00, 0x1c, // Response type and message length 0x21, 0x12, 0xa4, 0x42, // Magic cookie 0xb7, 0xe7, 0xa7, 0x01, // } @@ -493,7 +492,7 @@ static const unsigned char kRfc5769SampleResponseWithoutMI[] = { // This HMAC differs from the RFC 5769 SampleResponse message. This differs // because spec uses 0x20 for the padding where as our implementation uses 0. -static const unsigned char kCalculatedHmac2[] = { +static const uint8_t kCalculatedHmac2[] = { 0x5d, 0x6b, 0x58, 0xbe, // } 0xad, 0x94, 0xe0, 0x7e, // } 0xef, 0x0d, 0xfc, 0x12, // } HMAC-SHA1 fingerprint @@ -505,7 +504,7 @@ static const unsigned char kCalculatedHmac2[] = { // above since the sum is computed including header // and the header is different since the message is shorter // than when MESSAGE-INTEGRITY is used. -static const unsigned char kCalculatedHmac2_32[] = { +static const uint8_t kCalculatedHmac2_32[] = { 0xe7, 0x5c, 0xd3, 0x16, // } }; @@ -513,14 +512,14 @@ static const unsigned char kCalculatedHmac2_32[] = { // A transaction ID without the 'magic cookie' portion // pjnat's test programs use this transaction ID a lot. -const unsigned char kTestTransactionId1[] = {0x029, 0x01f, 0x0cd, 0x07c, - 0x0ba, 0x058, 0x0ab, 0x0d7, - 0x0f2, 0x041, 0x001, 0x000}; +const uint8_t kTestTransactionId1[] = {0x029, 0x01f, 0x0cd, 0x07c, + 0x0ba, 0x058, 0x0ab, 0x0d7, + 0x0f2, 0x041, 0x001, 0x000}; // They use this one sometimes too. -const unsigned char kTestTransactionId2[] = {0x0e3, 0x0a9, 0x046, 0x0e1, - 0x07c, 0x000, 0x0c2, 0x062, - 0x054, 0x008, 0x001, 0x000}; +const uint8_t kTestTransactionId2[] = {0x0e3, 0x0a9, 0x046, 0x0e1, + 0x07c, 0x000, 0x0c2, 0x062, + 0x054, 0x008, 0x001, 0x000}; const in6_addr kIPv6TestAddress1 = { {{0x24, 0x01, 0xfa, 0x00, 0x00, 0x04, 0x10, 0x00, 0xbe, 0x30, 0x5b, 0xff, @@ -743,7 +742,7 @@ TEST_F(StunTest, ReadRfc5769RequestMessageLongTermAuth) { // kStunMessageWithIPv4MappedAddress, but with a different value where the // magic cookie was. TEST_F(StunTest, ReadLegacyMessage) { - unsigned char rfc3489_packet[sizeof(kStunMessageWithIPv4MappedAddress)]; + uint8_t rfc3489_packet[sizeof(kStunMessageWithIPv4MappedAddress)]; memcpy(rfc3489_packet, kStunMessageWithIPv4MappedAddress, sizeof(kStunMessageWithIPv4MappedAddress)); // Overwrite the magic cookie here. @@ -1122,10 +1121,9 @@ TEST_F(StunTest, WriteMessageWithAUInt16ListAttribute) { } // Test that we fail to read messages with invalid lengths. -void CheckFailureToRead(const unsigned char* testcase, size_t length) { +void CheckFailureToRead(const uint8_t* testcase, size_t length) { StunMessage msg; - const char* input = reinterpret_cast(testcase); - rtc::ByteBufferReader buf(input, length); + rtc::ByteBufferReader buf(rtc::MakeArrayView(testcase, length)); ASSERT_FALSE(msg.Read(&buf)); } @@ -1228,16 +1226,14 @@ TEST_F(StunTest, ValidateMessageIntegrity) { // the RFC5769 test messages used include attributes not found in basic STUN. TEST_F(StunTest, AddMessageIntegrity) { IceMessage msg; - rtc::ByteBufferReader buf( - reinterpret_cast(kRfc5769SampleRequestWithoutMI), - sizeof(kRfc5769SampleRequestWithoutMI)); + rtc::ByteBufferReader buf(kRfc5769SampleRequestWithoutMI); EXPECT_TRUE(msg.Read(&buf)); EXPECT_TRUE(msg.AddMessageIntegrity(kRfc5769SampleMsgPassword)); const StunByteStringAttribute* mi_attr = msg.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); EXPECT_EQ(20U, mi_attr->length()); - EXPECT_EQ( - 0, memcmp(mi_attr->bytes(), kCalculatedHmac1, sizeof(kCalculatedHmac1))); + EXPECT_EQ(0, memcmp(mi_attr->array_view().data(), kCalculatedHmac1, + sizeof(kCalculatedHmac1))); rtc::ByteBufferWriter buf1; EXPECT_TRUE(msg.Write(&buf1)); @@ -1246,16 +1242,14 @@ TEST_F(StunTest, AddMessageIntegrity) { kRfc5769SampleMsgPassword)); IceMessage msg2; - rtc::ByteBufferReader buf2( - reinterpret_cast(kRfc5769SampleResponseWithoutMI), - sizeof(kRfc5769SampleResponseWithoutMI)); + rtc::ByteBufferReader buf2(kRfc5769SampleResponseWithoutMI); EXPECT_TRUE(msg2.Read(&buf2)); EXPECT_TRUE(msg2.AddMessageIntegrity(kRfc5769SampleMsgPassword)); const StunByteStringAttribute* mi_attr2 = msg2.GetByteString(STUN_ATTR_MESSAGE_INTEGRITY); EXPECT_EQ(20U, mi_attr2->length()); - EXPECT_EQ( - 0, memcmp(mi_attr2->bytes(), kCalculatedHmac2, sizeof(kCalculatedHmac2))); + EXPECT_EQ(0, memcmp(mi_attr2->array_view().data(), kCalculatedHmac2, + sizeof(kCalculatedHmac2))); rtc::ByteBufferWriter buf3; EXPECT_TRUE(msg2.Write(&buf3)); @@ -1321,15 +1315,13 @@ TEST_F(StunTest, ValidateMessageIntegrity32) { // Validate that we generate correct MESSAGE-INTEGRITY-32 attributes. TEST_F(StunTest, AddMessageIntegrity32) { IceMessage msg; - rtc::ByteBufferReader buf( - reinterpret_cast(kRfc5769SampleRequestWithoutMI), - sizeof(kRfc5769SampleRequestWithoutMI)); + rtc::ByteBufferReader buf(kRfc5769SampleRequestWithoutMI); EXPECT_TRUE(msg.Read(&buf)); EXPECT_TRUE(msg.AddMessageIntegrity32(kRfc5769SampleMsgPassword)); const StunByteStringAttribute* mi_attr = msg.GetByteString(STUN_ATTR_GOOG_MESSAGE_INTEGRITY_32); EXPECT_EQ(4U, mi_attr->length()); - EXPECT_EQ(0, memcmp(mi_attr->bytes(), kCalculatedHmac1_32, + EXPECT_EQ(0, memcmp(mi_attr->array_view().data(), kCalculatedHmac1_32, sizeof(kCalculatedHmac1_32))); rtc::ByteBufferWriter buf1; @@ -1339,15 +1331,13 @@ TEST_F(StunTest, AddMessageIntegrity32) { kRfc5769SampleMsgPassword)); IceMessage msg2; - rtc::ByteBufferReader buf2( - reinterpret_cast(kRfc5769SampleResponseWithoutMI), - sizeof(kRfc5769SampleResponseWithoutMI)); + rtc::ByteBufferReader buf2(kRfc5769SampleResponseWithoutMI); EXPECT_TRUE(msg2.Read(&buf2)); EXPECT_TRUE(msg2.AddMessageIntegrity32(kRfc5769SampleMsgPassword)); const StunByteStringAttribute* mi_attr2 = msg2.GetByteString(STUN_ATTR_GOOG_MESSAGE_INTEGRITY_32); EXPECT_EQ(4U, mi_attr2->length()); - EXPECT_EQ(0, memcmp(mi_attr2->bytes(), kCalculatedHmac2_32, + EXPECT_EQ(0, memcmp(mi_attr2->array_view().data(), kCalculatedHmac2_32, sizeof(kCalculatedHmac2_32))); rtc::ByteBufferWriter buf3; @@ -1420,9 +1410,7 @@ TEST_F(StunTest, ValidateFingerprint) { TEST_F(StunTest, AddFingerprint) { IceMessage msg; - rtc::ByteBufferReader buf( - reinterpret_cast(kRfc5769SampleRequestWithoutMI), - sizeof(kRfc5769SampleRequestWithoutMI)); + rtc::ByteBufferReader buf(kRfc5769SampleRequestWithoutMI); EXPECT_TRUE(msg.Read(&buf)); EXPECT_TRUE(msg.AddFingerprint()); @@ -1435,7 +1423,7 @@ TEST_F(StunTest, AddFingerprint) { // Sample "GTURN" relay message. // clang-format off // clang formatting doesn't respect inline comments. -static const unsigned char kRelayMessage[] = { +static const uint8_t kRelayMessage[] = { 0x00, 0x01, 0x00, 88, // message header 0x21, 0x12, 0xA4, 0x42, // magic cookie '0', '1', '2', '3', // transaction id @@ -1470,13 +1458,11 @@ static const unsigned char kRelayMessage[] = { TEST_F(StunTest, ReadRelayMessage) { RelayMessage msg; - const char* input = reinterpret_cast(kRelayMessage); - size_t size = sizeof(kRelayMessage); - rtc::ByteBufferReader buf(input, size); + rtc::ByteBufferReader buf(kRelayMessage); EXPECT_TRUE(msg.Read(&buf)); EXPECT_EQ(STUN_BINDING_REQUEST, msg.type()); - EXPECT_EQ(size - 20, msg.length()); + EXPECT_EQ(sizeof(kRelayMessage) - 20, msg.length()); EXPECT_EQ("0123456789ab", msg.transaction_id()); RelayMessage msg2(STUN_BINDING_REQUEST, "0123456789ab"); @@ -1516,7 +1502,7 @@ TEST_F(StunTest, ReadRelayMessage) { bytes = msg.GetByteString(STUN_ATTR_MAGIC_COOKIE); ASSERT_TRUE(bytes != NULL); EXPECT_EQ(4U, bytes->length()); - EXPECT_EQ(0, memcmp(bytes->bytes(), TURN_MAGIC_COOKIE_VALUE, + EXPECT_EQ(0, memcmp(bytes->array_view().data(), TURN_MAGIC_COOKIE_VALUE, sizeof(TURN_MAGIC_COOKIE_VALUE))); bytes2 = StunAttribute::CreateByteString(STUN_ATTR_MAGIC_COOKIE); @@ -1565,21 +1551,21 @@ TEST_F(StunTest, ReadRelayMessage) { rtc::ByteBufferWriter out; EXPECT_TRUE(msg.Write(&out)); - EXPECT_EQ(size, out.Length()); + EXPECT_EQ(sizeof(kRelayMessage), out.Length()); size_t len1 = out.Length(); rtc::ByteBufferReader read_buf(out); std::string outstring; read_buf.ReadString(&outstring, len1); - EXPECT_EQ(0, memcmp(outstring.c_str(), input, len1)); + EXPECT_EQ(0, memcmp(outstring.c_str(), kRelayMessage, len1)); rtc::ByteBufferWriter out2; EXPECT_TRUE(msg2.Write(&out2)); - EXPECT_EQ(size, out2.Length()); + EXPECT_EQ(sizeof(kRelayMessage), out2.Length()); size_t len2 = out2.Length(); rtc::ByteBufferReader read_buf2(out2); std::string outstring2; read_buf2.ReadString(&outstring2, len2); - EXPECT_EQ(0, memcmp(outstring2.c_str(), input, len2)); + EXPECT_EQ(0, memcmp(outstring2.c_str(), kRelayMessage, len2)); } // Test that we can remove attribute from a message. @@ -1600,8 +1586,9 @@ TEST_F(StunTest, RemoveAttribute) { auto attr = msg.RemoveAttribute(STUN_ATTR_USERNAME); ASSERT_NE(attr, nullptr); EXPECT_EQ(attr->type(), STUN_ATTR_USERNAME); - EXPECT_STREQ("kes", - static_cast(attr.get())->bytes()); + EXPECT_STREQ("kes", static_cast(attr.get()) + ->string_view() + .data()); EXPECT_LT(msg.length(), len); } @@ -1623,8 +1610,9 @@ TEST_F(StunTest, RemoveAttribute) { auto attr = msg.RemoveAttribute(STUN_ATTR_USERNAME); ASSERT_NE(attr, nullptr); EXPECT_EQ(attr->type(), STUN_ATTR_USERNAME); - EXPECT_STREQ("kenta", - static_cast(attr.get())->bytes()); + EXPECT_STREQ("kenta", static_cast(attr.get()) + ->string_view() + .data()); } // Remove should remove the last added occurrence. @@ -1632,8 +1620,9 @@ TEST_F(StunTest, RemoveAttribute) { auto attr = msg.RemoveAttribute(STUN_ATTR_USERNAME); ASSERT_NE(attr, nullptr); EXPECT_EQ(attr->type(), STUN_ATTR_USERNAME); - EXPECT_STREQ("kes", - static_cast(attr.get())->bytes()); + EXPECT_STREQ("kes", static_cast(attr.get()) + ->string_view() + .data()); } // Removing something that does exist should return nullptr. @@ -1666,8 +1655,9 @@ TEST_F(StunTest, CopyAttribute) { auto copy = CopyStunAttribute(*attr.get(), buffer_ptr); ASSERT_EQ(copy->value_type(), STUN_VALUE_BYTE_STRING); - EXPECT_STREQ("kes", - static_cast(copy.get())->bytes()); + EXPECT_STREQ("kes", static_cast(copy.get()) + ->string_view() + .data()); } { // Test StunAddressAttribute. @@ -1826,7 +1816,7 @@ TEST_F(StunTest, GoogMiscInfo) { ASSERT_EQ(size, out.Length()); size_t read_size = ReadStunMessageTestCase( - &msg, reinterpret_cast(out.Data()), out.Length()); + &msg, reinterpret_cast(out.Data()), out.Length()); ASSERT_EQ(read_size + 20, size); CheckStunHeader(msg, STUN_BINDING_REQUEST, read_size); const StunUInt16ListAttribute* types = @@ -1860,9 +1850,7 @@ TEST_F(StunTest, ValidateMessageIntegrityWithParser) { webrtc::metrics::Reset(); // Ensure counters start from zero. // Try the messages from RFC 5769. StunMessage message; - rtc::ByteBufferReader reader( - reinterpret_cast(kRfc5769SampleRequest), - sizeof(kRfc5769SampleRequest)); + rtc::ByteBufferReader reader(kRfc5769SampleRequest); EXPECT_TRUE(message.Read(&reader)); EXPECT_EQ(message.ValidateMessageIntegrity(kRfc5769SampleMsgPassword), StunMessage::IntegrityStatus::kIntegrityOk); diff --git a/third_party/libwebrtc/api/transport_api_gn/moz.build b/third_party/libwebrtc/api/transport_api_gn/moz.build index af080bee0b..506cb2f24d 100644 --- a/third_party/libwebrtc/api/transport_api_gn/moz.build +++ b/third_party/libwebrtc/api/transport_api_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/units/data_rate_gn/moz.build b/third_party/libwebrtc/api/units/data_rate_gn/moz.build index 4964c3e05f..b2bb9b7c5f 100644 --- a/third_party/libwebrtc/api/units/data_rate_gn/moz.build +++ b/third_party/libwebrtc/api/units/data_rate_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/units/data_size_gn/moz.build b/third_party/libwebrtc/api/units/data_size_gn/moz.build index 0fe0bc100b..ceaa9da9a2 100644 --- a/third_party/libwebrtc/api/units/data_size_gn/moz.build +++ b/third_party/libwebrtc/api/units/data_size_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/units/frequency_gn/moz.build b/third_party/libwebrtc/api/units/frequency_gn/moz.build index 413a57a8f3..8b0607cf75 100644 --- a/third_party/libwebrtc/api/units/frequency_gn/moz.build +++ b/third_party/libwebrtc/api/units/frequency_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/units/time_delta_gn/moz.build b/third_party/libwebrtc/api/units/time_delta_gn/moz.build index 39355ed588..6220551614 100644 --- a/third_party/libwebrtc/api/units/time_delta_gn/moz.build +++ b/third_party/libwebrtc/api/units/time_delta_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/units/timestamp_gn/moz.build b/third_party/libwebrtc/api/units/timestamp_gn/moz.build index da68eea160..083b864ff0 100644 --- a/third_party/libwebrtc/api/units/timestamp_gn/moz.build +++ b/third_party/libwebrtc/api/units/timestamp_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/BUILD.gn b/third_party/libwebrtc/api/video/BUILD.gn index 807fdcc3a9..5ec689c096 100644 --- a/third_party/libwebrtc/api/video/BUILD.gn +++ b/third_party/libwebrtc/api/video/BUILD.gn @@ -67,6 +67,7 @@ rtc_library("video_frame") { ":video_rtp_headers", "..:array_view", "..:make_ref_counted", + "..:ref_count", "..:rtp_packet_info", "..:scoped_refptr", "..:video_track_source_constraints", diff --git a/third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build b/third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build index cb32b05fa6..620fba65aa 100644 --- a/third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build +++ b/third_party/libwebrtc/api/video/builtin_video_bitrate_allocator_factory_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/encoded_frame_gn/moz.build b/third_party/libwebrtc/api/video/encoded_frame_gn/moz.build index fdb34bf903..4c92d824ae 100644 --- a/third_party/libwebrtc/api/video/encoded_frame_gn/moz.build +++ b/third_party/libwebrtc/api/video/encoded_frame_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/encoded_image_gn/moz.build b/third_party/libwebrtc/api/video/encoded_image_gn/moz.build index 3bc012ad28..25d2d0998e 100644 --- a/third_party/libwebrtc/api/video/encoded_image_gn/moz.build +++ b/third_party/libwebrtc/api/video/encoded_image_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/frame_buffer_gn/moz.build b/third_party/libwebrtc/api/video/frame_buffer_gn/moz.build index 2614e67133..048097ce50 100644 --- a/third_party/libwebrtc/api/video/frame_buffer_gn/moz.build +++ b/third_party/libwebrtc/api/video/frame_buffer_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build b/third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build index ace02623f7..a5b4399e4a 100644 --- a/third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build +++ b/third_party/libwebrtc/api/video/recordable_encoded_frame_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/render_resolution_gn/moz.build b/third_party/libwebrtc/api/video/render_resolution_gn/moz.build index f27e4cc944..6ee89b6451 100644 --- a/third_party/libwebrtc/api/video/render_resolution_gn/moz.build +++ b/third_party/libwebrtc/api/video/render_resolution_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/resolution_gn/moz.build b/third_party/libwebrtc/api/video/resolution_gn/moz.build index 673bb4f1c9..de79a64a66 100644 --- a/third_party/libwebrtc/api/video/resolution_gn/moz.build +++ b/third_party/libwebrtc/api/video/resolution_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_adaptation_gn/moz.build b/third_party/libwebrtc/api/video/video_adaptation_gn/moz.build index ffff5639ee..4483b3eaef 100644 --- a/third_party/libwebrtc/api/video/video_adaptation_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_adaptation_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build b/third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build index be63dc8252..1196221e63 100644 --- a/third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_bitrate_allocation_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build b/third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build index 222bcaf251..ff4934b7b5 100644 --- a/third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_bitrate_allocator_factory_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build b/third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build index e7f3f5a4de..758cbb7521 100644 --- a/third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_bitrate_allocator_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build b/third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build index 403c521a1f..2275aa4aa1 100644 --- a/third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_codec_constants_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_frame.h b/third_party/libwebrtc/api/video/video_frame.h index 2608f9aa42..5b77bcca23 100644 --- a/third_party/libwebrtc/api/video/video_frame.h +++ b/third_party/libwebrtc/api/video/video_frame.h @@ -33,10 +33,10 @@ class RTC_EXPORT VideoFrame { static constexpr uint16_t kNotSetId = 0; struct RTC_EXPORT UpdateRect { - int offset_x; - int offset_y; - int width; - int height; + int offset_x = 0; + int offset_y = 0; + int width = 0; + int height = 0; // Makes this UpdateRect a bounding box of this and other rect. void Union(const UpdateRect& other); diff --git a/third_party/libwebrtc/api/video/video_frame_buffer.h b/third_party/libwebrtc/api/video/video_frame_buffer.h index aaf786699f..ca6e9067db 100644 --- a/third_party/libwebrtc/api/video/video_frame_buffer.h +++ b/third_party/libwebrtc/api/video/video_frame_buffer.h @@ -14,8 +14,8 @@ #include #include "api/array_view.h" +#include "api/ref_count.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -44,7 +44,7 @@ class NV12BufferInterface; // performance by providing an optimized path without intermediate conversions. // Frame metadata such as rotation and timestamp are stored in // webrtc::VideoFrame, and not here. -class RTC_EXPORT VideoFrameBuffer : public rtc::RefCountInterface { +class RTC_EXPORT VideoFrameBuffer : public webrtc::RefCountInterface { public: // New frame buffer types will be added conservatively when there is an // opportunity to optimize the path between some pair of video source and diff --git a/third_party/libwebrtc/api/video/video_frame_gn/moz.build b/third_party/libwebrtc/api/video/video_frame_gn/moz.build index b0fc90582b..203b03a0a3 100644 --- a/third_party/libwebrtc/api/video/video_frame_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_frame_gn/moz.build @@ -206,7 +206,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -216,10 +215,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build b/third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build index 7fe6e4df95..1243513335 100644 --- a/third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_frame_i010_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build b/third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build index d80dda9178..6616ea0dd6 100644 --- a/third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_frame_metadata_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_frame_type_gn/moz.build b/third_party/libwebrtc/api/video/video_frame_type_gn/moz.build index 8fcbef76e8..ab7548fe8d 100644 --- a/third_party/libwebrtc/api/video/video_frame_type_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_frame_type_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build b/third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build index b8ba6ec54b..7f88b15c07 100644 --- a/third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_layers_allocation_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build b/third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build index f65965f80b..2f02f285f2 100644 --- a/third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_rtp_headers_gn/moz.build @@ -198,7 +198,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -208,10 +207,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build b/third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build index 7b8a329463..f75eac803f 100644 --- a/third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build +++ b/third_party/libwebrtc/api/video/video_stream_encoder_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build b/third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build index c3642c46d0..866df39c97 100644 --- a/third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build +++ b/third_party/libwebrtc/api/video_codecs/bitstream_parser_api_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build b/third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build index 4e928c91a4..e8139cb6f2 100644 --- a/third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build +++ b/third_party/libwebrtc/api/video_codecs/rtc_software_fallback_wrappers_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build b/third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build index d63795ed94..491c4880cc 100644 --- a/third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build +++ b/third_party/libwebrtc/api/video_codecs/scalability_mode_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build b/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build index 89cce4215b..c6c127e5b6 100644 --- a/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build +++ b/third_party/libwebrtc/api/video_codecs/video_codecs_api_gn/moz.build @@ -205,7 +205,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -215,10 +214,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build b/third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build index e757e9ed51..7131057c2f 100644 --- a/third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build +++ b/third_party/libwebrtc/api/video_codecs/vp8_temporal_layers_factory_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build b/third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build index 8213e3088f..9e9852b71f 100644 --- a/third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build +++ b/third_party/libwebrtc/api/video_track_source_constraints_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/api/wrapping_async_dns_resolver.h b/third_party/libwebrtc/api/wrapping_async_dns_resolver.h deleted file mode 100644 index b384f97652..0000000000 --- a/third_party/libwebrtc/api/wrapping_async_dns_resolver.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2021 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef API_WRAPPING_ASYNC_DNS_RESOLVER_H_ -#define API_WRAPPING_ASYNC_DNS_RESOLVER_H_ - -#include -#include -#include - -#include "absl/memory/memory.h" -#include "api/async_dns_resolver.h" -#include "api/sequence_checker.h" -#include "rtc_base/async_resolver.h" -#include "rtc_base/async_resolver_interface.h" -#include "rtc_base/checks.h" -#include "rtc_base/socket_address.h" -#include "rtc_base/third_party/sigslot/sigslot.h" -#include "rtc_base/thread_annotations.h" - -// This file defines a DNS resolver that wraps an old-style -// AsyncResolver. -// It is part of the conversion to the newer interface, and will go away -// once conversion is finished. -// TODO(bugs.webrtc.org/12598): Delete this API. - -namespace webrtc { - -class [[deprecated("Use AsyncDnsResolver directly")]] WrappingAsyncDnsResolver; - -class [[deprecated( - "Use AsyncDnsResolver directly")]] RTC_EXPORT WrappingAsyncDnsResolverResult - : public AsyncDnsResolverResult { - public: - explicit WrappingAsyncDnsResolverResult(WrappingAsyncDnsResolver* owner) - : owner_(owner) {} - ~WrappingAsyncDnsResolverResult() {} - - // Note: Inline declaration not possible, since it refers to - // WrappingAsyncDnsResolver. - bool GetResolvedAddress(int family, rtc::SocketAddress* addr) const override; - int GetError() const override; - - private: - WrappingAsyncDnsResolver* const owner_; -}; - -class RTC_EXPORT WrappingAsyncDnsResolver : public AsyncDnsResolverInterface, - public sigslot::has_slots<> { - public: -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - explicit WrappingAsyncDnsResolver(rtc::AsyncResolverInterface* wrapped) - : wrapped_(absl::WrapUnique(wrapped)), result_(this) {} - - ~WrappingAsyncDnsResolver() override { - // Workaround to get around the fact that sigslot-using objects can't be - // destroyed from within their callback: Alert class users early. - // TODO(bugs.webrtc.org/12651): Delete this class once the sigslot users are - // gone. - RTC_CHECK(!within_resolve_result_); - wrapped_.release()->Destroy(false); - } - - void Start(const rtc::SocketAddress& addr, - absl::AnyInvocable callback) override { - RTC_DCHECK_RUN_ON(&sequence_checker_); - PrepareToResolve(std::move(callback)); - wrapped_->Start(addr); - } - - void Start(const rtc::SocketAddress& addr, - int family, - absl::AnyInvocable callback) override { - RTC_DCHECK_RUN_ON(&sequence_checker_); - PrepareToResolve(std::move(callback)); - wrapped_->Start(addr, family); - } - - const AsyncDnsResolverResult& result() const override { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK_EQ(State::kResolved, state_); - return result_; - } - - private: - enum class State { kNotStarted, kStarted, kResolved }; - - friend class WrappingAsyncDnsResolverResult; - // For use by WrappingAsyncDnsResolverResult - rtc::AsyncResolverInterface* wrapped() const { - RTC_DCHECK_RUN_ON(&sequence_checker_); - return wrapped_.get(); - } - - void PrepareToResolve(absl::AnyInvocable callback) { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK_EQ(State::kNotStarted, state_); - state_ = State::kStarted; - callback_ = std::move(callback); - wrapped_->SignalDone.connect(this, - &WrappingAsyncDnsResolver::OnResolveResult); - } - - void OnResolveResult(rtc::AsyncResolverInterface* ref) { - RTC_DCHECK_RUN_ON(&sequence_checker_); - RTC_DCHECK(state_ == State::kStarted); - RTC_DCHECK_EQ(ref, wrapped_.get()); - state_ = State::kResolved; - within_resolve_result_ = true; - callback_(); - within_resolve_result_ = false; - } - - // The class variables need to be accessed on a single thread. - SequenceChecker sequence_checker_; - absl::AnyInvocable callback_ RTC_GUARDED_BY(sequence_checker_); - std::unique_ptr wrapped_ - RTC_GUARDED_BY(sequence_checker_); - State state_ RTC_GUARDED_BY(sequence_checker_) = State::kNotStarted; - WrappingAsyncDnsResolverResult result_ RTC_GUARDED_BY(sequence_checker_); - bool within_resolve_result_ RTC_GUARDED_BY(sequence_checker_) = false; -#pragma clang diagnostic pop -}; - -} // namespace webrtc - -#endif // API_WRAPPING_ASYNC_DNS_RESOLVER_H_ diff --git a/third_party/libwebrtc/audio/BUILD.gn b/third_party/libwebrtc/audio/BUILD.gn index ec09e5a350..09562b9131 100644 --- a/third_party/libwebrtc/audio/BUILD.gn +++ b/third_party/libwebrtc/audio/BUILD.gn @@ -223,6 +223,7 @@ if (rtc_include_tests) { "utility:utility_tests", "//testing/gtest", ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] } rtc_library("channel_receive_unittest") { @@ -241,6 +242,7 @@ if (rtc_include_tests) { "../rtc_base:logging", "../rtc_base:threading", "../test:audio_codec_mocks", + "../test:mock_frame_transformer", "../test:mock_transport", "../test:test_support", "../test/time_controller", diff --git a/third_party/libwebrtc/audio/audio_gn/moz.build b/third_party/libwebrtc/audio/audio_gn/moz.build index e81a4f673b..da615157b2 100644 --- a/third_party/libwebrtc/audio/audio_gn/moz.build +++ b/third_party/libwebrtc/audio/audio_gn/moz.build @@ -212,7 +212,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -222,10 +221,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/audio/audio_send_stream.cc b/third_party/libwebrtc/audio/audio_send_stream.cc index bffb910832..e7ebb2bf4e 100644 --- a/third_party/libwebrtc/audio/audio_send_stream.cc +++ b/third_party/libwebrtc/audio/audio_send_stream.cc @@ -637,12 +637,14 @@ bool AudioSendStream::SetupSendCodec(const Config& new_config) { } // Wrap the encoder in a RED encoder, if RED is enabled. + SdpAudioFormat format = spec.format; if (spec.red_payload_type) { AudioEncoderCopyRed::Config red_config; red_config.payload_type = *spec.red_payload_type; red_config.speech_encoder = std::move(encoder); encoder = std::make_unique(std::move(red_config), field_trials_); + format.name = cricket::kRedCodecName; } // Set currently known overhead (used in ANA, opus only). @@ -656,7 +658,7 @@ bool AudioSendStream::SetupSendCodec(const Config& new_config) { } StoreEncoderProperties(encoder->SampleRateHz(), encoder->NumChannels()); - channel_send_->SetEncoder(new_config.send_codec_spec->payload_type, + channel_send_->SetEncoder(new_config.send_codec_spec->payload_type, format, std::move(encoder)); return true; diff --git a/third_party/libwebrtc/audio/audio_send_stream_unittest.cc b/third_party/libwebrtc/audio/audio_send_stream_unittest.cc index d842afdfe5..c854f734b5 100644 --- a/third_party/libwebrtc/audio/audio_send_stream_unittest.cc +++ b/third_party/libwebrtc/audio/audio_send_stream_unittest.cc @@ -242,11 +242,11 @@ struct ConfigHelper { void SetupMockForSetupSendCodec(bool expect_set_encoder_call) { if (expect_set_encoder_call) { EXPECT_CALL(*channel_send_, SetEncoder) - .WillOnce( - [this](int payload_type, std::unique_ptr encoder) { - this->audio_encoder_ = std::move(encoder); - return true; - }); + .WillOnce([this](int payload_type, const SdpAudioFormat& format, + std::unique_ptr encoder) { + this->audio_encoder_ = std::move(encoder); + return true; + }); } } @@ -595,6 +595,7 @@ TEST(AudioSendStreamTest, SendCodecCanApplyVad) { std::unique_ptr stolen_encoder; EXPECT_CALL(*helper.channel_send(), SetEncoder) .WillOnce([&stolen_encoder](int payload_type, + const SdpAudioFormat& format, std::unique_ptr encoder) { stolen_encoder = std::move(encoder); return true; diff --git a/third_party/libwebrtc/audio/channel_receive.cc b/third_party/libwebrtc/audio/channel_receive.cc index c714b1dd4d..aff21fa72a 100644 --- a/third_party/libwebrtc/audio/channel_receive.cc +++ b/third_party/libwebrtc/audio/channel_receive.cc @@ -47,6 +47,7 @@ #include "rtc_base/numerics/safe_minmax.h" #include "rtc_base/numerics/sequence_number_unwrapper.h" #include "rtc_base/race_checker.h" +#include "rtc_base/strings/string_builder.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/time_utils.h" @@ -313,6 +314,8 @@ class ChannelReceive : public ChannelReceiveInterface, mutable Mutex rtcp_counter_mutex_; RtcpPacketTypeCounter rtcp_packet_type_counter_ RTC_GUARDED_BY(rtcp_counter_mutex_); + + std::map payload_type_map_; }; void ChannelReceive::OnReceivedPayloadData( @@ -639,6 +642,7 @@ void ChannelReceive::SetReceiveCodecs( RTC_DCHECK_GE(kv.second.clockrate_hz, 1000); payload_type_frequencies_[kv.first] = kv.second.clockrate_hz; } + payload_type_map_ = codecs; acm_receiver_.SetCodecs(codecs); } @@ -725,7 +729,14 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet, if (frame_transformer_delegate_) { // Asynchronously transform the received payload. After the payload is // transformed, the delegate will call OnReceivedPayloadData to handle it. - frame_transformer_delegate_->Transform(payload_data, header, remote_ssrc_); + char buf[1024]; + rtc::SimpleStringBuilder mime_type(buf); + auto it = payload_type_map_.find(header.payloadType); + mime_type << MediaTypeToString(cricket::MEDIA_TYPE_AUDIO) << "/" + << (it != payload_type_map_.end() ? it->second.name + : "x-unknown"); + frame_transformer_delegate_->Transform(payload_data, header, remote_ssrc_, + mime_type.str()); } else { OnReceivedPayloadData(payload_data, header); } @@ -917,12 +928,19 @@ void ChannelReceive::SetAssociatedSendChannel( void ChannelReceive::SetDepacketizerToDecoderFrameTransformer( rtc::scoped_refptr frame_transformer) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); - // Depending on when the channel is created, the transformer might be set - // twice. Don't replace the delegate if it was already initialized. - if (!frame_transformer || frame_transformer_delegate_) { + if (!frame_transformer) { RTC_DCHECK_NOTREACHED() << "Not setting the transformer?"; return; } + if (frame_transformer_delegate_) { + // Depending on when the channel is created, the transformer might be set + // twice. Don't replace the delegate if it was already initialized. + // TODO(crbug.com/webrtc/15674): Prevent multiple calls during + // reconfiguration. + RTC_CHECK_EQ(frame_transformer_delegate_->FrameTransformer(), + frame_transformer); + return; + } InitFrameTransformerDelegate(std::move(frame_transformer)); } diff --git a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.cc b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.cc index 2d2893b8f7..8a7dda826e 100644 --- a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.cc +++ b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.cc @@ -10,6 +10,7 @@ #include "audio/channel_receive_frame_transformer_delegate.h" +#include #include #include "rtc_base/buffer.h" @@ -22,10 +23,12 @@ class TransformableIncomingAudioFrame public: TransformableIncomingAudioFrame(rtc::ArrayView payload, const RTPHeader& header, - uint32_t ssrc) + uint32_t ssrc, + const std::string& codec_mime_type) : payload_(payload.data(), payload.size()), header_(header), - ssrc_(ssrc) {} + ssrc_(ssrc), + codec_mime_type_(codec_mime_type) {} ~TransformableIncomingAudioFrame() override = default; rtc::ArrayView GetData() const override { return payload_; } @@ -45,6 +48,7 @@ class TransformableIncomingAudioFrame } Direction GetDirection() const override { return Direction::kReceiver; } + std::string GetMimeType() const override { return codec_mime_type_; } const absl::optional SequenceNumber() const override { return header_.sequenceNumber; } @@ -65,6 +69,7 @@ class TransformableIncomingAudioFrame rtc::Buffer payload_; RTPHeader header_; uint32_t ssrc_; + std::string codec_mime_type_; }; } // namespace @@ -92,10 +97,16 @@ void ChannelReceiveFrameTransformerDelegate::Reset() { void ChannelReceiveFrameTransformerDelegate::Transform( rtc::ArrayView packet, const RTPHeader& header, - uint32_t ssrc) { + uint32_t ssrc, + const std::string& codec_mime_type) { RTC_DCHECK_RUN_ON(&sequence_checker_); - frame_transformer_->Transform( - std::make_unique(packet, header, ssrc)); + if (short_circuit_) { + receive_frame_callback_(packet, header); + } else { + frame_transformer_->Transform( + std::make_unique(packet, header, ssrc, + codec_mime_type)); + } } void ChannelReceiveFrameTransformerDelegate::OnTransformedFrame( @@ -107,6 +118,14 @@ void ChannelReceiveFrameTransformerDelegate::OnTransformedFrame( }); } +void ChannelReceiveFrameTransformerDelegate::StartShortCircuiting() { + rtc::scoped_refptr delegate(this); + channel_receive_thread_->PostTask([delegate = std::move(delegate)]() mutable { + RTC_DCHECK_RUN_ON(&delegate->sequence_checker_); + delegate->short_circuit_ = true; + }); +} + void ChannelReceiveFrameTransformerDelegate::ReceiveFrame( std::unique_ptr frame) const { RTC_DCHECK_RUN_ON(&sequence_checker_); @@ -138,4 +157,11 @@ void ChannelReceiveFrameTransformerDelegate::ReceiveFrame( // originally from this receiver. receive_frame_callback_(frame->GetData(), header); } + +rtc::scoped_refptr +ChannelReceiveFrameTransformerDelegate::FrameTransformer() { + RTC_DCHECK_RUN_ON(&sequence_checker_); + return frame_transformer_; +} + } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.h b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.h index 04ad7c4695..37ff75c2e9 100644 --- a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.h +++ b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate.h @@ -12,6 +12,7 @@ #define AUDIO_CHANNEL_RECEIVE_FRAME_TRANSFORMER_DELEGATE_H_ #include +#include #include "api/frame_transformer_interface.h" #include "api/sequence_checker.h" @@ -48,16 +49,21 @@ class ChannelReceiveFrameTransformerDelegate : public TransformedFrameCallback { // the frame asynchronously. void Transform(rtc::ArrayView packet, const RTPHeader& header, - uint32_t ssrc); + uint32_t ssrc, + const std::string& codec_mime_type); // Implements TransformedFrameCallback. Can be called on any thread. void OnTransformedFrame( std::unique_ptr frame) override; + void StartShortCircuiting() override; + // Delegates the call to ChannelReceive::OnReceivedPayloadData on the // `channel_receive_thread_`, by calling `receive_frame_callback_`. void ReceiveFrame(std::unique_ptr frame) const; + rtc::scoped_refptr FrameTransformer(); + protected: ~ChannelReceiveFrameTransformerDelegate() override = default; @@ -68,6 +74,7 @@ class ChannelReceiveFrameTransformerDelegate : public TransformedFrameCallback { rtc::scoped_refptr frame_transformer_ RTC_GUARDED_BY(sequence_checker_); TaskQueueBase* const channel_receive_thread_; + bool short_circuit_ RTC_GUARDED_BY(sequence_checker_) = false; }; } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc index 38ceb6d96d..8bdf217d5a 100644 --- a/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc +++ b/third_party/libwebrtc/audio/channel_receive_frame_transformer_delegate_unittest.cc @@ -93,7 +93,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, [&callback](std::unique_ptr frame) { callback->OnTransformedFrame(std::move(frame)); }); - delegate->Transform(packet, header, 1111 /*ssrc*/); + delegate->Transform(packet, header, /*ssrc=*/1111, /*mimeType=*/"audio/opus"); rtc::ThreadManager::ProcessAllMessageQueuesForTesting(); } @@ -126,7 +126,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, static_cast(frame.get()); callback->OnTransformedFrame(CloneSenderAudioFrame(transformed_frame)); }); - delegate->Transform(packet, header, 1111 /*ssrc*/); + delegate->Transform(packet, header, /*ssrc=*/1111, /*mimeType=*/"audio/opus"); rtc::ThreadManager::ProcessAllMessageQueuesForTesting(); } @@ -150,5 +150,29 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, rtc::ThreadManager::ProcessAllMessageQueuesForTesting(); } +TEST(ChannelReceiveFrameTransformerDelegateTest, + ShortCircuitingSkipsTransform) { + rtc::AutoThread main_thread; + rtc::scoped_refptr mock_frame_transformer = + rtc::make_ref_counted>(); + MockChannelReceive mock_channel; + rtc::scoped_refptr delegate = + rtc::make_ref_counted( + mock_channel.callback(), mock_frame_transformer, + rtc::Thread::Current()); + const uint8_t data[] = {1, 2, 3, 4}; + rtc::ArrayView packet(data, sizeof(data)); + RTPHeader header; + + delegate->StartShortCircuiting(); + rtc::ThreadManager::ProcessAllMessageQueuesForTesting(); + + // Will not call the actual transformer. + EXPECT_CALL(*mock_frame_transformer, Transform).Times(0); + // Will pass the frame straight to the channel. + EXPECT_CALL(mock_channel, ReceiveFrame); + delegate->Transform(packet, header, /*ssrc=*/1111, /*mimeType=*/"audio/opus"); +} + } // namespace } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_receive_unittest.cc b/third_party/libwebrtc/audio/channel_receive_unittest.cc index 4b7b7c0231..aab8a95d8b 100644 --- a/third_party/libwebrtc/audio/channel_receive_unittest.cc +++ b/third_party/libwebrtc/audio/channel_receive_unittest.cc @@ -29,6 +29,7 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_decoder_factory.h" +#include "test/mock_frame_transformer.h" #include "test/mock_transport.h" #include "test/time_controller/simulated_time_controller.h" @@ -226,6 +227,41 @@ TEST_F(ChannelReceiveTest, CaptureStartTimeBecomesValid) { EXPECT_NE(ProbeCaptureStartNtpTime(*channel), -1); } +TEST_F(ChannelReceiveTest, SettingFrameTransformer) { + auto channel = CreateTestChannelReceive(); + + rtc::scoped_refptr mock_frame_transformer = + rtc::make_ref_counted(); + + EXPECT_CALL(*mock_frame_transformer, RegisterTransformedFrameCallback); + channel->SetDepacketizerToDecoderFrameTransformer(mock_frame_transformer); + + // Must start playout, otherwise packet is discarded. + channel->StartPlayout(); + + RtpPacketReceived packet = CreateRtpPacket(); + + // Receive one RTP packet, this should be transformed. + EXPECT_CALL(*mock_frame_transformer, Transform); + channel->OnRtpPacket(packet); +} + +TEST_F(ChannelReceiveTest, SettingFrameTransformerMultipleTimes) { + auto channel = CreateTestChannelReceive(); + + rtc::scoped_refptr mock_frame_transformer = + rtc::make_ref_counted(); + + EXPECT_CALL(*mock_frame_transformer, RegisterTransformedFrameCallback); + channel->SetDepacketizerToDecoderFrameTransformer(mock_frame_transformer); + + // Set the same transformer again, shouldn't cause any additional callback + // registration calls. + EXPECT_CALL(*mock_frame_transformer, RegisterTransformedFrameCallback) + .Times(0); + channel->SetDepacketizerToDecoderFrameTransformer(mock_frame_transformer); +} + } // namespace } // namespace voe } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_send.cc b/third_party/libwebrtc/audio/channel_send.cc index ee94760b6f..3c59be52b4 100644 --- a/third_party/libwebrtc/audio/channel_send.cc +++ b/third_party/libwebrtc/audio/channel_send.cc @@ -37,6 +37,7 @@ #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/race_checker.h" #include "rtc_base/rate_limiter.h" +#include "rtc_base/strings/string_builder.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue.h" #include "rtc_base/time_utils.h" @@ -104,6 +105,7 @@ class ChannelSend : public ChannelSendInterface, // Send using this encoder, with this payload type. void SetEncoder(int payload_type, + const SdpAudioFormat& encoder_format, std::unique_ptr encoder) override; void ModifyEncoder(rtc::FunctionView*)> modifier) override; @@ -192,7 +194,8 @@ class ChannelSend : public ChannelSendInterface, uint8_t payloadType, uint32_t rtp_timestamp_without_offset, rtc::ArrayView payload, - int64_t absolute_capture_timestamp_ms) + int64_t absolute_capture_timestamp_ms, + rtc::ArrayView csrcs) RTC_RUN_ON(encoder_queue_); void OnReceivedRtt(int64_t rtt_ms); @@ -264,6 +267,8 @@ class ChannelSend : public ChannelSendInterface, // Defined last to ensure that there are no running tasks when the other // members are destroyed. rtc::TaskQueue encoder_queue_; + + SdpAudioFormat encoder_format_; }; const int kTelephoneEventAttenuationdB = 10; @@ -310,21 +315,26 @@ int32_t ChannelSend::SendData(AudioFrameType frameType, if (frame_transformer_delegate_) { // Asynchronously transform the payload before sending it. After the payload // is transformed, the delegate will call SendRtpAudio to send it. + char buf[1024]; + rtc::SimpleStringBuilder mime_type(buf); + mime_type << MediaTypeToString(cricket::MEDIA_TYPE_AUDIO) << "/" + << encoder_format_.name; frame_transformer_delegate_->Transform( frameType, payloadType, rtp_timestamp + rtp_rtcp_->StartTimestamp(), payloadData, payloadSize, absolute_capture_timestamp_ms, - rtp_rtcp_->SSRC()); + rtp_rtcp_->SSRC(), mime_type.str()); return 0; } return SendRtpAudio(frameType, payloadType, rtp_timestamp, payload, - absolute_capture_timestamp_ms); + absolute_capture_timestamp_ms, /*csrcs=*/{}); } int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_without_offset, rtc::ArrayView payload, - int64_t absolute_capture_timestamp_ms) { + int64_t absolute_capture_timestamp_ms, + rtc::ArrayView csrcs) { // E2EE Custom Audio Frame Encryption (This is optional). // Keep this buffer around for the lifetime of the send call. rtc::Buffer encrypted_audio_payload; @@ -386,7 +396,8 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, .payload = payload, .payload_id = payloadType, .rtp_timestamp = - rtp_timestamp_without_offset + rtp_rtcp_->StartTimestamp()}; + rtp_timestamp_without_offset + rtp_rtcp_->StartTimestamp(), + .csrcs = csrcs}; if (absolute_capture_timestamp_ms > 0) { frame.capture_time = Timestamp::Millis(absolute_capture_timestamp_ms); } @@ -426,7 +437,8 @@ ChannelSend::ChannelSend( crypto_options_(crypto_options), encoder_queue_(task_queue_factory->CreateTaskQueue( "AudioEncoder", - TaskQueueFactory::Priority::NORMAL)) { + TaskQueueFactory::Priority::NORMAL)), + encoder_format_("x-unknown", 0, 0) { audio_coding_ = AudioCodingModule::Create(); RtpRtcpInterface::Configuration configuration; @@ -527,6 +539,7 @@ void ChannelSend::StopSend() { } void ChannelSend::SetEncoder(int payload_type, + const SdpAudioFormat& encoder_format, std::unique_ptr encoder) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); RTC_DCHECK_GE(payload_type, 0); @@ -540,6 +553,7 @@ void ChannelSend::SetEncoder(int payload_type, encoder->RtpTimestampRateHz(), encoder->NumChannels(), 0); + encoder_format_ = encoder_format; audio_coding_->SetEncoder(std::move(encoder)); } @@ -881,12 +895,13 @@ void ChannelSend::InitFrameTransformerDelegate( [this](AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_with_offset, rtc::ArrayView payload, - int64_t absolute_capture_timestamp_ms) { + int64_t absolute_capture_timestamp_ms, + rtc::ArrayView csrcs) { RTC_DCHECK_RUN_ON(&encoder_queue_); return SendRtpAudio( frameType, payloadType, rtp_timestamp_with_offset - rtp_rtcp_->StartTimestamp(), payload, - absolute_capture_timestamp_ms); + absolute_capture_timestamp_ms, csrcs); }; frame_transformer_delegate_ = rtc::make_ref_counted( diff --git a/third_party/libwebrtc/audio/channel_send.h b/third_party/libwebrtc/audio/channel_send.h index f0c9232296..f36085c1fa 100644 --- a/third_party/libwebrtc/audio/channel_send.h +++ b/third_party/libwebrtc/audio/channel_send.h @@ -63,6 +63,7 @@ class ChannelSendInterface { virtual CallSendStatistics GetRTCPStatistics() const = 0; virtual void SetEncoder(int payload_type, + const SdpAudioFormat& encoder_format, std::unique_ptr encoder) = 0; virtual void ModifyEncoder( rtc::FunctionView*)> modifier) = 0; diff --git a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc index 0f85216e92..2eea0d2387 100644 --- a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc +++ b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc @@ -11,6 +11,7 @@ #include "audio/channel_send_frame_transformer_delegate.h" #include +#include namespace webrtc { namespace { @@ -55,13 +56,17 @@ class TransformableOutgoingAudioFrame const uint8_t* payload_data, size_t payload_size, absl::optional absolute_capture_timestamp_ms, - uint32_t ssrc) + uint32_t ssrc, + std::vector csrcs, + const std::string& codec_mime_type) : frame_type_(frame_type), payload_type_(payload_type), rtp_timestamp_with_offset_(rtp_timestamp_with_offset), payload_(payload_data, payload_size), absolute_capture_timestamp_ms_(absolute_capture_timestamp_ms), - ssrc_(ssrc) {} + ssrc_(ssrc), + csrcs_(std::move(csrcs)), + codec_mime_type_(codec_mime_type) {} ~TransformableOutgoingAudioFrame() override = default; rtc::ArrayView GetData() const override { return payload_; } void SetData(rtc::ArrayView data) override { @@ -76,9 +81,10 @@ class TransformableOutgoingAudioFrame uint8_t GetPayloadType() const override { return payload_type_; } Direction GetDirection() const override { return Direction::kSender; } + std::string GetMimeType() const override { return codec_mime_type_; } rtc::ArrayView GetContributingSources() const override { - return {}; + return csrcs_; } const absl::optional SequenceNumber() const override { @@ -100,6 +106,8 @@ class TransformableOutgoingAudioFrame rtc::Buffer payload_; absl::optional absolute_capture_timestamp_ms_; uint32_t ssrc_; + std::vector csrcs_; + std::string codec_mime_type_; }; } // namespace @@ -131,11 +139,23 @@ void ChannelSendFrameTransformerDelegate::Transform( const uint8_t* payload_data, size_t payload_size, int64_t absolute_capture_timestamp_ms, - uint32_t ssrc) { + uint32_t ssrc, + const std::string& codec_mimetype) { + { + MutexLock lock(&send_lock_); + if (short_circuit_) { + send_frame_callback_( + frame_type, payload_type, rtp_timestamp, + rtc::ArrayView(payload_data, payload_size), + absolute_capture_timestamp_ms, /*csrcs=*/{}); + return; + } + } frame_transformer_->Transform( std::make_unique( frame_type, payload_type, rtp_timestamp, payload_data, payload_size, - absolute_capture_timestamp_ms, ssrc)); + absolute_capture_timestamp_ms, ssrc, + /*csrcs=*/std::vector(), codec_mimetype)); } void ChannelSendFrameTransformerDelegate::OnTransformedFrame( @@ -150,6 +170,11 @@ void ChannelSendFrameTransformerDelegate::OnTransformedFrame( }); } +void ChannelSendFrameTransformerDelegate::StartShortCircuiting() { + MutexLock lock(&send_lock_); + short_circuit_ = true; +} + void ChannelSendFrameTransformerDelegate::SendFrame( std::unique_ptr frame) const { MutexLock lock(&send_lock_); @@ -164,16 +189,21 @@ void ChannelSendFrameTransformerDelegate::SendFrame( transformed_frame->GetData(), transformed_frame->AbsoluteCaptureTimestamp() ? *transformed_frame->AbsoluteCaptureTimestamp() - : 0); + : 0, + transformed_frame->GetContributingSources()); } std::unique_ptr CloneSenderAudioFrame( TransformableAudioFrameInterface* original) { + std::vector csrcs; + csrcs.assign(original->GetContributingSources().begin(), + original->GetContributingSources().end()); return std::make_unique( InterfaceFrameTypeToInternalFrameType(original->Type()), original->GetPayloadType(), original->GetTimestamp(), original->GetData().data(), original->GetData().size(), - original->AbsoluteCaptureTimestamp(), original->GetSsrc()); + original->AbsoluteCaptureTimestamp(), original->GetSsrc(), + std::move(csrcs), original->GetMimeType()); } } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.h b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.h index eb0027e4c8..97fc14f737 100644 --- a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.h +++ b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.h @@ -12,6 +12,7 @@ #define AUDIO_CHANNEL_SEND_FRAME_TRANSFORMER_DELEGATE_H_ #include +#include #include "api/frame_transformer_interface.h" #include "api/sequence_checker.h" @@ -34,7 +35,8 @@ class ChannelSendFrameTransformerDelegate : public TransformedFrameCallback { uint8_t payloadType, uint32_t rtp_timestamp_with_offset, rtc::ArrayView payload, - int64_t absolute_capture_timestamp_ms)>; + int64_t absolute_capture_timestamp_ms, + rtc::ArrayView csrcs)>; ChannelSendFrameTransformerDelegate( SendFrameCallback send_frame_callback, rtc::scoped_refptr frame_transformer, @@ -57,12 +59,15 @@ class ChannelSendFrameTransformerDelegate : public TransformedFrameCallback { const uint8_t* payload_data, size_t payload_size, int64_t absolute_capture_timestamp_ms, - uint32_t ssrc); + uint32_t ssrc, + const std::string& codec_mime_type); // Implements TransformedFrameCallback. Can be called on any thread. void OnTransformedFrame( std::unique_ptr frame) override; + void StartShortCircuiting() override; + // Delegates the call to ChannelSend::SendRtpAudio on the `encoder_queue_`, // by calling `send_audio_callback_`. void SendFrame(std::unique_ptr frame) const; @@ -75,6 +80,7 @@ class ChannelSendFrameTransformerDelegate : public TransformedFrameCallback { SendFrameCallback send_frame_callback_ RTC_GUARDED_BY(send_lock_); rtc::scoped_refptr frame_transformer_; rtc::TaskQueue* encoder_queue_ RTC_GUARDED_BY(send_lock_); + bool short_circuit_ RTC_GUARDED_BY(send_lock_) = false; }; std::unique_ptr CloneSenderAudioFrame( diff --git a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc index f75d4a8ab7..4dcd15cd95 100644 --- a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc +++ b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate_unittest.cc @@ -12,7 +12,9 @@ #include #include +#include +#include "absl/memory/memory.h" #include "rtc_base/task_queue_for_test.h" #include "test/gmock.h" #include "test/gtest.h" @@ -24,10 +26,13 @@ namespace { using ::testing::_; using ::testing::ElementsAre; +using ::testing::ElementsAreArray; using ::testing::NiceMock; using ::testing::Return; using ::testing::SaveArg; +const uint8_t mock_data[] = {1, 2, 3, 4}; + class MockChannelSend { public: MockChannelSend() = default; @@ -39,30 +44,56 @@ class MockChannelSend { uint8_t payloadType, uint32_t rtp_timestamp, rtc::ArrayView payload, - int64_t absolute_capture_timestamp_ms)); + int64_t absolute_capture_timestamp_ms, + rtc::ArrayView csrcs)); ChannelSendFrameTransformerDelegate::SendFrameCallback callback() { return [this](AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp, rtc::ArrayView payload, - int64_t absolute_capture_timestamp_ms) { + int64_t absolute_capture_timestamp_ms, + rtc::ArrayView csrcs) { return SendFrame(frameType, payloadType, rtp_timestamp, payload, - absolute_capture_timestamp_ms); + absolute_capture_timestamp_ms, csrcs); }; } }; -std::unique_ptr CreateMockReceiverFrame() { - const uint8_t mock_data[] = {1, 2, 3, 4}; +std::unique_ptr CreateMockReceiverFrame( + std::vector csrcs) { std::unique_ptr mock_frame = - std::make_unique(); + std::make_unique>(); rtc::ArrayView payload(mock_data); ON_CALL(*mock_frame, GetData).WillByDefault(Return(payload)); ON_CALL(*mock_frame, GetPayloadType).WillByDefault(Return(0)); ON_CALL(*mock_frame, GetDirection) .WillByDefault(Return(TransformableFrameInterface::Direction::kReceiver)); + ON_CALL(*mock_frame, GetContributingSources).WillByDefault(Return(csrcs)); return mock_frame; } +std::unique_ptr CreateFrame() { + TaskQueueForTest channel_queue("channel_queue"); + rtc::scoped_refptr mock_frame_transformer = + rtc::make_ref_counted>(); + MockChannelSend mock_channel; + rtc::scoped_refptr delegate = + rtc::make_ref_counted( + mock_channel.callback(), mock_frame_transformer, &channel_queue); + + std::unique_ptr frame; + ON_CALL(*mock_frame_transformer, Transform) + .WillByDefault( + [&frame]( + std::unique_ptr transform_frame) { + frame = std::move(transform_frame); + }); + delegate->Transform(AudioFrameType::kEmptyFrame, 0, 0, mock_data, + sizeof(mock_data), 0, + /*ssrc=*/0, /*mimeType=*/"audio/opus"); + return absl::WrapUnique( + static_cast(frame.release())); +} + // Test that the delegate registers itself with the frame transformer on Init(). TEST(ChannelSendFrameTransformerDelegateTest, RegisterTransformedFrameCallbackOnInit) { @@ -115,7 +146,7 @@ TEST(ChannelSendFrameTransformerDelegateTest, callback->OnTransformedFrame(std::move(frame)); }); delegate->Transform(AudioFrameType::kEmptyFrame, 0, 0, data, sizeof(data), 0, - 0); + /*ssrc=*/0, /*mimeType=*/"audio/opus"); channel_queue.WaitForPreviouslyPostedTasks(); } @@ -136,16 +167,17 @@ TEST(ChannelSendFrameTransformerDelegateTest, delegate->Init(); ASSERT_TRUE(callback); - const uint8_t data[] = {1, 2, 3, 4}; + std::vector csrcs = {123, 234, 345, 456}; EXPECT_CALL(mock_channel, SendFrame).Times(0); - EXPECT_CALL(mock_channel, SendFrame(_, 0, 0, ElementsAre(1, 2, 3, 4), _)); + EXPECT_CALL(mock_channel, SendFrame(_, 0, 0, ElementsAreArray(mock_data), _, + ElementsAreArray(csrcs))); ON_CALL(*mock_frame_transformer, Transform) - .WillByDefault( - [&callback](std::unique_ptr frame) { - callback->OnTransformedFrame(CreateMockReceiverFrame()); - }); - delegate->Transform(AudioFrameType::kEmptyFrame, 0, 0, data, sizeof(data), 0, - 0); + .WillByDefault([&](std::unique_ptr frame) { + callback->OnTransformedFrame(CreateMockReceiverFrame(csrcs)); + }); + delegate->Transform(AudioFrameType::kEmptyFrame, 0, 0, mock_data, + sizeof(mock_data), 0, + /*ssrc=*/0, /*mimeType=*/"audio/opus"); channel_queue.WaitForPreviouslyPostedTasks(); } @@ -168,5 +200,59 @@ TEST(ChannelSendFrameTransformerDelegateTest, channel_queue.WaitForPreviouslyPostedTasks(); } +TEST(ChannelSendFrameTransformerDelegateTest, ShortCircuitingSkipsTransform) { + TaskQueueForTest channel_queue("channel_queue"); + rtc::scoped_refptr mock_frame_transformer = + rtc::make_ref_counted>(); + MockChannelSend mock_channel; + rtc::scoped_refptr delegate = + rtc::make_ref_counted( + mock_channel.callback(), mock_frame_transformer, &channel_queue); + + delegate->StartShortCircuiting(); + + // Will not call the actual transformer. + EXPECT_CALL(*mock_frame_transformer, Transform).Times(0); + // Will pass the frame straight to the channel. + EXPECT_CALL(mock_channel, SendFrame); + const uint8_t data[] = {1, 2, 3, 4}; + delegate->Transform(AudioFrameType::kEmptyFrame, 0, 0, data, sizeof(data), 0, + /*ssrc=*/0, /*mimeType=*/"audio/opus"); +} + +TEST(ChannelSendFrameTransformerDelegateTest, + CloningSenderFramePreservesInformation) { + std::unique_ptr frame = CreateFrame(); + std::unique_ptr cloned_frame = + CloneSenderAudioFrame(frame.get()); + + EXPECT_EQ(cloned_frame->GetTimestamp(), frame->GetTimestamp()); + EXPECT_EQ(cloned_frame->GetSsrc(), frame->GetSsrc()); + EXPECT_EQ(cloned_frame->Type(), frame->Type()); + EXPECT_EQ(cloned_frame->GetPayloadType(), frame->GetPayloadType()); + EXPECT_EQ(cloned_frame->GetMimeType(), frame->GetMimeType()); + EXPECT_THAT(cloned_frame->GetContributingSources(), + ElementsAreArray(frame->GetContributingSources())); +} + +TEST(ChannelSendFrameTransformerDelegateTest, CloningReceiverFrameWithCsrcs) { + std::unique_ptr frame = + CreateMockReceiverFrame(/*csrcs=*/{123, 234, 345}); + std::unique_ptr cloned_frame = + CloneSenderAudioFrame(frame.get()); + + EXPECT_EQ(cloned_frame->GetTimestamp(), frame->GetTimestamp()); + EXPECT_EQ(cloned_frame->GetSsrc(), frame->GetSsrc()); + EXPECT_EQ(cloned_frame->Type(), frame->Type()); + EXPECT_EQ(cloned_frame->GetPayloadType(), frame->GetPayloadType()); + EXPECT_EQ(cloned_frame->GetMimeType(), frame->GetMimeType()); + EXPECT_EQ(cloned_frame->AbsoluteCaptureTimestamp(), + frame->AbsoluteCaptureTimestamp()); + + ASSERT_NE(frame->GetContributingSources().size(), 0u); + EXPECT_THAT(cloned_frame->GetContributingSources(), + ElementsAreArray(frame->GetContributingSources())); +} + } // namespace } // namespace webrtc diff --git a/third_party/libwebrtc/audio/channel_send_unittest.cc b/third_party/libwebrtc/audio/channel_send_unittest.cc index b9406e1523..58d7c93c1e 100644 --- a/third_party/libwebrtc/audio/channel_send_unittest.cc +++ b/third_party/libwebrtc/audio/channel_send_unittest.cc @@ -66,9 +66,10 @@ class ChannelSendTest : public ::testing::Test { &transport_, nullptr, &event_log_, nullptr, crypto_options_, false, kRtcpIntervalMs, kSsrc, nullptr, &transport_controller_, field_trials_); encoder_factory_ = CreateBuiltinAudioEncoderFactory(); - std::unique_ptr encoder = encoder_factory_->MakeAudioEncoder( - kPayloadType, SdpAudioFormat("opus", kRtpRateHz, 2), {}); - channel_->SetEncoder(kPayloadType, std::move(encoder)); + SdpAudioFormat opus = SdpAudioFormat("opus", kRtpRateHz, 2); + std::unique_ptr encoder = + encoder_factory_->MakeAudioEncoder(kPayloadType, opus, {}); + channel_->SetEncoder(kPayloadType, opus, std::move(encoder)); transport_controller_.EnsureStarted(); channel_->RegisterSenderCongestionControlObjects(&transport_controller_); ON_CALL(transport_, SendRtcp).WillByDefault(Return(true)); diff --git a/third_party/libwebrtc/audio/mock_voe_channel_proxy.h b/third_party/libwebrtc/audio/mock_voe_channel_proxy.h index 29005173df..71ef5d12fb 100644 --- a/third_party/libwebrtc/audio/mock_voe_channel_proxy.h +++ b/third_party/libwebrtc/audio/mock_voe_channel_proxy.h @@ -113,7 +113,9 @@ class MockChannelSend : public voe::ChannelSendInterface { public: MOCK_METHOD(void, SetEncoder, - (int payload_type, std::unique_ptr encoder), + (int payload_type, + const SdpAudioFormat& encoder_format, + std::unique_ptr encoder), (override)); MOCK_METHOD( void, diff --git a/third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build b/third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build index e215792f64..6489497db4 100644 --- a/third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build +++ b/third_party/libwebrtc/audio/utility/audio_frame_operations_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/build/config/android/BUILD.gn b/third_party/libwebrtc/build/config/android/BUILD.gn index a77a628be4..85d27ea89e 100644 --- a/third_party/libwebrtc/build/config/android/BUILD.gn +++ b/third_party/libwebrtc/build/config/android/BUILD.gn @@ -89,14 +89,6 @@ config("runtime_library") { libs = [] - # On 64-bit platforms, the only symbols provided by libandroid_support.a are - # strto{d,f,l,ul}_l. These symbols are not used by our libc++, and newer NDKs - # don't provide a libandroid_support.a on 64-bit platforms, so we only depend - # on this library on 32-bit platforms. - if (target_cpu == "arm" || target_cpu == "x86") { - libs += [ "android_support" ] - } - # arm builds of libc++ starting in NDK r12 depend on unwind. if (target_cpu == "arm") { libs += [ "unwind" ] diff --git a/third_party/libwebrtc/call/BUILD.gn b/third_party/libwebrtc/call/BUILD.gn index 47018a570a..626ed95066 100644 --- a/third_party/libwebrtc/call/BUILD.gn +++ b/third_party/libwebrtc/call/BUILD.gn @@ -61,6 +61,7 @@ rtc_library("call_interfaces") { "../api/audio_codecs:audio_codecs_api", "../api/crypto:frame_encryptor_interface", "../api/crypto:options", + "../api/environment", "../api/metronome", "../api/neteq:neteq_api", "../api/task_queue", @@ -500,8 +501,8 @@ if (rtc_include_tests) { "../api:rtp_parameters", "../api:transport_api", "../api/audio_codecs:builtin_audio_decoder_factory", - "../api/rtc_event_log", - "../api/task_queue:default_task_queue_factory", + "../api/environment", + "../api/environment:environment_factory", "../api/test/video:function_video_factory", "../api/transport:field_trial_based_config", "../api/units:timestamp", @@ -582,7 +583,6 @@ if (rtc_include_tests) { "../api/rtc_event_log", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue", - "../api/task_queue:default_task_queue_factory", "../api/task_queue:pending_task_safety_flag", "../api/test/metrics:global_metrics_logger_and_exporter", "../api/test/metrics:metric", diff --git a/third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build b/third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build index d8893a7341..79a2aa9def 100644 --- a/third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build +++ b/third_party/libwebrtc/call/adaptation/resource_adaptation_gn/moz.build @@ -209,7 +209,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -219,10 +218,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/audio_sender_interface_gn/moz.build b/third_party/libwebrtc/call/audio_sender_interface_gn/moz.build index 2b42e8ebf9..a53966813f 100644 --- a/third_party/libwebrtc/call/audio_sender_interface_gn/moz.build +++ b/third_party/libwebrtc/call/audio_sender_interface_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/bitrate_allocator_gn/moz.build b/third_party/libwebrtc/call/bitrate_allocator_gn/moz.build index a56b55faf3..db772f8d39 100644 --- a/third_party/libwebrtc/call/bitrate_allocator_gn/moz.build +++ b/third_party/libwebrtc/call/bitrate_allocator_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/bitrate_configurator_gn/moz.build b/third_party/libwebrtc/call/bitrate_configurator_gn/moz.build index e6f73025aa..f7c51b4a7c 100644 --- a/third_party/libwebrtc/call/bitrate_configurator_gn/moz.build +++ b/third_party/libwebrtc/call/bitrate_configurator_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/bitrate_estimator_tests.cc b/third_party/libwebrtc/call/bitrate_estimator_tests.cc index f17a037ed2..d945dfccca 100644 --- a/third_party/libwebrtc/call/bitrate_estimator_tests.cc +++ b/third_party/libwebrtc/call/bitrate_estimator_tests.cc @@ -178,13 +178,13 @@ class BitrateEstimatorTest : public test::CallTest { RTC_DCHECK_EQ(1, test_->GetVideoEncoderConfig()->number_of_streams); frame_generator_capturer_ = std::make_unique( - test->clock_, + &test->env().clock(), test::CreateSquareFrameGenerator( test::VideoTestConstants::kDefaultWidth, test::VideoTestConstants::kDefaultHeight, absl::nullopt, absl::nullopt), test::VideoTestConstants::kDefaultFramerate, - *test->task_queue_factory_); + test->env().task_queue_factory()); frame_generator_capturer_->Init(); frame_generator_capturer_->Start(); send_stream_->SetSource(frame_generator_capturer_.get(), diff --git a/third_party/libwebrtc/call/call.cc b/third_party/libwebrtc/call/call.cc index 0f3699501e..63dc370f1a 100644 --- a/third_party/libwebrtc/call/call.cc +++ b/third_party/libwebrtc/call/call.cc @@ -453,7 +453,7 @@ class Call final : public webrtc::Call, bool is_started_ RTC_GUARDED_BY(worker_thread_) = false; // Sequence checker for outgoing network traffic. Could be the network thread. - // Could also be a pacer owned thread or TQ such as the TaskQueuePacedSender. + // Could also be a pacer owned thread or TQ such as the TaskQueueSender. RTC_NO_UNIQUE_ADDRESS SequenceChecker sent_packet_sequence_checker_; absl::optional last_sent_packet_ RTC_GUARDED_BY(sent_packet_sequence_checker_); @@ -462,7 +462,8 @@ class Call final : public webrtc::Call, /* Mozilla: Avoid this since it could use GetRealTimeClock(). std::unique_ptr Call::Create(const CallConfig& config) { - Clock* clock = Clock::GetRealTimeClock(); + Clock* clock = + config.env.has_value() ? &config.env->clock() : Clock::GetRealTimeClock(); return Create(config, clock, RtpTransportControllerSendFactory().Create( config.ExtractTransportConfig(), clock)); diff --git a/third_party/libwebrtc/call/call_config.cc b/third_party/libwebrtc/call/call_config.cc index 93f6b1aec4..5832969b9c 100644 --- a/third_party/libwebrtc/call/call_config.cc +++ b/third_party/libwebrtc/call/call_config.cc @@ -14,6 +14,14 @@ namespace webrtc { +CallConfig::CallConfig(const Environment& env, + TaskQueueBase* network_task_queue) + : env(env), + event_log(&env.event_log()), + task_queue_factory(&env.task_queue_factory()), + trials(&env.field_trials()), + network_task_queue_(network_task_queue) {} + CallConfig::CallConfig(RtcEventLog* event_log, TaskQueueBase* network_task_queue /* = nullptr*/) : event_log(event_log), network_task_queue_(network_task_queue) { @@ -31,7 +39,6 @@ RtpTransportConfig CallConfig::ExtractTransportConfig() const { network_state_predictor_factory; transportConfig.task_queue_factory = task_queue_factory; transportConfig.trials = trials; - transportConfig.pacer_burst_interval = pacer_burst_interval; return transportConfig; } diff --git a/third_party/libwebrtc/call/call_config.h b/third_party/libwebrtc/call/call_config.h index 918c077435..1b1f696fee 100644 --- a/third_party/libwebrtc/call/call_config.h +++ b/third_party/libwebrtc/call/call_config.h @@ -10,6 +10,8 @@ #ifndef CALL_CALL_CONFIG_H_ #define CALL_CALL_CONFIG_H_ +#include "absl/types/optional.h" +#include "api/environment/environment.h" #include "api/fec_controller.h" #include "api/field_trials_view.h" #include "api/metronome/metronome.h" @@ -32,12 +34,23 @@ struct CallConfig { // If `network_task_queue` is set to nullptr, Call will assume that network // related callbacks will be made on the same TQ as the Call instance was // constructed on. + explicit CallConfig(const Environment& env, + TaskQueueBase* network_task_queue = nullptr); + + // TODO(bugs.webrtc.org/15656): Deprecate and delete constructor below. explicit CallConfig(RtcEventLog* event_log, TaskQueueBase* network_task_queue = nullptr); + CallConfig(const CallConfig&); - RtpTransportConfig ExtractTransportConfig() const; + ~CallConfig(); + RtpTransportConfig ExtractTransportConfig() const; + + // TODO(bugs.webrtc.org/15656): Make non-optional when constructor that + // doesn't pass Environment is removed. + absl::optional env; + // Bitrate config used until valid bitrate estimates are calculated. Also // used to cap total bitrate used. This comes from the remote connection. BitrateConstraints bitrate_config; @@ -79,9 +92,6 @@ struct CallConfig { Metronome* metronome = nullptr; - // The burst interval of the pacer, see TaskQueuePacedSender constructor. - absl::optional pacer_burst_interval; - // Enables send packet batching from the egress RTP sender. bool enable_send_packet_batching = false; }; diff --git a/third_party/libwebrtc/call/call_gn/moz.build b/third_party/libwebrtc/call/call_gn/moz.build index 25c1961b89..20f1f973a5 100644 --- a/third_party/libwebrtc/call/call_gn/moz.build +++ b/third_party/libwebrtc/call/call_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/call_interfaces_gn/moz.build b/third_party/libwebrtc/call/call_interfaces_gn/moz.build index a5796666d8..a7db90d471 100644 --- a/third_party/libwebrtc/call/call_interfaces_gn/moz.build +++ b/third_party/libwebrtc/call/call_interfaces_gn/moz.build @@ -206,7 +206,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -216,10 +215,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/call_perf_tests.cc b/third_party/libwebrtc/call/call_perf_tests.cc index 0ba6d05b19..e3939e1371 100644 --- a/third_party/libwebrtc/call/call_perf_tests.cc +++ b/third_party/libwebrtc/call/call_perf_tests.cc @@ -212,7 +212,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, metrics::Reset(); rtc::scoped_refptr fake_audio_device = TestAudioDeviceModule::Create( - task_queue_factory_.get(), + &env().task_queue_factory(), TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000), TestAudioDeviceModule::CreateDiscardRenderer(48000), audio_rtp_speed); @@ -223,12 +223,12 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, send_audio_state_config.audio_processing = AudioProcessingBuilder().Create(); send_audio_state_config.audio_device_module = fake_audio_device; - CallConfig sender_config(send_event_log_.get()); + CallConfig sender_config = SendCallConfig(); auto audio_state = AudioState::Create(send_audio_state_config); fake_audio_device->RegisterAudioCallback(audio_state->audio_transport()); sender_config.audio_state = audio_state; - CallConfig receiver_config(recv_event_log_.get()); + CallConfig receiver_config = RecvCallConfig(); receiver_config.audio_state = audio_state; CreateCalls(sender_config, receiver_config); @@ -319,7 +319,8 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, } EXPECT_EQ(1u, video_receive_streams_.size()); observer->set_receive_stream(video_receive_streams_[0]); - drifting_clock = std::make_unique(clock_, video_ntp_speed); + drifting_clock = + std::make_unique(&env().clock(), video_ntp_speed); CreateFrameGeneratorCapturerWithDrift( drifting_clock.get(), video_rtp_speed, test::VideoTestConstants::kDefaultFramerate, diff --git a/third_party/libwebrtc/call/call_unittest.cc b/third_party/libwebrtc/call/call_unittest.cc index 886a15aaf0..41394b9689 100644 --- a/third_party/libwebrtc/call/call_unittest.cc +++ b/third_party/libwebrtc/call/call_unittest.cc @@ -17,12 +17,11 @@ #include "absl/strings/string_view.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/media_types.h" -#include "api/rtc_event_log/rtc_event_log.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/test/mock_audio_mixer.h" #include "api/test/video/function_video_encoder_factory.h" -#include "api/transport/field_trial_based_config.h" #include "api/units/timestamp.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" #include "audio/audio_receive_stream.h" @@ -54,7 +53,6 @@ using ::webrtc::test::RunLoop; struct CallHelper { explicit CallHelper(bool use_null_audio_processing) { - task_queue_factory_ = CreateDefaultTaskQueueFactory(); AudioState::Config audio_state_config; audio_state_config.audio_mixer = rtc::make_ref_counted(); audio_state_config.audio_processing = @@ -63,10 +61,8 @@ struct CallHelper { : rtc::make_ref_counted>(); audio_state_config.audio_device_module = rtc::make_ref_counted(); - CallConfig config(&event_log_); + CallConfig config(CreateEnvironment()); config.audio_state = AudioState::Create(audio_state_config); - config.task_queue_factory = task_queue_factory_.get(); - config.trials = &field_trials_; call_ = Call::Create(config); } @@ -74,9 +70,6 @@ struct CallHelper { private: RunLoop loop_; - RtcEventLogNull event_log_; - FieldTrialBasedConfig field_trials_; - std::unique_ptr task_queue_factory_; std::unique_ptr call_; }; diff --git a/third_party/libwebrtc/call/rampup_tests.cc b/third_party/libwebrtc/call/rampup_tests.cc index 232fe0b3fe..66553f2674 100644 --- a/third_party/libwebrtc/call/rampup_tests.cc +++ b/third_party/libwebrtc/call/rampup_tests.cc @@ -16,9 +16,7 @@ #include "absl/strings/string_view.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/rtc_event_log_output_file.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/task_queue_base.h" -#include "api/task_queue/task_queue_factory.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" #include "api/test/metrics/metric.h" #include "call/fake_network_pipe.h" @@ -565,30 +563,29 @@ void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { class RampUpTest : public test::CallTest { public: - RampUpTest() - : task_queue_factory_(CreateDefaultTaskQueueFactory()), - rtc_event_log_factory_(task_queue_factory_.get()) { + RampUpTest() { std::string dump_name(absl::GetFlag(FLAGS_ramp_dump_name)); if (!dump_name.empty()) { - send_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( - RtcEventLog::EncodingType::Legacy); - recv_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( - RtcEventLog::EncodingType::Legacy); + std::unique_ptr send_event_log = + rtc_event_log_factory_.Create(env()); + std::unique_ptr recv_event_log = + rtc_event_log_factory_.Create(env()); bool event_log_started = - send_event_log_->StartLogging( + send_event_log->StartLogging( std::make_unique( dump_name + ".send.rtc.dat", RtcEventLog::kUnlimitedOutput), RtcEventLog::kImmediateOutput) && - recv_event_log_->StartLogging( + recv_event_log->StartLogging( std::make_unique( dump_name + ".recv.rtc.dat", RtcEventLog::kUnlimitedOutput), RtcEventLog::kImmediateOutput); RTC_DCHECK(event_log_started); + SetSendEventLog(std::move(send_event_log)); + SetRecvEventLog(std::move(recv_event_log)); } } private: - const std::unique_ptr task_queue_factory_; RtcEventLogFactory rtc_event_log_factory_; }; diff --git a/third_party/libwebrtc/call/receive_stream_interface_gn/moz.build b/third_party/libwebrtc/call/receive_stream_interface_gn/moz.build index 92973e6d7b..f259414835 100644 --- a/third_party/libwebrtc/call/receive_stream_interface_gn/moz.build +++ b/third_party/libwebrtc/call/receive_stream_interface_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/rtp_demuxer.cc b/third_party/libwebrtc/call/rtp_demuxer.cc index 5c53f48144..f5c4186871 100644 --- a/third_party/libwebrtc/call/rtp_demuxer.cc +++ b/third_party/libwebrtc/call/rtp_demuxer.cc @@ -255,6 +255,19 @@ bool RtpDemuxer::RemoveSink(const RtpPacketSinkInterface* sink) { return num_removed > 0; } +flat_set RtpDemuxer::GetSsrcsForSink( + const RtpPacketSinkInterface* sink) const { + flat_set ssrcs; + if (sink) { + for (const auto& it : sink_by_ssrc_) { + if (it.second == sink) { + ssrcs.insert(it.first); + } + } + } + return ssrcs; +} + bool RtpDemuxer::OnRtpPacket(const RtpPacketReceived& packet) { RtpPacketSinkInterface* sink = ResolveSink(packet); if (sink != nullptr) { diff --git a/third_party/libwebrtc/call/rtp_demuxer.h b/third_party/libwebrtc/call/rtp_demuxer.h index 53eeb0b6b6..80427b82a7 100644 --- a/third_party/libwebrtc/call/rtp_demuxer.h +++ b/third_party/libwebrtc/call/rtp_demuxer.h @@ -151,6 +151,9 @@ class RtpDemuxer { // Null pointer is not allowed. bool RemoveSink(const RtpPacketSinkInterface* sink); + // Returns the set of SSRCs associated with a sink. + flat_set GetSsrcsForSink(const RtpPacketSinkInterface* sink) const; + // Demuxes the given packet and forwards it to the chosen sink. Returns true // if the packet was forwarded and false if the packet was dropped. bool OnRtpPacket(const RtpPacketReceived& packet); diff --git a/third_party/libwebrtc/call/rtp_interfaces_gn/moz.build b/third_party/libwebrtc/call/rtp_interfaces_gn/moz.build index c83031d5b5..d5223f0b8b 100644 --- a/third_party/libwebrtc/call/rtp_interfaces_gn/moz.build +++ b/third_party/libwebrtc/call/rtp_interfaces_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/rtp_receiver_gn/moz.build b/third_party/libwebrtc/call/rtp_receiver_gn/moz.build index 8809c7664f..b6b43b0afa 100644 --- a/third_party/libwebrtc/call/rtp_receiver_gn/moz.build +++ b/third_party/libwebrtc/call/rtp_receiver_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/rtp_sender_gn/moz.build b/third_party/libwebrtc/call/rtp_sender_gn/moz.build index 09560bbaab..54d1115417 100644 --- a/third_party/libwebrtc/call/rtp_sender_gn/moz.build +++ b/third_party/libwebrtc/call/rtp_sender_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/rtp_transport_config.h b/third_party/libwebrtc/call/rtp_transport_config.h index 6c94f7d911..f2030b3672 100644 --- a/third_party/libwebrtc/call/rtp_transport_config.h +++ b/third_party/libwebrtc/call/rtp_transport_config.h @@ -44,9 +44,6 @@ struct RtpTransportConfig { // Key-value mapping of internal configurations to apply, // e.g. field trials. const FieldTrialsView* trials = nullptr; - - // The burst interval of the pacer, see TaskQueuePacedSender constructor. - absl::optional pacer_burst_interval; }; } // namespace webrtc diff --git a/third_party/libwebrtc/call/rtp_transport_controller_send.cc b/third_party/libwebrtc/call/rtp_transport_controller_send.cc index 556a4dd89a..8d24f7551e 100644 --- a/third_party/libwebrtc/call/rtp_transport_controller_send.cc +++ b/third_party/libwebrtc/call/rtp_transport_controller_send.cc @@ -80,12 +80,7 @@ RtpTransportControllerSend::RtpTransportControllerSend( task_queue_(TaskQueueBase::Current()), bitrate_configurator_(config.bitrate_config), pacer_started_(false), - pacer_(clock, - &packet_router_, - *config.trials, - TimeDelta::Millis(5), - 3, - config.pacer_burst_interval), + pacer_(clock, &packet_router_, *config.trials, TimeDelta::Millis(5), 3), observer_(nullptr), controller_factory_override_(config.network_controller_factory), controller_factory_fallback_( diff --git a/third_party/libwebrtc/call/rtp_video_sender_unittest.cc b/third_party/libwebrtc/call/rtp_video_sender_unittest.cc index cd2f1efbcf..9646a81cfd 100644 --- a/third_party/libwebrtc/call/rtp_video_sender_unittest.cc +++ b/third_party/libwebrtc/call/rtp_video_sender_unittest.cc @@ -1092,7 +1092,7 @@ TEST(RtpVideoSenderTest, ClearsPendingPacketsOnInactivation) { // Set a very low bitrate. test.router()->OnBitrateUpdated( - CreateBitrateAllocationUpdate(/*rate_bps=*/30'000), + CreateBitrateAllocationUpdate(/*rate_bps=*/10'000), /*framerate=*/30); // Create and send a large keyframe. @@ -1119,7 +1119,7 @@ TEST(RtpVideoSenderTest, ClearsPendingPacketsOnInactivation) { EXPECT_FALSE(packet.Marker()); } EXPECT_GT(transmittedPayload, DataSize::Zero()); - EXPECT_LT(transmittedPayload, DataSize::Bytes(kImageSizeBytes / 4)); + EXPECT_LT(transmittedPayload, DataSize::Bytes(kImageSizeBytes / 3)); // Record the RTP timestamp of the first frame. const uint32_t first_frame_timestamp = sent_packets[0].Timestamp(); diff --git a/third_party/libwebrtc/call/simulated_network.h b/third_party/libwebrtc/call/simulated_network.h index 8597367add..02a37a3c43 100644 --- a/third_party/libwebrtc/call/simulated_network.h +++ b/third_party/libwebrtc/call/simulated_network.h @@ -36,7 +36,7 @@ namespace webrtc { // - Extra delay with or without packets reorder // - Packet overhead // - Queue max capacity -class SimulatedNetwork : public SimulatedNetworkInterface { +class RTC_EXPORT SimulatedNetwork : public SimulatedNetworkInterface { public: using Config = BuiltInNetworkBehaviorConfig; explicit SimulatedNetwork(Config config, uint64_t random_seed = 1); diff --git a/third_party/libwebrtc/call/version.cc b/third_party/libwebrtc/call/version.cc index 44c8c77156..5770253625 100644 --- a/third_party/libwebrtc/call/version.cc +++ b/third_party/libwebrtc/call/version.cc @@ -13,7 +13,7 @@ namespace webrtc { // The timestamp is always in UTC. -const char* const kSourceTimestamp = "WebRTC source stamp 2023-10-30T04:03:42"; +const char* const kSourceTimestamp = "WebRTC source stamp 2023-12-03T04:02:06"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even diff --git a/third_party/libwebrtc/call/version_gn/moz.build b/third_party/libwebrtc/call/version_gn/moz.build index e2e087a17f..28745e4fc6 100644 --- a/third_party/libwebrtc/call/version_gn/moz.build +++ b/third_party/libwebrtc/call/version_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/call/video_send_stream.h b/third_party/libwebrtc/call/video_send_stream.h index 1a0261be1b..2b4ea5b66a 100644 --- a/third_party/libwebrtc/call/video_send_stream.h +++ b/third_party/libwebrtc/call/video_send_stream.h @@ -113,6 +113,7 @@ class VideoSendStream { uint64_t total_encoded_bytes_target = 0; uint32_t frames = 0; uint32_t frames_dropped_by_capturer = 0; + uint32_t frames_dropped_by_bad_timestamp = 0; uint32_t frames_dropped_by_encoder_queue = 0; uint32_t frames_dropped_by_rate_limiter = 0; uint32_t frames_dropped_by_congestion_window = 0; diff --git a/third_party/libwebrtc/call/video_stream_api_gn/moz.build b/third_party/libwebrtc/call/video_stream_api_gn/moz.build index f2ec65de01..cf58d3748e 100644 --- a/third_party/libwebrtc/call/video_stream_api_gn/moz.build +++ b/third_party/libwebrtc/call/video_stream_api_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build index 390c83ec43..708eb92e1e 100644 --- a/third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_avx2_gn/moz.build @@ -177,10 +177,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86": CXXFLAGS += [ diff --git a/third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build index ec4329a9cc..deb2dbe301 100644 --- a/third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_c_arm_asm_gn/moz.build @@ -181,16 +181,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build index 1c3cdc1624..77ad77a1d5 100644 --- a/third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_c_gn/moz.build @@ -292,7 +292,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -302,10 +301,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - UNIFIED_SOURCES += [ "/third_party/libwebrtc/common_audio/signal_processing/complex_bit_reverse.c", "/third_party/libwebrtc/common_audio/signal_processing/filter_ar_fast_q12.c" diff --git a/third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build index 31757c2b89..9fc98aac37 100644 --- a/third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_cc_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/common_audio_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_gn/moz.build index b6c5dc57c8..ee91cec775 100644 --- a/third_party/libwebrtc/common_audio/common_audio_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_gn/moz.build @@ -212,7 +212,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -222,10 +221,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build index f2ef55667b..3890cd0f94 100644 --- a/third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_neon_c_gn/moz.build @@ -186,7 +186,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] diff --git a/third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build index 2b5a1cf4cc..b8b06ffc74 100644 --- a/third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_neon_gn/moz.build @@ -185,7 +185,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] diff --git a/third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build b/third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build index 298c08b418..7f0b17b287 100644 --- a/third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build +++ b/third_party/libwebrtc/common_audio/common_audio_sse2_gn/moz.build @@ -181,10 +181,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64": CXXFLAGS += [ diff --git a/third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build b/third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build index 699fdd0267..e5cef24832 100644 --- a/third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build +++ b/third_party/libwebrtc/common_audio/fir_filter_factory_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/fir_filter_gn/moz.build b/third_party/libwebrtc/common_audio/fir_filter_gn/moz.build index b0236d1067..4140a35292 100644 --- a/third_party/libwebrtc/common_audio/fir_filter_gn/moz.build +++ b/third_party/libwebrtc/common_audio/fir_filter_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build b/third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build index cda88c03f9..ec0b21c2fc 100644 --- a/third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build +++ b/third_party/libwebrtc/common_audio/sinc_resampler_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build b/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build index 328c77410c..6efbe87f02 100644 --- a/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build +++ b/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_128_gn/moz.build @@ -219,7 +219,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -230,10 +229,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86_64": CXXFLAGS += [ diff --git a/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build b/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build index e65c7c572f..d1e512c383 100644 --- a/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build +++ b/third_party/libwebrtc/common_audio/third_party/ooura/fft_size_256_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build b/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build index 618af60da3..718ca3b4e8 100644 --- a/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build +++ b/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor_gn/moz.build @@ -212,7 +212,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "aarch64": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -222,10 +221,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - UNIFIED_SOURCES += [ "/third_party/libwebrtc/common_audio/third_party/spl_sqrt_floor/spl_sqrt_floor.c" ] diff --git a/third_party/libwebrtc/common_video/common_video_gn/moz.build b/third_party/libwebrtc/common_video/common_video_gn/moz.build index a767c9c765..4572d78fab 100644 --- a/third_party/libwebrtc/common_video/common_video_gn/moz.build +++ b/third_party/libwebrtc/common_video/common_video_gn/moz.build @@ -207,7 +207,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -217,10 +216,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_video/frame_counts_gn/moz.build b/third_party/libwebrtc/common_video/frame_counts_gn/moz.build index 0ccbf9ac76..0727032aea 100644 --- a/third_party/libwebrtc/common_video/frame_counts_gn/moz.build +++ b/third_party/libwebrtc/common_video/frame_counts_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build b/third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build index 7aa4e9bfff..1b9792fe56 100644 --- a/third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build +++ b/third_party/libwebrtc/common_video/generic_frame_descriptor/generic_frame_descriptor_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/common_video/h265/h265_bitstream_parser.cc b/third_party/libwebrtc/common_video/h265/h265_bitstream_parser.cc index 1093add102..f8dc242c7d 100644 --- a/third_party/libwebrtc/common_video/h265/h265_bitstream_parser.cc +++ b/third_party/libwebrtc/common_video/h265/h265_bitstream_parser.cc @@ -475,8 +475,8 @@ void H265BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) { case H265::NaluType::kAud: case H265::NaluType::kPrefixSei: case H265::NaluType::kSuffixSei: - case H265::NaluType::kAP: - case H265::NaluType::kFU: + case H265::NaluType::kAp: + case H265::NaluType::kFu: break; default: Result res = ParseNonParameterSetNalu(slice, length, nalu_type); diff --git a/third_party/libwebrtc/common_video/h265/h265_common.h b/third_party/libwebrtc/common_video/h265/h265_common.h index fcb97815ff..643726f701 100644 --- a/third_party/libwebrtc/common_video/h265/h265_common.h +++ b/third_party/libwebrtc/common_video/h265/h265_common.h @@ -55,8 +55,8 @@ enum NaluType : uint8_t { kAud = 35, kPrefixSei = 39, kSuffixSei = 40, - kAP = 48, - kFU = 49 + kAp = 48, + kFu = 49 }; // Slice type definition. See table 7-7 of the H265 spec diff --git a/third_party/libwebrtc/examples/BUILD.gn b/third_party/libwebrtc/examples/BUILD.gn index 458205cea7..4ace29bb7e 100644 --- a/third_party/libwebrtc/examples/BUILD.gn +++ b/third_party/libwebrtc/examples/BUILD.gn @@ -489,6 +489,7 @@ if (is_ios || (is_mac && target_cpu != "x86")) { ] deps = [ + "../api:enable_media", "../api:libjingle_peerconnection_api", "../api:scoped_refptr", "../api:sequence_checker", @@ -496,7 +497,6 @@ if (is_ios || (is_mac && target_cpu != "x86")) { "../api/audio_codecs:builtin_audio_encoder_factory", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue:default_task_queue_factory", - "../media:rtc_audio_video", "../modules/audio_processing", "../modules/audio_processing:api", "../pc:libjingle_peerconnection", diff --git a/third_party/libwebrtc/examples/androidnativeapi/BUILD.gn b/third_party/libwebrtc/examples/androidnativeapi/BUILD.gn index e0eb6d8b24..d1088b3e61 100644 --- a/third_party/libwebrtc/examples/androidnativeapi/BUILD.gn +++ b/third_party/libwebrtc/examples/androidnativeapi/BUILD.gn @@ -47,6 +47,7 @@ if (is_android) { deps = [ ":generated_jni", + "../../api:enable_media_with_defaults", "../../api:scoped_refptr", "../../api:sequence_checker", "../../rtc_base:ssl", @@ -56,7 +57,6 @@ if (is_android) { "//api/task_queue:default_task_queue_factory", "//media:rtc_audio_video", "//media:rtc_internal_video_codecs", - "//media:rtc_media_engine_defaults", "//modules/utility", "//pc:libjingle_peerconnection", "//sdk/android:native_api_base", diff --git a/third_party/libwebrtc/examples/androidnativeapi/jni/android_call_client.cc b/third_party/libwebrtc/examples/androidnativeapi/jni/android_call_client.cc index 2713a563cd..40af78cdac 100644 --- a/third_party/libwebrtc/examples/androidnativeapi/jni/android_call_client.cc +++ b/third_party/libwebrtc/examples/androidnativeapi/jni/android_call_client.cc @@ -13,6 +13,7 @@ #include #include +#include "api/enable_media_with_defaults.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/task_queue/default_task_queue_factory.h" @@ -20,7 +21,6 @@ #include "media/engine/internal_decoder_factory.h" #include "media/engine/internal_encoder_factory.h" #include "media/engine/webrtc_media_engine.h" -#include "media/engine/webrtc_media_engine_defaults.h" #include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/native_api/video/wrapper.h" @@ -154,19 +154,14 @@ void AndroidCallClient::CreatePeerConnectionFactory() { pcf_deps.worker_thread = worker_thread_.get(); pcf_deps.signaling_thread = signaling_thread_.get(); pcf_deps.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); - pcf_deps.call_factory = webrtc::CreateCallFactory(); pcf_deps.event_log_factory = std::make_unique( pcf_deps.task_queue_factory.get()); - cricket::MediaEngineDependencies media_deps; - media_deps.task_queue_factory = pcf_deps.task_queue_factory.get(); - media_deps.video_encoder_factory = + pcf_deps.video_encoder_factory = std::make_unique(); - media_deps.video_decoder_factory = + pcf_deps.video_decoder_factory = std::make_unique(); - webrtc::SetMediaEngineDefaults(&media_deps); - pcf_deps.media_engine = cricket::CreateMediaEngine(std::move(media_deps)); - RTC_LOG(LS_INFO) << "Media engine created: " << pcf_deps.media_engine.get(); + EnableMediaWithDefaults(pcf_deps); pcf_ = CreateModularPeerConnectionFactory(std::move(pcf_deps)); RTC_LOG(LS_INFO) << "PeerConnectionFactory created: " << pcf_.get(); diff --git a/third_party/libwebrtc/examples/objcnativeapi/objc/objc_call_client.mm b/third_party/libwebrtc/examples/objcnativeapi/objc/objc_call_client.mm index 90bcfcc35b..996c6a9c7f 100644 --- a/third_party/libwebrtc/examples/objcnativeapi/objc/objc_call_client.mm +++ b/third_party/libwebrtc/examples/objcnativeapi/objc/objc_call_client.mm @@ -20,10 +20,10 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/enable_media.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/task_queue/default_task_queue_factory.h" -#include "media/engine/webrtc_media_engine.h" #include "modules/audio_processing/include/audio_processing.h" #include "sdk/objc/native/api/video_capturer.h" #include "sdk/objc/native/api/video_decoder_factory.h" @@ -118,18 +118,14 @@ void ObjCCallClient::CreatePeerConnectionFactory() { dependencies.worker_thread = worker_thread_.get(); dependencies.signaling_thread = signaling_thread_.get(); dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); - cricket::MediaEngineDependencies media_deps; - media_deps.task_queue_factory = dependencies.task_queue_factory.get(); - media_deps.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); - media_deps.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); - media_deps.video_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory( + dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); + dependencies.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); + dependencies.video_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory( [[RTC_OBJC_TYPE(RTCDefaultVideoEncoderFactory) alloc] init]); - media_deps.video_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory( + dependencies.video_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory( [[RTC_OBJC_TYPE(RTCDefaultVideoDecoderFactory) alloc] init]); - media_deps.audio_processing = webrtc::AudioProcessingBuilder().Create(); - dependencies.media_engine = cricket::CreateMediaEngine(std::move(media_deps)); - RTC_LOG(LS_INFO) << "Media engine created: " << dependencies.media_engine.get(); - dependencies.call_factory = webrtc::CreateCallFactory(); + dependencies.audio_processing = webrtc::AudioProcessingBuilder().Create(); + webrtc::EnableMedia(dependencies); dependencies.event_log_factory = std::make_unique(dependencies.task_queue_factory.get()); pcf_ = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies)); diff --git a/third_party/libwebrtc/examples/peerconnection/client/peer_connection_client.cc b/third_party/libwebrtc/examples/peerconnection/client/peer_connection_client.cc index 48d5bb6545..488d2f04ed 100644 --- a/third_party/libwebrtc/examples/peerconnection/client/peer_connection_client.cc +++ b/third_party/libwebrtc/examples/peerconnection/client/peer_connection_client.cc @@ -16,6 +16,7 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/net_helpers.h" +#include "rtc_base/thread.h" namespace { diff --git a/third_party/libwebrtc/examples/stunserver/stunserver_main.cc b/third_party/libwebrtc/examples/stunserver/stunserver_main.cc index 8180069bf0..ecf6c81ff1 100644 --- a/third_party/libwebrtc/examples/stunserver/stunserver_main.cc +++ b/third_party/libwebrtc/examples/stunserver/stunserver_main.cc @@ -29,7 +29,8 @@ int main(int argc, char* argv[]) { return 1; } - rtc::Thread* pthMain = rtc::Thread::Current(); + rtc::Thread* pthMain = rtc::ThreadManager::Instance()->WrapCurrentThread(); + RTC_DCHECK(pthMain); rtc::AsyncUDPSocket* server_socket = rtc::AsyncUDPSocket::Create(pthMain->socketserver(), server_addr); diff --git a/third_party/libwebrtc/experiments/field_trials.py b/third_party/libwebrtc/experiments/field_trials.py index e39b53eb47..567cafc058 100755 --- a/third_party/libwebrtc/experiments/field_trials.py +++ b/third_party/libwebrtc/experiments/field_trials.py @@ -107,9 +107,9 @@ ACTIVE_FIELD_TRIALS: FrozenSet[FieldTrial] = frozenset([ FieldTrial('WebRTC-SendPacketsOnWorkerThread', 'webrtc:14502', date(2024, 4, 1)), - FieldTrial('WebRTC-Stats-RtxReceiveStats', - 'webrtc:15096', - date(2024, 4, 1)), + FieldTrial('WebRTC-SrtpRemoveReceiveStream', + 'webrtc:15604', + date(2024, 10, 1)), FieldTrial('WebRTC-TaskQueue-ReplaceLibeventWithStdlib', 'webrtc:14389', date(2024, 4, 1)), diff --git a/third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build b/third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build index 023dd46dd1..f261435853 100644 --- a/third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build +++ b/third_party/libwebrtc/experiments/registered_field_trials_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/g3doc/style-guide.md b/third_party/libwebrtc/g3doc/style-guide.md index b32163f906..57cb85c466 100644 --- a/third_party/libwebrtc/g3doc/style-guide.md +++ b/third_party/libwebrtc/g3doc/style-guide.md @@ -65,7 +65,7 @@ Follow the [Google styleguide for `TODO` comments][goog-style-todo]. When referencing a WebRTC bug, prefer using the URL form (excluding the scheme part): ```cpp -// TODO(bugs.webrtc.org/12345): Delete the hack when blocking bugs are resolved. +// TODO: bugs.webrtc.org/12345 - Delete the hack when blocking bugs are resolved. ``` The short form used in commit messages, e.g. `webrtc:12345`, is discouraged. @@ -132,7 +132,8 @@ docs. WebRTC uses std::string, with content assumed to be UTF-8. Note that this has to be verified whenever accepting external input. -For concatenation of strings, use rtc::SimpleStringBuilder. +For concatenation of strings, use webrtc::StrJoin or rtc::SimpleStringBuilder +directly. The following string building tools are NOT recommended: * The + operator. See https://abseil.io/tips/3 for why not. diff --git a/third_party/libwebrtc/infra/specs/client.webrtc.json b/third_party/libwebrtc/infra/specs/client.webrtc.json index 5f8adfc40e..6f8bfb5ba5 100644 --- a/third_party/libwebrtc/infra/specs/client.webrtc.json +++ b/third_party/libwebrtc/infra/specs/client.webrtc.json @@ -8034,10 +8034,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -8083,10 +8084,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8132,10 +8134,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8180,10 +8183,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -8228,10 +8232,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8276,10 +8281,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8324,10 +8330,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -8372,10 +8379,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8420,10 +8428,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8468,10 +8477,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -8516,10 +8526,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8564,10 +8575,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8612,10 +8624,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -8660,10 +8673,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8708,10 +8722,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8756,10 +8771,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -8805,10 +8821,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8854,10 +8871,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -8903,10 +8921,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -8953,10 +8972,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -9003,10 +9023,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -9053,10 +9074,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -9101,10 +9123,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9149,10 +9172,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9197,10 +9221,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -9245,10 +9270,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9293,10 +9319,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9341,10 +9368,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -9389,10 +9417,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9437,10 +9466,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9485,10 +9515,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -9534,10 +9565,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9583,10 +9615,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9633,10 +9666,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -9682,10 +9716,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9731,10 +9766,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9780,10 +9816,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -9829,10 +9866,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9878,10 +9916,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -9926,10 +9965,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -9976,10 +10016,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -10026,10 +10067,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -10076,10 +10118,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -10124,10 +10167,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10172,10 +10216,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10220,10 +10265,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -10268,10 +10314,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10316,10 +10363,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10364,10 +10412,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -10412,10 +10461,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10460,10 +10510,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10508,10 +10559,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -10556,10 +10608,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10604,10 +10657,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10652,10 +10706,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -10701,10 +10756,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10750,10 +10806,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10799,10 +10856,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -10847,10 +10905,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10895,10 +10954,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -10943,10 +11003,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -10991,10 +11052,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -11039,10 +11101,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, diff --git a/third_party/libwebrtc/infra/specs/internal.client.webrtc.json b/third_party/libwebrtc/infra/specs/internal.client.webrtc.json index 1e3a147201..59547fc132 100644 --- a/third_party/libwebrtc/infra/specs/internal.client.webrtc.json +++ b/third_party/libwebrtc/infra/specs/internal.client.webrtc.json @@ -7,7 +7,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -24,7 +24,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -34,7 +34,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -47,7 +47,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -64,7 +64,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -74,7 +74,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -88,7 +88,7 @@ "--readline-timeout=1200", "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -105,7 +105,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -117,7 +117,7 @@ "io_timeout": 7200, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -131,7 +131,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -148,7 +148,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -158,7 +158,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -172,7 +172,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -189,7 +189,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -199,7 +199,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -212,7 +212,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -229,7 +229,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -239,7 +239,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -252,7 +252,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -269,7 +269,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -279,7 +279,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -292,7 +292,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -309,7 +309,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -319,7 +319,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -332,7 +332,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -349,7 +349,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -359,7 +359,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -372,7 +372,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -389,7 +389,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -399,7 +399,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -412,7 +412,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -429,7 +429,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -439,7 +439,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -480,10 +480,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "device_status": "available", "id": "mac-254-e504", "os": "iOS-15.7.8", @@ -511,7 +512,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -528,7 +529,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -538,7 +539,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -551,7 +552,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -568,7 +569,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -578,7 +579,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -592,7 +593,7 @@ "--readline-timeout=1200", "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -609,7 +610,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -621,7 +622,7 @@ "io_timeout": 7200, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -635,7 +636,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -652,7 +653,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -662,7 +663,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -676,7 +677,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -693,7 +694,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -703,7 +704,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -716,7 +717,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -733,7 +734,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -743,7 +744,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -756,7 +757,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -773,7 +774,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -783,7 +784,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -796,7 +797,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -813,7 +814,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -823,7 +824,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -836,7 +837,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -853,7 +854,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -863,7 +864,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -876,7 +877,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -893,7 +894,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -903,7 +904,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], @@ -916,7 +917,7 @@ "args": [ "--xctest", "--xcode-build-version", - "15a240d", + "15a507", "--out-dir", "${ISOLATED_OUTDIR}" ], @@ -933,7 +934,7 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { @@ -943,7 +944,7 @@ }, "named_caches": [ { - "name": "xcode_ios_15a240d", + "name": "xcode_ios_15a507", "path": "Xcode.app" } ], diff --git a/third_party/libwebrtc/infra/specs/mixins.pyl b/third_party/libwebrtc/infra/specs/mixins.pyl index cbf9b2472f..e436846ef0 100644 --- a/third_party/libwebrtc/infra/specs/mixins.pyl +++ b/third_party/libwebrtc/infra/specs/mixins.pyl @@ -176,7 +176,7 @@ 'location': '.', 'revision': - 'git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb' + 'git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce' }] } }, @@ -309,6 +309,9 @@ 'xcode_13_main': { 'args': ['--xcode-build-version', '13c100'], 'swarming': { + 'dimensions': { + 'caches': 'xcode_ios_13c100' + }, 'named_caches': [{ 'name': 'xcode_ios_13c100', 'path': 'Xcode.app' @@ -318,6 +321,9 @@ 'xcode_14_main': { 'args': ['--xcode-build-version', '14c18'], 'swarming': { + 'dimensions': { + 'caches': 'xcode_ios_14c18' + }, 'named_caches': [{ 'name': 'xcode_ios_14c18', 'path': 'Xcode.app' @@ -325,10 +331,10 @@ } }, 'xcode_15_main': { - 'args': ['--xcode-build-version', '15a240d'], + 'args': ['--xcode-build-version', '15a507'], 'swarming': { 'named_caches': [{ - 'name': 'xcode_ios_15a240d', + 'name': 'xcode_ios_15a507', 'path': 'Xcode.app' }] } diff --git a/third_party/libwebrtc/infra/specs/mixins_webrtc.pyl b/third_party/libwebrtc/infra/specs/mixins_webrtc.pyl index f8fa66b27f..443a4450eb 100644 --- a/third_party/libwebrtc/infra/specs/mixins_webrtc.pyl +++ b/third_party/libwebrtc/infra/specs/mixins_webrtc.pyl @@ -224,6 +224,9 @@ 'xcode_13_main': { 'args': ['--xcode-build-version', '13c100'], 'swarming': { + 'dimensions': { + 'caches': 'xcode_ios_13c100', + }, 'named_caches': [{ 'name': 'xcode_ios_13c100', 'path': 'Xcode.app' @@ -233,6 +236,9 @@ 'xcode_14_main': { 'args': ['--xcode-build-version', '14c18'], 'swarming': { + 'dimensions': { + 'caches': 'xcode_ios_14c18', + }, 'named_caches': [{ 'name': 'xcode_ios_14c18', 'path': 'Xcode.app' diff --git a/third_party/libwebrtc/infra/specs/tryserver.webrtc.json b/third_party/libwebrtc/infra/specs/tryserver.webrtc.json index 61f4221970..61e47fd0f8 100644 --- a/third_party/libwebrtc/infra/specs/tryserver.webrtc.json +++ b/third_party/libwebrtc/infra/specs/tryserver.webrtc.json @@ -2242,10 +2242,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -2291,10 +2292,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2340,10 +2342,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2388,10 +2391,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -2436,10 +2440,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2484,10 +2489,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2532,10 +2538,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -2580,10 +2587,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2628,10 +2636,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2676,10 +2685,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -2724,10 +2734,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2772,10 +2783,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2820,10 +2832,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -2868,10 +2881,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2916,10 +2930,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -2964,10 +2979,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -3013,10 +3029,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3062,10 +3079,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3111,10 +3129,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -3161,10 +3180,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -3211,10 +3231,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -3261,10 +3282,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -3309,10 +3331,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3357,10 +3380,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3405,10 +3429,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -3453,10 +3478,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3501,10 +3527,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3549,10 +3576,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -3597,10 +3625,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3645,10 +3674,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3693,10 +3723,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -3742,10 +3773,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3791,10 +3823,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3841,10 +3874,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -3890,10 +3924,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3939,10 +3974,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -3988,10 +4024,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -4037,10 +4074,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4086,10 +4124,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4134,10 +4173,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -4184,10 +4224,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -4234,10 +4275,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cores": "12", "cpu": "x86-64", "os": "Mac-12" @@ -4284,10 +4326,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -4332,10 +4375,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4380,10 +4424,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4428,10 +4473,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -4476,10 +4522,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4524,10 +4571,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4572,10 +4620,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -4620,10 +4669,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4668,10 +4718,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4716,10 +4767,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -4764,10 +4816,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4812,10 +4865,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4860,10 +4914,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -4909,10 +4964,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -4958,10 +5014,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -5007,10 +5064,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -5055,10 +5113,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -5103,10 +5162,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -5151,10 +5211,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_13c100", "cpu": "x86-64", "os": "Mac-12" }, @@ -5199,10 +5260,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, @@ -5247,10 +5309,11 @@ { "cipd_package": "infra/tools/mac_toolchain/${platform}", "location": ".", - "revision": "git_revision:59ddedfe3849abf560cbe0b41bb8e431041cd2bb" + "revision": "git_revision:32d81d877ee07af07bf03b7f70ce597e323b80ce" } ], "dimensions": { + "caches": "xcode_ios_14c18", "cpu": "x86-64", "os": "Mac-12" }, diff --git a/third_party/libwebrtc/infra/specs/variants.pyl b/third_party/libwebrtc/infra/specs/variants.pyl index cf050c671e..e764f698e3 100644 --- a/third_party/libwebrtc/infra/specs/variants.pyl +++ b/third_party/libwebrtc/infra/specs/variants.pyl @@ -15,10 +15,7 @@ '14.5', ], 'identifier': 'iPhone X 14.5', - 'mixins': [ - 'xcode_13_main', - 'ios_runtime_cache_14_5', - ], + 'mixins': ['xcode_13_main', 'ios_runtime_cache_14_5'], }, 'SIM_IPHONE_X_15_5': { 'args': [ @@ -28,10 +25,7 @@ '15.5', ], 'identifier': 'iPhone X 15.5', - 'mixins': [ - 'xcode_14_main', - 'ios_runtime_cache_15_5', - ], + 'mixins': ['xcode_14_main', 'ios_runtime_cache_15_5'], }, 'SIM_IPHONE_X_16_2': { 'args': [ @@ -41,9 +35,6 @@ '16.2', ], 'identifier': 'iPhone X 16.2', - 'mixins': [ - 'xcode_14_main', - 'ios_runtime_cache_16_2', - ], + 'mixins': ['xcode_14_main', 'ios_runtime_cache_16_2'], }, } diff --git a/third_party/libwebrtc/logging/BUILD.gn b/third_party/libwebrtc/logging/BUILD.gn index ab1fbbc52b..92f55edfa0 100644 --- a/third_party/libwebrtc/logging/BUILD.gn +++ b/third_party/libwebrtc/logging/BUILD.gn @@ -281,7 +281,6 @@ rtc_library("rtc_event_number_encodings") { "../rtc_base:bit_buffer", "../rtc_base:bitstream_reader", "../rtc_base:checks", - "../rtc_base:ignore_wundef", "../rtc_base:macromagic", ] absl_deps = [ @@ -355,7 +354,6 @@ rtc_library("rtc_event_log_impl_encoder") { "../rtc_base:bitstream_reader", "../rtc_base:buffer", "../rtc_base:checks", - "../rtc_base:ignore_wundef", "../rtc_base:logging", "../rtc_base:safe_conversions", "../system_wrappers:field_trial", @@ -427,10 +425,7 @@ if (rtc_enable_protobuf) { if (rtc_enable_protobuf) { rtc_source_set("rtc_event_log2_proto_include") { sources = [ "rtc_event_log/rtc_event_log2_proto_include.h" ] - deps = [ - ":rtc_event_log2_proto", - "../rtc_base:ignore_wundef", - ] + deps = [ ":rtc_event_log2_proto" ] } } @@ -487,10 +482,12 @@ rtc_library("fake_rtc_event_log") { ] deps = [ + "../api/environment", "../api/rtc_event_log", "../rtc_base:macromagic", "../rtc_base/synchronization:mutex", ] + absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ] } if (rtc_enable_protobuf) { @@ -549,7 +546,6 @@ if (rtc_enable_protobuf) { "../modules/rtp_rtcp:rtp_rtcp_format", "../rtc_base:checks", "../rtc_base:copy_on_write_buffer", - "../rtc_base:ignore_wundef", "../rtc_base:logging", "../rtc_base:protobuf_utils", "../rtc_base:rtc_numerics", @@ -610,9 +606,10 @@ if (rtc_enable_protobuf) { "../api:rtc_event_log_output_file", "../api:rtp_headers", "../api:rtp_parameters", + "../api/environment", + "../api/environment:environment_factory", "../api/rtc_event_log", "../api/rtc_event_log:rtc_event_log_factory", - "../api/task_queue:default_task_queue_factory", "../api/units:time_delta", "../api/units:timestamp", "../call", @@ -627,6 +624,7 @@ if (rtc_enable_protobuf) { "../rtc_base:timeutils", "../system_wrappers", "../system_wrappers:field_trial", + "../test:explicit_key_value_config", "../test:field_trial", "../test:fileutils", "../test:test_support", diff --git a/third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build index f4f41e48ae..806981ed68 100644 --- a/third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_audio_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build index 72e02793f7..d1f1deac9a 100644 --- a/third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_bwe_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_event_field_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_field_gn/moz.build index 6a37b25112..2c6740f28f 100644 --- a/third_party/libwebrtc/logging/rtc_event_field_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_field_gn/moz.build @@ -198,7 +198,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -208,10 +207,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc b/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc index 5619827246..2c1444af07 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc +++ b/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.cc @@ -53,17 +53,14 @@ #include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "rtc_base/checks.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/logging.h" // *.pb.h files are generated at build-time by the protobuf compiler. -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" #else #include "logging/rtc_event_log/rtc_event_log.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() namespace webrtc { diff --git a/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc b/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc index 2c9e42e064..01bd89718d 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc +++ b/third_party/libwebrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.cc @@ -61,18 +61,15 @@ #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet.h" #include "rtc_base/checks.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/logging.h" #include "system_wrappers/include/field_trial.h" // *.pb.h files are generated at build-time by the protobuf compiler. -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log2.pb.h" #else #include "logging/rtc_event_log/rtc_event_log2.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() using webrtc_event_logging::ToUnsigned; diff --git a/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.cc b/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.cc index 47db40c9f4..bacc3cd1cb 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.cc +++ b/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.cc @@ -17,17 +17,11 @@ namespace webrtc { -std::unique_ptr FakeRtcEventLogFactory::Create( - RtcEventLog::EncodingType /*encoding_type*/) const { +absl::Nonnull> FakeRtcEventLogFactory::Create( + const Environment& /*env*/) const { auto fake_event_log = std::make_unique(); - const_cast(this)->last_log_created_ = - fake_event_log.get(); + const_cast(last_log_created_) = fake_event_log.get(); return fake_event_log; } -std::unique_ptr FakeRtcEventLogFactory::CreateRtcEventLog( - RtcEventLog::EncodingType encoding_type) { - return Create(encoding_type); -} - } // namespace webrtc diff --git a/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.h b/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.h index c7ff33dee4..0d6d076038 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.h +++ b/third_party/libwebrtc/logging/rtc_event_log/fake_rtc_event_log_factory.h @@ -13,6 +13,8 @@ #include +#include "absl/base/nullability.h" +#include "api/environment/environment.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "logging/rtc_event_log/fake_rtc_event_log.h" @@ -23,16 +25,13 @@ class FakeRtcEventLogFactory : public RtcEventLogFactoryInterface { FakeRtcEventLogFactory() = default; ~FakeRtcEventLogFactory() override = default; - std::unique_ptr Create( - RtcEventLog::EncodingType encoding_type) const override; + absl::Nonnull> Create( + const Environment& env) const override; - std::unique_ptr CreateRtcEventLog( - RtcEventLog::EncodingType encoding_type) override; - - webrtc::FakeRtcEventLog* last_log_created() { return last_log_created_; } + FakeRtcEventLog* last_log_created() { return last_log_created_; } private: - webrtc::FakeRtcEventLog* last_log_created_; + FakeRtcEventLog* last_log_created_ = nullptr; }; } // namespace webrtc diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log2_proto_include.h b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log2_proto_include.h index 3e43103897..43b914fd0c 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log2_proto_include.h +++ b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log2_proto_include.h @@ -11,15 +11,11 @@ #ifndef LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG2_PROTO_INCLUDE_H_ #define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG2_PROTO_INCLUDE_H_ -#include "rtc_base/ignore_wundef.h" - // *.pb.h files are generated at build-time by the protobuf compiler. -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log2.pb.h" #else #include "logging/rtc_event_log/rtc_event_log2.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() #endif // LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG2_PROTO_INCLUDE_H_ diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_parser.h b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_parser.h index 9ad96274d3..def9f0ab35 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_parser.h +++ b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_parser.h @@ -54,10 +54,8 @@ #include "logging/rtc_event_log/events/rtc_event_video_send_stream_config.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" -#include "rtc_base/ignore_wundef.h" // Files generated at build-time by the protobuf compiler. -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log2.pb.h" @@ -65,7 +63,6 @@ RTC_PUSH_IGNORING_WUNDEF() #include "logging/rtc_event_log/rtc_event_log.pb.h" #include "logging/rtc_event_log/rtc_event_log2.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() namespace webrtc { diff --git a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc index 3730a080dd..a3005729ab 100644 --- a/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/third_party/libwebrtc/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -19,8 +19,9 @@ #include #include +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/task_queue/default_task_queue_factory.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" #include "logging/rtc_event_log/events/rtc_event_audio_playout.h" #include "logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h" @@ -50,6 +51,7 @@ #include "rtc_base/checks.h" #include "rtc_base/fake_clock.h" #include "rtc_base/random.h" +#include "test/explicit_key_value_config.h" #include "test/gtest.h" #include "test/logging/memory_log_writer.h" #include "test/testsupport/file_utils.h" @@ -58,6 +60,8 @@ namespace webrtc { namespace { +using test::ExplicitKeyValueConfig; + struct EventCounts { size_t audio_send_streams = 0; size_t audio_recv_streams = 0; @@ -105,6 +109,21 @@ struct EventCounts { } }; +std::unique_ptr CreateFieldTrialsFor( + RtcEventLog::EncodingType encoding_type) { + switch (encoding_type) { + case RtcEventLog::EncodingType::Legacy: + return std::make_unique( + "WebRTC-RtcEventLogNewFormat/Disabled/"); + case RtcEventLog::EncodingType::NewFormat: + return std::make_unique( + "WebRTC-RtcEventLogNewFormat/Enabled/"); + case RtcEventLog::EncodingType::ProtoFree: + RTC_CHECK(false); + return nullptr; + } +} + class RtcEventLogSession : public ::testing::TestWithParam< std::tuple> { @@ -336,14 +355,13 @@ void RtcEventLogSession::WriteVideoSendConfigs(size_t video_send_streams, void RtcEventLogSession::WriteLog(EventCounts count, size_t num_events_before_start) { - // TODO(terelius): Allow test to run with either a real or a fake clock_. - // Maybe always use the ScopedFakeClock, but conditionally SleepMs()? + // TODO(terelius): Allow test to run with either a real or a fake clock_ + // e.g. by using clock and task_queue_factory from TimeController + // when RtcEventLogImpl switches to use injected clock from the environment. - auto task_queue_factory = CreateDefaultTaskQueueFactory(); - RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get()); // The log will be flushed to output when the event_log goes out of scope. - std::unique_ptr event_log = - rtc_event_log_factory.CreateRtcEventLog(encoding_type_); + std::unique_ptr event_log = RtcEventLogFactory().Create( + CreateEnvironment(CreateFieldTrialsFor(encoding_type_))); // We can't send or receive packets without configured streams. RTC_CHECK_GE(count.video_recv_streams, 1); @@ -934,12 +952,9 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) { int64_t start_time_us, utc_start_time_us, stop_time_us; { - auto task_queue_factory = CreateDefaultTaskQueueFactory(); - RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get()); - // When `log` goes out of scope, the contents are flushed - // to the output. - std::unique_ptr log = - rtc_event_log_factory.CreateRtcEventLog(encoding_type_); + // When `log` goes out of scope, the contents are flushed to the output. + std::unique_ptr log = RtcEventLogFactory().Create( + CreateEnvironment(CreateFieldTrialsFor(encoding_type_))); for (size_t i = 0; i < kNumEvents; i++) { // The purpose of the test is to verify that the log can handle diff --git a/third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build index 5ad6834dff..2936d8ef48 100644 --- a/third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_log_parse_status_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build index af4c0bf656..6ecf9077cf 100644 --- a/third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_number_encodings_gn/moz.build @@ -190,7 +190,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -200,10 +199,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build index abf04bb09f..f0e8d5d4e8 100644 --- a/third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_pacing_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build index b003d287bd..082924c2d0 100644 --- a/third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_rtp_rtcp_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_event_video_gn/moz.build b/third_party/libwebrtc/logging/rtc_event_video_gn/moz.build index 264fc2cf4b..6e74aef635 100644 --- a/third_party/libwebrtc/logging/rtc_event_video_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_event_video_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build b/third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build index eb3342a926..935bf8bbf9 100644 --- a/third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build +++ b/third_party/libwebrtc/logging/rtc_stream_config_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/BUILD.gn b/third_party/libwebrtc/media/BUILD.gn index 97ad4a889a..055bf75a19 100644 --- a/third_party/libwebrtc/media/BUILD.gn +++ b/third_party/libwebrtc/media/BUILD.gn @@ -262,7 +262,6 @@ rtc_library("codec") { ] deps = [ ":media_constants", - "../api:field_trials_view", "../api:rtp_parameters", "../api/audio_codecs:audio_codecs_api", "../api/video_codecs:video_codecs_api", @@ -546,7 +545,6 @@ rtc_library("rtc_audio_video") { "../rtc_base:copy_on_write_buffer", "../rtc_base:dscp", "../rtc_base:event_tracer", - "../rtc_base:ignore_wundef", "../rtc_base:logging", "../rtc_base:macromagic", "../rtc_base:network_route", @@ -611,33 +609,6 @@ rtc_library("rtc_audio_video") { } } -# Heavy but optional helper for unittests and webrtc users who prefer to use -# defaults factories or do not worry about extra dependencies and binary size. -rtc_library("rtc_media_engine_defaults") { - visibility = [ "*" ] - allow_poison = [ - "audio_codecs", - "default_task_queue", - "software_video_codecs", - ] - sources = [ - "engine/webrtc_media_engine_defaults.cc", - "engine/webrtc_media_engine_defaults.h", - ] - deps = [ - ":rtc_audio_video", - "../api/audio_codecs:builtin_audio_decoder_factory", - "../api/audio_codecs:builtin_audio_encoder_factory", - "../api/task_queue:default_task_queue_factory", - "../api/video:builtin_video_bitrate_allocator_factory", - "../api/video_codecs:builtin_video_decoder_factory", - "../api/video_codecs:builtin_video_encoder_factory", - "../modules/audio_processing:api", - "../rtc_base:checks", - "../rtc_base/system:rtc_export", - ] -} - rtc_source_set("rtc_data_sctp_transport_internal") { sources = [ "sctp/sctp_transport_internal.h" ] deps = [ @@ -840,7 +811,6 @@ if (rtc_include_tests) { ":rtc_internal_video_codecs", ":rtc_media", ":rtc_media_base", - ":rtc_media_engine_defaults", ":rtc_media_tests_utils", ":rtc_sdp_video_format_utils", ":rtc_simulcast_encoder_adapter", @@ -860,6 +830,8 @@ if (rtc_include_tests) { "../api:simulcast_test_fixture_api", "../api/audio_codecs:builtin_audio_decoder_factory", "../api/audio_codecs:builtin_audio_encoder_factory", + "../api/environment", + "../api/environment:environment_factory", "../api/rtc_event_log", "../api/task_queue", "../api/task_queue:default_task_queue_factory", diff --git a/third_party/libwebrtc/media/base/codec.cc b/third_party/libwebrtc/media/base/codec.cc index b819707702..c4e1c6f1f3 100644 --- a/third_party/libwebrtc/media/base/codec.cc +++ b/third_party/libwebrtc/media/base/codec.cc @@ -158,8 +158,7 @@ bool Codec::operator==(const Codec& c) const { : (packetization == c.packetization)); } -bool Codec::Matches(const Codec& codec, - const webrtc::FieldTrialsView* field_trials) const { +bool Codec::Matches(const Codec& codec) const { // Match the codec id/name based on the typical static/dynamic name rules. // Matching is case-insensitive. diff --git a/third_party/libwebrtc/media/base/codec.h b/third_party/libwebrtc/media/base/codec.h index 228acad07a..bd4239b251 100644 --- a/third_party/libwebrtc/media/base/codec.h +++ b/third_party/libwebrtc/media/base/codec.h @@ -20,7 +20,6 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/audio_codecs/audio_format.h" -#include "api/field_trials_view.h" #include "api/rtp_parameters.h" #include "api/video_codecs/sdp_video_format.h" #include "media/base/media_constants.h" @@ -112,8 +111,7 @@ struct RTC_EXPORT Codec { // Indicates if this codec is compatible with the specified codec by // checking the assigned id and profile values for the relevant video codecs. // H264 levels are not compared. - bool Matches(const Codec& codec, - const webrtc::FieldTrialsView* field_trials = nullptr) const; + bool Matches(const Codec& codec) const; bool MatchesRtpCodec(const webrtc::RtpCodec& capability) const; // Find the parameter for `name` and write the value to `out`. diff --git a/third_party/libwebrtc/media/codec_gn/moz.build b/third_party/libwebrtc/media/codec_gn/moz.build index a6fa3b4063..b5ebd454d3 100644 --- a/third_party/libwebrtc/media/codec_gn/moz.build +++ b/third_party/libwebrtc/media/codec_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/engine/null_webrtc_video_engine_unittest.cc b/third_party/libwebrtc/media/engine/null_webrtc_video_engine_unittest.cc index 31c442d53d..9515d44be9 100644 --- a/third_party/libwebrtc/media/engine/null_webrtc_video_engine_unittest.cc +++ b/third_party/libwebrtc/media/engine/null_webrtc_video_engine_unittest.cc @@ -37,7 +37,7 @@ TEST(NullWebRtcVideoEngineTest, CheckInterface) { task_queue_factory.get(), adm.get(), webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, - webrtc::AudioProcessingBuilder().Create(), nullptr, nullptr, trials); + webrtc::AudioProcessingBuilder().Create(), nullptr, trials); CompositeMediaEngine engine(std::move(audio_engine), std::make_unique()); diff --git a/third_party/libwebrtc/media/engine/webrtc_media_engine.cc b/third_party/libwebrtc/media/engine/webrtc_media_engine.cc index 99d7dd2704..463ed29109 100644 --- a/third_party/libwebrtc/media/engine/webrtc_media_engine.cc +++ b/third_party/libwebrtc/media/engine/webrtc_media_engine.cc @@ -46,7 +46,6 @@ std::unique_ptr CreateMediaEngine( std::move(dependencies.audio_decoder_factory), std::move(dependencies.audio_mixer), std::move(dependencies.audio_processing), - dependencies.audio_frame_processor, std::move(dependencies.owned_audio_frame_processor), trials); #ifdef HAVE_WEBRTC_VIDEO auto video_engine = std::make_unique( diff --git a/third_party/libwebrtc/media/engine/webrtc_media_engine.h b/third_party/libwebrtc/media/engine/webrtc_media_engine.h index 0f6dce35b5..863db9f278 100644 --- a/third_party/libwebrtc/media/engine/webrtc_media_engine.h +++ b/third_party/libwebrtc/media/engine/webrtc_media_engine.h @@ -49,9 +49,6 @@ struct MediaEngineDependencies { rtc::scoped_refptr audio_decoder_factory; rtc::scoped_refptr audio_mixer; rtc::scoped_refptr audio_processing; - // TODO(bugs.webrtc.org/15111): - // Remove the raw AudioFrameProcessor pointer in the follow-up. - webrtc::AudioFrameProcessor* audio_frame_processor = nullptr; std::unique_ptr owned_audio_frame_processor; std::unique_ptr video_encoder_factory; @@ -63,8 +60,9 @@ struct MediaEngineDependencies { // CreateMediaEngine may be called on any thread, though the engine is // only expected to be used on one thread, internally called the "worker // thread". This is the thread Init must be called on. -RTC_EXPORT std::unique_ptr CreateMediaEngine( - MediaEngineDependencies dependencies); +[[deprecated("bugs.webrtc.org/15574")]] // +RTC_EXPORT std::unique_ptr +CreateMediaEngine(MediaEngineDependencies dependencies); // Verify that extension IDs are within 1-byte extension range and are not // overlapping, and that they form a legal change from previously registerd diff --git a/third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.cc b/third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.cc deleted file mode 100644 index 1660873e8b..0000000000 --- a/third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "media/engine/webrtc_media_engine_defaults.h" - -#include "api/audio_codecs/builtin_audio_decoder_factory.h" -#include "api/audio_codecs/builtin_audio_encoder_factory.h" -#include "api/task_queue/default_task_queue_factory.h" -#include "api/video/builtin_video_bitrate_allocator_factory.h" -#include "api/video_codecs/builtin_video_decoder_factory.h" -#include "api/video_codecs/builtin_video_encoder_factory.h" -#include "modules/audio_processing/include/audio_processing.h" -#include "rtc_base/checks.h" - -namespace webrtc { - -void SetMediaEngineDefaults(cricket::MediaEngineDependencies* deps) { - RTC_DCHECK(deps); - if (deps->task_queue_factory == nullptr) { - static TaskQueueFactory* const task_queue_factory = - CreateDefaultTaskQueueFactory().release(); - deps->task_queue_factory = task_queue_factory; - } - if (deps->audio_encoder_factory == nullptr) - deps->audio_encoder_factory = CreateBuiltinAudioEncoderFactory(); - if (deps->audio_decoder_factory == nullptr) - deps->audio_decoder_factory = CreateBuiltinAudioDecoderFactory(); - if (deps->audio_processing == nullptr) - deps->audio_processing = AudioProcessingBuilder().Create(); - - if (deps->video_encoder_factory == nullptr) - deps->video_encoder_factory = CreateBuiltinVideoEncoderFactory(); - if (deps->video_decoder_factory == nullptr) - deps->video_decoder_factory = CreateBuiltinVideoDecoderFactory(); -} - -} // namespace webrtc diff --git a/third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.h b/third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.h deleted file mode 100644 index 16b1d462e3..0000000000 --- a/third_party/libwebrtc/media/engine/webrtc_media_engine_defaults.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_DEFAULTS_H_ -#define MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_DEFAULTS_H_ - -#include "media/engine/webrtc_media_engine.h" -#include "rtc_base/system/rtc_export.h" - -namespace webrtc { - -// Sets required but null dependencies with default factories. -RTC_EXPORT void SetMediaEngineDefaults(cricket::MediaEngineDependencies* deps); - -} // namespace webrtc - -#endif // MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_DEFAULTS_H_ diff --git a/third_party/libwebrtc/media/engine/webrtc_media_engine_unittest.cc b/third_party/libwebrtc/media/engine/webrtc_media_engine_unittest.cc index 4615f03deb..40cad75701 100644 --- a/third_party/libwebrtc/media/engine/webrtc_media_engine_unittest.cc +++ b/third_party/libwebrtc/media/engine/webrtc_media_engine_unittest.cc @@ -14,7 +14,6 @@ #include #include -#include "media/engine/webrtc_media_engine_defaults.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" @@ -322,16 +321,4 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantBwe3) { EXPECT_EQ(RtpExtension::kTimestampOffsetUri, filtered[0].uri); } -TEST(WebRtcMediaEngineTest, Create) { - MediaEngineDependencies deps; - webrtc::SetMediaEngineDefaults(&deps); - webrtc::test::ScopedKeyValueConfig trials; - deps.trials = &trials; - - std::unique_ptr engine = - CreateMediaEngine(std::move(deps)); - - EXPECT_TRUE(engine); -} - } // namespace cricket diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc b/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc index e8b7ee4b2d..f5736679be 100644 --- a/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc +++ b/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc @@ -20,9 +20,9 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" -#include "api/rtc_event_log/rtc_event_log.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/rtp_parameters.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/test/mock_encoder_selector.h" #include "api/test/mock_video_bitrate_allocator.h" #include "api/test/mock_video_bitrate_allocator_factory.h" @@ -101,6 +101,8 @@ using ::testing::WithArg; using ::webrtc::BitrateConstraints; using ::webrtc::Call; using ::webrtc::CallConfig; +using ::webrtc::CreateEnvironment; +using ::webrtc::Environment; using ::webrtc::kDefaultScalabilityModeStr; using ::webrtc::RtpExtension; using ::webrtc::RtpPacket; @@ -355,13 +357,10 @@ class WebRtcVideoEngineTest : public ::testing::Test { explicit WebRtcVideoEngineTest(const std::string& field_trials) : field_trials_(field_trials), time_controller_(webrtc::Timestamp::Millis(4711)), - task_queue_factory_(time_controller_.CreateTaskQueueFactory()), - call_(Call::Create([&] { - CallConfig call_config(&event_log_); - call_config.task_queue_factory = task_queue_factory_.get(); - call_config.trials = &field_trials_; - return call_config; - }())), + env_(CreateEnvironment(&field_trials_, + time_controller_.CreateTaskQueueFactory(), + time_controller_.GetClock())), + call_(Call::Create(CallConfig(env_))), encoder_factory_(new cricket::FakeWebRtcVideoEncoderFactory), decoder_factory_(new cricket::FakeWebRtcVideoDecoderFactory), video_bitrate_allocator_factory_( @@ -398,8 +397,7 @@ class WebRtcVideoEngineTest : public ::testing::Test { webrtc::test::ScopedKeyValueConfig field_trials_; webrtc::GlobalSimulatedTimeController time_controller_; - webrtc::RtcEventLogNull event_log_; - std::unique_ptr task_queue_factory_; + Environment env_; // Used in WebRtcVideoEngineVoiceTest, but defined here so it's properly // initialized when the constructor is called. std::unique_ptr call_; @@ -1479,14 +1477,10 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { EXPECT_CALL(*decoder_factory, CreateVideoDecoder(format)).Times(0); // Create a call. - webrtc::RtcEventLogNull event_log; webrtc::GlobalSimulatedTimeController time_controller( webrtc::Timestamp::Millis(4711)); - auto task_queue_factory = time_controller.CreateTaskQueueFactory(); - CallConfig call_config(&event_log); - webrtc::FieldTrialBasedConfig field_trials; - call_config.trials = &field_trials; - call_config.task_queue_factory = task_queue_factory.get(); + CallConfig call_config(CreateEnvironment( + time_controller.CreateTaskQueueFactory(), time_controller.GetClock())); const std::unique_ptr call = Call::Create(call_config); // Create send channel. @@ -1615,18 +1609,11 @@ TEST_F(WebRtcVideoEngineTest, SetVideoRtxEnabled) { class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { protected: - CallConfig GetCallConfig(webrtc::RtcEventLogNull* event_log, - webrtc::TaskQueueFactory* task_queue_factory) { - CallConfig call_config(event_log); - call_config.task_queue_factory = task_queue_factory; - call_config.trials = &field_trials_; - return call_config; - } - WebRtcVideoChannelEncodedFrameCallbackTest() - : task_queue_factory_(time_controller_.CreateTaskQueueFactory()), - call_(Call::Create( - GetCallConfig(&event_log_, task_queue_factory_.get()))), + : env_(CreateEnvironment(&field_trials_, + time_controller_.CreateTaskQueueFactory(), + time_controller_.GetClock())), + call_(Call::Create(CallConfig(env_))), video_bitrate_allocator_factory_( webrtc::CreateBuiltinVideoBitrateAllocatorFactory()), engine_( @@ -1676,8 +1663,7 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { webrtc::GlobalSimulatedTimeController time_controller_{ Timestamp::Seconds(1000)}; webrtc::test::ScopedKeyValueConfig field_trials_; - webrtc::RtcEventLogNull event_log_; - std::unique_ptr task_queue_factory_; + Environment env_; std::unique_ptr call_; std::unique_ptr video_bitrate_allocator_factory_; @@ -1796,7 +1782,9 @@ TEST_F(WebRtcVideoChannelEncodedFrameCallbackTest, DoesNotDecodeWhenDisabled) { class WebRtcVideoChannelBaseTest : public ::testing::Test { protected: WebRtcVideoChannelBaseTest() - : task_queue_factory_(time_controller_.CreateTaskQueueFactory()), + : env_(CreateEnvironment(&field_trials_, + time_controller_.CreateTaskQueueFactory(), + time_controller_.GetClock())), video_bitrate_allocator_factory_( webrtc::CreateBuiltinVideoBitrateAllocatorFactory()), engine_(std::make_unique override_field_trials_; - std::unique_ptr task_queue_factory_; + Environment env_; std::unique_ptr call_; std::unique_ptr video_bitrate_allocator_factory_; @@ -4378,7 +4362,7 @@ TEST_F(WebRtcVideoChannelTest, SetDefaultSendCodecs) { absl::optional codec = send_channel_->GetSendCodec(); ASSERT_TRUE(codec); - EXPECT_TRUE(codec->Matches(engine_.send_codecs()[0], &field_trials_)); + EXPECT_TRUE(codec->Matches(engine_.send_codecs()[0])); // Using a RTX setup to verify that the default RTX payload type is good. const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); @@ -9863,7 +9847,6 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { } webrtc::test::ScopedKeyValueConfig field_trials_; - webrtc::RtcEventLogNull event_log_; FakeCall fake_call_; cricket::FakeWebRtcVideoEncoderFactory* encoder_factory_; cricket::FakeWebRtcVideoDecoderFactory* decoder_factory_; diff --git a/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc b/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc index adf8b5c51d..adf662074d 100644 --- a/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc +++ b/third_party/libwebrtc/media/engine/webrtc_voice_engine.cc @@ -66,7 +66,6 @@ #include "rtc_base/checks.h" #include "rtc_base/dscp.h" #include "rtc_base/experiments/struct_parameters_parser.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/logging.h" #include "rtc_base/race_checker.h" #include "rtc_base/string_encode.h" @@ -79,13 +78,12 @@ #include "system_wrappers/include/metrics.h" #if WEBRTC_ENABLE_PROTOBUF -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" #else #include "modules/audio_coding/audio_network_adaptor/config.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() + #endif namespace cricket { @@ -147,12 +145,10 @@ bool IsCodec(const AudioCodec& codec, const char* ref_name) { return absl::EqualsIgnoreCase(codec.name, ref_name); } -absl::optional FindCodec( - const std::vector& codecs, - const AudioCodec& codec, - const webrtc::FieldTrialsView* field_trials) { +absl::optional FindCodec(const std::vector& codecs, + const AudioCodec& codec) { for (const AudioCodec& c : codecs) { - if (c.Matches(codec, field_trials)) { + if (c.Matches(codec)) { return c; } } @@ -344,10 +340,7 @@ WebRtcVoiceEngine::WebRtcVoiceEngine( const rtc::scoped_refptr& decoder_factory, rtc::scoped_refptr audio_mixer, rtc::scoped_refptr audio_processing, - // TODO(bugs.webrtc.org/15111): - // Remove the raw AudioFrameProcessor pointer in the follow-up. - webrtc::AudioFrameProcessor* audio_frame_processor, - std::unique_ptr owned_audio_frame_processor, + std::unique_ptr audio_frame_processor, const webrtc::FieldTrialsView& trials) : task_queue_factory_(task_queue_factory), adm_(adm), @@ -355,8 +348,7 @@ WebRtcVoiceEngine::WebRtcVoiceEngine( decoder_factory_(decoder_factory), audio_mixer_(audio_mixer), apm_(audio_processing), - audio_frame_processor_(audio_frame_processor), - owned_audio_frame_processor_(std::move(owned_audio_frame_processor)), + audio_frame_processor_(std::move(audio_frame_processor)), minimized_remsampling_on_mobile_trial_enabled_( IsEnabled(trials, "WebRTC-Audio-MinimizeResamplingOnMobile")) { RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; @@ -425,11 +417,7 @@ void WebRtcVoiceEngine::Init() { if (audio_frame_processor_) { config.async_audio_processing_factory = rtc::make_ref_counted( - *audio_frame_processor_, *task_queue_factory_); - } else if (owned_audio_frame_processor_) { - config.async_audio_processing_factory = - rtc::make_ref_counted( - std::move(owned_audio_frame_processor_), *task_queue_factory_); + std::move(audio_frame_processor_), *task_queue_factory_); } audio_state_ = webrtc::AudioState::Create(config); } @@ -2151,8 +2139,7 @@ bool WebRtcVoiceReceiveChannel::SetRecvCodecs( for (const AudioCodec& codec : codecs) { // Log a warning if a codec's payload type is changing. This used to be // treated as an error. It's abnormal, but not really illegal. - absl::optional old_codec = - FindCodec(recv_codecs_, codec, &call_->trials()); + absl::optional old_codec = FindCodec(recv_codecs_, codec); if (old_codec && old_codec->id != codec.id) { RTC_LOG(LS_WARNING) << codec.name << " mapped to a second payload type (" << codec.id << ", was already mapped to " diff --git a/third_party/libwebrtc/media/engine/webrtc_voice_engine.h b/third_party/libwebrtc/media/engine/webrtc_voice_engine.h index a3e6d3acab..ed71667525 100644 --- a/third_party/libwebrtc/media/engine/webrtc_voice_engine.h +++ b/third_party/libwebrtc/media/engine/webrtc_voice_engine.h @@ -90,9 +90,6 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { const rtc::scoped_refptr& decoder_factory, rtc::scoped_refptr audio_mixer, rtc::scoped_refptr audio_processing, - // TODO(bugs.webrtc.org/15111): - // Remove the raw AudioFrameProcessor pointer in the follow-up. - webrtc::AudioFrameProcessor* audio_frame_processor, std::unique_ptr owned_audio_frame_processor, const webrtc::FieldTrialsView& trials); @@ -166,10 +163,7 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { // The audio processing module. rtc::scoped_refptr apm_; // Asynchronous audio processing. - // TODO(bugs.webrtc.org/15111): - // Remove the raw AudioFrameProcessor pointer in the follow-up. - webrtc::AudioFrameProcessor* const audio_frame_processor_; - std::unique_ptr owned_audio_frame_processor_; + std::unique_ptr audio_frame_processor_; // The primary instance of WebRtc VoiceEngine. rtc::scoped_refptr audio_state_; std::vector send_codecs_; diff --git a/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc b/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc index b1393eec74..4d6580631d 100644 --- a/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc +++ b/third_party/libwebrtc/media/engine/webrtc_voice_engine_unittest.cc @@ -18,8 +18,9 @@ #include "absl/types/optional.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/environment/environment.h" +#include "api/environment/environment_factory.h" #include "api/media_types.h" -#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" @@ -45,6 +46,7 @@ #include "test/mock_audio_encoder_factory.h" #include "test/scoped_key_value_config.h" +namespace { using ::testing::_; using ::testing::ContainerEq; using ::testing::Contains; @@ -55,11 +57,11 @@ using ::testing::ReturnPointee; using ::testing::SaveArg; using ::testing::StrictMock; using ::testing::UnorderedElementsAreArray; +using ::webrtc::BitrateConstraints; using ::webrtc::Call; using ::webrtc::CallConfig; - -namespace { -using webrtc::BitrateConstraints; +using ::webrtc::CreateEnvironment; +using ::webrtc::Environment; constexpr uint32_t kMaxUnsignaledRecvStreams = 4; @@ -174,7 +176,7 @@ TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { task_queue_factory.get(), adm.get(), webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm, - nullptr, nullptr, trials); + nullptr, trials); engine.Init(); } } @@ -220,7 +222,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { auto decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); engine_.reset(new cricket::WebRtcVoiceEngine( task_queue_factory_.get(), adm_.get(), encoder_factory, decoder_factory, - nullptr, apm_, nullptr, nullptr, field_trials_)); + nullptr, apm_, nullptr, field_trials_)); engine_->Init(); send_parameters_.codecs.push_back(kPcmuCodec); recv_parameters_.codecs.push_back(kPcmuCodec); @@ -3678,24 +3680,18 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) { for (bool use_null_apm : {false, true}) { // If the VoiceEngine wants to gather available codecs early, that's fine // but we never want it to create a decoder at this stage. - std::unique_ptr task_queue_factory = - webrtc::CreateDefaultTaskQueueFactory(); + Environment env = CreateEnvironment(); rtc::scoped_refptr adm = webrtc::test::MockAudioDeviceModule::CreateNice(); rtc::scoped_refptr apm = use_null_apm ? nullptr : webrtc::AudioProcessingBuilder().Create(); - webrtc::FieldTrialBasedConfig field_trials; cricket::WebRtcVoiceEngine engine( - task_queue_factory.get(), adm.get(), + &env.task_queue_factory(), adm.get(), webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm, - nullptr, nullptr, field_trials); + nullptr, env.field_trials()); engine.Init(); - webrtc::RtcEventLogNull event_log; - CallConfig call_config(&event_log); - call_config.trials = &field_trials; - call_config.task_queue_factory = task_queue_factory.get(); - std::unique_ptr call = Call::Create(call_config); + std::unique_ptr call = Call::Create(CallConfig(env)); std::unique_ptr send_channel = engine.CreateSendChannel( call.get(), cricket::MediaConfig(), cricket::AudioOptions(), @@ -3713,25 +3709,19 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) { TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { rtc::AutoThread main_thread; for (bool use_null_apm : {false, true}) { - std::unique_ptr task_queue_factory = - webrtc::CreateDefaultTaskQueueFactory(); + Environment env = CreateEnvironment(); auto adm = rtc::make_ref_counted< ::testing::NiceMock>(); { rtc::scoped_refptr apm = use_null_apm ? nullptr : webrtc::AudioProcessingBuilder().Create(); - webrtc::FieldTrialBasedConfig field_trials; cricket::WebRtcVoiceEngine engine( - task_queue_factory.get(), adm.get(), + &env.task_queue_factory(), adm.get(), webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm, - nullptr, nullptr, field_trials); + nullptr, env.field_trials()); engine.Init(); - webrtc::RtcEventLogNull event_log; - CallConfig call_config(&event_log); - call_config.trials = &field_trials; - call_config.task_queue_factory = task_queue_factory.get(); - std::unique_ptr call = Call::Create(call_config); + std::unique_ptr call = Call::Create(CallConfig(env)); std::unique_ptr send_channel = engine.CreateSendChannel( call.get(), cricket::MediaConfig(), cricket::AudioOptions(), @@ -3765,7 +3755,7 @@ TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { task_queue_factory.get(), adm.get(), webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm, - nullptr, nullptr, field_trials); + nullptr, field_trials); engine.Init(); for (const cricket::AudioCodec& codec : engine.send_codecs()) { auto is_codec = [&codec](const char* name, int clockrate = 0) { @@ -3804,24 +3794,18 @@ TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { TEST(WebRtcVoiceEngineTest, Has32Channels) { rtc::AutoThread main_thread; for (bool use_null_apm : {false, true}) { - std::unique_ptr task_queue_factory = - webrtc::CreateDefaultTaskQueueFactory(); + Environment env = CreateEnvironment(); rtc::scoped_refptr adm = webrtc::test::MockAudioDeviceModule::CreateNice(); rtc::scoped_refptr apm = use_null_apm ? nullptr : webrtc::AudioProcessingBuilder().Create(); - webrtc::FieldTrialBasedConfig field_trials; cricket::WebRtcVoiceEngine engine( - task_queue_factory.get(), adm.get(), + &env.task_queue_factory(), adm.get(), webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm, - nullptr, nullptr, field_trials); + nullptr, env.field_trials()); engine.Init(); - webrtc::RtcEventLogNull event_log; - CallConfig call_config(&event_log); - call_config.trials = &field_trials; - call_config.task_queue_factory = task_queue_factory.get(); - std::unique_ptr call = Call::Create(call_config); + std::unique_ptr call = Call::Create(CallConfig(env)); std::vector> channels; @@ -3843,8 +3827,7 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) { TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { rtc::AutoThread main_thread; for (bool use_null_apm : {false, true}) { - std::unique_ptr task_queue_factory = - webrtc::CreateDefaultTaskQueueFactory(); + Environment env = CreateEnvironment(); // TODO(ossu): I'm not sure of the intent of this test. It's either: // - Check that our builtin codecs are usable by Channel. // - The codecs provided by the engine is usable by Channel. @@ -3856,18 +3839,13 @@ TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { webrtc::test::MockAudioDeviceModule::CreateNice(); rtc::scoped_refptr apm = use_null_apm ? nullptr : webrtc::AudioProcessingBuilder().Create(); - webrtc::FieldTrialBasedConfig field_trials; cricket::WebRtcVoiceEngine engine( - task_queue_factory.get(), adm.get(), + &env.task_queue_factory(), adm.get(), webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, apm, nullptr, - nullptr, field_trials); + env.field_trials()); engine.Init(); - webrtc::RtcEventLogNull event_log; - CallConfig call_config(&event_log); - call_config.trials = &field_trials; - call_config.task_queue_factory = task_queue_factory.get(); - std::unique_ptr call = Call::Create(call_config); + std::unique_ptr call = Call::Create(CallConfig(env)); cricket::WebRtcVoiceReceiveChannel channel( &engine, cricket::MediaConfig(), cricket::AudioOptions(), webrtc::CryptoOptions(), call.get(), @@ -3880,22 +3858,17 @@ TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { TEST(WebRtcVoiceEngineTest, SetRtpSendParametersMaxBitrate) { rtc::AutoThread main_thread; - std::unique_ptr task_queue_factory = - webrtc::CreateDefaultTaskQueueFactory(); + Environment env = CreateEnvironment(); rtc::scoped_refptr adm = webrtc::test::MockAudioDeviceModule::CreateNice(); - webrtc::FieldTrialBasedConfig field_trials; FakeAudioSource source; - cricket::WebRtcVoiceEngine engine(task_queue_factory.get(), adm.get(), + cricket::WebRtcVoiceEngine engine(&env.task_queue_factory(), adm.get(), webrtc::CreateBuiltinAudioEncoderFactory(), webrtc::CreateBuiltinAudioDecoderFactory(), - nullptr, nullptr, nullptr, nullptr, - field_trials); + nullptr, nullptr, nullptr, + env.field_trials()); engine.Init(); - webrtc::RtcEventLogNull event_log; - CallConfig call_config(&event_log); - call_config.trials = &field_trials; - call_config.task_queue_factory = task_queue_factory.get(); + CallConfig call_config(env); { webrtc::AudioState::Config config; config.audio_mixer = webrtc::AudioMixerImpl::Create(); @@ -3965,7 +3938,7 @@ TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { webrtc::FieldTrialBasedConfig field_trials; cricket::WebRtcVoiceEngine engine( task_queue_factory.get(), adm.get(), unused_encoder_factory, - mock_decoder_factory, nullptr, apm, nullptr, nullptr, field_trials); + mock_decoder_factory, nullptr, apm, nullptr, field_trials); engine.Init(); auto codecs = engine.recv_codecs(); EXPECT_EQ(11u, codecs.size()); diff --git a/third_party/libwebrtc/media/media_channel_gn/moz.build b/third_party/libwebrtc/media/media_channel_gn/moz.build index 1bedb41bf2..c665368568 100644 --- a/third_party/libwebrtc/media/media_channel_gn/moz.build +++ b/third_party/libwebrtc/media/media_channel_gn/moz.build @@ -192,16 +192,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/media_channel_impl_gn/moz.build b/third_party/libwebrtc/media/media_channel_impl_gn/moz.build index 7d0a4bd650..27bfa53fff 100644 --- a/third_party/libwebrtc/media/media_channel_impl_gn/moz.build +++ b/third_party/libwebrtc/media/media_channel_impl_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/media_constants_gn/moz.build b/third_party/libwebrtc/media/media_constants_gn/moz.build index af4cd6b257..95a0c3a056 100644 --- a/third_party/libwebrtc/media/media_constants_gn/moz.build +++ b/third_party/libwebrtc/media/media_constants_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/rid_description_gn/moz.build b/third_party/libwebrtc/media/rid_description_gn/moz.build index 61afeec945..944901a1ca 100644 --- a/third_party/libwebrtc/media/rid_description_gn/moz.build +++ b/third_party/libwebrtc/media/rid_description_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/rtc_media_base_gn/moz.build b/third_party/libwebrtc/media/rtc_media_base_gn/moz.build index cfff6f3411..a5b3661adc 100644 --- a/third_party/libwebrtc/media/rtc_media_base_gn/moz.build +++ b/third_party/libwebrtc/media/rtc_media_base_gn/moz.build @@ -203,7 +203,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -213,10 +212,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/rtc_media_config_gn/moz.build b/third_party/libwebrtc/media/rtc_media_config_gn/moz.build index 17afebe8da..8f3f81cc5b 100644 --- a/third_party/libwebrtc/media/rtc_media_config_gn/moz.build +++ b/third_party/libwebrtc/media/rtc_media_config_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build b/third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build index c09703ddd6..6b1032e1b0 100644 --- a/third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build +++ b/third_party/libwebrtc/media/rtc_simulcast_encoder_adapter_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/rtp_utils_gn/moz.build b/third_party/libwebrtc/media/rtp_utils_gn/moz.build index 1aaa347151..e2e5c11695 100644 --- a/third_party/libwebrtc/media/rtp_utils_gn/moz.build +++ b/third_party/libwebrtc/media/rtp_utils_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/media/stream_params_gn/moz.build b/third_party/libwebrtc/media/stream_params_gn/moz.build index 71875c4e01..1582a42c0d 100644 --- a/third_party/libwebrtc/media/stream_params_gn/moz.build +++ b/third_party/libwebrtc/media/stream_params_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build b/third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build index 347559a342..dfff987043 100644 --- a/third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build +++ b/third_party/libwebrtc/modules/async_audio_processing/async_audio_processing_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/BUILD.gn b/third_party/libwebrtc/modules/audio_coding/BUILD.gn index 3e4d7e0c25..ddd1fd2656 100644 --- a/third_party/libwebrtc/modules/audio_coding/BUILD.gn +++ b/third_party/libwebrtc/modules/audio_coding/BUILD.gn @@ -618,7 +618,6 @@ rtc_library("audio_network_adaptor") { "../../common_audio", "../../logging:rtc_event_audio", "../../rtc_base:checks", - "../../rtc_base:ignore_wundef", "../../rtc_base:logging", "../../rtc_base:protobuf_utils", "../../rtc_base:safe_conversions", @@ -957,7 +956,6 @@ rtc_library("audio_coding_modules_tests_shared") { "../../api/audio_codecs:builtin_audio_encoder_factory", "../../api/neteq:neteq_api", "../../rtc_base:checks", - "../../rtc_base:ignore_wundef", "../../rtc_base:ssl", "../../rtc_base:stringutils", "../../system_wrappers", @@ -1644,6 +1642,7 @@ if (rtc_include_tests) { "neteq/mock/mock_expand.h", "neteq/mock/mock_histogram.h", "neteq/mock/mock_neteq_controller.h", + "neteq/mock/mock_packet_arrival_history.h", "neteq/mock/mock_packet_buffer.h", "neteq/mock/mock_red_payload_splitter.h", "neteq/mock/mock_statistics_calculator.h", @@ -1717,7 +1716,6 @@ if (rtc_include_tests) { "../../logging:rtc_event_audio", "../../modules/rtp_rtcp:rtp_rtcp_format", "../../rtc_base:checks", - "../../rtc_base:ignore_wundef", "../../rtc_base:macromagic", "../../rtc_base:platform_thread", "../../rtc_base:refcount", diff --git a/third_party/libwebrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/third_party/libwebrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc index 210244154a..2d9ea91106 100644 --- a/third_party/libwebrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -707,7 +707,7 @@ class AcmSenderBitExactnessNewApi : public AcmSenderBitExactnessOldApi {}; TEST_F(AcmSenderBitExactnessOldApi, Pcm16_8000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80)); - Run(/*audio_checksum_ref=*/"69118ed438ac76252d023e0463819471", + Run(/*audio_checksum_ref=*/"3e43fd5d3c73a59e8118e68fbfafe2c7", /*payload_checksum_ref=*/"c1edd36339ce0326cc4550041ad719a0", /*expected_packets=*/100, /*expected_channels=*/test::AcmReceiveTestOldApi::kMonoOutput); @@ -715,7 +715,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcm16_8000khz_10ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcm16_16000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 16000, 1, 108, 160, 160)); - Run(/*audio_checksum_ref=*/"f95c87bdd33f631bcf80f4b19445bbd2", + Run(/*audio_checksum_ref=*/"608750138315cbab33d76d38e8367807", /*payload_checksum_ref=*/"ad786526383178b08d80d6eee06e9bad", /*expected_packets=*/100, /*expected_channels=*/test::AcmReceiveTestOldApi::kMonoOutput); @@ -723,7 +723,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcm16_16000khz_10ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcm16_32000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 32000, 1, 109, 320, 320)); - Run(/*audio_checksum_ref=*/"c50244419c5c3a2f04cc69a022c266a2", + Run(/*audio_checksum_ref=*/"02e9927ef5e4d2cd792a5df0bdee5e19", /*payload_checksum_ref=*/"5ef82ea885e922263606c6fdbc49f651", /*expected_packets=*/100, /*expected_channels=*/test::AcmReceiveTestOldApi::kMonoOutput); @@ -731,7 +731,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcm16_32000khz_10ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_8000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 2, 111, 80, 80)); - Run(/*audio_checksum_ref=*/"4fccf4cc96f1e8e8de4b9fadf62ded9e", + Run(/*audio_checksum_ref=*/"4ff38de045b19f64de9c7e229ba36317", /*payload_checksum_ref=*/"62ce5adb0d4965d0a52ec98ae7f98974", /*expected_packets=*/100, /*expected_channels=*/test::AcmReceiveTestOldApi::kStereoOutput); @@ -739,7 +739,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_8000khz_10ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_16000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 16000, 2, 112, 160, 160)); - Run(/*audio_checksum_ref=*/"e15e388d9d4af8c02a59fe1552fedee3", + Run(/*audio_checksum_ref=*/"1ee35394cfca78ad6d55468441af36fa", /*payload_checksum_ref=*/"41ca8edac4b8c71cd54fd9f25ec14870", /*expected_packets=*/100, /*expected_channels=*/test::AcmReceiveTestOldApi::kStereoOutput); @@ -747,7 +747,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_16000khz_10ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_32000khz_10ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 32000, 2, 113, 320, 320)); - Run(/*audio_checksum_ref=*/"b240520c0d05003fde7a174ae5957286", + Run(/*audio_checksum_ref=*/"19cae34730a0f6a17cf4e76bf21b69d6", /*payload_checksum_ref=*/"50e58502fb04421bf5b857dda4c96879", /*expected_packets=*/100, /*expected_channels=*/test::AcmReceiveTestOldApi::kStereoOutput); @@ -763,7 +763,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcmu_20ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcma_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMA", 8000, 1, 8, 160, 160)); - Run(/*audio_checksum_ref=*/"47eb60e855eb12d1b0e6da9c975754a4", + Run(/*audio_checksum_ref=*/"ae259cab624095270b7369e53a7b53a3", /*payload_checksum_ref=*/"6ad745e55aa48981bfc790d0eeef2dd1", /*expected_packets=*/50, /*expected_channels=*/test::AcmReceiveTestOldApi::kMonoOutput); @@ -779,7 +779,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcmu_stereo_20ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcma_stereo_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMA", 8000, 2, 118, 160, 160)); - Run(/*audio_checksum_ref=*/"a84d75e098d87ab6b260687eb4b612a2", + Run(/*audio_checksum_ref=*/"f2e81d2531a805c40e61da5106b50006", /*payload_checksum_ref=*/"92b282c83efd20e7eeef52ba40842cf7", /*expected_packets=*/50, /*expected_channels=*/test::AcmReceiveTestOldApi::kStereoOutput); @@ -789,7 +789,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Pcma_stereo_20ms) { defined(WEBRTC_ARCH_X86_64) TEST_F(AcmSenderBitExactnessOldApi, Ilbc_30ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("ILBC", 8000, 1, 102, 240, 240)); - Run(/*audio_checksum_ref=*/"b14dba0de36efa5ec88a32c0b320b70f", + Run(/*audio_checksum_ref=*/"a739434bec8a754e9356ce2115603ce5", /*payload_checksum_ref=*/"cfae2e9f6aba96e145f2bcdd5050ce78", /*expected_packets=*/33, /*expected_channels=*/test::AcmReceiveTestOldApi::kMonoOutput); @@ -799,7 +799,7 @@ TEST_F(AcmSenderBitExactnessOldApi, Ilbc_30ms) { #if defined(WEBRTC_LINUX) && defined(WEBRTC_ARCH_X86_64) TEST_F(AcmSenderBitExactnessOldApi, G722_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("G722", 16000, 1, 9, 320, 160)); - Run(/*audio_checksum_ref=*/"f5264affff25cf2cbd2e1e8a5217f9a3", + Run(/*audio_checksum_ref=*/"b875d9a3e41f5470857bdff02e3b368f", /*payload_checksum_ref=*/"fc68a87e1380614e658087cb35d5ca10", /*expected_packets=*/50, /*expected_channels=*/test::AcmReceiveTestOldApi::kMonoOutput); @@ -809,7 +809,7 @@ TEST_F(AcmSenderBitExactnessOldApi, G722_20ms) { #if defined(WEBRTC_LINUX) && defined(WEBRTC_ARCH_X86_64) TEST_F(AcmSenderBitExactnessOldApi, G722_stereo_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("G722", 16000, 2, 119, 320, 160)); - Run(/*audio_checksum_ref=*/"be0b8528ff9db3a2219f55ddd36faf7f", + Run(/*audio_checksum_ref=*/"02c427d73363b2f37853a0dd17fe1aba", /*payload_checksum_ref=*/"66516152eeaa1e650ad94ff85f668dac", /*expected_packets=*/50, /*expected_channels=*/test::AcmReceiveTestOldApi::kStereoOutput); @@ -897,8 +897,8 @@ TEST_F(AcmSenderBitExactnessNewApi, OpusFromFormat_stereo_20ms_voip) { ASSERT_NO_FATAL_FAILURE(SetUpTestExternalEncoder( AudioEncoderOpus::MakeAudioEncoder(*config, 120), 120)); const std::string audio_maybe_sse = - "1010e60ad34cee73c939edaf563d0593" - "|c05b4523d4c3fad2bab96d2a56baa2d0"; + "cb644fc17d9666a0f5986eef24818159" + "|4a74024473c7c729543c2790829b1e42"; const std::string payload_maybe_sse = "ea48d94e43217793af9b7e15ece94e54" diff --git a/third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build index 4dad1217d0..88fa77a0e2 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/audio_coding_gn/moz.build @@ -203,7 +203,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -213,10 +212,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build index 704026c845..851dd7b58e 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/audio_coding_module_typedefs_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build index bbb1557baa..e509916cfd 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/audio_coding_opus_common_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build index 75153f3221..7829419065 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/audio_encoder_cng_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc index 42dd8a8786..793c73a380 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc +++ b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc @@ -24,18 +24,16 @@ #include "modules/audio_coding/audio_network_adaptor/frame_length_controller.h" #include "modules/audio_coding/audio_network_adaptor/frame_length_controller_v2.h" #include "modules/audio_coding/audio_network_adaptor/util/threshold_curve.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/logging.h" #include "rtc_base/time_utils.h" #if WEBRTC_ENABLE_PROTOBUF -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" #else #include "modules/audio_coding/audio_network_adaptor/config.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() + #endif namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc index 3e6ecf6def..f399511757 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc @@ -17,17 +17,14 @@ #include "modules/audio_coding/audio_network_adaptor/mock/mock_controller.h" #include "modules/audio_coding/audio_network_adaptor/mock/mock_debug_dump_writer.h" #include "rtc_base/fake_clock.h" -#include "rtc_base/ignore_wundef.h" #include "test/gtest.h" #if WEBRTC_ENABLE_PROTOBUF -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" #else #include "modules/audio_coding/audio_network_adaptor/config.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() #endif namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc index 2616706ee5..5ffbee219c 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc +++ b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc @@ -14,18 +14,15 @@ #include "absl/types/optional.h" #include "rtc_base/checks.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/system/file_wrapper.h" #if WEBRTC_ENABLE_PROTOBUF -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/debug_dump.pb.h" #else #include "modules/audio_coding/audio_network_adaptor/debug_dump.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() #endif namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h index 8fdf2f7728..fd3a64dbb1 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h +++ b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor/debug_dump_writer.h @@ -15,16 +15,14 @@ #include "modules/audio_coding/audio_network_adaptor/controller.h" #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/system/file_wrapper.h" + #if WEBRTC_ENABLE_PROTOBUF -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" #else #include "modules/audio_coding/audio_network_adaptor/config.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() #endif namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build index b9d3c55453..de87e8b033 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_config_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build index 7d446965f1..8a371a9aaf 100644 --- a/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/audio_network_adaptor_gn/moz.build @@ -209,7 +209,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -219,10 +218,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/default_neteq_factory_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/default_neteq_factory_gn/moz.build index aea0a80ed4..d7928549d7 100644 --- a/third_party/libwebrtc/modules/audio_coding/default_neteq_factory_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/default_neteq_factory_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build index 575478702e..bedb8fc477 100644 --- a/third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/g711_c_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build index fa25fde0bd..103d89c6d8 100644 --- a/third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/g711_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build index 4821c2bd82..48137ada85 100644 --- a/third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/g722_c_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build index 0a56f32af0..81eb870466 100644 --- a/third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/g722_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build index 43d69c7662..d3aa4e0018 100644 --- a/third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/ilbc_c_gn/moz.build @@ -267,7 +267,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -277,10 +276,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build index c4b3b4cd13..9a397a1fdc 100644 --- a/third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/ilbc_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build index 4f4a5c0e7e..fdfc4fc855 100644 --- a/third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/isac_bwinfo_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build index a5cc52279a..1b599c5e51 100644 --- a/third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/isac_vad_gn/moz.build @@ -187,7 +187,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -197,10 +196,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build index 78b7338ddd..b884cb8d99 100644 --- a/third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/legacy_encoded_audio_frame_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.cc b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.cc index fd4f2f5a20..6648fd8709 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.cc @@ -95,10 +95,14 @@ DecisionLogic::DecisionLogic(NetEqController::Config config) DecisionLogic::DecisionLogic( NetEqController::Config config, std::unique_ptr delay_manager, - std::unique_ptr buffer_level_filter) + std::unique_ptr buffer_level_filter, + std::unique_ptr packet_arrival_history) : delay_manager_(std::move(delay_manager)), buffer_level_filter_(std::move(buffer_level_filter)), - packet_arrival_history_(config_.packet_history_size_ms), + packet_arrival_history_(packet_arrival_history + ? std::move(packet_arrival_history) + : std::make_unique( + config_.packet_history_size_ms)), tick_timer_(config.tick_timer), disallow_time_stretching_(!config.allow_time_stretching), timescale_countdown_( @@ -115,7 +119,7 @@ void DecisionLogic::SoftReset() { time_stretched_cn_samples_ = 0; delay_manager_->Reset(); buffer_level_filter_->Reset(); - packet_arrival_history_.Reset(); + packet_arrival_history_->Reset(); } void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) { @@ -124,7 +128,7 @@ void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) { fs_hz == 48000); sample_rate_khz_ = fs_hz / 1000; output_size_samples_ = output_size_samples; - packet_arrival_history_.set_sample_rate(fs_hz); + packet_arrival_history_->set_sample_rate(fs_hz); } NetEq::Operation DecisionLogic::GetDecision(const NetEqStatus& status, @@ -218,15 +222,15 @@ absl::optional DecisionLogic::PacketArrived( delay_manager_->SetPacketAudioLength(packet_length_samples_ * 1000 / fs_hz); } int64_t time_now_ms = tick_timer_->ticks() * tick_timer_->ms_per_tick(); - packet_arrival_history_.Insert(info.main_timestamp, time_now_ms); - if (packet_arrival_history_.size() < 2) { + packet_arrival_history_->Insert(info.main_timestamp, time_now_ms); + if (packet_arrival_history_->size() < 2) { // No meaningful delay estimate unless at least 2 packets have arrived. return absl::nullopt; } int arrival_delay_ms = - packet_arrival_history_.GetDelayMs(info.main_timestamp, time_now_ms); + packet_arrival_history_->GetDelayMs(info.main_timestamp, time_now_ms); bool reordered = - !packet_arrival_history_.IsNewestRtpTimestamp(info.main_timestamp); + !packet_arrival_history_->IsNewestRtpTimestamp(info.main_timestamp); delay_manager_->Update(arrival_delay_ms, reordered); return arrival_delay_ms; } @@ -306,10 +310,10 @@ NetEq::Operation DecisionLogic::ExpectedPacketAvailable( !status.play_dtmf) { if (config_.enable_stable_delay_mode) { const int playout_delay_ms = GetPlayoutDelayMs(status); - const int low_limit = TargetLevelMs(); - const int high_limit = low_limit + - packet_arrival_history_.GetMaxDelayMs() + - kDelayAdjustmentGranularityMs; + const int64_t low_limit = TargetLevelMs(); + const int64_t high_limit = low_limit + + packet_arrival_history_->GetMaxDelayMs() + + kDelayAdjustmentGranularityMs; if (playout_delay_ms >= high_limit * 4) { return NetEq::Operation::kFastAccelerate; } @@ -460,7 +464,7 @@ int DecisionLogic::GetPlayoutDelayMs( NetEqController::NetEqStatus status) const { uint32_t playout_timestamp = status.target_timestamp - status.sync_buffer_samples; - return packet_arrival_history_.GetDelayMs( + return packet_arrival_history_->GetDelayMs( playout_timestamp, tick_timer_->ticks() * tick_timer_->ms_per_tick()); } diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.h b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.h index d96fbecd6a..a6b02c69cd 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.h +++ b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.h @@ -27,9 +27,11 @@ namespace webrtc { class DecisionLogic : public NetEqController { public: DecisionLogic(NetEqController::Config config); - DecisionLogic(NetEqController::Config config, - std::unique_ptr delay_manager, - std::unique_ptr buffer_level_filter); + DecisionLogic( + NetEqController::Config config, + std::unique_ptr delay_manager, + std::unique_ptr buffer_level_filter, + std::unique_ptr packet_arrival_history = nullptr); ~DecisionLogic() override; @@ -154,16 +156,16 @@ class DecisionLogic : public NetEqController { struct Config { Config(); - bool enable_stable_delay_mode = false; - bool combine_concealment_decision = false; + bool enable_stable_delay_mode = true; + bool combine_concealment_decision = true; int deceleration_target_level_offset_ms = 85; int packet_history_size_ms = 2000; - absl::optional cng_timeout_ms; + absl::optional cng_timeout_ms = 1000; }; Config config_; std::unique_ptr delay_manager_; std::unique_ptr buffer_level_filter_; - PacketArrivalHistory packet_arrival_history_; + std::unique_ptr packet_arrival_history_; const TickTimer* tick_timer_; int sample_rate_khz_; size_t output_size_samples_; diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc index 97e20dd883..9e9902af50 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc @@ -18,6 +18,7 @@ #include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/mock/mock_buffer_level_filter.h" #include "modules/audio_coding/neteq/mock/mock_delay_manager.h" +#include "modules/audio_coding/neteq/mock/mock_packet_arrival_history.h" #include "test/field_trial.h" #include "test/gtest.h" @@ -47,6 +48,7 @@ NetEqController::NetEqStatus CreateNetEqStatus(NetEq::Mode last_mode, return status; } +using ::testing::_; using ::testing::Return; } // namespace @@ -54,8 +56,6 @@ using ::testing::Return; class DecisionLogicTest : public ::testing::Test { protected: DecisionLogicTest() { - test::ScopedFieldTrials trials( - "WebRTC-Audio-NetEqDecisionLogicConfig/cng_timeout_ms:1000/"); NetEqController::Config config; config.tick_timer = &tick_timer_; config.allow_time_stretching = true; @@ -64,8 +64,11 @@ class DecisionLogicTest : public ::testing::Test { mock_delay_manager_ = delay_manager.get(); auto buffer_level_filter = std::make_unique(); mock_buffer_level_filter_ = buffer_level_filter.get(); + auto packet_arrival_history = std::make_unique(); + mock_packet_arrival_history_ = packet_arrival_history.get(); decision_logic_ = std::make_unique( - config, std::move(delay_manager), std::move(buffer_level_filter)); + config, std::move(delay_manager), std::move(buffer_level_filter), + std::move(packet_arrival_history)); decision_logic_->SetSampleRate(kSampleRate, kOutputSizeSamples); } @@ -73,13 +76,16 @@ class DecisionLogicTest : public ::testing::Test { std::unique_ptr decision_logic_; MockDelayManager* mock_delay_manager_; MockBufferLevelFilter* mock_buffer_level_filter_; + MockPacketArrivalHistory* mock_packet_arrival_history_; }; TEST_F(DecisionLogicTest, NormalOperation) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(90 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(100)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -92,8 +98,10 @@ TEST_F(DecisionLogicTest, NormalOperation) { TEST_F(DecisionLogicTest, Accelerate) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(110 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(150)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -106,8 +114,10 @@ TEST_F(DecisionLogicTest, Accelerate) { TEST_F(DecisionLogicTest, FastAccelerate) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(400 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(500)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -120,8 +130,10 @@ TEST_F(DecisionLogicTest, FastAccelerate) { TEST_F(DecisionLogicTest, PreemptiveExpand) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(50 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(50)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -131,20 +143,6 @@ TEST_F(DecisionLogicTest, PreemptiveExpand) { EXPECT_FALSE(reset_decoder); } -TEST_F(DecisionLogicTest, DecelerationTargetLevelOffset) { - EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) - .WillRepeatedly(Return(500)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(400 * kSamplesPerMs)); - - bool reset_decoder = false; - tick_timer_.Increment(kMinTimescaleInterval + 1); - EXPECT_EQ(decision_logic_->GetDecision( - CreateNetEqStatus(NetEq::Mode::kNormal, 400), &reset_decoder), - NetEq::Operation::kPreemptiveExpand); - EXPECT_FALSE(reset_decoder); -} - TEST_F(DecisionLogicTest, PostponeDecodeAfterExpand) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(500)); @@ -170,7 +168,7 @@ TEST_F(DecisionLogicTest, TimeStrechComfortNoise) { { bool reset_decoder = false; // Below target window. - auto status = CreateNetEqStatus(NetEq::Mode::kCodecInternalCng, 400); + auto status = CreateNetEqStatus(NetEq::Mode::kCodecInternalCng, 200); status.generated_noise_samples = 400 * kSamplesPerMs; status.next_packet->timestamp = status.target_timestamp + 400 * kSamplesPerMs; @@ -189,18 +187,6 @@ TEST_F(DecisionLogicTest, TimeStrechComfortNoise) { EXPECT_EQ(decision_logic_->GetDecision(status, &reset_decoder), NetEq::Operation::kNormal); EXPECT_FALSE(reset_decoder); - - // The buffer level filter should be adjusted with the number of samples - // that was skipped. - int timestamp_leap = status.next_packet->timestamp - - status.target_timestamp - - status.generated_noise_samples; - EXPECT_CALL(*mock_buffer_level_filter_, - Update(400 * kSamplesPerMs, timestamp_leap)); - EXPECT_EQ(decision_logic_->GetDecision( - CreateNetEqStatus(NetEq::Mode::kNormal, 400), &reset_decoder), - NetEq::Operation::kNormal); - EXPECT_FALSE(reset_decoder); } } diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h b/third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h new file mode 100644 index 0000000000..1b2080cd94 --- /dev/null +++ b/third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_arrival_history.h @@ -0,0 +1,32 @@ +/* + * Copyright 2023 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_PACKET_ARRIVAL_HISTORY_H_ +#define MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_PACKET_ARRIVAL_HISTORY_H_ + +#include "modules/audio_coding/neteq/packet_arrival_history.h" +#include "test/gmock.h" + +namespace webrtc { + +class MockPacketArrivalHistory : public PacketArrivalHistory { + public: + MockPacketArrivalHistory() : PacketArrivalHistory(0) {} + + MOCK_METHOD(int, + GetDelayMs, + (uint32_t rtp_timestamp, int64_t time_ms), + (const override)); + MOCK_METHOD(int, GetMaxDelayMs, (), (const override)); +}; + +} // namespace webrtc + +#endif // MODULES_AUDIO_CODING_NETEQ_MOCK_MOCK_PACKET_ARRIVAL_HISTORY_H_ diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h b/third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h index 48357ea466..fa44f606fc 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h +++ b/third_party/libwebrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h @@ -18,39 +18,15 @@ namespace webrtc { class MockPacketBuffer : public PacketBuffer { public: - MockPacketBuffer(size_t max_number_of_packets, const TickTimer* tick_timer) - : PacketBuffer(max_number_of_packets, tick_timer) {} + MockPacketBuffer(size_t max_number_of_packets, + const TickTimer* tick_timer, + StatisticsCalculator* stats) + : PacketBuffer(max_number_of_packets, tick_timer, stats) {} ~MockPacketBuffer() override { Die(); } MOCK_METHOD(void, Die, ()); - MOCK_METHOD(void, Flush, (StatisticsCalculator * stats), (override)); - MOCK_METHOD(void, - PartialFlush, - (int target_level_ms, - size_t sample_rate, - size_t last_decoded_length, - StatisticsCalculator* stats), - (override)); + MOCK_METHOD(void, Flush, (), (override)); MOCK_METHOD(bool, Empty, (), (const, override)); - MOCK_METHOD(int, - InsertPacket, - (Packet && packet, - StatisticsCalculator* stats, - size_t last_decoded_length, - size_t sample_rate, - int target_level_ms, - const DecoderDatabase& decoder_database), - (override)); - MOCK_METHOD(int, - InsertPacketList, - (PacketList * packet_list, - const DecoderDatabase& decoder_database, - absl::optional* current_rtp_payload_type, - absl::optional* current_cng_rtp_payload_type, - StatisticsCalculator* stats, - size_t last_decoded_length, - size_t sample_rate, - int target_level_ms), - (override)); + MOCK_METHOD(int, InsertPacket, (Packet && packet), (override)); MOCK_METHOD(int, NextTimestamp, (uint32_t * next_timestamp), @@ -61,19 +37,14 @@ class MockPacketBuffer : public PacketBuffer { (const, override)); MOCK_METHOD(const Packet*, PeekNextPacket, (), (const, override)); MOCK_METHOD(absl::optional, GetNextPacket, (), (override)); - MOCK_METHOD(int, - DiscardNextPacket, - (StatisticsCalculator * stats), - (override)); + MOCK_METHOD(int, DiscardNextPacket, (), (override)); MOCK_METHOD(void, DiscardOldPackets, - (uint32_t timestamp_limit, - uint32_t horizon_samples, - StatisticsCalculator* stats), + (uint32_t timestamp_limit, uint32_t horizon_samples), (override)); MOCK_METHOD(void, DiscardAllOldPackets, - (uint32_t timestamp_limit, StatisticsCalculator* stats), + (uint32_t timestamp_limit), (override)); MOCK_METHOD(size_t, NumPacketsInBuffer, (), (const, override)); }; diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.cc b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.cc index 52e8cbad3a..e5c8bf6c08 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -70,6 +70,62 @@ std::unique_ptr CreateNetEqController( return controller_factory.CreateNetEqController(config); } +void SetAudioFrameActivityAndType(bool vad_enabled, + NetEqImpl::OutputType type, + AudioFrame::VADActivity last_vad_activity, + AudioFrame* audio_frame) { + switch (type) { + case NetEqImpl::OutputType::kNormalSpeech: { + audio_frame->speech_type_ = AudioFrame::kNormalSpeech; + audio_frame->vad_activity_ = AudioFrame::kVadActive; + break; + } + case NetEqImpl::OutputType::kVadPassive: { + // This should only be reached if the VAD is enabled. + RTC_DCHECK(vad_enabled); + audio_frame->speech_type_ = AudioFrame::kNormalSpeech; + audio_frame->vad_activity_ = AudioFrame::kVadPassive; + break; + } + case NetEqImpl::OutputType::kCNG: { + audio_frame->speech_type_ = AudioFrame::kCNG; + audio_frame->vad_activity_ = AudioFrame::kVadPassive; + break; + } + case NetEqImpl::OutputType::kPLC: { + audio_frame->speech_type_ = AudioFrame::kPLC; + audio_frame->vad_activity_ = last_vad_activity; + break; + } + case NetEqImpl::OutputType::kPLCCNG: { + audio_frame->speech_type_ = AudioFrame::kPLCCNG; + audio_frame->vad_activity_ = AudioFrame::kVadPassive; + break; + } + case NetEqImpl::OutputType::kCodecPLC: { + audio_frame->speech_type_ = AudioFrame::kCodecPLC; + audio_frame->vad_activity_ = last_vad_activity; + break; + } + default: + RTC_DCHECK_NOTREACHED(); + } + if (!vad_enabled) { + // Always set kVadUnknown when receive VAD is inactive. + audio_frame->vad_activity_ = AudioFrame::kVadUnknown; + } +} + +// Returns true if both payload types are known to the decoder database, and +// have the same sample rate. +bool EqualSampleRates(uint8_t pt1, + uint8_t pt2, + const DecoderDatabase& decoder_database) { + auto* di1 = decoder_database.GetDecoderInfo(pt1); + auto* di2 = decoder_database.GetDecoderInfo(pt2); + return di1 && di2 && di1->SampleRateHz() == di2->SampleRateHz(); +} + } // namespace NetEqImpl::Dependencies::Dependencies( @@ -84,8 +140,9 @@ NetEqImpl::Dependencies::Dependencies( new DecoderDatabase(decoder_factory, config.codec_pair_id)), dtmf_buffer(new DtmfBuffer(config.sample_rate_hz)), dtmf_tone_generator(new DtmfToneGenerator), - packet_buffer( - new PacketBuffer(config.max_packets_in_buffer, tick_timer.get())), + packet_buffer(new PacketBuffer(config.max_packets_in_buffer, + tick_timer.get(), + stats.get())), neteq_controller( CreateNetEqController(controller_factory, config.min_delay_ms, @@ -182,54 +239,6 @@ void NetEqImpl::InsertEmptyPacket(const RTPHeader& rtp_header) { controller_->RegisterEmptyPacket(); } -namespace { -void SetAudioFrameActivityAndType(bool vad_enabled, - NetEqImpl::OutputType type, - AudioFrame::VADActivity last_vad_activity, - AudioFrame* audio_frame) { - switch (type) { - case NetEqImpl::OutputType::kNormalSpeech: { - audio_frame->speech_type_ = AudioFrame::kNormalSpeech; - audio_frame->vad_activity_ = AudioFrame::kVadActive; - break; - } - case NetEqImpl::OutputType::kVadPassive: { - // This should only be reached if the VAD is enabled. - RTC_DCHECK(vad_enabled); - audio_frame->speech_type_ = AudioFrame::kNormalSpeech; - audio_frame->vad_activity_ = AudioFrame::kVadPassive; - break; - } - case NetEqImpl::OutputType::kCNG: { - audio_frame->speech_type_ = AudioFrame::kCNG; - audio_frame->vad_activity_ = AudioFrame::kVadPassive; - break; - } - case NetEqImpl::OutputType::kPLC: { - audio_frame->speech_type_ = AudioFrame::kPLC; - audio_frame->vad_activity_ = last_vad_activity; - break; - } - case NetEqImpl::OutputType::kPLCCNG: { - audio_frame->speech_type_ = AudioFrame::kPLCCNG; - audio_frame->vad_activity_ = AudioFrame::kVadPassive; - break; - } - case NetEqImpl::OutputType::kCodecPLC: { - audio_frame->speech_type_ = AudioFrame::kCodecPLC; - audio_frame->vad_activity_ = last_vad_activity; - break; - } - default: - RTC_DCHECK_NOTREACHED(); - } - if (!vad_enabled) { - // Always set kVadUnknown when receive VAD is inactive. - audio_frame->vad_activity_ = AudioFrame::kVadUnknown; - } -} -} // namespace - int NetEqImpl::GetAudio(AudioFrame* audio_frame, bool* muted, int* current_sample_rate_hz, @@ -265,7 +274,7 @@ void NetEqImpl::SetCodecs(const std::map& codecs) { const std::vector changed_payload_types = decoder_database_->SetCodecs(codecs); for (const int pt : changed_payload_types) { - packet_buffer_->DiscardPacketsWithPayloadType(pt, stats_.get()); + packet_buffer_->DiscardPacketsWithPayloadType(pt); } } @@ -283,8 +292,7 @@ int NetEqImpl::RemovePayloadType(uint8_t rtp_payload_type) { MutexLock lock(&mutex_); int ret = decoder_database_->Remove(rtp_payload_type); if (ret == DecoderDatabase::kOK || ret == DecoderDatabase::kDecoderNotFound) { - packet_buffer_->DiscardPacketsWithPayloadType(rtp_payload_type, - stats_.get()); + packet_buffer_->DiscardPacketsWithPayloadType(rtp_payload_type); return kOK; } return kFail; @@ -441,7 +449,7 @@ absl::optional NetEqImpl::GetDecoderFormat( void NetEqImpl::FlushBuffers() { MutexLock lock(&mutex_); RTC_LOG(LS_VERBOSE) << "FlushBuffers"; - packet_buffer_->Flush(stats_.get()); + packet_buffer_->Flush(); RTC_DCHECK(sync_buffer_.get()); RTC_DCHECK(expand_.get()); sync_buffer_->Flush(); @@ -542,7 +550,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, // the packet has been successfully inserted into the packet buffer. // Flush the packet buffer and DTMF buffer. - packet_buffer_->Flush(stats_.get()); + packet_buffer_->Flush(); dtmf_buffer_->Flush(); // Update audio buffer timestamp. @@ -681,26 +689,25 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, number_of_primary_packets); } - // Insert packets in buffer. - const int target_level_ms = controller_->TargetLevelMs(); - const int ret = packet_buffer_->InsertPacketList( - &parsed_packet_list, *decoder_database_, ¤t_rtp_payload_type_, - ¤t_cng_rtp_payload_type_, stats_.get(), decoder_frame_length_, - last_output_sample_rate_hz_, target_level_ms); bool buffer_flush_occured = false; - if (ret == PacketBuffer::kFlushed) { + for (Packet& packet : parsed_packet_list) { + if (MaybeChangePayloadType(packet.payload_type)) { + packet_buffer_->Flush(); + buffer_flush_occured = true; + } + int return_val = packet_buffer_->InsertPacket(std::move(packet)); + if (return_val == PacketBuffer::kFlushed) { + buffer_flush_occured = true; + } else if (return_val != PacketBuffer::kOK) { + // An error occurred. + return kOtherError; + } + } + + if (buffer_flush_occured) { // Reset DSP timestamp etc. if packet buffer flushed. new_codec_ = true; update_sample_rate_and_channels = true; - buffer_flush_occured = true; - } else if (ret == PacketBuffer::kPartialFlush) { - // Forward sync buffer timestamp - timestamp_ = packet_buffer_->PeekNextPacket()->timestamp; - sync_buffer_->IncreaseEndTimestamp(timestamp_ - - sync_buffer_->end_timestamp()); - buffer_flush_occured = true; - } else if (ret != PacketBuffer::kOK) { - return kOtherError; } if (first_packet_) { @@ -767,6 +774,31 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, return 0; } +bool NetEqImpl::MaybeChangePayloadType(uint8_t payload_type) { + bool changed = false; + if (decoder_database_->IsComfortNoise(payload_type)) { + if (current_cng_rtp_payload_type_ && + *current_cng_rtp_payload_type_ != payload_type) { + // New CNG payload type implies new codec type. + current_rtp_payload_type_ = absl::nullopt; + changed = true; + } + current_cng_rtp_payload_type_ = payload_type; + } else if (!decoder_database_->IsDtmf(payload_type)) { + // This must be speech. + if ((current_rtp_payload_type_ && + *current_rtp_payload_type_ != payload_type) || + (current_cng_rtp_payload_type_ && + !EqualSampleRates(payload_type, *current_cng_rtp_payload_type_, + *decoder_database_))) { + current_cng_rtp_payload_type_ = absl::nullopt; + changed = true; + } + current_rtp_payload_type_ = payload_type; + } + return changed; +} + int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame, bool* muted, absl::optional action_override) { @@ -1037,8 +1069,7 @@ int NetEqImpl::GetDecision(Operation* operation, uint32_t end_timestamp = sync_buffer_->end_timestamp(); if (!new_codec_) { const uint32_t five_seconds_samples = 5 * fs_hz_; - packet_buffer_->DiscardOldPackets(end_timestamp, five_seconds_samples, - stats_.get()); + packet_buffer_->DiscardOldPackets(end_timestamp, five_seconds_samples); } const Packet* packet = packet_buffer_->PeekNextPacket(); @@ -1058,14 +1089,12 @@ int NetEqImpl::GetDecision(Operation* operation, (end_timestamp >= packet->timestamp || end_timestamp + generated_noise_samples > packet->timestamp)) { // Don't use this packet, discard it. - if (packet_buffer_->DiscardNextPacket(stats_.get()) != - PacketBuffer::kOK) { + if (packet_buffer_->DiscardNextPacket() != PacketBuffer::kOK) { RTC_DCHECK_NOTREACHED(); // Must be ok by design. } // Check buffer again. if (!new_codec_) { - packet_buffer_->DiscardOldPackets(end_timestamp, 5 * fs_hz_, - stats_.get()); + packet_buffer_->DiscardOldPackets(end_timestamp, 5 * fs_hz_); } packet = packet_buffer_->PeekNextPacket(); } @@ -2024,7 +2053,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples, // we could end up in the situation where we never decode anything, since // all incoming packets are considered too old but the buffer will also // never be flooded and flushed. - packet_buffer_->DiscardAllOldPackets(timestamp_, stats_.get()); + packet_buffer_->DiscardAllOldPackets(timestamp_); } return rtc::dchecked_cast(extracted_samples); diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.h b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.h index f27738bcbf..f8f2b06410 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.h +++ b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl.h @@ -27,6 +27,7 @@ #include "modules/audio_coding/neteq/audio_multi_vector.h" #include "modules/audio_coding/neteq/expand_uma_logger.h" #include "modules/audio_coding/neteq/packet.h" +#include "modules/audio_coding/neteq/packet_buffer.h" #include "modules/audio_coding/neteq/random_vector.h" #include "modules/audio_coding/neteq/statistics_calculator.h" #include "rtc_base/synchronization/mutex.h" @@ -46,7 +47,6 @@ class Expand; class Merge; class NackTracker; class Normal; -class PacketBuffer; class RedPayloadSplitter; class PostDecodeVad; class PreemptiveExpand; @@ -215,6 +215,12 @@ class NetEqImpl : public webrtc::NetEq { rtc::ArrayView payload) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + // Returns true if the payload type changed (this should be followed by + // resetting various state). Returns false if the current payload type is + // unknown or equal to `payload_type`. + bool MaybeChangePayloadType(uint8_t payload_type) + RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + // Delivers 10 ms of audio data. The data is written to `audio_frame`. // Returns 0 on success, otherwise an error code. int GetAudioInternal(AudioFrame* audio_frame, diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc index e61cd52502..8309dafb58 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -108,8 +108,8 @@ class NetEqImplTest : public ::testing::Test { dtmf_tone_generator_ = deps.dtmf_tone_generator.get(); if (use_mock_packet_buffer_) { - std::unique_ptr mock( - new MockPacketBuffer(config_.max_packets_in_buffer, tick_timer_)); + std::unique_ptr mock(new MockPacketBuffer( + config_.max_packets_in_buffer, tick_timer_, deps.stats.get())); mock_packet_buffer_ = mock.get(); deps.packet_buffer = std::move(mock); } @@ -120,7 +120,6 @@ class NetEqImplTest : public ::testing::Test { mock_neteq_controller_ = mock.get(); deps.neteq_controller = std::move(mock); } else { - deps.stats = std::make_unique(); NetEqController::Config controller_config; controller_config.tick_timer = tick_timer_; controller_config.base_min_delay_ms = config_.min_delay_ms; @@ -329,15 +328,10 @@ TEST_F(NetEqImplTest, InsertPacket) { // Expectations for packet buffer. EXPECT_CALL(*mock_packet_buffer_, Empty()) .WillOnce(Return(false)); // Called once after first packet is inserted. - EXPECT_CALL(*mock_packet_buffer_, Flush(_)).Times(1); - EXPECT_CALL(*mock_packet_buffer_, InsertPacketList(_, _, _, _, _, _, _, _)) + EXPECT_CALL(*mock_packet_buffer_, Flush()).Times(1); + EXPECT_CALL(*mock_packet_buffer_, InsertPacket(_)) .Times(2) - .WillRepeatedly(DoAll(SetArgPointee<2>(kPayloadType), - WithArg<0>(Invoke(DeletePacketsAndReturnOk)))); - // SetArgPointee<2>(kPayloadType) means that the third argument (zero-based - // index) is a pointer, and the variable pointed to is set to kPayloadType. - // Also invoke the function DeletePacketsAndReturnOk to properly delete all - // packets in the list (to avoid memory leaks in the test). + .WillRepeatedly(Return(PacketBuffer::kOK)); EXPECT_CALL(*mock_packet_buffer_, PeekNextPacket()) .Times(1) .WillOnce(Return(&fake_packet)); @@ -1246,12 +1240,15 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) { EXPECT_EQ(kChannels, output.num_channels_); EXPECT_THAT(output.packet_infos_, IsEmpty()); - // Second call to GetAudio will decode the packet that is ok. No errors are - // expected. - EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); - EXPECT_EQ(kExpectedOutputSize, output.samples_per_channel_ * kChannels); - EXPECT_EQ(kChannels, output.num_channels_); - EXPECT_THAT(output.packet_infos_, SizeIs(1)); + // Call GetAudio until the next packet is decoded. + int calls = 0; + int kTimeout = 10; + while (output.packet_infos_.empty() && calls < kTimeout) { + EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); + EXPECT_EQ(kExpectedOutputSize, output.samples_per_channel_ * kChannels); + EXPECT_EQ(kChannels, output.num_channels_); + } + EXPECT_LT(calls, kTimeout); // Die isn't called through NiceMock (since it's called by the // MockAudioDecoder constructor), so it needs to be mocked explicitly. @@ -1640,6 +1637,74 @@ TEST_F(NetEqImplTest, NoCrashWith1000Channels) { } } +// The test first inserts a packet with narrow-band CNG, then a packet with +// wide-band speech. The expected behavior is to detect a change in sample rate, +// even though no speech packet has been inserted before, and flush out the CNG +// packet. +TEST_F(NetEqImplTest, CngFirstThenSpeechWithNewSampleRate) { + UseNoMocks(); + CreateInstance(); + constexpr int kCnPayloadType = 7; + neteq_->RegisterPayloadType(kCnPayloadType, SdpAudioFormat("cn", 8000, 1)); + constexpr int kSpeechPayloadType = 8; + neteq_->RegisterPayloadType(kSpeechPayloadType, + SdpAudioFormat("l16", 16000, 1)); + + RTPHeader header; + header.payloadType = kCnPayloadType; + uint8_t payload[320] = {0}; + + EXPECT_EQ(neteq_->InsertPacket(header, payload), NetEq::kOK); + EXPECT_EQ(neteq_->GetLifetimeStatistics().packets_discarded, 0u); + + header.payloadType = kSpeechPayloadType; + header.timestamp += 160; + EXPECT_EQ(neteq_->InsertPacket(header, payload), NetEq::kOK); + // CN packet should be discarded, since it does not match the + // new speech sample rate. + EXPECT_EQ(neteq_->GetLifetimeStatistics().packets_discarded, 1u); + + // Next decoded packet should be speech. + AudioFrame audio_frame; + bool muted; + EXPECT_EQ(neteq_->GetAudio(&audio_frame, &muted), NetEq::kOK); + EXPECT_EQ(audio_frame.sample_rate_hz(), 16000); + EXPECT_EQ(audio_frame.speech_type_, AudioFrame::SpeechType::kNormalSpeech); +} + +TEST_F(NetEqImplTest, InsertPacketChangePayloadType) { + UseNoMocks(); + CreateInstance(); + constexpr int kPcmuPayloadType = 7; + neteq_->RegisterPayloadType(kPcmuPayloadType, + SdpAudioFormat("pcmu", 8000, 1)); + constexpr int kPcmaPayloadType = 8; + neteq_->RegisterPayloadType(kPcmaPayloadType, + SdpAudioFormat("pcma", 8000, 1)); + + RTPHeader header; + header.payloadType = kPcmuPayloadType; + header.timestamp = 1234; + uint8_t payload[160] = {0}; + + EXPECT_EQ(neteq_->InsertPacket(header, payload), NetEq::kOK); + EXPECT_EQ(neteq_->GetLifetimeStatistics().packets_discarded, 0u); + + header.payloadType = kPcmaPayloadType; + header.timestamp += 80; + EXPECT_EQ(neteq_->InsertPacket(header, payload), NetEq::kOK); + // The previous packet should be discarded since the codec changed. + EXPECT_EQ(neteq_->GetLifetimeStatistics().packets_discarded, 1u); + + // Next decoded packet should be speech. + AudioFrame audio_frame; + bool muted; + EXPECT_EQ(neteq_->GetAudio(&audio_frame, &muted), NetEq::kOK); + EXPECT_EQ(audio_frame.sample_rate_hz(), 8000); + EXPECT_EQ(audio_frame.speech_type_, AudioFrame::SpeechType::kNormalSpeech); + // TODO(jakobi): check active decoder. +} + class Decoder120ms : public AudioDecoder { public: Decoder120ms(int sample_rate_hz, SpeechType speech_type) diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc index a669ad727e..da516982c7 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc @@ -273,15 +273,16 @@ class NetEqNetworkStatsTest { // Next we introduce packet losses. SetPacketLossRate(0.1); - expects.stats_ref.expand_rate = expects.stats_ref.speech_expand_rate = 898; + expects.expand_rate = expects.speech_expand_rate = kLargerThan; RunTest(50, expects); // Next we enable FEC. decoder_->set_fec_enabled(true); // If FEC fills in the lost packets, no packet loss will be counted. + expects.expand_rate = expects.speech_expand_rate = kEqual; expects.stats_ref.expand_rate = expects.stats_ref.speech_expand_rate = 0; - expects.stats_ref.secondary_decoded_rate = 2006; - expects.stats_ref.secondary_discarded_rate = 14336; + expects.secondary_decoded_rate = kLargerThan; + expects.secondary_discarded_rate = kLargerThan; RunTest(50, expects); } diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_unittest.cc index 77bd5b5035..aec7e580ec 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_unittest.cc @@ -31,7 +31,6 @@ #include "modules/include/module_common_types_public.h" #include "modules/rtp_rtcp/include/rtcp_statistics.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/message_digest.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/strings/string_builder.h" @@ -77,11 +76,11 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp"); const std::string output_checksum = - "fec6827bb9ee0b21770bbbb4a3a6f8823bf537dc|" - "3610cc7be4b3407b9c273b1299ab7f8f47cca96b"; + "2efdbea92c3fb2383c59f89d881efec9f94001d0|" + "a6831b946b59913852ae3e53f99fa8f209bb23cd"; const std::string network_stats_checksum = - "3d043e47e5f4bb81d37e7bce8c44bf802965c853|" + "dfaf4399fd60293405290476ccf1c05c807c71a0|" "076662525572dba753b11578330bd491923f7f5e"; DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, @@ -99,11 +98,11 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusDtxBitExactness) { webrtc::test::ResourcePath("audio_coding/neteq_opus_dtx", "rtp"); const std::string output_checksum = - "b3c4899eab5378ef5e54f2302948872149f6ad5e|" - "589e975ec31ea13f302457fea1425be9380ffb96"; + "7eddce841cbfa500964c91cdae78b01b9f448948|" + "5d13affec87bf4cc8c7667f0cd0d25e1ad09c7c3"; const std::string network_stats_checksum = - "dc8447b9fee1a21fd5d1f4045d62b982a3fb0215"; + "92b0fdcbf8bb9354d40140b7312f2fb76a078555"; DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, absl::GetFlag(FLAGS_gen_ref)); @@ -165,7 +164,7 @@ TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDrift) { const double kDriftFactor = 1000.0 / (1000.0 + 25.0); const double kNetworkFreezeTimeMs = 0.0; const bool kGetAudioDuringFreezeRecovery = false; - const int kDelayToleranceMs = 20; + const int kDelayToleranceMs = 60; const int kMaxTimeToSpeechMs = 100; LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, kGetAudioDuringFreezeRecovery, kDelayToleranceMs, @@ -495,7 +494,7 @@ TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { timestamp += kCngPeriodSamples; uint32_t first_speech_timestamp = timestamp; // Insert speech again. - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < 4; ++i) { PopulateRtpInfo(seq_no, timestamp, &rtp_info); ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload)); ++seq_no; @@ -700,8 +699,7 @@ TEST_F(NetEqDecodingTestWithMutedState, MutedStateOldPacket) { for (int i = 0; i < 5; ++i) { InsertPacket(kSamples * (i - 1000)); } - EXPECT_FALSE(GetAudioReturnMuted()); - EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); + GetAudioUntilNormal(); } // Verifies that NetEq doesn't enter muted state when CNG mode is active and the diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/packet_arrival_history.h b/third_party/libwebrtc/modules/audio_coding/neteq/packet_arrival_history.h index cad362b469..722caf5688 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/packet_arrival_history.h +++ b/third_party/libwebrtc/modules/audio_coding/neteq/packet_arrival_history.h @@ -26,6 +26,7 @@ namespace webrtc { class PacketArrivalHistory { public: explicit PacketArrivalHistory(int window_size_ms); + virtual ~PacketArrivalHistory() = default; // Insert packet with `rtp_timestamp` and `arrival_time_ms` into the history. void Insert(uint32_t rtp_timestamp, int64_t arrival_time_ms); @@ -34,10 +35,10 @@ class PacketArrivalHistory { // `(time_ms - p.arrival_time_ms) - (rtp_timestamp - p.rtp_timestamp)` // where `p` is chosen as the packet arrival in the history that maximizes the // delay. - int GetDelayMs(uint32_t rtp_timestamp, int64_t time_ms) const; + virtual int GetDelayMs(uint32_t rtp_timestamp, int64_t time_ms) const; // Get the maximum packet arrival delay observed in the history. - int GetMaxDelayMs() const; + virtual int GetMaxDelayMs() const; bool IsNewestRtpTimestamp(uint32_t rtp_timestamp) const; diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.cc b/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.cc index 9bfa908ab9..47c391a18f 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.cc @@ -44,53 +44,14 @@ class NewTimestampIsLarger { const Packet& new_packet_; }; -// Returns true if both payload types are known to the decoder database, and -// have the same sample rate. -bool EqualSampleRates(uint8_t pt1, - uint8_t pt2, - const DecoderDatabase& decoder_database) { - auto* di1 = decoder_database.GetDecoderInfo(pt1); - auto* di2 = decoder_database.GetDecoderInfo(pt2); - return di1 && di2 && di1->SampleRateHz() == di2->SampleRateHz(); -} - -void LogPacketDiscarded(int codec_level, StatisticsCalculator* stats) { - RTC_CHECK(stats); - if (codec_level > 0) { - stats->SecondaryPacketsDiscarded(1); - } else { - stats->PacketsDiscarded(1); - } -} - -absl::optional GetSmartflushingConfig() { - absl::optional result; - std::string field_trial_string = - field_trial::FindFullName("WebRTC-Audio-NetEqSmartFlushing"); - result = SmartFlushingConfig(); - bool enabled = false; - auto parser = StructParametersParser::Create( - "enabled", &enabled, "target_level_threshold_ms", - &result->target_level_threshold_ms, "target_level_multiplier", - &result->target_level_multiplier); - parser->Parse(field_trial_string); - if (!enabled) { - return absl::nullopt; - } - RTC_LOG(LS_INFO) << "Using smart flushing, target_level_threshold_ms: " - << result->target_level_threshold_ms - << ", target_level_multiplier: " - << result->target_level_multiplier; - return result; -} - } // namespace PacketBuffer::PacketBuffer(size_t max_number_of_packets, - const TickTimer* tick_timer) - : smart_flushing_config_(GetSmartflushingConfig()), - max_number_of_packets_(max_number_of_packets), - tick_timer_(tick_timer) {} + const TickTimer* tick_timer, + StatisticsCalculator* stats) + : max_number_of_packets_(max_number_of_packets), + tick_timer_(tick_timer), + stats_(stats) {} // Destructor. All packets in the buffer will be destroyed. PacketBuffer::~PacketBuffer() { @@ -98,45 +59,19 @@ PacketBuffer::~PacketBuffer() { } // Flush the buffer. All packets in the buffer will be destroyed. -void PacketBuffer::Flush(StatisticsCalculator* stats) { +void PacketBuffer::Flush() { for (auto& p : buffer_) { - LogPacketDiscarded(p.priority.codec_level, stats); + LogPacketDiscarded(p.priority.codec_level); } buffer_.clear(); - stats->FlushedPacketBuffer(); -} - -void PacketBuffer::PartialFlush(int target_level_ms, - size_t sample_rate, - size_t last_decoded_length, - StatisticsCalculator* stats) { - // Make sure that at least half the packet buffer capacity will be available - // after the flush. This is done to avoid getting stuck if the target level is - // very high. - int target_level_samples = - std::min(target_level_ms * sample_rate / 1000, - max_number_of_packets_ * last_decoded_length / 2); - // We should avoid flushing to very low levels. - target_level_samples = std::max( - target_level_samples, smart_flushing_config_->target_level_threshold_ms); - while (GetSpanSamples(last_decoded_length, sample_rate, false) > - static_cast(target_level_samples) || - buffer_.size() > max_number_of_packets_ / 2) { - LogPacketDiscarded(PeekNextPacket()->priority.codec_level, stats); - buffer_.pop_front(); - } + stats_->FlushedPacketBuffer(); } bool PacketBuffer::Empty() const { return buffer_.empty(); } -int PacketBuffer::InsertPacket(Packet&& packet, - StatisticsCalculator* stats, - size_t last_decoded_length, - size_t sample_rate, - int target_level_ms, - const DecoderDatabase& decoder_database) { +int PacketBuffer::InsertPacket(Packet&& packet) { if (packet.empty()) { RTC_LOG(LS_WARNING) << "InsertPacket invalid packet"; return kInvalidPacket; @@ -149,32 +84,11 @@ int PacketBuffer::InsertPacket(Packet&& packet, packet.waiting_time = tick_timer_->GetNewStopwatch(); - // Perform a smart flush if the buffer size exceeds a multiple of the target - // level. - const size_t span_threshold = - smart_flushing_config_ - ? smart_flushing_config_->target_level_multiplier * - std::max(smart_flushing_config_->target_level_threshold_ms, - target_level_ms) * - sample_rate / 1000 - : 0; - const bool smart_flush = - smart_flushing_config_.has_value() && - GetSpanSamples(last_decoded_length, sample_rate, false) >= span_threshold; - if (buffer_.size() >= max_number_of_packets_ || smart_flush) { - size_t buffer_size_before_flush = buffer_.size(); - if (smart_flushing_config_.has_value()) { - // Flush down to the target level. - PartialFlush(target_level_ms, sample_rate, last_decoded_length, stats); - return_val = kPartialFlush; - } else { - // Buffer is full. - Flush(stats); - return_val = kFlushed; - } - RTC_LOG(LS_WARNING) << "Packet buffer flushed, " - << (buffer_size_before_flush - buffer_.size()) - << " packets discarded."; + if (buffer_.size() >= max_number_of_packets_) { + // Buffer is full. + Flush(); + return_val = kFlushed; + RTC_LOG(LS_WARNING) << "Packet buffer flushed."; } // Get an iterator pointing to the place in the buffer where the new packet @@ -187,7 +101,7 @@ int PacketBuffer::InsertPacket(Packet&& packet, // timestamp as `rit`, which has a higher priority, do not insert the new // packet to list. if (rit != buffer_.rend() && packet.timestamp == rit->timestamp) { - LogPacketDiscarded(packet.priority.codec_level, stats); + LogPacketDiscarded(packet.priority.codec_level); return return_val; } @@ -196,7 +110,7 @@ int PacketBuffer::InsertPacket(Packet&& packet, // packet. PacketList::iterator it = rit.base(); if (it != buffer_.end() && packet.timestamp == it->timestamp) { - LogPacketDiscarded(it->priority.codec_level, stats); + LogPacketDiscarded(it->priority.codec_level); it = buffer_.erase(it); } buffer_.insert(it, std::move(packet)); // Insert the packet at that position. @@ -204,57 +118,6 @@ int PacketBuffer::InsertPacket(Packet&& packet, return return_val; } -int PacketBuffer::InsertPacketList( - PacketList* packet_list, - const DecoderDatabase& decoder_database, - absl::optional* current_rtp_payload_type, - absl::optional* current_cng_rtp_payload_type, - StatisticsCalculator* stats, - size_t last_decoded_length, - size_t sample_rate, - int target_level_ms) { - RTC_DCHECK(stats); - bool flushed = false; - for (auto& packet : *packet_list) { - if (decoder_database.IsComfortNoise(packet.payload_type)) { - if (*current_cng_rtp_payload_type && - **current_cng_rtp_payload_type != packet.payload_type) { - // New CNG payload type implies new codec type. - *current_rtp_payload_type = absl::nullopt; - Flush(stats); - flushed = true; - } - *current_cng_rtp_payload_type = packet.payload_type; - } else if (!decoder_database.IsDtmf(packet.payload_type)) { - // This must be speech. - if ((*current_rtp_payload_type && - **current_rtp_payload_type != packet.payload_type) || - (*current_cng_rtp_payload_type && - !EqualSampleRates(packet.payload_type, - **current_cng_rtp_payload_type, - decoder_database))) { - *current_cng_rtp_payload_type = absl::nullopt; - Flush(stats); - flushed = true; - } - *current_rtp_payload_type = packet.payload_type; - } - int return_val = - InsertPacket(std::move(packet), stats, last_decoded_length, sample_rate, - target_level_ms, decoder_database); - if (return_val == kFlushed) { - // The buffer flushed, but this is not an error. We can still continue. - flushed = true; - } else if (return_val != kOK) { - // An error occurred. Delete remaining packets in list and return. - packet_list->clear(); - return return_val; - } - } - packet_list->clear(); - return flushed ? kFlushed : kOK; -} - int PacketBuffer::NextTimestamp(uint32_t* next_timestamp) const { if (Empty()) { return kBufferEmpty; @@ -303,43 +166,40 @@ absl::optional PacketBuffer::GetNextPacket() { return packet; } -int PacketBuffer::DiscardNextPacket(StatisticsCalculator* stats) { +int PacketBuffer::DiscardNextPacket() { if (Empty()) { return kBufferEmpty; } // Assert that the packet sanity checks in InsertPacket method works. const Packet& packet = buffer_.front(); RTC_DCHECK(!packet.empty()); - LogPacketDiscarded(packet.priority.codec_level, stats); + LogPacketDiscarded(packet.priority.codec_level); buffer_.pop_front(); return kOK; } void PacketBuffer::DiscardOldPackets(uint32_t timestamp_limit, - uint32_t horizon_samples, - StatisticsCalculator* stats) { - buffer_.remove_if([timestamp_limit, horizon_samples, stats](const Packet& p) { + uint32_t horizon_samples) { + buffer_.remove_if([this, timestamp_limit, horizon_samples](const Packet& p) { if (timestamp_limit == p.timestamp || !IsObsoleteTimestamp(p.timestamp, timestamp_limit, horizon_samples)) { return false; } - LogPacketDiscarded(p.priority.codec_level, stats); + LogPacketDiscarded(p.priority.codec_level); return true; }); } -void PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit, - StatisticsCalculator* stats) { - DiscardOldPackets(timestamp_limit, 0, stats); +void PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit) { + DiscardOldPackets(timestamp_limit, 0); } -void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type, - StatisticsCalculator* stats) { - buffer_.remove_if([payload_type, stats](const Packet& p) { +void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type) { + buffer_.remove_if([this, payload_type](const Packet& p) { if (p.payload_type != payload_type) { return false; } - LogPacketDiscarded(p.priority.codec_level, stats); + LogPacketDiscarded(p.priority.codec_level); return true; }); } @@ -404,4 +264,12 @@ bool PacketBuffer::ContainsDtxOrCngPacket( return false; } +void PacketBuffer::LogPacketDiscarded(int codec_level) { + if (codec_level > 0) { + stats_->SecondaryPacketsDiscarded(1); + } else { + stats_->PacketsDiscarded(1); + } +} + } // namespace webrtc diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.h b/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.h index 1eef64a02c..795dd4e812 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.h +++ b/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer.h @@ -21,14 +21,6 @@ namespace webrtc { class DecoderDatabase; class StatisticsCalculator; class TickTimer; -struct SmartFlushingConfig { - // When calculating the flushing threshold, the maximum between the target - // level and this value is used. - int target_level_threshold_ms = 500; - // A smart flush is triggered when the packet buffer contains a multiple of - // the target level. - int target_level_multiplier = 3; -}; // This is the actual buffer holding the packets before decoding. class PacketBuffer { @@ -36,7 +28,6 @@ class PacketBuffer { enum BufferReturnCodes { kOK = 0, kFlushed, - kPartialFlush, kNotFound, kBufferEmpty, kInvalidPacket, @@ -45,7 +36,9 @@ class PacketBuffer { // Constructor creates a buffer which can hold a maximum of // `max_number_of_packets` packets. - PacketBuffer(size_t max_number_of_packets, const TickTimer* tick_timer); + PacketBuffer(size_t max_number_of_packets, + const TickTimer* tick_timer, + StatisticsCalculator* stats); // Deletes all packets in the buffer before destroying the buffer. virtual ~PacketBuffer(); @@ -54,13 +47,7 @@ class PacketBuffer { PacketBuffer& operator=(const PacketBuffer&) = delete; // Flushes the buffer and deletes all packets in it. - virtual void Flush(StatisticsCalculator* stats); - - // Partial flush. Flush packets but leave some packets behind. - virtual void PartialFlush(int target_level_ms, - size_t sample_rate, - size_t last_decoded_length, - StatisticsCalculator* stats); + virtual void Flush(); // Returns true for an empty buffer. virtual bool Empty() const; @@ -69,30 +56,7 @@ class PacketBuffer { // the packet object. // Returns PacketBuffer::kOK on success, PacketBuffer::kFlushed if the buffer // was flushed due to overfilling. - virtual int InsertPacket(Packet&& packet, - StatisticsCalculator* stats, - size_t last_decoded_length, - size_t sample_rate, - int target_level_ms, - const DecoderDatabase& decoder_database); - - // Inserts a list of packets into the buffer. The buffer will take over - // ownership of the packet objects. - // Returns PacketBuffer::kOK if all packets were inserted successfully. - // If the buffer was flushed due to overfilling, only a subset of the list is - // inserted, and PacketBuffer::kFlushed is returned. - // The last three parameters are included for legacy compatibility. - // TODO(hlundin): Redesign to not use current_*_payload_type and - // decoder_database. - virtual int InsertPacketList( - PacketList* packet_list, - const DecoderDatabase& decoder_database, - absl::optional* current_rtp_payload_type, - absl::optional* current_cng_rtp_payload_type, - StatisticsCalculator* stats, - size_t last_decoded_length, - size_t sample_rate, - int target_level_ms); + virtual int InsertPacket(Packet&& packet); // Gets the timestamp for the first packet in the buffer and writes it to the // output variable `next_timestamp`. @@ -119,7 +83,7 @@ class PacketBuffer { // Discards the first packet in the buffer. The packet is deleted. // Returns PacketBuffer::kBufferEmpty if the buffer is empty, // PacketBuffer::kOK otherwise. - virtual int DiscardNextPacket(StatisticsCalculator* stats); + virtual int DiscardNextPacket(); // Discards all packets that are (strictly) older than timestamp_limit, // but newer than timestamp_limit - horizon_samples. Setting horizon_samples @@ -127,16 +91,13 @@ class PacketBuffer { // is, if a packet is more than 2^31 timestamps into the future compared with // timestamp_limit (including wrap-around), it is considered old. virtual void DiscardOldPackets(uint32_t timestamp_limit, - uint32_t horizon_samples, - StatisticsCalculator* stats); + uint32_t horizon_samples); // Discards all packets that are (strictly) older than timestamp_limit. - virtual void DiscardAllOldPackets(uint32_t timestamp_limit, - StatisticsCalculator* stats); + virtual void DiscardAllOldPackets(uint32_t timestamp_limit); // Removes all packets with a specific payload type from the buffer. - virtual void DiscardPacketsWithPayloadType(uint8_t payload_type, - StatisticsCalculator* stats); + virtual void DiscardPacketsWithPayloadType(uint8_t payload_type); // Returns the number of packets in the buffer, including duplicates and // redundant packets. @@ -171,10 +132,12 @@ class PacketBuffer { } private: - absl::optional smart_flushing_config_; + void LogPacketDiscarded(int codec_level); + size_t max_number_of_packets_; PacketList buffer_; const TickTimer* tick_timer_; + StatisticsCalculator* stats_; }; } // namespace webrtc diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc index b0079645ff..8f307a9eaf 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc @@ -108,26 +108,23 @@ namespace webrtc { TEST(PacketBuffer, CreateAndDestroy) { TickTimer tick_timer; - PacketBuffer* buffer = new PacketBuffer(10, &tick_timer); // 10 packets. + StrictMock mock_stats; + PacketBuffer* buffer = + new PacketBuffer(10, &tick_timer, &mock_stats); // 10 packets. EXPECT_TRUE(buffer->Empty()); delete buffer; } TEST(PacketBuffer, InsertPacket) { TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. - PacketGenerator gen(17u, 4711u, 0, 10); StrictMock mock_stats; + PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets. + PacketGenerator gen(17u, 4711u, 0, 10); MockDecoderDatabase decoder_database; const int payload_len = 100; const Packet packet = gen.NextPacket(payload_len, nullptr); - EXPECT_EQ(0, buffer.InsertPacket(/*packet=*/packet.Clone(), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/10000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + EXPECT_EQ(0, buffer.InsertPacket(/*packet=*/packet.Clone())); uint32_t next_ts; EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); EXPECT_EQ(4711u, next_ts); @@ -144,28 +141,22 @@ TEST(PacketBuffer, InsertPacket) { // Test to flush buffer. TEST(PacketBuffer, FlushBuffer) { TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. + StrictMock mock_stats; + PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets. PacketGenerator gen(0, 0, 0, 10); const int payload_len = 10; - StrictMock mock_stats; MockDecoderDatabase decoder_database; // Insert 10 small packets; should be ok. for (int i = 0; i < 10; ++i) { - EXPECT_EQ( - PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/gen.NextPacket(payload_len, nullptr), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacket(/*packet=*/gen.NextPacket( + payload_len, nullptr))); } EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); EXPECT_FALSE(buffer.Empty()); EXPECT_CALL(mock_stats, PacketsDiscarded(1)).Times(10); - buffer.Flush(&mock_stats); + buffer.Flush(); // Buffer should delete the payloads itself. EXPECT_EQ(0u, buffer.NumPacketsInBuffer()); EXPECT_TRUE(buffer.Empty()); @@ -175,23 +166,17 @@ TEST(PacketBuffer, FlushBuffer) { // Test to fill the buffer over the limits, and verify that it flushes. TEST(PacketBuffer, OverfillBuffer) { TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. - PacketGenerator gen(0, 0, 0, 10); StrictMock mock_stats; + PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets. + PacketGenerator gen(0, 0, 0, 10); MockDecoderDatabase decoder_database; // Insert 10 small packets; should be ok. const int payload_len = 10; int i; for (i = 0; i < 10; ++i) { - EXPECT_EQ( - PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/gen.NextPacket(payload_len, nullptr), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacket(/*packet=*/gen.NextPacket( + payload_len, nullptr))); } EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); uint32_t next_ts; @@ -202,12 +187,7 @@ TEST(PacketBuffer, OverfillBuffer) { const Packet packet = gen.NextPacket(payload_len, nullptr); // Insert 11th packet; should flush the buffer and insert it after flushing. EXPECT_EQ(PacketBuffer::kFlushed, - buffer.InsertPacket(/*packet=*/packet.Clone(), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + buffer.InsertPacket(/*packet=*/packet.Clone())); EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); // Expect last inserted packet to be first in line. @@ -216,190 +196,11 @@ TEST(PacketBuffer, OverfillBuffer) { EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. } -// Test a partial buffer flush. -TEST(PacketBuffer, PartialFlush) { - // Use a field trial to configure smart flushing. - test::ScopedFieldTrials field_trials( - "WebRTC-Audio-NetEqSmartFlushing/enabled:true," - "target_level_threshold_ms:0,target_level_multiplier:2/"); - TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. - PacketGenerator gen(0, 0, 0, 10); - const int payload_len = 10; - StrictMock mock_stats; - MockDecoderDatabase decoder_database; - - // Insert 10 small packets; should be ok. - for (int i = 0; i < 10; ++i) { - EXPECT_EQ( - PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/gen.NextPacket(payload_len, nullptr), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/100, - /*decoder_database=*/decoder_database)); - } - EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); - EXPECT_FALSE(buffer.Empty()); - - EXPECT_CALL(mock_stats, PacketsDiscarded(1)).Times(7); - buffer.PartialFlush(/*target_level_ms=*/30, - /*sample_rate=*/1000, - /*last_decoded_length=*/payload_len, - /*stats=*/&mock_stats); - // There should still be some packets left in the buffer. - EXPECT_EQ(3u, buffer.NumPacketsInBuffer()); - EXPECT_FALSE(buffer.Empty()); - EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. -} - -// Test to fill the buffer over the limits, and verify that the smart flush -// functionality works as expected. -TEST(PacketBuffer, SmartFlushOverfillBuffer) { - // Use a field trial to configure smart flushing. - test::ScopedFieldTrials field_trials( - "WebRTC-Audio-NetEqSmartFlushing/enabled:true," - "target_level_threshold_ms:0,target_level_multiplier:2/"); - TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. - PacketGenerator gen(0, 0, 0, 10); - StrictMock mock_stats; - MockDecoderDatabase decoder_database; - - // Insert 10 small packets; should be ok. - const int payload_len = 10; - int i; - for (i = 0; i < 10; ++i) { - EXPECT_EQ( - PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/gen.NextPacket(payload_len, nullptr), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/100, - /*decoder_database=*/decoder_database)); - } - EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); - uint32_t next_ts; - EXPECT_EQ(PacketBuffer::kOK, buffer.NextTimestamp(&next_ts)); - EXPECT_EQ(0u, next_ts); // Expect first inserted packet to be first in line. - - const Packet packet = gen.NextPacket(payload_len, nullptr); - EXPECT_CALL(mock_stats, PacketsDiscarded(1)).Times(6); - // Insert 11th packet; should cause a partial flush and insert the packet - // after flushing. - EXPECT_EQ(PacketBuffer::kPartialFlush, - buffer.InsertPacket(/*packet=*/packet.Clone(), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/40, - /*decoder_database=*/decoder_database)); - EXPECT_EQ(5u, buffer.NumPacketsInBuffer()); - EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. -} - -// Test inserting a list of packets. -TEST(PacketBuffer, InsertPacketList) { - TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. - PacketGenerator gen(0, 0, 0, 10); - PacketList list; - const int payload_len = 10; - - // Insert 10 small packets. - for (int i = 0; i < 10; ++i) { - list.push_back(gen.NextPacket(payload_len, nullptr)); - } - - MockDecoderDatabase decoder_database; - auto factory = CreateBuiltinAudioDecoderFactory(); - const DecoderDatabase::DecoderInfo info(SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, factory.get()); - EXPECT_CALL(decoder_database, GetDecoderInfo(0)) - .WillRepeatedly(Return(&info)); - - StrictMock mock_stats; - - absl::optional current_pt; - absl::optional current_cng_pt; - EXPECT_EQ( - PacketBuffer::kOK, - buffer.InsertPacketList(/*packet_list=*/&list, - /*decoder_database=*/decoder_database, - /*current_rtp_payload_type=*/¤t_pt, - /*current_cng_rtp_payload_type=*/¤t_cng_pt, - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/30)); - EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. - EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); - EXPECT_EQ(0, current_pt); // Current payload type changed to 0. - EXPECT_EQ(absl::nullopt, current_cng_pt); // CNG payload type not changed. - - EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. -} - -// Test inserting a list of packets. Last packet is of a different payload type. -// Expecting the buffer to flush. -// TODO(hlundin): Remove this test when legacy operation is no longer needed. -TEST(PacketBuffer, InsertPacketListChangePayloadType) { - TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. - PacketGenerator gen(0, 0, 0, 10); - PacketList list; - const int payload_len = 10; - - // Insert 10 small packets. - for (int i = 0; i < 10; ++i) { - list.push_back(gen.NextPacket(payload_len, nullptr)); - } - // Insert 11th packet of another payload type (not CNG). - { - Packet packet = gen.NextPacket(payload_len, nullptr); - packet.payload_type = 1; - list.push_back(std::move(packet)); - } - - MockDecoderDatabase decoder_database; - auto factory = CreateBuiltinAudioDecoderFactory(); - const DecoderDatabase::DecoderInfo info0(SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, factory.get()); - EXPECT_CALL(decoder_database, GetDecoderInfo(0)) - .WillRepeatedly(Return(&info0)); - const DecoderDatabase::DecoderInfo info1(SdpAudioFormat("pcma", 8000, 1), - absl::nullopt, factory.get()); - EXPECT_CALL(decoder_database, GetDecoderInfo(1)) - .WillRepeatedly(Return(&info1)); - - StrictMock mock_stats; - - absl::optional current_pt; - absl::optional current_cng_pt; - EXPECT_CALL(mock_stats, PacketsDiscarded(1)).Times(10); - EXPECT_EQ( - PacketBuffer::kFlushed, - buffer.InsertPacketList(/*packet_list=*/&list, - /*decoder_database=*/decoder_database, - /*current_rtp_payload_type=*/¤t_pt, - /*current_cng_rtp_payload_type=*/¤t_cng_pt, - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/30)); - EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. - EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); // Only the last packet. - EXPECT_EQ(1, current_pt); // Current payload type changed to 1. - EXPECT_EQ(absl::nullopt, current_cng_pt); // CNG payload type not changed. - - EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. -} TEST(PacketBuffer, ExtractOrderRedundancy) { TickTimer tick_timer; - PacketBuffer buffer(100, &tick_timer); // 100 packets. + StrictMock mock_stats; + PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets. const int kPackets = 18; const int kFrameSize = 10; const int kPayloadLength = 10; @@ -423,8 +224,6 @@ TEST(PacketBuffer, ExtractOrderRedundancy) { PacketGenerator gen(0, 0, 0, kFrameSize); - StrictMock mock_stats; - // Interleaving the EXPECT_CALL sequence with expectations on the MockFunction // check ensures that exactly one call to PacketsDiscarded happens in each // DiscardNextPacket call. @@ -444,12 +243,7 @@ TEST(PacketBuffer, ExtractOrderRedundancy) { } EXPECT_CALL(check, Call(i)); EXPECT_EQ(PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/packet.Clone(), - /*stats=*/&mock_stats, - /*last_decoded_length=*/kPayloadLength, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + buffer.InsertPacket(/*packet=*/packet.Clone())); if (packet_facts[i].extract_order >= 0) { expect_order[packet_facts[i].extract_order] = std::move(packet); } @@ -468,25 +262,20 @@ TEST(PacketBuffer, ExtractOrderRedundancy) { TEST(PacketBuffer, DiscardPackets) { TickTimer tick_timer; - PacketBuffer buffer(100, &tick_timer); // 100 packets. + StrictMock mock_stats; + PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets. const uint16_t start_seq_no = 17; const uint32_t start_ts = 4711; const uint32_t ts_increment = 10; PacketGenerator gen(start_seq_no, start_ts, 0, ts_increment); PacketList list; const int payload_len = 10; - StrictMock mock_stats; MockDecoderDatabase decoder_database; constexpr int kTotalPackets = 10; // Insert 10 small packets. for (int i = 0; i < kTotalPackets; ++i) { - buffer.InsertPacket(/*packet=*/gen.NextPacket(payload_len, nullptr), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database); + buffer.InsertPacket(/*packet=*/gen.NextPacket(payload_len, nullptr)); } EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); @@ -507,7 +296,7 @@ TEST(PacketBuffer, DiscardPackets) { EXPECT_EQ(current_ts, ts); EXPECT_CALL(mock_stats, PacketsDiscarded(1)); EXPECT_CALL(check, Call(i)); - EXPECT_EQ(PacketBuffer::kOK, buffer.DiscardNextPacket(&mock_stats)); + EXPECT_EQ(PacketBuffer::kOK, buffer.DiscardNextPacket()); current_ts += ts_increment; check.Call(i); } @@ -520,7 +309,7 @@ TEST(PacketBuffer, DiscardPackets) { .Times(kRemainingPackets - kSkipPackets); EXPECT_CALL(check, Call(17)); // Arbitrary id number. buffer.DiscardOldPackets(start_ts + kTotalPackets * ts_increment, - kRemainingPackets * ts_increment, &mock_stats); + kRemainingPackets * ts_increment); check.Call(17); // Same arbitrary id number. EXPECT_EQ(kSkipPackets, buffer.NumPacketsInBuffer()); @@ -530,8 +319,7 @@ TEST(PacketBuffer, DiscardPackets) { // Discard all remaining packets. EXPECT_CALL(mock_stats, PacketsDiscarded(kSkipPackets)); - buffer.DiscardAllOldPackets(start_ts + kTotalPackets * ts_increment, - &mock_stats); + buffer.DiscardAllOldPackets(start_ts + kTotalPackets * ts_increment); EXPECT_TRUE(buffer.Empty()); EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. @@ -539,7 +327,8 @@ TEST(PacketBuffer, DiscardPackets) { TEST(PacketBuffer, Reordering) { TickTimer tick_timer; - PacketBuffer buffer(100, &tick_timer); // 100 packets. + StrictMock mock_stats; + PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets. const uint16_t start_seq_no = 17; const uint32_t start_ts = 4711; const uint32_t ts_increment = 10; @@ -559,27 +348,9 @@ TEST(PacketBuffer, Reordering) { } } - MockDecoderDatabase decoder_database; - auto factory = CreateBuiltinAudioDecoderFactory(); - const DecoderDatabase::DecoderInfo info(SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, factory.get()); - EXPECT_CALL(decoder_database, GetDecoderInfo(0)) - .WillRepeatedly(Return(&info)); - absl::optional current_pt; - absl::optional current_cng_pt; - - StrictMock mock_stats; - - EXPECT_EQ( - PacketBuffer::kOK, - buffer.InsertPacketList(/*packet_list=*/&list, - /*decoder_database=*/decoder_database, - /*current_rtp_payload_type=*/¤t_pt, - /*current_cng_rtp_payload_type=*/¤t_cng_pt, - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/30)); + for (Packet& packet : list) { + EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacket(std::move(packet))); + } EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); // Extract them and make sure that come out in the right order. @@ -591,86 +362,6 @@ TEST(PacketBuffer, Reordering) { current_ts += ts_increment; } EXPECT_TRUE(buffer.Empty()); - - EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. -} - -// The test first inserts a packet with narrow-band CNG, then a packet with -// wide-band speech. The expected behavior of the packet buffer is to detect a -// change in sample rate, even though no speech packet has been inserted before, -// and flush out the CNG packet. -TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) { - TickTimer tick_timer; - PacketBuffer buffer(10, &tick_timer); // 10 packets. - const uint8_t kCngPt = 13; - const int kPayloadLen = 10; - const uint8_t kSpeechPt = 100; - - MockDecoderDatabase decoder_database; - auto factory = CreateBuiltinAudioDecoderFactory(); - const DecoderDatabase::DecoderInfo info_cng(SdpAudioFormat("cn", 8000, 1), - absl::nullopt, factory.get()); - EXPECT_CALL(decoder_database, GetDecoderInfo(kCngPt)) - .WillRepeatedly(Return(&info_cng)); - const DecoderDatabase::DecoderInfo info_speech( - SdpAudioFormat("l16", 16000, 1), absl::nullopt, factory.get()); - EXPECT_CALL(decoder_database, GetDecoderInfo(kSpeechPt)) - .WillRepeatedly(Return(&info_speech)); - - // Insert first packet, which is narrow-band CNG. - PacketGenerator gen(0, 0, kCngPt, 10); - PacketList list; - list.push_back(gen.NextPacket(kPayloadLen, nullptr)); - absl::optional current_pt; - absl::optional current_cng_pt; - - StrictMock mock_stats; - - EXPECT_EQ( - PacketBuffer::kOK, - buffer.InsertPacketList(/*packet_list=*/&list, - /*decoder_database=*/decoder_database, - /*current_rtp_payload_type=*/¤t_pt, - /*current_cng_rtp_payload_type=*/¤t_cng_pt, - /*stats=*/&mock_stats, - /*last_decoded_length=*/kPayloadLen, - /*sample_rate=*/1000, - /*target_level_ms=*/30)); - EXPECT_TRUE(list.empty()); - EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); - ASSERT_TRUE(buffer.PeekNextPacket()); - EXPECT_EQ(kCngPt, buffer.PeekNextPacket()->payload_type); - EXPECT_EQ(current_pt, absl::nullopt); // Current payload type not set. - EXPECT_EQ(kCngPt, current_cng_pt); // CNG payload type set. - - // Insert second packet, which is wide-band speech. - { - Packet packet = gen.NextPacket(kPayloadLen, nullptr); - packet.payload_type = kSpeechPt; - list.push_back(std::move(packet)); - } - // Expect the buffer to flush out the CNG packet, since it does not match the - // new speech sample rate. - EXPECT_CALL(mock_stats, PacketsDiscarded(1)); - EXPECT_EQ( - PacketBuffer::kFlushed, - buffer.InsertPacketList(/*packet_list=*/&list, - /*decoder_database=*/decoder_database, - /*current_rtp_payload_type=*/¤t_pt, - /*current_cng_rtp_payload_type=*/¤t_cng_pt, - /*stats=*/&mock_stats, - /*last_decoded_length=*/kPayloadLen, - /*sample_rate=*/1000, - /*target_level_ms=*/30)); - EXPECT_TRUE(list.empty()); - EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); - ASSERT_TRUE(buffer.PeekNextPacket()); - EXPECT_EQ(kSpeechPt, buffer.PeekNextPacket()->payload_type); - - EXPECT_EQ(kSpeechPt, current_pt); // Current payload type set. - EXPECT_EQ(absl::nullopt, current_cng_pt); // CNG payload type reset. - - EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. } TEST(PacketBuffer, Failures) { @@ -681,80 +372,26 @@ TEST(PacketBuffer, Failures) { PacketGenerator gen(start_seq_no, start_ts, 0, ts_increment); TickTimer tick_timer; StrictMock mock_stats; - MockDecoderDatabase decoder_database; - PacketBuffer* buffer = new PacketBuffer(100, &tick_timer); // 100 packets. + PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets. { Packet packet = gen.NextPacket(payload_len, nullptr); packet.payload.Clear(); EXPECT_EQ(PacketBuffer::kInvalidPacket, - buffer->InsertPacket(/*packet=*/std::move(packet), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + buffer.InsertPacket(/*packet=*/std::move(packet))); } // Buffer should still be empty. Test all empty-checks. uint32_t temp_ts; - EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer->NextTimestamp(&temp_ts)); + EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer.NextTimestamp(&temp_ts)); EXPECT_EQ(PacketBuffer::kBufferEmpty, - buffer->NextHigherTimestamp(0, &temp_ts)); - EXPECT_EQ(NULL, buffer->PeekNextPacket()); - EXPECT_FALSE(buffer->GetNextPacket()); + buffer.NextHigherTimestamp(0, &temp_ts)); + EXPECT_EQ(NULL, buffer.PeekNextPacket()); + EXPECT_FALSE(buffer.GetNextPacket()); // Discarding packets will not invoke mock_stats.PacketDiscarded() because the // packet buffer is empty. - EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer->DiscardNextPacket(&mock_stats)); - buffer->DiscardAllOldPackets(0, &mock_stats); - - // Insert one packet to make the buffer non-empty. - EXPECT_EQ( - PacketBuffer::kOK, - buffer->InsertPacket(/*packet=*/gen.NextPacket(payload_len, nullptr), - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); - EXPECT_EQ(PacketBuffer::kInvalidPointer, buffer->NextTimestamp(NULL)); - EXPECT_EQ(PacketBuffer::kInvalidPointer, - buffer->NextHigherTimestamp(0, NULL)); - delete buffer; - - // Insert packet list of three packets, where the second packet has an invalid - // payload. Expect first packet to be inserted, and the remaining two to be - // discarded. - buffer = new PacketBuffer(100, &tick_timer); // 100 packets. - PacketList list; - list.push_back(gen.NextPacket(payload_len, nullptr)); // Valid packet. - { - Packet packet = gen.NextPacket(payload_len, nullptr); - packet.payload.Clear(); // Invalid. - list.push_back(std::move(packet)); - } - list.push_back(gen.NextPacket(payload_len, nullptr)); // Valid packet. - auto factory = CreateBuiltinAudioDecoderFactory(); - const DecoderDatabase::DecoderInfo info(SdpAudioFormat("pcmu", 8000, 1), - absl::nullopt, factory.get()); - EXPECT_CALL(decoder_database, GetDecoderInfo(0)) - .WillRepeatedly(Return(&info)); - absl::optional current_pt; - absl::optional current_cng_pt; - EXPECT_EQ( - PacketBuffer::kInvalidPacket, - buffer->InsertPacketList(/*packet_list=*/&list, - /*decoder_database=*/decoder_database, - /*current_rtp_payload_type=*/¤t_pt, - /*current_cng_rtp_payload_type=*/¤t_cng_pt, - /*stats=*/&mock_stats, - /*last_decoded_length=*/payload_len, - /*sample_rate=*/1000, - /*target_level_ms=*/30)); - EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. - EXPECT_EQ(1u, buffer->NumPacketsInBuffer()); - delete buffer; - EXPECT_CALL(decoder_database, Die()); // Called when object is deleted. + EXPECT_EQ(PacketBuffer::kBufferEmpty, buffer.DiscardNextPacket()); + buffer.DiscardAllOldPackets(0); } // Test packet comparison function. @@ -873,9 +510,9 @@ TEST(PacketBuffer, GetSpanSamples) { constexpr int kSampleRateHz = 48000; constexpr bool kCountWaitingTime = false; TickTimer tick_timer; - PacketBuffer buffer(3, &tick_timer); - PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples); StrictMock mock_stats; + PacketBuffer buffer(3, &tick_timer, &mock_stats); + PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples); MockDecoderDatabase decoder_database; Packet packet_1 = gen.NextPacket(kPayloadSizeBytes, nullptr); @@ -891,12 +528,7 @@ TEST(PacketBuffer, GetSpanSamples) { packet_2.timestamp); // Tmestamp wrapped around. EXPECT_EQ(PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/std::move(packet_1), - /*stats=*/&mock_stats, - /*last_decoded_length=*/kFrameSizeSamples, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + buffer.InsertPacket(/*packet=*/std::move(packet_1))); constexpr size_t kLastDecodedSizeSamples = 2; // packet_1 has no access to duration, and relies last decoded duration as @@ -906,12 +538,7 @@ TEST(PacketBuffer, GetSpanSamples) { kCountWaitingTime)); EXPECT_EQ(PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/std::move(packet_2), - /*stats=*/&mock_stats, - /*last_decoded_length=*/kFrameSizeSamples, - /*sample_rate=*/1000, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + buffer.InsertPacket(/*packet=*/std::move(packet_2))); EXPECT_EQ(kFrameSizeSamples * 2, buffer.GetSpanSamples(0, kSampleRateHz, kCountWaitingTime)); @@ -931,20 +558,15 @@ TEST(PacketBuffer, GetSpanSamplesCountWaitingTime) { constexpr bool kCountWaitingTime = true; constexpr size_t kLastDecodedSizeSamples = 0; TickTimer tick_timer; - PacketBuffer buffer(3, &tick_timer); - PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples); StrictMock mock_stats; + PacketBuffer buffer(3, &tick_timer, &mock_stats); + PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples); MockDecoderDatabase decoder_database; Packet packet = gen.NextPacket(kPayloadSizeBytes, nullptr); EXPECT_EQ(PacketBuffer::kOK, - buffer.InsertPacket(/*packet=*/std::move(packet), - /*stats=*/&mock_stats, - /*last_decoded_length=*/kFrameSizeSamples, - /*sample_rate=*/kSampleRateHz, - /*target_level_ms=*/60, - /*decoder_database=*/decoder_database)); + buffer.InsertPacket(/*packet=*/std::move(packet))); EXPECT_EQ(0u, buffer.GetSpanSamples(kLastDecodedSizeSamples, kSampleRateHz, kCountWaitingTime)); diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/test/neteq_decoding_test.cc b/third_party/libwebrtc/modules/audio_coding/neteq/test/neteq_decoding_test.cc index e6c1809fb6..e626d09c99 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/test/neteq_decoding_test.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/test/neteq_decoding_test.cc @@ -19,13 +19,13 @@ #include "test/testsupport/file_utils.h" #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT -RTC_PUSH_IGNORING_WUNDEF() + #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" #else #include "modules/audio_coding/neteq/neteq_unittest.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() + #endif namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/test/result_sink.cc b/third_party/libwebrtc/modules/audio_coding/neteq/test/result_sink.cc index f5d50dc859..fee7b49eb3 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/test/result_sink.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/test/result_sink.cc @@ -13,19 +13,18 @@ #include #include "absl/strings/string_view.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/message_digest.h" #include "rtc_base/string_encode.h" #include "test/gtest.h" #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT -RTC_PUSH_IGNORING_WUNDEF() + #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" #else #include "modules/audio_coding/neteq/neteq_unittest.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() + #endif namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build index 04dbb03279..834a8d1265 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/neteq_gn/moz.build @@ -234,7 +234,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -244,10 +243,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build index 41f722069c..ef0c150cb8 100644 --- a/third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/pcm16b_c_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build index ed96e7c0f8..a1d9c8009d 100644 --- a/third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/pcm16b_gn/moz.build @@ -197,7 +197,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -207,10 +206,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/red_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/red_gn/moz.build index 479cf67a2a..ab0d8129bb 100644 --- a/third_party/libwebrtc/modules/audio_coding/red_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/red_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build index a8a6c576e2..d077aaa930 100644 --- a/third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/webrtc_cng_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build index 491f0cc543..d48fd68174 100644 --- a/third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/webrtc_multiopus_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build index e2c57b99af..02986beaa4 100644 --- a/third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/webrtc_opus_gn/moz.build @@ -204,7 +204,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -214,10 +213,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build b/third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build index 268854264f..e6c31b48b5 100644 --- a/third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_coding/webrtc_opus_wrapper_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_device/BUILD.gn b/third_party/libwebrtc/modules/audio_device/BUILD.gn index 4726f93279..a135f042db 100644 --- a/third_party/libwebrtc/modules/audio_device/BUILD.gn +++ b/third_party/libwebrtc/modules/audio_device/BUILD.gn @@ -50,6 +50,7 @@ rtc_source_set("audio_device_api") { "include/audio_device_defines.h", ] deps = [ + "../../api:ref_count", "../../api:scoped_refptr", "../../api/task_queue", "../../rtc_base:checks", @@ -490,7 +491,6 @@ if (rtc_include_tests && !build_with_chromium && !build_with_mozilla) { "../../common_audio", "../../rtc_base:buffer", "../../rtc_base:checks", - "../../rtc_base:ignore_wundef", "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:race_checker", diff --git a/third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build b/third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build index df00e056c6..4128efbbf8 100644 --- a/third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_device/audio_device_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_device/include/audio_device.h b/third_party/libwebrtc/modules/audio_device/include/audio_device.h index 936ee6cb04..47d2aecfa7 100644 --- a/third_party/libwebrtc/modules/audio_device/include/audio_device.h +++ b/third_party/libwebrtc/modules/audio_device/include/audio_device.h @@ -12,16 +12,16 @@ #define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_ #include "absl/types/optional.h" +#include "api/ref_count.h" #include "api/scoped_refptr.h" #include "api/task_queue/task_queue_factory.h" #include "modules/audio_device/include/audio_device_defines.h" -#include "rtc_base/ref_count.h" namespace webrtc { class AudioDeviceModuleForTest; -class AudioDeviceModule : public rtc::RefCountInterface { +class AudioDeviceModule : public webrtc::RefCountInterface { public: enum AudioLayer { kPlatformDefaultAudio = 0, diff --git a/third_party/libwebrtc/modules/audio_device/include/fake_audio_device.h b/third_party/libwebrtc/modules/audio_device/include/fake_audio_device.h index 2322ce0263..2a303173e9 100644 --- a/third_party/libwebrtc/modules/audio_device/include/fake_audio_device.h +++ b/third_party/libwebrtc/modules/audio_device/include/fake_audio_device.h @@ -23,8 +23,8 @@ class FakeAudioDeviceModule // references using scoped_refptr. Current code doesn't always use refcounting // for this class. void AddRef() const override {} - rtc::RefCountReleaseStatus Release() const override { - return rtc::RefCountReleaseStatus::kDroppedLastRef; + webrtc::RefCountReleaseStatus Release() const override { + return webrtc::RefCountReleaseStatus::kDroppedLastRef; } }; diff --git a/third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build b/third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build index edfac56a3a..cc60512cda 100644 --- a/third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_mixer/audio_frame_manipulator_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build b/third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build index 7108d9fbe1..6595939941 100644 --- a/third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_mixer/audio_mixer_impl_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/BUILD.gn b/third_party/libwebrtc/modules/audio_processing/BUILD.gn index 2b81427da9..6aca7dee46 100644 --- a/third_party/libwebrtc/modules/audio_processing/BUILD.gn +++ b/third_party/libwebrtc/modules/audio_processing/BUILD.gn @@ -29,6 +29,7 @@ rtc_library("api") { ":audio_frame_view", ":audio_processing_statistics", "../../api:array_view", + "../../api:ref_count", "../../api:scoped_refptr", "../../api/audio:aec3_config", "../../api/audio:audio_frame_api", @@ -190,7 +191,6 @@ rtc_library("audio_processing") { "../../rtc_base:checks", "../../rtc_base:event_tracer", "../../rtc_base:gtest_prod", - "../../rtc_base:ignore_wundef", "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:safe_minmax", @@ -397,7 +397,6 @@ if (rtc_include_tests) { "../../common_audio:common_audio_c", "../../rtc_base:checks", "../../rtc_base:gtest_prod", - "../../rtc_base:ignore_wundef", "../../rtc_base:macromagic", "../../rtc_base:platform_thread", "../../rtc_base:protobuf_utils", @@ -573,7 +572,6 @@ if (rtc_include_tests) { "../../api/audio:echo_detector_creator", "../../common_audio", "../../rtc_base:checks", - "../../rtc_base:ignore_wundef", "../../rtc_base:logging", "../../rtc_base:protobuf_utils", "../../rtc_base:rtc_json", @@ -613,7 +611,6 @@ if (rtc_include_tests) { deps = [ ":audioproc_debug_proto", "../../rtc_base:checks", - "../../rtc_base:ignore_wundef", "../../rtc_base:protobuf_utils", "../../rtc_base/system:arch", ] diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build index f21e65fb4a..7435b6a457 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_erl_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build index b9c819893f..0d2471073d 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/adaptive_fir_filter_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build index 097e67bbe5..f9844b6521 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_avx2_gn/moz.build @@ -181,10 +181,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86": CXXFLAGS += [ diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build index 955fe2022f..8d9c4e6bd7 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_common_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build index 154d9f4406..d403ae8b96 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_fft_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build index 7ad4cffedf..85e5654231 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/aec3_gn/moz.build @@ -256,7 +256,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -266,10 +265,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build index 0084077435..aa1aaf15d9 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/fft_data_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build index be2c3bbf56..0ebdb0798f 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/matched_filter_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build index 2bd3ae0c01..6444c3137f 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/render_buffer_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build index e40fdb1cf1..9cf3a7842a 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec3/vector_math_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec_dump/BUILD.gn b/third_party/libwebrtc/modules/audio_processing/aec_dump/BUILD.gn index 38d8776258..78bae56835 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec_dump/BUILD.gn +++ b/third_party/libwebrtc/modules/audio_processing/aec_dump/BUILD.gn @@ -66,7 +66,6 @@ if (rtc_enable_protobuf) { "../../../api/audio:audio_frame_api", "../../../api/task_queue", "../../../rtc_base:checks", - "../../../rtc_base:ignore_wundef", "../../../rtc_base:logging", "../../../rtc_base:macromagic", "../../../rtc_base:protobuf_utils", diff --git a/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build index f1280fed0d..13420467de 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_gn/moz.build @@ -187,16 +187,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_impl.h b/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_impl.h index fac3712b7a..429808f9af 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_impl.h +++ b/third_party/libwebrtc/modules/audio_processing/aec_dump/aec_dump_impl.h @@ -17,20 +17,17 @@ #include "modules/audio_processing/aec_dump/capture_stream_info.h" #include "modules/audio_processing/include/aec_dump.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/race_checker.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/task_queue.h" #include "rtc_base/thread_annotations.h" // Files generated at build-time by the protobuf compiler. -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" #else #include "modules/audio_processing/debug.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_processing/aec_dump/capture_stream_info.h b/third_party/libwebrtc/modules/audio_processing/aec_dump/capture_stream_info.h index 0819bbcb23..572990c150 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec_dump/capture_stream_info.h +++ b/third_party/libwebrtc/modules/audio_processing/aec_dump/capture_stream_info.h @@ -15,16 +15,13 @@ #include #include "modules/audio_processing/include/aec_dump.h" -#include "rtc_base/ignore_wundef.h" // Files generated at build-time by the protobuf compiler. -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" #else #include "modules/audio_processing/debug.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build index 2966151ab6..4e8b16442d 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec_dump/null_aec_dump_factory_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build index 02b847ed76..89ae508073 100644 --- a/third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aec_dump_interface_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build index 9ff36991fe..ca3ffeb81e 100644 --- a/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/aecm/aecm_core_gn/moz.build @@ -238,7 +238,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -248,10 +247,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build index f6f4442cfc..f26489f413 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc/agc_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build index be6b4f9b27..ebf241f7a5 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc/gain_control_interface_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build index 4e6e295d34..aa5c6835cc 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc/legacy_agc_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build index 64ffa75960..a272555662 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc/level_estimation_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build index 9473ac62f5..5e3b5801ad 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/adaptive_digital_gain_controller_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build index c7a2f6d215..d9520efe2f 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/biquad_filter_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build index e70e3f68e9..dbf53e8e8e 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/clipping_predictor_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build index 8690613542..44307f4147 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/common_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build index 4b0431db1a..e842cac9c3 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/cpu_features_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build index 1b8da82f58..60614d4cc1 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/fixed_digital_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build index bea71dcee3..691900e356 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/gain_applier_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build index 03eb1fb3a1..ee04e973fb 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/gain_map_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build index f1a841d5ae..0bde4db9d4 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_controller_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build index 40448f68a9..b7d0a9ba88 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/input_volume_stats_reporter_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build index 9d4629e9ab..210539ab46 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/noise_level_estimator_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build index 134ffac5fd..7965a026ef 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_auto_correlation_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build index cf3de48a57..bdfe90cf16 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_common_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build index dbb926c5fc..6a73ce96e4 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build index 92da260f90..27b40f13a5 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_layers_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build index cedb17bc22..d66ed412b2 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_lp_residual_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build index d45bc78ff6..0ddc85f5ac 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_pitch_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build index 20da5f3615..25e813a226 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_ring_buffer_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build index b0ba79562e..f54dd88a23 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_sequence_buffer_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build index 2d8396fa2a..d8b88047d7 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_spectral_features_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build index 143ba6960c..4a3c5bf28b 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/rnn_vad_symmetric_matrix_buffer_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build index d4dd169f15..01313fa460 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_avx2_gn/moz.build @@ -176,10 +176,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "x86": CXXFLAGS += [ diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build index 09fe0c3d24..3f88913309 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/rnn_vad/vector_math_gn/moz.build @@ -191,16 +191,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build index 6b8def8650..6562d840b7 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/saturation_protector_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build index 8f2996fa26..3afaa88450 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/speech_level_estimator_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build index 55cfbb60e7..3aa09832b2 100644 --- a/third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/agc2/vad_wrapper_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/api_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/api_gn/moz.build index 7a02b7e10c..37e50af014 100644 --- a/third_party/libwebrtc/modules/audio_processing/api_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/api_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build index 992376cd8a..53fd9d9f94 100644 --- a/third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/apm_logging_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build index 88031a747d..2087aeb909 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/audio_buffer_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build index 7e73b70483..737ca5e834 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/audio_frame_proxies_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build index 0f81755091..b7391a78b1 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/audio_frame_view_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build index 7dc22bcf2b..5b4f4d5d54 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/audio_processing_gn/moz.build @@ -206,7 +206,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -216,10 +215,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/audio_processing_impl.h b/third_party/libwebrtc/modules/audio_processing/audio_processing_impl.h index fe80e0d912..1e058b5a32 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_processing_impl.h +++ b/third_party/libwebrtc/modules/audio_processing/audio_processing_impl.h @@ -43,7 +43,6 @@ #include "modules/audio_processing/rms_level.h" #include "modules/audio_processing/transient/transient_suppressor.h" #include "rtc_base/gtest_prod_util.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/swap_queue.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" diff --git a/third_party/libwebrtc/modules/audio_processing/audio_processing_impl_unittest.cc b/third_party/libwebrtc/modules/audio_processing/audio_processing_impl_unittest.cc index 9e50f994b1..e03f966b06 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_processing_impl_unittest.cc +++ b/third_party/libwebrtc/modules/audio_processing/audio_processing_impl_unittest.cc @@ -48,7 +48,7 @@ class MockInitialize : public AudioProcessingImpl { } MOCK_METHOD(void, AddRef, (), (const, override)); - MOCK_METHOD(rtc::RefCountReleaseStatus, Release, (), (const, override)); + MOCK_METHOD(RefCountReleaseStatus, Release, (), (const, override)); }; // Creates MockEchoControl instances and provides a raw pointer access to diff --git a/third_party/libwebrtc/modules/audio_processing/audio_processing_statistics_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/audio_processing_statistics_gn/moz.build index 6d174505ed..6b3e54c3f7 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_processing_statistics_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/audio_processing_statistics_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/audio_processing_unittest.cc b/third_party/libwebrtc/modules/audio_processing/audio_processing_unittest.cc index e320e71405..c2bedb2da4 100644 --- a/third_party/libwebrtc/modules/audio_processing/audio_processing_unittest.cc +++ b/third_party/libwebrtc/modules/audio_processing/audio_processing_unittest.cc @@ -38,7 +38,6 @@ #include "rtc_base/checks.h" #include "rtc_base/fake_clock.h" #include "rtc_base/gtest_prod_util.h" -#include "rtc_base/ignore_wundef.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_minmax.h" #include "rtc_base/protobuf_utils.h" @@ -51,14 +50,13 @@ #include "test/gtest.h" #include "test/testsupport/file_utils.h" -RTC_PUSH_IGNORING_WUNDEF() -#include "modules/audio_processing/debug.pb.h" #ifdef WEBRTC_ANDROID_PLATFORM_BUILD +#include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" #include "external/webrtc/webrtc/modules/audio_processing/test/unittest.pb.h" #else +#include "modules/audio_processing/debug.pb.h" #include "modules/audio_processing/test/unittest.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() ABSL_FLAG(bool, write_apm_ref_data, diff --git a/third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build index d80a3bb1c6..ad198344e2 100644 --- a/third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/capture_levels_adjuster/capture_levels_adjuster_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build index d6d9d3658b..ab31e68564 100644 --- a/third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/gain_controller2_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build index 8769a3a318..af06d4142f 100644 --- a/third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/high_pass_filter_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/include/audio_processing.h b/third_party/libwebrtc/modules/audio_processing/include/audio_processing.h index f613a38de1..e3223513af 100644 --- a/third_party/libwebrtc/modules/audio_processing/include/audio_processing.h +++ b/third_party/libwebrtc/modules/audio_processing/include/audio_processing.h @@ -28,10 +28,10 @@ #include "api/array_view.h" #include "api/audio/echo_canceller3_config.h" #include "api/audio/echo_control.h" +#include "api/ref_count.h" #include "api/scoped_refptr.h" #include "modules/audio_processing/include/audio_processing_statistics.h" #include "rtc_base/arraysize.h" -#include "rtc_base/ref_count.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/system/rtc_export.h" @@ -127,7 +127,7 @@ class CustomProcessing; // // Close the application... // apm.reset(); // -class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface { +class RTC_EXPORT AudioProcessing : public RefCountInterface { public: // The struct below constitutes the new parameter scheme for the audio // processing. It is being introduced gradually and until it is fully @@ -912,7 +912,7 @@ class CustomProcessing { }; // Interface for an echo detector submodule. -class EchoDetector : public rtc::RefCountInterface { +class EchoDetector : public RefCountInterface { public: // (Re-)Initializes the submodule. virtual void Initialize(int capture_sample_rate_hz, diff --git a/third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build index 14595abaf9..ac1c19134a 100644 --- a/third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/ns/ns_gn/moz.build @@ -212,7 +212,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -222,10 +221,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/optionally_built_submodule_creators_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/optionally_built_submodule_creators_gn/moz.build index af79a781f6..da2a1b7ae3 100644 --- a/third_party/libwebrtc/modules/audio_processing/optionally_built_submodule_creators_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/optionally_built_submodule_creators_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build index 23f52652ae..d0c4b2bd8e 100644 --- a/third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/rms_level_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/test/aec_dump_based_simulator.h b/third_party/libwebrtc/modules/audio_processing/test/aec_dump_based_simulator.h index e2c1f3e4ba..4713c800ec 100644 --- a/third_party/libwebrtc/modules/audio_processing/test/aec_dump_based_simulator.h +++ b/third_party/libwebrtc/modules/audio_processing/test/aec_dump_based_simulator.h @@ -15,15 +15,12 @@ #include #include "modules/audio_processing/test/audio_processing_simulator.h" -#include "rtc_base/ignore_wundef.h" -RTC_PUSH_IGNORING_WUNDEF() #ifdef WEBRTC_ANDROID_PLATFORM_BUILD #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" #else #include "modules/audio_processing/debug.pb.h" #endif -RTC_POP_IGNORING_WUNDEF() namespace webrtc { namespace test { diff --git a/third_party/libwebrtc/modules/audio_processing/test/debug_dump_replayer.h b/third_party/libwebrtc/modules/audio_processing/test/debug_dump_replayer.h index be21c68663..077147eb68 100644 --- a/third_party/libwebrtc/modules/audio_processing/test/debug_dump_replayer.h +++ b/third_party/libwebrtc/modules/audio_processing/test/debug_dump_replayer.h @@ -16,11 +16,9 @@ #include "absl/strings/string_view.h" #include "common_audio/channel_buffer.h" #include "modules/audio_processing/include/audio_processing.h" -#include "rtc_base/ignore_wundef.h" -RTC_PUSH_IGNORING_WUNDEF() +// Generated at build-time by the protobuf compiler. #include "modules/audio_processing/debug.pb.h" -RTC_POP_IGNORING_WUNDEF() namespace webrtc { namespace test { diff --git a/third_party/libwebrtc/modules/audio_processing/test/protobuf_utils.h b/third_party/libwebrtc/modules/audio_processing/test/protobuf_utils.h index b9c2e819f9..eb93383f5a 100644 --- a/third_party/libwebrtc/modules/audio_processing/test/protobuf_utils.h +++ b/third_party/libwebrtc/modules/audio_processing/test/protobuf_utils.h @@ -14,12 +14,10 @@ #include #include // no-presubmit-check TODO(webrtc:8982) -#include "rtc_base/ignore_wundef.h" #include "rtc_base/protobuf_utils.h" -RTC_PUSH_IGNORING_WUNDEF() +// Generated at build-time by the protobuf compiler. #include "modules/audio_processing/debug.pb.h" -RTC_POP_IGNORING_WUNDEF() namespace webrtc { diff --git a/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_api_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_api_gn/moz.build index 6310b948ac..44571715b8 100644 --- a/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_api_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_api_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_impl_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_impl_gn/moz.build index 31e0736f30..d700fc1a32 100644 --- a/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_impl_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/transient/transient_suppressor_impl_gn/moz.build @@ -203,7 +203,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -213,10 +212,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/transient/voice_probability_delay_unit_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/transient/voice_probability_delay_unit_gn/moz.build index 52587c0890..c67675f431 100644 --- a/third_party/libwebrtc/modules/audio_processing/transient/voice_probability_delay_unit_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/transient/voice_probability_delay_unit_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build index 02813d2513..b6566a8950 100644 --- a/third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/utility/cascaded_biquad_filter_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build index 67c6a218f6..c20d5b6189 100644 --- a/third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/utility/legacy_delay_estimator_gn/moz.build @@ -189,7 +189,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -199,10 +198,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build index 3213706005..936decab70 100644 --- a/third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/utility/pffft_wrapper_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build b/third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build index 3739bbef8a..0ae31f5a2e 100644 --- a/third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build +++ b/third_party/libwebrtc/modules/audio_processing/vad/vad_gn/moz.build @@ -206,7 +206,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -216,10 +215,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build index b5bcafa45f..1190193b94 100644 --- a/third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/congestion_controller_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build index b48fc38c39..40fd1189aa 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/alr_detector_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build index 31d8c420f6..e2087c6126 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/delay_based_bwe_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build index e233806b43..7b77d3dc86 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/estimators_gn/moz.build @@ -205,7 +205,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -215,10 +214,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build index 147a08113b..0e5182a469 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_gn/moz.build @@ -201,7 +201,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -211,10 +210,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build index 0ee8a34df8..04b78b5988 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/link_capacity_estimator_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build index 5931292efe..d290fbe9ec 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v1_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc index ef200869a6..8e1a3c4698 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -132,7 +132,7 @@ LossBasedBweV2::LossBasedBweV2(const FieldTrialsView* key_value_config) instant_upper_bound_temporal_weights_.resize( config_->observation_window_size); CalculateTemporalWeights(); - hold_duration_ = kInitHoldDuration; + last_hold_info_.duration = kInitHoldDuration; } bool LossBasedBweV2::IsEnabled() const { @@ -149,6 +149,10 @@ bool LossBasedBweV2::ReadyToUseInStartPhase() const { return IsReady() && config_->use_in_start_phase; } +bool LossBasedBweV2::UseInStartPhase() const { + return config_->use_in_start_phase; +} + LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult() const { if (!IsReady()) { if (!IsEnabled()) { @@ -289,50 +293,69 @@ void LossBasedBweV2::UpdateBandwidthEstimate( /*new_estimate=*/best_candidate.loss_limited_bandwidth); // Bound the best candidate by the acked bitrate. if (increasing_when_loss_limited && IsValid(acknowledged_bitrate_)) { + double rampup_factor = config_->bandwidth_rampup_upper_bound_factor; + if (IsValid(last_hold_info_.rate) && + acknowledged_bitrate_ < + config_->bandwidth_rampup_hold_threshold * last_hold_info_.rate) { + rampup_factor = config_->bandwidth_rampup_upper_bound_factor_in_hold; + } + best_candidate.loss_limited_bandwidth = std::max(current_best_estimate_.loss_limited_bandwidth, std::min(best_candidate.loss_limited_bandwidth, - config_->bandwidth_rampup_upper_bound_factor * - (*acknowledged_bitrate_))); + rampup_factor * (*acknowledged_bitrate_))); + // Increase current estimate by at least 1kbps to make sure that the state + // will be switched to kIncreasing, thus padding is triggered. + if (loss_based_result_.state == LossBasedState::kDecreasing && + best_candidate.loss_limited_bandwidth == + current_best_estimate_.loss_limited_bandwidth) { + best_candidate.loss_limited_bandwidth = + current_best_estimate_.loss_limited_bandwidth + + DataRate::BitsPerSec(1); + } } } - current_best_estimate_ = best_candidate; - UpdateResult(); - - if (IsInLossLimitedState() && - (recovering_after_loss_timestamp_.IsInfinite() || - recovering_after_loss_timestamp_ + config_->delayed_increase_window < - last_send_time_most_recent_observation_)) { - bandwidth_limit_in_current_window_ = - std::max(kCongestionControllerMinBitrate, - current_best_estimate_.loss_limited_bandwidth * - config_->max_increase_factor); - recovering_after_loss_timestamp_ = last_send_time_most_recent_observation_; - } -} - -void LossBasedBweV2::UpdateResult() { DataRate bounded_bandwidth_estimate = DataRate::PlusInfinity(); if (IsValid(delay_based_estimate_)) { bounded_bandwidth_estimate = std::max(GetInstantLowerBound(), - std::min({current_best_estimate_.loss_limited_bandwidth, + std::min({best_candidate.loss_limited_bandwidth, GetInstantUpperBound(), delay_based_estimate_})); } else { - bounded_bandwidth_estimate = - std::max(GetInstantLowerBound(), - std::min(current_best_estimate_.loss_limited_bandwidth, - GetInstantUpperBound())); + bounded_bandwidth_estimate = std::max( + GetInstantLowerBound(), std::min(best_candidate.loss_limited_bandwidth, + GetInstantUpperBound())); + } + if (config_->bound_best_candidate && + bounded_bandwidth_estimate < best_candidate.loss_limited_bandwidth) { + RTC_LOG(LS_INFO) << "Resetting loss based BWE to " + << bounded_bandwidth_estimate.kbps() + << "due to loss. Avg loss rate: " + << GetAverageReportedLossRatio(); + current_best_estimate_.loss_limited_bandwidth = bounded_bandwidth_estimate; + current_best_estimate_.inherent_loss = 0; + } else { + current_best_estimate_ = best_candidate; + if (config_->lower_bound_by_acked_rate_factor > 0.0) { + current_best_estimate_.loss_limited_bandwidth = + std::max(current_best_estimate_.loss_limited_bandwidth, + GetInstantLowerBound()); + } } if (loss_based_result_.state == LossBasedState::kDecreasing && - last_hold_timestamp_ > last_send_time_most_recent_observation_ && + last_hold_info_.timestamp > last_send_time_most_recent_observation_ && bounded_bandwidth_estimate < delay_based_estimate_) { - // BWE is not allowed to increase during the HOLD duration. The purpose of + // Ensure that acked rate is the lower bound of HOLD rate. + if (config_->lower_bound_by_acked_rate_factor > 0.0) { + last_hold_info_.rate = + std::max(GetInstantLowerBound(), last_hold_info_.rate); + } + // BWE is not allowed to increase above the HOLD rate. The purpose of // HOLD is to not immediately ramp up BWE to a rate that may cause loss. - loss_based_result_.bandwidth_estimate = std::min( - loss_based_result_.bandwidth_estimate, bounded_bandwidth_estimate); + loss_based_result_.bandwidth_estimate = + std::min(last_hold_info_.rate, bounded_bandwidth_estimate); return; } @@ -359,22 +382,38 @@ void LossBasedBweV2::UpdateResult() { RTC_LOG(LS_INFO) << this << " " << "Switch to HOLD. Bounded BWE: " << bounded_bandwidth_estimate.kbps() - << ", duration: " << hold_duration_.seconds(); - last_hold_timestamp_ = - last_send_time_most_recent_observation_ + hold_duration_; - hold_duration_ = std::min(kMaxHoldDuration, - hold_duration_ * config_->hold_duration_factor); + << ", duration: " << last_hold_info_.duration.ms(); + last_hold_info_ = { + .timestamp = last_send_time_most_recent_observation_ + + last_hold_info_.duration, + .duration = + std::min(kMaxHoldDuration, last_hold_info_.duration * + config_->hold_duration_factor), + .rate = bounded_bandwidth_estimate}; } last_padding_info_ = PaddingInfo(); loss_based_result_.state = LossBasedState::kDecreasing; } else { - // Reset the HOLD duration if delay based estimate works to avoid getting + // Reset the HOLD info if delay based estimate works to avoid getting // stuck in low bitrate. - hold_duration_ = kInitHoldDuration; + last_hold_info_ = {.timestamp = Timestamp::MinusInfinity(), + .duration = kInitHoldDuration, + .rate = DataRate::PlusInfinity()}; last_padding_info_ = PaddingInfo(); loss_based_result_.state = LossBasedState::kDelayBasedEstimate; } loss_based_result_.bandwidth_estimate = bounded_bandwidth_estimate; + + if (IsInLossLimitedState() && + (recovering_after_loss_timestamp_.IsInfinite() || + recovering_after_loss_timestamp_ + config_->delayed_increase_window < + last_send_time_most_recent_observation_)) { + bandwidth_limit_in_current_window_ = + std::max(kCongestionControllerMinBitrate, + current_best_estimate_.loss_limited_bandwidth * + config_->max_increase_factor); + recovering_after_loss_timestamp_ = last_send_time_most_recent_observation_; + } } bool LossBasedBweV2::IsEstimateIncreasingWhenLossLimited( @@ -394,6 +433,10 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter enabled("Enabled", true); FieldTrialParameter bandwidth_rampup_upper_bound_factor( "BwRampupUpperBoundFactor", 1000000.0); + FieldTrialParameter bandwidth_rampup_upper_bound_factor_in_hold( + "BwRampupUpperBoundInHoldFactor", 1000000.0); + FieldTrialParameter bandwidth_rampup_hold_threshold( + "BwRampupUpperBoundHoldThreshold", 1.3); FieldTrialParameter rampup_acceleration_max_factor( "BwRampupAccelMaxFactor", 0.0); FieldTrialParameter rampup_acceleration_maxout_time( @@ -445,12 +488,6 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter not_increase_if_inherent_loss_less_than_average_loss( "NotIncreaseIfInherentLossLessThanAverageLoss", true); - FieldTrialParameter high_loss_rate_threshold("HighLossRateThreshold", - 1.0); - FieldTrialParameter bandwidth_cap_at_high_loss_rate( - "BandwidthCapAtHighLossRate", DataRate::KilobitsPerSec(500.0)); - FieldTrialParameter slope_of_bwe_high_loss_func( - "SlopeOfBweHighLossFunc", 1000); FieldTrialParameter not_use_acked_rate_in_alr("NotUseAckedRateInAlr", true); FieldTrialParameter use_in_start_phase("UseInStartPhase", false); @@ -461,9 +498,12 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter use_byte_loss_rate("UseByteLossRate", false); FieldTrialParameter padding_duration("PaddingDuration", TimeDelta::Zero()); + FieldTrialParameter bound_best_candidate("BoundBestCandidate", false); if (key_value_config) { ParseFieldTrial({&enabled, &bandwidth_rampup_upper_bound_factor, + &bandwidth_rampup_upper_bound_factor_in_hold, + &bandwidth_rampup_hold_threshold, &rampup_acceleration_max_factor, &rampup_acceleration_maxout_time, &candidate_factors, @@ -491,16 +531,14 @@ absl::optional LossBasedBweV2::CreateConfig( &max_increase_factor, &delayed_increase_window, ¬_increase_if_inherent_loss_less_than_average_loss, - &high_loss_rate_threshold, - &bandwidth_cap_at_high_loss_rate, - &slope_of_bwe_high_loss_func, ¬_use_acked_rate_in_alr, &use_in_start_phase, &min_num_observations, &lower_bound_by_acked_rate_factor, &hold_duration_factor, &use_byte_loss_rate, - &padding_duration}, + &padding_duration, + &bound_best_candidate}, key_value_config->Lookup("WebRTC-Bwe-LossBasedBweV2")); } @@ -511,6 +549,10 @@ absl::optional LossBasedBweV2::CreateConfig( config.emplace(Config()); config->bandwidth_rampup_upper_bound_factor = bandwidth_rampup_upper_bound_factor.Get(); + config->bandwidth_rampup_upper_bound_factor_in_hold = + bandwidth_rampup_upper_bound_factor_in_hold.Get(); + config->bandwidth_rampup_hold_threshold = + bandwidth_rampup_hold_threshold.Get(); config->rampup_acceleration_max_factor = rampup_acceleration_max_factor.Get(); config->rampup_acceleration_maxout_time = rampup_acceleration_maxout_time.Get(); @@ -553,10 +595,6 @@ absl::optional LossBasedBweV2::CreateConfig( config->delayed_increase_window = delayed_increase_window.Get(); config->not_increase_if_inherent_loss_less_than_average_loss = not_increase_if_inherent_loss_less_than_average_loss.Get(); - config->high_loss_rate_threshold = high_loss_rate_threshold.Get(); - config->bandwidth_cap_at_high_loss_rate = - bandwidth_cap_at_high_loss_rate.Get(); - config->slope_of_bwe_high_loss_func = slope_of_bwe_high_loss_func.Get(); config->not_use_acked_rate_in_alr = not_use_acked_rate_in_alr.Get(); config->use_in_start_phase = use_in_start_phase.Get(); config->min_num_observations = min_num_observations.Get(); @@ -565,7 +603,7 @@ absl::optional LossBasedBweV2::CreateConfig( config->hold_duration_factor = hold_duration_factor.Get(); config->use_byte_loss_rate = use_byte_loss_rate.Get(); config->padding_duration = padding_duration.Get(); - + config->bound_best_candidate = bound_best_candidate.Get(); return config; } @@ -582,6 +620,18 @@ bool LossBasedBweV2::IsConfigValid() const { << config_->bandwidth_rampup_upper_bound_factor; valid = false; } + if (config_->bandwidth_rampup_upper_bound_factor_in_hold <= 1.0) { + RTC_LOG(LS_WARNING) << "The bandwidth rampup upper bound factor in hold " + "must be greater than 1: " + << config_->bandwidth_rampup_upper_bound_factor_in_hold; + valid = false; + } + if (config_->bandwidth_rampup_hold_threshold < 0.0) { + RTC_LOG(LS_WARNING) << "The bandwidth rampup hold threshold must" + "must be non-negative.: " + << config_->bandwidth_rampup_hold_threshold; + valid = false; + } if (config_->rampup_acceleration_max_factor < 0.0) { RTC_LOG(LS_WARNING) << "The rampup acceleration max factor must be non-negative.: " @@ -739,12 +789,6 @@ bool LossBasedBweV2::IsConfigValid() const { << config_->delayed_increase_window.ms(); valid = false; } - if (config_->high_loss_rate_threshold <= 0.0 || - config_->high_loss_rate_threshold > 1.0) { - RTC_LOG(LS_WARNING) << "The high loss rate threshold must be in (0, 1]: " - << config_->high_loss_rate_threshold; - valid = false; - } if (config_->min_num_observations <= 0) { RTC_LOG(LS_WARNING) << "The min number of observations must be positive: " << config_->min_num_observations; @@ -834,15 +878,19 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound() const { std::vector LossBasedBweV2::GetCandidates( bool in_alr) const { + ChannelParameters best_estimate = current_best_estimate_; std::vector bandwidths; for (double candidate_factor : config_->candidate_factors) { bandwidths.push_back(candidate_factor * - current_best_estimate_.loss_limited_bandwidth); + best_estimate.loss_limited_bandwidth); } if (acknowledged_bitrate_.has_value() && config_->append_acknowledged_rate_candidate) { - if (!(config_->not_use_acked_rate_in_alr && in_alr)) { + if (!(config_->not_use_acked_rate_in_alr && in_alr) || + (config_->padding_duration > TimeDelta::Zero() && + last_padding_info_.padding_timestamp + config_->padding_duration >= + last_send_time_most_recent_observation_)) { bandwidths.push_back(*acknowledged_bitrate_ * config_->bandwidth_backoff_lower_bound_factor); } @@ -850,13 +898,13 @@ std::vector LossBasedBweV2::GetCandidates( if (IsValid(delay_based_estimate_) && config_->append_delay_based_estimate_candidate) { - if (delay_based_estimate_ > current_best_estimate_.loss_limited_bandwidth) { + if (delay_based_estimate_ > best_estimate.loss_limited_bandwidth) { bandwidths.push_back(delay_based_estimate_); } } if (in_alr && config_->append_upper_bound_candidate_in_alr && - current_best_estimate_.loss_limited_bandwidth > GetInstantUpperBound()) { + best_estimate.loss_limited_bandwidth > GetInstantUpperBound()) { bandwidths.push_back(GetInstantUpperBound()); } @@ -866,10 +914,10 @@ std::vector LossBasedBweV2::GetCandidates( std::vector candidates; candidates.resize(bandwidths.size()); for (size_t i = 0; i < bandwidths.size(); ++i) { - ChannelParameters candidate = current_best_estimate_; - candidate.loss_limited_bandwidth = std::min( - bandwidths[i], std::max(current_best_estimate_.loss_limited_bandwidth, - candidate_bandwidth_upper_bound)); + ChannelParameters candidate = best_estimate; + candidate.loss_limited_bandwidth = + std::min(bandwidths[i], std::max(best_estimate.loss_limited_bandwidth, + candidate_bandwidth_upper_bound)); candidate.inherent_loss = GetFeasibleInherentLoss(candidate); candidates[i] = candidate; } @@ -1037,14 +1085,6 @@ void LossBasedBweV2::CalculateInstantUpperBound() { instant_limit = config_->instant_upper_bound_bandwidth_balance / (average_reported_loss_ratio - config_->instant_upper_bound_loss_offset); - if (average_reported_loss_ratio > config_->high_loss_rate_threshold) { - instant_limit = std::min( - instant_limit, DataRate::KilobitsPerSec(std::max( - static_cast(min_bitrate_.kbps()), - config_->bandwidth_cap_at_high_loss_rate.kbps() - - config_->slope_of_bwe_high_loss_func * - average_reported_loss_ratio))); - } } cached_instant_upper_bound_ = instant_limit; diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h index 425ca2a0c8..9afbb11f1f 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -62,6 +62,9 @@ class LossBasedBweV2 { // Returns true if loss based BWE is ready to be used in the start phase. bool ReadyToUseInStartPhase() const; + // Returns true if loss based BWE can be used in the start phase. + bool UseInStartPhase() const; + // Returns `DataRate::PlusInfinity` if no BWE can be calculated. Result GetLossBasedResult() const; @@ -83,6 +86,8 @@ class LossBasedBweV2 { struct Config { double bandwidth_rampup_upper_bound_factor = 0.0; + double bandwidth_rampup_upper_bound_factor_in_hold = 0; + double bandwidth_rampup_hold_threshold = 0; double rampup_acceleration_max_factor = 0.0; TimeDelta rampup_acceleration_maxout_time = TimeDelta::Zero(); std::vector candidate_factors; @@ -111,9 +116,6 @@ class LossBasedBweV2 { double max_increase_factor = 0.0; TimeDelta delayed_increase_window = TimeDelta::Zero(); bool not_increase_if_inherent_loss_less_than_average_loss = false; - double high_loss_rate_threshold = 1.0; - DataRate bandwidth_cap_at_high_loss_rate = DataRate::MinusInfinity(); - double slope_of_bwe_high_loss_func = 1000.0; bool not_use_acked_rate_in_alr = false; bool use_in_start_phase = false; int min_num_observations = 0; @@ -121,6 +123,7 @@ class LossBasedBweV2 { double hold_duration_factor = 0.0; bool use_byte_loss_rate = false; TimeDelta padding_duration = TimeDelta::Zero(); + bool bound_best_candidate = false; }; struct Derivatives { @@ -152,6 +155,12 @@ class LossBasedBweV2 { Timestamp padding_timestamp = Timestamp::MinusInfinity(); }; + struct HoldInfo { + Timestamp timestamp = Timestamp::MinusInfinity(); + TimeDelta duration = TimeDelta::Zero(); + DataRate rate = DataRate::PlusInfinity(); + }; + static absl::optional CreateConfig( const FieldTrialsView* key_value_config); bool IsConfigValid() const; @@ -180,7 +189,6 @@ class LossBasedBweV2 { // Returns false if no observation was created. bool PushBackObservation(rtc::ArrayView packet_results); - void UpdateResult(); bool IsEstimateIncreasingWhenLossLimited(DataRate old_estimate, DataRate new_estimate); bool IsInLossLimitedState() const; @@ -204,8 +212,7 @@ class LossBasedBweV2 { DataRate max_bitrate_ = DataRate::PlusInfinity(); DataRate delay_based_estimate_ = DataRate::PlusInfinity(); LossBasedBweV2::Result loss_based_result_ = LossBasedBweV2::Result(); - Timestamp last_hold_timestamp_ = Timestamp::MinusInfinity(); - TimeDelta hold_duration_ = TimeDelta::Zero(); + HoldInfo last_hold_info_ = HoldInfo(); PaddingInfo last_padding_info_ = PaddingInfo(); }; diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build index ca9f20ab87..709bcdb937 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc index 347e2a86d1..9b7ad03148 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/loss_based_bwe_v2_test.cc @@ -795,7 +795,7 @@ TEST_F(LossBasedBweV2Test, // The estimate is capped by acked_bitrate * BwRampupUpperBoundFactor. EXPECT_EQ(result.bandwidth_estimate, estimate_1 * 0.9 * 1.2); - // But if acked bitrate decrease, BWE does not decrease when there is no + // But if acked bitrate decreases, BWE does not decrease when there is no // loss. loss_based_bandwidth_estimator.SetAcknowledgedBitrate(estimate_1 * 0.9); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( @@ -809,6 +809,53 @@ TEST_F(LossBasedBweV2Test, result.bandwidth_estimate); } +// Ensure that the state can switch to kIncrease even when the bandwidth is +// bounded by acked bitrate. +TEST_F(LossBasedBweV2Test, EnsureIncreaseEvenIfAckedBitrateBound) { + ExplicitKeyValueConfig key_value_config(ShortObservationConfig( + "LossThresholdOfHighBandwidthPreference:0.99," + "BwRampupUpperBoundFactor:1.2," + // Set InstantUpperBoundBwBalance high to disable InstantUpperBound cap. + "InstantUpperBoundBwBalance:10000kbps,")); + std::vector enough_feedback_1 = + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); + + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(600)); + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(300)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate(enough_feedback_1, + delay_based_estimate, + /*in_alr=*/false); + ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kDecreasing); + LossBasedBweV2::Result result = + loss_based_bandwidth_estimator.GetLossBasedResult(); + DataRate estimate_1 = result.bandwidth_estimate; + ASSERT_LT(estimate_1.kbps(), 600); + + // Set a low acked bitrate. + loss_based_bandwidth_estimator.SetAcknowledgedBitrate(estimate_1 / 2); + + int feedback_count = 1; + while (feedback_count < 5 && result.state != LossBasedState::kIncreasing) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + feedback_count++ * kObservationDurationLowerBound), + delay_based_estimate, + /*in_alr=*/false); + result = loss_based_bandwidth_estimator.GetLossBasedResult(); + } + + ASSERT_EQ(result.state, LossBasedState::kIncreasing); + // The estimate increases by 1kbps. + EXPECT_EQ(result.bandwidth_estimate, estimate_1 + DataRate::BitsPerSec(1)); +} + // After loss based bwe backs off, the estimate is bounded during the delayed // window. TEST_F(LossBasedBweV2Test, @@ -1007,164 +1054,6 @@ TEST_F(LossBasedBweV2Test, DataRate::KilobitsPerSec(600)); } -TEST_F(LossBasedBweV2Test, - StricterBoundUsingHighLossRateThresholdAt10pLossRate) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.09")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_10p_loss_1 = - CreatePacketResultsWith10pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_10p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_10p_loss_2 = - CreatePacketResultsWith10pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_10p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // At 10% loss rate and high loss rate threshold to be 10%, cap the estimate - // to be 500 * 1000-0.1 = 400kbps. - EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(400)); -} - -TEST_F(LossBasedBweV2Test, - StricterBoundUsingHighLossRateThresholdAt50pLossRate) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.3")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_50p_loss_1 = - CreatePacketResultsWith50pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_50p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_50p_loss_2 = - CreatePacketResultsWith50pPacketLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_50p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // At 50% loss rate and high loss rate threshold to be 30%, cap the estimate - // to be the min bitrate. - EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); -} - -TEST_F(LossBasedBweV2Test, - StricterBoundUsingHighLossRateThresholdAt100pLossRate) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.3")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_100p_loss_1 = - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_100p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_100p_loss_2 = - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_100p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // At 100% loss rate and high loss rate threshold to be 30%, cap the estimate - // to be the min bitrate. - EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); -} - -TEST_F(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) { - ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HighLossRateThreshold:0.3")); - LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); - loss_based_bandwidth_estimator.SetMinMaxBitrate( - /*min_bitrate=*/DataRate::KilobitsPerSec(10), - /*max_bitrate=*/DataRate::KilobitsPerSec(1000000)); - DataRate delay_based_estimate = DataRate::KilobitsPerSec(5000); - loss_based_bandwidth_estimator.SetBandwidthEstimate( - DataRate::KilobitsPerSec(600)); - - std::vector enough_feedback_100p_loss_1 = - CreatePacketResultsWith100pLossRate( - /*first_packet_timestamp=*/Timestamp::Zero()); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_100p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - // Make sure that the estimate is set to min bitrate because of 100% loss - // rate. - EXPECT_EQ( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); - - // Create some feedbacks with 0 loss rate to simulate network recovering. - std::vector enough_feedback_0p_loss_1 = - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_0p_loss_1, delay_based_estimate, - - /*in_alr=*/false); - - std::vector enough_feedback_0p_loss_2 = - CreatePacketResultsWithReceivedPackets( - /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * 2); - loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_0p_loss_2, delay_based_estimate, - - /*in_alr=*/false); - - // The estimate increases as network recovers. - EXPECT_GT( - loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - DataRate::KilobitsPerSec(10)); -} - TEST_F(LossBasedBweV2Test, EstimateIsNotHigherThanMaxBitrate) { ExplicitKeyValueConfig key_value_config( Config(/*enabled=*/true, /*valid=*/true)); @@ -1494,6 +1383,92 @@ TEST_F(LossBasedBweV2Test, IncreaseUsingPaddingStateIfFieldTrial) { LossBasedState::kIncreaseUsingPadding); } +TEST_F(LossBasedBweV2Test, BestCandidateResetsToUpperBoundInFieldTrial) { + ExplicitKeyValueConfig key_value_config( + ShortObservationConfig("PaddingDuration:1000ms,BoundBestCandidate:true")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(2500)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith50pPacketLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + LossBasedBweV2::Result result_after_loss = + loss_based_bandwidth_estimator.GetLossBasedResult(); + ASSERT_EQ(result_after_loss.state, LossBasedState::kDecreasing); + + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + 2 * kObservationDurationLowerBound), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + // After a BWE decrease due to large loss, BWE is expected to ramp up slowly + // and follow the acked bitrate. + EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kIncreaseUsingPadding); + EXPECT_NEAR(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate.kbps(), + result_after_loss.bandwidth_estimate.kbps(), 100); +} + +TEST_F(LossBasedBweV2Test, DecreaseToAckedCandidateIfPaddingInAlr) { + ExplicitKeyValueConfig key_value_config(ShortObservationConfig( + "PaddingDuration:1000ms," + // Set InstantUpperBoundBwBalance high to disable InstantUpperBound cap. + "InstantUpperBoundBwBalance:10000kbps")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(1000)); + int feedback_id = 0; + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kDecreasing) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + feedback_id++; + } + + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kIncreaseUsingPadding) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + feedback_id++; + } + ASSERT_GT( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(900)); + + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(100)); + // Padding is sent now, create some lost packets. + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/true); + EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kDecreasing); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(100)); +} + TEST_F(LossBasedBweV2Test, DecreaseAfterPadding) { ExplicitKeyValueConfig key_value_config(ShortObservationConfig( "PaddingDuration:1000ms,BwRampupUpperBoundFactor:2.0")); @@ -1580,7 +1555,7 @@ TEST_F(LossBasedBweV2Test, IncreaseEstimateIfNotHold) { TEST_F(LossBasedBweV2Test, IncreaseEstimateAfterHoldDuration) { ExplicitKeyValueConfig key_value_config( - ShortObservationConfig("HoldDurationFactor:3")); + ShortObservationConfig("HoldDurationFactor:10")); LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(2500)); @@ -1629,36 +1604,126 @@ TEST_F(LossBasedBweV2Test, IncreaseEstimateAfterHoldDuration) { /*in_alr=*/false); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, LossBasedState::kDecreasing); - estimate = + DataRate estimate_at_hold = loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate; - // During the hold duration, e.g. next 900ms, the estimate cannot increase. + // In the hold duration, e.g. next 3s, the estimate cannot increase above the + // hold rate. Get some lost packets to get lower estimate than the HOLD rate. for (int i = 4; i <= 6; ++i) { loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( + CreatePacketResultsWith100pLossRate( /*first_packet_timestamp=*/Timestamp::Zero() + kObservationDurationLowerBound * i), /*delay_based_estimate=*/DataRate::PlusInfinity(), /*in_alr=*/false); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, LossBasedState::kDecreasing); - EXPECT_EQ( + EXPECT_LT( loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate); + estimate_at_hold); + } + + int feedback_id = 7; + while (loss_based_bandwidth_estimator.GetLossBasedResult().state != + LossBasedState::kIncreasing) { + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * feedback_id), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + if (loss_based_bandwidth_estimator.GetLossBasedResult().state == + LossBasedState::kDecreasing) { + // In the hold duration, the estimate can not go higher than estimate at + // hold. + EXPECT_LE(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate, + estimate_at_hold); + } else if (loss_based_bandwidth_estimator.GetLossBasedResult().state == + LossBasedState::kIncreasing) { + // After the hold duration, the estimate can increase again. + EXPECT_GT(loss_based_bandwidth_estimator.GetLossBasedResult() + .bandwidth_estimate, + estimate_at_hold); + } + feedback_id++; } +} - // After the hold duration, the estimate can increase again. +TEST_F(LossBasedBweV2Test, HoldRateNotLowerThanAckedRate) { + ExplicitKeyValueConfig key_value_config(ShortObservationConfig( + "HoldDurationFactor:10,LowerBoundByAckedRateFactor:1.0")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(2500)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - CreatePacketResultsWithReceivedPackets( + CreatePacketResultsWith50pPacketLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + ASSERT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, + LossBasedState::kDecreasing); + + // During the hold duration, hold rate is not lower than the acked rate. + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(1000)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith50pPacketLossRate( /*first_packet_timestamp=*/Timestamp::Zero() + - kObservationDurationLowerBound * 7), + kObservationDurationLowerBound), /*delay_based_estimate=*/DataRate::PlusInfinity(), /*in_alr=*/false); EXPECT_EQ(loss_based_bandwidth_estimator.GetLossBasedResult().state, - LossBasedState::kIncreasing); - EXPECT_GE( + LossBasedState::kDecreasing); + EXPECT_EQ( loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, - estimate); + DataRate::KilobitsPerSec(1000)); +} + +TEST_F(LossBasedBweV2Test, EstimateNotLowerThanAckedRate) { + ExplicitKeyValueConfig key_value_config( + ShortObservationConfig("LowerBoundByAckedRateFactor:1.0")); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(2500)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero()), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + ASSERT_LT( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(1000)); + + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(1000)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWith100pLossRate( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + EXPECT_EQ( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(1000)); + + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * 2), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + CreatePacketResultsWithReceivedPackets( + /*first_packet_timestamp=*/Timestamp::Zero() + + kObservationDurationLowerBound * 3), + /*delay_based_estimate=*/DataRate::PlusInfinity(), + /*in_alr=*/false); + + // Verify that the estimate recovers from the acked rate. + EXPECT_GT( + loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate, + DataRate::KilobitsPerSec(1000)); } TEST_F(LossBasedBweV2Test, EndHoldDurationIfDelayBasedEstimateWorks) { diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build index 703c22a590..049ac6f477 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/probe_controller_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build index 291502c95a..6e1d0acff5 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/pushback_controller_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc index b09cb22f49..22693d67e9 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -203,9 +203,9 @@ TimeDelta RttBasedBackoff::CorrectedRtt() const { RttBasedBackoff::~RttBasedBackoff() = default; SendSideBandwidthEstimation::SendSideBandwidthEstimation( - const FieldTrialsView* key_value_config, - RtcEventLog* event_log) - : rtt_backoff_(key_value_config), + const FieldTrialsView* key_value_config, RtcEventLog* event_log) + : key_value_config_(key_value_config), + rtt_backoff_(key_value_config), lost_packets_since_last_loss_update_(0), expected_packets_since_last_loss_update_(0), current_target_(DataRate::Zero()), @@ -234,7 +234,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation( high_loss_threshold_(kDefaultHighLossThreshold), bitrate_threshold_(kDefaultBitrateThreshold), loss_based_bandwidth_estimator_v1_(key_value_config), - loss_based_bandwidth_estimator_v2_(key_value_config), + loss_based_bandwidth_estimator_v2_(new LossBasedBweV2(key_value_config)), loss_based_state_(LossBasedState::kDelayBasedEstimate), disable_receiver_limit_caps_only_("Disabled") { RTC_DCHECK(event_log); @@ -252,7 +252,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation( ParseFieldTrial({&disable_receiver_limit_caps_only_}, key_value_config->Lookup("WebRTC-Bwe-ReceiverLimitCapsOnly")); if (LossBasedBandwidthEstimatorV2Enabled()) { - loss_based_bandwidth_estimator_v2_.SetMinMaxBitrate( + loss_based_bandwidth_estimator_v2_->SetMinMaxBitrate( min_bitrate_configured_, max_bitrate_configured_); } } @@ -281,6 +281,10 @@ void SendSideBandwidthEstimation::OnRouteChange() { uma_update_state_ = kNoUpdate; uma_rtt_state_ = kNoUpdate; last_rtc_event_log_ = Timestamp::MinusInfinity(); + if (loss_based_bandwidth_estimator_v2_->UseInStartPhase()) { + loss_based_bandwidth_estimator_v2_.reset( + new LossBasedBweV2(key_value_config_)); + } } void SendSideBandwidthEstimation::SetBitrates( @@ -315,8 +319,8 @@ void SendSideBandwidthEstimation::SetMinMaxBitrate(DataRate min_bitrate, } else { max_bitrate_configured_ = kDefaultMaxBitrate; } - loss_based_bandwidth_estimator_v2_.SetMinMaxBitrate(min_bitrate_configured_, - max_bitrate_configured_); + loss_based_bandwidth_estimator_v2_->SetMinMaxBitrate(min_bitrate_configured_, + max_bitrate_configured_); } int SendSideBandwidthEstimation::GetMinBitrate() const { @@ -371,7 +375,7 @@ void SendSideBandwidthEstimation::SetAcknowledgedRate( *acknowledged_rate, at_time); } if (LossBasedBandwidthEstimatorV2Enabled()) { - loss_based_bandwidth_estimator_v2_.SetAcknowledgedBitrate( + loss_based_bandwidth_estimator_v2_->SetAcknowledgedBitrate( *acknowledged_rate); } } @@ -386,7 +390,7 @@ void SendSideBandwidthEstimation::UpdateLossBasedEstimator( report.packet_feedbacks, report.feedback_time); } if (LossBasedBandwidthEstimatorV2Enabled()) { - loss_based_bandwidth_estimator_v2_.UpdateBandwidthEstimate( + loss_based_bandwidth_estimator_v2_->UpdateBandwidthEstimate( report.packet_feedbacks, delay_based_limit_, in_alr); UpdateEstimate(report.feedback_time); } @@ -492,7 +496,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) { // We trust the REMB and/or delay-based estimate during the first 2 seconds if // we haven't had any packet loss reported, to allow startup bitrate probing. if (last_fraction_loss_ == 0 && IsInStartPhase(at_time) && - !loss_based_bandwidth_estimator_v2_.ReadyToUseInStartPhase()) { + !loss_based_bandwidth_estimator_v2_->ReadyToUseInStartPhase()) { DataRate new_bitrate = current_target_; // TODO(srte): We should not allow the new_bitrate to be larger than the // receiver limit here. @@ -534,7 +538,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) { if (LossBasedBandwidthEstimatorV2ReadyForUse()) { LossBasedBweV2::Result result = - loss_based_bandwidth_estimator_v2_.GetLossBasedResult(); + loss_based_bandwidth_estimator_v2_->GetLossBasedResult(); loss_based_state_ = result.state; UpdateTargetBitrate(result.bandwidth_estimate, at_time); return; @@ -690,13 +694,13 @@ bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV1ReadyForUse() } bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV2Enabled() const { - return loss_based_bandwidth_estimator_v2_.IsEnabled(); + return loss_based_bandwidth_estimator_v2_->IsEnabled(); } bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV2ReadyForUse() const { return LossBasedBandwidthEstimatorV2Enabled() && - loss_based_bandwidth_estimator_v2_.IsReady(); + loss_based_bandwidth_estimator_v2_->IsReady(); } } // namespace webrtc diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h index 3a4efc47c7..dd4d25a236 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -167,6 +168,7 @@ class SendSideBandwidthEstimation { bool LossBasedBandwidthEstimatorV1ReadyForUse() const; bool LossBasedBandwidthEstimatorV2ReadyForUse() const; + const FieldTrialsView* key_value_config_; RttBasedBackoff rtt_backoff_; LinkCapacityTracker link_capacity_; @@ -208,7 +210,7 @@ class SendSideBandwidthEstimation { float high_loss_threshold_; DataRate bitrate_threshold_; LossBasedBandwidthEstimation loss_based_bandwidth_estimator_v1_; - LossBasedBweV2 loss_based_bandwidth_estimator_v2_; + std::unique_ptr loss_based_bandwidth_estimator_v2_; LossBasedState loss_based_state_; FieldTrialFlag disable_receiver_limit_caps_only_; }; diff --git a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build index d83d51f985..08cfdec69b 100644 --- a/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/goog_cc/send_side_bwe_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build index 7e8cb87820..62800e263d 100644 --- a/third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/rtp/control_handler_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build b/third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build index 40ead5619c..41f64326b2 100644 --- a/third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build +++ b/third_party/libwebrtc/modules/congestion_controller/rtp/transport_feedback_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc index 40764de7ae..81caa9bd2d 100644 --- a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc +++ b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc @@ -112,6 +112,7 @@ void BaseCapturerPipeWire::OnScreenCastSessionClosed() { if (!capturer_failed_) { options_.screencast_stream()->StopScreenCastStream(); } + capturer_failed_ = true; } void BaseCapturerPipeWire::UpdateResolution(uint32_t width, uint32_t height) { diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index 61c6957d27..473f913466 100644 --- a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -14,7 +14,6 @@ #include #include #include -#include #include @@ -49,33 +48,6 @@ constexpr int CursorMetaSize(int w, int h) { constexpr PipeWireVersion kDmaBufModifierMinVersion = {0, 3, 33}; constexpr PipeWireVersion kDropSingleModifierMinVersion = {0, 3, 40}; -class ScopedBuf { - public: - ScopedBuf() {} - ScopedBuf(uint8_t* map, int map_size, int fd) - : map_(map), map_size_(map_size), fd_(fd) {} - ~ScopedBuf() { - if (map_ != MAP_FAILED) { - munmap(map_, map_size_); - } - } - - explicit operator bool() { return map_ != MAP_FAILED; } - - void initialize(uint8_t* map, int map_size, int fd) { - map_ = map; - map_size_ = map_size; - fd_ = fd; - } - - uint8_t* get() { return map_; } - - protected: - uint8_t* map_ = static_cast(MAP_FAILED); - int map_size_; - int fd_; -}; - class SharedScreenCastStreamPrivate { public: SharedScreenCastStreamPrivate(); diff --git a/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_provider.h b/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_provider.h index aad28d2f30..64ef5750ec 100644 --- a/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_provider.h +++ b/third_party/libwebrtc/modules/desktop_capture/mac/desktop_frame_provider.h @@ -46,6 +46,8 @@ class DesktopFrameProvider { // Expected to be called before stopping the CGDisplayStreamRef streams. void Release(); + bool allow_iosurface() const { return allow_iosurface_; } + private: SequenceChecker thread_checker_; const bool allow_iosurface_; diff --git a/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm b/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm index 1f4a62f7cd..785a15dfa4 100644 --- a/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm +++ b/third_party/libwebrtc/modules/desktop_capture/mac/screen_capturer_mac.mm @@ -442,6 +442,10 @@ void ScreenCapturerMac::ScreenConfigurationChanged() { bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() { RTC_DCHECK(thread_checker_.IsCurrent()); + if (!desktop_frame_provider_.allow_iosurface()) { + return true; + } + desktop_config_ = desktop_config_monitor_->desktop_configuration(); for (const auto& config : desktop_config_.displays) { size_t pixel_width = config.pixel_bounds.width(); diff --git a/third_party/libwebrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h b/third_party/libwebrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h index 2b1e0ab041..815986f680 100644 --- a/third_party/libwebrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h +++ b/third_party/libwebrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h @@ -132,7 +132,7 @@ class RTC_EXPORT DxgiDuplicatorController { // scoped_refptr accesses private AddRef() and // Release() functions. - friend class rtc::scoped_refptr; + friend class webrtc::scoped_refptr; // A private constructor to ensure consumers to use // DxgiDuplicatorController::Instance(). diff --git a/third_party/libwebrtc/modules/module_api_gn/moz.build b/third_party/libwebrtc/modules/module_api_gn/moz.build index d61cca4a48..7613736af2 100644 --- a/third_party/libwebrtc/modules/module_api_gn/moz.build +++ b/third_party/libwebrtc/modules/module_api_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/module_api_public_gn/moz.build b/third_party/libwebrtc/modules/module_api_public_gn/moz.build index 45518d1a8a..c40e3cf5e9 100644 --- a/third_party/libwebrtc/modules/module_api_public_gn/moz.build +++ b/third_party/libwebrtc/modules/module_api_public_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/module_fec_api_gn/moz.build b/third_party/libwebrtc/modules/module_fec_api_gn/moz.build index 7b4274f1b8..86a280e5cc 100644 --- a/third_party/libwebrtc/modules/module_fec_api_gn/moz.build +++ b/third_party/libwebrtc/modules/module_fec_api_gn/moz.build @@ -176,16 +176,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build b/third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build index a528123ae0..8bb44ecf62 100644 --- a/third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build +++ b/third_party/libwebrtc/modules/pacing/interval_budget_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/pacing/pacing_controller.cc b/third_party/libwebrtc/modules/pacing/pacing_controller.cc index 13ff9a2a95..5b81207d56 100644 --- a/third_party/libwebrtc/modules/pacing/pacing_controller.cc +++ b/third_party/libwebrtc/modules/pacing/pacing_controller.cc @@ -73,7 +73,7 @@ PacingController::PacingController(Clock* clock, keyframe_flushing_( IsEnabled(field_trials_, "WebRTC-Pacer-KeyframeFlushing")), transport_overhead_per_packet_(DataSize::Zero()), - send_burst_interval_(TimeDelta::Zero()), + send_burst_interval_(kDefaultBurstInterval), last_timestamp_(clock_->CurrentTime()), paused_(false), media_debt_(DataSize::Zero()), diff --git a/third_party/libwebrtc/modules/pacing/pacing_controller.h b/third_party/libwebrtc/modules/pacing/pacing_controller.h index dd5636ccef..04e0a820f9 100644 --- a/third_party/libwebrtc/modules/pacing/pacing_controller.h +++ b/third_party/libwebrtc/modules/pacing/pacing_controller.h @@ -25,6 +25,7 @@ #include "api/transport/field_trial_based_config.h" #include "api/transport/network_types.h" #include "api/units/data_size.h" +#include "api/units/time_delta.h" #include "modules/pacing/bitrate_prober.h" #include "modules/pacing/interval_budget.h" #include "modules/pacing/prioritized_packet_queue.h" @@ -92,6 +93,10 @@ class PacingController { // the send burst interval. // Ex: max send burst interval = 63Kb / 10Mbit/s = 50ms. static constexpr DataSize kMaxBurstSize = DataSize::Bytes(63 * 1000); + // The pacer is allowed to send enqued packets in bursts and can build up a + // packet "debt" that correspond to approximately the send rate during + // the burst interval. + static constexpr TimeDelta kDefaultBurstInterval = TimeDelta::Millis(40); PacingController(Clock* clock, PacketSender* packet_sender, diff --git a/third_party/libwebrtc/modules/pacing/pacing_controller_unittest.cc b/third_party/libwebrtc/modules/pacing/pacing_controller_unittest.cc index ba93d05bb7..9e6ede6dc0 100644 --- a/third_party/libwebrtc/modules/pacing/pacing_controller_unittest.cc +++ b/third_party/libwebrtc/modules/pacing/pacing_controller_unittest.cc @@ -427,6 +427,7 @@ TEST_F(PacingControllerTest, BudgetAffectsAudioInTrial) { DataRate pacing_rate = DataRate::BitsPerSec(kPacketSize / 3 * 8 * kProcessIntervalsPerSecond); pacer.SetPacingRates(pacing_rate, DataRate::Zero()); + pacer.SetSendBurstInterval(TimeDelta::Zero()); // Video fills budget for following process periods. pacer.EnqueuePacket(video_.BuildNextPacket(kPacketSize)); EXPECT_CALL(callback_, SendPacket).Times(1); @@ -484,7 +485,7 @@ TEST_F(PacingControllerTest, FirstSentPacketTimeIsSet) { EXPECT_EQ(kStartTime, pacer->FirstSentPacketTime()); } -TEST_F(PacingControllerTest, QueueAndPacePackets) { +TEST_F(PacingControllerTest, QueueAndPacePacketsWithZeroBurstPeriod) { const uint32_t kSsrc = 12345; uint16_t sequence_number = 1234; const DataSize kPackeSize = DataSize::Bytes(250); @@ -495,6 +496,7 @@ TEST_F(PacingControllerTest, QueueAndPacePackets) { const size_t kPacketsToSend = (kSendInterval * kTargetRate).bytes() * kPaceMultiplier / kPackeSize.bytes(); auto pacer = std::make_unique(&clock_, &callback_, trials_); + pacer->SetSendBurstInterval(TimeDelta::Zero()); pacer->SetPacingRates(kTargetRate * kPaceMultiplier, DataRate::Zero()); for (size_t i = 0; i < kPacketsToSend; ++i) { @@ -536,30 +538,30 @@ TEST_F(PacingControllerTest, PaceQueuedPackets) { auto pacer = std::make_unique(&clock_, &callback_, trials_); pacer->SetPacingRates(kTargetRate * kPaceMultiplier, DataRate::Zero()); - // Due to the multiplicative factor we can send 5 packets during a send - // interval. (network capacity * multiplier / (8 bits per byte * - // (packet size * #send intervals per second) - const size_t packets_to_send_per_interval = - kTargetRate.bps() * kPaceMultiplier / (8 * kPacketSize * 200); - for (size_t i = 0; i < packets_to_send_per_interval; ++i) { + const size_t packets_to_send_per_burst_interval = + (kTargetRate * kPaceMultiplier * PacingController::kDefaultBurstInterval) + .bytes() / + kPacketSize; + for (size_t i = 0; i < packets_to_send_per_burst_interval; ++i) { SendAndExpectPacket(pacer.get(), RtpPacketMediaType::kVideo, ssrc, sequence_number++, clock_.TimeInMilliseconds(), kPacketSize); } - for (size_t j = 0; j < packets_to_send_per_interval * 10; ++j) { + for (size_t j = 0; j < packets_to_send_per_burst_interval * 10; ++j) { pacer->EnqueuePacket(BuildPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, clock_.TimeInMilliseconds(), kPacketSize)); } - EXPECT_EQ(packets_to_send_per_interval + packets_to_send_per_interval * 10, + EXPECT_EQ(packets_to_send_per_burst_interval + + packets_to_send_per_burst_interval * 10, pacer->QueueSizePackets()); - while (pacer->QueueSizePackets() > packets_to_send_per_interval * 10) { + while (pacer->QueueSizePackets() > packets_to_send_per_burst_interval * 10) { AdvanceTimeUntil(pacer->NextSendTime()); pacer->ProcessPackets(); } - EXPECT_EQ(pacer->QueueSizePackets(), packets_to_send_per_interval * 10); + EXPECT_EQ(pacer->QueueSizePackets(), packets_to_send_per_burst_interval * 10); EXPECT_CALL(callback_, SendPadding).Times(0); EXPECT_CALL(callback_, SendPacket(ssrc, _, _, false, false)) @@ -582,12 +584,12 @@ TEST_F(PacingControllerTest, PaceQueuedPackets) { pacer->ProcessPackets(); // Send some more packet, just show that we can..? - for (size_t i = 0; i < packets_to_send_per_interval; ++i) { + for (size_t i = 0; i < packets_to_send_per_burst_interval; ++i) { SendAndExpectPacket(pacer.get(), RtpPacketMediaType::kVideo, ssrc, sequence_number++, clock_.TimeInMilliseconds(), 250); } - EXPECT_EQ(packets_to_send_per_interval, pacer->QueueSizePackets()); - for (size_t i = 0; i < packets_to_send_per_interval; ++i) { + EXPECT_EQ(packets_to_send_per_burst_interval, pacer->QueueSizePackets()); + for (size_t i = 0; i < packets_to_send_per_burst_interval; ++i) { AdvanceTimeUntil(pacer->NextSendTime()); pacer->ProcessPackets(); } @@ -641,19 +643,23 @@ TEST_F(PacingControllerTest, TEST_F(PacingControllerTest, Padding) { uint32_t ssrc = 12345; uint16_t sequence_number = 1234; - const size_t kPacketSize = 250; + const size_t kPacketSize = 1000; auto pacer = std::make_unique(&clock_, &callback_, trials_); pacer->SetPacingRates(kTargetRate * kPaceMultiplier, kTargetRate); - const size_t kPacketsToSend = 20; + const size_t kPacketsToSend = 30; for (size_t i = 0; i < kPacketsToSend; ++i) { SendAndExpectPacket(pacer.get(), RtpPacketMediaType::kVideo, ssrc, sequence_number++, clock_.TimeInMilliseconds(), kPacketSize); } + + int expected_bursts = + floor(DataSize::Bytes(pacer->QueueSizePackets() * kPacketSize) / + (kPaceMultiplier * kTargetRate) / + PacingController::kDefaultBurstInterval); const TimeDelta expected_pace_time = - DataSize::Bytes(pacer->QueueSizePackets() * kPacketSize) / - (kPaceMultiplier * kTargetRate); + (expected_bursts - 1) * PacingController::kDefaultBurstInterval; EXPECT_CALL(callback_, SendPadding).Times(0); // Only the media packets should be sent. Timestamp start_time = clock_.CurrentTime(); @@ -663,7 +669,7 @@ TEST_F(PacingControllerTest, Padding) { } const TimeDelta actual_pace_time = clock_.CurrentTime() - start_time; EXPECT_LE((actual_pace_time - expected_pace_time).Abs(), - PacingController::kMinSleepTime); + PacingController::kDefaultBurstInterval); // Pacing media happens at 2.5x, but padding was configured with 1.0x // factor. We have to wait until the padding debt is gone before we start @@ -766,8 +772,8 @@ TEST_F(PacingControllerTest, VerifyAverageBitrateVaryingMediaPayload) { media_payload)); media_bytes += media_payload; } - - AdvanceTimeUntil(pacer->NextSendTime()); + AdvanceTimeUntil(std::min(clock_.CurrentTime() + TimeDelta::Millis(20), + pacer->NextSendTime())); pacer->ProcessPackets(); } @@ -805,20 +811,18 @@ TEST_F(PacingControllerTest, Priority) { // Expect all high and normal priority to be sent out first. EXPECT_CALL(callback_, SendPadding).Times(0); + testing::Sequence s; EXPECT_CALL(callback_, SendPacket(ssrc, _, capture_time_ms, _, _)) - .Times(packets_to_send_per_interval + 1); + .Times(packets_to_send_per_interval + 1) + .InSequence(s); + EXPECT_CALL(callback_, SendPacket(ssrc_low_priority, _, + capture_time_ms_low_priority, _, _)) + .InSequence(s); - while (pacer->QueueSizePackets() > 1) { + while (pacer->QueueSizePackets() > 0) { AdvanceTimeUntil(pacer->NextSendTime()); pacer->ProcessPackets(); } - - EXPECT_EQ(1u, pacer->QueueSizePackets()); - - EXPECT_CALL(callback_, SendPacket(ssrc_low_priority, _, - capture_time_ms_low_priority, _, _)); - AdvanceTimeUntil(pacer->NextSendTime()); - pacer->ProcessPackets(); } TEST_F(PacingControllerTest, RetransmissionPriority) { @@ -829,23 +833,22 @@ TEST_F(PacingControllerTest, RetransmissionPriority) { auto pacer = std::make_unique(&clock_, &callback_, trials_); pacer->SetPacingRates(kTargetRate * kPaceMultiplier, DataRate::Zero()); - // Due to the multiplicative factor we can send 5 packets during a send - // interval. (network capacity * multiplier / (8 bits per byte * - // (packet size * #send intervals per second) - const size_t packets_to_send_per_interval = - kTargetRate.bps() * kPaceMultiplier / (8 * 250 * 200); + const size_t packets_to_send_per_burst_interval = + (kTargetRate * kPaceMultiplier * PacingController::kDefaultBurstInterval) + .bytes() / + 250; pacer->ProcessPackets(); EXPECT_EQ(0u, pacer->QueueSizePackets()); // Alternate retransmissions and normal packets. - for (size_t i = 0; i < packets_to_send_per_interval; ++i) { + for (size_t i = 0; i < packets_to_send_per_burst_interval; ++i) { pacer->EnqueuePacket(BuildPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, capture_time_ms, 250)); pacer->EnqueuePacket(BuildPacket(RtpPacketMediaType::kRetransmission, ssrc, sequence_number++, capture_time_ms_retransmission, 250)); } - EXPECT_EQ(2 * packets_to_send_per_interval, pacer->QueueSizePackets()); + EXPECT_EQ(2 * packets_to_send_per_burst_interval, pacer->QueueSizePackets()); // Expect all retransmissions to be sent out first despite having a later // capture time. @@ -853,19 +856,19 @@ TEST_F(PacingControllerTest, RetransmissionPriority) { EXPECT_CALL(callback_, SendPacket(_, _, _, false, _)).Times(0); EXPECT_CALL(callback_, SendPacket(ssrc, _, capture_time_ms_retransmission, true, _)) - .Times(packets_to_send_per_interval); + .Times(packets_to_send_per_burst_interval); - while (pacer->QueueSizePackets() > packets_to_send_per_interval) { + while (pacer->QueueSizePackets() > packets_to_send_per_burst_interval) { AdvanceTimeUntil(pacer->NextSendTime()); pacer->ProcessPackets(); } - EXPECT_EQ(packets_to_send_per_interval, pacer->QueueSizePackets()); + EXPECT_EQ(packets_to_send_per_burst_interval, pacer->QueueSizePackets()); // Expect the remaining (non-retransmission) packets to be sent. EXPECT_CALL(callback_, SendPadding).Times(0); EXPECT_CALL(callback_, SendPacket(_, _, _, true, _)).Times(0); EXPECT_CALL(callback_, SendPacket(ssrc, _, capture_time_ms, false, _)) - .Times(packets_to_send_per_interval); + .Times(packets_to_send_per_burst_interval); while (pacer->QueueSizePackets() > 0) { AdvanceTimeUntil(pacer->NextSendTime()); @@ -890,13 +893,13 @@ TEST_F(PacingControllerTest, HighPrioDoesntAffectBudget) { sequence_number++, capture_time_ms, kPacketSize); } pacer->ProcessPackets(); + EXPECT_EQ(pacer->QueueSizePackets(), 0u); // Low prio packets does affect the budget. - // Due to the multiplicative factor we can send 5 packets during a send - // interval. (network capacity * multiplier / (8 bits per byte * - // (packet size * #send intervals per second) - const size_t kPacketsToSendPerInterval = - kTargetRate.bps() * kPaceMultiplier / (8 * kPacketSize * 200); - for (size_t i = 0; i < kPacketsToSendPerInterval; ++i) { + const size_t kPacketsToSendPerBurstInterval = + (kTargetRate * kPaceMultiplier * PacingController::kDefaultBurstInterval) + .bytes() / + kPacketSize; + for (size_t i = 0; i < kPacketsToSendPerBurstInterval; ++i) { SendAndExpectPacket(pacer.get(), RtpPacketMediaType::kVideo, ssrc, sequence_number++, clock_.TimeInMilliseconds(), kPacketSize); @@ -904,16 +907,16 @@ TEST_F(PacingControllerTest, HighPrioDoesntAffectBudget) { // Send all packets and measure pace time. Timestamp start_time = clock_.CurrentTime(); + EXPECT_EQ(pacer->NextSendTime(), clock_.CurrentTime()); while (pacer->QueueSizePackets() > 0) { AdvanceTimeUntil(pacer->NextSendTime()); pacer->ProcessPackets(); } - // Measure pacing time. Expect only low-prio packets to affect this. + // Measure pacing time. TimeDelta pacing_time = clock_.CurrentTime() - start_time; - TimeDelta expected_pacing_time = - DataSize::Bytes(kPacketsToSendPerInterval * kPacketSize) / - (kTargetRate * kPaceMultiplier); + // All packets sent in one burst since audio packets are not accounted for. + TimeDelta expected_pacing_time = TimeDelta::Zero(); EXPECT_NEAR(pacing_time.us(), expected_pacing_time.us(), PacingController::kMinSleepTime.us()); } @@ -965,6 +968,7 @@ TEST_F(PacingControllerTest, DoesNotAllowOveruseAfterCongestion) { auto now_ms = [this] { return clock_.TimeInMilliseconds(); }; auto pacer = std::make_unique(&clock_, &callback_, trials_); pacer->SetPacingRates(kTargetRate * kPaceMultiplier, DataRate::Zero()); + pacer->SetSendBurstInterval(TimeDelta::Zero()); EXPECT_CALL(callback_, SendPadding).Times(0); // The pacing rate is low enough that the budget should not allow two packets // to be sent in a row. @@ -1853,6 +1857,7 @@ TEST_F(PacingControllerTest, AccountsForAudioEnqueueTime) { // Audio not paced, but still accounted for in budget. pacer->SetAccountForAudioPackets(true); pacer->SetPacingRates(kPacingDataRate, kPaddingDataRate); + pacer->SetSendBurstInterval(TimeDelta::Zero()); // Enqueue two audio packets, advance clock to where one packet // should have drained the buffer already, has they been sent @@ -1898,13 +1903,12 @@ TEST_F(PacingControllerTest, NextSendTimeAccountsForPadding) { EXPECT_EQ(pacer->NextSendTime() - clock_.CurrentTime(), PacingController::kPausedProcessInterval); - // Enqueue a new packet, that can't be sent until previous buffer has - // drained. + // Enqueue a new packet, that can be sent immediately due to default burst + // rate is 40ms. SendAndExpectPacket(pacer.get(), RtpPacketMediaType::kVideo, kSsrc, sequnce_number++, clock_.TimeInMilliseconds(), kPacketSize.bytes()); - EXPECT_EQ(pacer->NextSendTime() - clock_.CurrentTime(), kPacketPacingTime); - clock_.AdvanceTime(kPacketPacingTime); + EXPECT_EQ(pacer->NextSendTime() - clock_.CurrentTime(), TimeDelta::Zero()); pacer->ProcessPackets(); ::testing::Mock::VerifyAndClearExpectations(&callback_); @@ -1916,11 +1920,13 @@ TEST_F(PacingControllerTest, NextSendTimeAccountsForPadding) { // previous debt has cleared. Since padding was disabled before, there // currently is no padding debt. pacer->SetPacingRates(kPacingDataRate, kPacingDataRate / 2); - EXPECT_EQ(pacer->NextSendTime() - clock_.CurrentTime(), kPacketPacingTime); + EXPECT_EQ(pacer->QueueSizePackets(), 0u); + EXPECT_LT(pacer->NextSendTime() - clock_.CurrentTime(), + PacingController::kDefaultBurstInterval); // Advance time, expect padding. EXPECT_CALL(callback_, SendPadding).WillOnce(Return(kPacketSize.bytes())); - clock_.AdvanceTime(kPacketPacingTime); + clock_.AdvanceTime(pacer->NextSendTime() - clock_.CurrentTime()); pacer->ProcessPackets(); ::testing::Mock::VerifyAndClearExpectations(&callback_); @@ -1933,7 +1939,7 @@ TEST_F(PacingControllerTest, NextSendTimeAccountsForPadding) { pacer->EnqueuePacket( BuildPacket(RtpPacketMediaType::kVideo, kSsrc, sequnce_number++, clock_.TimeInMilliseconds(), kPacketSize.bytes())); - EXPECT_EQ(pacer->NextSendTime() - clock_.CurrentTime(), kPacketPacingTime); + EXPECT_EQ(pacer->NextSendTime(), clock_.CurrentTime()); } TEST_F(PacingControllerTest, PaddingTargetAccountsForPaddingRate) { @@ -2011,8 +2017,8 @@ TEST_F(PacingControllerTest, SendsFecPackets) { TEST_F(PacingControllerTest, GapInPacingDoesntAccumulateBudget) { const uint32_t kSsrc = 12345; uint16_t sequence_number = 1234; - const DataSize kPackeSize = DataSize::Bytes(250); - const TimeDelta kPacketSendTime = TimeDelta::Millis(15); + const DataSize kPackeSize = DataSize::Bytes(1000); + const TimeDelta kPacketSendTime = TimeDelta::Millis(25); auto pacer = std::make_unique(&clock_, &callback_, trials_); pacer->SetPacingRates(kPackeSize / kPacketSendTime, @@ -2028,15 +2034,20 @@ TEST_F(PacingControllerTest, GapInPacingDoesntAccumulateBudget) { // Advance time kPacketSendTime past where the media debt should be 0. clock_.AdvanceTime(2 * kPacketSendTime); - // Enqueue two new packets. Expect only one to be sent one ProcessPackets(). + // Enqueue three new packets. Expect only two to be sent one ProcessPackets() + // since the default burst interval is 40ms. + SendAndExpectPacket(pacer.get(), RtpPacketMediaType::kVideo, kSsrc, + sequence_number++, clock_.TimeInMilliseconds(), + kPackeSize.bytes()); + SendAndExpectPacket(pacer.get(), RtpPacketMediaType::kVideo, kSsrc, + sequence_number++, clock_.TimeInMilliseconds(), + kPackeSize.bytes()); + EXPECT_CALL(callback_, SendPacket(kSsrc, sequence_number + 1, _, _, _)) + .Times(0); pacer->EnqueuePacket( BuildPacket(RtpPacketMediaType::kVideo, kSsrc, sequence_number + 1, clock_.TimeInMilliseconds(), kPackeSize.bytes())); - pacer->EnqueuePacket( - BuildPacket(RtpPacketMediaType::kVideo, kSsrc, sequence_number + 2, - clock_.TimeInMilliseconds(), kPackeSize.bytes())); - EXPECT_CALL(callback_, SendPacket(kSsrc, sequence_number + 1, - clock_.TimeInMilliseconds(), false, false)); + pacer->ProcessPackets(); } @@ -2044,6 +2055,7 @@ TEST_F(PacingControllerTest, HandlesSubMicrosecondSendIntervals) { static constexpr DataSize kPacketSize = DataSize::Bytes(1); static constexpr TimeDelta kPacketSendTime = TimeDelta::Micros(1); auto pacer = std::make_unique(&clock_, &callback_, trials_); + pacer->SetSendBurstInterval(TimeDelta::Zero()); // Set pacing rate such that a packet is sent in 0.5us. pacer->SetPacingRates(/*pacing_rate=*/2 * kPacketSize / kPacketSendTime, diff --git a/third_party/libwebrtc/modules/pacing/pacing_gn/moz.build b/third_party/libwebrtc/modules/pacing/pacing_gn/moz.build index 6b7f69865f..353f876c55 100644 --- a/third_party/libwebrtc/modules/pacing/pacing_gn/moz.build +++ b/third_party/libwebrtc/modules/pacing/pacing_gn/moz.build @@ -207,7 +207,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -217,10 +216,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.cc b/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.cc index afa36ea88d..f7218e48a1 100644 --- a/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.cc +++ b/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.cc @@ -17,35 +17,19 @@ #include "api/task_queue/pending_task_safety_flag.h" #include "api/transport/network_types.h" #include "rtc_base/checks.h" -#include "rtc_base/experiments/field_trial_parser.h" -#include "rtc_base/experiments/field_trial_units.h" #include "rtc_base/trace_event.h" namespace webrtc { -namespace { - -constexpr const char* kBurstyPacerFieldTrial = "WebRTC-BurstyPacer"; - -} // namespace - const int TaskQueuePacedSender::kNoPacketHoldback = -1; -TaskQueuePacedSender::BurstyPacerFlags::BurstyPacerFlags( - const FieldTrialsView& field_trials) - : burst("burst") { - ParseFieldTrial({&burst}, field_trials.Lookup(kBurstyPacerFieldTrial)); -} - TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, const FieldTrialsView& field_trials, TimeDelta max_hold_back_window, - int max_hold_back_window_in_packets, - absl::optional burst_interval) + int max_hold_back_window_in_packets) : clock_(clock), - bursty_pacer_flags_(field_trials), max_hold_back_window_(max_hold_back_window), max_hold_back_window_in_packets_(max_hold_back_window_in_packets), pacing_controller_(clock, packet_sender, field_trials), @@ -56,17 +40,6 @@ TaskQueuePacedSender::TaskQueuePacedSender( include_overhead_(false), task_queue_(TaskQueueBase::Current()) { RTC_DCHECK_GE(max_hold_back_window_, PacingController::kMinSleepTime); - // There are multiple field trials that can affect burst. If multiple bursts - // are specified we pick the largest of the values. - absl::optional burst = bursty_pacer_flags_.burst.GetOptional(); - // If not overriden by an experiment, the burst is specified by the - // `burst_interval` argument. - if (!burst.has_value()) { - burst = burst_interval; - } - if (burst.has_value()) { - pacing_controller_.SetSendBurstInterval(burst.value()); - } } TaskQueuePacedSender::~TaskQueuePacedSender() { @@ -74,6 +47,11 @@ TaskQueuePacedSender::~TaskQueuePacedSender() { is_shutdown_ = true; } +void TaskQueuePacedSender::SetSendBurstInterval(TimeDelta burst_interval) { + RTC_DCHECK_RUN_ON(task_queue_); + pacing_controller_.SetSendBurstInterval(burst_interval); +} + void TaskQueuePacedSender::EnsureStarted() { RTC_DCHECK_RUN_ON(task_queue_); is_started_ = true; diff --git a/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.h b/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.h index fd71be1654..e29acdf878 100644 --- a/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.h +++ b/third_party/libwebrtc/modules/pacing/task_queue_paced_sender.h @@ -45,23 +45,21 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { // processed. Increasing this reduces thread wakeups at the expense of higher // latency. // - // If the `burst_interval` parameter is set, the pacer is allowed to build up - // a packet "debt" that correspond to approximately the send rate during the - // specified interval. This greatly reduced wake ups by not pacing packets - // within the allowed burst budget. - // // The taskqueue used when constructing a TaskQueuePacedSender will also be // used for pacing. - TaskQueuePacedSender( - Clock* clock, - PacingController::PacketSender* packet_sender, - const FieldTrialsView& field_trials, - TimeDelta max_hold_back_window, - int max_hold_back_window_in_packets, - absl::optional burst_interval = absl::nullopt); + TaskQueuePacedSender(Clock* clock, + PacingController::PacketSender* packet_sender, + const FieldTrialsView& field_trials, + TimeDelta max_hold_back_window, + int max_hold_back_window_in_packets); ~TaskQueuePacedSender() override; + // The pacer is allowed to send enqued packets in bursts and can build up a + // packet "debt" that correspond to approximately the send rate during + // 'burst_interval'. + void SetSendBurstInterval(TimeDelta burst_interval); + // Ensure that necessary delayed tasks are scheduled. void EnsureStarted(); @@ -145,15 +143,6 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { Stats GetStats() const; Clock* const clock_; - struct BurstyPacerFlags { - // Parses `kBurstyPacerFieldTrial`. Example: - // --force-fieldtrials=WebRTC-BurstyPacer/burst:20ms/ - explicit BurstyPacerFlags(const FieldTrialsView& field_trials); - // If set, the pacer is allowed to build up a packet "debt" that correspond - // to approximately the send rate during the specified interval. - FieldTrialOptional burst; - }; - const BurstyPacerFlags bursty_pacer_flags_; // The holdback window prevents too frequent delayed MaybeProcessPackets() // calls. These are only applicable if `allow_low_precision` is false. diff --git a/third_party/libwebrtc/modules/pacing/task_queue_paced_sender_unittest.cc b/third_party/libwebrtc/modules/pacing/task_queue_paced_sender_unittest.cc index 54347493e7..f0a9ad78c2 100644 --- a/third_party/libwebrtc/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/third_party/libwebrtc/modules/pacing/task_queue_paced_sender_unittest.cc @@ -11,6 +11,7 @@ #include "modules/pacing/task_queue_paced_sender.h" #include +#include #include #include #include @@ -24,6 +25,7 @@ #include "api/units/data_rate.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" +#include "modules/pacing/pacing_controller.h" #include "modules/pacing/packet_router.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "test/gmock.h" @@ -33,6 +35,9 @@ using ::testing::_; using ::testing::AtLeast; +using ::testing::AtMost; +using ::testing::Lt; +using ::testing::NiceMock; using ::testing::Return; using ::testing::SaveArg; @@ -167,9 +172,10 @@ TEST(TaskQueuePacedSenderTest, PacesPacketsWithBurst) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, PacingController::kMinSleepTime, - TaskQueuePacedSender::kNoPacketHoldback, - // Half a second of bursting. - TimeDelta::Seconds(0.5)); + TaskQueuePacedSender::kNoPacketHoldback); + pacer.SetSendBurstInterval( + // Half a second of bursting. + TimeDelta::Seconds(0.5)); // Insert a number of packets, covering one second. static constexpr size_t kPacketsToSend = 42; @@ -262,7 +268,7 @@ TEST(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) { TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); - MockPacketRouter packet_router; + NiceMock packet_router; ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, @@ -270,21 +276,16 @@ TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { TaskQueuePacedSender::kNoPacketHoldback); const DataRate kPacingDataRate = DataRate::KilobitsPerSec(125); - const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); - const TimeDelta kPacketPacingTime = kPacketSize / kPacingDataRate; pacer.SetPacingRates(kPacingDataRate, DataRate::Zero()); pacer.EnsureStarted(); - // Add some initial video packets, only one should be sent. - EXPECT_CALL(packet_router, SendPacket); + // Add some initial video packets. Not all should be sent immediately. + EXPECT_CALL(packet_router, SendPacket).Times(AtMost(9)); pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 10)); time_controller.AdvanceTime(TimeDelta::Zero()); ::testing::Mock::VerifyAndClearExpectations(&packet_router); - // Advance time, but still before next packet should be sent. - time_controller.AdvanceTime(kPacketPacingTime / 2); - // Insert an audio packet, it should be sent immediately. EXPECT_CALL(packet_router, SendPacket); pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kAudio, 1)); @@ -295,12 +296,13 @@ TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { TEST(TaskQueuePacedSenderTest, SleepsDuringCoalscingWindow) { const TimeDelta kCoalescingWindow = TimeDelta::Millis(5); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); - MockPacketRouter packet_router; + NiceMock packet_router; ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, kCoalescingWindow, TaskQueuePacedSender::kNoPacketHoldback); + pacer.SetSendBurstInterval(TimeDelta::Zero()); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -310,9 +312,9 @@ TEST(TaskQueuePacedSenderTest, SleepsDuringCoalscingWindow) { pacer.SetPacingRates(kPacingDataRate, DataRate::Zero()); pacer.EnsureStarted(); - // Add 10 packets. The first should be sent immediately since the buffers - // are clear. - EXPECT_CALL(packet_router, SendPacket); + // Add 10 packets. The first burst should be sent immediately since the + // buffers are clear. + EXPECT_CALL(packet_router, SendPacket).Times(AtMost(9)); pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 10)); time_controller.AdvanceTime(TimeDelta::Zero()); ::testing::Mock::VerifyAndClearExpectations(&packet_router); @@ -370,11 +372,12 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSentTime) { ScopedKeyValueConfig trials( "WebRTC-Bwe-ProbingBehavior/min_probe_delta:1ms/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); - MockPacketRouter packet_router; + NiceMock packet_router; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); + pacer.SetSendBurstInterval(TimeDelta::Zero()); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -504,11 +507,12 @@ TEST(TaskQueuePacedSenderTest, PacketBasedCoalescing) { const int kPacketBasedHoldback = 5; GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); - MockPacketRouter packet_router; + NiceMock packet_router; ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, kFixedCoalescingWindow, kPacketBasedHoldback); + pacer.SetSendBurstInterval(TimeDelta::Zero()); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -559,6 +563,7 @@ TEST(TaskQueuePacedSenderTest, FixedHoldBackHasPriorityOverPackets) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, kFixedCoalescingWindow, kPacketBasedHoldback); + pacer.SetSendBurstInterval(TimeDelta::Zero()); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -691,7 +696,7 @@ TEST(TaskQueuePacedSenderTest, PostedPacketsNotSendFromRemovePacketsForSsrc) { TEST(TaskQueuePacedSenderTest, Stats) { static constexpr Timestamp kStartTime = Timestamp::Millis(1234); GlobalSimulatedTimeController time_controller(kStartTime); - MockPacketRouter packet_router; + NiceMock packet_router; ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, @@ -708,7 +713,8 @@ TEST(TaskQueuePacedSenderTest, Stats) { // Allowed `QueueSizeData` and `ExpectedQueueTime` deviation. static constexpr size_t kAllowedPacketsDeviation = 1; static constexpr DataSize kAllowedQueueSizeDeviation = - DataSize::Bytes(kDefaultPacketSize * kAllowedPacketsDeviation); + DataSize::Bytes(kDefaultPacketSize * kAllowedPacketsDeviation) + + kPacingRate * PacingController::kDefaultBurstInterval; static constexpr TimeDelta kAllowedQueueTimeDeviation = kAllowedQueueSizeDeviation / kPacingRate; diff --git a/third_party/libwebrtc/modules/portal/pipewire_utils.h b/third_party/libwebrtc/modules/portal/pipewire_utils.h index 8344a8cefb..c1327b85c9 100644 --- a/third_party/libwebrtc/modules/portal/pipewire_utils.h +++ b/third_party/libwebrtc/modules/portal/pipewire_utils.h @@ -11,6 +11,21 @@ #ifndef MODULES_PORTAL_PIPEWIRE_UTILS_H_ #define MODULES_PORTAL_PIPEWIRE_UTILS_H_ +#include +#include +#include +#include + +// static +struct dma_buf_sync { + uint64_t flags; +}; +#define DMA_BUF_SYNC_READ (1 << 0) +#define DMA_BUF_SYNC_START (0 << 2) +#define DMA_BUF_SYNC_END (1 << 2) +#define DMA_BUF_BASE 'b' +#define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync) + struct pw_thread_loop; namespace webrtc { @@ -32,6 +47,66 @@ class PipeWireThreadLoopLock { pw_thread_loop* const loop_; }; +// We should synchronize DMA Buffer object access from CPU to avoid potential +// cache incoherency and data loss. +// See +// https://01.org/linuxgraphics/gfx-docs/drm/driver-api/dma-buf.html#cpu-access-to-dma-buffer-objects +static bool SyncDmaBuf(int fd, uint64_t start_or_end) { + struct dma_buf_sync sync = {0}; + + sync.flags = start_or_end | DMA_BUF_SYNC_READ; + + while (true) { + int ret; + ret = ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync); + if (ret == -1 && errno == EINTR) { + continue; + } else if (ret == -1) { + return false; + } else { + break; + } + } + + return true; +} + +class ScopedBuf { + public: + ScopedBuf() {} + ScopedBuf(uint8_t* map, int map_size, int fd, bool is_dma_buf = false) + : map_(map), map_size_(map_size), fd_(fd), is_dma_buf_(is_dma_buf) {} + ~ScopedBuf() { + if (map_ != MAP_FAILED) { + if (is_dma_buf_) { + SyncDmaBuf(fd_, DMA_BUF_SYNC_END); + } + munmap(map_, map_size_); + } + } + + explicit operator bool() { return map_ != MAP_FAILED; } + + void initialize(uint8_t* map, int map_size, int fd, bool is_dma_buf = false) { + map_ = map; + map_size_ = map_size; + is_dma_buf_ = is_dma_buf; + fd_ = fd; + + if (is_dma_buf_) { + SyncDmaBuf(fd_, DMA_BUF_SYNC_START); + } + } + + uint8_t* get() { return map_; } + + protected: + uint8_t* map_ = static_cast(MAP_FAILED); + int map_size_; + int fd_; + bool is_dma_buf_; +}; + } // namespace webrtc #endif // MODULES_PORTAL_PIPEWIRE_UTILS_H_ diff --git a/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control.h b/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control.h index 97fa490adf..c9edc4f551 100644 --- a/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control.h +++ b/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control.h @@ -108,7 +108,7 @@ class AimdRateControl { // If "Disabled", estimated link capacity is not used as upper bound. FieldTrialFlag disable_estimate_bounded_increase_{"Disabled"}; FieldTrialParameter use_current_estimate_as_min_upper_bound_{"c_upper", - false}; + true}; absl::optional last_decrease_; }; } // namespace webrtc diff --git a/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index f26afe995c..401e87e310 100644 --- a/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/third_party/libwebrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -208,6 +208,7 @@ TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { AimdRateControl aimd_rate_control(ExplicitKeyValueConfig(""), /*send_side=*/true); + aimd_rate_control.SetEstimate(DataRate::BitsPerSec(300'000), kInitialTime); NetworkStateEstimate network_estimate; network_estimate.link_capacity_upper = DataRate::BitsPerSec(400'000); aimd_rate_control.SetNetworkStateEstimate(network_estimate); @@ -217,11 +218,9 @@ TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { } TEST(AimdRateControlTest, - SetEstimateUpperLimitedByCurrentBitrateIfNetworkEstimateIsLow) { - AimdRateControl aimd_rate_control( - ExplicitKeyValueConfig( - "WebRTC-Bwe-EstimateBoundedIncrease/c_upper:true/"), - /*send_side=*/true); + SetEstimateDefaultUpperLimitedByCurrentBitrateIfNetworkEstimateIsLow) { + AimdRateControl aimd_rate_control(ExplicitKeyValueConfig(""), + /*send_side=*/true); aimd_rate_control.SetEstimate(DataRate::BitsPerSec(500'000), kInitialTime); ASSERT_EQ(aimd_rate_control.LatestEstimate(), DataRate::BitsPerSec(500'000)); @@ -233,9 +232,12 @@ TEST(AimdRateControlTest, } TEST(AimdRateControlTest, - SetEstimateDefaultNotUpperLimitedByCurrentBitrateIfNetworkEstimateIsLow) { - AimdRateControl aimd_rate_control(ExplicitKeyValueConfig(""), - /*send_side=*/true); + SetEstimateNotUpperLimitedByCurrentBitrateIfNetworkEstimateIsLowIf) { + AimdRateControl aimd_rate_control( + ExplicitKeyValueConfig( + "WebRTC-Bwe-EstimateBoundedIncrease/c_upper:false/"), + /*send_side=*/true); + aimd_rate_control.SetEstimate(DataRate::BitsPerSec(500'000), kInitialTime); ASSERT_EQ(aimd_rate_control.LatestEstimate(), DataRate::BitsPerSec(500'000)); diff --git a/third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build b/third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build index 2876755e91..45104d15ca 100644 --- a/third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build +++ b/third_party/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_gn/moz.build @@ -211,7 +211,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -221,10 +220,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/rtp_rtcp/BUILD.gn b/third_party/libwebrtc/modules/rtp_rtcp/BUILD.gn index 0fc9931f39..b471c2fa76 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/BUILD.gn +++ b/third_party/libwebrtc/modules/rtp_rtcp/BUILD.gn @@ -258,6 +258,13 @@ rtc_library("rtp_rtcp") { "source/video_rtp_depacketizer_vp9.h", ] + if (rtc_use_h265) { + sources += [ + "source/rtp_packetizer_h265.cc", + "source/rtp_packetizer_h265.h", + ] + } + if (rtc_enable_bwe_test_logging) { defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ] } else { @@ -624,6 +631,10 @@ if (rtc_include_tests) { "source/video_rtp_depacketizer_vp8_unittest.cc", "source/video_rtp_depacketizer_vp9_unittest.cc", ] + if (rtc_use_h265) { + sources += [ "source/rtp_packetizer_h265_unittest.cc" ] + } + deps = [ ":fec_test_helper", ":frame_transformer_factory_unittest", diff --git a/third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build b/third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build index 88f2cb22e0..e42ea18507 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build +++ b/third_party/libwebrtc/modules/rtp_rtcp/leb128_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build b/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build index da304ae5a4..33d8799fb2 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build +++ b/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_format_gn/moz.build @@ -241,7 +241,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -251,10 +250,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build b/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build index 382194837b..8c49736436 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build +++ b/third_party/libwebrtc/modules/rtp_rtcp/rtp_rtcp_gn/moz.build @@ -255,7 +255,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -265,10 +264,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build b/third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build index 2c8b5e2321..d2a102cfe3 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build +++ b/third_party/libwebrtc/modules/rtp_rtcp/rtp_video_header_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc index cfca7cb066..3e6d04d59c 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc @@ -138,9 +138,9 @@ bool FlexfecHeaderReader::ReadFecHeader( mask_part0 <<= 1; ByteWriter::WriteBigEndian(&data[byte_index], mask_part0); byte_index += kFlexfecPacketMaskSizes[0]; - if (k_bit0) { - // The first K-bit is set, and the packet mask is thus only 2 bytes long. - // We have finished reading the properties for current ssrc. + if (!k_bit0) { + // The first K-bit is clear, and the packet mask is thus only 2 bytes + // long. We have finished reading the properties for current ssrc. fec_packet->protected_streams[i].packet_mask_size = kFlexfecPacketMaskSizes[0]; } else { @@ -162,8 +162,8 @@ bool FlexfecHeaderReader::ReadFecHeader( mask_part1 <<= 2; ByteWriter::WriteBigEndian(&data[byte_index], mask_part1); byte_index += kFlexfecPacketMaskSizes[1] - kFlexfecPacketMaskSizes[0]; - if (k_bit1) { - // The first K-bit is clear, but the second K-bit is set. The packet + if (!k_bit1) { + // The first K-bit is set, but the second K-bit is clear. The packet // mask is thus 6 bytes long. We have finished reading the properties // for current ssrc. fec_packet->protected_streams[i].packet_mask_size = @@ -273,8 +273,9 @@ void FlexfecHeaderWriter::FinalizeFecHeader( tmp_mask_part0 >>= 1; // Shift, thus clearing K-bit 0. ByteWriter::WriteBigEndian(write_at, tmp_mask_part0); + *write_at |= 0x80; // Set K-bit 0. write_at += kFlexfecPacketMaskSizes[0]; - tmp_mask_part1 >>= 2; // Shift, thus clearing K-bit 1 and bit 15. + tmp_mask_part1 >>= 2; // Shift twice, thus clearing K-bit 1 and bit 15. ByteWriter::WriteBigEndian(write_at, tmp_mask_part1); bool bit15 = (protected_stream.packet_mask[1] & 0x01) != 0; @@ -284,9 +285,9 @@ void FlexfecHeaderWriter::FinalizeFecHeader( bool bit46 = (protected_stream.packet_mask[5] & 0x02) != 0; bool bit47 = (protected_stream.packet_mask[5] & 0x01) != 0; if (!bit46 && !bit47) { - *write_at |= 0x80; // Set K-bit 1. write_at += kFlexfecPacketMaskSizes[1] - kFlexfecPacketMaskSizes[0]; } else { + *write_at |= 0x80; // Set K-bit 1. write_at += kFlexfecPacketMaskSizes[1] - kFlexfecPacketMaskSizes[0]; // Clear all trailing bits. memset(write_at, 0, @@ -307,14 +308,13 @@ void FlexfecHeaderWriter::FinalizeFecHeader( ByteWriter::WriteBigEndian(write_at, tmp_mask_part0); bool bit15 = (protected_stream.packet_mask[1] & 0x01) != 0; if (!bit15) { - *write_at |= 0x80; // Set K-bit 0. write_at += kFlexfecPacketMaskSizes[0]; } else { + *write_at |= 0x80; // Set K-bit 0. write_at += kFlexfecPacketMaskSizes[0]; // Clear all trailing bits. memset(write_at, 0U, kFlexfecPacketMaskSizes[1] - kFlexfecPacketMaskSizes[0]); - *write_at |= 0x80; // Set K-bit 1. *write_at |= 0x40; // Set bit 15. write_at += kFlexfecPacketMaskSizes[1] - kFlexfecPacketMaskSizes[0]; } diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc index 6995ba3871..f25e0d8d2a 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc @@ -36,11 +36,12 @@ using ReceivedFecPacket = ForwardErrorCorrection::ReceivedFecPacket; using ::testing::Each; using ::testing::ElementsAreArray; -constexpr uint8_t kMask0[] = {0xAB, 0xCD}; // First K bit is set. -constexpr uint8_t kMask1[] = {0x12, 0x34, // First K bit cleared. - 0xF6, 0x78, 0x9A, 0xBC}; // Second K bit set. -constexpr uint8_t kMask2[] = {0x12, 0x34, // First K bit cleared. - 0x56, 0x78, 0x9A, 0xBC, // Second K bit cleared. +constexpr uint8_t kKBit = 1 << 7; +constexpr uint8_t kMask0[] = {0x2B, 0xCD}; // First K bit is cleared. +constexpr uint8_t kMask1[] = {0x92, 0x34, // First K bit set. + 0x76, 0x78, 0x9A, 0xBC}; // Second K bit cleared. +constexpr uint8_t kMask2[] = {0x92, 0x34, // First K bit set. + 0xD6, 0x78, 0x9A, 0xBC, // Second K bit set. 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC}; constexpr size_t kMediaPacketLength = 1234; @@ -186,11 +187,10 @@ void VerifyWrittenAndReadHeaders( } // namespace -TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit0SetSingleStream) { - constexpr uint8_t kKBit0 = 1 << 7; +TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit0ClearSingleStream) { constexpr size_t kExpectedFecHeaderSize = 12; constexpr uint16_t kSnBase = 0x0102; - constexpr uint8_t kFlexfecPktMask[] = {kKBit0 | 0x08, 0x81}; + constexpr uint8_t kFlexfecPktMask[] = {0x08, 0x81}; constexpr uint8_t kUlpfecPacketMask[] = {0x11, 0x02}; constexpr uint8_t kPacketData[] = { kFlexible, kPtRecovery, kLengthRecovery[0], kLengthRecovery[1], @@ -215,13 +215,11 @@ TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit0SetSingleStream) { VerifyReadHeaders(kExpectedFecHeaderSize, read_packet, expected); } -TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit1SetSingleStream) { - constexpr uint8_t kKBit0 = 0 << 7; - constexpr uint8_t kKBit1 = 1 << 7; +TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit1ClearSingleStream) { constexpr size_t kExpectedFecHeaderSize = 16; constexpr uint16_t kSnBase = 0x0102; - constexpr uint8_t kFlexfecPktMask[] = {kKBit0 | 0x48, 0x81, // - kKBit1 | 0x02, 0x11, 0x00, 0x21}; + constexpr uint8_t kFlexfecPktMask[] = {kKBit | 0x48, 0x81, // + 0x02, 0x11, 0x00, 0x21}; constexpr uint8_t kUlpfecPacketMask[] = {0x91, 0x02, // 0x08, 0x44, 0x00, 0x84}; constexpr uint8_t kPacketData[] = { @@ -250,15 +248,13 @@ TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit1SetSingleStream) { VerifyReadHeaders(kExpectedFecHeaderSize, read_packet, expected); } -TEST(FlexfecHeaderReaderTest, ReadsHeaderWithNoKBitsSetSingleStream) { - constexpr uint8_t kKBit0 = 0 << 7; - constexpr uint8_t kKBit1 = 0 << 7; +TEST(FlexfecHeaderReaderTest, ReadsHeaderWithBothKBitsSetSingleStream) { constexpr size_t kExpectedFecHeaderSize = 24; constexpr uint16_t kSnBase = 0x0102; - constexpr uint8_t kFlexfecPacketMask[] = {kKBit0 | 0x48, 0x81, // - kKBit1 | 0x02, 0x11, 0x00, 0x21, // - 0x01, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11}; + constexpr uint8_t kFlexfecPacketMask[] = {kKBit | 0x48, 0x81, // + kKBit | 0x02, 0x11, 0x00, 0x21, // + 0x01, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11}; constexpr uint8_t kUlpfecPacketMask[] = {0x91, 0x02, // 0x08, 0x44, 0x00, 0x84, // 0x04, 0x44, 0x44, 0x44, @@ -309,14 +305,13 @@ TEST(FlexfecHeaderReaderTest, ReadsHeaderWithNoKBitsSetSingleStream) { VerifyReadHeaders(kExpectedFecHeaderSize, read_packet, expected); } -TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit0Set2Streams) { - constexpr uint8_t kKBit0 = 1 << 7; +TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit0Clear2Streams) { constexpr size_t kExpectedFecHeaderSize = 16; constexpr uint16_t kSnBase0 = 0x0102; constexpr uint16_t kSnBase1 = 0x0304; - constexpr uint8_t kFlexfecPktMask1[] = {kKBit0 | 0x08, 0x81}; + constexpr uint8_t kFlexfecPktMask1[] = {0x08, 0x81}; constexpr uint8_t kUlpfecPacketMask1[] = {0x11, 0x02}; - constexpr uint8_t kFlexfecPktMask2[] = {kKBit0 | 0x04, 0x41}; + constexpr uint8_t kFlexfecPktMask2[] = {0x04, 0x41}; constexpr uint8_t kUlpfecPacketMask2[] = {0x08, 0x82}; constexpr uint8_t kPacketData[] = { @@ -349,18 +344,16 @@ TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit0Set2Streams) { VerifyReadHeaders(kExpectedFecHeaderSize, read_packet, expected); } -TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit1Set2Streams) { - constexpr uint8_t kKBit0 = 0 << 7; - constexpr uint8_t kKBit1 = 1 << 7; +TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit1Clear2Streams) { constexpr size_t kExpectedFecHeaderSize = 24; constexpr uint16_t kSnBase0 = 0x0102; constexpr uint16_t kSnBase1 = 0x0304; - constexpr uint8_t kFlexfecPktMask1[] = {kKBit0 | 0x48, 0x81, // - kKBit1 | 0x02, 0x11, 0x00, 0x21}; + constexpr uint8_t kFlexfecPktMask1[] = {kKBit | 0x48, 0x81, // + 0x02, 0x11, 0x00, 0x21}; constexpr uint8_t kUlpfecPacketMask1[] = {0x91, 0x02, // 0x08, 0x44, 0x00, 0x84}; - constexpr uint8_t kFlexfecPktMask2[] = {kKBit0 | 0x57, 0x82, // - kKBit1 | 0x04, 0x33, 0x00, 0x51}; + constexpr uint8_t kFlexfecPktMask2[] = {kKBit | 0x57, 0x82, // + 0x04, 0x33, 0x00, 0x51}; constexpr uint8_t kUlpfecPacketMask2[] = {0xAF, 0x04, // 0x10, 0xCC, 0x01, 0x44}; constexpr uint8_t kPacketData[] = { @@ -398,24 +391,22 @@ TEST(FlexfecHeaderReaderTest, ReadsHeaderWithKBit1Set2Streams) { VerifyReadHeaders(kExpectedFecHeaderSize, read_packet, expected); } -TEST(FlexfecHeaderReaderTest, ReadsHeaderWithNoKBitsSet2Streams) { - constexpr uint8_t kKBit0 = 0 << 7; - constexpr uint8_t kKBit1 = 0 << 7; +TEST(FlexfecHeaderReaderTest, ReadsHeaderWithBothKBitsSet2Streams) { constexpr size_t kExpectedFecHeaderSize = 40; constexpr uint16_t kSnBase0 = 0x0102; constexpr uint16_t kSnBase1 = 0x0304; - constexpr uint8_t kFlexfecPktMask1[] = {kKBit0 | 0x48, 0x81, // - kKBit1 | 0x02, 0x11, 0x00, 0x21, // - 0x01, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11}; + constexpr uint8_t kFlexfecPktMask1[] = {kKBit | 0x48, 0x81, // + kKBit | 0x02, 0x11, 0x00, 0x21, // + 0x01, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11}; constexpr uint8_t kUlpfecPacketMask1[] = {0x91, 0x02, // 0x08, 0x44, 0x00, 0x84, // 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44}; - constexpr uint8_t kFlexfecPktMask2[] = {kKBit0 | 0x32, 0x84, // - kKBit1 | 0x05, 0x23, 0x00, 0x55, // - 0xA3, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x35}; + constexpr uint8_t kFlexfecPktMask2[] = {kKBit | 0x32, 0x84, // + kKBit | 0x05, 0x23, 0x00, 0x55, // + 0xA3, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x35}; constexpr uint8_t kUlpfecPacketMask2[] = {0x65, 0x08, // 0x14, 0x8C, 0x01, 0x56, // 0x8C, 0x88, 0x88, 0x88, @@ -490,29 +481,27 @@ TEST(FlexfecHeaderReaderTest, ReadsHeaderWithNoKBitsSet2Streams) { } TEST(FlexfecHeaderReaderTest, ReadsHeaderWithMultipleStreamsMultipleMasks) { - constexpr uint8_t kBit0 = 0 << 7; - constexpr uint8_t kBit1 = 1 << 7; constexpr size_t kExpectedFecHeaderSize = 44; constexpr uint16_t kSnBase0 = 0x0102; constexpr uint16_t kSnBase1 = 0x0304; constexpr uint16_t kSnBase2 = 0x0506; constexpr uint16_t kSnBase3 = 0x0708; - constexpr uint8_t kFlexfecPacketMask1[] = {kBit1 | 0x29, 0x91}; + constexpr uint8_t kFlexfecPacketMask1[] = {0x29, 0x91}; constexpr uint8_t kUlpfecPacketMask1[] = {0x53, 0x22}; - constexpr uint8_t kFlexfecPacketMask2[] = {kBit0 | 0x32, 0xA1, // - kBit1 | 0x02, 0x11, 0x00, 0x21}; + constexpr uint8_t kFlexfecPacketMask2[] = {kKBit | 0x32, 0xA1, // + 0x02, 0x11, 0x00, 0x21}; constexpr uint8_t kUlpfecPacketMask2[] = {0x65, 0x42, // 0x08, 0x44, 0x00, 0x84}; - constexpr uint8_t kFlexfecPacketMask3[] = {kBit0 | 0x48, 0x81, // - kBit0 | 0x02, 0x11, 0x00, 0x21, // + constexpr uint8_t kFlexfecPacketMask3[] = {kKBit | 0x48, 0x81, // + kKBit | 0x02, 0x11, 0x00, 0x21, // 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}; constexpr uint8_t kUlpfecPacketMask3[] = {0x91, 0x02, // 0x08, 0x44, 0x00, 0x84, // 0x04, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44}; - constexpr uint8_t kFlexfecPacketMask4[] = {kBit0 | 0x32, 0x84, // - kBit1 | 0x05, 0x23, 0x00, 0x55}; + constexpr uint8_t kFlexfecPacketMask4[] = {kKBit | 0x32, 0x84, // + 0x05, 0x23, 0x00, 0x55}; constexpr uint8_t kUlpfecPacketMask4[] = {0x65, 0x08, // 0x14, 0x8C, 0x01, 0x54}; constexpr uint8_t kPacketData[] = {kFlexible, @@ -642,7 +631,7 @@ TEST(FlexfecHeaderReaderTest, ReadShortPacketWithKBit0SetShouldFail) { EXPECT_FALSE(reader.ReadFecHeader(&read_packet)); } -TEST(FlexfecHeaderReaderTest, ReadShortPacketWithKBit1SetShouldFail) { +TEST(FlexfecHeaderReaderTest, ReadShortPacketWithKBit1ClearShouldFail) { // Simulate short received packet. constexpr uint8_t kPacketData[] = { kFlexible, kPtRecovery, kLengthRecovery[0], kLengthRecovery[1], @@ -659,7 +648,7 @@ TEST(FlexfecHeaderReaderTest, ReadShortPacketWithKBit1SetShouldFail) { EXPECT_FALSE(reader.ReadFecHeader(&read_packet)); } -TEST(FlexfecHeaderReaderTest, ReadShortPacketWithKBit1ClearedShouldFail) { +TEST(FlexfecHeaderReaderTest, ReadShortPacketWithKBit1SetShouldFail) { // Simulate short received packet. constexpr uint8_t kPacketData[] = { kFlexible, kPtRecovery, kLengthRecovery[0], kLengthRecovery[1], @@ -698,8 +687,8 @@ TEST(FlexfecHeaderReaderTest, ReadShortPacketMultipleStreamsShouldFail) { EXPECT_FALSE(reader.ReadFecHeader(&read_packet)); } -TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithKBit0SetSingleStream) { - constexpr uint8_t kFlexfecPacketMask[] = {0x88, 0x81}; +TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithKBit0ClearSingleStream) { + constexpr uint8_t kFlexfecPacketMask[] = {0x08, 0x81}; constexpr uint8_t kUlpfecPacketMask[] = {0x11, 0x02}; constexpr uint16_t kMediaStartSeqNum = 1234; Packet written_packet = WritePacket({{.ssrc = 0x01, @@ -714,8 +703,8 @@ TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithKBit0SetSingleStream) { VerifyFinalizedHeaders(written_packet, expected); } -TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithKBit1SetSingleStream) { - constexpr uint8_t kFlexfecPacketMask[] = {0x48, 0x81, 0x82, 0x11, 0x00, 0x21}; +TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithKBit1ClearSingleStream) { + constexpr uint8_t kFlexfecPacketMask[] = {0xC8, 0x81, 0x02, 0x11, 0x00, 0x21}; constexpr uint8_t kUlpfecPacketMask[] = {0x91, 0x02, 0x08, 0x44, 0x00, 0x84}; constexpr uint16_t kMediaStartSeqNum = 1234; Packet written_packet = WritePacket({{.ssrc = 0x01, @@ -730,10 +719,10 @@ TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithKBit1SetSingleStream) { VerifyFinalizedHeaders(written_packet, expected); } -TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithNoKBitsSetSingleStream) { +TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithBothKBitsSetSingleStream) { constexpr uint8_t kFlexfecPacketMask[] = { - 0x11, 0x11, // K-bit 0 clear. - 0x11, 0x11, 0x11, 0x10, // K-bit 1 clear. + 0x91, 0x11, // K-bit 0 set. + 0x91, 0x11, 0x11, 0x10, // K-bit 1 set. 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // }; constexpr uint8_t kUlpfecPacketMask[] = {0x22, 0x22, 0x44, 0x44, 0x44, 0x41}; @@ -752,22 +741,22 @@ TEST(FlexfecHeaderWriterTest, FinalizesHeaderWithNoKBitsSetSingleStream) { TEST(FlexfecHeaderWriterTest, FinalizesHeaderMultipleStreamsMultipleMasks) { constexpr uint8_t kFlexfecPacketMask1[] = { - 0x11, 0x11, // K-bit 0 clear. - 0x11, 0x11, 0x11, 0x10, // K-bit 1 clear. + 0x91, 0x11, // K-bit 0 set. + 0x91, 0x11, 0x11, 0x10, // K-bit 1 set. 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // }; constexpr uint8_t kUlpfecPacketMask1[] = {0x22, 0x22, 0x44, 0x44, 0x44, 0x41}; constexpr uint16_t kMediaStartSeqNum1 = 1234; - constexpr uint8_t kFlexfecPacketMask2[] = {0x88, 0x81}; + constexpr uint8_t kFlexfecPacketMask2[] = {0x08, 0x81}; constexpr uint8_t kUlpfecPacketMask2[] = {0x11, 0x02}; constexpr uint16_t kMediaStartSeqNum2 = 2345; - constexpr uint8_t kFlexfecPacketMask3[] = {0x48, 0x81, 0x82, + constexpr uint8_t kFlexfecPacketMask3[] = {0xC8, 0x81, 0x02, 0x11, 0x00, 0x21}; constexpr uint8_t kUlpfecPacketMask3[] = {0x91, 0x02, 0x08, 0x44, 0x00, 0x84}; constexpr uint16_t kMediaStartSeqNum3 = 3456; constexpr uint8_t kFlexfecPacketMask4[] = { - 0x55, 0xAA, // K-bit 0 clear. - 0x22, 0xAB, 0xCD, 0xEF, // K-bit 1 clear. + 0xD5, 0xAA, // K-bit 0 set. + 0xA2, 0xAB, 0xCD, 0xEF, // K-bit 1 set. 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // }; constexpr uint8_t kUlpfecPacketMask4[] = {0xAB, 0x54, 0x8A, 0xAF, 0x37, 0xBF}; diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_format.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_format.cc index 2c11a29bfa..c7534dee40 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_format.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_format.cc @@ -22,6 +22,9 @@ #include "modules/video_coding/codecs/vp8/include/vp8_globals.h" #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" #include "rtc_base/checks.h" +#ifdef RTC_ENABLE_H265 +#include "modules/rtp_rtcp/source/rtp_packetizer_h265.h" +#endif namespace webrtc { @@ -57,7 +60,11 @@ std::unique_ptr RtpPacketizer::Create( return std::make_unique( payload, limits, rtp_video_header.frame_type, rtp_video_header.is_last_frame_in_picture); - // TODO(bugs.webrtc.org/13485): Implement RtpPacketizerH265. +#ifdef RTC_ENABLE_H265 + case kVideoCodecH265: { + return std::make_unique(payload, limits); + } +#endif default: { return std::make_unique(payload, limits, rtp_video_header); diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_av1.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_av1.cc index 95dbaf364c..859b529a47 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_av1.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_av1.cc @@ -74,8 +74,7 @@ RtpPacketizerAv1::RtpPacketizerAv1(rtc::ArrayView payload, std::vector RtpPacketizerAv1::ParseObus( rtc::ArrayView payload) { std::vector result; - rtc::ByteBufferReader payload_reader( - reinterpret_cast(payload.data()), payload.size()); + rtc::ByteBufferReader payload_reader(payload); while (payload_reader.Length() > 0) { Obu obu; payload_reader.ReadUInt8(&obu.header); diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.cc new file mode 100644 index 0000000000..313680cc87 --- /dev/null +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.cc @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "modules/rtp_rtcp/source/rtp_packetizer_h265.h" + +#include + +#include "absl/types/optional.h" +#include "common_video/h264/h264_common.h" +#include "common_video/h265/h265_common.h" +#include "modules/rtp_rtcp/source/byte_io.h" +#include "rtc_base/logging.h" + +namespace webrtc { +namespace { + +// The payload header consists of the same +// fields (F, Type, LayerId and TID) as the NAL unit header. Refer to +// section 4.2 in RFC 7798. +constexpr size_t kH265PayloadHeaderSize = 2; +// Unlike H.264, H265 NAL header is 2-bytes. +constexpr size_t kH265NalHeaderSize = 2; +// H265's FU is constructed of 2-byte payload header, 1-byte FU header and FU +// payload. +constexpr size_t kH265FuHeaderSize = 1; +// The NALU size for H265 RTP aggregated packet indicates the size of the NAL +// unit is 2-bytes. +constexpr size_t kH265LengthFieldSize = 2; + +enum H265NalHdrMasks { + kH265FBit = 0x80, + kH265TypeMask = 0x7E, + kH265LayerIDHMask = 0x1, + kH265LayerIDLMask = 0xF8, + kH265TIDMask = 0x7, + kH265TypeMaskN = 0x81, + kH265TypeMaskInFuHeader = 0x3F +}; + +// Bit masks for FU headers. +enum H265FuBitmasks { + kH265SBitMask = 0x80, + kH265EBitMask = 0x40, + kH265FuTypeBitMask = 0x3F +}; + +} // namespace + +RtpPacketizerH265::RtpPacketizerH265(rtc::ArrayView payload, + PayloadSizeLimits limits) + : limits_(limits), num_packets_left_(0) { + for (const auto& nalu : + H264::FindNaluIndices(payload.data(), payload.size())) { + input_fragments_.push_back( + payload.subview(nalu.payload_start_offset, nalu.payload_size)); + } + + if (!GeneratePackets()) { + // If failed to generate all the packets, discard already generated + // packets in case the caller would ignore return value and still try to + // call NextPacket(). + num_packets_left_ = 0; + while (!packets_.empty()) { + packets_.pop(); + } + } +} + +RtpPacketizerH265::~RtpPacketizerH265() = default; + +size_t RtpPacketizerH265::NumPackets() const { + return num_packets_left_; +} + +bool RtpPacketizerH265::GeneratePackets() { + for (size_t i = 0; i < input_fragments_.size();) { + int fragment_len = input_fragments_[i].size(); + int single_packet_capacity = limits_.max_payload_len; + if (input_fragments_.size() == 1) { + single_packet_capacity -= limits_.single_packet_reduction_len; + } else if (i == 0) { + single_packet_capacity -= limits_.first_packet_reduction_len; + } else if (i + 1 == input_fragments_.size()) { + // Pretend that last fragment is larger instead of making last packet + // smaller. + single_packet_capacity -= limits_.last_packet_reduction_len; + } + if (fragment_len > single_packet_capacity) { + if (!PacketizeFu(i)) { + return false; + } + ++i; + } else { + i = PacketizeAp(i); + } + } + return true; +} + +bool RtpPacketizerH265::PacketizeFu(size_t fragment_index) { + // Fragment payload into packets (FU). + // Strip out the original header and leave room for the FU header. + rtc::ArrayView fragment = input_fragments_[fragment_index]; + PayloadSizeLimits limits = limits_; + // Refer to section 4.4.3 in RFC7798, each FU fragment will have a 2-bytes + // payload header and a one-byte FU header. DONL is not supported so ignore + // its size when calculating max_payload_len. + limits.max_payload_len -= kH265FuHeaderSize + kH265PayloadHeaderSize; + + // Update single/first/last packet reductions unless it is single/first/last + // fragment. + if (input_fragments_.size() != 1) { + // if this fragment is put into a single packet, it might still be the + // first or the last packet in the whole sequence of packets. + if (fragment_index == input_fragments_.size() - 1) { + limits.single_packet_reduction_len = limits_.last_packet_reduction_len; + } else if (fragment_index == 0) { + limits.single_packet_reduction_len = limits_.first_packet_reduction_len; + } else { + limits.single_packet_reduction_len = 0; + } + } + if (fragment_index != 0) { + limits.first_packet_reduction_len = 0; + } + if (fragment_index != input_fragments_.size() - 1) { + limits.last_packet_reduction_len = 0; + } + + // Strip out the original header. + size_t payload_left = fragment.size() - kH265NalHeaderSize; + int offset = kH265NalHeaderSize; + + std::vector payload_sizes = SplitAboutEqually(payload_left, limits); + if (payload_sizes.empty()) { + return false; + } + + for (size_t i = 0; i < payload_sizes.size(); ++i) { + int packet_length = payload_sizes[i]; + RTC_CHECK_GT(packet_length, 0); + uint16_t header = (fragment[0] << 8) | fragment[1]; + packets_.push({.source_fragment = fragment.subview(offset, packet_length), + .first_fragment = (i == 0), + .last_fragment = (i == payload_sizes.size() - 1), + .aggregated = false, + .header = header}); + offset += packet_length; + payload_left -= packet_length; + } + num_packets_left_ += payload_sizes.size(); + RTC_CHECK_EQ(payload_left, 0); + return true; +} + +int RtpPacketizerH265::PacketizeAp(size_t fragment_index) { + // Aggregate fragments into one packet. + size_t payload_size_left = limits_.max_payload_len; + if (input_fragments_.size() == 1) { + payload_size_left -= limits_.single_packet_reduction_len; + } else if (fragment_index == 0) { + payload_size_left -= limits_.first_packet_reduction_len; + } + int aggregated_fragments = 0; + size_t fragment_headers_length = 0; + rtc::ArrayView fragment = input_fragments_[fragment_index]; + RTC_CHECK_GE(payload_size_left, fragment.size()); + ++num_packets_left_; + + auto payload_size_needed = [&] { + size_t fragment_size = fragment.size() + fragment_headers_length; + if (input_fragments_.size() == 1) { + // Single fragment, single packet, payload_size_left already adjusted + // with limits_.single_packet_reduction_len. + return fragment_size; + } + if (fragment_index == input_fragments_.size() - 1) { + // Last fragment, so this might be the last packet. + return fragment_size + limits_.last_packet_reduction_len; + } + return fragment_size; + }; + + while (payload_size_left >= payload_size_needed()) { + RTC_CHECK_GT(fragment.size(), 0); + packets_.push({.source_fragment = fragment, + .first_fragment = (aggregated_fragments == 0), + .last_fragment = false, + .aggregated = true, + .header = fragment[0]}); + payload_size_left -= fragment.size(); + payload_size_left -= fragment_headers_length; + + fragment_headers_length = kH265LengthFieldSize; + // If we are going to try to aggregate more fragments into this packet + // we need to add the AP NALU header and a length field for the first + // NALU of this packet. + if (aggregated_fragments == 0) { + fragment_headers_length += kH265PayloadHeaderSize + kH265LengthFieldSize; + } + ++aggregated_fragments; + + // Next fragment. + ++fragment_index; + if (fragment_index == input_fragments_.size()) { + break; + } + fragment = input_fragments_[fragment_index]; + } + RTC_CHECK_GT(aggregated_fragments, 0); + packets_.back().last_fragment = true; + return fragment_index; +} + +bool RtpPacketizerH265::NextPacket(RtpPacketToSend* rtp_packet) { + RTC_DCHECK(rtp_packet); + + if (packets_.empty()) { + return false; + } + + PacketUnit packet = packets_.front(); + + if (packet.first_fragment && packet.last_fragment) { + // Single NAL unit packet. Do not support DONL for single NAL unit packets, + // DONL field is not present. + size_t bytes_to_send = packet.source_fragment.size(); + uint8_t* buffer = rtp_packet->AllocatePayload(bytes_to_send); + memcpy(buffer, packet.source_fragment.data(), bytes_to_send); + packets_.pop(); + input_fragments_.pop_front(); + } else if (packet.aggregated) { + NextAggregatePacket(rtp_packet); + } else { + NextFragmentPacket(rtp_packet); + } + rtp_packet->SetMarker(packets_.empty()); + --num_packets_left_; + return true; +} + +void RtpPacketizerH265::NextAggregatePacket(RtpPacketToSend* rtp_packet) { + size_t payload_capacity = rtp_packet->FreeCapacity(); + RTC_CHECK_GE(payload_capacity, kH265PayloadHeaderSize); + uint8_t* buffer = rtp_packet->AllocatePayload(payload_capacity); + RTC_CHECK(buffer); + PacketUnit* packet = &packets_.front(); + RTC_CHECK(packet->first_fragment); + + /* + +---------------+---------------+ + |0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |F| Type | LayerId | TID | + +-------------+-----------------+ + */ + // Refer to section section 4.4.2 for aggregation packets and modify type to + // 48 in PayloadHdr for aggregate packet. Do not support DONL for aggregation + // packets, DONL field is not present. + uint8_t payload_hdr_h = packet->header >> 8; + uint8_t payload_hdr_l = packet->header & 0xFF; + uint8_t layer_id_h = payload_hdr_h & kH265LayerIDHMask; + payload_hdr_h = (payload_hdr_h & kH265TypeMaskN) | + (H265::NaluType::kAp << 1) | layer_id_h; + buffer[0] = payload_hdr_h; + buffer[1] = payload_hdr_l; + + int index = kH265PayloadHeaderSize; + bool is_last_fragment = packet->last_fragment; + while (packet->aggregated) { + // Add NAL unit length field. + rtc::ArrayView fragment = packet->source_fragment; + ByteWriter::WriteBigEndian(&buffer[index], fragment.size()); + index += kH265LengthFieldSize; + // Add NAL unit. + memcpy(&buffer[index], fragment.data(), fragment.size()); + index += fragment.size(); + packets_.pop(); + input_fragments_.pop_front(); + if (is_last_fragment) { + break; + } + packet = &packets_.front(); + is_last_fragment = packet->last_fragment; + } + RTC_CHECK(is_last_fragment); + rtp_packet->SetPayloadSize(index); +} + +void RtpPacketizerH265::NextFragmentPacket(RtpPacketToSend* rtp_packet) { + PacketUnit* packet = &packets_.front(); + // NAL unit fragmented over multiple packets (FU). + // We do not send original NALU header, so it will be replaced by the + // PayloadHdr of the first packet. + /* + +---------------+---------------+ + |0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |F| Type | LayerId | TID | + +-------------+-----------------+ + */ + // Refer to section section 4.4.3 for aggregation packets and modify type to + // 49 in PayloadHdr for aggregate packet. + uint8_t payload_hdr_h = + packet->header >> 8; // 1-bit F, 6-bit type, 1-bit layerID highest-bit + uint8_t payload_hdr_l = packet->header & 0xFF; + uint8_t layer_id_h = payload_hdr_h & kH265LayerIDHMask; + uint8_t fu_header = 0; + /* + +---------------+ + |0|1|2|3|4|5|6|7| + +-+-+-+-+-+-+-+-+ + |S|E| FuType | + +---------------+ + */ + // S bit indicates the start of a fragmented NAL unit. + // E bit indicates the end of a fragmented NAL unit. + // FuType must be equal to the field type value of the fragmented NAL unit. + fu_header |= (packet->first_fragment ? kH265SBitMask : 0); + fu_header |= (packet->last_fragment ? kH265EBitMask : 0); + uint8_t type = (payload_hdr_h & kH265TypeMask) >> 1; + fu_header |= type; + // Now update payload_hdr_h with FU type. + payload_hdr_h = (payload_hdr_h & kH265TypeMaskN) | + (H265::NaluType::kFu << 1) | layer_id_h; + rtc::ArrayView fragment = packet->source_fragment; + uint8_t* buffer = rtp_packet->AllocatePayload( + kH265FuHeaderSize + kH265PayloadHeaderSize + fragment.size()); + RTC_CHECK(buffer); + buffer[0] = payload_hdr_h; + buffer[1] = payload_hdr_l; + buffer[2] = fu_header; + + // Do not support DONL for fragmentation units, DONL field is not present. + memcpy(buffer + kH265FuHeaderSize + kH265PayloadHeaderSize, fragment.data(), + fragment.size()); + if (packet->last_fragment) { + input_fragments_.pop_front(); + } + packets_.pop(); +} + +} // namespace webrtc diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.h b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.h new file mode 100644 index 0000000000..95442f795c --- /dev/null +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef MODULES_RTP_RTCP_SOURCE_RTP_PACKETIZER_H265_H_ +#define MODULES_RTP_RTCP_SOURCE_RTP_PACKETIZER_H265_H_ + +#include +#include +#include + +#include "api/array_view.h" +#include "modules/rtp_rtcp/source/rtp_format.h" +#include "modules/rtp_rtcp/source/rtp_packet_to_send.h" + +namespace webrtc { + +class RtpPacketizerH265 : public RtpPacketizer { + public: + // Initialize with payload from encoder. + // The payload_data must be exactly one encoded H.265 frame. + // For H265 we only support tx-mode SRST. + RtpPacketizerH265(rtc::ArrayView payload, + PayloadSizeLimits limits); + + RtpPacketizerH265(const RtpPacketizerH265&) = delete; + RtpPacketizerH265& operator=(const RtpPacketizerH265&) = delete; + + ~RtpPacketizerH265() override; + + size_t NumPackets() const override; + + // Get the next payload with H.265 payload header. + // Write payload and set marker bit of the `packet`. + // Returns true on success or false if there was no payload to packetize. + bool NextPacket(RtpPacketToSend* rtp_packet) override; + + private: + struct PacketUnit { + rtc::ArrayView source_fragment; + bool first_fragment = false; + bool last_fragment = false; + bool aggregated = false; + uint16_t header = 0; + }; + std::deque> input_fragments_; + std::queue packets_; + + bool GeneratePackets(); + bool PacketizeFu(size_t fragment_index); + int PacketizeAp(size_t fragment_index); + + void NextAggregatePacket(RtpPacketToSend* rtp_packet); + void NextFragmentPacket(RtpPacketToSend* rtp_packet); + + const PayloadSizeLimits limits_; + size_t num_packets_left_ = 0; +}; +} // namespace webrtc +#endif // MODULES_RTP_RTCP_SOURCE_RTP_PACKETIZER_H265_H_ diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265_unittest.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265_unittest.cc new file mode 100644 index 0000000000..cb1de334c0 --- /dev/null +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_packetizer_h265_unittest.cc @@ -0,0 +1,525 @@ +/* + * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "modules/rtp_rtcp/source/rtp_packetizer_h265.h" + +#include + +#include "common_video/h265/h265_common.h" +#include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" +#include "modules/rtp_rtcp/source/byte_io.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { +namespace { + +using ::testing::Each; +using ::testing::ElementsAre; +using ::testing::ElementsAreArray; +using ::testing::Eq; +using ::testing::IsEmpty; +using ::testing::SizeIs; + +constexpr RtpPacketToSend::ExtensionManager* kNoExtensions = nullptr; +constexpr size_t kMaxPayloadSize = 1200; +constexpr size_t kLengthFieldLength = 2; +constexpr RtpPacketizer::PayloadSizeLimits kNoLimits; + +constexpr size_t kNalHeaderSize = 2; +constexpr size_t kFuHeaderSize = 3; + +constexpr uint8_t kNaluTypeMask = 0x7E; + +// Bit masks for FU headers. +constexpr uint8_t kH265SBit = 0x80; +constexpr uint8_t kH265EBit = 0x40; + +// Creates Buffer that looks like nal unit of given size. +rtc::Buffer GenerateNalUnit(size_t size) { + RTC_CHECK_GT(size, 0); + rtc::Buffer buffer(size); + // Set some valid header with type TRAIL_R and temporal id + buffer[0] = 2; + buffer[1] = 2; + for (size_t i = 2; i < size; ++i) { + buffer[i] = static_cast(i); + } + // Last byte shouldn't be 0, or it may be counted as part of next 4-byte start + // sequence. + buffer[size - 1] |= 0x10; + return buffer; +} + +// Create frame consisting of nalus of given size. +rtc::Buffer CreateFrame(std::initializer_list nalu_sizes) { + static constexpr int kStartCodeSize = 3; + rtc::Buffer frame(absl::c_accumulate(nalu_sizes, size_t{0}) + + kStartCodeSize * nalu_sizes.size()); + size_t offset = 0; + for (size_t nalu_size : nalu_sizes) { + EXPECT_GE(nalu_size, 1u); + // Insert nalu start code + frame[offset] = 0; + frame[offset + 1] = 0; + frame[offset + 2] = 1; + // Set some valid header. + frame[offset + 3] = 2; + // Fill payload avoiding accidental start codes + if (nalu_size > 1) { + memset(frame.data() + offset + 4, 0x3f, nalu_size - 1); + } + offset += (kStartCodeSize + nalu_size); + } + return frame; +} + +// Create frame consisting of given nalus. +rtc::Buffer CreateFrame(rtc::ArrayView nalus) { + static constexpr int kStartCodeSize = 3; + int frame_size = 0; + for (const rtc::Buffer& nalu : nalus) { + frame_size += (kStartCodeSize + nalu.size()); + } + rtc::Buffer frame(frame_size); + size_t offset = 0; + for (const rtc::Buffer& nalu : nalus) { + // Insert nalu start code + frame[offset] = 0; + frame[offset + 1] = 0; + frame[offset + 2] = 1; + // Copy the nalu unit. + memcpy(frame.data() + offset + 3, nalu.data(), nalu.size()); + offset += (kStartCodeSize + nalu.size()); + } + return frame; +} + +std::vector FetchAllPackets(RtpPacketizerH265* packetizer) { + std::vector result; + size_t num_packets = packetizer->NumPackets(); + result.reserve(num_packets); + RtpPacketToSend packet(kNoExtensions); + while (packetizer->NextPacket(&packet)) { + result.push_back(packet); + } + EXPECT_THAT(result, SizeIs(num_packets)); + return result; +} + +// Single nalu tests. +TEST(RtpPacketizerH265Test, SingleNalu) { + const uint8_t frame[] = {0, 0, 1, H265::kIdrWRadl, 0xFF}; + + RtpPacketizerH265 packetizer(frame, kNoLimits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(1)); + EXPECT_THAT(packets[0].payload(), ElementsAre(H265::kIdrWRadl, 0xFF)); +} + +TEST(RtpPacketizerH265Test, SingleNaluTwoPackets) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = kMaxPayloadSize; + rtc::Buffer nalus[] = {GenerateNalUnit(kMaxPayloadSize), + GenerateNalUnit(100)}; + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(2)); + EXPECT_THAT(packets[0].payload(), ElementsAreArray(nalus[0])); + EXPECT_THAT(packets[1].payload(), ElementsAreArray(nalus[1])); +} + +TEST(RtpPacketizerH265Test, + SingleNaluFirstPacketReductionAppliesOnlyToFirstFragment) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 200; + limits.first_packet_reduction_len = 5; + rtc::Buffer nalus[] = {GenerateNalUnit(/*size=*/195), + GenerateNalUnit(/*size=*/200), + GenerateNalUnit(/*size=*/200)}; + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(3)); + EXPECT_THAT(packets[0].payload(), ElementsAreArray(nalus[0])); + EXPECT_THAT(packets[1].payload(), ElementsAreArray(nalus[1])); + EXPECT_THAT(packets[2].payload(), ElementsAreArray(nalus[2])); +} + +TEST(RtpPacketizerH265Test, + SingleNaluLastPacketReductionAppliesOnlyToLastFragment) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 200; + limits.last_packet_reduction_len = 5; + rtc::Buffer nalus[] = {GenerateNalUnit(/*size=*/200), + GenerateNalUnit(/*size=*/200), + GenerateNalUnit(/*size=*/195)}; + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(3)); + EXPECT_THAT(packets[0].payload(), ElementsAreArray(nalus[0])); + EXPECT_THAT(packets[1].payload(), ElementsAreArray(nalus[1])); + EXPECT_THAT(packets[2].payload(), ElementsAreArray(nalus[2])); +} + +TEST(RtpPacketizerH265Test, + SingleNaluFirstAndLastPacketReductionSumsForSinglePacket) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 200; + limits.first_packet_reduction_len = 20; + limits.last_packet_reduction_len = 30; + rtc::Buffer frame = CreateFrame({150}); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + EXPECT_THAT(packets, SizeIs(1)); +} + +// Aggregation tests. +TEST(RtpPacketizerH265Test, ApRespectsNoPacketReduction) { + rtc::Buffer nalus[] = {GenerateNalUnit(/*size=*/2), + GenerateNalUnit(/*size=*/2), + GenerateNalUnit(/*size=*/0x123)}; + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, kNoLimits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(1)); + auto payload = packets[0].payload(); + int type = H265::ParseNaluType(payload[0]); + EXPECT_EQ(payload.size(), + kNalHeaderSize + 3 * kLengthFieldLength + 2 + 2 + 0x123); + + EXPECT_EQ(type, H265::NaluType::kAp); + payload = payload.subview(kNalHeaderSize); + // 1st fragment. + EXPECT_THAT(payload.subview(0, kLengthFieldLength), + ElementsAre(0, 2)); // Size. + EXPECT_THAT(payload.subview(kLengthFieldLength, 2), + ElementsAreArray(nalus[0])); + payload = payload.subview(kLengthFieldLength + 2); + // 2nd fragment. + EXPECT_THAT(payload.subview(0, kLengthFieldLength), + ElementsAre(0, 2)); // Size. + EXPECT_THAT(payload.subview(kLengthFieldLength, 2), + ElementsAreArray(nalus[1])); + payload = payload.subview(kLengthFieldLength + 2); + // 3rd fragment. + EXPECT_THAT(payload.subview(0, kLengthFieldLength), + ElementsAre(0x1, 0x23)); // Size. + EXPECT_THAT(payload.subview(kLengthFieldLength), ElementsAreArray(nalus[2])); +} + +TEST(RtpPacketizerH265Test, ApRespectsFirstPacketReduction) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1000; + limits.first_packet_reduction_len = 100; + const size_t kFirstFragmentSize = + limits.max_payload_len - limits.first_packet_reduction_len; + rtc::Buffer nalus[] = {GenerateNalUnit(/*size=*/kFirstFragmentSize), + GenerateNalUnit(/*size=*/2), + GenerateNalUnit(/*size=*/2)}; + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(2)); + // Expect 1st packet is single nalu. + EXPECT_THAT(packets[0].payload(), ElementsAreArray(nalus[0])); + // Expect 2nd packet is aggregate of last two fragments. + // The size of H265 nal_unit_header is 2 bytes, according to 7.3.1.2 + // in H265 spec. Aggregation packet type is 48, and nuh_temporal_id_plus1 + // is 2, so the nal_unit_header should be "01100000 00000010", + // which is 96 and 2. + EXPECT_THAT(packets[1].payload(), + ElementsAre(96, 2, // + 0, 2, nalus[1][0], nalus[1][1], // + 0, 2, nalus[2][0], nalus[2][1])); +} + +TEST(RtpPacketizerH265Test, ApRespectsLastPacketReduction) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1000; + limits.last_packet_reduction_len = 100; + const size_t kLastFragmentSize = + limits.max_payload_len - limits.last_packet_reduction_len; + rtc::Buffer nalus[] = {GenerateNalUnit(/*size=*/2), + GenerateNalUnit(/*size=*/2), + GenerateNalUnit(/*size=*/kLastFragmentSize)}; + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(2)); + // Expect 1st packet is aggregate of 1st two fragments. + EXPECT_THAT(packets[0].payload(), + ElementsAre(96, 2, // + 0, 2, nalus[0][0], nalus[0][1], // + 0, 2, nalus[1][0], nalus[1][1])); + // Expect 2nd packet is single nalu. + EXPECT_THAT(packets[1].payload(), ElementsAreArray(nalus[2])); +} + +TEST(RtpPacketizerH265Test, TooSmallForApHeaders) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1000; + const size_t kLastFragmentSize = + limits.max_payload_len - 3 * kLengthFieldLength - 4; + rtc::Buffer nalus[] = {GenerateNalUnit(/*size=*/2), + GenerateNalUnit(/*size=*/2), + GenerateNalUnit(/*size=*/kLastFragmentSize)}; + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(2)); + // Expect 1st packet is aggregate of 1st two fragments. + EXPECT_THAT(packets[0].payload(), + ElementsAre(96, 2, // + 0, 2, nalus[0][0], nalus[0][1], // + 0, 2, nalus[1][0], nalus[1][1])); + // Expect 2nd packet is single nalu. + EXPECT_THAT(packets[1].payload(), ElementsAreArray(nalus[2])); +} + +TEST(RtpPacketizerH265Test, LastFragmentFitsInSingleButNotLastPacket) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1178; + limits.first_packet_reduction_len = 0; + limits.last_packet_reduction_len = 20; + limits.single_packet_reduction_len = 20; + // Actual sizes, which triggered this bug. + rtc::Buffer frame = CreateFrame({20, 8, 18, 1161}); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + // Last packet has to be of correct size. + // Incorrect implementation might miss this constraint and not split the last + // fragment in two packets. + EXPECT_LE(static_cast(packets.back().payload_size()), + limits.max_payload_len - limits.last_packet_reduction_len); +} + +// Splits frame with payload size `frame_payload_size` without fragmentation, +// Returns sizes of the payloads excluding FU headers. +std::vector TestFu(size_t frame_payload_size, + const RtpPacketizer::PayloadSizeLimits& limits) { + rtc::Buffer nalu[] = {GenerateNalUnit(kNalHeaderSize + frame_payload_size)}; + rtc::Buffer frame = CreateFrame(nalu); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + EXPECT_GE(packets.size(), 2u); // Single packet indicates it is not FU. + std::vector fu_header; + std::vector payload_sizes; + + for (const RtpPacketToSend& packet : packets) { + auto payload = packet.payload(); + EXPECT_GT(payload.size(), kFuHeaderSize); + // FU header is after the 2-bytes size PayloadHdr according to 4.4.3 in spec + fu_header.push_back(payload[2]); + payload_sizes.push_back(payload.size() - kFuHeaderSize); + } + + EXPECT_TRUE(fu_header.front() & kH265SBit); + EXPECT_TRUE(fu_header.back() & kH265EBit); + // Clear S and E bits before testing all are duplicating same original header. + fu_header.front() &= ~kH265SBit; + fu_header.back() &= ~kH265EBit; + uint8_t nalu_type = (nalu[0][0] & kNaluTypeMask) >> 1; + EXPECT_THAT(fu_header, Each(Eq(nalu_type))); + + return payload_sizes; +} + +// Fragmentation tests. +TEST(RtpPacketizerH265Test, FuOddSize) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + EXPECT_THAT(TestFu(1200, limits), ElementsAre(600, 600)); +} + +TEST(RtpPacketizerH265Test, FuWithFirstPacketReduction) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + limits.first_packet_reduction_len = 4; + limits.single_packet_reduction_len = 4; + EXPECT_THAT(TestFu(1198, limits), ElementsAre(597, 601)); +} + +TEST(RtpPacketizerH265Test, FuWithLastPacketReduction) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + limits.last_packet_reduction_len = 4; + limits.single_packet_reduction_len = 4; + EXPECT_THAT(TestFu(1198, limits), ElementsAre(601, 597)); +} + +TEST(RtpPacketizerH265Test, FuWithSinglePacketReduction) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1199; + limits.single_packet_reduction_len = 200; + EXPECT_THAT(TestFu(1000, limits), ElementsAre(500, 500)); +} + +TEST(RtpPacketizerH265Test, FuEvenSize) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + EXPECT_THAT(TestFu(1201, limits), ElementsAre(600, 601)); +} + +TEST(RtpPacketizerH265Test, FuRounding) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1448; + EXPECT_THAT(TestFu(10123, limits), + ElementsAre(1265, 1265, 1265, 1265, 1265, 1266, 1266, 1266)); +} + +TEST(RtpPacketizerH265Test, FuBig) { + RtpPacketizer::PayloadSizeLimits limits; + limits.max_payload_len = 1200; + // Generate 10 full sized packets, leave room for FU headers. + EXPECT_THAT( + TestFu(10 * (1200 - kFuHeaderSize), limits), + ElementsAre(1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197)); +} + +struct PacketInfo { + bool first_fragment = false; + bool last_fragment = false; + bool aggregated = false; + int nalu_index = 0; + int nalu_number = 0; + int payload_size = 0; + int start_offset = 0; +}; + +struct MixedApFuTestParams { + std::vector nalus; + int expect_packetsSize = 0; + std::vector expected_packets; +}; + +class RtpPacketizerH265ParametrizedTest + : public ::testing::TestWithParam {}; + +// Fragmentation + aggregation mixed testing. +TEST_P(RtpPacketizerH265ParametrizedTest, MixedApFu) { + RtpPacketizer::PayloadSizeLimits limits; + const MixedApFuTestParams params = GetParam(); + limits.max_payload_len = 100; + std::vector nalus; + nalus.reserve(params.nalus.size()); + + // Generate nalus according to size specified in paramters + for (size_t index = 0; index < params.nalus.size(); index++) { + nalus.push_back(GenerateNalUnit(params.nalus[index])); + } + rtc::Buffer frame = CreateFrame(nalus); + + RtpPacketizerH265 packetizer(frame, limits); + std::vector packets = FetchAllPackets(&packetizer); + + ASSERT_THAT(packets, SizeIs(params.expect_packetsSize)); + for (int i = 0; i < params.expect_packetsSize; i++) { + PacketInfo expected_packet = params.expected_packets[i]; + if (expected_packet.aggregated) { + int type = H265::ParseNaluType(packets[i].payload()[0]); + EXPECT_THAT(type, H265::NaluType::kAp); + auto payload = packets[i].payload().subview(kNalHeaderSize); + int offset = 0; + // Generated AP packet header and payload align + for (int j = expected_packet.nalu_index; j < expected_packet.nalu_number; + j++) { + EXPECT_THAT(payload.subview(0, kLengthFieldLength), + ElementsAre(0, nalus[j].size())); + EXPECT_THAT( + payload.subview(offset + kLengthFieldLength, nalus[j].size()), + ElementsAreArray(nalus[j])); + offset += kLengthFieldLength + nalus[j].size(); + } + } else { + uint8_t fu_header = 0; + fu_header |= (expected_packet.first_fragment ? kH265SBit : 0); + fu_header |= (expected_packet.last_fragment ? kH265EBit : 0); + fu_header |= H265::NaluType::kTrailR; + EXPECT_THAT(packets[i].payload().subview(0, kFuHeaderSize), + ElementsAre(98, 2, fu_header)); + EXPECT_THAT( + packets[i].payload().subview(kFuHeaderSize), + ElementsAreArray(nalus[expected_packet.nalu_index].data() + + kNalHeaderSize + expected_packet.start_offset, + expected_packet.payload_size)); + } + } +} + +INSTANTIATE_TEST_SUITE_P( + RtpPacketizerH265Test, + RtpPacketizerH265ParametrizedTest, + testing::Values( + // FU + AP + FU. + // GenerateNalUnit will include 2 bytes nalu header, for FU packet split + // calculation, this 2-byte nalu header length should be excluded. + MixedApFuTestParams{.nalus = {140, 20, 20, 160}, + .expect_packetsSize = 5, + .expected_packets = {{.first_fragment = true, + .nalu_index = 0, + .payload_size = 69, + .start_offset = 0}, + {.last_fragment = true, + .nalu_index = 0, + .payload_size = 69, + .start_offset = 69}, + {.aggregated = true, + .nalu_index = 1, + .nalu_number = 2}, + {.first_fragment = true, + .nalu_index = 3, + .payload_size = 79, + .start_offset = 0}, + {.last_fragment = true, + .nalu_index = 3, + .payload_size = 79, + .start_offset = 79}}}, + // AP + FU + AP + MixedApFuTestParams{ + .nalus = {20, 20, 160, 30, 30}, + .expect_packetsSize = 4, + .expected_packets = { + {.aggregated = true, .nalu_index = 0, .nalu_number = 2}, + {.first_fragment = true, + .nalu_index = 2, + .payload_size = 79, + .start_offset = 0}, + {.last_fragment = true, + .nalu_index = 2, + .payload_size = 79, + .start_offset = 79}, + {.aggregated = true, .nalu_index = 3, .nalu_number = 2}}})); + +} // namespace +} // namespace webrtc diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc index ff482b39b6..31e8b71117 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -53,8 +53,8 @@ RTCPSender::Configuration AddRtcpSendEvaluationCallback( RtpPacketHistory::PaddingMode GetPaddingMode( const FieldTrialsView* field_trials) { - if (field_trials && - field_trials->IsEnabled("WebRTC-PaddingMode-RecentLargePacket")) { + if (!field_trials || + !field_trials->IsDisabled("WebRTC-PaddingMode-RecentLargePacket")) { return RtpPacketHistory::PaddingMode::kRecentLargePacket; } return RtpPacketHistory::PaddingMode::kPriority; diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc index b826c30e07..9d2258dc66 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -254,7 +254,8 @@ bool RTPSenderAudio::SendAudio(const RtpAudioFrame& frame) { return false; } - std::unique_ptr packet = rtp_sender_->AllocatePacket(); + std::unique_ptr packet = + rtp_sender_->AllocatePacket(frame.csrcs); packet->SetMarker(MarkerBit(frame.type, frame.payload_id)); packet->SetPayloadType(frame.payload_id); packet->SetTimestamp(frame.rtp_timestamp); diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.h b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.h index 662f908216..83a2cb211f 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.h +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio.h @@ -61,6 +61,9 @@ class RTPSenderAudio { // header-extension-for-audio-level-indication. // Valid range is [0,127]. Actual value is negative. absl::optional audio_level_dbov; + + // Contributing sources list. + rtc::ArrayView csrcs; }; bool SendAudio(const RtpAudioFrame& frame); diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc index 0db610c149..724cd3a5e0 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_audio_unittest.cc @@ -222,4 +222,19 @@ TEST_F(RtpSenderAudioTest, CheckMarkerBitForTelephoneEvents) { EXPECT_FALSE(transport_.last_sent_packet().Marker()); } +TEST_F(RtpSenderAudioTest, SendsCsrcs) { + const char payload_name[] = "audio"; + const uint8_t payload_type = 127; + ASSERT_EQ(0, rtp_sender_audio_->RegisterAudioPayload( + payload_name, payload_type, 48000, 0, 1500)); + uint8_t payload[] = {47, 11, 32, 93, 89}; + + std::vector csrcs({123, 456, 789}); + + ASSERT_TRUE(rtp_sender_audio_->SendAudio( + {.payload = payload, .payload_id = payload_type, .csrcs = csrcs})); + + EXPECT_EQ(transport_.last_sent_packet().Csrcs(), csrcs); +} + } // namespace webrtc diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc index 9d7c58d19a..ae9eb6b4bd 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc @@ -19,10 +19,17 @@ #include "modules/rtp_rtcp/source/rtp_descriptor_authentication.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" +#include "rtc_base/logging.h" namespace webrtc { namespace { +// Using a reasonable default of 10ms for the retransmission delay for frames +// not coming from this sender's encoder. This is usually taken from an +// estimate of the RTT of the link,so 10ms should be a reasonable estimate for +// frames being re-transmitted to a peer, probably on the same network. +const TimeDelta kDefaultRetransmissionsTime = TimeDelta::Millis(10); + class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { public: TransformableVideoSenderFrame(const EncodedImage& encoded_image, @@ -155,6 +162,17 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame( const EncodedImage& encoded_image, RTPVideoHeader video_header, TimeDelta expected_retransmission_time) { + { + MutexLock lock(&sender_lock_); + if (short_circuit_) { + sender_->SendVideo(payload_type, codec_type, rtp_timestamp, + encoded_image.CaptureTime(), + *encoded_image.GetEncodedData(), encoded_image.size(), + video_header, expected_retransmission_time, + /*csrcs=*/{}); + return true; + } + } frame_transformer_->Transform(std::make_unique( encoded_image, video_header, payload_type, codec_type, rtp_timestamp, expected_retransmission_time, ssrc_, @@ -177,6 +195,11 @@ void RTPSenderVideoFrameTransformerDelegate::OnTransformedFrame( }); } +void RTPSenderVideoFrameTransformerDelegate::StartShortCircuiting() { + MutexLock lock(&sender_lock_); + short_circuit_ = true; +} + void RTPSenderVideoFrameTransformerDelegate::SendVideo( std::unique_ptr transformed_frame) const { RTC_DCHECK_RUN_ON(transformation_queue_.get()); @@ -200,15 +223,17 @@ void RTPSenderVideoFrameTransformerDelegate::SendVideo( auto* transformed_video_frame = static_cast(transformed_frame.get()); VideoFrameMetadata metadata = transformed_video_frame->Metadata(); - sender_->SendVideo( - transformed_video_frame->GetPayloadType(), metadata.GetCodec(), - transformed_video_frame->GetTimestamp(), - /*capture_time=*/Timestamp::MinusInfinity(), - transformed_video_frame->GetData(), - transformed_video_frame->GetData().size(), - RTPVideoHeader::FromMetadata(metadata), - /*expected_retransmission_time=*/TimeDelta::PlusInfinity(), - metadata.GetCsrcs()); + // TODO(bugs.webrtc.org/14708): Use an actual RTT estimate for the + // retransmission time instead of a const default, in the same way as a + // locally encoded frame. + sender_->SendVideo(transformed_video_frame->GetPayloadType(), + metadata.GetCodec(), + transformed_video_frame->GetTimestamp(), + /*capture_time=*/Timestamp::MinusInfinity(), + transformed_video_frame->GetData(), + transformed_video_frame->GetData().size(), + RTPVideoHeader::FromMetadata(metadata), + kDefaultRetransmissionsTime, metadata.GetCsrcs()); } } @@ -253,13 +278,14 @@ std::unique_ptr CloneSenderVideoFrame( ? VideoFrameType::kVideoFrameKey : VideoFrameType::kVideoFrameDelta; // TODO(bugs.webrtc.org/14708): Fill in other EncodedImage parameters - + // TODO(bugs.webrtc.org/14708): Use an actual RTT estimate for the + // retransmission time instead of a const default, in the same way as a + // locally encoded frame. VideoFrameMetadata metadata = original->Metadata(); RTPVideoHeader new_header = RTPVideoHeader::FromMetadata(metadata); return std::make_unique( encoded_image, new_header, original->GetPayloadType(), new_header.codec, - original->GetTimestamp(), - /*expected_retransmission_time=*/TimeDelta::PlusInfinity(), + original->GetTimestamp(), kDefaultRetransmissionsTime, original->GetSsrc(), metadata.GetCsrcs(), original->GetRid()); } diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h index 3379ead364..1f70a23ccc 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h @@ -76,6 +76,8 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback { void OnTransformedFrame( std::unique_ptr frame) override; + void StartShortCircuiting() override; + // Delegates the call to RTPSendVideo::SendVideo on the `encoder_queue_`. void SendVideo(std::unique_ptr frame) const RTC_RUN_ON(transformation_queue_); @@ -109,6 +111,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback { // Used when the encoded frames arrives without a current task queue. This can // happen if a hardware encoder was used. std::unique_ptr transformation_queue_; + bool short_circuit_ RTC_GUARDED_BY(sender_lock_) = false; }; // Method to support cloning a Sender frame from another frame diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc index a376be77b4..6790fc3a71 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate_unittest.cc @@ -83,7 +83,7 @@ class RtpSenderVideoFrameTransformerDelegateTest : public ::testing::Test { delegate->TransformFrame( /*payload_type=*/1, VideoCodecType::kVideoCodecVP8, /*rtp_timestamp=*/2, encoded_image, RTPVideoHeader::FromMetadata(metadata), - /*expected_retransmission_time=*/TimeDelta::PlusInfinity()); + /*expected_retransmission_time=*/TimeDelta::Millis(10)); return frame; } @@ -123,7 +123,7 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest, delegate->TransformFrame( /*payload_type=*/1, VideoCodecType::kVideoCodecVP8, /*rtp_timestamp=*/2, encoded_image, RTPVideoHeader(), - /*expected_retransmission_time=*/TimeDelta::PlusInfinity()); + /*expected_retransmission_time=*/TimeDelta::Millis(10)); } TEST_F(RtpSenderVideoFrameTransformerDelegateTest, @@ -260,7 +260,7 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest, test_sender_, SendVideo(payload_type, absl::make_optional(kVideoCodecVP8), timestamp, /*capture_time=*/Timestamp::MinusInfinity(), buffer, _, _, - /*expected_retransmission_time=*/TimeDelta::PlusInfinity(), + /*expected_retransmission_time=*/TimeDelta::Millis(10), frame_csrcs)) .WillOnce(WithoutArgs([&] { event.Set(); @@ -289,5 +289,29 @@ TEST_F(RtpSenderVideoFrameTransformerDelegateTest, SettingRTPTimestamp) { EXPECT_EQ(video_frame.GetTimestamp(), rtp_timestamp); } +TEST_F(RtpSenderVideoFrameTransformerDelegateTest, + ShortCircuitingSkipsTransform) { + auto delegate = rtc::make_ref_counted( + &test_sender_, frame_transformer_, + /*ssrc=*/1111, time_controller_.CreateTaskQueueFactory().get()); + EXPECT_CALL(*frame_transformer_, + RegisterTransformedFrameSinkCallback(_, 1111)); + delegate->Init(); + + delegate->StartShortCircuiting(); + + // Will not call the actual transformer. + EXPECT_CALL(*frame_transformer_, Transform).Times(0); + // Will pass the frame straight to the reciever. + EXPECT_CALL(test_sender_, SendVideo); + + EncodedImage encoded_image; + encoded_image.SetEncodedData(EncodedImageBuffer::Create(1)); + delegate->TransformFrame( + /*payload_type=*/1, VideoCodecType::kVideoCodecVP8, /*rtp_timestamp=*/2, + encoded_image, RTPVideoHeader(), + /*expected_retransmission_time=*/TimeDelta::Millis(10)); +} + } // namespace } // namespace webrtc diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc index 94c9249e16..7af945c623 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc @@ -17,6 +17,7 @@ #include "absl/memory/memory.h" #include "modules/rtp_rtcp/source/rtp_descriptor_authentication.h" #include "rtc_base/checks.h" +#include "rtc_base/logging.h" #include "rtc_base/thread.h" namespace webrtc { @@ -123,9 +124,14 @@ void RtpVideoStreamReceiverFrameTransformerDelegate::Reset() { void RtpVideoStreamReceiverFrameTransformerDelegate::TransformFrame( std::unique_ptr frame) { RTC_DCHECK_RUN_ON(&network_sequence_checker_); - frame_transformer_->Transform( - std::make_unique(std::move(frame), ssrc_, - receiver_)); + if (short_circuit_) { + // Just pass the frame straight back. + receiver_->ManageFrame(std::move(frame)); + } else { + frame_transformer_->Transform( + std::make_unique(std::move(frame), + ssrc_, receiver_)); + } } void RtpVideoStreamReceiverFrameTransformerDelegate::OnTransformedFrame( @@ -138,6 +144,20 @@ void RtpVideoStreamReceiverFrameTransformerDelegate::OnTransformedFrame( }); } +void RtpVideoStreamReceiverFrameTransformerDelegate::StartShortCircuiting() { + rtc::scoped_refptr delegate( + this); + network_thread_->PostTask([delegate = std::move(delegate)]() mutable { + delegate->StartShortCircuitingOnNetworkSequence(); + }); +} + +void RtpVideoStreamReceiverFrameTransformerDelegate:: + StartShortCircuitingOnNetworkSequence() { + RTC_DCHECK_RUN_ON(&network_sequence_checker_); + short_circuit_ = true; +} + void RtpVideoStreamReceiverFrameTransformerDelegate::ManageFrame( std::unique_ptr frame) { RTC_DCHECK_RUN_ON(&network_sequence_checker_); diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h index 20f9a5caa9..02f2e53923 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h @@ -54,6 +54,8 @@ class RtpVideoStreamReceiverFrameTransformerDelegate void OnTransformedFrame( std::unique_ptr frame) override; + void StartShortCircuiting() override; + // Delegates the call to RtpVideoFrameReceiver::ManageFrame on the // `network_thread_`. void ManageFrame(std::unique_ptr frame); @@ -62,6 +64,8 @@ class RtpVideoStreamReceiverFrameTransformerDelegate ~RtpVideoStreamReceiverFrameTransformerDelegate() override = default; private: + void StartShortCircuitingOnNetworkSequence(); + RTC_NO_UNIQUE_ADDRESS SequenceChecker network_sequence_checker_; RtpVideoFrameReceiver* receiver_ RTC_GUARDED_BY(network_sequence_checker_); rtc::scoped_refptr frame_transformer_ @@ -69,6 +73,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate TaskQueueBase* const network_thread_; const uint32_t ssrc_; Clock* const clock_; + bool short_circuit_ RTC_GUARDED_BY(network_sequence_checker_) = false; }; } // namespace webrtc diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc index f403c91a74..cf3062610f 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate_unittest.cc @@ -349,5 +349,28 @@ TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest, rtc::ThreadManager::ProcessAllMessageQueuesForTesting(); } +TEST(RtpVideoStreamReceiverFrameTransformerDelegateTest, + ShortCircuitingSkipsTransform) { + rtc::AutoThread main_thread_; + TestRtpVideoFrameReceiver receiver; + auto mock_frame_transformer = + rtc::make_ref_counted>(); + SimulatedClock clock(0); + auto delegate = + rtc::make_ref_counted( + &receiver, &clock, mock_frame_transformer, rtc::Thread::Current(), + 1111); + delegate->Init(); + + delegate->StartShortCircuiting(); + rtc::ThreadManager::ProcessAllMessageQueuesForTesting(); + + // Will not call the actual transformer. + EXPECT_CALL(*mock_frame_transformer, Transform).Times(0); + // Will pass the frame straight to the reciever. + EXPECT_CALL(receiver, ManageFrame); + delegate->TransformFrame(CreateRtpFrameObject()); +} + } // namespace } // namespace webrtc diff --git a/third_party/libwebrtc/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc b/third_party/libwebrtc/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc index 870f788538..30bbbc5000 100644 --- a/third_party/libwebrtc/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc +++ b/third_party/libwebrtc/modules/rtp_rtcp/source/video_rtp_depacketizer_av1.cc @@ -188,8 +188,7 @@ VectorObuInfo ParseObus( VectorObuInfo obu_infos; bool expect_continues_obu = false; for (rtc::ArrayView rtp_payload : rtp_payloads) { - rtc::ByteBufferReader payload( - reinterpret_cast(rtp_payload.data()), rtp_payload.size()); + rtc::ByteBufferReader payload(rtp_payload); uint8_t aggregation_header; if (!payload.ReadUInt8(&aggregation_header)) { RTC_DLOG(LS_WARNING) diff --git a/third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build b/third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build index d2e3ea0128..c260743e28 100644 --- a/third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build +++ b/third_party/libwebrtc/modules/third_party/fft/fft_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build b/third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build index aa7a21a680..c2d2597a21 100644 --- a/third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build +++ b/third_party/libwebrtc/modules/third_party/g711/g711_3p_gn/moz.build @@ -184,7 +184,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -194,10 +193,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build b/third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build index 41a8c05bae..468cc88c65 100644 --- a/third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build +++ b/third_party/libwebrtc/modules/third_party/g722/g722_3p_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/utility/utility_gn/moz.build b/third_party/libwebrtc/modules/utility/utility_gn/moz.build index b6921b7626..6c17ac236e 100644 --- a/third_party/libwebrtc/modules/utility/utility_gn/moz.build +++ b/third_party/libwebrtc/modules/utility/utility_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": ] OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_capture/linux/camera_portal.cc b/third_party/libwebrtc/modules/video_capture/linux/camera_portal.cc index 85b9f20228..106ca1682c 100644 --- a/third_party/libwebrtc/modules/video_capture/linux/camera_portal.cc +++ b/third_party/libwebrtc/modules/video_capture/linux/camera_portal.cc @@ -15,6 +15,7 @@ #include "modules/portal/pipewire_utils.h" #include "modules/portal/xdg_desktop_portal_utils.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { @@ -54,7 +55,9 @@ class CameraPortalPrivate { GAsyncResult* result, gpointer user_data); - CameraPortal::PortalNotifier* notifier_ = nullptr; + webrtc::Mutex notifier_lock_; + CameraPortal::PortalNotifier* notifier_ RTC_GUARDED_BY(¬ifier_lock_) = + nullptr; GDBusConnection* connection_ = nullptr; GDBusProxy* proxy_ = nullptr; @@ -66,6 +69,11 @@ CameraPortalPrivate::CameraPortalPrivate(CameraPortal::PortalNotifier* notifier) : notifier_(notifier) {} CameraPortalPrivate::~CameraPortalPrivate() { + { + webrtc::MutexLock lock(¬ifier_lock_); + notifier_ = nullptr; + } + if (access_request_signal_id_) { g_dbus_connection_signal_unsubscribe(connection_, access_request_signal_id_); @@ -229,7 +237,11 @@ void CameraPortalPrivate::OnOpenResponse(GDBusProxy* proxy, } void CameraPortalPrivate::OnPortalDone(RequestResponse result, int fd) { - notifier_->OnCameraRequestResult(result, fd); + webrtc::MutexLock lock(¬ifier_lock_); + if (notifier_) { + notifier_->OnCameraRequestResult(result, fd); + notifier_ = nullptr; + } } CameraPortal::CameraPortal(PortalNotifier* notifier) diff --git a/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.cc b/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.cc index ad6cea57b8..31d922035b 100644 --- a/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.cc +++ b/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.cc @@ -20,10 +20,10 @@ #include +#include "modules/video_capture/linux/pipewire_session.h" #include "modules/video_capture/video_capture.h" #include "modules/video_capture/video_capture_defines.h" #include "modules/video_capture/video_capture_impl.h" -#include "modules/video_capture/video_capture_options.h" #include "rtc_base/logging.h" namespace webrtc { @@ -38,6 +38,8 @@ int32_t DeviceInfoPipeWire::Init() { DeviceInfoPipeWire::~DeviceInfoPipeWire() = default; uint32_t DeviceInfoPipeWire::NumberOfDevices() { + RTC_CHECK(pipewire_session_); + return pipewire_session_->nodes().size(); } @@ -50,6 +52,8 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber, uint32_t productUniqueIdUTF8Length, pid_t* pid, bool* deviceIsPlaceholder) { + RTC_CHECK(pipewire_session_); + if (deviceNumber >= NumberOfDevices()) return -1; @@ -85,6 +89,8 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber, int32_t DeviceInfoPipeWire::CreateCapabilityMap( const char* deviceUniqueIdUTF8) { + RTC_CHECK(pipewire_session_); + for (auto& node : pipewire_session_->nodes()) { if (node.unique_id().compare(deviceUniqueIdUTF8) != 0) continue; diff --git a/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.h b/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.h index 1a1324e92b..00715c94bc 100644 --- a/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.h +++ b/third_party/libwebrtc/modules/video_capture/linux/device_info_pipewire.h @@ -14,7 +14,7 @@ #include #include "modules/video_capture/device_info_impl.h" -#include "modules/video_capture/linux/pipewire_session.h" +#include "modules/video_capture/video_capture_options.h" namespace webrtc { namespace videocapturemodule { diff --git a/third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc b/third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc index eaeed26b7c..401c38f9c5 100644 --- a/third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc +++ b/third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc @@ -57,24 +57,6 @@ #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) #endif -// These defines are here to support building on kernel 3.16 which some -// downstream projects, e.g. Firefox, use. -// TODO(apehrson): Remove them and their undefs when no longer needed. -#ifndef V4L2_PIX_FMT_ABGR32 -#define ABGR32_OVERRIDE 1 -#define V4L2_PIX_FMT_ABGR32 v4l2_fourcc('A', 'R', '2', '4') -#endif - -#ifndef V4L2_PIX_FMT_ARGB32 -#define ARGB32_OVERRIDE 1 -#define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') -#endif - -#ifndef V4L2_PIX_FMT_RGBA32 -#define RGBA32_OVERRIDE 1 -#define V4L2_PIX_FMT_RGBA32 v4l2_fourcc('A', 'B', '2', '4') -#endif - namespace webrtc { namespace videocapturemodule { #ifdef WEBRTC_LINUX diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc index 8af483636a..319824d3c5 100644 --- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc +++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_pipewire.cc @@ -178,8 +178,7 @@ int32_t VideoCaptureModulePipeWire::StartCapture( int res = pw_stream_connect( stream_, PW_DIRECTION_INPUT, node_id_, static_cast(PW_STREAM_FLAG_AUTOCONNECT | - PW_STREAM_FLAG_DONT_RECONNECT | - PW_STREAM_FLAG_MAP_BUFFERS), + PW_STREAM_FLAG_DONT_RECONNECT), params.data(), params.size()); if (res != 0) { RTC_LOG(LS_ERROR) << "Could not connect to camera stream: " @@ -312,11 +311,11 @@ void VideoCaptureModulePipeWire::OnFormatChanged(const struct spa_pod* format) { 0); } + const int buffer_types = + (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr); spa_pod_builder_add( &builder, SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(8, 1, 32), - SPA_PARAM_BUFFERS_dataType, - SPA_POD_CHOICE_FLAGS_Int((1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr)), - 0); + SPA_PARAM_BUFFERS_dataType, SPA_POD_CHOICE_FLAGS_Int(buffer_types), 0); params.push_back( static_cast(spa_pod_builder_pop(&builder, &frame))); @@ -384,14 +383,15 @@ void VideoCaptureModulePipeWire::ProcessBuffers() { RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); while (pw_buffer* buffer = pw_stream_dequeue_buffer(stream_)) { + spa_buffer* spaBuffer = buffer->buffer; struct spa_meta_header* h; h = static_cast( - spa_buffer_find_meta_data(buffer->buffer, SPA_META_Header, sizeof(*h))); + spa_buffer_find_meta_data(spaBuffer, SPA_META_Header, sizeof(*h))); struct spa_meta_videotransform* videotransform; videotransform = static_cast(spa_buffer_find_meta_data( - buffer->buffer, SPA_META_VideoTransform, sizeof(*videotransform))); + spaBuffer, SPA_META_VideoTransform, sizeof(*videotransform))); if (videotransform) { VideoRotation rotation = VideorotationFromPipeWireTransform(videotransform->transform); @@ -401,11 +401,35 @@ void VideoCaptureModulePipeWire::ProcessBuffers() { if (h->flags & SPA_META_HEADER_FLAG_CORRUPTED) { RTC_LOG(LS_INFO) << "Dropping corruped frame."; - } else { - IncomingFrame(static_cast(buffer->buffer->datas[0].data), - buffer->buffer->datas[0].chunk->size, - configured_capability_); + pw_stream_queue_buffer(stream_, buffer); + continue; + } + + if (spaBuffer->datas[0].type == SPA_DATA_DmaBuf || + spaBuffer->datas[0].type == SPA_DATA_MemFd) { + ScopedBuf frame; + frame.initialize( + static_cast( + mmap(nullptr, + spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset, + PROT_READ, MAP_PRIVATE, spaBuffer->datas[0].fd, 0)), + spaBuffer->datas[0].maxsize + spaBuffer->datas[0].mapoffset, + spaBuffer->datas[0].fd, spaBuffer->datas[0].type == SPA_DATA_DmaBuf); + + if (!frame) { + RTC_LOG(LS_ERROR) << "Failed to mmap the memory: " + << std::strerror(errno); + return; + } + + IncomingFrame( + SPA_MEMBER(frame.get(), spaBuffer->datas[0].mapoffset, uint8_t), + spaBuffer->datas[0].chunk->size, configured_capability_); + } else { // SPA_DATA_MemPtr + IncomingFrame(static_cast(spaBuffer->datas[0].data), + spaBuffer->datas[0].chunk->size, configured_capability_); } + pw_stream_queue_buffer(stream_, buffer); } } diff --git a/third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc b/third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc index c887683dc8..08d23f7f58 100644 --- a/third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc +++ b/third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc @@ -294,7 +294,7 @@ int32_t VideoCaptureModuleV4L2::StartCapture( if (_captureThread.empty()) { quit_ = false; _captureThread = rtc::PlatformThread::SpawnJoinable( - [self = rtc::scoped_refptr(this)] { + [self = scoped_refptr(this)] { while (self->CaptureProcess()) { } }, diff --git a/third_party/libwebrtc/modules/video_capture/video_capture.h b/third_party/libwebrtc/modules/video_capture/video_capture.h index 378a53b4d2..f59c34f8b2 100644 --- a/third_party/libwebrtc/modules/video_capture/video_capture.h +++ b/third_party/libwebrtc/modules/video_capture/video_capture.h @@ -34,7 +34,7 @@ protected: virtual ~VideoInputFeedBack(){} }; -class VideoCaptureModule : public rtc::RefCountInterface { +class VideoCaptureModule : public RefCountInterface { public: // Interface for receiving information about available camera devices. class DeviceInfo { diff --git a/third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build b/third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build index 24988a1ffc..f58aa8e782 100644 --- a/third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build +++ b/third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn/moz.build @@ -267,7 +267,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -277,10 +276,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["WEBRTC_USE_PIPEWIRE"] = True diff --git a/third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build b/third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build index 49c62d5cf6..820d5655df 100644 --- a/third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build +++ b/third_party/libwebrtc/modules/video_capture/video_capture_module_gn/moz.build @@ -204,7 +204,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -214,10 +213,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/BUILD.gn b/third_party/libwebrtc/modules/video_coding/BUILD.gn index cca9d8883a..d9e614ff81 100644 --- a/third_party/libwebrtc/modules/video_coding/BUILD.gn +++ b/third_party/libwebrtc/modules/video_coding/BUILD.gn @@ -757,7 +757,6 @@ if (rtc_include_tests) { "../../api/video_codecs:video_codecs_api", "../../modules/utility:utility", "../../rtc_base:checks", - "../../rtc_base:ignore_wundef", "../../sdk/android:internal_jni", "../../sdk/android:native_api_base", "../../sdk/android:native_api_codecs", @@ -852,8 +851,6 @@ if (rtc_include_tests) { "../../api:frame_generator_api", "../../api:scoped_refptr", "../../api:sequence_checker", - "../../api:video_codec_stats_api", - "../../api:video_codec_tester_api", "../../api:videocodec_test_fixture_api", "../../api/numerics:numerics", "../../api/task_queue", @@ -995,46 +992,6 @@ if (rtc_include_tests) { ] } - rtc_library("video_codec_tester") { - testonly = true - sources = [ - "codecs/test/video_codec_analyzer.cc", - "codecs/test/video_codec_analyzer.h", - "codecs/test/video_codec_stats_impl.cc", - "codecs/test/video_codec_stats_impl.h", - "codecs/test/video_codec_tester_impl.cc", - "codecs/test/video_codec_tester_impl.h", - ] - - deps = [ - ":video_coding_utility", - "../../api:sequence_checker", - "../../api:video_codec_stats_api", - "../../api:video_codec_tester_api", - "../../api/numerics:numerics", - "../../api/task_queue:default_task_queue_factory", - "../../api/test/metrics:metrics_logger", - "../../api/units:data_rate", - "../../api/units:frequency", - "../../api/units:time_delta", - "../../api/units:timestamp", - "../../api/video:encoded_image", - "../../api/video:resolution", - "../../api/video:video_codec_constants", - "../../api/video:video_frame", - "../../rtc_base:checks", - "../../rtc_base:rtc_event", - "../../rtc_base:task_queue_for_test", - "../../rtc_base:timeutils", - "../../rtc_base/system:no_unique_address", - "../../system_wrappers", - "../../test:video_test_support", - "//third_party/libyuv", - ] - - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] - } - rtc_test("video_codec_perf_tests") { testonly = true @@ -1042,28 +999,20 @@ if (rtc_include_tests) { deps = [ ":video_codec_interface", - ":video_codec_tester", - "../../api:create_video_codec_tester_api", - "../../api:video_codec_tester_api", - "../../api:videocodec_test_stats_api", "../../api/test/metrics:global_metrics_logger_and_exporter", "../../api/units:data_rate", "../../api/units:frequency", - "../../api/video:encoded_image", "../../api/video:resolution", - "../../api/video:video_frame", - "../../api/video_codecs:scalability_mode", - "../../api/video_codecs:video_codecs_api", - "../../media:rtc_internal_video_codecs", + "../../api/video_codecs:builtin_video_decoder_factory", + "../../api/video_codecs:builtin_video_encoder_factory", + "../../modules/video_coding/svc:scalability_mode_util", "../../rtc_base:logging", + "../../rtc_base:stringutils", "../../test:fileutils", "../../test:test_flags", "../../test:test_main", "../../test:test_support", - "../../test:video_test_support", - "../rtp_rtcp:rtp_rtcp_format", - "svc:scalability_mode_util", - "//third_party/libyuv", + "../../test:video_codec_tester", ] if (is_android) { @@ -1191,9 +1140,6 @@ if (rtc_include_tests) { sources = [ "chain_diff_calculator_unittest.cc", - "codecs/test/video_codec_analyzer_unittest.cc", - "codecs/test/video_codec_stats_impl_unittest.cc", - "codecs/test/video_codec_tester_impl_unittest.cc", "codecs/test/videocodec_test_fixture_config_unittest.cc", "codecs/test/videocodec_test_stats_impl_unittest.cc", "codecs/test/videoprocessor_unittest.cc", @@ -1248,7 +1194,6 @@ if (rtc_include_tests) { ":packet_buffer", ":simulcast_test_fixture_impl", ":video_codec_interface", - ":video_codec_tester", ":video_codecs_test_framework", ":video_coding", ":video_coding_legacy", @@ -1271,7 +1216,6 @@ if (rtc_include_tests) { "../../api:rtp_packet_info", "../../api:scoped_refptr", "../../api:simulcast_test_fixture_api", - "../../api:video_codec_tester_api", "../../api:videocodec_test_fixture_api", "../../api/task_queue", "../../api/task_queue:default_task_queue_factory", @@ -1297,6 +1241,7 @@ if (rtc_include_tests) { "../../common_video/generic_frame_descriptor", "../../common_video/test:utilities", "../../media:media_constants", + "../../media:rtc_internal_video_codecs", "../../media:rtc_media_base", "../../rtc_base:checks", "../../rtc_base:gunit_helpers", diff --git a/third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build b/third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build index dd8e979e41..144097f87a 100644 --- a/third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/chain_diff_calculator_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build b/third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build index 73fce5bf02..cf74ae964c 100644 --- a/third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/codec_globals_headers_gn/moz.build @@ -180,16 +180,9 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] -if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": - - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build b/third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build index e67bb6616d..bfe37b935d 100644 --- a/third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/codecs/av1/av1_svc_config_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.cc deleted file mode 100644 index 772c15734a..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.cc +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/video_coding/codecs/test/video_codec_analyzer.h" - -#include - -#include "api/task_queue/default_task_queue_factory.h" -#include "api/video/i420_buffer.h" -#include "api/video/video_codec_constants.h" -#include "api/video/video_frame.h" -#include "rtc_base/checks.h" -#include "rtc_base/event.h" -#include "rtc_base/time_utils.h" -#include "third_party/libyuv/include/libyuv/compare.h" - -namespace webrtc { -namespace test { - -namespace { -using Psnr = VideoCodecStats::Frame::Psnr; - -Psnr CalcPsnr(const I420BufferInterface& ref_buffer, - const I420BufferInterface& dec_buffer) { - RTC_CHECK_EQ(ref_buffer.width(), dec_buffer.width()); - RTC_CHECK_EQ(ref_buffer.height(), dec_buffer.height()); - - uint64_t sse_y = libyuv::ComputeSumSquareErrorPlane( - dec_buffer.DataY(), dec_buffer.StrideY(), ref_buffer.DataY(), - ref_buffer.StrideY(), dec_buffer.width(), dec_buffer.height()); - - uint64_t sse_u = libyuv::ComputeSumSquareErrorPlane( - dec_buffer.DataU(), dec_buffer.StrideU(), ref_buffer.DataU(), - ref_buffer.StrideU(), dec_buffer.width() / 2, dec_buffer.height() / 2); - - uint64_t sse_v = libyuv::ComputeSumSquareErrorPlane( - dec_buffer.DataV(), dec_buffer.StrideV(), ref_buffer.DataV(), - ref_buffer.StrideV(), dec_buffer.width() / 2, dec_buffer.height() / 2); - - int num_y_samples = dec_buffer.width() * dec_buffer.height(); - Psnr psnr; - psnr.y = libyuv::SumSquareErrorToPsnr(sse_y, num_y_samples); - psnr.u = libyuv::SumSquareErrorToPsnr(sse_u, num_y_samples / 4); - psnr.v = libyuv::SumSquareErrorToPsnr(sse_v, num_y_samples / 4); - - return psnr; -} - -} // namespace - -VideoCodecAnalyzer::VideoCodecAnalyzer( - ReferenceVideoSource* reference_video_source) - : reference_video_source_(reference_video_source), num_frames_(0) { - sequence_checker_.Detach(); -} - -void VideoCodecAnalyzer::StartEncode(const VideoFrame& input_frame) { - int64_t encode_start_us = rtc::TimeMicros(); - task_queue_.PostTask( - [this, timestamp_rtp = input_frame.timestamp(), encode_start_us]() { - RTC_DCHECK_RUN_ON(&sequence_checker_); - - RTC_CHECK(frame_num_.find(timestamp_rtp) == frame_num_.end()); - frame_num_[timestamp_rtp] = num_frames_++; - - stats_.AddFrame({.frame_num = frame_num_[timestamp_rtp], - .timestamp_rtp = timestamp_rtp, - .encode_start = Timestamp::Micros(encode_start_us)}); - }); -} - -void VideoCodecAnalyzer::FinishEncode(const EncodedImage& frame) { - int64_t encode_finished_us = rtc::TimeMicros(); - - task_queue_.PostTask([this, timestamp_rtp = frame.RtpTimestamp(), - spatial_idx = frame.SpatialIndex().value_or(0), - temporal_idx = frame.TemporalIndex().value_or(0), - width = frame._encodedWidth, - height = frame._encodedHeight, - frame_type = frame._frameType, - frame_size_bytes = frame.size(), qp = frame.qp_, - encode_finished_us]() { - RTC_DCHECK_RUN_ON(&sequence_checker_); - - if (spatial_idx > 0) { - VideoCodecStats::Frame* base_frame = - stats_.GetFrame(timestamp_rtp, /*spatial_idx=*/0); - - stats_.AddFrame({.frame_num = base_frame->frame_num, - .timestamp_rtp = timestamp_rtp, - .spatial_idx = spatial_idx, - .encode_start = base_frame->encode_start}); - } - - VideoCodecStats::Frame* fs = stats_.GetFrame(timestamp_rtp, spatial_idx); - fs->spatial_idx = spatial_idx; - fs->temporal_idx = temporal_idx; - fs->width = width; - fs->height = height; - fs->frame_size = DataSize::Bytes(frame_size_bytes); - fs->qp = qp; - fs->keyframe = frame_type == VideoFrameType::kVideoFrameKey; - fs->encode_time = Timestamp::Micros(encode_finished_us) - fs->encode_start; - fs->encoded = true; - }); -} - -void VideoCodecAnalyzer::StartDecode(const EncodedImage& frame) { - int64_t decode_start_us = rtc::TimeMicros(); - task_queue_.PostTask([this, timestamp_rtp = frame.RtpTimestamp(), - spatial_idx = frame.SpatialIndex().value_or(0), - frame_size_bytes = frame.size(), decode_start_us]() { - RTC_DCHECK_RUN_ON(&sequence_checker_); - - VideoCodecStats::Frame* fs = stats_.GetFrame(timestamp_rtp, spatial_idx); - if (fs == nullptr) { - if (frame_num_.find(timestamp_rtp) == frame_num_.end()) { - frame_num_[timestamp_rtp] = num_frames_++; - } - stats_.AddFrame({.frame_num = frame_num_[timestamp_rtp], - .timestamp_rtp = timestamp_rtp, - .spatial_idx = spatial_idx, - .frame_size = DataSize::Bytes(frame_size_bytes)}); - fs = stats_.GetFrame(timestamp_rtp, spatial_idx); - } - - fs->decode_start = Timestamp::Micros(decode_start_us); - }); -} - -void VideoCodecAnalyzer::FinishDecode(const VideoFrame& frame, - int spatial_idx) { - int64_t decode_finished_us = rtc::TimeMicros(); - task_queue_.PostTask([this, timestamp_rtp = frame.timestamp(), spatial_idx, - width = frame.width(), height = frame.height(), - decode_finished_us]() { - RTC_DCHECK_RUN_ON(&sequence_checker_); - VideoCodecStats::Frame* fs = stats_.GetFrame(timestamp_rtp, spatial_idx); - fs->decode_time = Timestamp::Micros(decode_finished_us) - fs->decode_start; - - if (!fs->encoded) { - fs->width = width; - fs->height = height; - } - - fs->decoded = true; - }); - - if (reference_video_source_ != nullptr) { - // Copy hardware-backed frame into main memory to release output buffers - // which number may be limited in hardware decoders. - rtc::scoped_refptr decoded_buffer = - frame.video_frame_buffer()->ToI420(); - - task_queue_.PostTask([this, decoded_buffer, - timestamp_rtp = frame.timestamp(), spatial_idx]() { - RTC_DCHECK_RUN_ON(&sequence_checker_); - VideoFrame ref_frame = reference_video_source_->GetFrame( - timestamp_rtp, {.width = decoded_buffer->width(), - .height = decoded_buffer->height()}); - rtc::scoped_refptr ref_buffer = - ref_frame.video_frame_buffer()->ToI420(); - - Psnr psnr = CalcPsnr(*decoded_buffer, *ref_buffer); - - VideoCodecStats::Frame* fs = - this->stats_.GetFrame(timestamp_rtp, spatial_idx); - fs->psnr = psnr; - }); - } -} - -std::unique_ptr VideoCodecAnalyzer::GetStats() { - std::unique_ptr stats; - rtc::Event ready; - task_queue_.PostTask([this, &stats, &ready]() mutable { - RTC_DCHECK_RUN_ON(&sequence_checker_); - stats.reset(new VideoCodecStatsImpl(stats_)); - ready.Set(); - }); - ready.Wait(rtc::Event::kForever); - return stats; -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.h b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.h deleted file mode 100644 index 29ca8ee2ff..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_ANALYZER_H_ -#define MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_ANALYZER_H_ - -#include -#include - -#include "absl/types/optional.h" -#include "api/sequence_checker.h" -#include "api/test/video_codec_tester.h" -#include "api/video/encoded_image.h" -#include "api/video/resolution.h" -#include "api/video/video_frame.h" -#include "modules/video_coding/codecs/test/video_codec_stats_impl.h" -#include "rtc_base/system/no_unique_address.h" -#include "rtc_base/task_queue_for_test.h" - -namespace webrtc { -namespace test { - -// Analyzer measures and collects metrics necessary for evaluation of video -// codec quality and performance. This class is thread-safe. -class VideoCodecAnalyzer { - public: - // An interface that provides reference frames for spatial quality analysis. - class ReferenceVideoSource { - public: - virtual ~ReferenceVideoSource() = default; - - virtual VideoFrame GetFrame(uint32_t timestamp_rtp, - Resolution resolution) = 0; - }; - - explicit VideoCodecAnalyzer( - ReferenceVideoSource* reference_video_source = nullptr); - - void StartEncode(const VideoFrame& frame); - - void FinishEncode(const EncodedImage& frame); - - void StartDecode(const EncodedImage& frame); - - void FinishDecode(const VideoFrame& frame, int spatial_idx); - - std::unique_ptr GetStats(); - - protected: - TaskQueueForTest task_queue_; - - ReferenceVideoSource* const reference_video_source_; - - VideoCodecStatsImpl stats_ RTC_GUARDED_BY(sequence_checker_); - - // Map from RTP timestamp to frame number. - std::map frame_num_ RTC_GUARDED_BY(sequence_checker_); - - // Processed frames counter. - int num_frames_ RTC_GUARDED_BY(sequence_checker_); - - RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_; -}; - -} // namespace test -} // namespace webrtc - -#endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_ANALYZER_H_ diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer_unittest.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer_unittest.cc deleted file mode 100644 index 03146417da..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_analyzer_unittest.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/video_coding/codecs/test/video_codec_analyzer.h" - -#include "absl/types/optional.h" -#include "api/video/i420_buffer.h" -#include "test/gmock.h" -#include "test/gtest.h" -#include "third_party/libyuv/include/libyuv/planar_functions.h" - -namespace webrtc { -namespace test { - -namespace { -using ::testing::Return; -using ::testing::Values; -using Psnr = VideoCodecStats::Frame::Psnr; - -const uint32_t kTimestamp = 3000; -const int kSpatialIdx = 2; - -class MockReferenceVideoSource - : public VideoCodecAnalyzer::ReferenceVideoSource { - public: - MOCK_METHOD(VideoFrame, GetFrame, (uint32_t, Resolution), (override)); -}; - -VideoFrame CreateVideoFrame(uint32_t timestamp_rtp, - uint8_t y = 0, - uint8_t u = 0, - uint8_t v = 0) { - rtc::scoped_refptr buffer(I420Buffer::Create(2, 2)); - - libyuv::I420Rect(buffer->MutableDataY(), buffer->StrideY(), - buffer->MutableDataU(), buffer->StrideU(), - buffer->MutableDataV(), buffer->StrideV(), 0, 0, - buffer->width(), buffer->height(), y, u, v); - - return VideoFrame::Builder() - .set_video_frame_buffer(buffer) - .set_timestamp_rtp(timestamp_rtp) - .build(); -} - -EncodedImage CreateEncodedImage(uint32_t timestamp_rtp, int spatial_idx = 0) { - EncodedImage encoded_image; - encoded_image.SetRtpTimestamp(timestamp_rtp); - encoded_image.SetSpatialIndex(spatial_idx); - return encoded_image; -} -} // namespace - -TEST(VideoCodecAnalyzerTest, StartEncode) { - VideoCodecAnalyzer analyzer; - analyzer.StartEncode(CreateVideoFrame(kTimestamp)); - - auto fs = analyzer.GetStats()->Slice(); - EXPECT_EQ(1u, fs.size()); - EXPECT_EQ(fs[0].timestamp_rtp, kTimestamp); -} - -TEST(VideoCodecAnalyzerTest, FinishEncode) { - VideoCodecAnalyzer analyzer; - analyzer.StartEncode(CreateVideoFrame(kTimestamp)); - - EncodedImage encoded_frame = CreateEncodedImage(kTimestamp, kSpatialIdx); - analyzer.FinishEncode(encoded_frame); - - auto fs = analyzer.GetStats()->Slice(); - EXPECT_EQ(2u, fs.size()); - EXPECT_EQ(kSpatialIdx, fs[1].spatial_idx); -} - -TEST(VideoCodecAnalyzerTest, StartDecode) { - VideoCodecAnalyzer analyzer; - analyzer.StartDecode(CreateEncodedImage(kTimestamp, kSpatialIdx)); - - auto fs = analyzer.GetStats()->Slice(); - EXPECT_EQ(1u, fs.size()); - EXPECT_EQ(kTimestamp, fs[0].timestamp_rtp); -} - -TEST(VideoCodecAnalyzerTest, FinishDecode) { - VideoCodecAnalyzer analyzer; - analyzer.StartDecode(CreateEncodedImage(kTimestamp, kSpatialIdx)); - VideoFrame decoded_frame = CreateVideoFrame(kTimestamp); - analyzer.FinishDecode(decoded_frame, kSpatialIdx); - - auto fs = analyzer.GetStats()->Slice(); - EXPECT_EQ(1u, fs.size()); - EXPECT_EQ(decoded_frame.width(), fs[0].width); - EXPECT_EQ(decoded_frame.height(), fs[0].height); -} - -TEST(VideoCodecAnalyzerTest, ReferenceVideoSource) { - MockReferenceVideoSource reference_video_source; - VideoCodecAnalyzer analyzer(&reference_video_source); - analyzer.StartDecode(CreateEncodedImage(kTimestamp, kSpatialIdx)); - - EXPECT_CALL(reference_video_source, GetFrame) - .WillOnce(Return(CreateVideoFrame(kTimestamp, /*y=*/0, - /*u=*/0, /*v=*/0))); - - analyzer.FinishDecode( - CreateVideoFrame(kTimestamp, /*value_y=*/1, /*value_u=*/2, /*value_v=*/3), - kSpatialIdx); - - auto fs = analyzer.GetStats()->Slice(); - EXPECT_EQ(1u, fs.size()); - EXPECT_TRUE(fs[0].psnr.has_value()); - - const Psnr& psnr = *fs[0].psnr; - EXPECT_NEAR(psnr.y, 48, 1); - EXPECT_NEAR(psnr.u, 42, 1); - EXPECT_NEAR(psnr.v, 38, 1); -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.cc deleted file mode 100644 index 9808e2a601..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.cc +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/video_coding/codecs/test/video_codec_stats_impl.h" - -#include - -#include "api/numerics/samples_stats_counter.h" -#include "api/test/metrics/metrics_logger.h" -#include "rtc_base/checks.h" -#include "rtc_base/time_utils.h" - -namespace webrtc { -namespace test { -namespace { -using Frame = VideoCodecStats::Frame; -using Stream = VideoCodecStats::Stream; - -constexpr Frequency k90kHz = Frequency::Hertz(90000); - -class LeakyBucket { - public: - LeakyBucket() : level_bits_(0) {} - - // Updates bucket level and returns its current level in bits. Data is remove - // from bucket with rate equal to target bitrate of previous frame. Bucket - // level is tracked with floating point precision. Returned value of bucket - // level is rounded up. - int Update(const Frame& frame) { - RTC_CHECK(frame.target_bitrate) << "Bitrate must be specified."; - - if (prev_frame_) { - RTC_CHECK_GT(frame.timestamp_rtp, prev_frame_->timestamp_rtp) - << "Timestamp must increase."; - TimeDelta passed = - (frame.timestamp_rtp - prev_frame_->timestamp_rtp) / k90kHz; - level_bits_ -= - prev_frame_->target_bitrate->bps() * passed.us() / 1000000.0; - level_bits_ = std::max(level_bits_, 0.0); - } - - prev_frame_ = frame; - - level_bits_ += frame.frame_size.bytes() * 8; - return static_cast(std::ceil(level_bits_)); - } - - private: - absl::optional prev_frame_; - double level_bits_; -}; - -// Merges spatial layer frames into superframes. -std::vector Merge(const std::vector& frames) { - std::vector superframes; - // Map from frame timestamp to index in `superframes` vector. - std::map index; - - for (const auto& f : frames) { - if (index.find(f.timestamp_rtp) == index.end()) { - index[f.timestamp_rtp] = static_cast(superframes.size()); - superframes.push_back(f); - continue; - } - - Frame& sf = superframes[index[f.timestamp_rtp]]; - - sf.width = std::max(sf.width, f.width); - sf.height = std::max(sf.height, f.height); - sf.frame_size += f.frame_size; - sf.keyframe |= f.keyframe; - - sf.encode_time = std::max(sf.encode_time, f.encode_time); - sf.decode_time = std::max(sf.decode_time, f.decode_time); - - if (f.spatial_idx > sf.spatial_idx) { - if (f.qp) { - sf.qp = f.qp; - } - if (f.psnr) { - sf.psnr = f.psnr; - } - } - - sf.spatial_idx = std::max(sf.spatial_idx, f.spatial_idx); - sf.temporal_idx = std::max(sf.temporal_idx, f.temporal_idx); - - sf.encoded |= f.encoded; - sf.decoded |= f.decoded; - } - - return superframes; -} - -Timestamp RtpToTime(uint32_t timestamp_rtp) { - return Timestamp::Micros((timestamp_rtp / k90kHz).us()); -} - -SamplesStatsCounter::StatsSample StatsSample(double value, Timestamp time) { - return SamplesStatsCounter::StatsSample{value, time}; -} - -TimeDelta CalcTotalDuration(const std::vector& frames) { - RTC_CHECK(!frames.empty()); - TimeDelta duration = TimeDelta::Zero(); - if (frames.size() > 1) { - duration += - (frames.rbegin()->timestamp_rtp - frames.begin()->timestamp_rtp) / - k90kHz; - } - - // Add last frame duration. If target frame rate is provided, calculate frame - // duration from it. Otherwise, assume duration of last frame is the same as - // duration of preceding frame. - if (frames.rbegin()->target_framerate) { - duration += 1 / *frames.rbegin()->target_framerate; - } else { - RTC_CHECK_GT(frames.size(), 1u); - duration += (frames.rbegin()->timestamp_rtp - - std::next(frames.rbegin())->timestamp_rtp) / - k90kHz; - } - - return duration; -} -} // namespace - -std::vector VideoCodecStatsImpl::Slice( - absl::optional filter) const { - std::vector frames; - for (const auto& [frame_id, f] : frames_) { - if (filter.has_value()) { - if (filter->first_frame.has_value() && - f.frame_num < *filter->first_frame) { - continue; - } - if (filter->last_frame.has_value() && f.frame_num > *filter->last_frame) { - continue; - } - if (filter->spatial_idx.has_value() && - f.spatial_idx != *filter->spatial_idx) { - continue; - } - if (filter->temporal_idx.has_value() && - f.temporal_idx > *filter->temporal_idx) { - continue; - } - } - frames.push_back(f); - } - return frames; -} - -Stream VideoCodecStatsImpl::Aggregate(const std::vector& frames) const { - std::vector superframes = Merge(frames); - RTC_CHECK(!superframes.empty()); - - LeakyBucket leacky_bucket; - Stream stream; - for (size_t i = 0; i < superframes.size(); ++i) { - Frame& f = superframes[i]; - Timestamp time = RtpToTime(f.timestamp_rtp); - - if (!f.frame_size.IsZero()) { - stream.width.AddSample(StatsSample(f.width, time)); - stream.height.AddSample(StatsSample(f.height, time)); - stream.frame_size_bytes.AddSample( - StatsSample(f.frame_size.bytes(), time)); - stream.keyframe.AddSample(StatsSample(f.keyframe, time)); - if (f.qp) { - stream.qp.AddSample(StatsSample(*f.qp, time)); - } - } - - if (f.encoded) { - stream.encode_time_ms.AddSample(StatsSample(f.encode_time.ms(), time)); - } - - if (f.decoded) { - stream.decode_time_ms.AddSample(StatsSample(f.decode_time.ms(), time)); - } - - if (f.psnr) { - stream.psnr.y.AddSample(StatsSample(f.psnr->y, time)); - stream.psnr.u.AddSample(StatsSample(f.psnr->u, time)); - stream.psnr.v.AddSample(StatsSample(f.psnr->v, time)); - } - - if (f.target_framerate) { - stream.target_framerate_fps.AddSample( - StatsSample(f.target_framerate->millihertz() / 1000.0, time)); - } - - if (f.target_bitrate) { - stream.target_bitrate_kbps.AddSample( - StatsSample(f.target_bitrate->bps() / 1000.0, time)); - - int buffer_level_bits = leacky_bucket.Update(f); - stream.transmission_time_ms.AddSample( - StatsSample(buffer_level_bits * rtc::kNumMillisecsPerSec / - f.target_bitrate->bps(), - RtpToTime(f.timestamp_rtp))); - } - } - - TimeDelta duration = CalcTotalDuration(superframes); - DataRate encoded_bitrate = - DataSize::Bytes(stream.frame_size_bytes.GetSum()) / duration; - - int num_encoded_frames = stream.frame_size_bytes.NumSamples(); - Frequency encoded_framerate = num_encoded_frames / duration; - - absl::optional bitrate_mismatch_pct; - if (auto target_bitrate = superframes.begin()->target_bitrate; - target_bitrate) { - bitrate_mismatch_pct = 100.0 * - (encoded_bitrate.bps() - target_bitrate->bps()) / - target_bitrate->bps(); - } - - absl::optional framerate_mismatch_pct; - if (auto target_framerate = superframes.begin()->target_framerate; - target_framerate) { - framerate_mismatch_pct = - 100.0 * - (encoded_framerate.millihertz() - target_framerate->millihertz()) / - target_framerate->millihertz(); - } - - for (auto& f : superframes) { - Timestamp time = RtpToTime(f.timestamp_rtp); - stream.encoded_bitrate_kbps.AddSample( - StatsSample(encoded_bitrate.bps() / 1000.0, time)); - - stream.encoded_framerate_fps.AddSample( - StatsSample(encoded_framerate.millihertz() / 1000.0, time)); - - if (bitrate_mismatch_pct) { - stream.bitrate_mismatch_pct.AddSample( - StatsSample(*bitrate_mismatch_pct, time)); - } - - if (framerate_mismatch_pct) { - stream.framerate_mismatch_pct.AddSample( - StatsSample(*framerate_mismatch_pct, time)); - } - } - - return stream; -} - -void VideoCodecStatsImpl::AddFrame(const Frame& frame) { - FrameId frame_id{.timestamp_rtp = frame.timestamp_rtp, - .spatial_idx = frame.spatial_idx}; - RTC_CHECK(frames_.find(frame_id) == frames_.end()) - << "Frame with timestamp_rtp=" << frame.timestamp_rtp - << " and spatial_idx=" << frame.spatial_idx << " already exists"; - - frames_[frame_id] = frame; -} - -Frame* VideoCodecStatsImpl::GetFrame(uint32_t timestamp_rtp, int spatial_idx) { - FrameId frame_id{.timestamp_rtp = timestamp_rtp, .spatial_idx = spatial_idx}; - if (frames_.find(frame_id) == frames_.end()) { - return nullptr; - } - return &frames_.find(frame_id)->second; -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.h b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.h deleted file mode 100644 index 77471d2ecd..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_ -#define MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_ - -#include -#include -#include - -#include "absl/types/optional.h" -#include "api/test/video_codec_stats.h" - -namespace webrtc { -namespace test { - -// Implementation of `VideoCodecStats`. This class is not thread-safe. -class VideoCodecStatsImpl : public VideoCodecStats { - public: - std::vector Slice( - absl::optional filter = absl::nullopt) const override; - - Stream Aggregate(const std::vector& frames) const override; - - void AddFrame(const Frame& frame); - - // Returns raw pointers to previously added frame. If frame does not exist, - // returns `nullptr`. - Frame* GetFrame(uint32_t timestamp_rtp, int spatial_idx); - - private: - struct FrameId { - uint32_t timestamp_rtp; - int spatial_idx; - - bool operator==(const FrameId& o) const { - return timestamp_rtp == o.timestamp_rtp && spatial_idx == o.spatial_idx; - } - - bool operator<(const FrameId& o) const { - if (timestamp_rtp < o.timestamp_rtp) - return true; - if (timestamp_rtp == o.timestamp_rtp && spatial_idx < o.spatial_idx) - return true; - return false; - } - }; - - std::map frames_; -}; - -} // namespace test -} // namespace webrtc - -#endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_ diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl_unittest.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl_unittest.cc deleted file mode 100644 index ce11d5abe6..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_stats_impl_unittest.cc +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/video_coding/codecs/test/video_codec_stats_impl.h" - -#include - -#include "absl/types/optional.h" -#include "test/gmock.h" -#include "test/gtest.h" - -namespace webrtc { -namespace test { - -namespace { -using ::testing::Return; -using ::testing::Values; -using Filter = VideoCodecStats::Filter; -using Frame = VideoCodecStatsImpl::Frame; -using Stream = VideoCodecStats::Stream; -} // namespace - -TEST(VideoCodecStatsImpl, AddAndGetFrame) { - VideoCodecStatsImpl stats; - stats.AddFrame({.timestamp_rtp = 0, .spatial_idx = 0}); - stats.AddFrame({.timestamp_rtp = 0, .spatial_idx = 1}); - stats.AddFrame({.timestamp_rtp = 1, .spatial_idx = 0}); - - Frame* fs = stats.GetFrame(/*timestamp_rtp=*/0, /*spatial_idx=*/0); - ASSERT_NE(fs, nullptr); - EXPECT_EQ(fs->timestamp_rtp, 0u); - EXPECT_EQ(fs->spatial_idx, 0); - - fs = stats.GetFrame(/*timestamp_rtp=*/0, /*spatial_idx=*/1); - ASSERT_NE(fs, nullptr); - EXPECT_EQ(fs->timestamp_rtp, 0u); - EXPECT_EQ(fs->spatial_idx, 1); - - fs = stats.GetFrame(/*timestamp_rtp=*/1, /*spatial_idx=*/0); - ASSERT_NE(fs, nullptr); - EXPECT_EQ(fs->timestamp_rtp, 1u); - EXPECT_EQ(fs->spatial_idx, 0); - - fs = stats.GetFrame(/*timestamp_rtp=*/1, /*spatial_idx=*/1); - EXPECT_EQ(fs, nullptr); -} - -class VideoCodecStatsImplSlicingTest - : public ::testing::TestWithParam>> {}; - -TEST_P(VideoCodecStatsImplSlicingTest, Slice) { - Filter filter = std::get<0>(GetParam()); - std::vector expected_frames = std::get<1>(GetParam()); - std::vector frames = { - {.frame_num = 0, .timestamp_rtp = 0, .spatial_idx = 0, .temporal_idx = 0}, - {.frame_num = 0, .timestamp_rtp = 0, .spatial_idx = 1, .temporal_idx = 0}, - {.frame_num = 1, .timestamp_rtp = 1, .spatial_idx = 0, .temporal_idx = 1}, - {.frame_num = 1, - .timestamp_rtp = 1, - .spatial_idx = 1, - .temporal_idx = 1}}; - - VideoCodecStatsImpl stats; - stats.AddFrame(frames[0]); - stats.AddFrame(frames[1]); - stats.AddFrame(frames[2]); - stats.AddFrame(frames[3]); - - std::vector slice = stats.Slice(filter); - ASSERT_EQ(slice.size(), expected_frames.size()); - for (size_t i = 0; i < expected_frames.size(); ++i) { - Frame& expected = frames[expected_frames[i]]; - EXPECT_EQ(slice[i].frame_num, expected.frame_num); - EXPECT_EQ(slice[i].timestamp_rtp, expected.timestamp_rtp); - EXPECT_EQ(slice[i].spatial_idx, expected.spatial_idx); - EXPECT_EQ(slice[i].temporal_idx, expected.temporal_idx); - } -} - -INSTANTIATE_TEST_SUITE_P( - All, - VideoCodecStatsImplSlicingTest, - ::testing::Values( - std::make_tuple(Filter{}, std::vector{0, 1, 2, 3}), - std::make_tuple(Filter{.first_frame = 1}, std::vector{2, 3}), - std::make_tuple(Filter{.last_frame = 0}, std::vector{0, 1}), - std::make_tuple(Filter{.spatial_idx = 0}, std::vector{0, 2}), - std::make_tuple(Filter{.temporal_idx = 1}, - std::vector{0, 1, 2, 3}))); - -TEST(VideoCodecStatsImpl, AggregateBitrate) { - std::vector frames = { - {.frame_num = 0, - .timestamp_rtp = 0, - .frame_size = DataSize::Bytes(1000), - .target_bitrate = DataRate::BytesPerSec(1000)}, - {.frame_num = 1, - .timestamp_rtp = 90000, - .frame_size = DataSize::Bytes(2000), - .target_bitrate = DataRate::BytesPerSec(1000)}}; - - Stream stream = VideoCodecStatsImpl().Aggregate(frames); - EXPECT_EQ(stream.encoded_bitrate_kbps.GetAverage(), 12.0); - EXPECT_EQ(stream.bitrate_mismatch_pct.GetAverage(), 50.0); -} - -TEST(VideoCodecStatsImpl, AggregateFramerate) { - std::vector frames = { - {.frame_num = 0, - .timestamp_rtp = 0, - .frame_size = DataSize::Bytes(1), - .target_framerate = Frequency::Hertz(1)}, - {.frame_num = 1, - .timestamp_rtp = 90000, - .frame_size = DataSize::Zero(), - .target_framerate = Frequency::Hertz(1)}}; - - Stream stream = VideoCodecStatsImpl().Aggregate(frames); - EXPECT_EQ(stream.encoded_framerate_fps.GetAverage(), 0.5); - EXPECT_EQ(stream.framerate_mismatch_pct.GetAverage(), -50.0); -} - -TEST(VideoCodecStatsImpl, AggregateTransmissionTime) { - std::vector frames = { - {.frame_num = 0, - .timestamp_rtp = 0, - .frame_size = DataSize::Bytes(2), - .target_bitrate = DataRate::BytesPerSec(1)}, - {.frame_num = 1, - .timestamp_rtp = 90000, - .frame_size = DataSize::Bytes(3), - .target_bitrate = DataRate::BytesPerSec(1)}}; - - Stream stream = VideoCodecStatsImpl().Aggregate(frames); - ASSERT_EQ(stream.transmission_time_ms.NumSamples(), 2); - ASSERT_EQ(stream.transmission_time_ms.GetSamples()[0], 2000); - ASSERT_EQ(stream.transmission_time_ms.GetSamples()[1], 4000); -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_test.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_test.cc index 1c8fe97e84..60c2fcbb6e 100644 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_test.cc +++ b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_test.cc @@ -8,41 +8,62 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "api/video_codecs/video_codec.h" - -#include #include #include #include #include "absl/flags/flag.h" #include "absl/functional/any_invocable.h" -#include "api/test/create_video_codec_tester.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" -#include "api/test/video_codec_tester.h" -#include "api/test/videocodec_test_stats.h" #include "api/units/data_rate.h" #include "api/units/frequency.h" -#include "api/video/encoded_image.h" -#include "api/video/i420_buffer.h" #include "api/video/resolution.h" -#include "api/video/video_frame.h" -#include "api/video_codecs/scalability_mode.h" -#include "api/video_codecs/video_decoder.h" -#include "api/video_codecs/video_encoder.h" -#include "media/engine/internal_decoder_factory.h" -#include "media/engine/internal_encoder_factory.h" -#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" -#include "modules/video_coding/include/video_error_codes.h" -#include "modules/video_coding/svc/scalability_mode_util.h" +#include "api/video_codecs/builtin_video_decoder_factory.h" +#include "api/video_codecs/builtin_video_encoder_factory.h" #if defined(WEBRTC_ANDROID) #include "modules/video_coding/codecs/test/android_codec_factory_helper.h" #endif +#include "modules/video_coding/svc/scalability_mode_util.h" #include "rtc_base/logging.h" +#include "rtc_base/strings/string_builder.h" #include "test/gtest.h" #include "test/test_flags.h" #include "test/testsupport/file_utils.h" -#include "test/testsupport/frame_reader.h" +#include "test/video_codec_tester.h" + +ABSL_FLAG(std::string, + video_name, + "FourPeople_1280x720_30", + "Name of input video sequence."); +ABSL_FLAG(std::string, + encoder, + "libaom-av1", + "Encoder: libaom-av1, libvpx-vp9, libvpx-vp8, openh264, hw-vp8, " + "hw-vp9, hw-av1, hw-h264, hw-h265"); +ABSL_FLAG(std::string, + decoder, + "dav1d", + "Decoder: dav1d, libvpx-vp9, libvpx-vp8, ffmpeg-h264, hw-vp8, " + "hw-vp9, hw-av1, hw-h264, hw-h265"); +ABSL_FLAG(std::string, scalability_mode, "L1T1", "Scalability mode."); +ABSL_FLAG(int, width, 1280, "Width."); +ABSL_FLAG(int, height, 720, "Height."); +ABSL_FLAG(std::vector, + bitrate_kbps, + {"1024"}, + "Encode target bitrate per layer (l0t0,l0t1,...l1t0,l1t1 and so on) " + "in kbps."); +ABSL_FLAG(double, + framerate_fps, + 30.0, + "Encode target frame rate of the top temporal layer in fps."); +ABSL_FLAG(int, num_frames, 300, "Number of frames to encode and/or decode."); +ABSL_FLAG(std::string, test_name, "", "Test name."); +ABSL_FLAG(bool, dump_decoder_input, false, "Dump decoder input."); +ABSL_FLAG(bool, dump_decoder_output, false, "Dump decoder output."); +ABSL_FLAG(bool, dump_encoder_input, false, "Dump encoder input."); +ABSL_FLAG(bool, dump_encoder_output, false, "Dump encoder output."); +ABSL_FLAG(bool, write_csv, false, "Write metrics to a CSV file."); namespace webrtc { namespace test { @@ -50,6 +71,10 @@ namespace test { namespace { using ::testing::Combine; using ::testing::Values; +using VideoSourceSettings = VideoCodecTester::VideoSourceSettings; +using EncodingSettings = VideoCodecTester::EncodingSettings; +using VideoCodecStats = VideoCodecTester::VideoCodecStats; +using Filter = VideoCodecStats::Filter; using PacingMode = VideoCodecTester::PacingSettings::PacingMode; struct VideoInfo { @@ -58,405 +83,93 @@ struct VideoInfo { Frequency framerate; }; -struct LayerId { - int spatial_idx; - int temporal_idx; - - bool operator==(const LayerId& o) const { - return spatial_idx == o.spatial_idx && temporal_idx == o.temporal_idx; - } - - bool operator<(const LayerId& o) const { - if (spatial_idx < o.spatial_idx) - return true; - if (spatial_idx == o.spatial_idx && temporal_idx < o.temporal_idx) - return true; - return false; - } -}; - -struct EncodingSettings { - ScalabilityMode scalability_mode; - struct LayerSettings { - Resolution resolution; - Frequency framerate; - DataRate bitrate; - }; - std::map layer_settings; - - bool IsSameSettings(const EncodingSettings& other) const { - if (scalability_mode != other.scalability_mode) { - return false; - } - - for (auto [layer_id, layer] : layer_settings) { - const auto& other_layer = other.layer_settings.at(layer_id); - if (layer.resolution != other_layer.resolution) { - return false; - } - } - - return true; - } - - bool IsSameRate(const EncodingSettings& other) const { - for (auto [layer_id, layer] : layer_settings) { - const auto& other_layer = other.layer_settings.at(layer_id); - if (layer.bitrate != other_layer.bitrate || - layer.framerate != other_layer.framerate) { - return false; - } - } - - return true; - } -}; - -const VideoInfo kFourPeople_1280x720_30 = { - .name = "FourPeople_1280x720_30", - .resolution = {.width = 1280, .height = 720}, - .framerate = Frequency::Hertz(30)}; - -class TestRawVideoSource : public VideoCodecTester::RawVideoSource { - public: - static constexpr Frequency k90kHz = Frequency::Hertz(90000); - - TestRawVideoSource(VideoInfo video_info, - const std::map& frame_settings, - int num_frames) - : video_info_(video_info), - frame_settings_(frame_settings), - num_frames_(num_frames), - frame_num_(0), - // Start with non-zero timestamp to force using frame RTP timestamps in - // IvfFrameWriter. - timestamp_rtp_(90000) { - // Ensure settings for the first frame are provided. - RTC_CHECK_GT(frame_settings_.size(), 0u); - RTC_CHECK_EQ(frame_settings_.begin()->first, 0); - - frame_reader_ = CreateYuvFrameReader( - ResourcePath(video_info_.name, "yuv"), video_info_.resolution, - YuvFrameReaderImpl::RepeatMode::kPingPong); - RTC_CHECK(frame_reader_); - } - - // Pulls next frame. Frame RTP timestamp is set accordingly to - // `EncodingSettings::framerate`. - absl::optional PullFrame() override { - if (frame_num_ >= num_frames_) { - return absl::nullopt; // End of stream. - } - - const EncodingSettings& encoding_settings = - std::prev(frame_settings_.upper_bound(frame_num_))->second; - - Resolution resolution = - encoding_settings.layer_settings.begin()->second.resolution; - Frequency framerate = - encoding_settings.layer_settings.begin()->second.framerate; - - int pulled_frame; - auto buffer = frame_reader_->PullFrame( - &pulled_frame, resolution, - {.num = static_cast(framerate.millihertz()), - .den = static_cast(video_info_.framerate.millihertz())}); - RTC_CHECK(buffer) << "Cannot pull frame " << frame_num_; - - auto frame = VideoFrame::Builder() - .set_video_frame_buffer(buffer) - .set_timestamp_rtp(timestamp_rtp_) - .set_timestamp_us((timestamp_rtp_ / k90kHz).us()) - .build(); - - pulled_frames_[timestamp_rtp_] = pulled_frame; - timestamp_rtp_ += k90kHz / framerate; - ++frame_num_; - - return frame; - } - - // Reads frame specified by `timestamp_rtp`, scales it to `resolution` and - // returns. Frame with the given `timestamp_rtp` is expected to be pulled - // before. - VideoFrame GetFrame(uint32_t timestamp_rtp, Resolution resolution) override { - RTC_CHECK(pulled_frames_.find(timestamp_rtp) != pulled_frames_.end()) - << "Frame with RTP timestamp " << timestamp_rtp - << " was not pulled before"; - auto buffer = - frame_reader_->ReadFrame(pulled_frames_[timestamp_rtp], resolution); - return VideoFrame::Builder() - .set_video_frame_buffer(buffer) - .set_timestamp_rtp(timestamp_rtp) - .build(); - } - - protected: - VideoInfo video_info_; - std::unique_ptr frame_reader_; - const std::map& frame_settings_; - int num_frames_; - int frame_num_; - uint32_t timestamp_rtp_; - std::map pulled_frames_; -}; - -class TestEncoder : public VideoCodecTester::Encoder, - public EncodedImageCallback { - public: - TestEncoder(std::unique_ptr encoder, - const std::string codec_type, - const std::map& frame_settings) - : encoder_(std::move(encoder)), - codec_type_(codec_type), - frame_settings_(frame_settings), - frame_num_(0) { - // Ensure settings for the first frame is provided. - RTC_CHECK_GT(frame_settings_.size(), 0u); - RTC_CHECK_EQ(frame_settings_.begin()->first, 0); - - encoder_->RegisterEncodeCompleteCallback(this); - } - - void Initialize() override { - const EncodingSettings& first_frame_settings = frame_settings_.at(0); - Configure(first_frame_settings); - SetRates(first_frame_settings); - } - - void Encode(const VideoFrame& frame, EncodeCallback callback) override { - { - MutexLock lock(&mutex_); - callbacks_[frame.timestamp()] = std::move(callback); - } - - if (auto fs = frame_settings_.find(frame_num_); - fs != frame_settings_.begin() && fs != frame_settings_.end()) { - if (!fs->second.IsSameSettings(std::prev(fs)->second)) { - Configure(fs->second); - } else if (!fs->second.IsSameRate(std::prev(fs)->second)) { - SetRates(fs->second); - } - } - - encoder_->Encode(frame, nullptr); - ++frame_num_; - } - - void Flush() override { - // TODO(webrtc:14852): For codecs which buffer frames we need a to - // flush them to get last frames. Add such functionality to VideoEncoder - // API. On Android it will map directly to `MediaCodec.flush()`. - encoder_->Release(); - } - - VideoEncoder* encoder() { return encoder_.get(); } - - protected: - Result OnEncodedImage(const EncodedImage& encoded_image, - const CodecSpecificInfo* codec_specific_info) override { - MutexLock lock(&mutex_); - auto cb = callbacks_.find(encoded_image.RtpTimestamp()); - RTC_CHECK(cb != callbacks_.end()); - cb->second(encoded_image); - - callbacks_.erase(callbacks_.begin(), cb); - return Result(Result::Error::OK); - } - - void Configure(const EncodingSettings& es) { - VideoCodec vc; - const EncodingSettings::LayerSettings& layer_settings = - es.layer_settings.begin()->second; - vc.width = layer_settings.resolution.width; - vc.height = layer_settings.resolution.height; - const DataRate& bitrate = layer_settings.bitrate; - vc.startBitrate = bitrate.kbps(); - vc.maxBitrate = bitrate.kbps(); - vc.minBitrate = 0; - vc.maxFramerate = static_cast(layer_settings.framerate.hertz()); - vc.active = true; - vc.qpMax = 63; - vc.numberOfSimulcastStreams = 0; - vc.mode = webrtc::VideoCodecMode::kRealtimeVideo; - vc.SetFrameDropEnabled(true); - vc.SetScalabilityMode(es.scalability_mode); - - vc.codecType = PayloadStringToCodecType(codec_type_); - if (vc.codecType == kVideoCodecVP8) { - *(vc.VP8()) = VideoEncoder::GetDefaultVp8Settings(); - } else if (vc.codecType == kVideoCodecVP9) { - *(vc.VP9()) = VideoEncoder::GetDefaultVp9Settings(); - } else if (vc.codecType == kVideoCodecH264) { - *(vc.H264()) = VideoEncoder::GetDefaultH264Settings(); - } - - VideoEncoder::Settings ves( - VideoEncoder::Capabilities(/*loss_notification=*/false), - /*number_of_cores=*/1, - /*max_payload_size=*/1440); - - int result = encoder_->InitEncode(&vc, ves); - ASSERT_EQ(result, WEBRTC_VIDEO_CODEC_OK); - - SetRates(es); - } - - void SetRates(const EncodingSettings& es) { - VideoEncoder::RateControlParameters rc; - int num_spatial_layers = - ScalabilityModeToNumSpatialLayers(es.scalability_mode); - int num_temporal_layers = - ScalabilityModeToNumSpatialLayers(es.scalability_mode); - for (int sidx = 0; sidx < num_spatial_layers; ++sidx) { - for (int tidx = 0; tidx < num_temporal_layers; ++tidx) { - auto layer_settings = - es.layer_settings.find({.spatial_idx = sidx, .temporal_idx = tidx}); - RTC_CHECK(layer_settings != es.layer_settings.end()) - << "Bitrate for layer S=" << sidx << " T=" << tidx << " is not set"; - rc.bitrate.SetBitrate(sidx, tidx, layer_settings->second.bitrate.bps()); - } - } - - rc.framerate_fps = - es.layer_settings.begin()->second.framerate.millihertz() / 1000.0; - encoder_->SetRates(rc); - } - - std::unique_ptr encoder_; - const std::string codec_type_; - const std::map& frame_settings_; - int frame_num_; - std::map callbacks_ RTC_GUARDED_BY(mutex_); - Mutex mutex_; -}; - -class TestDecoder : public VideoCodecTester::Decoder, - public DecodedImageCallback { - public: - TestDecoder(std::unique_ptr decoder, - const std::string codec_type) - : decoder_(std::move(decoder)), codec_type_(codec_type) { - decoder_->RegisterDecodeCompleteCallback(this); - } - - void Initialize() override { - VideoDecoder::Settings ds; - ds.set_codec_type(PayloadStringToCodecType(codec_type_)); - ds.set_number_of_cores(1); - ds.set_max_render_resolution({1280, 720}); - - bool result = decoder_->Configure(ds); - ASSERT_TRUE(result); - } - - void Decode(const EncodedImage& frame, DecodeCallback callback) override { - { - MutexLock lock(&mutex_); - callbacks_[frame.RtpTimestamp()] = std::move(callback); - } - - decoder_->Decode(frame, /*render_time_ms=*/0); - } - - void Flush() override { - // TODO(webrtc:14852): For codecs which buffer frames we need a to - // flush them to get last frames. Add such functionality to VideoDecoder - // API. On Android it will map directly to `MediaCodec.flush()`. - decoder_->Release(); - } - - VideoDecoder* decoder() { return decoder_.get(); } - - protected: - int Decoded(VideoFrame& decoded_frame) override { - MutexLock lock(&mutex_); - auto cb = callbacks_.find(decoded_frame.timestamp()); - RTC_CHECK(cb != callbacks_.end()); - cb->second(decoded_frame); +const std::map kRawVideos = { + {"FourPeople_1280x720_30", + {.name = "FourPeople_1280x720_30", + .resolution = {.width = 1280, .height = 720}, + .framerate = Frequency::Hertz(30)}}, + {"vidyo1_1280x720_30", + {.name = "vidyo1_1280x720_30", + .resolution = {.width = 1280, .height = 720}, + .framerate = Frequency::Hertz(30)}}, + {"vidyo4_1280x720_30", + {.name = "vidyo4_1280x720_30", + .resolution = {.width = 1280, .height = 720}, + .framerate = Frequency::Hertz(30)}}, + {"KristenAndSara_1280x720_30", + {.name = "KristenAndSara_1280x720_30", + .resolution = {.width = 1280, .height = 720}, + .framerate = Frequency::Hertz(30)}}, + {"Johnny_1280x720_30", + {.name = "Johnny_1280x720_30", + .resolution = {.width = 1280, .height = 720}, + .framerate = Frequency::Hertz(30)}}}; + +static constexpr Frequency k90kHz = Frequency::Hertz(90000); + +std::string CodecNameToCodecType(std::string name) { + if (name.find("av1") != std::string::npos) { + return "AV1"; + } + if (name.find("vp9") != std::string::npos) { + return "VP9"; + } + if (name.find("vp8") != std::string::npos) { + return "VP8"; + } + if (name.find("h264") != std::string::npos) { + return "H264"; + } + if (name.find("h265") != std::string::npos) { + return "H265"; + } + RTC_CHECK_NOTREACHED(); +} - callbacks_.erase(callbacks_.begin(), cb); - return WEBRTC_VIDEO_CODEC_OK; +// TODO(webrtc:14852): Make Create[Encoder,Decoder]Factory to work with codec +// name directly. +std::string CodecNameToCodecImpl(std::string name) { + if (name.find("hw") != std::string::npos) { + return "mediacodec"; } - - std::unique_ptr decoder_; - const std::string codec_type_; - std::map callbacks_ RTC_GUARDED_BY(mutex_); - Mutex mutex_; -}; - -std::unique_ptr CreateVideoSource( - const VideoInfo& video, - const std::map& frame_settings, - int num_frames) { - return std::make_unique(video, frame_settings, - num_frames); + return "builtin"; } -std::unique_ptr CreateEncoder( - std::string type, - std::string impl, - const std::map& frame_settings) { - std::unique_ptr factory; +std::unique_ptr CreateEncoderFactory(std::string impl) { if (impl == "builtin") { - factory = std::make_unique(); - } else if (impl == "mediacodec") { + return CreateBuiltinVideoEncoderFactory(); + } #if defined(WEBRTC_ANDROID) - InitializeAndroidObjects(); - factory = CreateAndroidEncoderFactory(); + InitializeAndroidObjects(); + return CreateAndroidEncoderFactory(); +#else + return nullptr; #endif - } - std::unique_ptr encoder = - factory->CreateVideoEncoder(SdpVideoFormat(type)); - if (encoder == nullptr) { - return nullptr; - } - return std::make_unique(std::move(encoder), type, - frame_settings); } -std::unique_ptr CreateDecoder(std::string type, std::string impl) { - std::unique_ptr factory; +std::unique_ptr CreateDecoderFactory(std::string impl) { if (impl == "builtin") { - factory = std::make_unique(); - } else if (impl == "mediacodec") { + return CreateBuiltinVideoDecoderFactory(); + } #if defined(WEBRTC_ANDROID) - InitializeAndroidObjects(); - factory = CreateAndroidDecoderFactory(); + InitializeAndroidObjects(); + return CreateAndroidDecoderFactory(); +#else + return nullptr; #endif - } - std::unique_ptr decoder = - factory->CreateVideoDecoder(SdpVideoFormat(type)); - if (decoder == nullptr) { - return nullptr; - } - return std::make_unique(std::move(decoder), type); } -void SetTargetRates(const std::map& frame_settings, - std::vector& frames) { - for (VideoCodecStats::Frame& f : frames) { - const EncodingSettings& encoding_settings = - std::prev(frame_settings.upper_bound(f.frame_num))->second; - LayerId layer_id = {.spatial_idx = f.spatial_idx, - .temporal_idx = f.temporal_idx}; - RTC_CHECK(encoding_settings.layer_settings.find(layer_id) != - encoding_settings.layer_settings.end()) - << "Frame frame_num=" << f.frame_num - << " belongs to spatial_idx=" << f.spatial_idx - << " temporal_idx=" << f.temporal_idx - << " but settings for this layer are not provided."; - const EncodingSettings::LayerSettings& layer_settings = - encoding_settings.layer_settings.at(layer_id); - f.target_bitrate = layer_settings.bitrate; - f.target_framerate = layer_settings.framerate; +std::string TestName() { + std::string test_name = absl::GetFlag(FLAGS_test_name); + if (!test_name.empty()) { + return test_name; } + return ::testing::UnitTest::GetInstance()->current_test_info()->name(); } std::string TestOutputPath() { std::string output_path = - OutputPath() + - ::testing::UnitTest::GetInstance()->current_test_info()->name(); + (rtc::StringBuilder() << OutputPath() << TestName()).str(); std::string output_dir = DirName(output_path); bool result = CreateDir(output_dir); RTC_CHECK(result) << "Cannot create " << output_dir; @@ -465,116 +178,120 @@ std::string TestOutputPath() { } // namespace std::unique_ptr RunEncodeDecodeTest( - std::string codec_type, std::string codec_impl, const VideoInfo& video_info, - const std::map& frame_settings, - int num_frames, - bool save_codec_input, - bool save_codec_output) { - std::unique_ptr video_source = - CreateVideoSource(video_info, frame_settings, num_frames); - - std::unique_ptr encoder = - CreateEncoder(codec_type, codec_impl, frame_settings); - if (encoder == nullptr) { + const std::map& encoding_settings) { + VideoSourceSettings source_settings{ + .file_path = ResourcePath(video_info.name, "yuv"), + .resolution = video_info.resolution, + .framerate = video_info.framerate}; + + const SdpVideoFormat& sdp_video_format = + encoding_settings.begin()->second.sdp_video_format; + + std::unique_ptr encoder_factory = + CreateEncoderFactory(codec_impl); + if (!encoder_factory + ->QueryCodecSupport(sdp_video_format, + /*scalability_mode=*/absl::nullopt) + .is_supported) { + RTC_LOG(LS_WARNING) << "No encoder for video format " + << sdp_video_format.ToString(); return nullptr; } - std::unique_ptr decoder = CreateDecoder(codec_type, codec_impl); - if (decoder == nullptr) { - // If platform decoder is not available try built-in one. - if (codec_impl == "builtin") { - return nullptr; - } - - decoder = CreateDecoder(codec_type, "builtin"); - if (decoder == nullptr) { + std::unique_ptr decoder_factory = + CreateDecoderFactory(codec_impl); + if (!decoder_factory + ->QueryCodecSupport(sdp_video_format, + /*reference_scaling=*/false) + .is_supported) { + decoder_factory = CreateDecoderFactory("builtin"); + if (!decoder_factory + ->QueryCodecSupport(sdp_video_format, + /*reference_scaling=*/false) + .is_supported) { + RTC_LOG(LS_WARNING) << "No decoder for video format " + << sdp_video_format.ToString(); return nullptr; } } - RTC_LOG(LS_INFO) << "Encoder implementation: " - << encoder->encoder()->GetEncoderInfo().implementation_name; - RTC_LOG(LS_INFO) << "Decoder implementation: " - << decoder->decoder()->GetDecoderInfo().implementation_name; + std::string output_path = TestOutputPath(); VideoCodecTester::EncoderSettings encoder_settings; - encoder_settings.pacing.mode = - encoder->encoder()->GetEncoderInfo().is_hardware_accelerated - ? PacingMode::kRealTime - : PacingMode::kNoPacing; + encoder_settings.pacing_settings.mode = + codec_impl == "builtin" ? PacingMode::kNoPacing : PacingMode::kRealTime; + if (absl::GetFlag(FLAGS_dump_encoder_input)) { + encoder_settings.encoder_input_base_path = output_path + "_enc_input"; + } + if (absl::GetFlag(FLAGS_dump_encoder_output)) { + encoder_settings.encoder_output_base_path = output_path + "_enc_output"; + } VideoCodecTester::DecoderSettings decoder_settings; - decoder_settings.pacing.mode = - decoder->decoder()->GetDecoderInfo().is_hardware_accelerated - ? PacingMode::kRealTime - : PacingMode::kNoPacing; - - std::string output_path = TestOutputPath(); - if (save_codec_input) { - encoder_settings.encoder_input_base_path = output_path + "_enc_input"; + decoder_settings.pacing_settings.mode = + codec_impl == "builtin" ? PacingMode::kNoPacing : PacingMode::kRealTime; + if (absl::GetFlag(FLAGS_dump_decoder_input)) { decoder_settings.decoder_input_base_path = output_path + "_dec_input"; } - if (save_codec_output) { - encoder_settings.encoder_output_base_path = output_path + "_enc_output"; + if (absl::GetFlag(FLAGS_dump_decoder_output)) { decoder_settings.decoder_output_base_path = output_path + "_dec_output"; } - std::unique_ptr tester = CreateVideoCodecTester(); - return tester->RunEncodeDecodeTest(video_source.get(), encoder.get(), - decoder.get(), encoder_settings, - decoder_settings); + return VideoCodecTester::RunEncodeDecodeTest( + source_settings, encoder_factory.get(), decoder_factory.get(), + encoder_settings, decoder_settings, encoding_settings); } std::unique_ptr RunEncodeTest( std::string codec_type, std::string codec_impl, const VideoInfo& video_info, - const std::map& frame_settings, - int num_frames, - bool save_codec_input, - bool save_codec_output) { - std::unique_ptr video_source = - CreateVideoSource(video_info, frame_settings, num_frames); - - std::unique_ptr encoder = - CreateEncoder(codec_type, codec_impl, frame_settings); - if (encoder == nullptr) { + const std::map& encoding_settings) { + VideoSourceSettings source_settings{ + .file_path = ResourcePath(video_info.name, "yuv"), + .resolution = video_info.resolution, + .framerate = video_info.framerate}; + + const SdpVideoFormat& sdp_video_format = + encoding_settings.begin()->second.sdp_video_format; + + std::unique_ptr encoder_factory = + CreateEncoderFactory(codec_impl); + if (!encoder_factory + ->QueryCodecSupport(sdp_video_format, + /*scalability_mode=*/absl::nullopt) + .is_supported) { + RTC_LOG(LS_WARNING) << "No encoder for video format " + << sdp_video_format.ToString(); return nullptr; } - RTC_LOG(LS_INFO) << "Encoder implementation: " - << encoder->encoder()->GetEncoderInfo().implementation_name; - - VideoCodecTester::EncoderSettings encoder_settings; - encoder_settings.pacing.mode = - encoder->encoder()->GetEncoderInfo().is_hardware_accelerated - ? PacingMode::kRealTime - : PacingMode::kNoPacing; - std::string output_path = TestOutputPath(); - if (save_codec_input) { + VideoCodecTester::EncoderSettings encoder_settings; + encoder_settings.pacing_settings.mode = + codec_impl == "builtin" ? PacingMode::kNoPacing : PacingMode::kRealTime; + if (absl::GetFlag(FLAGS_dump_encoder_input)) { encoder_settings.encoder_input_base_path = output_path + "_enc_input"; } - if (save_codec_output) { + if (absl::GetFlag(FLAGS_dump_encoder_output)) { encoder_settings.encoder_output_base_path = output_path + "_enc_output"; } - std::unique_ptr tester = CreateVideoCodecTester(); - return tester->RunEncodeTest(video_source.get(), encoder.get(), - encoder_settings); + return VideoCodecTester::RunEncodeTest(source_settings, encoder_factory.get(), + encoder_settings, encoding_settings); } -class SpatialQualityTest : public ::testing::TestWithParam< - std::tuple>> { +class SpatialQualityTest : public ::testing::TestWithParam>> { public: static std::string TestParamsToString( const ::testing::TestParamInfo& info) { @@ -590,41 +307,35 @@ class SpatialQualityTest : public ::testing::TestWithParam< TEST_P(SpatialQualityTest, SpatialQuality) { auto [codec_type, codec_impl, video_info, coding_settings] = GetParam(); - auto [width, height, framerate_fps, bitrate_kbps, psnr] = coding_settings; - - std::map frame_settings = { - {0, - {.scalability_mode = ScalabilityMode::kL1T1, - .layer_settings = { - {LayerId{.spatial_idx = 0, .temporal_idx = 0}, - {.resolution = {.width = width, .height = height}, - .framerate = Frequency::MilliHertz(1000 * framerate_fps), - .bitrate = DataRate::KilobitsPerSec(bitrate_kbps)}}}}}}; - + auto [width, height, framerate_fps, bitrate_kbps, expected_min_psnr] = + coding_settings; int duration_s = 10; int num_frames = duration_s * framerate_fps; - std::unique_ptr stats = RunEncodeDecodeTest( - codec_type, codec_impl, video_info, frame_settings, num_frames, - /*save_codec_input=*/false, /*save_codec_output=*/false); + std::map frames_settings = + VideoCodecTester::CreateEncodingSettings( + codec_type, /*scalability_mode=*/"L1T1", width, height, + {bitrate_kbps}, framerate_fps, num_frames); + + std::unique_ptr stats = + RunEncodeDecodeTest(codec_impl, video_info, frames_settings); VideoCodecStats::Stream stream; if (stats != nullptr) { - std::vector frames = stats->Slice(); - SetTargetRates(frame_settings, frames); - stream = stats->Aggregate(frames); + stream = stats->Aggregate(Filter{}); if (absl::GetFlag(FLAGS_webrtc_quick_perf_test)) { - EXPECT_GE(stream.psnr.y.GetAverage(), psnr); + EXPECT_GE(stream.psnr.y.GetAverage(), expected_min_psnr); } } stream.LogMetrics( GetGlobalMetricsLogger(), ::testing::UnitTest::GetInstance()->current_test_info()->name(), + /*prefix=*/"", /*metadata=*/ - {{"codec_type", codec_type}, - {"codec_impl", codec_impl}, - {"video_name", video_info.name}}); + {{"video_name", video_info.name}, + {"codec_type", codec_type}, + {"codec_impl", codec_impl}}); } INSTANTIATE_TEST_SUITE_P( @@ -636,7 +347,7 @@ INSTANTIATE_TEST_SUITE_P( #else Values("builtin"), #endif - Values(kFourPeople_1280x720_30), + Values(kRawVideos.at("FourPeople_1280x720_30")), Values(std::make_tuple(320, 180, 30, 32, 28), std::make_tuple(320, 180, 30, 64, 30), std::make_tuple(320, 180, 30, 128, 33), @@ -671,33 +382,32 @@ TEST_P(BitrateAdaptationTest, BitrateAdaptation) { auto [codec_type, codec_impl, video_info, bitrate_kbps] = GetParam(); int duration_s = 10; // Duration of fixed rate interval. - int first_frame = duration_s * video_info.framerate.millihertz() / 1000; - int num_frames = 2 * duration_s * video_info.framerate.millihertz() / 1000; - - std::map frame_settings = { - {0, - {.layer_settings = {{LayerId{.spatial_idx = 0, .temporal_idx = 0}, - {.resolution = {.width = 640, .height = 360}, - .framerate = video_info.framerate, - .bitrate = DataRate::KilobitsPerSec( - bitrate_kbps.first)}}}}}, - {first_frame, - {.layer_settings = { - {LayerId{.spatial_idx = 0, .temporal_idx = 0}, - {.resolution = {.width = 640, .height = 360}, - .framerate = video_info.framerate, - .bitrate = DataRate::KilobitsPerSec(bitrate_kbps.second)}}}}}}; - - std::unique_ptr stats = RunEncodeTest( - codec_type, codec_impl, video_info, frame_settings, num_frames, - /*save_codec_input=*/false, /*save_codec_output=*/false); + int num_frames = + static_cast(duration_s * video_info.framerate.hertz()); + + std::map encoding_settings = + VideoCodecTester::CreateEncodingSettings( + codec_type, /*scalability_mode=*/"L1T1", + /*width=*/640, /*height=*/360, {bitrate_kbps.first}, + /*framerate_fps=*/30, num_frames); + + uint32_t initial_timestamp_rtp = + encoding_settings.rbegin()->first + k90kHz / Frequency::Hertz(30); + + std::map encoding_settings2 = + VideoCodecTester::CreateEncodingSettings( + codec_type, /*scalability_mode=*/"L1T1", + /*width=*/640, /*height=*/360, {bitrate_kbps.second}, + /*framerate_fps=*/30, num_frames, initial_timestamp_rtp); + + encoding_settings.merge(encoding_settings2); + + std::unique_ptr stats = + RunEncodeTest(codec_type, codec_impl, video_info, encoding_settings); VideoCodecStats::Stream stream; if (stats != nullptr) { - std::vector frames = - stats->Slice(VideoCodecStats::Filter{.first_frame = first_frame}); - SetTargetRates(frame_settings, frames); - stream = stats->Aggregate(frames); + stream = stats->Aggregate({.min_timestamp_rtp = initial_timestamp_rtp}); if (absl::GetFlag(FLAGS_webrtc_quick_perf_test)) { EXPECT_NEAR(stream.bitrate_mismatch_pct.GetAverage(), 0, 10); EXPECT_NEAR(stream.framerate_mismatch_pct.GetAverage(), 0, 10); @@ -707,6 +417,7 @@ TEST_P(BitrateAdaptationTest, BitrateAdaptation) { stream.LogMetrics( GetGlobalMetricsLogger(), ::testing::UnitTest::GetInstance()->current_test_info()->name(), + /*prefix=*/"", /*metadata=*/ {{"codec_type", codec_type}, {"codec_impl", codec_impl}, @@ -715,18 +426,18 @@ TEST_P(BitrateAdaptationTest, BitrateAdaptation) { std::to_string(bitrate_kbps.second)}}); } -INSTANTIATE_TEST_SUITE_P(All, - BitrateAdaptationTest, - Combine(Values("AV1", "VP9", "VP8", "H264", "H265"), +INSTANTIATE_TEST_SUITE_P( + All, + BitrateAdaptationTest, + Combine(Values("AV1", "VP9", "VP8", "H264", "H265"), #if defined(WEBRTC_ANDROID) - Values("builtin", "mediacodec"), + Values("builtin", "mediacodec"), #else - Values("builtin"), + Values("builtin"), #endif - Values(kFourPeople_1280x720_30), - Values(std::pair(1024, 512), - std::pair(512, 1024))), - BitrateAdaptationTest::TestParamsToString); + Values(kRawVideos.at("FourPeople_1280x720_30")), + Values(std::pair(1024, 512), std::pair(512, 1024))), + BitrateAdaptationTest::TestParamsToString); class FramerateAdaptationTest : public ::testing::TestWithParam(duration_s * framerate_fps.first); - int num_frames = static_cast( - duration_s * (framerate_fps.first + framerate_fps.second)); - - std::map frame_settings = { - {0, - {.layer_settings = {{LayerId{.spatial_idx = 0, .temporal_idx = 0}, - {.resolution = {.width = 640, .height = 360}, - .framerate = Frequency::MilliHertz( - 1000 * framerate_fps.first), - .bitrate = DataRate::KilobitsPerSec(512)}}}}}, - {first_frame, - {.layer_settings = { - {LayerId{.spatial_idx = 0, .temporal_idx = 0}, - {.resolution = {.width = 640, .height = 360}, - .framerate = Frequency::MilliHertz(1000 * framerate_fps.second), - .bitrate = DataRate::KilobitsPerSec(512)}}}}}}; - - std::unique_ptr stats = RunEncodeTest( - codec_type, codec_impl, video_info, frame_settings, num_frames, - /*save_codec_input=*/false, /*save_codec_output=*/false); + + std::map encoding_settings = + VideoCodecTester::CreateEncodingSettings( + codec_type, /*scalability_mode=*/"L1T1", + /*width=*/640, /*height=*/360, + /*layer_bitrates_kbps=*/{512}, framerate_fps.first, + static_cast(duration_s * framerate_fps.first)); + + uint32_t initial_timestamp_rtp = + encoding_settings.rbegin()->first + + k90kHz / Frequency::Hertz(framerate_fps.first); + + std::map encoding_settings2 = + VideoCodecTester::CreateEncodingSettings( + codec_type, /*scalability_mode=*/"L1T1", /*width=*/640, + /*height=*/360, + /*layer_bitrates_kbps=*/{512}, framerate_fps.second, + static_cast(duration_s * framerate_fps.second), + initial_timestamp_rtp); + + encoding_settings.merge(encoding_settings2); + + std::unique_ptr stats = + RunEncodeTest(codec_type, codec_impl, video_info, encoding_settings); VideoCodecStats::Stream stream; if (stats != nullptr) { - std::vector frames = - stats->Slice(VideoCodecStats::Filter{.first_frame = first_frame}); - SetTargetRates(frame_settings, frames); - stream = stats->Aggregate(frames); + stream = stats->Aggregate({.min_timestamp_rtp = initial_timestamp_rtp}); if (absl::GetFlag(FLAGS_webrtc_quick_perf_test)) { EXPECT_NEAR(stream.bitrate_mismatch_pct.GetAverage(), 0, 10); EXPECT_NEAR(stream.framerate_mismatch_pct.GetAverage(), 0, 10); @@ -786,6 +497,7 @@ TEST_P(FramerateAdaptationTest, FramerateAdaptation) { stream.LogMetrics( GetGlobalMetricsLogger(), ::testing::UnitTest::GetInstance()->current_test_info()->name(), + /*prefix=*/"", /*metadata=*/ {{"codec_type", codec_type}, {"codec_impl", codec_impl}, @@ -794,17 +506,71 @@ TEST_P(FramerateAdaptationTest, FramerateAdaptation) { std::to_string(framerate_fps.second)}}); } -INSTANTIATE_TEST_SUITE_P(All, - FramerateAdaptationTest, - Combine(Values("AV1", "VP9", "VP8", "H264", "H265"), +INSTANTIATE_TEST_SUITE_P( + All, + FramerateAdaptationTest, + Combine(Values("AV1", "VP9", "VP8", "H264", "H265"), #if defined(WEBRTC_ANDROID) - Values("builtin", "mediacodec"), + Values("builtin", "mediacodec"), #else - Values("builtin"), + Values("builtin"), #endif - Values(kFourPeople_1280x720_30), - Values(std::pair(30, 15), std::pair(15, 30))), - FramerateAdaptationTest::TestParamsToString); + Values(kRawVideos.at("FourPeople_1280x720_30")), + Values(std::pair(30, 15), std::pair(15, 30))), + FramerateAdaptationTest::TestParamsToString); + +TEST(VideoCodecTest, DISABLED_EncodeDecode) { + std::vector bitrate_str = absl::GetFlag(FLAGS_bitrate_kbps); + std::vector bitrate_kbps; + std::transform(bitrate_str.begin(), bitrate_str.end(), + std::back_inserter(bitrate_kbps), + [](const std::string& str) { return std::stoi(str); }); + + std::map frames_settings = + VideoCodecTester::CreateEncodingSettings( + CodecNameToCodecType(absl::GetFlag(FLAGS_encoder)), + absl::GetFlag(FLAGS_scalability_mode), absl::GetFlag(FLAGS_width), + absl::GetFlag(FLAGS_height), {bitrate_kbps}, + absl::GetFlag(FLAGS_framerate_fps), absl::GetFlag(FLAGS_num_frames)); + + // TODO(webrtc:14852): Pass encoder and decoder names directly, and update + // logged test name (implies lossing history in the chromeperf dashboard). + // Sync with changes in Stream::LogMetrics (see TODOs there). + std::unique_ptr stats = RunEncodeDecodeTest( + CodecNameToCodecImpl(absl::GetFlag(FLAGS_encoder)), + kRawVideos.at(absl::GetFlag(FLAGS_video_name)), frames_settings); + ASSERT_NE(nullptr, stats); + + // Log unsliced metrics. + VideoCodecStats::Stream stream = stats->Aggregate(Filter{}); + stream.LogMetrics(GetGlobalMetricsLogger(), TestName(), /*prefix=*/"", + /*metadata=*/{}); + + // Log metrics sliced on spatial and temporal layer. + ScalabilityMode scalability_mode = + *ScalabilityModeFromString(absl::GetFlag(FLAGS_scalability_mode)); + int num_spatial_layers = ScalabilityModeToNumSpatialLayers(scalability_mode); + int num_temporal_layers = + ScalabilityModeToNumTemporalLayers(scalability_mode); + for (int sidx = 0; sidx < num_spatial_layers; ++sidx) { + for (int tidx = 0; tidx < num_temporal_layers; ++tidx) { + std::string metric_name_prefix = + (rtc::StringBuilder() << "s" << sidx << "t" << tidx << "_").str(); + stream = stats->Aggregate( + {.layer_id = {{.spatial_idx = sidx, .temporal_idx = tidx}}}); + stream.LogMetrics(GetGlobalMetricsLogger(), TestName(), + metric_name_prefix, + /*metadata=*/{}); + } + } + + if (absl::GetFlag(FLAGS_write_csv)) { + stats->LogMetrics( + (rtc::StringBuilder() << TestOutputPath() << ".csv").str(), + stats->Slice(Filter{}, /*merge=*/false), /*metadata=*/ + {{"test_name", TestName()}}); + } +} } // namespace test diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.cc deleted file mode 100644 index f15b1b35f3..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.cc +++ /dev/null @@ -1,437 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/video_coding/codecs/test/video_codec_tester_impl.h" - -#include -#include -#include -#include - -#include "api/task_queue/default_task_queue_factory.h" -#include "api/units/frequency.h" -#include "api/units/time_delta.h" -#include "api/units/timestamp.h" -#include "api/video/encoded_image.h" -#include "api/video/i420_buffer.h" -#include "api/video/video_codec_type.h" -#include "api/video/video_frame.h" -#include "modules/video_coding/codecs/test/video_codec_analyzer.h" -#include "modules/video_coding/utility/ivf_file_writer.h" -#include "rtc_base/event.h" -#include "rtc_base/time_utils.h" -#include "system_wrappers/include/sleep.h" -#include "test/testsupport/video_frame_writer.h" - -namespace webrtc { -namespace test { - -namespace { -using RawVideoSource = VideoCodecTester::RawVideoSource; -using CodedVideoSource = VideoCodecTester::CodedVideoSource; -using Decoder = VideoCodecTester::Decoder; -using Encoder = VideoCodecTester::Encoder; -using EncoderSettings = VideoCodecTester::EncoderSettings; -using DecoderSettings = VideoCodecTester::DecoderSettings; -using PacingSettings = VideoCodecTester::PacingSettings; -using PacingMode = PacingSettings::PacingMode; - -constexpr Frequency k90kHz = Frequency::Hertz(90000); - -// A thread-safe wrapper for video source to be shared with the quality analyzer -// that reads reference frames from a separate thread. -class SyncRawVideoSource : public VideoCodecAnalyzer::ReferenceVideoSource { - public: - explicit SyncRawVideoSource(RawVideoSource* video_source) - : video_source_(video_source) {} - - absl::optional PullFrame() { - MutexLock lock(&mutex_); - return video_source_->PullFrame(); - } - - VideoFrame GetFrame(uint32_t timestamp_rtp, Resolution resolution) override { - MutexLock lock(&mutex_); - return video_source_->GetFrame(timestamp_rtp, resolution); - } - - protected: - RawVideoSource* const video_source_ RTC_GUARDED_BY(mutex_); - Mutex mutex_; -}; - -// Pacer calculates delay necessary to keep frame encode or decode call spaced -// from the previous calls by the pacing time. `Delay` is expected to be called -// as close as possible to posting frame encode or decode task. This class is -// not thread safe. -class Pacer { - public: - explicit Pacer(PacingSettings settings) - : settings_(settings), delay_(TimeDelta::Zero()) {} - Timestamp Schedule(Timestamp timestamp) { - Timestamp now = Timestamp::Micros(rtc::TimeMicros()); - if (settings_.mode == PacingMode::kNoPacing) { - return now; - } - - Timestamp scheduled = now; - if (prev_scheduled_) { - scheduled = *prev_scheduled_ + PacingTime(timestamp); - if (scheduled < now) { - scheduled = now; - } - } - - prev_timestamp_ = timestamp; - prev_scheduled_ = scheduled; - return scheduled; - } - - private: - TimeDelta PacingTime(Timestamp timestamp) { - if (settings_.mode == PacingMode::kRealTime) { - return timestamp - *prev_timestamp_; - } - RTC_CHECK_EQ(PacingMode::kConstantRate, settings_.mode); - return 1 / settings_.constant_rate; - } - - PacingSettings settings_; - absl::optional prev_timestamp_; - absl::optional prev_scheduled_; - TimeDelta delay_; -}; - -// Task queue that keeps the number of queued tasks below a certain limit. If -// the limit is reached, posting of a next task is blocked until execution of a -// previously posted task starts. This class is not thread-safe. -class LimitedTaskQueue { - public: - // The codec tester reads frames from video source in the main thread. - // Encoding and decoding are done in separate threads. If encoding or - // decoding is slow, the reading may go far ahead and may buffer too many - // frames in memory. To prevent this we limit the encoding/decoding queue - // size. When the queue is full, the main thread and, hence, reading frames - // from video source is blocked until a previously posted encoding/decoding - // task starts. - static constexpr int kMaxTaskQueueSize = 3; - - LimitedTaskQueue() : queue_size_(0) {} - - void PostScheduledTask(absl::AnyInvocable task, Timestamp start) { - ++queue_size_; - task_queue_.PostTask([this, task = std::move(task), start]() mutable { - int wait_ms = static_cast(start.ms() - rtc::TimeMillis()); - if (wait_ms > 0) { - SleepMs(wait_ms); - } - - std::move(task)(); - --queue_size_; - task_executed_.Set(); - }); - - task_executed_.Reset(); - if (queue_size_ > kMaxTaskQueueSize) { - task_executed_.Wait(rtc::Event::kForever); - } - RTC_CHECK(queue_size_ <= kMaxTaskQueueSize); - } - - void WaitForPreviouslyPostedTasks() { - task_queue_.SendTask([] {}); - } - - TaskQueueForTest task_queue_; - std::atomic_int queue_size_; - rtc::Event task_executed_; -}; - -class TesterY4mWriter { - public: - explicit TesterY4mWriter(absl::string_view base_path) - : base_path_(base_path) {} - - ~TesterY4mWriter() { - task_queue_.SendTask([] {}); - } - - void Write(const VideoFrame& frame, int spatial_idx) { - task_queue_.PostTask([this, frame, spatial_idx] { - if (y4m_writers_.find(spatial_idx) == y4m_writers_.end()) { - std::string file_path = - base_path_ + "_s" + std::to_string(spatial_idx) + ".y4m"; - - Y4mVideoFrameWriterImpl* y4m_writer = new Y4mVideoFrameWriterImpl( - file_path, frame.width(), frame.height(), /*fps=*/30); - RTC_CHECK(y4m_writer); - - y4m_writers_[spatial_idx] = - std::unique_ptr(y4m_writer); - } - - y4m_writers_.at(spatial_idx)->WriteFrame(frame); - }); - } - - protected: - std::string base_path_; - std::map> y4m_writers_; - TaskQueueForTest task_queue_; -}; - -class TesterIvfWriter { - public: - explicit TesterIvfWriter(absl::string_view base_path) - : base_path_(base_path) {} - - ~TesterIvfWriter() { - task_queue_.SendTask([] {}); - } - - void Write(const EncodedImage& encoded_frame) { - task_queue_.PostTask([this, encoded_frame] { - int spatial_idx = encoded_frame.SpatialIndex().value_or(0); - if (ivf_file_writers_.find(spatial_idx) == ivf_file_writers_.end()) { - std::string ivf_path = - base_path_ + "_s" + std::to_string(spatial_idx) + ".ivf"; - - FileWrapper ivf_file = FileWrapper::OpenWriteOnly(ivf_path); - RTC_CHECK(ivf_file.is_open()); - - std::unique_ptr ivf_writer = - IvfFileWriter::Wrap(std::move(ivf_file), /*byte_limit=*/0); - RTC_CHECK(ivf_writer); - - ivf_file_writers_[spatial_idx] = std::move(ivf_writer); - } - - // To play: ffplay -vcodec vp8|vp9|av1|hevc|h264 filename - ivf_file_writers_.at(spatial_idx) - ->WriteFrame(encoded_frame, VideoCodecType::kVideoCodecGeneric); - }); - } - - protected: - std::string base_path_; - std::map> ivf_file_writers_; - TaskQueueForTest task_queue_; -}; - -class TesterDecoder { - public: - TesterDecoder(Decoder* decoder, - VideoCodecAnalyzer* analyzer, - const DecoderSettings& settings) - : decoder_(decoder), - analyzer_(analyzer), - settings_(settings), - pacer_(settings.pacing) { - RTC_CHECK(analyzer_) << "Analyzer must be provided"; - - if (settings.decoder_input_base_path) { - input_writer_ = - std::make_unique(*settings.decoder_input_base_path); - } - - if (settings.decoder_output_base_path) { - output_writer_ = - std::make_unique(*settings.decoder_output_base_path); - } - } - - void Initialize() { - task_queue_.PostScheduledTask([this] { decoder_->Initialize(); }, - Timestamp::Zero()); - task_queue_.WaitForPreviouslyPostedTasks(); - } - - void Decode(const EncodedImage& input_frame) { - Timestamp timestamp = - Timestamp::Micros((input_frame.RtpTimestamp() / k90kHz).us()); - - task_queue_.PostScheduledTask( - [this, input_frame] { - analyzer_->StartDecode(input_frame); - - decoder_->Decode( - input_frame, - [this, spatial_idx = input_frame.SpatialIndex().value_or(0)]( - const VideoFrame& output_frame) { - analyzer_->FinishDecode(output_frame, spatial_idx); - - if (output_writer_) { - output_writer_->Write(output_frame, spatial_idx); - } - }); - - if (input_writer_) { - input_writer_->Write(input_frame); - } - }, - pacer_.Schedule(timestamp)); - } - - void Flush() { - task_queue_.PostScheduledTask([this] { decoder_->Flush(); }, - Timestamp::Zero()); - task_queue_.WaitForPreviouslyPostedTasks(); - } - - protected: - Decoder* const decoder_; - VideoCodecAnalyzer* const analyzer_; - const DecoderSettings& settings_; - Pacer pacer_; - LimitedTaskQueue task_queue_; - std::unique_ptr input_writer_; - std::unique_ptr output_writer_; -}; - -class TesterEncoder { - public: - TesterEncoder(Encoder* encoder, - TesterDecoder* decoder, - VideoCodecAnalyzer* analyzer, - const EncoderSettings& settings) - : encoder_(encoder), - decoder_(decoder), - analyzer_(analyzer), - settings_(settings), - pacer_(settings.pacing) { - RTC_CHECK(analyzer_) << "Analyzer must be provided"; - if (settings.encoder_input_base_path) { - input_writer_ = - std::make_unique(*settings.encoder_input_base_path); - } - - if (settings.encoder_output_base_path) { - output_writer_ = - std::make_unique(*settings.encoder_output_base_path); - } - } - - void Initialize() { - task_queue_.PostScheduledTask([this] { encoder_->Initialize(); }, - Timestamp::Zero()); - task_queue_.WaitForPreviouslyPostedTasks(); - } - - void Encode(const VideoFrame& input_frame) { - Timestamp timestamp = - Timestamp::Micros((input_frame.timestamp() / k90kHz).us()); - - task_queue_.PostScheduledTask( - [this, input_frame] { - analyzer_->StartEncode(input_frame); - encoder_->Encode(input_frame, - [this](const EncodedImage& encoded_frame) { - analyzer_->FinishEncode(encoded_frame); - - if (decoder_ != nullptr) { - decoder_->Decode(encoded_frame); - } - - if (output_writer_ != nullptr) { - output_writer_->Write(encoded_frame); - } - }); - - if (input_writer_) { - input_writer_->Write(input_frame, /*spatial_idx=*/0); - } - }, - pacer_.Schedule(timestamp)); - } - - void Flush() { - task_queue_.PostScheduledTask([this] { encoder_->Flush(); }, - Timestamp::Zero()); - task_queue_.WaitForPreviouslyPostedTasks(); - } - - protected: - Encoder* const encoder_; - TesterDecoder* const decoder_; - VideoCodecAnalyzer* const analyzer_; - const EncoderSettings& settings_; - std::unique_ptr input_writer_; - std::unique_ptr output_writer_; - Pacer pacer_; - LimitedTaskQueue task_queue_; -}; - -} // namespace - -std::unique_ptr VideoCodecTesterImpl::RunDecodeTest( - CodedVideoSource* video_source, - Decoder* decoder, - const DecoderSettings& decoder_settings) { - VideoCodecAnalyzer perf_analyzer; - TesterDecoder tester_decoder(decoder, &perf_analyzer, decoder_settings); - - tester_decoder.Initialize(); - - while (auto frame = video_source->PullFrame()) { - tester_decoder.Decode(*frame); - } - - tester_decoder.Flush(); - - return perf_analyzer.GetStats(); -} - -std::unique_ptr VideoCodecTesterImpl::RunEncodeTest( - RawVideoSource* video_source, - Encoder* encoder, - const EncoderSettings& encoder_settings) { - SyncRawVideoSource sync_source(video_source); - VideoCodecAnalyzer perf_analyzer; - TesterEncoder tester_encoder(encoder, /*decoder=*/nullptr, &perf_analyzer, - encoder_settings); - - tester_encoder.Initialize(); - - while (auto frame = sync_source.PullFrame()) { - tester_encoder.Encode(*frame); - } - - tester_encoder.Flush(); - - return perf_analyzer.GetStats(); -} - -std::unique_ptr VideoCodecTesterImpl::RunEncodeDecodeTest( - RawVideoSource* video_source, - Encoder* encoder, - Decoder* decoder, - const EncoderSettings& encoder_settings, - const DecoderSettings& decoder_settings) { - SyncRawVideoSource sync_source(video_source); - VideoCodecAnalyzer perf_analyzer(&sync_source); - TesterDecoder tester_decoder(decoder, &perf_analyzer, decoder_settings); - TesterEncoder tester_encoder(encoder, &tester_decoder, &perf_analyzer, - encoder_settings); - - tester_encoder.Initialize(); - tester_decoder.Initialize(); - - while (auto frame = sync_source.PullFrame()) { - tester_encoder.Encode(*frame); - } - - tester_encoder.Flush(); - tester_decoder.Flush(); - - return perf_analyzer.GetStats(); -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.h b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.h deleted file mode 100644 index 32191b5a98..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TESTER_IMPL_H_ -#define MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TESTER_IMPL_H_ - -#include - -#include "api/test/video_codec_tester.h" - -namespace webrtc { -namespace test { - -// A stateless implementation of `VideoCodecTester`. This class is thread safe. -class VideoCodecTesterImpl : public VideoCodecTester { - public: - std::unique_ptr RunDecodeTest( - CodedVideoSource* video_source, - Decoder* decoder, - const DecoderSettings& decoder_settings) override; - - std::unique_ptr RunEncodeTest( - RawVideoSource* video_source, - Encoder* encoder, - const EncoderSettings& encoder_settings) override; - - std::unique_ptr RunEncodeDecodeTest( - RawVideoSource* video_source, - Encoder* encoder, - Decoder* decoder, - const EncoderSettings& encoder_settings, - const DecoderSettings& decoder_settings) override; -}; - -} // namespace test -} // namespace webrtc - -#endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_TESTER_IMPL_H_ diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl_unittest.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl_unittest.cc deleted file mode 100644 index a8c118ef20..0000000000 --- a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_tester_impl_unittest.cc +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/video_coding/codecs/test/video_codec_tester_impl.h" - -#include -#include -#include -#include - -#include "api/units/frequency.h" -#include "api/units/time_delta.h" -#include "api/video/encoded_image.h" -#include "api/video/i420_buffer.h" -#include "api/video/video_frame.h" -#include "rtc_base/fake_clock.h" -#include "rtc_base/gunit.h" -#include "rtc_base/task_queue_for_test.h" -#include "rtc_base/time_utils.h" -#include "test/gmock.h" -#include "test/gtest.h" - -namespace webrtc { -namespace test { - -namespace { -using ::testing::_; -using ::testing::Invoke; -using ::testing::InvokeWithoutArgs; -using ::testing::Return; - -using Decoder = VideoCodecTester::Decoder; -using Encoder = VideoCodecTester::Encoder; -using CodedVideoSource = VideoCodecTester::CodedVideoSource; -using RawVideoSource = VideoCodecTester::RawVideoSource; -using DecoderSettings = VideoCodecTester::DecoderSettings; -using EncoderSettings = VideoCodecTester::EncoderSettings; -using PacingSettings = VideoCodecTester::PacingSettings; -using PacingMode = PacingSettings::PacingMode; - -constexpr Frequency k90kHz = Frequency::Hertz(90000); - -struct PacingTestParams { - PacingSettings pacing_settings; - Frequency framerate; - int num_frames; - std::vector expected_delta_ms; -}; - -VideoFrame CreateVideoFrame(uint32_t timestamp_rtp) { - rtc::scoped_refptr buffer(I420Buffer::Create(2, 2)); - return VideoFrame::Builder() - .set_video_frame_buffer(buffer) - .set_timestamp_rtp(timestamp_rtp) - .build(); -} - -EncodedImage CreateEncodedImage(uint32_t timestamp_rtp) { - EncodedImage encoded_image; - encoded_image.SetRtpTimestamp(timestamp_rtp); - return encoded_image; -} - -class MockRawVideoSource : public RawVideoSource { - public: - MockRawVideoSource(int num_frames, Frequency framerate) - : num_frames_(num_frames), frame_num_(0), framerate_(framerate) {} - - absl::optional PullFrame() override { - if (frame_num_ >= num_frames_) { - return absl::nullopt; - } - uint32_t timestamp_rtp = frame_num_ * k90kHz / framerate_; - ++frame_num_; - return CreateVideoFrame(timestamp_rtp); - } - - MOCK_METHOD(VideoFrame, - GetFrame, - (uint32_t timestamp_rtp, Resolution), - (override)); - - private: - int num_frames_; - int frame_num_; - Frequency framerate_; -}; - -class MockCodedVideoSource : public CodedVideoSource { - public: - MockCodedVideoSource(int num_frames, Frequency framerate) - : num_frames_(num_frames), frame_num_(0), framerate_(framerate) {} - - absl::optional PullFrame() override { - if (frame_num_ >= num_frames_) { - return absl::nullopt; - } - uint32_t timestamp_rtp = frame_num_ * k90kHz / framerate_; - ++frame_num_; - return CreateEncodedImage(timestamp_rtp); - } - - private: - int num_frames_; - int frame_num_; - Frequency framerate_; -}; - -class MockDecoder : public Decoder { - public: - MOCK_METHOD(void, Initialize, (), (override)); - MOCK_METHOD(void, - Decode, - (const EncodedImage& frame, DecodeCallback callback), - (override)); - MOCK_METHOD(void, Flush, (), (override)); -}; - -class MockEncoder : public Encoder { - public: - MOCK_METHOD(void, Initialize, (), (override)); - MOCK_METHOD(void, - Encode, - (const VideoFrame& frame, EncodeCallback callback), - (override)); - MOCK_METHOD(void, Flush, (), (override)); -}; - -} // namespace - -class VideoCodecTesterImplPacingTest - : public ::testing::TestWithParam { - public: - VideoCodecTesterImplPacingTest() : test_params_(GetParam()) {} - - protected: - PacingTestParams test_params_; -}; - -TEST_P(VideoCodecTesterImplPacingTest, PaceEncode) { - MockRawVideoSource video_source(test_params_.num_frames, - test_params_.framerate); - MockEncoder encoder; - EncoderSettings encoder_settings; - encoder_settings.pacing = test_params_.pacing_settings; - - VideoCodecTesterImpl tester; - auto fs = - tester.RunEncodeTest(&video_source, &encoder, encoder_settings)->Slice(); - ASSERT_EQ(static_cast(fs.size()), test_params_.num_frames); - - for (size_t i = 1; i < fs.size(); ++i) { - int delta_ms = (fs[i].encode_start - fs[i - 1].encode_start).ms(); - EXPECT_NEAR(delta_ms, test_params_.expected_delta_ms[i - 1], 10); - } -} - -TEST_P(VideoCodecTesterImplPacingTest, PaceDecode) { - MockCodedVideoSource video_source(test_params_.num_frames, - test_params_.framerate); - MockDecoder decoder; - DecoderSettings decoder_settings; - decoder_settings.pacing = test_params_.pacing_settings; - - VideoCodecTesterImpl tester; - auto fs = - tester.RunDecodeTest(&video_source, &decoder, decoder_settings)->Slice(); - ASSERT_EQ(static_cast(fs.size()), test_params_.num_frames); - - for (size_t i = 1; i < fs.size(); ++i) { - int delta_ms = (fs[i].decode_start - fs[i - 1].decode_start).ms(); - EXPECT_NEAR(delta_ms, test_params_.expected_delta_ms[i - 1], 20); - } -} - -INSTANTIATE_TEST_SUITE_P( - DISABLED_All, - VideoCodecTesterImplPacingTest, - ::testing::ValuesIn( - {// No pacing. - PacingTestParams({.pacing_settings = {.mode = PacingMode::kNoPacing}, - .framerate = Frequency::Hertz(10), - .num_frames = 3, - .expected_delta_ms = {0, 0}}), - // Real-time pacing. - PacingTestParams({.pacing_settings = {.mode = PacingMode::kRealTime}, - .framerate = Frequency::Hertz(10), - .num_frames = 3, - .expected_delta_ms = {100, 100}}), - // Pace with specified constant rate. - PacingTestParams( - {.pacing_settings = {.mode = PacingMode::kConstantRate, - .constant_rate = Frequency::Hertz(20)}, - .framerate = Frequency::Hertz(10), - .num_frames = 3, - .expected_delta_ms = {50, 50}})})); -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build b/third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build index 9b8e33b7d5..31e83f9c31 100644 --- a/third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/encoded_frame_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build b/third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build index 487fc5b4d6..1ad9c574ad 100644 --- a/third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/frame_dependencies_calculator_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build b/third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build index dd901a5371..ccac90f50d 100644 --- a/third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/frame_helpers_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/generic_decoder.cc b/third_party/libwebrtc/modules/video_coding/generic_decoder.cc index fc356e7a44..00585abbc9 100644 --- a/third_party/libwebrtc/modules/video_coding/generic_decoder.cc +++ b/third_party/libwebrtc/modules/video_coding/generic_decoder.cc @@ -329,18 +329,7 @@ int32_t VCMGenericDecoder::Decode(const EncodedImage& frame, } _callback->OnDecoderInfoChanged(std::move(decoder_info)); } - if (ret < WEBRTC_VIDEO_CODEC_OK) { - const absl::optional ssrc = - !frame_info.packet_infos.empty() - ? absl::make_optional(frame_info.packet_infos[0].ssrc()) - : absl::nullopt; - RTC_LOG(LS_WARNING) << "Failed to decode frame with timestamp " - << frame.RtpTimestamp() << ", ssrc " - << (ssrc ? rtc::ToString(*ssrc) : "") - << ", error code: " << ret; - _callback->ClearTimestampMap(); - } else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT) { - // No output. + if (ret < WEBRTC_VIDEO_CODEC_OK || ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT) { _callback->ClearTimestampMap(); } return ret; diff --git a/third_party/libwebrtc/modules/video_coding/include/video_codec_interface.h b/third_party/libwebrtc/modules/video_coding/include/video_codec_interface.h index c6522fcc6b..987e1b623e 100644 --- a/third_party/libwebrtc/modules/video_coding/include/video_codec_interface.h +++ b/third_party/libwebrtc/modules/video_coding/include/video_codec_interface.h @@ -50,7 +50,9 @@ struct CodecSpecificInfoVP8 { size_t updatedBuffers[kBuffersCount]; size_t updatedBuffersCount; }; -static_assert(std::is_pod::value, ""); +static_assert(std::is_trivial_v && + std::is_standard_layout_v, + ""); // Hack alert - the code assumes that thisstruct is memset when constructed. struct CodecSpecificInfoVP9 { @@ -79,7 +81,9 @@ struct CodecSpecificInfoVP9 { uint8_t num_ref_pics; uint8_t p_diff[kMaxVp9RefPics]; }; -static_assert(std::is_pod::value, ""); +static_assert(std::is_trivial_v && + std::is_standard_layout_v, + ""); // Hack alert - the code assumes that thisstruct is memset when constructed. struct CodecSpecificInfoH264 { @@ -88,14 +92,18 @@ struct CodecSpecificInfoH264 { bool base_layer_sync; bool idr_frame; }; -static_assert(std::is_pod::value, ""); +static_assert(std::is_trivial_v && + std::is_standard_layout_v, + ""); union CodecSpecificInfoUnion { CodecSpecificInfoVP8 VP8; CodecSpecificInfoVP9 VP9; CodecSpecificInfoH264 H264; }; -static_assert(std::is_pod::value, ""); +static_assert(std::is_trivial_v && + std::is_standard_layout_v, + ""); // Note: if any pointers are added to this struct or its sub-structs, it // must be fitted with a copy-constructor. This is because it is copied diff --git a/third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build b/third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build index 0f6654f1ab..d50ed75a00 100644 --- a/third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/nack_requester_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build b/third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build index f3f85aacaa..2c161989c1 100644 --- a/third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/packet_buffer_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build b/third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build index 8a1dfd6377..80eb00a991 100644 --- a/third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/svc/scalability_mode_util_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build b/third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build index a3ea8b3495..931dfe8d89 100644 --- a/third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/moz.build @@ -202,7 +202,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -212,10 +211,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build b/third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build index a285154a79..18aa68e696 100644 --- a/third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/svc/scalable_video_controller_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build b/third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build index 412f719d18..bbb5a75959 100644 --- a/third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/svc/svc_rate_allocator_gn/moz.build @@ -195,7 +195,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -205,10 +204,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build b/third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build index 36867642c7..2347b0937c 100644 --- a/third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/timing/decode_time_percentile_filter_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build b/third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build index caf0efc165..274023c6e7 100644 --- a/third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/timing/frame_delay_variation_kalman_filter_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build b/third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build index 8c6e826a4a..d4ec330ed1 100644 --- a/third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/timing/inter_frame_delay_variation_calculator_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build b/third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build index c7ca3c7fd8..e540f00f8c 100644 --- a/third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/timing/jitter_estimator_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build b/third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build index f3993a17b1..18a30a6ede 100644 --- a/third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/timing/rtt_filter_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build b/third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build index ad8a6874e4..4c2a6eed62 100644 --- a/third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/timing/timestamp_extrapolator_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build b/third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build index 60cc81a229..76c4cfe664 100644 --- a/third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/timing/timing_module_gn/moz.build @@ -199,7 +199,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -209,10 +208,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build b/third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build index b14bef2dec..141def9090 100644 --- a/third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/video_codec_interface_gn/moz.build @@ -196,7 +196,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -206,10 +205,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build b/third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build index 5af51f1238..923ac7785a 100644 --- a/third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/video_coding_gn/moz.build @@ -214,7 +214,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -224,10 +223,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build b/third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build index d42eb284cd..bc1510e0ba 100644 --- a/third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/video_coding_utility_gn/moz.build @@ -211,7 +211,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -221,10 +220,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build b/third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build index 81c9b9d404..8cb4b64625 100644 --- a/third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/webrtc_libvpx_interface_gn/moz.build @@ -191,7 +191,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -201,10 +200,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build b/third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build index 82a4d24e97..21d5eeee9f 100644 --- a/third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/webrtc_vp8_gn/moz.build @@ -206,7 +206,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -216,10 +215,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build b/third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build index 6799224dff..92fd7cf630 100644 --- a/third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/webrtc_vp8_scalability_gn/moz.build @@ -188,7 +188,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -198,10 +197,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build b/third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build index 2423950ba5..caf91a5d2c 100644 --- a/third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/webrtc_vp8_temporal_layers_gn/moz.build @@ -205,7 +205,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -215,10 +214,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build b/third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build index 5bb64f3412..707d563559 100644 --- a/third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/webrtc_vp9_gn/moz.build @@ -208,7 +208,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -218,10 +217,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build b/third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build index 6f1575870e..883e5c70b2 100644 --- a/third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build +++ b/third_party/libwebrtc/modules/video_coding/webrtc_vp9_helpers_gn/moz.build @@ -200,7 +200,6 @@ if CONFIG["MOZ_X11"] == "1" and CONFIG["OS_TARGET"] == "Linux": if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "arm": OS_LIBS += [ - "android_support", "unwind" ] @@ -210,10 +209,6 @@ if CONFIG["OS_TARGET"] == "Android" and CONFIG["TARGET_CPU"] == "x86": "-msse2" ] - OS_LIBS += [ - "android_support" - ] - if CONFIG["OS_TARGET"] == "Linux" and CONFIG["TARGET_CPU"] == "aarch64": DEFINES["_GNU_SOURCE"] = True diff --git a/third_party/libwebrtc/moz-patch-stack/0001.patch b/third_party/libwebrtc/moz-patch-stack/0001.patch index 31a12dd98b..6547c47b40 100644 --- a/third_party/libwebrtc/moz-patch-stack/0001.patch +++ b/third_party/libwebrtc/moz-patch-stack/0001.patch @@ -413,7 +413,7 @@ index 54132bcdbb..cf8b3ad3dc 100644 bool RtpExtension::IsSupportedForVideo(absl::string_view uri) { diff --git a/call/BUILD.gn b/call/BUILD.gn -index 4cc42fd99f..58473dc1ea 100644 +index 9a7be88892..66c8b2011a 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -20,6 +20,7 @@ rtc_library("call_interfaces") { @@ -1233,7 +1233,7 @@ index fb95a6020d..95432a509d 100644 } // namespace videocapturemodule } // namespace webrtc diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h -index eddc31414a..e207598d68 100644 +index 48920b27c0..f31b239c71 100644 --- a/modules/video_capture/video_capture.h +++ b/modules/video_capture/video_capture.h @@ -15,15 +15,44 @@ @@ -1256,7 +1256,7 @@ index eddc31414a..e207598d68 100644 + virtual ~VideoInputFeedBack(){} +}; + - class VideoCaptureModule : public rtc::RefCountInterface { + class VideoCaptureModule : public RefCountInterface { public: // Interface for receiving information about available camera devices. class DeviceInfo { @@ -1281,7 +1281,7 @@ index eddc31414a..e207598d68 100644 // Returns the available capture devices. // deviceNumber - Index of capture device. -@@ -38,7 +67,8 @@ class VideoCaptureModule : public rtc::RefCountInterface { +@@ -38,7 +67,8 @@ class VideoCaptureModule : public RefCountInterface { char* deviceUniqueIdUTF8, uint32_t deviceUniqueIdUTF8Length, char* productUniqueIdUTF8 = 0, @@ -1291,7 +1291,7 @@ index eddc31414a..e207598d68 100644 // Returns the number of capabilities this device. virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0; -@@ -70,6 +100,8 @@ class VideoCaptureModule : public rtc::RefCountInterface { +@@ -70,6 +100,8 @@ class VideoCaptureModule : public RefCountInterface { uint32_t positionY) = 0; virtual ~DeviceInfo() {} @@ -1300,7 +1300,7 @@ index eddc31414a..e207598d68 100644 }; // Register capture data callback -@@ -79,11 +111,16 @@ class VideoCaptureModule : public rtc::RefCountInterface { +@@ -79,11 +111,16 @@ class VideoCaptureModule : public RefCountInterface { RawVideoSinkInterface* dataCallback) = 0; // Remove capture data callback @@ -1560,10 +1560,10 @@ index 0474e7bc17..1953923f81 100644 std::unique_ptr svc_controller_; absl::optional scalability_mode_; diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 6abae807fe..99d8e48e39 100644 +index 3011d6a797..9f5f0aad56 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn -@@ -458,6 +458,12 @@ rtc_library("logging") { +@@ -463,6 +463,12 @@ rtc_library("logging") { "//third_party/abseil-cpp/absl/types:optional", ] @@ -1679,7 +1679,7 @@ index 0a9226ef6f..620c1c02f3 100644 vcm_ = nullptr; } diff --git a/webrtc.gni b/webrtc.gni -index 173d66c791..912b9b4ef0 100644 +index 447aae4096..277c12c054 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -126,7 +126,7 @@ declare_args() { diff --git a/third_party/libwebrtc/moz-patch-stack/0002.patch b/third_party/libwebrtc/moz-patch-stack/0002.patch index eb8cb95b8d..1354066675 100644 --- a/third_party/libwebrtc/moz-patch-stack/0002.patch +++ b/third_party/libwebrtc/moz-patch-stack/0002.patch @@ -30,7 +30,7 @@ index a4e3e897fd..e777a45f92 100644 enum class CaptureType { kWindow, kScreen, kAnyScreenContent }; diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h -index e207598d68..58485f28e9 100644 +index f31b239c71..7279bed476 100644 --- a/modules/video_capture/video_capture.h +++ b/modules/video_capture/video_capture.h @@ -13,6 +13,7 @@ diff --git a/third_party/libwebrtc/moz-patch-stack/0005.patch b/third_party/libwebrtc/moz-patch-stack/0005.patch index a7b1f9b1f5..3d925a62e2 100644 --- a/third_party/libwebrtc/moz-patch-stack/0005.patch +++ b/third_party/libwebrtc/moz-patch-stack/0005.patch @@ -17,10 +17,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b3ba8452e77105c72 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/call/rtp_demuxer.cc b/call/rtp_demuxer.cc -index 0b74f2ac0a..5c53f48144 100644 +index 841d7e3b94..f5c4186871 100644 --- a/call/rtp_demuxer.cc +++ b/call/rtp_demuxer.cc -@@ -272,13 +272,17 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink( +@@ -285,13 +285,17 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink( // RSID and RRID are routed to the same sinks. If an RSID is specified on a // repair packet, it should be ignored and the RRID should be used. std::string packet_mid, packet_rsid; @@ -39,7 +39,7 @@ index 0b74f2ac0a..5c53f48144 100644 // The BUNDLE spec says to drop any packets with unknown MIDs, even if the // SSRC is known/latched. if (has_mid && known_mids_.find(packet_mid) == known_mids_.end()) { -@@ -352,6 +356,7 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink( +@@ -365,6 +369,7 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink( } } diff --git a/third_party/libwebrtc/moz-patch-stack/0006.patch b/third_party/libwebrtc/moz-patch-stack/0006.patch index 70d4576a93..7decaa705c 100644 --- a/third_party/libwebrtc/moz-patch-stack/0006.patch +++ b/third_party/libwebrtc/moz-patch-stack/0006.patch @@ -93,7 +93,7 @@ index d298081432..dd706e569d 100644 // interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats. // Within this list, the `ReportBlockData::source_ssrc()`, which is the SSRC diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc -index 800ec77d3e..0df8543497 100644 +index 3dbbc77086..1d73bc3d87 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -503,6 +503,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters( diff --git a/third_party/libwebrtc/moz-patch-stack/0007.patch b/third_party/libwebrtc/moz-patch-stack/0007.patch index b217db4f34..052a4431bf 100644 --- a/third_party/libwebrtc/moz-patch-stack/0007.patch +++ b/third_party/libwebrtc/moz-patch-stack/0007.patch @@ -96,7 +96,7 @@ index dd706e569d..742a69cce3 100644 // A snapshot of the most recent Report Block with additional data of // interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats. diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc -index 0df8543497..31a1b764b3 100644 +index 1d73bc3d87..d7e3c50f82 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -504,8 +504,10 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters( diff --git a/third_party/libwebrtc/moz-patch-stack/0008.patch b/third_party/libwebrtc/moz-patch-stack/0008.patch index 7d97e4804e..4b7bb94bd6 100644 --- a/third_party/libwebrtc/moz-patch-stack/0008.patch +++ b/third_party/libwebrtc/moz-patch-stack/0008.patch @@ -29,10 +29,10 @@ index 7e38b5bd08..e4a2cc2fc9 100644 } // namespace webrtc diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm -index 28cc410573..b082136e76 100644 +index 60089fd0f2..a2370ed695 100644 --- a/modules/desktop_capture/mac/screen_capturer_mac.mm +++ b/modules/desktop_capture/mac/screen_capturer_mac.mm -@@ -182,6 +182,7 @@ void ScreenCapturerMac::Start(Callback* callback) { +@@ -182,6 +182,7 @@ DesktopRect GetExcludedWindowPixelBounds(CGWindowID window, float dip_to_pixel_s "webrtc", "ScreenCapturermac::Start", "target display id ", current_display_); callback_ = callback; @@ -40,7 +40,7 @@ index 28cc410573..b082136e76 100644 // Start and operate CGDisplayStream handler all from capture thread. if (!RegisterRefreshAndMoveHandlers()) { RTC_LOG(LS_ERROR) << "Failed to register refresh and move handlers."; -@@ -202,7 +203,8 @@ void ScreenCapturerMac::CaptureFrame() { +@@ -202,7 +203,8 @@ DesktopRect GetExcludedWindowPixelBounds(CGWindowID window, float dip_to_pixel_s } MacDesktopConfiguration new_config = desktop_config_monitor_->desktop_configuration(); @@ -54,7 +54,7 @@ diff --git a/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/modules/deskt index 3db4332cd1..512103ab5e 100644 --- a/modules/desktop_capture/mouse_cursor_monitor_mac.mm +++ b/modules/desktop_capture/mouse_cursor_monitor_mac.mm -@@ -133,7 +133,7 @@ void MouseCursorMonitorMac::CaptureImage(float scale) { +@@ -133,7 +133,7 @@ void DisplaysReconfigured(CGDirectDisplayID display, NSSize nssize = [nsimage size]; // DIP size // No need to caputre cursor image if it's unchanged since last capture. diff --git a/third_party/libwebrtc/moz-patch-stack/0009.patch b/third_party/libwebrtc/moz-patch-stack/0009.patch index 793bf996b8..58b2ab9994 100644 --- a/third_party/libwebrtc/moz-patch-stack/0009.patch +++ b/third_party/libwebrtc/moz-patch-stack/0009.patch @@ -16,10 +16,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/9314046d89ebc0836 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm -index b082136e76..1f4a62f7cd 100644 +index a2370ed695..785a15dfa4 100644 --- a/modules/desktop_capture/mac/screen_capturer_mac.mm +++ b/modules/desktop_capture/mac/screen_capturer_mac.mm -@@ -276,7 +276,8 @@ bool ScreenCapturerMac::GetSourceList(SourceList* screens) { +@@ -276,7 +276,8 @@ DesktopRect GetExcludedWindowPixelBounds(CGWindowID window, float dip_to_pixel_s for (MacDisplayConfigurations::iterator it = desktop_config_.displays.begin(); it != desktop_config_.displays.end(); ++it) { diff --git a/third_party/libwebrtc/moz-patch-stack/0030.patch b/third_party/libwebrtc/moz-patch-stack/0030.patch index c5c638459c..8c6652af46 100644 --- a/third_party/libwebrtc/moz-patch-stack/0030.patch +++ b/third_party/libwebrtc/moz-patch-stack/0030.patch @@ -55,13 +55,21 @@ Bug 1774628 - re-enable support for Windows.Graphics.Capture APIs in libwebrtc. Differential Revision: https://phabricator.services.mozilla.com/D186862 Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/08567f4539a12b54202aecbf554ec6540fb99ab2 + +Bug 1876843 - (fix-082cb56ee7) remove mozilla dependency on pc:media_factory. + +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/136b3fc0377be6dcaa302469d27968f445e0355e + +Bug 1876843 - (fix-b29ff000da) remove mozilla dependency on api:enable_media + +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7f403ee038e9797a1aff6161fc70a2d92769851f --- .gn | 2 + - BUILD.gn | 45 ++++++++++++++++++- - api/BUILD.gn | 34 +++++++++++++- + BUILD.gn | 46 ++++++++++++++++++- + api/BUILD.gn | 36 ++++++++++++++- api/rtp_sender_interface.h | 4 +- api/rtp_sender_setparameters_callback.cc | 27 +++++++++++ - api/rtp_sender_setparameters_callback.h | 28 ++++++++++++ + api/rtp_sender_setparameters_callback.h | 28 +++++++++++ api/task_queue/BUILD.gn | 2 + api/transport/BUILD.gn | 2 + call/BUILD.gn | 14 +++++- @@ -70,24 +78,24 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/08567f4539a12b542 common_audio/BUILD.gn | 4 -- common_audio/fir_filter_avx2.cc | 2 + common_audio/intrin.h | 8 ++++ - media/BUILD.gn | 35 ++++++++++++++- + media/BUILD.gn | 35 +++++++++++++- media/base/media_channel.h | 4 -- media/base/media_channel_impl.cc | 13 ------ modules/audio_coding/BUILD.gn | 2 +- modules/audio_device/BUILD.gn | 17 +++++-- - modules/audio_processing/aec3/BUILD.gn | 13 +++--- + modules/audio_processing/aec3/BUILD.gn | 13 ++---- .../aec3/adaptive_fir_filter_avx2.cc | 2 +- .../audio_processing/agc2/rnn_vad/BUILD.gn | 2 +- modules/desktop_capture/BUILD.gn | 29 +----------- modules/portal/BUILD.gn | 24 ++++++++++ modules/utility/BUILD.gn | 4 ++ modules/video_capture/BUILD.gn | 11 +---- - rtc_base/BUILD.gn | 30 ++++++++++++- + rtc_base/BUILD.gn | 30 +++++++++++- rtc_base/system/BUILD.gn | 2 +- - test/BUILD.gn | 10 +++++ + test/BUILD.gn | 10 ++++ video/BUILD.gn | 4 +- webrtc.gni | 32 ++++++++----- - 31 files changed, 311 insertions(+), 99 deletions(-) + 31 files changed, 315 insertions(+), 98 deletions(-) create mode 100644 api/rtp_sender_setparameters_callback.cc create mode 100644 api/rtp_sender_setparameters_callback.h create mode 100644 common_audio/intrin.h @@ -106,7 +114,7 @@ index b9948d2fcd..77cfa94d8a 100644 # TODO(https://bugs.webrtc.org/14437): Remove this section if general # Chromium fix resolves the problem. diff --git a/BUILD.gn b/BUILD.gn -index 7e8325e306..f61f8965b9 100644 +index 571049f3e4..f393179bbb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -33,7 +33,7 @@ if (is_android) { @@ -141,13 +149,14 @@ index 7e8325e306..f61f8965b9 100644 if (!build_with_chromium) { # Target to build all the WebRTC production code. -@@ -532,6 +538,33 @@ if (!build_with_chromium) { +@@ -533,6 +539,34 @@ if (!build_with_chromium) { "sdk", "video", ] + if (build_with_mozilla) { + deps -= [ + "api:create_peerconnection_factory", ++ "api:enable_media", + "api:rtc_error", + "api:transport_api", + "api/crypto", @@ -175,7 +184,7 @@ index 7e8325e306..f61f8965b9 100644 if (rtc_include_builtin_audio_codecs) { deps += [ -@@ -544,6 +577,16 @@ if (!build_with_chromium) { +@@ -545,6 +579,16 @@ if (!build_with_chromium) { deps += [ "api/video:video_frame", "api/video:video_rtp_headers", @@ -193,10 +202,20 @@ index 7e8325e306..f61f8965b9 100644 } else { deps += [ diff --git a/api/BUILD.gn b/api/BUILD.gn -index 46703f93ce..d2b7f06c87 100644 +index ee162577c8..10a4c8c95f 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn -@@ -35,7 +35,7 @@ rtc_source_set("callfactory_api") { +@@ -49,6 +49,9 @@ rtc_source_set("enable_media") { + "../rtc_base/system:rtc_export", + "environment", + ] ++ if (build_with_mozilla) { ++ deps -= [ "../pc:media_factory" ] ++ } + } + + rtc_source_set("enable_media_with_defaults") { +@@ -75,7 +78,7 @@ rtc_source_set("enable_media_with_defaults") { ] } @@ -204,8 +223,8 @@ index 46703f93ce..d2b7f06c87 100644 +if (!build_with_chromium && !build_with_mozilla) { rtc_library("create_peerconnection_factory") { visibility = [ "*" ] - allow_poison = [ "default_task_queue" ] -@@ -189,6 +189,10 @@ rtc_source_set("ice_transport_interface") { + allow_poison = [ "environment_construction" ] +@@ -228,6 +231,10 @@ rtc_source_set("ice_transport_interface") { } rtc_library("dtls_transport_interface") { @@ -216,7 +235,7 @@ index 46703f93ce..d2b7f06c87 100644 visibility = [ "*" ] sources = [ -@@ -205,6 +209,7 @@ rtc_library("dtls_transport_interface") { +@@ -244,6 +251,7 @@ rtc_library("dtls_transport_interface") { ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } @@ -224,7 +243,7 @@ index 46703f93ce..d2b7f06c87 100644 rtc_library("dtmf_sender_interface") { visibility = [ "*" ] -@@ -217,6 +222,10 @@ rtc_library("dtmf_sender_interface") { +@@ -256,6 +264,10 @@ rtc_library("dtmf_sender_interface") { } rtc_library("rtp_sender_interface") { @@ -235,17 +254,14 @@ index 46703f93ce..d2b7f06c87 100644 visibility = [ "*" ] sources = [ -@@ -228,8 +237,8 @@ rtc_library("rtp_sender_interface") { - ":dtmf_sender_interface", - ":frame_transformer_interface", - ":media_stream_interface", -- ":rtc_error", +@@ -270,16 +282,31 @@ rtc_library("rtp_sender_interface") { + ":ref_count", + ":rtc_error", ":rtp_parameters", + ":rtp_sender_setparameters_callback", ":scoped_refptr", "../rtc_base:checks", - "../rtc_base:refcount", -@@ -237,10 +246,24 @@ rtc_library("rtp_sender_interface") { + "../rtc_base/system:rtc_export", "crypto:frame_encryptor_interface", "video_codecs:video_codecs_api", ] @@ -270,7 +286,7 @@ index 46703f93ce..d2b7f06c87 100644 visibility = [ "*" ] cflags = [] sources = [ -@@ -357,6 +380,7 @@ rtc_library("libjingle_peerconnection_api") { +@@ -396,6 +423,7 @@ rtc_library("libjingle_peerconnection_api") { "//third_party/abseil-cpp/absl/types:optional", ] } @@ -278,7 +294,7 @@ index 46703f93ce..d2b7f06c87 100644 rtc_source_set("frame_transformer_interface") { visibility = [ "*" ] -@@ -548,6 +572,7 @@ rtc_source_set("peer_network_dependencies") { +@@ -568,6 +596,7 @@ rtc_source_set("peer_network_dependencies") { } rtc_source_set("peer_connection_quality_test_fixture_api") { @@ -286,7 +302,7 @@ index 46703f93ce..d2b7f06c87 100644 visibility = [ "*" ] testonly = true sources = [ "test/peerconnection_quality_test_fixture.h" ] -@@ -598,6 +623,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { +@@ -618,6 +647,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { "//third_party/abseil-cpp/absl/types:optional", ] } @@ -294,7 +310,7 @@ index 46703f93ce..d2b7f06c87 100644 rtc_source_set("frame_generator_api") { visibility = [ "*" ] -@@ -716,6 +742,7 @@ rtc_library("create_frame_generator") { +@@ -736,6 +766,7 @@ rtc_library("create_frame_generator") { absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } @@ -302,7 +318,7 @@ index 46703f93ce..d2b7f06c87 100644 rtc_library("create_peer_connection_quality_test_frame_generator") { visibility = [ "*" ] testonly = true -@@ -732,6 +759,7 @@ rtc_library("create_peer_connection_quality_test_frame_generator") { +@@ -752,6 +783,7 @@ rtc_library("create_peer_connection_quality_test_frame_generator") { ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } @@ -310,7 +326,7 @@ index 46703f93ce..d2b7f06c87 100644 rtc_source_set("libjingle_logging_api") { visibility = [ "*" ] -@@ -904,6 +932,7 @@ rtc_source_set("refcountedbase") { +@@ -926,6 +958,7 @@ rtc_source_set("refcountedbase") { ] } @@ -318,7 +334,7 @@ index 46703f93ce..d2b7f06c87 100644 rtc_library("ice_transport_factory") { visibility = [ "*" ] sources = [ -@@ -922,6 +951,7 @@ rtc_library("ice_transport_factory") { +@@ -944,6 +977,7 @@ rtc_library("ice_transport_factory") { "rtc_event_log:rtc_event_log", ] } @@ -327,11 +343,11 @@ index 46703f93ce..d2b7f06c87 100644 rtc_library("neteq_simulator_api") { visibility = [ "*" ] diff --git a/api/rtp_sender_interface.h b/api/rtp_sender_interface.h -index 41d35bc287..619b601f1f 100644 +index 7b8ab135c8..7090c233cd 100644 --- a/api/rtp_sender_interface.h +++ b/api/rtp_sender_interface.h @@ -32,9 +32,9 @@ - #include "rtc_base/ref_count.h" + #include "api/video_codecs/video_encoder_factory.h" #include "rtc_base/system/rtc_export.h" -namespace webrtc { @@ -340,7 +356,7 @@ index 41d35bc287..619b601f1f 100644 -using SetParametersCallback = absl::AnyInvocable; +namespace webrtc { - class RTC_EXPORT RtpSenderInterface : public rtc::RefCountInterface { + class RTC_EXPORT RtpSenderInterface : public webrtc::RefCountInterface { public: diff --git a/api/rtp_sender_setparameters_callback.cc b/api/rtp_sender_setparameters_callback.cc new file mode 100644 @@ -410,7 +426,7 @@ index 0000000000..45194f5ace + +#endif // API_RTP_SENDER_SETPARAMETERS_CALLBACK_H_ diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn -index e0e2e50514..8d845e2735 100644 +index 246164c68b..d557d8f100 100644 --- a/api/task_queue/BUILD.gn +++ b/api/task_queue/BUILD.gn @@ -31,6 +31,7 @@ rtc_library("task_queue") { @@ -450,7 +466,7 @@ index 84a0968ee9..c0209bf0d0 100644 if (rtc_include_tests) { rtc_source_set("test_feedback_generator_interface") { diff --git a/call/BUILD.gn b/call/BUILD.gn -index 58473dc1ea..825097e8d4 100644 +index 66c8b2011a..fa733a67b9 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -46,7 +46,7 @@ rtc_library("call_interfaces") { @@ -462,7 +478,7 @@ index 58473dc1ea..825097e8d4 100644 "../api:scoped_refptr", "../api:transport_api", "../api/adaptation:resource_adaptation_api", -@@ -346,6 +346,16 @@ rtc_library("call") { +@@ -347,6 +347,16 @@ rtc_library("call") { "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] @@ -479,7 +495,7 @@ index 58473dc1ea..825097e8d4 100644 } rtc_source_set("receive_stream_interface") { -@@ -373,7 +383,7 @@ rtc_library("video_stream_api") { +@@ -374,7 +384,7 @@ rtc_library("video_stream_api") { "../api:frame_transformer_interface", "../api:rtp_headers", "../api:rtp_parameters", @@ -502,7 +518,7 @@ index 9c2fad652f..f9e49db574 100644 #include "call/audio_sender.h" #include "call/rtp_config.h" diff --git a/call/video_send_stream.h b/call/video_send_stream.h -index 5fde44a719..1a0261be1b 100644 +index c305d60bcc..2b4ea5b66a 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h @@ -23,7 +23,7 @@ @@ -561,7 +577,7 @@ index 0000000000..f6ff7f218f + #endif +#endif diff --git a/media/BUILD.gn b/media/BUILD.gn -index cf7c523201..97ad4a889a 100644 +index 295a748802..055bf75a19 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -64,7 +64,7 @@ rtc_library("rtc_media_base") { @@ -601,7 +617,7 @@ index cf7c523201..97ad4a889a 100644 rtc_source_set("media_channel") { sources = [ "base/media_channel.h" ] -@@ -269,6 +280,7 @@ rtc_library("codec") { +@@ -268,6 +279,7 @@ rtc_library("codec") { } rtc_library("rtp_utils") { @@ -609,7 +625,7 @@ index cf7c523201..97ad4a889a 100644 sources = [ "base/rtp_utils.cc", "base/rtp_utils.h", -@@ -285,8 +297,10 @@ rtc_library("rtp_utils") { +@@ -284,8 +296,10 @@ rtc_library("rtp_utils") { ] absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } @@ -620,7 +636,7 @@ index cf7c523201..97ad4a889a 100644 sources = [ "base/stream_params.cc", "base/stream_params.h", -@@ -299,6 +313,7 @@ rtc_library("stream_params") { +@@ -298,6 +312,7 @@ rtc_library("stream_params") { ] absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ] } @@ -628,7 +644,7 @@ index cf7c523201..97ad4a889a 100644 rtc_library("media_constants") { sources = [ -@@ -309,6 +324,7 @@ rtc_library("media_constants") { +@@ -308,6 +323,7 @@ rtc_library("media_constants") { } rtc_library("turn_utils") { @@ -636,7 +652,7 @@ index cf7c523201..97ad4a889a 100644 sources = [ "base/turn_utils.cc", "base/turn_utils.h", -@@ -319,14 +335,17 @@ rtc_library("turn_utils") { +@@ -318,14 +334,17 @@ rtc_library("turn_utils") { "../rtc_base/system:rtc_export", ] } @@ -654,7 +670,7 @@ index cf7c523201..97ad4a889a 100644 rtc_library("rtc_simulcast_encoder_adapter") { visibility = [ "*" ] -@@ -400,6 +419,12 @@ rtc_library("rtc_internal_video_codecs") { +@@ -399,6 +418,12 @@ rtc_library("rtc_internal_video_codecs") { "../system_wrappers:field_trial", "../test:fake_video_codecs", ] @@ -667,7 +683,7 @@ index cf7c523201..97ad4a889a 100644 if (enable_libaom) { defines += [ "RTC_USE_LIBAOM_AV1_ENCODER" ] -@@ -425,6 +450,14 @@ rtc_library("rtc_internal_video_codecs") { +@@ -424,6 +449,14 @@ rtc_library("rtc_internal_video_codecs") { "engine/multiplex_codec_factory.cc", "engine/multiplex_codec_factory.h", ] @@ -722,7 +738,7 @@ index e7e84c781c..5b41a9ccda 100644 using webrtc::FrameDecryptorInterface; using webrtc::FrameEncryptorInterface; diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn -index 61fecea691..3e4d7e0c25 100644 +index 5de99efa45..ddd1fd2656 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -553,7 +553,7 @@ rtc_library("webrtc_opus_wrapper") { @@ -735,7 +751,7 @@ index 61fecea691..3e4d7e0c25 100644 } diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn -index f1ab09d154..4726f93279 100644 +index 6f52cf8af1..a135f042db 100644 --- a/modules/audio_device/BUILD.gn +++ b/modules/audio_device/BUILD.gn @@ -30,6 +30,7 @@ rtc_source_set("audio_device_default") { @@ -754,7 +770,7 @@ index f1ab09d154..4726f93279 100644 rtc_source_set("audio_device_api") { visibility = [ "*" ] -@@ -62,6 +64,7 @@ rtc_library("audio_device_config") { +@@ -63,6 +65,7 @@ rtc_library("audio_device_config") { } rtc_library("audio_device_buffer") { @@ -762,7 +778,7 @@ index f1ab09d154..4726f93279 100644 sources = [ "audio_device_buffer.cc", "audio_device_buffer.h", -@@ -88,6 +91,7 @@ rtc_library("audio_device_buffer") { +@@ -89,6 +92,7 @@ rtc_library("audio_device_buffer") { "../../system_wrappers:metrics", ] } @@ -770,7 +786,7 @@ index f1ab09d154..4726f93279 100644 rtc_library("audio_device_generic") { sources = [ -@@ -265,6 +269,7 @@ if (!build_with_chromium) { +@@ -266,6 +270,7 @@ if (!build_with_chromium) { # Contains default implementations of webrtc::AudioDeviceModule for Windows, # Linux, Mac, iOS and Android. rtc_library("audio_device_impl") { @@ -778,7 +794,7 @@ index f1ab09d154..4726f93279 100644 visibility = [ "*" ] deps = [ ":audio_device_api", -@@ -314,9 +319,9 @@ rtc_library("audio_device_impl") { +@@ -315,9 +320,9 @@ rtc_library("audio_device_impl") { sources = [ "include/fake_audio_device.h" ] if (build_with_mozilla) { @@ -791,7 +807,7 @@ index f1ab09d154..4726f93279 100644 ] } -@@ -421,6 +426,7 @@ rtc_library("audio_device_impl") { +@@ -422,6 +427,7 @@ rtc_library("audio_device_impl") { sources += [ "dummy/file_audio_device_factory.h" ] } } @@ -799,7 +815,7 @@ index f1ab09d154..4726f93279 100644 if (is_mac) { rtc_source_set("audio_device_impl_frameworks") { -@@ -438,6 +444,7 @@ if (is_mac) { +@@ -439,6 +445,7 @@ if (is_mac) { } } @@ -807,7 +823,7 @@ index f1ab09d154..4726f93279 100644 rtc_source_set("mock_audio_device") { visibility = [ "*" ] testonly = true -@@ -454,8 +461,10 @@ rtc_source_set("mock_audio_device") { +@@ -455,8 +462,10 @@ rtc_source_set("mock_audio_device") { "../../test:test_support", ] } @@ -1012,10 +1028,10 @@ index 730ec9bfdd..d473dbb74c 100644 "/config/external/nspr", "/nsprpub/lib/ds", diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 99d8e48e39..b411811b70 100644 +index 9f5f0aad56..089b9971a3 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn -@@ -323,6 +323,7 @@ rtc_library("sample_counter") { +@@ -327,6 +327,7 @@ rtc_library("sample_counter") { absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } @@ -1023,7 +1039,7 @@ index 99d8e48e39..b411811b70 100644 rtc_library("timestamp_aligner") { visibility = [ "*" ] sources = [ -@@ -336,6 +337,7 @@ rtc_library("timestamp_aligner") { +@@ -340,6 +341,7 @@ rtc_library("timestamp_aligner") { "system:rtc_export", ] } @@ -1031,7 +1047,7 @@ index 99d8e48e39..b411811b70 100644 rtc_library("zero_memory") { visibility = [ "*" ] -@@ -869,7 +871,9 @@ rtc_library("rtc_json") { +@@ -875,7 +877,9 @@ rtc_library("rtc_json") { "strings/json.h", ] deps = [ ":stringutils" ] @@ -1041,7 +1057,7 @@ index 99d8e48e39..b411811b70 100644 if (rtc_build_json) { deps += [ "//third_party/jsoncpp" ] } else { -@@ -1234,6 +1238,7 @@ if (!build_with_chromium) { +@@ -1223,6 +1227,7 @@ if (!build_with_chromium) { } rtc_library("network") { @@ -1049,7 +1065,7 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "network.cc", -@@ -1272,16 +1277,20 @@ rtc_library("network") { +@@ -1261,16 +1266,20 @@ rtc_library("network") { deps += [ ":win32" ] } } @@ -1070,7 +1086,7 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "net_helper.cc", -@@ -1290,8 +1299,10 @@ rtc_library("net_helper") { +@@ -1279,8 +1288,10 @@ rtc_library("net_helper") { absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] deps = [ "system:rtc_export" ] } @@ -1081,7 +1097,7 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "socket_adapters.cc", -@@ -1311,6 +1322,7 @@ rtc_library("socket_adapters") { +@@ -1300,6 +1311,7 @@ rtc_library("socket_adapters") { ] absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } @@ -1089,7 +1105,7 @@ index 99d8e48e39..b411811b70 100644 rtc_library("network_route") { sources = [ -@@ -1325,6 +1337,7 @@ rtc_library("network_route") { +@@ -1314,6 +1326,7 @@ rtc_library("network_route") { } rtc_library("async_tcp_socket") { @@ -1097,7 +1113,7 @@ index 99d8e48e39..b411811b70 100644 sources = [ "async_tcp_socket.cc", "async_tcp_socket.h", -@@ -1342,8 +1355,10 @@ rtc_library("async_tcp_socket") { +@@ -1331,8 +1344,10 @@ rtc_library("async_tcp_socket") { "network:sent_packet", ] } @@ -1108,7 +1124,7 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "async_udp_socket.cc", -@@ -1365,8 +1380,10 @@ rtc_library("async_udp_socket") { +@@ -1354,8 +1369,10 @@ rtc_library("async_udp_socket") { ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } @@ -1119,15 +1135,15 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "async_packet_socket.cc", -@@ -1384,6 +1401,7 @@ rtc_library("async_packet_socket") { +@@ -1375,6 +1392,7 @@ rtc_library("async_packet_socket") { "third_party/sigslot", ] } +} - rtc_library("mdns_responder_interface") { - sources = [ "mdns_responder_interface.h" ] -@@ -1396,6 +1414,7 @@ rtc_library("dscp") { + if (rtc_include_tests) { + rtc_library("async_packet_socket_unittest") { +@@ -1402,6 +1420,7 @@ rtc_library("dscp") { } rtc_library("proxy_info") { @@ -1135,7 +1151,7 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "proxy_info.cc", -@@ -1406,6 +1425,7 @@ rtc_library("proxy_info") { +@@ -1412,6 +1431,7 @@ rtc_library("proxy_info") { ":socket_address", ] } @@ -1143,7 +1159,7 @@ index 99d8e48e39..b411811b70 100644 rtc_library("file_rotating_stream") { sources = [ -@@ -1434,6 +1454,7 @@ rtc_library("data_rate_limiter") { +@@ -1440,6 +1460,7 @@ rtc_library("data_rate_limiter") { } rtc_library("unique_id_generator") { @@ -1151,7 +1167,7 @@ index 99d8e48e39..b411811b70 100644 sources = [ "unique_id_generator.cc", "unique_id_generator.h", -@@ -1448,6 +1469,7 @@ rtc_library("unique_id_generator") { +@@ -1454,6 +1475,7 @@ rtc_library("unique_id_generator") { ] absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } @@ -1159,7 +1175,7 @@ index 99d8e48e39..b411811b70 100644 rtc_library("crc32") { sources = [ -@@ -1475,6 +1497,7 @@ rtc_library("stream") { +@@ -1481,6 +1503,7 @@ rtc_library("stream") { } rtc_library("rtc_certificate_generator") { @@ -1167,7 +1183,7 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "rtc_certificate_generator.cc", -@@ -1492,8 +1515,10 @@ rtc_library("rtc_certificate_generator") { +@@ -1498,8 +1521,10 @@ rtc_library("rtc_certificate_generator") { "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1178,7 +1194,7 @@ index 99d8e48e39..b411811b70 100644 visibility = [ "*" ] sources = [ "helpers.cc", -@@ -1594,6 +1619,7 @@ rtc_library("ssl") { +@@ -1600,6 +1625,7 @@ rtc_library("ssl") { deps += [ ":win32" ] } } @@ -1186,7 +1202,7 @@ index 99d8e48e39..b411811b70 100644 rtc_library("crypt_string") { sources = [ -@@ -1603,6 +1629,7 @@ rtc_library("crypt_string") { +@@ -1609,6 +1635,7 @@ rtc_library("crypt_string") { } rtc_library("http_common") { @@ -1194,7 +1210,7 @@ index 99d8e48e39..b411811b70 100644 sources = [ "http_common.cc", "http_common.h", -@@ -1619,6 +1646,7 @@ rtc_library("http_common") { +@@ -1625,6 +1652,7 @@ rtc_library("http_common") { absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } @@ -1202,7 +1218,7 @@ index 99d8e48e39..b411811b70 100644 rtc_source_set("gtest_prod") { sources = [ "gtest_prod_util.h" ] -@@ -2176,7 +2204,7 @@ if (rtc_include_tests) { +@@ -2189,7 +2217,7 @@ if (rtc_include_tests) { } } @@ -1225,7 +1241,7 @@ index 77f5139a2f..486b37590c 100644 deps += [ "..:logging", diff --git a/test/BUILD.gn b/test/BUILD.gn -index be8ee1684e..f7980f941d 100644 +index d313c6d82d..854530c01e 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -241,6 +241,7 @@ rtc_library("audio_test_common") { @@ -1267,7 +1283,7 @@ index be8ee1684e..f7980f941d 100644 sources += [ "testsupport/jpeg_frame_writer.cc" ] } else { sources += [ "testsupport/jpeg_frame_writer_ios.cc" ] -@@ -1322,6 +1330,7 @@ if (!build_with_chromium) { +@@ -1331,6 +1339,7 @@ if (!build_with_chromium) { } } @@ -1275,7 +1291,7 @@ index be8ee1684e..f7980f941d 100644 if (!build_with_chromium && is_android) { rtc_android_library("native_test_java") { testonly = true -@@ -1335,6 +1344,7 @@ if (!build_with_chromium && is_android) { +@@ -1344,6 +1353,7 @@ if (!build_with_chromium && is_android) { ] } } @@ -1284,7 +1300,7 @@ index be8ee1684e..f7980f941d 100644 rtc_library("call_config_utils") { testonly = true diff --git a/video/BUILD.gn b/video/BUILD.gn -index 1722ad4f6e..e84b73a352 100644 +index 204c6b66f4..0a930053c0 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -17,7 +17,7 @@ rtc_library("video_stream_encoder_interface") { @@ -1306,7 +1322,7 @@ index 1722ad4f6e..e84b73a352 100644 "../api/adaptation:resource_adaptation_api", "../api/task_queue:pending_task_safety_flag", diff --git a/webrtc.gni b/webrtc.gni -index 912b9b4ef0..1ee647b69d 100644 +index 277c12c054..c84464e84a 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -35,6 +35,11 @@ if (is_mac) { @@ -1406,7 +1422,7 @@ index 912b9b4ef0..1ee647b69d 100644 # Make it possible to provide custom locations for some libraries (move these # up into declare_args should we need to actually use them for the GN build). rtc_libvpx_dir = "//third_party/libvpx" -@@ -1144,7 +1154,7 @@ if (is_mac || is_ios) { +@@ -1146,7 +1156,7 @@ if (is_mac || is_ios) { } } diff --git a/third_party/libwebrtc/moz-patch-stack/0031.patch b/third_party/libwebrtc/moz-patch-stack/0031.patch index 4602f40c31..0b1372a1dd 100644 --- a/third_party/libwebrtc/moz-patch-stack/0031.patch +++ b/third_party/libwebrtc/moz-patch-stack/0031.patch @@ -9,10 +9,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/7163801a480d60700 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/channel_send.cc b/audio/channel_send.cc -index 08dd74591d..81d5c66652 100644 +index ecf2cb5175..310e0517cf 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc -@@ -625,9 +625,9 @@ void ChannelSend::SetSendAudioLevelIndicationStatus(bool enable, int id) { +@@ -639,9 +639,9 @@ void ChannelSend::SetSendAudioLevelIndicationStatus(bool enable, int id) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); include_audio_level_indication_.store(enable); if (enable) { diff --git a/third_party/libwebrtc/moz-patch-stack/0033.patch b/third_party/libwebrtc/moz-patch-stack/0033.patch index 2742e376b0..5c69ef0bce 100644 --- a/third_party/libwebrtc/moz-patch-stack/0033.patch +++ b/third_party/libwebrtc/moz-patch-stack/0033.patch @@ -15,7 +15,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/d380a43d59f4f7cbc 4 files changed, 35 insertions(+) diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc -index 0caf59a20e..bffb910832 100644 +index c9dc42c04e..e7ebb2bf4e 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -431,6 +431,7 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats( @@ -27,10 +27,10 @@ index 0caf59a20e..bffb910832 100644 stats.header_and_padding_bytes_sent = call_stats.header_and_padding_bytes_sent; diff --git a/audio/channel_send.cc b/audio/channel_send.cc -index 81d5c66652..ddc3323df9 100644 +index 310e0517cf..549e65a59c 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc -@@ -55,6 +55,31 @@ constexpr int64_t kMinRetransmissionWindowMs = 30; +@@ -56,6 +56,31 @@ constexpr int64_t kMinRetransmissionWindowMs = 30; class RtpPacketSenderProxy; class TransportSequenceNumberProxy; @@ -62,7 +62,7 @@ index 81d5c66652..ddc3323df9 100644 class ChannelSend : public ChannelSendInterface, public AudioPacketizationCallback, // receive encoded // packets from the ACM -@@ -207,6 +232,8 @@ class ChannelSend : public ChannelSendInterface, +@@ -210,6 +235,8 @@ class ChannelSend : public ChannelSendInterface, bool input_mute_ RTC_GUARDED_BY(volume_settings_mutex_) = false; bool previous_frame_muted_ RTC_GUARDED_BY(encoder_queue_) = false; @@ -71,7 +71,7 @@ index 81d5c66652..ddc3323df9 100644 PacketRouter* packet_router_ RTC_GUARDED_BY(&worker_thread_checker_) = nullptr; const std::unique_ptr rtp_packet_pacer_proxy_; -@@ -387,6 +414,7 @@ ChannelSend::ChannelSend( +@@ -398,6 +425,7 @@ ChannelSend::ChannelSend( const FieldTrialsView& field_trials) : ssrc_(ssrc), event_log_(rtc_event_log), @@ -79,7 +79,7 @@ index 81d5c66652..ddc3323df9 100644 rtp_packet_pacer_proxy_(new RtpPacketSenderProxy()), retransmission_rate_limiter_( new RateLimiter(clock, kMaxRetransmissionWindowMs)), -@@ -411,6 +439,8 @@ ChannelSend::ChannelSend( +@@ -423,6 +451,8 @@ ChannelSend::ChannelSend( configuration.event_log = event_log_; configuration.rtt_stats = rtcp_rtt_stats; @@ -88,7 +88,7 @@ index 81d5c66652..ddc3323df9 100644 if (field_trials.IsDisabled("WebRTC-DisableRtxRateLimiter")) { configuration.retransmission_rate_limiter = retransmission_rate_limiter_.get(); -@@ -673,6 +703,7 @@ CallSendStatistics ChannelSend::GetRTCPStatistics() const { +@@ -687,6 +717,7 @@ CallSendStatistics ChannelSend::GetRTCPStatistics() const { RTC_DCHECK_RUN_ON(&worker_thread_checker_); CallSendStatistics stats = {0}; stats.rttMs = GetRTT(); @@ -97,7 +97,7 @@ index 81d5c66652..ddc3323df9 100644 StreamDataCounters rtp_stats; StreamDataCounters rtx_stats; diff --git a/audio/channel_send.h b/audio/channel_send.h -index 00d954c952..f0c9232296 100644 +index b6a6a37bf5..f36085c1fa 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -43,6 +43,7 @@ struct CallSendStatistics { diff --git a/third_party/libwebrtc/moz-patch-stack/0041.patch b/third_party/libwebrtc/moz-patch-stack/0041.patch index dc73538fe0..44fb08ed83 100644 --- a/third_party/libwebrtc/moz-patch-stack/0041.patch +++ b/third_party/libwebrtc/moz-patch-stack/0041.patch @@ -20,7 +20,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/58f47eacaf10d12e2 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index f61f8965b9..e514b4d6a7 100644 +index f393179bbb..d2ede84941 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -427,12 +427,12 @@ config("common_config") { @@ -276,7 +276,7 @@ index 344c8a1531..dcc1b3c6ac 100644 config("x11_config") { if (rtc_use_x11_extensions) { diff --git a/webrtc.gni b/webrtc.gni -index 1ee647b69d..44eaa2db04 100644 +index c84464e84a..ad69bf8f8e 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -175,13 +175,13 @@ declare_args() { diff --git a/third_party/libwebrtc/moz-patch-stack/0042.patch b/third_party/libwebrtc/moz-patch-stack/0042.patch index be51a5a8b6..42bc15e1f6 100644 --- a/third_party/libwebrtc/moz-patch-stack/0042.patch +++ b/third_party/libwebrtc/moz-patch-stack/0042.patch @@ -43,10 +43,10 @@ index 978bbb25b2..655b2761ac 100644 } // namespace diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc -index f5d214f672..c714b1dd4d 100644 +index 8367b00113..aff21fa72a 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc -@@ -104,7 +104,8 @@ class ChannelReceive : public ChannelReceiveInterface, +@@ -105,7 +105,8 @@ class ChannelReceive : public ChannelReceiveInterface, absl::optional codec_pair_id, rtc::scoped_refptr frame_decryptor, const webrtc::CryptoOptions& crypto_options, @@ -56,7 +56,7 @@ index f5d214f672..c714b1dd4d 100644 ~ChannelReceive() override; void SetSink(AudioSinkInterface* sink) override; -@@ -538,7 +539,8 @@ ChannelReceive::ChannelReceive( +@@ -541,7 +542,8 @@ ChannelReceive::ChannelReceive( absl::optional codec_pair_id, rtc::scoped_refptr frame_decryptor, const webrtc::CryptoOptions& crypto_options, @@ -66,7 +66,7 @@ index f5d214f672..c714b1dd4d 100644 : worker_thread_(TaskQueueBase::Current()), event_log_(rtc_event_log), rtp_receive_statistics_(ReceiveStatistics::Create(clock)), -@@ -584,6 +586,7 @@ ChannelReceive::ChannelReceive( +@@ -587,6 +589,7 @@ ChannelReceive::ChannelReceive( configuration.local_media_ssrc = local_ssrc; configuration.rtcp_packet_type_counter_observer = this; configuration.non_sender_rtt_measurement = enable_non_sender_rtt; @@ -74,7 +74,7 @@ index f5d214f672..c714b1dd4d 100644 if (frame_transformer) InitFrameTransformerDelegate(std::move(frame_transformer)); -@@ -1111,13 +1114,15 @@ std::unique_ptr CreateChannelReceive( +@@ -1129,13 +1132,15 @@ std::unique_ptr CreateChannelReceive( absl::optional codec_pair_id, rtc::scoped_refptr frame_decryptor, const webrtc::CryptoOptions& crypto_options, diff --git a/third_party/libwebrtc/moz-patch-stack/0044.patch b/third_party/libwebrtc/moz-patch-stack/0044.patch index ec7206b4fa..7fdc82d1da 100644 --- a/third_party/libwebrtc/moz-patch-stack/0044.patch +++ b/third_party/libwebrtc/moz-patch-stack/0044.patch @@ -53,11 +53,11 @@ index 0178355262..be8bce770f 100644 // Implements RtpVideoFrameReceiver. void ManageFrame(std::unique_ptr frame) override; diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc -index 6c1df7d874..f50c3d0775 100644 +index af25c364de..776c49042b 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc -@@ -573,6 +573,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { - } +@@ -570,6 +570,14 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { + stats.rtx_rtp_stats = rtx_statistician->GetStats(); } } + diff --git a/third_party/libwebrtc/moz-patch-stack/0049.patch b/third_party/libwebrtc/moz-patch-stack/0049.patch index 3074531967..e94ab52a26 100644 --- a/third_party/libwebrtc/moz-patch-stack/0049.patch +++ b/third_party/libwebrtc/moz-patch-stack/0049.patch @@ -13,7 +13,7 @@ diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_ca index 56c94baada..8f5dc25516 100644 --- a/modules/desktop_capture/window_capturer_mac.mm +++ b/modules/desktop_capture/window_capturer_mac.mm -@@ -169,8 +169,9 @@ void WindowCapturerMac::CaptureFrame() { +@@ -169,8 +169,9 @@ explicit WindowCapturerMac( return webrtc::GetWindowList( [sources](CFDictionaryRef window) { WindowId window_id = GetWindowId(window); diff --git a/third_party/libwebrtc/moz-patch-stack/0050.patch b/third_party/libwebrtc/moz-patch-stack/0050.patch index 3c72c60db4..e36c3b83c6 100644 --- a/third_party/libwebrtc/moz-patch-stack/0050.patch +++ b/third_party/libwebrtc/moz-patch-stack/0050.patch @@ -106,7 +106,7 @@ index 742a69cce3..0b1266a2db 100644 // A snapshot of the most recent Report Block with additional data of // interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats. diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc -index 31a1b764b3..ff482b39b6 100644 +index d7e3c50f82..31e8b71117 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -503,11 +503,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters( @@ -190,10 +190,10 @@ index be8bce770f..0e96d7f2cd 100644 private: // Implements RtpVideoFrameReceiver. diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc -index f50c3d0775..2067f255f7 100644 +index 776c49042b..c04b43a1d1 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc -@@ -579,7 +579,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { +@@ -576,7 +576,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { // seem to be any support for these stats right now. So, we hack this in. rtp_video_stream_receiver_.RemoteRTCPSenderInfo( &stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent, diff --git a/third_party/libwebrtc/moz-patch-stack/0052.patch b/third_party/libwebrtc/moz-patch-stack/0052.patch index 7835e41a3c..616b4fdcc7 100644 --- a/third_party/libwebrtc/moz-patch-stack/0052.patch +++ b/third_party/libwebrtc/moz-patch-stack/0052.patch @@ -24,10 +24,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0744d68b8c944e699 10 files changed, 18 insertions(+), 6 deletions(-) diff --git a/audio/channel_send.cc b/audio/channel_send.cc -index ddc3323df9..777cc6d4c1 100644 +index 549e65a59c..8080f4a3b8 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc -@@ -431,7 +431,7 @@ ChannelSend::ChannelSend( +@@ -443,7 +443,7 @@ ChannelSend::ChannelSend( transport_controller->GetRtcpObserver(); configuration.transport_feedback_callback = transport_controller->transport_feedback_observer(); @@ -37,17 +37,18 @@ index ddc3323df9..777cc6d4c1 100644 configuration.outgoing_transport = rtp_transport; diff --git a/call/call.cc b/call/call.cc -index 6b975edc6a..c0ee5a92f4 100644 +index 42b3b988ea..d2ac705274 100644 --- a/call/call.cc +++ b/call/call.cc -@@ -473,12 +473,14 @@ std::string Call::Stats::ToString(int64_t time_ms) const { +@@ -473,6 +473,7 @@ std::string Call::Stats::ToString(int64_t time_ms) const { return ss.str(); } +/* Mozilla: Avoid this since it could use GetRealTimeClock(). std::unique_ptr Call::Create(const CallConfig& config) { - Clock* clock = Clock::GetRealTimeClock(); - return Create(config, clock, + Clock* clock = + config.env.has_value() ? &config.env->clock() : Clock::GetRealTimeClock(); +@@ -480,6 +481,7 @@ std::unique_ptr Call::Create(const CallConfig& config) { RtpTransportControllerSendFactory().Create( config.ExtractTransportConfig(), clock)); } diff --git a/third_party/libwebrtc/moz-patch-stack/0053.patch b/third_party/libwebrtc/moz-patch-stack/0053.patch index 38f35ba6e0..56c0b13b8e 100644 --- a/third_party/libwebrtc/moz-patch-stack/0053.patch +++ b/third_party/libwebrtc/moz-patch-stack/0053.patch @@ -18,7 +18,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0300b32b7de70fb89 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn -index e514b4d6a7..9fd472f10b 100644 +index d2ede84941..f595a2951a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -221,6 +221,9 @@ config("common_inherited_config") { @@ -74,7 +74,7 @@ index d64ea689bb..c3c6955a7b 100644 #endif // defined(WEBRTC_POSIX) } diff --git a/webrtc.gni b/webrtc.gni -index 44eaa2db04..bacd158140 100644 +index ad69bf8f8e..e339ba25fe 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -360,7 +360,7 @@ rtc_opus_dir = "//third_party/opus" diff --git a/third_party/libwebrtc/moz-patch-stack/0054.patch b/third_party/libwebrtc/moz-patch-stack/0054.patch index a3f95bca6c..928198e5a4 100644 --- a/third_party/libwebrtc/moz-patch-stack/0054.patch +++ b/third_party/libwebrtc/moz-patch-stack/0054.patch @@ -15,7 +15,7 @@ Subject: Bug 1766646 - (fix) breakout Call::Stats and SharedModuleThread into create mode 100644 call/call_basic_stats.h diff --git a/call/BUILD.gn b/call/BUILD.gn -index 825097e8d4..47018a570a 100644 +index fa733a67b9..626ed95066 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -33,6 +33,12 @@ rtc_library("call_interfaces") { @@ -32,7 +32,7 @@ index 825097e8d4..47018a570a 100644 deps = [ ":audio_sender_interface", diff --git a/call/call.cc b/call/call.cc -index c0ee5a92f4..0f3699501e 100644 +index d2ac705274..63dc370f1a 100644 --- a/call/call.cc +++ b/call/call.cc @@ -460,19 +460,6 @@ class Call final : public webrtc::Call, @@ -54,7 +54,7 @@ index c0ee5a92f4..0f3699501e 100644 - /* Mozilla: Avoid this since it could use GetRealTimeClock(). std::unique_ptr Call::Create(const CallConfig& config) { - Clock* clock = Clock::GetRealTimeClock(); + Clock* clock = diff --git a/call/call.h b/call/call.h index 6f8e4cd6d7..b36872f5b5 100644 --- a/call/call.h diff --git a/third_party/libwebrtc/moz-patch-stack/0059.patch b/third_party/libwebrtc/moz-patch-stack/0059.patch index a5825e03b3..018d4ac255 100644 --- a/third_party/libwebrtc/moz-patch-stack/0059.patch +++ b/third_party/libwebrtc/moz-patch-stack/0059.patch @@ -8,10 +8,10 @@ Subject: Bug 1766646 - (fix-f137b75a4d) specify default constructor on 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc -index e26fcc6cb1..ef200869a6 100644 +index 95f821352a..8e1a3c4698 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc -@@ -508,7 +508,7 @@ absl::optional LossBasedBweV2::CreateConfig( +@@ -546,7 +546,7 @@ absl::optional LossBasedBweV2::CreateConfig( if (!enabled.Get()) { return config; } @@ -19,4 +19,4 @@ index e26fcc6cb1..ef200869a6 100644 + config.emplace(Config()); config->bandwidth_rampup_upper_bound_factor = bandwidth_rampup_upper_bound_factor.Get(); - config->rampup_acceleration_max_factor = rampup_acceleration_max_factor.Get(); + config->bandwidth_rampup_upper_bound_factor_in_hold = diff --git a/third_party/libwebrtc/moz-patch-stack/0061.patch b/third_party/libwebrtc/moz-patch-stack/0061.patch index 8b12fb66f9..cc24d61d85 100644 --- a/third_party/libwebrtc/moz-patch-stack/0061.patch +++ b/third_party/libwebrtc/moz-patch-stack/0061.patch @@ -2,12 +2,15 @@ From: Michael Froman Date: Tue, 21 Jun 2022 11:17:46 -0500 Subject: Bug 1772380 - to upstream - ref count this in lambda capture +Bug 1876843 - (fix-23cecc1d43) drop rtc:: prefix on scoped_ptr + +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2e4867d8cc9813869bd80f5201d3f7d84afcd412 --- modules/video_capture/linux/video_capture_v4l2.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc -index 00cede01cb..d6813b13fd 100644 +index 00cede01cb..97cd9a70eb 100644 --- a/modules/video_capture/linux/video_capture_v4l2.cc +++ b/modules/video_capture/linux/video_capture_v4l2.cc @@ -296,8 +296,8 @@ int32_t VideoCaptureModuleV4L2::StartCapture( @@ -16,7 +19,7 @@ index 00cede01cb..d6813b13fd 100644 _captureThread = rtc::PlatformThread::SpawnJoinable( - [this] { - while (CaptureProcess()) { -+ [self = rtc::scoped_refptr(this)] { ++ [self = scoped_refptr(this)] { + while (self->CaptureProcess()) { } }, diff --git a/third_party/libwebrtc/moz-patch-stack/0063.patch b/third_party/libwebrtc/moz-patch-stack/0063.patch index a61bf11937..12bf71ee22 100644 --- a/third_party/libwebrtc/moz-patch-stack/0063.patch +++ b/third_party/libwebrtc/moz-patch-stack/0063.patch @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e826dfadfe1264c59 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h -index 58485f28e9..04203033b0 100644 +index 7279bed476..db07580921 100644 --- a/modules/video_capture/video_capture.h +++ b/modules/video_capture/video_capture.h @@ -16,6 +16,8 @@ @@ -22,7 +22,7 @@ index 58485f28e9..04203033b0 100644 #include #if defined(ANDROID) -@@ -40,15 +42,18 @@ class VideoCaptureModule : public rtc::RefCountInterface { +@@ -40,15 +42,18 @@ class VideoCaptureModule : public RefCountInterface { virtual uint32_t NumberOfDevices() = 0; virtual int32_t Refresh() = 0; virtual void DeviceChange() { @@ -41,7 +41,7 @@ index 58485f28e9..04203033b0 100644 auto it = _inputCallBacks.find(callBack); if (it != _inputCallBacks.end()) { _inputCallBacks.erase(it); -@@ -102,7 +107,8 @@ class VideoCaptureModule : public rtc::RefCountInterface { +@@ -102,7 +107,8 @@ class VideoCaptureModule : public RefCountInterface { virtual ~DeviceInfo() {} private: diff --git a/third_party/libwebrtc/moz-patch-stack/0064.patch b/third_party/libwebrtc/moz-patch-stack/0064.patch index c285381dbb..4d9c0c6550 100644 --- a/third_party/libwebrtc/moz-patch-stack/0064.patch +++ b/third_party/libwebrtc/moz-patch-stack/0064.patch @@ -13,7 +13,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/f097eb8cbd8b7686c 2 files changed, 9 insertions(+) diff --git a/api/task_queue/BUILD.gn b/api/task_queue/BUILD.gn -index 8d845e2735..760ceaa3ef 100644 +index d557d8f100..9b2f747e78 100644 --- a/api/task_queue/BUILD.gn +++ b/api/task_queue/BUILD.gn @@ -31,6 +31,11 @@ rtc_library("task_queue") { @@ -29,10 +29,10 @@ index 8d845e2735..760ceaa3ef 100644 rtc_library("task_queue_test") { visibility = [ "*" ] diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index b411811b70..3d57e3bfb4 100644 +index 089b9971a3..5392e5f472 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn -@@ -737,10 +737,14 @@ if (is_mac || is_ios) { +@@ -743,10 +743,14 @@ if (is_mac || is_ios) { if (is_win) { rtc_library("rtc_task_queue_win") { visibility = [ "../api/task_queue:default_task_queue_factory" ] diff --git a/third_party/libwebrtc/moz-patch-stack/0066.patch b/third_party/libwebrtc/moz-patch-stack/0066.patch index 6c4bb19816..01f4a41c95 100644 --- a/third_party/libwebrtc/moz-patch-stack/0066.patch +++ b/third_party/libwebrtc/moz-patch-stack/0066.patch @@ -11,10 +11,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b0658888969395dca 2 files changed, 10 insertions(+) diff --git a/BUILD.gn b/BUILD.gn -index 9fd472f10b..612483cef8 100644 +index f595a2951a..7feca08e60 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -601,6 +601,10 @@ if (!build_with_chromium) { +@@ -603,6 +603,10 @@ if (!build_with_chromium) { ] } @@ -26,7 +26,7 @@ index 9fd472f10b..612483cef8 100644 deps += [ "logging:rtc_event_log_proto" ] } diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn -index 4f5ceb5ed3..eea26dc31d 100644 +index e28bdcc5a2..586d4d1911 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -533,6 +533,7 @@ if (is_ios || is_mac) { diff --git a/third_party/libwebrtc/moz-patch-stack/0067.patch b/third_party/libwebrtc/moz-patch-stack/0067.patch index c7b6230bcc..52302d9a8d 100644 --- a/third_party/libwebrtc/moz-patch-stack/0067.patch +++ b/third_party/libwebrtc/moz-patch-stack/0067.patch @@ -13,10 +13,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7362238c9e6fbe0d 1 file changed, 3 insertions(+) diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h -index 04203033b0..6614032299 100644 +index db07580921..43a6a7f832 100644 --- a/modules/video_capture/video_capture.h +++ b/modules/video_capture/video_capture.h -@@ -154,6 +154,9 @@ class VideoCaptureModule : public rtc::RefCountInterface { +@@ -154,6 +154,9 @@ class VideoCaptureModule : public RefCountInterface { // Return whether the rotation is applied or left pending. virtual bool GetApplyRotation() = 0; diff --git a/third_party/libwebrtc/moz-patch-stack/0068.patch b/third_party/libwebrtc/moz-patch-stack/0068.patch index 93e486f645..ab46127e4f 100644 --- a/third_party/libwebrtc/moz-patch-stack/0068.patch +++ b/third_party/libwebrtc/moz-patch-stack/0068.patch @@ -273,7 +273,7 @@ index 0e96d7f2cd..10329005ba 100644 RTC_GUARDED_BY(packet_sequence_checker_); UniqueTimestampCounter frame_counter_ diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc -index 2067f255f7..85cc0aa0dc 100644 +index c04b43a1d1..33e2f39ced 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -210,6 +210,7 @@ VideoReceiveStream2::VideoReceiveStream2( diff --git a/third_party/libwebrtc/moz-patch-stack/0078.patch b/third_party/libwebrtc/moz-patch-stack/0078.patch index b6198f6e9c..c7d811ffd7 100644 --- a/third_party/libwebrtc/moz-patch-stack/0078.patch +++ b/third_party/libwebrtc/moz-patch-stack/0078.patch @@ -1,60 +1,57 @@ -From: Andreas Pehrson -Date: Wed, 10 May 2023 07:06:00 +0000 -Subject: Bug 1810949 - cherry-pick upstream libwebrtc commit 91d5fc2ed6. - r=webrtc-reviewers,mjf +From: Nico Grunbaum +Date: Tue, 6 Jun 2023 16:37:00 -0700 +Subject: Bug 1833237 - (fix-f0be3bee1f) remove reference to + portal:pipewire_base;r?pehrsons -Upstream commit: https://webrtc.googlesource.com/src/+/91d5fc2ed6ef347d90182868320267d45cf9525b - Support more pixel formats in v4l2 camera backend - - These were tested with gstreamer and v4l2loopback, example setup: - $ sudo v4l2loopback-ctl add -n BGRA 10 - $ gst-launch-1.0 videotestsrc pattern=smpte-rp-219 ! \ - video/x-raw,format=BGRA ! v4l2sink device=/dev/video10 > /dev/null & - - Then conversion was confirmed with video_loopback: - $ ./video_loopback --capture_device_index=3 --logs 2>&1 | grep -i \ - capture - - Bug: webrtc:14830 - Change-Id: I35c8e453cf7f9a2923935b0ad82477a3144e8c12 - Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291532 - Commit-Queue: Stefan Holmer - Reviewed-by: Mirko Bonadei - Reviewed-by: Stefan Holmer - Cr-Commit-Position: refs/heads/main@{#39979} - -Differential Revision: https://phabricator.services.mozilla.com/D177232 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/92dc582fdcf3a2fdb3fcdbcd96080d081de8f8d5 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ff886a4d366b4be35b329d1ef733a6df542067c --- - .../video_capture/linux/device_info_v4l2.cc | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) + modules/video_capture/BUILD.gn | 4 ++++ + modules/video_capture/linux/device_info_pipewire.cc | 4 ++-- + modules/video_capture/linux/device_info_pipewire.h | 3 ++- + 3 files changed, 8 insertions(+), 3 deletions(-) -diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc -index 04caaea592..abd2886f85 100644 ---- a/modules/video_capture/linux/device_info_v4l2.cc -+++ b/modules/video_capture/linux/device_info_v4l2.cc -@@ -57,6 +57,24 @@ - #define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) - #endif +diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn +index 8f89918359..45a0272eee 100644 +--- a/modules/video_capture/BUILD.gn ++++ b/modules/video_capture/BUILD.gn +@@ -104,6 +104,10 @@ if (!build_with_chromium || is_linux || is_chromeos) { + "../../media:rtc_media_base", + "../portal", + ] ++ if (build_with_mozilla) { ++ configs -= [ "../portal:pipewire_base" ] ++ public_deps = [ "//third_party/pipewire" ] ++ } + } + } + if (is_win) { +diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc +index e9f7e6a869..fc0554f384 100644 +--- a/modules/video_capture/linux/device_info_pipewire.cc ++++ b/modules/video_capture/linux/device_info_pipewire.cc +@@ -49,9 +49,9 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber, + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8, +- uint32_t productUniqueIdUTF8Length) { ++ uint32_t productUniqueIdUTF8Length, ++ pid_t* pid) { + RTC_CHECK(pipewire_session_); +- + if (deviceNumber >= NumberOfDevices()) + return -1; -+// These defines are here to support building on kernel 3.16 which some -+// downstream projects, e.g. Firefox, use. -+// TODO(apehrson): Remove them and their undefs when no longer needed. -+#ifndef V4L2_PIX_FMT_ABGR32 -+#define ABGR32_OVERRIDE 1 -+#define V4L2_PIX_FMT_ABGR32 v4l2_fourcc('A', 'R', '2', '4') -+#endif -+ -+#ifndef V4L2_PIX_FMT_ARGB32 -+#define ARGB32_OVERRIDE 1 -+#define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') -+#endif -+ -+#ifndef V4L2_PIX_FMT_RGBA32 -+#define RGBA32_OVERRIDE 1 -+#define V4L2_PIX_FMT_RGBA32 v4l2_fourcc('A', 'B', '2', '4') -+#endif -+ - namespace webrtc { - namespace videocapturemodule { - #ifdef WEBRTC_LINUX +diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h +index 4da0c7a90b..8a33d75892 100644 +--- a/modules/video_capture/linux/device_info_pipewire.h ++++ b/modules/video_capture/linux/device_info_pipewire.h +@@ -29,7 +29,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl { + char* deviceUniqueIdUTF8, + uint32_t deviceUniqueIdUTF8Length, + char* productUniqueIdUTF8 = nullptr, +- uint32_t productUniqueIdUTF8Length = 0) override; ++ uint32_t productUniqueIdUTF8Length = 0, ++ pid_t* pid = 0) override; + /* + * Fills the membervariable _captureCapabilities with capabilites for the + * given device name. diff --git a/third_party/libwebrtc/moz-patch-stack/0079.patch b/third_party/libwebrtc/moz-patch-stack/0079.patch index e7b81ca2ba..1e8257408f 100644 --- a/third_party/libwebrtc/moz-patch-stack/0079.patch +++ b/third_party/libwebrtc/moz-patch-stack/0079.patch @@ -1,55 +1,29 @@ -From: Nico Grunbaum -Date: Tue, 6 Jun 2023 16:37:00 -0700 -Subject: Bug 1833237 - (fix-f0be3bee1f) remove reference to - portal:pipewire_base;r?pehrsons +From: Jan-Ivar Bruaroey +Date: Wed, 28 Jun 2023 20:45:00 -0400 +Subject: Bug 1839451 - (fix-0f43da2248) Keep mozilla's + RTCPReceiver::RemoteRTCPSenderInfo function working. -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8ff886a4d366b4be35b329d1ef733a6df542067c +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/154c9cdb386d0f50c5e1549270e1af6ab4969602 --- - modules/video_capture/BUILD.gn | 4 ++++ - modules/video_capture/linux/device_info_pipewire.cc | 3 ++- - modules/video_capture/linux/device_info_pipewire.h | 3 ++- - 3 files changed, 8 insertions(+), 2 deletions(-) + modules/rtp_rtcp/source/rtcp_receiver.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) -diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn -index 8f89918359..45a0272eee 100644 ---- a/modules/video_capture/BUILD.gn -+++ b/modules/video_capture/BUILD.gn -@@ -104,6 +104,10 @@ if (!build_with_chromium || is_linux || is_chromeos) { - "../../media:rtc_media_base", - "../portal", - ] -+ if (build_with_mozilla) { -+ configs -= [ "../portal:pipewire_base" ] -+ public_deps = [ "//third_party/pipewire" ] -+ } - } - } - if (is_win) { -diff --git a/modules/video_capture/linux/device_info_pipewire.cc b/modules/video_capture/linux/device_info_pipewire.cc -index 1dee78f5ee..2cb6161514 100644 ---- a/modules/video_capture/linux/device_info_pipewire.cc -+++ b/modules/video_capture/linux/device_info_pipewire.cc -@@ -47,7 +47,8 @@ int32_t DeviceInfoPipeWire::GetDeviceName(uint32_t deviceNumber, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8, -- uint32_t productUniqueIdUTF8Length) { -+ uint32_t productUniqueIdUTF8Length, -+ pid_t* pid) { - if (deviceNumber >= NumberOfDevices()) - return -1; +diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc +index 94de316421..bda6ad9a52 100644 +--- a/modules/rtp_rtcp/source/rtcp_receiver.cc ++++ b/modules/rtp_rtcp/source/rtcp_receiver.cc +@@ -368,10 +368,10 @@ void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count, + int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const { + MutexLock lock(&rtcp_receiver_lock_); +- *packet_count = remote_sender_packet_count_; +- *octet_count = remote_sender_octet_count_; +- *ntp_timestamp_ms = last_received_sr_ntp_.ToMs(); +- *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs(); ++ *packet_count = remote_sender_.packets_sent; ++ *octet_count = remote_sender_.bytes_sent; ++ *ntp_timestamp_ms = remote_sender_.last_arrival_timestamp.ToMs(); ++ *remote_ntp_timestamp_ms = remote_sender_.last_remote_timestamp.ToMs(); + } -diff --git a/modules/video_capture/linux/device_info_pipewire.h b/modules/video_capture/linux/device_info_pipewire.h -index a006c85d1b..724717be5e 100644 ---- a/modules/video_capture/linux/device_info_pipewire.h -+++ b/modules/video_capture/linux/device_info_pipewire.h -@@ -29,7 +29,8 @@ class DeviceInfoPipeWire : public DeviceInfoImpl { - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8 = nullptr, -- uint32_t productUniqueIdUTF8Length = 0) override; -+ uint32_t productUniqueIdUTF8Length = 0, -+ pid_t* pid = 0) override; - /* - * Fills the membervariable _captureCapabilities with capabilites for the - * given device name. + std::vector RTCPReceiver::GetLatestReportBlockData() const { diff --git a/third_party/libwebrtc/moz-patch-stack/0080.patch b/third_party/libwebrtc/moz-patch-stack/0080.patch index 1e8257408f..25beff2915 100644 --- a/third_party/libwebrtc/moz-patch-stack/0080.patch +++ b/third_party/libwebrtc/moz-patch-stack/0080.patch @@ -1,29 +1,33 @@ -From: Jan-Ivar Bruaroey -Date: Wed, 28 Jun 2023 20:45:00 -0400 -Subject: Bug 1839451 - (fix-0f43da2248) Keep mozilla's - RTCPReceiver::RemoteRTCPSenderInfo function working. +From: Nico Grunbaum +Date: Thu, 22 Jun 2023 16:23:00 +0000 +Subject: Bug 1837918 - libwebrtc update broke the build on + OpenBSD;r=mjf,webrtc-reviewers -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/154c9cdb386d0f50c5e1549270e1af6ab4969602 +Differential Revision: https://phabricator.services.mozilla.com/D181791 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2a6a838b7021bb285f9485c2ceda6ba2543e0d6f --- - modules/rtp_rtcp/source/rtcp_receiver.cc | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) + modules/video_capture/video_capture_options.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) -diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc -index 94de316421..bda6ad9a52 100644 ---- a/modules/rtp_rtcp/source/rtcp_receiver.cc -+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc -@@ -368,10 +368,10 @@ void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count, - int64_t* ntp_timestamp_ms, - int64_t* remote_ntp_timestamp_ms) const { - MutexLock lock(&rtcp_receiver_lock_); -- *packet_count = remote_sender_packet_count_; -- *octet_count = remote_sender_octet_count_; -- *ntp_timestamp_ms = last_received_sr_ntp_.ToMs(); -- *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs(); -+ *packet_count = remote_sender_.packets_sent; -+ *octet_count = remote_sender_.bytes_sent; -+ *ntp_timestamp_ms = remote_sender_.last_arrival_timestamp.ToMs(); -+ *remote_ntp_timestamp_ms = remote_sender_.last_remote_timestamp.ToMs(); - } +diff --git a/modules/video_capture/video_capture_options.h b/modules/video_capture/video_capture_options.h +index 6f72f7927e..37965305d9 100644 +--- a/modules/video_capture/video_capture_options.h ++++ b/modules/video_capture/video_capture_options.h +@@ -55,7 +55,7 @@ class RTC_EXPORT VideoCaptureOptions { - std::vector RTCPReceiver::GetLatestReportBlockData() const { + void Init(Callback* callback); + +-#if defined(WEBRTC_LINUX) ++#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD) + bool allow_v4l2() const { return allow_v4l2_; } + void set_allow_v4l2(bool allow) { allow_v4l2_ = allow; } + #endif +@@ -68,7 +68,7 @@ class RTC_EXPORT VideoCaptureOptions { + #endif + + private: +-#if defined(WEBRTC_LINUX) ++#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD) + bool allow_v4l2_ = false; + #endif + #if defined(WEBRTC_USE_PIPEWIRE) diff --git a/third_party/libwebrtc/moz-patch-stack/0081.patch b/third_party/libwebrtc/moz-patch-stack/0081.patch index 25beff2915..8a60e356af 100644 --- a/third_party/libwebrtc/moz-patch-stack/0081.patch +++ b/third_party/libwebrtc/moz-patch-stack/0081.patch @@ -1,33 +1,24 @@ -From: Nico Grunbaum -Date: Thu, 22 Jun 2023 16:23:00 +0000 -Subject: Bug 1837918 - libwebrtc update broke the build on - OpenBSD;r=mjf,webrtc-reviewers +From: Michael Froman +Date: Wed, 5 Jul 2023 19:15:00 +0000 +Subject: Bug 1841864 - upstream commit 4baea5b07f should properly check size + of encoder_config_.simulcast_layers. r=jib -Differential Revision: https://phabricator.services.mozilla.com/D181791 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2a6a838b7021bb285f9485c2ceda6ba2543e0d6f +Differential Revision: https://phabricator.services.mozilla.com/D182813 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7179d8d75313b6c9c76a496e10d102da019ff4f --- - modules/video_capture/video_capture_options.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) + video/video_stream_encoder.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/modules/video_capture/video_capture_options.h b/modules/video_capture/video_capture_options.h -index 6f72f7927e..37965305d9 100644 ---- a/modules/video_capture/video_capture_options.h -+++ b/modules/video_capture/video_capture_options.h -@@ -55,7 +55,7 @@ class RTC_EXPORT VideoCaptureOptions { +diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc +index 552463e143..669f165635 100644 +--- a/video/video_stream_encoder.cc ++++ b/video/video_stream_encoder.cc +@@ -1375,7 +1375,7 @@ void VideoStreamEncoder::ReconfigureEncoder() { - void Init(Callback* callback); - --#if defined(WEBRTC_LINUX) -+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD) - bool allow_v4l2() const { return allow_v4l2_; } - void set_allow_v4l2(bool allow) { allow_v4l2_ = allow; } - #endif -@@ -68,7 +68,7 @@ class RTC_EXPORT VideoCaptureOptions { - #endif - - private: --#if defined(WEBRTC_LINUX) -+#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD) - bool allow_v4l2_ = false; - #endif - #if defined(WEBRTC_USE_PIPEWIRE) + bool is_svc = false; + bool single_stream_or_non_first_inactive = true; +- for (size_t i = 1; i < encoder_config_.number_of_streams; ++i) { ++ for (size_t i = 1; i < encoder_config_.simulcast_layers.size(); ++i) { + if (encoder_config_.simulcast_layers[i].active) { + single_stream_or_non_first_inactive = false; + break; diff --git a/third_party/libwebrtc/moz-patch-stack/0082.patch b/third_party/libwebrtc/moz-patch-stack/0082.patch index d54ddf9d75..1d9ff301d6 100644 --- a/third_party/libwebrtc/moz-patch-stack/0082.patch +++ b/third_party/libwebrtc/moz-patch-stack/0082.patch @@ -1,24 +1,24 @@ -From: Michael Froman -Date: Wed, 5 Jul 2023 19:15:00 +0000 -Subject: Bug 1841864 - upstream commit 4baea5b07f should properly check size - of encoder_config_.simulcast_layers. r=jib +From: Mike Hommey +Date: Fri, 7 Jul 2023 00:58:00 +0000 +Subject: Bug 1841577 - Don't set WEBRTC_ENABLE_AVX2 on platforms that don't + have AVX2. r=mjf,webrtc-reviewers -Differential Revision: https://phabricator.services.mozilla.com/D182813 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a7179d8d75313b6c9c76a496e10d102da019ff4f +Differential Revision: https://phabricator.services.mozilla.com/D182695 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/46fb51c90709be64c35946a8cf69195121441024 --- - video/video_stream_encoder.cc | 2 +- + webrtc.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc -index 2e5a120eed..c5f086e155 100644 ---- a/video/video_stream_encoder.cc -+++ b/video/video_stream_encoder.cc -@@ -1392,7 +1392,7 @@ void VideoStreamEncoder::ReconfigureEncoder() { +diff --git a/webrtc.gni b/webrtc.gni +index e339ba25fe..e1273475b9 100644 +--- a/webrtc.gni ++++ b/webrtc.gni +@@ -310,7 +310,7 @@ declare_args() { - bool is_svc = false; - bool single_stream_or_non_first_inactive = true; -- for (size_t i = 1; i < encoder_config_.number_of_streams; ++i) { -+ for (size_t i = 1; i < encoder_config_.simulcast_layers.size(); ++i) { - if (encoder_config_.simulcast_layers[i].active) { - single_stream_or_non_first_inactive = false; - break; + # Set this to true to enable the avx2 support in webrtc. + # TODO: Make sure that AVX2 works also for non-clang compilers. +- if (is_clang == true) { ++ if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) { + rtc_enable_avx2 = true + } else { + rtc_enable_avx2 = false diff --git a/third_party/libwebrtc/moz-patch-stack/0083.patch b/third_party/libwebrtc/moz-patch-stack/0083.patch index 6da77ca4ba..181d1439da 100644 --- a/third_party/libwebrtc/moz-patch-stack/0083.patch +++ b/third_party/libwebrtc/moz-patch-stack/0083.patch @@ -1,24 +1,26 @@ -From: Mike Hommey -Date: Fri, 7 Jul 2023 00:58:00 +0000 -Subject: Bug 1841577 - Don't set WEBRTC_ENABLE_AVX2 on platforms that don't - have AVX2. r=mjf,webrtc-reviewers +From: Byron Campen +Date: Thu, 20 Jul 2023 14:24:00 +0000 +Subject: Bug 1838080: Remove this duplicate init (that's also on the wrong + thread). r=pehrsons,webrtc-reviewers -Differential Revision: https://phabricator.services.mozilla.com/D182695 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/46fb51c90709be64c35946a8cf69195121441024 +This was causing assertions. + +Differential Revision: https://phabricator.services.mozilla.com/D179731 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ac6592a04a839a6152d5ad5f0778f63dbbd6b1b --- - webrtc.gni | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + audio/channel_send.cc | 2 -- + 1 file changed, 2 deletions(-) -diff --git a/webrtc.gni b/webrtc.gni -index bacd158140..931a0a24e5 100644 ---- a/webrtc.gni -+++ b/webrtc.gni -@@ -310,7 +310,7 @@ declare_args() { +diff --git a/audio/channel_send.cc b/audio/channel_send.cc +index 8080f4a3b8..61e68d19df 100644 +--- a/audio/channel_send.cc ++++ b/audio/channel_send.cc +@@ -474,8 +474,6 @@ ChannelSend::ChannelSend( + + int error = audio_coding_->RegisterTransportCallback(this); + RTC_DCHECK_EQ(0, error); +- if (frame_transformer) +- InitFrameTransformerDelegate(std::move(frame_transformer)); + } - # Set this to true to enable the avx2 support in webrtc. - # TODO: Make sure that AVX2 works also for non-clang compilers. -- if (is_clang == true) { -+ if (is_clang == true && (target_cpu == "x86" || target_cpu == "x64")) { - rtc_enable_avx2 = true - } else { - rtc_enable_avx2 = false + ChannelSend::~ChannelSend() { diff --git a/third_party/libwebrtc/moz-patch-stack/0084.patch b/third_party/libwebrtc/moz-patch-stack/0084.patch index c2888e89a3..8a565cc5d3 100644 --- a/third_party/libwebrtc/moz-patch-stack/0084.patch +++ b/third_party/libwebrtc/moz-patch-stack/0084.patch @@ -1,26 +1,39 @@ From: Byron Campen Date: Thu, 20 Jul 2023 14:24:00 +0000 -Subject: Bug 1838080: Remove this duplicate init (that's also on the wrong - thread). r=pehrsons,webrtc-reviewers +Subject: Bug 1838080: Work around a race in + ChannelSendFrameTransformerDelegate. r=pehrsons,webrtc-reviewers -This was causing assertions. +This variable can be null when a ChannelSendFrameTransformerDelegate is in use, +because that does an async dispatch to the encoder queue in the handling for +transformed frames. If this is unset while that dispatch is in flight, we +nullptr crash. -Differential Revision: https://phabricator.services.mozilla.com/D179731 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/6ac6592a04a839a6152d5ad5f0778f63dbbd6b1b +Differential Revision: https://phabricator.services.mozilla.com/D180735 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56555ecee7f36ae73abff1cbbd06807c2b65fc19 --- - audio/channel_send.cc | 2 -- - 1 file changed, 2 deletions(-) + audio/channel_send.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/audio/channel_send.cc b/audio/channel_send.cc -index 777cc6d4c1..2b64569fdd 100644 +index 61e68d19df..3c59be52b4 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc -@@ -462,8 +462,6 @@ ChannelSend::ChannelSend( +@@ -286,12 +286,16 @@ class RtpPacketSenderProxy : public RtpPacketSender { + void EnqueuePackets( + std::vector> packets) override { + MutexLock lock(&mutex_); +- rtp_packet_pacer_->EnqueuePackets(std::move(packets)); ++ if (rtp_packet_pacer_) { ++ rtp_packet_pacer_->EnqueuePackets(std::move(packets)); ++ } + } - int error = audio_coding_->RegisterTransportCallback(this); - RTC_DCHECK_EQ(0, error); -- if (frame_transformer) -- InitFrameTransformerDelegate(std::move(frame_transformer)); - } + void RemovePacketsForSsrc(uint32_t ssrc) override { + MutexLock lock(&mutex_); +- rtp_packet_pacer_->RemovePacketsForSsrc(ssrc); ++ if (rtp_packet_pacer_) { ++ rtp_packet_pacer_->RemovePacketsForSsrc(ssrc); ++ } + } - ChannelSend::~ChannelSend() { + private: diff --git a/third_party/libwebrtc/moz-patch-stack/0085.patch b/third_party/libwebrtc/moz-patch-stack/0085.patch index fe0fd9a95c..62d24fdc20 100644 --- a/third_party/libwebrtc/moz-patch-stack/0085.patch +++ b/third_party/libwebrtc/moz-patch-stack/0085.patch @@ -1,39 +1,66 @@ From: Byron Campen Date: Thu, 20 Jul 2023 14:24:00 +0000 -Subject: Bug 1838080: Work around a race in - ChannelSendFrameTransformerDelegate. r=pehrsons,webrtc-reviewers +Subject: Bug 1838080: Use the current TaskQueue, instead of the current + thread, to init this. r=pehrsons,webrtc-reviewers -This variable can be null when a ChannelSendFrameTransformerDelegate is in use, -because that does an async dispatch to the encoder queue in the handling for -transformed frames. If this is unset while that dispatch is in flight, we -nullptr crash. +There are situations where the current thread is not set, but the current +TaskQueue is (but not vice versa). -Differential Revision: https://phabricator.services.mozilla.com/D180735 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56555ecee7f36ae73abff1cbbd06807c2b65fc19 +Differential Revision: https://phabricator.services.mozilla.com/D180736 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/62e71a2f745c4b98d5ee7ce9e6386aa1b657be9b --- - audio/channel_send.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) + .../rtp_video_stream_receiver_frame_transformer_delegate.cc | 3 +-- + .../rtp_video_stream_receiver_frame_transformer_delegate.h | 5 ++--- + video/rtp_video_stream_receiver2.cc | 2 +- + 3 files changed, 4 insertions(+), 6 deletions(-) -diff --git a/audio/channel_send.cc b/audio/channel_send.cc -index 2b64569fdd..ee94760b6f 100644 ---- a/audio/channel_send.cc -+++ b/audio/channel_send.cc -@@ -281,12 +281,16 @@ class RtpPacketSenderProxy : public RtpPacketSender { - void EnqueuePackets( - std::vector> packets) override { - MutexLock lock(&mutex_); -- rtp_packet_pacer_->EnqueuePackets(std::move(packets)); -+ if (rtp_packet_pacer_) { -+ rtp_packet_pacer_->EnqueuePackets(std::move(packets)); -+ } - } +diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc +index fbd10c4c7b..ad3aa86c79 100644 +--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc ++++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc +@@ -96,8 +96,7 @@ RtpVideoStreamReceiverFrameTransformerDelegate:: + RtpVideoFrameReceiver* receiver, + Clock* clock, + rtc::scoped_refptr frame_transformer, +- rtc::Thread* network_thread, +- uint32_t ssrc) ++ TaskQueueBase* network_thread, uint32_t ssrc) + : receiver_(receiver), + frame_transformer_(std::move(frame_transformer)), + network_thread_(network_thread), +diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h +index f08fc692dd..02f2e53923 100644 +--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h ++++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h +@@ -41,8 +41,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate + RtpVideoFrameReceiver* receiver, + Clock* clock, + rtc::scoped_refptr frame_transformer, +- rtc::Thread* network_thread, +- uint32_t ssrc); ++ TaskQueueBase* network_thread, uint32_t ssrc); - void RemovePacketsForSsrc(uint32_t ssrc) override { - MutexLock lock(&mutex_); -- rtp_packet_pacer_->RemovePacketsForSsrc(ssrc); -+ if (rtp_packet_pacer_) { -+ rtp_packet_pacer_->RemovePacketsForSsrc(ssrc); -+ } + void Init(); + void Reset(); +@@ -71,7 +70,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate + RtpVideoFrameReceiver* receiver_ RTC_GUARDED_BY(network_sequence_checker_); + rtc::scoped_refptr frame_transformer_ + RTC_GUARDED_BY(network_sequence_checker_); +- rtc::Thread* const network_thread_; ++ TaskQueueBase* const network_thread_; + const uint32_t ssrc_; + Clock* const clock_; + bool short_circuit_ RTC_GUARDED_BY(network_sequence_checker_) = false; +diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc +index db0b87c736..c4a021d6c0 100644 +--- a/video/rtp_video_stream_receiver2.cc ++++ b/video/rtp_video_stream_receiver2.cc +@@ -341,7 +341,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( + if (frame_transformer) { + frame_transformer_delegate_ = + rtc::make_ref_counted( +- this, clock_, std::move(frame_transformer), rtc::Thread::Current(), ++ this, clock_, std::move(frame_transformer), TaskQueueBase::Current(), + config_.rtp.remote_ssrc); + frame_transformer_delegate_->Init(); } - - private: diff --git a/third_party/libwebrtc/moz-patch-stack/0086.patch b/third_party/libwebrtc/moz-patch-stack/0086.patch index 10657e6049..cb6695d69d 100644 --- a/third_party/libwebrtc/moz-patch-stack/0086.patch +++ b/third_party/libwebrtc/moz-patch-stack/0086.patch @@ -1,66 +1,166 @@ -From: Byron Campen -Date: Thu, 20 Jul 2023 14:24:00 +0000 -Subject: Bug 1838080: Use the current TaskQueue, instead of the current - thread, to init this. r=pehrsons,webrtc-reviewers +From: Michael Froman +Date: Thu, 27 Jul 2023 12:42:44 -0500 +Subject: Bug 1838080: Store the rid in TransformableVideoSenderFrame. + r=ng,webrtc-reviewers -There are situations where the current thread is not set, but the current -TaskQueue is (but not vice versa). +This is necessary to reliably detect what rid a given keyframe is for, for the +purposes of resolving promises from RTCRtpScriptTransformer.generateKeyFrame. -Differential Revision: https://phabricator.services.mozilla.com/D180736 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/62e71a2f745c4b98d5ee7ce9e6386aa1b657be9b +Differential Revision: https://phabricator.services.mozilla.com/D180737 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2f1a0ba74bf71cfa0bc4e77714b8a5276a70cc36 --- - .../rtp_video_stream_receiver_frame_transformer_delegate.cc | 3 +-- - .../rtp_video_stream_receiver_frame_transformer_delegate.h | 5 ++--- - video/rtp_video_stream_receiver2.cc | 2 +- - 3 files changed, 4 insertions(+), 6 deletions(-) + api/frame_transformer_interface.h | 1 + + modules/rtp_rtcp/source/rtp_sender.h | 4 ++++ + modules/rtp_rtcp/source/rtp_sender_video.cc | 1 + + ...rtp_sender_video_frame_transformer_delegate.cc | 15 +++++++++++---- + .../rtp_sender_video_frame_transformer_delegate.h | 2 ++ + ..._stream_receiver_frame_transformer_delegate.cc | 5 +++++ + 6 files changed, 24 insertions(+), 4 deletions(-) -diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc -index ddbd22e34a..6f9aa6ae09 100644 ---- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc -+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc -@@ -95,8 +95,7 @@ RtpVideoStreamReceiverFrameTransformerDelegate:: - RtpVideoFrameReceiver* receiver, - Clock* clock, - rtc::scoped_refptr frame_transformer, -- rtc::Thread* network_thread, -- uint32_t ssrc) -+ TaskQueueBase* network_thread, uint32_t ssrc) - : receiver_(receiver), +diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h +index 5bbcffe28e..afa79b92ea 100644 +--- a/api/frame_transformer_interface.h ++++ b/api/frame_transformer_interface.h +@@ -60,6 +60,7 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface { + public: + virtual ~TransformableVideoFrameInterface() = default; + virtual bool IsKeyFrame() const = 0; ++ virtual const std::string& GetRid() const = 0; + + virtual VideoFrameMetadata Metadata() const = 0; + +diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h +index a398f16d46..8136730e4c 100644 +--- a/modules/rtp_rtcp/source/rtp_sender.h ++++ b/modules/rtp_rtcp/source/rtp_sender.h +@@ -140,6 +140,10 @@ class RTPSender { + + uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; } + ++ const std::string& Rid() const RTC_LOCKS_EXCLUDED(send_mutex_) { ++ return rid_; ++ } ++ + absl::optional FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) { + return flexfec_ssrc_; + } +diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc +index ebca7aaa75..ede8fdc3d6 100644 +--- a/modules/rtp_rtcp/source/rtp_sender_video.cc ++++ b/modules/rtp_rtcp/source/rtp_sender_video.cc +@@ -158,6 +158,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config) + this, + config.frame_transformer, + rtp_sender_->SSRC(), ++ rtp_sender_->Rid(), + config.task_queue_factory) + : nullptr) { + if (frame_transformer_delegate_) +diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc +index 2bb71941f9..ff15840529 100644 +--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc ++++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc +@@ -38,7 +38,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { + uint32_t rtp_timestamp, + TimeDelta expected_retransmission_time, + uint32_t ssrc, +- std::vector csrcs) ++ std::vector csrcs, ++ const std::string& rid) + : encoded_data_(encoded_image.GetEncodedData()), + pre_transform_payload_size_(encoded_image.size()), + header_(video_header), +@@ -50,7 +51,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { + capture_time_identifier_(encoded_image.CaptureTimeIdentifier()), + expected_retransmission_time_(expected_retransmission_time), + ssrc_(ssrc), +- csrcs_(csrcs) { ++ csrcs_(csrcs), ++ rid_(rid) { + RTC_DCHECK_GE(payload_type_, 0); + RTC_DCHECK_LE(payload_type_, 127); + } +@@ -113,6 +115,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { + return mime_type + CodecTypeToPayloadString(*codec_type_); + } + ++ const std::string& GetRid() const override { return rid_; } ++ + private: + rtc::scoped_refptr encoded_data_; + const size_t pre_transform_payload_size_; +@@ -127,6 +131,7 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { + + uint32_t ssrc_; + std::vector csrcs_; ++ const std::string rid_; + }; + } // namespace + +@@ -134,10 +139,12 @@ RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate( + RTPVideoFrameSenderInterface* sender, + rtc::scoped_refptr frame_transformer, + uint32_t ssrc, ++ const std::string& rid, + TaskQueueFactory* task_queue_factory) + : sender_(sender), frame_transformer_(std::move(frame_transformer)), - network_thread_(network_thread), -diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h -index 62a42fdddf..20f9a5caa9 100644 ---- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h -+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h -@@ -41,8 +41,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate - RtpVideoFrameReceiver* receiver, - Clock* clock, + ssrc_(ssrc), ++ rid_(rid), + transformation_queue_(task_queue_factory->CreateTaskQueue( + "video_frame_transformer", + TaskQueueFactory::Priority::NORMAL)) {} +@@ -168,7 +175,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame( + frame_transformer_->Transform(std::make_unique( + encoded_image, video_header, payload_type, codec_type, rtp_timestamp, + expected_retransmission_time, ssrc_, +- /*csrcs=*/std::vector())); ++ /*csrcs=*/std::vector(), rid_)); + return true; + } + +@@ -270,7 +277,7 @@ std::unique_ptr CloneSenderVideoFrame( + return std::make_unique( + encoded_image, new_header, original->GetPayloadType(), new_header.codec, + original->GetTimestamp(), kDefaultRetransmissionsTime, +- original->GetSsrc(), metadata.GetCsrcs()); ++ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid()); + } + + } // namespace webrtc +diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h +index 243f22ca9f..1f70a23ccc 100644 +--- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h ++++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h +@@ -58,6 +58,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback { + RTPVideoFrameSenderInterface* sender, rtc::scoped_refptr frame_transformer, -- rtc::Thread* network_thread, -- uint32_t ssrc); -+ TaskQueueBase* network_thread, uint32_t ssrc); + uint32_t ssrc, ++ const std::string& rid, + TaskQueueFactory* send_transport_queue); void Init(); - void Reset(); -@@ -67,7 +66,7 @@ class RtpVideoStreamReceiverFrameTransformerDelegate - RtpVideoFrameReceiver* receiver_ RTC_GUARDED_BY(network_sequence_checker_); - rtc::scoped_refptr frame_transformer_ - RTC_GUARDED_BY(network_sequence_checker_); -- rtc::Thread* const network_thread_; -+ TaskQueueBase* const network_thread_; +@@ -106,6 +107,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback { + RTPVideoFrameSenderInterface* sender_ RTC_GUARDED_BY(sender_lock_); + rtc::scoped_refptr frame_transformer_; const uint32_t ssrc_; - Clock* const clock_; - }; -diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc -index db0b87c736..c4a021d6c0 100644 ---- a/video/rtp_video_stream_receiver2.cc -+++ b/video/rtp_video_stream_receiver2.cc -@@ -341,7 +341,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( - if (frame_transformer) { - frame_transformer_delegate_ = - rtc::make_ref_counted( -- this, clock_, std::move(frame_transformer), rtc::Thread::Current(), -+ this, clock_, std::move(frame_transformer), TaskQueueBase::Current(), - config_.rtp.remote_ssrc); - frame_transformer_delegate_->Init(); ++ const std::string rid_; + // Used when the encoded frames arrives without a current task queue. This can + // happen if a hardware encoder was used. + std::unique_ptr transformation_queue_; +diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc +index ad3aa86c79..7af945c623 100644 +--- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc ++++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc +@@ -58,6 +58,11 @@ class TransformableVideoReceiverFrame + return frame_->FrameType() == VideoFrameType::kVideoFrameKey; } + ++ const std::string& GetRid() const override { ++ static const std::string empty; ++ return empty; ++ } ++ + VideoFrameMetadata Metadata() const override { return metadata_; } + + void SetMetadata(const VideoFrameMetadata& metadata) override { diff --git a/third_party/libwebrtc/moz-patch-stack/0087.patch b/third_party/libwebrtc/moz-patch-stack/0087.patch index 241fb871b6..d6aca49a9b 100644 --- a/third_party/libwebrtc/moz-patch-stack/0087.patch +++ b/third_party/libwebrtc/moz-patch-stack/0087.patch @@ -1,166 +1,38 @@ -From: Michael Froman -Date: Thu, 27 Jul 2023 12:42:44 -0500 -Subject: Bug 1838080: Store the rid in TransformableVideoSenderFrame. - r=ng,webrtc-reviewers +From: Byron Campen +Date: Thu, 20 Jul 2023 14:24:00 +0000 +Subject: Bug 1838080: Ensure that last ref to transformation_queue_ is not + released on itself. r=pehrsons,webrtc-reviewers -This is necessary to reliably detect what rid a given keyframe is for, for the -purposes of resolving promises from RTCRtpScriptTransformer.generateKeyFrame. - -Differential Revision: https://phabricator.services.mozilla.com/D180737 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/2f1a0ba74bf71cfa0bc4e77714b8a5276a70cc36 +Differential Revision: https://phabricator.services.mozilla.com/D181699 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91d9e8b6a5c430a73561ffd2330865f04fcb1a6d --- - api/frame_transformer_interface.h | 1 + - modules/rtp_rtcp/source/rtp_sender.h | 4 ++++ - modules/rtp_rtcp/source/rtp_sender_video.cc | 1 + - ...rtp_sender_video_frame_transformer_delegate.cc | 15 +++++++++++---- - .../rtp_sender_video_frame_transformer_delegate.h | 2 ++ - ..._stream_receiver_frame_transformer_delegate.cc | 5 +++++ - 6 files changed, 24 insertions(+), 4 deletions(-) + .../rtp_sender_video_frame_transformer_delegate.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) -diff --git a/api/frame_transformer_interface.h b/api/frame_transformer_interface.h -index 9024988db6..d1ea15a54e 100644 ---- a/api/frame_transformer_interface.h -+++ b/api/frame_transformer_interface.h -@@ -65,6 +65,7 @@ class TransformableVideoFrameInterface : public TransformableFrameInterface { - public: - virtual ~TransformableVideoFrameInterface() = default; - virtual bool IsKeyFrame() const = 0; -+ virtual const std::string& GetRid() const = 0; - - virtual VideoFrameMetadata Metadata() const = 0; - -diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h -index a398f16d46..8136730e4c 100644 ---- a/modules/rtp_rtcp/source/rtp_sender.h -+++ b/modules/rtp_rtcp/source/rtp_sender.h -@@ -140,6 +140,10 @@ class RTPSender { - - uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; } - -+ const std::string& Rid() const RTC_LOCKS_EXCLUDED(send_mutex_) { -+ return rid_; -+ } -+ - absl::optional FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) { - return flexfec_ssrc_; - } -diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc -index ebca7aaa75..ede8fdc3d6 100644 ---- a/modules/rtp_rtcp/source/rtp_sender_video.cc -+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc -@@ -158,6 +158,7 @@ RTPSenderVideo::RTPSenderVideo(const Config& config) - this, - config.frame_transformer, - rtp_sender_->SSRC(), -+ rtp_sender_->Rid(), - config.task_queue_factory) - : nullptr) { - if (frame_transformer_delegate_) diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc -index d255ef4aa9..f24c91ae35 100644 +index ff15840529..ae9eb6b4bd 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc -@@ -31,7 +31,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { - uint32_t rtp_timestamp, - TimeDelta expected_retransmission_time, - uint32_t ssrc, -- std::vector csrcs) -+ std::vector csrcs, -+ const std::string& rid) - : encoded_data_(encoded_image.GetEncodedData()), - pre_transform_payload_size_(encoded_image.size()), - header_(video_header), -@@ -43,7 +44,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { - capture_time_identifier_(encoded_image.CaptureTimeIdentifier()), - expected_retransmission_time_(expected_retransmission_time), - ssrc_(ssrc), -- csrcs_(csrcs) { -+ csrcs_(csrcs), -+ rid_(rid) { - RTC_DCHECK_GE(payload_type_, 0); - RTC_DCHECK_LE(payload_type_, 127); +@@ -18,6 +18,7 @@ + #include "api/task_queue/task_queue_factory.h" + #include "modules/rtp_rtcp/source/rtp_descriptor_authentication.h" + #include "rtc_base/checks.h" ++#include "rtc_base/event.h" + #include "rtc_base/logging.h" + + namespace webrtc { +@@ -257,6 +258,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() { + MutexLock lock(&sender_lock_); + sender_ = nullptr; } -@@ -106,6 +108,8 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { - return mime_type + CodecTypeToPayloadString(*codec_type_); - } - -+ const std::string& GetRid() const override { return rid_; } -+ - private: - rtc::scoped_refptr encoded_data_; - const size_t pre_transform_payload_size_; -@@ -120,6 +124,7 @@ class TransformableVideoSenderFrame : public TransformableVideoFrameInterface { - - uint32_t ssrc_; - std::vector csrcs_; -+ const std::string rid_; - }; - } // namespace - -@@ -127,10 +132,12 @@ RTPSenderVideoFrameTransformerDelegate::RTPSenderVideoFrameTransformerDelegate( - RTPVideoFrameSenderInterface* sender, - rtc::scoped_refptr frame_transformer, - uint32_t ssrc, -+ const std::string& rid, - TaskQueueFactory* task_queue_factory) - : sender_(sender), - frame_transformer_(std::move(frame_transformer)), - ssrc_(ssrc), -+ rid_(rid), - transformation_queue_(task_queue_factory->CreateTaskQueue( - "video_frame_transformer", - TaskQueueFactory::Priority::NORMAL)) {} -@@ -150,7 +157,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame( - frame_transformer_->Transform(std::make_unique( - encoded_image, video_header, payload_type, codec_type, rtp_timestamp, - expected_retransmission_time, ssrc_, -- /*csrcs=*/std::vector())); -+ /*csrcs=*/std::vector(), rid_)); - return true; - } - -@@ -244,7 +251,7 @@ std::unique_ptr CloneSenderVideoFrame( - encoded_image, new_header, original->GetPayloadType(), new_header.codec, - original->GetTimestamp(), - /*expected_retransmission_time=*/TimeDelta::PlusInfinity(), -- original->GetSsrc(), metadata.GetCsrcs()); -+ original->GetSsrc(), metadata.GetCsrcs(), original->GetRid()); ++ // Wait until all pending tasks are executed, to ensure that the last ref ++ // standing is not on the transformation queue. ++ rtc::Event flush; ++ transformation_queue_->PostTask([this, &flush]() { ++ RTC_DCHECK_RUN_ON(transformation_queue_.get()); ++ flush.Set(); ++ }); ++ flush.Wait(rtc::Event::kForever); } - } // namespace webrtc -diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h -index a333db235a..3379ead364 100644 ---- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h -+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h -@@ -58,6 +58,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback { - RTPVideoFrameSenderInterface* sender, - rtc::scoped_refptr frame_transformer, - uint32_t ssrc, -+ const std::string& rid, - TaskQueueFactory* send_transport_queue); - - void Init(); -@@ -104,6 +105,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback { - RTPVideoFrameSenderInterface* sender_ RTC_GUARDED_BY(sender_lock_); - rtc::scoped_refptr frame_transformer_; - const uint32_t ssrc_; -+ const std::string rid_; - // Used when the encoded frames arrives without a current task queue. This can - // happen if a hardware encoder was used. - std::unique_ptr transformation_queue_; -diff --git a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc -index 6f9aa6ae09..94c9249e16 100644 ---- a/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc -+++ b/modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc -@@ -57,6 +57,11 @@ class TransformableVideoReceiverFrame - return frame_->FrameType() == VideoFrameType::kVideoFrameKey; - } - -+ const std::string& GetRid() const override { -+ static const std::string empty; -+ return empty; -+ } -+ - VideoFrameMetadata Metadata() const override { return metadata_; } - - void SetMetadata(const VideoFrameMetadata& metadata) override { + std::unique_ptr CloneSenderVideoFrame( diff --git a/third_party/libwebrtc/moz-patch-stack/0088.patch b/third_party/libwebrtc/moz-patch-stack/0088.patch index d969596186..1a2541f93f 100644 --- a/third_party/libwebrtc/moz-patch-stack/0088.patch +++ b/third_party/libwebrtc/moz-patch-stack/0088.patch @@ -1,38 +1,38 @@ -From: Byron Campen -Date: Thu, 20 Jul 2023 14:24:00 +0000 -Subject: Bug 1838080: Ensure that last ref to transformation_queue_ is not - released on itself. r=pehrsons,webrtc-reviewers +From: stransky +Date: Tue, 29 Aug 2023 12:43:00 +0000 +Subject: Bug 1821629 [DMABuf] Don't use DMABuf if it's disabled by Firefox gfx + config r=ng,webrtc-reviewers -Differential Revision: https://phabricator.services.mozilla.com/D181699 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/91d9e8b6a5c430a73561ffd2330865f04fcb1a6d +Differential Revision: https://phabricator.services.mozilla.com/D172224 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/158a888cad8869a2f0026fa7cfaaa13ecbfcf2ed --- - .../rtp_sender_video_frame_transformer_delegate.cc | 9 +++++++++ - 1 file changed, 9 insertions(+) + .../linux/wayland/shared_screencast_stream.cc | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) -diff --git a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc -index f24c91ae35..9d7c58d19a 100644 ---- a/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc -+++ b/modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.cc -@@ -18,6 +18,7 @@ - #include "api/task_queue/task_queue_factory.h" - #include "modules/rtp_rtcp/source/rtp_descriptor_authentication.h" - #include "rtc_base/checks.h" -+#include "rtc_base/event.h" +diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +index 0c26e7a7d5..22aa355e44 100644 +--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc ++++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +@@ -28,6 +28,13 @@ + #include "rtc_base/synchronization/mutex.h" + #include "rtc_base/time_utils.h" ++// Wrapper for gfxVars::UseDMABuf() as we can't include gfxVars here. ++// We don't want to use dmabuf of known broken systems. ++// See FEATURE_DMABUF for details. ++namespace mozilla::gfx { ++bool IsDMABufEnabled(); ++} ++ namespace webrtc { - namespace { -@@ -232,6 +233,14 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() { - MutexLock lock(&sender_lock_); - sender_ = nullptr; - } -+ // Wait until all pending tasks are executed, to ensure that the last ref -+ // standing is not on the transformation queue. -+ rtc::Event flush; -+ transformation_queue_->PostTask([this, &flush]() { -+ RTC_DCHECK_RUN_ON(transformation_queue_.get()); -+ flush.Set(); -+ }); -+ flush.Wait(rtc::Event::kForever); - } - std::unique_ptr CloneSenderVideoFrame( + const int kBytesPerPixel = 4; +@@ -294,7 +301,7 @@ void SharedScreenCastStreamPrivate::OnStreamParamChanged( + that->modifier_ = + has_modifier ? that->spa_video_format_.modifier : DRM_FORMAT_MOD_INVALID; + std::vector params; +- const int buffer_types = has_modifier ++ const int buffer_types = has_modifier && mozilla::gfx::IsDMABufEnabled() + ? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd) + : (1 << SPA_DATA_MemFd); + diff --git a/third_party/libwebrtc/moz-patch-stack/0089.patch b/third_party/libwebrtc/moz-patch-stack/0089.patch index 1a2541f93f..dfd2faa87d 100644 --- a/third_party/libwebrtc/moz-patch-stack/0089.patch +++ b/third_party/libwebrtc/moz-patch-stack/0089.patch @@ -1,38 +1,47 @@ From: stransky Date: Tue, 29 Aug 2023 12:43:00 +0000 -Subject: Bug 1821629 [DMABuf] Don't use DMABuf if it's disabled by Firefox gfx - config r=ng,webrtc-reviewers +Subject: Bug 1821629 [Pipewire/DMABuf] Don't create dmabuf backend if it's + disabled r=ng,webrtc-reviewers -Differential Revision: https://phabricator.services.mozilla.com/D172224 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/158a888cad8869a2f0026fa7cfaaa13ecbfcf2ed +Depends on D172224 + +Differential Revision: https://phabricator.services.mozilla.com/D172229 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/237d19fe96dd7d25b6a817415ee4e6854678d648 --- - .../linux/wayland/shared_screencast_stream.cc | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) + .../linux/wayland/shared_screencast_stream.cc | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc -index 0c26e7a7d5..22aa355e44 100644 +index 22aa355e44..61c6957d27 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc -@@ -28,6 +28,13 @@ - #include "rtc_base/synchronization/mutex.h" - #include "rtc_base/time_utils.h" +@@ -419,7 +419,9 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( + RTC_LOG(LS_ERROR) << "Unable to open PipeWire library"; + return false; + } +- egl_dmabuf_ = std::make_unique(); ++ if (mozilla::gfx::IsDMABufEnabled()) { ++ egl_dmabuf_ = std::make_unique(); ++ } + + pw_stream_node_id_ = stream_node_id; + +@@ -508,7 +510,8 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( + for (uint32_t format : {SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGBA, + SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx}) { + // Modifiers can be used with PipeWire >= 0.3.33 +- if (has_required_pw_client_version && has_required_pw_server_version) { ++ if (egl_dmabuf_ && ++ has_required_pw_client_version && has_required_pw_server_version) { + modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format); + + if (!modifiers_.empty()) { +@@ -927,7 +930,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer( -+// Wrapper for gfxVars::UseDMABuf() as we can't include gfxVars here. -+// We don't want to use dmabuf of known broken systems. -+// See FEATURE_DMABUF for details. -+namespace mozilla::gfx { -+bool IsDMABufEnabled(); -+} -+ - namespace webrtc { + const uint n_planes = spa_buffer->n_datas; - const int kBytesPerPixel = 4; -@@ -294,7 +301,7 @@ void SharedScreenCastStreamPrivate::OnStreamParamChanged( - that->modifier_ = - has_modifier ? that->spa_video_format_.modifier : DRM_FORMAT_MOD_INVALID; - std::vector params; -- const int buffer_types = has_modifier -+ const int buffer_types = has_modifier && mozilla::gfx::IsDMABufEnabled() - ? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd) - : (1 << SPA_DATA_MemFd); +- if (!n_planes) { ++ if (!n_planes || !egl_dmabuf_) { + return false; + } diff --git a/third_party/libwebrtc/moz-patch-stack/0090.patch b/third_party/libwebrtc/moz-patch-stack/0090.patch index dfd2faa87d..b38361e516 100644 --- a/third_party/libwebrtc/moz-patch-stack/0090.patch +++ b/third_party/libwebrtc/moz-patch-stack/0090.patch @@ -1,47 +1,56 @@ -From: stransky -Date: Tue, 29 Aug 2023 12:43:00 +0000 -Subject: Bug 1821629 [Pipewire/DMABuf] Don't create dmabuf backend if it's - disabled r=ng,webrtc-reviewers +From: Michael Froman +Date: Thu, 28 Sep 2023 14:12:00 +0000 +Subject: Bug 1832465 - remove libXtst usage from libwebrtc. + r=ng,webrtc-reviewers -Depends on D172224 - -Differential Revision: https://phabricator.services.mozilla.com/D172229 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/237d19fe96dd7d25b6a817415ee4e6854678d648 +Differential Revision: https://phabricator.services.mozilla.com/D189386 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0ec1b33b95dbb2d39355f28b2812fe25b4ad9f20 --- - .../linux/wayland/shared_screencast_stream.cc | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) + modules/desktop_capture/BUILD.gn | 3 +++ + modules/desktop_capture/linux/x11/shared_x_display.cc | 4 ++++ + 2 files changed, 7 insertions(+) -diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc -index 22aa355e44..61c6957d27 100644 ---- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc -+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc -@@ -419,7 +419,9 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( - RTC_LOG(LS_ERROR) << "Unable to open PipeWire library"; - return false; +diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn +index dcc1b3c6ac..0634e0e9c4 100644 +--- a/modules/desktop_capture/BUILD.gn ++++ b/modules/desktop_capture/BUILD.gn +@@ -384,6 +384,9 @@ rtc_library("desktop_capture") { + "Xrandr", + "Xtst", + ] ++ if (build_with_mozilla) { ++ libs -= [ "Xtst" ] ++ } } -- egl_dmabuf_ = std::make_unique(); -+ if (mozilla::gfx::IsDMABufEnabled()) { -+ egl_dmabuf_ = std::make_unique(); -+ } - pw_stream_node_id_ = stream_node_id; + if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire && +diff --git a/modules/desktop_capture/linux/x11/shared_x_display.cc b/modules/desktop_capture/linux/x11/shared_x_display.cc +index d690b0e2ba..3f3617b074 100644 +--- a/modules/desktop_capture/linux/x11/shared_x_display.cc ++++ b/modules/desktop_capture/linux/x11/shared_x_display.cc +@@ -11,7 +11,9 @@ + #include "modules/desktop_capture/linux/x11/shared_x_display.h" -@@ -508,7 +510,8 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( - for (uint32_t format : {SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGBA, - SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx}) { - // Modifiers can be used with PipeWire >= 0.3.33 -- if (has_required_pw_client_version && has_required_pw_server_version) { -+ if (egl_dmabuf_ && -+ has_required_pw_client_version && has_required_pw_server_version) { - modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format); + #include ++#if !defined(WEBRTC_MOZILLA_BUILD) + #include ++#endif - if (!modifiers_.empty()) { -@@ -927,7 +930,7 @@ bool SharedScreenCastStreamPrivate::ProcessDMABuffer( + #include - const uint n_planes = spa_buffer->n_datas; +@@ -95,6 +97,7 @@ void SharedXDisplay::ProcessPendingXEvents() { + } -- if (!n_planes) { -+ if (!n_planes || !egl_dmabuf_) { - return false; + void SharedXDisplay::IgnoreXServerGrabs() { ++#if !defined(WEBRTC_MOZILLA_BUILD) + int test_event_base = 0; + int test_error_base = 0; + int major = 0; +@@ -103,6 +106,7 @@ void SharedXDisplay::IgnoreXServerGrabs() { + &minor)) { + XTestGrabControl(display(), true); } ++#endif + } + } // namespace webrtc diff --git a/third_party/libwebrtc/moz-patch-stack/0091.patch b/third_party/libwebrtc/moz-patch-stack/0091.patch index b38361e516..51b0c620b0 100644 --- a/third_party/libwebrtc/moz-patch-stack/0091.patch +++ b/third_party/libwebrtc/moz-patch-stack/0091.patch @@ -1,56 +1,91 @@ -From: Michael Froman -Date: Thu, 28 Sep 2023 14:12:00 +0000 -Subject: Bug 1832465 - remove libXtst usage from libwebrtc. - r=ng,webrtc-reviewers +From: Dan Baker +Date: Mon, 2 Oct 2023 17:17:00 +0000 +Subject: Bug 1851693 - (fix-279a05475d) Revert addition of race checker which + is causing tsan failurs until better fix is landed upstream.r=pehrsons -Differential Revision: https://phabricator.services.mozilla.com/D189386 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/0ec1b33b95dbb2d39355f28b2812fe25b4ad9f20 +This merely reverses a race checker that is too strict for our use, maintaining the code we had before, so we can fix upstream in the meantime tracked with Bug 1856392. + +Differential Revision: https://phabricator.services.mozilla.com/D189396 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e626ce7279e6575e68d0e43de3dfd3ed59b00a75 --- - modules/desktop_capture/BUILD.gn | 3 +++ - modules/desktop_capture/linux/x11/shared_x_display.cc | 4 ++++ - 2 files changed, 7 insertions(+) + modules/video_capture/linux/video_capture_v4l2.cc | 7 ------- + modules/video_capture/linux/video_capture_v4l2.h | 7 +++---- + 2 files changed, 3 insertions(+), 11 deletions(-) -diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn -index dcc1b3c6ac..0634e0e9c4 100644 ---- a/modules/desktop_capture/BUILD.gn -+++ b/modules/desktop_capture/BUILD.gn -@@ -384,6 +384,9 @@ rtc_library("desktop_capture") { - "Xrandr", - "Xtst", - ] -+ if (build_with_mozilla) { -+ libs -= [ "Xtst" ] -+ } +diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc +index 97cd9a70eb..08d23f7f58 100644 +--- a/modules/video_capture/linux/video_capture_v4l2.cc ++++ b/modules/video_capture/linux/video_capture_v4l2.cc +@@ -110,7 +110,6 @@ int32_t VideoCaptureModuleV4L2::Init(const char* deviceUniqueIdUTF8) { + + VideoCaptureModuleV4L2::~VideoCaptureModuleV4L2() { + RTC_DCHECK_RUN_ON(&api_checker_); +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + + StopCapture(); + if (_deviceFd != -1) +@@ -120,7 +119,6 @@ VideoCaptureModuleV4L2::~VideoCaptureModuleV4L2() { + int32_t VideoCaptureModuleV4L2::StartCapture( + const VideoCaptureCapability& capability) { + RTC_DCHECK_RUN_ON(&api_checker_); +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + + if (_captureStarted) { + if (capability == _requestedCapability) { +@@ -318,7 +316,6 @@ int32_t VideoCaptureModuleV4L2::StopCapture() { + _captureThread.Finalize(); } - if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire && -diff --git a/modules/desktop_capture/linux/x11/shared_x_display.cc b/modules/desktop_capture/linux/x11/shared_x_display.cc -index d690b0e2ba..3f3617b074 100644 ---- a/modules/desktop_capture/linux/x11/shared_x_display.cc -+++ b/modules/desktop_capture/linux/x11/shared_x_display.cc -@@ -11,7 +11,9 @@ - #include "modules/desktop_capture/linux/x11/shared_x_display.h" +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + MutexLock lock(&capture_lock_); + if (_captureStarted) { + _captureStarted = false; +@@ -336,7 +333,6 @@ int32_t VideoCaptureModuleV4L2::StopCapture() { + // critical section protected by the caller - #include -+#if !defined(WEBRTC_MOZILLA_BUILD) - #include -+#endif + bool VideoCaptureModuleV4L2::AllocateVideoBuffers() { +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + struct v4l2_requestbuffers rbuffer; + memset(&rbuffer, 0, sizeof(v4l2_requestbuffers)); - #include +@@ -387,7 +383,6 @@ bool VideoCaptureModuleV4L2::AllocateVideoBuffers() { + } -@@ -95,6 +97,7 @@ void SharedXDisplay::ProcessPendingXEvents() { + bool VideoCaptureModuleV4L2::DeAllocateVideoBuffers() { +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + // unmap buffers + for (int i = 0; i < _buffersAllocatedByDevice; i++) + munmap(_pool[i].start, _pool[i].length); +@@ -405,12 +400,10 @@ bool VideoCaptureModuleV4L2::DeAllocateVideoBuffers() { } - void SharedXDisplay::IgnoreXServerGrabs() { -+#if !defined(WEBRTC_MOZILLA_BUILD) - int test_event_base = 0; - int test_error_base = 0; - int major = 0; -@@ -103,6 +106,7 @@ void SharedXDisplay::IgnoreXServerGrabs() { - &minor)) { - XTestGrabControl(display(), true); - } -+#endif + bool VideoCaptureModuleV4L2::CaptureStarted() { +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + return _captureStarted; } - } // namespace webrtc + bool VideoCaptureModuleV4L2::CaptureProcess() { +- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); + + int retVal = 0; + struct pollfd rSet; +diff --git a/modules/video_capture/linux/video_capture_v4l2.h b/modules/video_capture/linux/video_capture_v4l2.h +index 0191e41876..61358d0325 100644 +--- a/modules/video_capture/linux/video_capture_v4l2.h ++++ b/modules/video_capture/linux/video_capture_v4l2.h +@@ -45,12 +45,11 @@ class VideoCaptureModuleV4L2 : public VideoCaptureImpl { + Mutex capture_lock_ RTC_ACQUIRED_BEFORE(api_lock_); + bool quit_ RTC_GUARDED_BY(capture_lock_); + int32_t _deviceId RTC_GUARDED_BY(api_checker_); +- int32_t _deviceFd RTC_GUARDED_BY(capture_checker_); ++ int32_t _deviceFd; + + int32_t _buffersAllocatedByDevice RTC_GUARDED_BY(capture_lock_); +- VideoCaptureCapability configured_capability_ +- RTC_GUARDED_BY(capture_checker_); +- bool _captureStarted RTC_GUARDED_BY(capture_checker_); ++ VideoCaptureCapability configured_capability_; ++ bool _captureStarted; + struct Buffer { + void* start; + size_t length; diff --git a/third_party/libwebrtc/moz-patch-stack/0092.patch b/third_party/libwebrtc/moz-patch-stack/0092.patch index 6160d6eecb..3fcbcd0f94 100644 --- a/third_party/libwebrtc/moz-patch-stack/0092.patch +++ b/third_party/libwebrtc/moz-patch-stack/0092.patch @@ -1,91 +1,30 @@ -From: Dan Baker -Date: Mon, 2 Oct 2023 17:17:00 +0000 -Subject: Bug 1851693 - (fix-279a05475d) Revert addition of race checker which - is causing tsan failurs until better fix is landed upstream.r=pehrsons +From: Michael Froman +Date: Thu, 5 Oct 2023 14:21:00 +0000 +Subject: Bug 1857037 - pt1 - add shim gni files to limit BUILD.gn changes. + r=ng,webrtc-reviewers -This merely reverses a race checker that is too strict for our use, maintaining the code we had before, so we can fix upstream in the meantime tracked with Bug 1856392. - -Differential Revision: https://phabricator.services.mozilla.com/D189396 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/e626ce7279e6575e68d0e43de3dfd3ed59b00a75 +Differential Revision: https://phabricator.services.mozilla.com/D190104 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a84d39db037cbe34aa19588b0d18335eb5e2d79b --- - modules/video_capture/linux/video_capture_v4l2.cc | 7 ------- - modules/video_capture/linux/video_capture_v4l2.h | 7 +++---- - 2 files changed, 3 insertions(+), 11 deletions(-) + testing/libfuzzer/fuzzer_test.gni | 2 ++ + testing/test.gni | 2 ++ + 2 files changed, 4 insertions(+) + create mode 100644 testing/libfuzzer/fuzzer_test.gni + create mode 100644 testing/test.gni -diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc -index d6813b13fd..c887683dc8 100644 ---- a/modules/video_capture/linux/video_capture_v4l2.cc -+++ b/modules/video_capture/linux/video_capture_v4l2.cc -@@ -110,7 +110,6 @@ int32_t VideoCaptureModuleV4L2::Init(const char* deviceUniqueIdUTF8) { - - VideoCaptureModuleV4L2::~VideoCaptureModuleV4L2() { - RTC_DCHECK_RUN_ON(&api_checker_); -- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); - - StopCapture(); - if (_deviceFd != -1) -@@ -120,7 +119,6 @@ VideoCaptureModuleV4L2::~VideoCaptureModuleV4L2() { - int32_t VideoCaptureModuleV4L2::StartCapture( - const VideoCaptureCapability& capability) { - RTC_DCHECK_RUN_ON(&api_checker_); -- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); - - if (_captureStarted) { - if (capability == _requestedCapability) { -@@ -318,7 +316,6 @@ int32_t VideoCaptureModuleV4L2::StopCapture() { - _captureThread.Finalize(); - } - -- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); - MutexLock lock(&capture_lock_); - if (_captureStarted) { - _captureStarted = false; -@@ -336,7 +333,6 @@ int32_t VideoCaptureModuleV4L2::StopCapture() { - // critical section protected by the caller - - bool VideoCaptureModuleV4L2::AllocateVideoBuffers() { -- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); - struct v4l2_requestbuffers rbuffer; - memset(&rbuffer, 0, sizeof(v4l2_requestbuffers)); - -@@ -387,7 +383,6 @@ bool VideoCaptureModuleV4L2::AllocateVideoBuffers() { - } - - bool VideoCaptureModuleV4L2::DeAllocateVideoBuffers() { -- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); - // unmap buffers - for (int i = 0; i < _buffersAllocatedByDevice; i++) - munmap(_pool[i].start, _pool[i].length); -@@ -405,12 +400,10 @@ bool VideoCaptureModuleV4L2::DeAllocateVideoBuffers() { - } - - bool VideoCaptureModuleV4L2::CaptureStarted() { -- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); - return _captureStarted; - } - - bool VideoCaptureModuleV4L2::CaptureProcess() { -- RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); - - int retVal = 0; - struct pollfd rSet; -diff --git a/modules/video_capture/linux/video_capture_v4l2.h b/modules/video_capture/linux/video_capture_v4l2.h -index 0191e41876..61358d0325 100644 ---- a/modules/video_capture/linux/video_capture_v4l2.h -+++ b/modules/video_capture/linux/video_capture_v4l2.h -@@ -45,12 +45,11 @@ class VideoCaptureModuleV4L2 : public VideoCaptureImpl { - Mutex capture_lock_ RTC_ACQUIRED_BEFORE(api_lock_); - bool quit_ RTC_GUARDED_BY(capture_lock_); - int32_t _deviceId RTC_GUARDED_BY(api_checker_); -- int32_t _deviceFd RTC_GUARDED_BY(capture_checker_); -+ int32_t _deviceFd; - - int32_t _buffersAllocatedByDevice RTC_GUARDED_BY(capture_lock_); -- VideoCaptureCapability configured_capability_ -- RTC_GUARDED_BY(capture_checker_); -- bool _captureStarted RTC_GUARDED_BY(capture_checker_); -+ VideoCaptureCapability configured_capability_; -+ bool _captureStarted; - struct Buffer { - void* start; - size_t length; +diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni +new file mode 100644 +index 0000000000..8fdf3cdad2 +--- /dev/null ++++ b/testing/libfuzzer/fuzzer_test.gni +@@ -0,0 +1,2 @@ ++# "empty" file in place of importing new testing/libfuzzer ++# to allow BUILD.gn imports to succeed. +diff --git a/testing/test.gni b/testing/test.gni +new file mode 100644 +index 0000000000..f46fa82778 +--- /dev/null ++++ b/testing/test.gni +@@ -0,0 +1,2 @@ ++# "empty" file in place of importing new testing/test.gni ++# to allow BUILD.gn imports to succeed. diff --git a/third_party/libwebrtc/moz-patch-stack/0093.patch b/third_party/libwebrtc/moz-patch-stack/0093.patch index 3fcbcd0f94..b0cdd2d540 100644 --- a/third_party/libwebrtc/moz-patch-stack/0093.patch +++ b/third_party/libwebrtc/moz-patch-stack/0093.patch @@ -1,30 +1,40 @@ From: Michael Froman -Date: Thu, 5 Oct 2023 14:21:00 +0000 -Subject: Bug 1857037 - pt1 - add shim gni files to limit BUILD.gn changes. - r=ng,webrtc-reviewers +Date: Tue, 14 Feb 2023 03:27:00 +0000 +Subject: Bug 1816173 - pt12 - add shim config for + third_party/libwebrtc/testing/{gmock|gtest} r=ng -Differential Revision: https://phabricator.services.mozilla.com/D190104 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/a84d39db037cbe34aa19588b0d18335eb5e2d79b +We don't vendor third_party/libwebrtc/third_party/gmock + third_party/libwebrtc/third_party/gtest, so: +- add BUILD.gn to avoid scattered BUILD.gn changes + +Differential Revision: https://phabricator.services.mozilla.com/D169674 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4ea9d2db79c42a144235e45c47c71adf1dd01fdc --- - testing/libfuzzer/fuzzer_test.gni | 2 ++ - testing/test.gni | 2 ++ - 2 files changed, 4 insertions(+) - create mode 100644 testing/libfuzzer/fuzzer_test.gni - create mode 100644 testing/test.gni + testing/gmock/BUILD.gn | 5 +++++ + testing/gtest/BUILD.gn | 5 +++++ + 2 files changed, 10 insertions(+) + create mode 100644 testing/gmock/BUILD.gn + create mode 100644 testing/gtest/BUILD.gn -diff --git a/testing/libfuzzer/fuzzer_test.gni b/testing/libfuzzer/fuzzer_test.gni +diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn new file mode 100644 -index 0000000000..8fdf3cdad2 +index 0000000000..a2a1efdea9 --- /dev/null -+++ b/testing/libfuzzer/fuzzer_test.gni -@@ -0,0 +1,2 @@ -+# "empty" file in place of importing new testing/libfuzzer -+# to allow BUILD.gn imports to succeed. -diff --git a/testing/test.gni b/testing/test.gni ++++ b/testing/gmock/BUILD.gn +@@ -0,0 +1,5 @@ ++import("//third_party/libaom/options.gni") ++import("../../webrtc.gni") ++ ++rtc_library("gmock") { ++} +diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn new file mode 100644 -index 0000000000..f46fa82778 +index 0000000000..c9c2703c37 --- /dev/null -+++ b/testing/test.gni -@@ -0,0 +1,2 @@ -+# "empty" file in place of importing new testing/test.gni -+# to allow BUILD.gn imports to succeed. ++++ b/testing/gtest/BUILD.gn +@@ -0,0 +1,5 @@ ++import("//third_party/libaom/options.gni") ++import("../../webrtc.gni") ++ ++rtc_library("gtest") { ++} diff --git a/third_party/libwebrtc/moz-patch-stack/0094.patch b/third_party/libwebrtc/moz-patch-stack/0094.patch index b0cdd2d540..36e7778d1a 100644 --- a/third_party/libwebrtc/moz-patch-stack/0094.patch +++ b/third_party/libwebrtc/moz-patch-stack/0094.patch @@ -1,40 +1,28 @@ -From: Michael Froman -Date: Tue, 14 Feb 2023 03:27:00 +0000 -Subject: Bug 1816173 - pt12 - add shim config for - third_party/libwebrtc/testing/{gmock|gtest} r=ng +From: Andreas Pehrson +Date: Wed, 18 Oct 2023 17:25:00 +0000 +Subject: Bug 1857862 - (fix-32a8169a65) Don't call non-constexpr + RTC_CHECK_NOTREACHED from constexpr VideoFrameTypeToString under gcc-8. + r=webrtc-reviewers,mjf -We don't vendor third_party/libwebrtc/third_party/gmock - third_party/libwebrtc/third_party/gtest, so: -- add BUILD.gn to avoid scattered BUILD.gn changes - -Differential Revision: https://phabricator.services.mozilla.com/D169674 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4ea9d2db79c42a144235e45c47c71adf1dd01fdc +Differential Revision: https://phabricator.services.mozilla.com/D191308 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8a4449ba24fa3192b44863ed8ba96f6f94a6e88d --- - testing/gmock/BUILD.gn | 5 +++++ - testing/gtest/BUILD.gn | 5 +++++ - 2 files changed, 10 insertions(+) - create mode 100644 testing/gmock/BUILD.gn - create mode 100644 testing/gtest/BUILD.gn + api/video/video_frame_type.h | 4 ++++ + 1 file changed, 4 insertions(+) -diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn -new file mode 100644 -index 0000000000..a2a1efdea9 ---- /dev/null -+++ b/testing/gmock/BUILD.gn -@@ -0,0 +1,5 @@ -+import("//third_party/libaom/options.gni") -+import("../../webrtc.gni") -+ -+rtc_library("gmock") { -+} -diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn -new file mode 100644 -index 0000000000..c9c2703c37 ---- /dev/null -+++ b/testing/gtest/BUILD.gn -@@ -0,0 +1,5 @@ -+import("//third_party/libaom/options.gni") -+import("../../webrtc.gni") -+ -+rtc_library("gtest") { -+} +diff --git a/api/video/video_frame_type.h b/api/video/video_frame_type.h +index 9079829ff8..3665a80cd8 100644 +--- a/api/video/video_frame_type.h ++++ b/api/video/video_frame_type.h +@@ -34,7 +34,11 @@ inline constexpr absl::string_view VideoFrameTypeToString( + case VideoFrameType::kVideoFrameDelta: + return "delta"; + } ++// Mozilla: ++// gcc-8 complains about a constexpr function calling a non-constexpr ditto. ++#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9) + RTC_CHECK_NOTREACHED(); ++#endif + return ""; + } + diff --git a/third_party/libwebrtc/moz-patch-stack/0095.patch b/third_party/libwebrtc/moz-patch-stack/0095.patch index 36e7778d1a..3b8608fa76 100644 --- a/third_party/libwebrtc/moz-patch-stack/0095.patch +++ b/third_party/libwebrtc/moz-patch-stack/0095.patch @@ -1,28 +1,41 @@ From: Andreas Pehrson -Date: Wed, 18 Oct 2023 17:25:00 +0000 -Subject: Bug 1857862 - (fix-32a8169a65) Don't call non-constexpr - RTC_CHECK_NOTREACHED from constexpr VideoFrameTypeToString under gcc-8. - r=webrtc-reviewers,mjf +Date: Wed, 18 Oct 2023 17:21:00 +0000 +Subject: Bug 1859786 - Fix lock annotation warning in Mozilla-specific edit on + top of video_capture_impl.cc. r=webrtc-reviewers,mjf -Differential Revision: https://phabricator.services.mozilla.com/D191308 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8a4449ba24fa3192b44863ed8ba96f6f94a6e88d +The annotations were added in M116: +https://hg.mozilla.org/mozilla-central/rev/9cd372df013948ad822ae936752d725d77474fb5 + +Note that this was never unsafe, since _dataCallbacks is only written on the +same thread that we are patching here. This patch however, adds helpful static +analysis. + +Differential Revision: https://phabricator.services.mozilla.com/D191301 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56ff441b644400f09d2d0453dbd8991ea25db7b1 --- - api/video/video_frame_type.h | 4 ++++ - 1 file changed, 4 insertions(+) + modules/video_capture/video_capture_impl.cc | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) -diff --git a/api/video/video_frame_type.h b/api/video/video_frame_type.h -index 9079829ff8..3665a80cd8 100644 ---- a/api/video/video_frame_type.h -+++ b/api/video/video_frame_type.h -@@ -34,7 +34,11 @@ inline constexpr absl::string_view VideoFrameTypeToString( - case VideoFrameType::kVideoFrameDelta: - return "delta"; +diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc +index 02404697ad..1bddaf824d 100644 +--- a/modules/video_capture/video_capture_impl.cc ++++ b/modules/video_capture/video_capture_impl.cc +@@ -119,11 +119,14 @@ void VideoCaptureImpl::DeRegisterCaptureDataCallback( + } + + int32_t VideoCaptureImpl::StopCaptureIfAllClientsClose() { +- if (_dataCallBacks.empty()) { +- return StopCapture(); +- } else { +- return 0; ++ RTC_DCHECK_RUN_ON(&api_checker_); ++ { ++ MutexLock lock(&api_lock_); ++ if (!_dataCallBacks.empty()) { ++ return 0; ++ } } -+// Mozilla: -+// gcc-8 complains about a constexpr function calling a non-constexpr ditto. -+#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9) - RTC_CHECK_NOTREACHED(); -+#endif - return ""; ++ return StopCapture(); } + int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) { diff --git a/third_party/libwebrtc/moz-patch-stack/0096.patch b/third_party/libwebrtc/moz-patch-stack/0096.patch index 3b8608fa76..983834acba 100644 --- a/third_party/libwebrtc/moz-patch-stack/0096.patch +++ b/third_party/libwebrtc/moz-patch-stack/0096.patch @@ -1,41 +1,27 @@ From: Andreas Pehrson Date: Wed, 18 Oct 2023 17:21:00 +0000 -Subject: Bug 1859786 - Fix lock annotation warning in Mozilla-specific edit on - top of video_capture_impl.cc. r=webrtc-reviewers,mjf +Subject: Bug 1859786 - Fix clang-tidy warning in video_capture_impl.cc. + r=webrtc-reviewers,mjf -The annotations were added in M116: -https://hg.mozilla.org/mozilla-central/rev/9cd372df013948ad822ae936752d725d77474fb5 +clang-tidy says: + 'auto dataCallBack' can be declared as 'auto *dataCallBack' -Note that this was never unsafe, since _dataCallbacks is only written on the -same thread that we are patching here. This patch however, adds helpful static -analysis. - -Differential Revision: https://phabricator.services.mozilla.com/D191301 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/56ff441b644400f09d2d0453dbd8991ea25db7b1 +Differential Revision: https://phabricator.services.mozilla.com/D191302 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/26c84d214137a1b0de0902c7038756964e5786f4 --- - modules/video_capture/video_capture_impl.cc | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) + modules/video_capture/video_capture_impl.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc -index 02404697ad..1bddaf824d 100644 +index 1bddaf824d..15dfb7fe1f 100644 --- a/modules/video_capture/video_capture_impl.cc +++ b/modules/video_capture/video_capture_impl.cc -@@ -119,11 +119,14 @@ void VideoCaptureImpl::DeRegisterCaptureDataCallback( - } +@@ -134,7 +134,7 @@ int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) { + + UpdateFrameCount(); // frame count used for local frame rate callback. - int32_t VideoCaptureImpl::StopCaptureIfAllClientsClose() { -- if (_dataCallBacks.empty()) { -- return StopCapture(); -- } else { -- return 0; -+ RTC_DCHECK_RUN_ON(&api_checker_); -+ { -+ MutexLock lock(&api_lock_); -+ if (!_dataCallBacks.empty()) { -+ return 0; -+ } +- for (auto dataCallBack : _dataCallBacks) { ++ for (auto* dataCallBack : _dataCallBacks) { + dataCallBack->OnFrame(captureFrame); } -+ return StopCapture(); - } - int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) { diff --git a/third_party/libwebrtc/moz-patch-stack/0097.patch b/third_party/libwebrtc/moz-patch-stack/0097.patch index 983834acba..56c8dca72b 100644 --- a/third_party/libwebrtc/moz-patch-stack/0097.patch +++ b/third_party/libwebrtc/moz-patch-stack/0097.patch @@ -1,27 +1,2186 @@ -From: Andreas Pehrson -Date: Wed, 18 Oct 2023 17:21:00 +0000 -Subject: Bug 1859786 - Fix clang-tidy warning in video_capture_impl.cc. - r=webrtc-reviewers,mjf +From: Dan Minor +Date: Thu, 24 Sep 2020 18:28:00 +0000 +Subject: Bug 1665166 - Move media/webrtc/trunk/* to third-party/libwebrtc; + r=ng -clang-tidy says: - 'auto dataCallBack' can be declared as 'auto *dataCallBack' - -Differential Revision: https://phabricator.services.mozilla.com/D191302 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/26c84d214137a1b0de0902c7038756964e5786f4 +Differential Revision: https://phabricator.services.mozilla.com/D91317 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/57e3c54bd7b9a0203e19ff1df272d24bb551ed29 --- - modules/video_capture/video_capture_impl.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + tools/clang/OWNERS | 2 + + tools/clang/plugins/ChromeClassTester.cpp | 294 ++++++++++++ + tools/clang/plugins/ChromeClassTester.h | 84 ++++ + tools/clang/plugins/FindBadConstructs.cpp | 435 ++++++++++++++++++ + tools/clang/plugins/Makefile | 19 + + tools/clang/plugins/OWNERS | 1 + + tools/clang/plugins/README.chromium | 4 + + tools/clang/plugins/tests/base_refcounted.cpp | 72 +++ + tools/clang/plugins/tests/base_refcounted.h | 121 +++++ + tools/clang/plugins/tests/base_refcounted.txt | 23 + + .../clang/plugins/tests/inline_copy_ctor.cpp | 5 + + tools/clang/plugins/tests/inline_copy_ctor.h | 12 + + .../clang/plugins/tests/inline_copy_ctor.txt | 5 + + tools/clang/plugins/tests/inline_ctor.cpp | 25 + + tools/clang/plugins/tests/inline_ctor.h | 21 + + tools/clang/plugins/tests/inline_ctor.txt | 8 + + tools/clang/plugins/tests/missing_ctor.cpp | 23 + + tools/clang/plugins/tests/missing_ctor.h | 19 + + tools/clang/plugins/tests/missing_ctor.txt | 6 + + .../tests/nested_class_inline_ctor.cpp | 5 + + .../plugins/tests/nested_class_inline_ctor.h | 22 + + .../tests/nested_class_inline_ctor.txt | 8 + + .../plugins/tests/overridden_methods.cpp | 38 ++ + .../clang/plugins/tests/overridden_methods.h | 54 +++ + .../plugins/tests/overridden_methods.txt | 20 + + tools/clang/plugins/tests/test.sh | 72 +++ + tools/clang/plugins/tests/virtual_methods.cpp | 36 ++ + tools/clang/plugins/tests/virtual_methods.h | 39 ++ + tools/clang/plugins/tests/virtual_methods.txt | 8 + + tools/clang/scripts/package.sh | 87 ++++ + tools/clang/scripts/plugin_flags.sh | 24 + + tools/clang/scripts/update.py | 34 ++ + tools/clang/scripts/update.sh | 286 ++++++++++++ + 33 files changed, 1912 insertions(+) + create mode 100644 tools/clang/OWNERS + create mode 100644 tools/clang/plugins/ChromeClassTester.cpp + create mode 100644 tools/clang/plugins/ChromeClassTester.h + create mode 100644 tools/clang/plugins/FindBadConstructs.cpp + create mode 100644 tools/clang/plugins/Makefile + create mode 100644 tools/clang/plugins/OWNERS + create mode 100644 tools/clang/plugins/README.chromium + create mode 100644 tools/clang/plugins/tests/base_refcounted.cpp + create mode 100644 tools/clang/plugins/tests/base_refcounted.h + create mode 100644 tools/clang/plugins/tests/base_refcounted.txt + create mode 100644 tools/clang/plugins/tests/inline_copy_ctor.cpp + create mode 100644 tools/clang/plugins/tests/inline_copy_ctor.h + create mode 100644 tools/clang/plugins/tests/inline_copy_ctor.txt + create mode 100644 tools/clang/plugins/tests/inline_ctor.cpp + create mode 100644 tools/clang/plugins/tests/inline_ctor.h + create mode 100644 tools/clang/plugins/tests/inline_ctor.txt + create mode 100644 tools/clang/plugins/tests/missing_ctor.cpp + create mode 100644 tools/clang/plugins/tests/missing_ctor.h + create mode 100644 tools/clang/plugins/tests/missing_ctor.txt + create mode 100644 tools/clang/plugins/tests/nested_class_inline_ctor.cpp + create mode 100644 tools/clang/plugins/tests/nested_class_inline_ctor.h + create mode 100644 tools/clang/plugins/tests/nested_class_inline_ctor.txt + create mode 100644 tools/clang/plugins/tests/overridden_methods.cpp + create mode 100644 tools/clang/plugins/tests/overridden_methods.h + create mode 100644 tools/clang/plugins/tests/overridden_methods.txt + create mode 100755 tools/clang/plugins/tests/test.sh + create mode 100644 tools/clang/plugins/tests/virtual_methods.cpp + create mode 100644 tools/clang/plugins/tests/virtual_methods.h + create mode 100644 tools/clang/plugins/tests/virtual_methods.txt + create mode 100755 tools/clang/scripts/package.sh + create mode 100755 tools/clang/scripts/plugin_flags.sh + create mode 100755 tools/clang/scripts/update.py + create mode 100755 tools/clang/scripts/update.sh -diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc -index 1bddaf824d..15dfb7fe1f 100644 ---- a/modules/video_capture/video_capture_impl.cc -+++ b/modules/video_capture/video_capture_impl.cc -@@ -134,7 +134,7 @@ int32_t VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame) { - - UpdateFrameCount(); // frame count used for local frame rate callback. - -- for (auto dataCallBack : _dataCallBacks) { -+ for (auto* dataCallBack : _dataCallBacks) { - dataCallBack->OnFrame(captureFrame); - } - +diff --git a/tools/clang/OWNERS b/tools/clang/OWNERS +new file mode 100644 +index 0000000000..d86ef9424a +--- /dev/null ++++ b/tools/clang/OWNERS +@@ -0,0 +1,2 @@ ++hans@chromium.org ++thakis@chromium.org +diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp +new file mode 100644 +index 0000000000..055866c5c5 +--- /dev/null ++++ b/tools/clang/plugins/ChromeClassTester.cpp +@@ -0,0 +1,294 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// A general interface for filtering and only acting on classes in Chromium C++ ++// code. ++ ++#include "ChromeClassTester.h" ++ ++#include ++ ++#include "clang/AST/AST.h" ++#include "clang/Basic/FileManager.h" ++#include "clang/Basic/SourceManager.h" ++ ++using namespace clang; ++ ++namespace { ++ ++bool starts_with(const std::string& one, const std::string& two) { ++ return one.compare(0, two.size(), two) == 0; ++} ++ ++std::string lstrip(const std::string& one, const std::string& two) { ++ if (starts_with(one, two)) ++ return one.substr(two.size()); ++ return one; ++} ++ ++bool ends_with(const std::string& one, const std::string& two) { ++ if (two.size() > one.size()) ++ return false; ++ ++ return one.compare(one.size() - two.size(), two.size(), two) == 0; ++} ++ ++} // namespace ++ ++ChromeClassTester::ChromeClassTester(CompilerInstance& instance) ++ : instance_(instance), ++ diagnostic_(instance.getDiagnostics()) { ++ BuildBannedLists(); ++} ++ ++ChromeClassTester::~ChromeClassTester() {} ++ ++void ChromeClassTester::HandleTagDeclDefinition(TagDecl* tag) { ++ pending_class_decls_.push_back(tag); ++} ++ ++bool ChromeClassTester::HandleTopLevelDecl(DeclGroupRef group_ref) { ++ for (size_t i = 0; i < pending_class_decls_.size(); ++i) ++ CheckTag(pending_class_decls_[i]); ++ pending_class_decls_.clear(); ++ ++ return true; // true means continue parsing. ++} ++ ++void ChromeClassTester::CheckTag(TagDecl* tag) { ++ // We handle class types here where we have semantic information. We can only ++ // check structs/classes/enums here, but we get a bunch of nice semantic ++ // information instead of just parsing information. ++ ++ if (CXXRecordDecl* record = dyn_cast(tag)) { ++ // If this is a POD or a class template or a type dependent on a ++ // templated class, assume there's no ctor/dtor/virtual method ++ // optimization that we can do. ++ if (record->isPOD() || ++ record->getDescribedClassTemplate() || ++ record->getTemplateSpecializationKind() || ++ record->isDependentType()) ++ return; ++ ++ if (InBannedNamespace(record)) ++ return; ++ ++ SourceLocation record_location = record->getInnerLocStart(); ++ if (InBannedDirectory(record_location)) ++ return; ++ ++ // We sadly need to maintain a blacklist of types that violate these ++ // rules, but do so for good reason or due to limitations of this ++ // checker (i.e., we don't handle extern templates very well). ++ std::string base_name = record->getNameAsString(); ++ if (IsIgnoredType(base_name)) ++ return; ++ ++ // We ignore all classes that end with "Matcher" because they're probably ++ // GMock artifacts. ++ if (ends_with(base_name, "Matcher")) ++ return; ++ ++ CheckChromeClass(record_location, record); ++ } ++} ++ ++void ChromeClassTester::emitWarning(SourceLocation loc, ++ const char* raw_error) { ++ FullSourceLoc full(loc, instance().getSourceManager()); ++ std::string err; ++ err = "[chromium-style] "; ++ err += raw_error; ++ DiagnosticsEngine::Level level = ++ diagnostic().getWarningsAsErrors() ? ++ DiagnosticsEngine::Error : ++ DiagnosticsEngine::Warning; ++ unsigned id = diagnostic().getCustomDiagID(level, err); ++ DiagnosticBuilder builder = diagnostic().Report(full, id); ++} ++ ++bool ChromeClassTester::InBannedNamespace(const Decl* record) { ++ std::string n = GetNamespace(record); ++ if (!n.empty()) { ++ return std::find(banned_namespaces_.begin(), banned_namespaces_.end(), n) ++ != banned_namespaces_.end(); ++ } ++ ++ return false; ++} ++ ++std::string ChromeClassTester::GetNamespace(const Decl* record) { ++ return GetNamespaceImpl(record->getDeclContext(), ""); ++} ++ ++bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { ++ std::string filename; ++ if (!GetFilename(record_location, &filename)) ++ return false; ++ ++ if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || ++ ends_with(filename, ".mm")) { ++ return true; ++ } ++ ++ return false; ++} ++ ++void ChromeClassTester::BuildBannedLists() { ++ banned_namespaces_.push_back("std"); ++ banned_namespaces_.push_back("__gnu_cxx"); ++ banned_namespaces_.push_back("WebKit"); ++ ++ banned_directories_.push_back("third_party/"); ++ banned_directories_.push_back("native_client/"); ++ banned_directories_.push_back("breakpad/"); ++ banned_directories_.push_back("courgette/"); ++ banned_directories_.push_back("pdf/"); ++ banned_directories_.push_back("ppapi/"); ++ banned_directories_.push_back("usr/"); ++ banned_directories_.push_back("testing/"); ++ banned_directories_.push_back("googleurl/"); ++ banned_directories_.push_back("v8/"); ++ banned_directories_.push_back("dart/"); ++ banned_directories_.push_back("sdch/"); ++ banned_directories_.push_back("icu4c/"); ++ banned_directories_.push_back("frameworks/"); ++ ++ // Don't check autogenerated headers. ++ // Make puts them below $(builddir_name)/.../gen and geni. ++ // Ninja puts them below OUTPUT_DIR/.../gen ++ // Xcode has a fixed output directory for everything. ++ banned_directories_.push_back("gen/"); ++ banned_directories_.push_back("geni/"); ++ banned_directories_.push_back("xcodebuild/"); ++ ++ // You are standing in a mazy of twisty dependencies, all resolved by ++ // putting everything in the header. ++ banned_directories_.push_back("automation/"); ++ ++ // Don't check system headers. ++ banned_directories_.push_back("/Developer/"); ++ ++ // Used in really low level threading code that probably shouldn't be out of ++ // lined. ++ ignored_record_names_.insert("ThreadLocalBoolean"); ++ ++ // A complicated pickle derived struct that is all packed integers. ++ ignored_record_names_.insert("Header"); ++ ++ // Part of the GPU system that uses multiple included header ++ // weirdness. Never getting this right. ++ ignored_record_names_.insert("Validators"); ++ ++ // Has a UNIT_TEST only constructor. Isn't *terribly* complex... ++ ignored_record_names_.insert("AutocompleteController"); ++ ignored_record_names_.insert("HistoryURLProvider"); ++ ++ // Because of chrome frame ++ ignored_record_names_.insert("ReliabilityTestSuite"); ++ ++ // Used over in the net unittests. A large enough bundle of integers with 1 ++ // non-pod class member. Probably harmless. ++ ignored_record_names_.insert("MockTransaction"); ++ ++ // Used heavily in ui_unittests and once in views_unittests. Fixing this ++ // isn't worth the overhead of an additional library. ++ ignored_record_names_.insert("TestAnimationDelegate"); ++ ++ // Part of our public interface that nacl and friends use. (Arguably, this ++ // should mean that this is a higher priority but fixing this looks hard.) ++ ignored_record_names_.insert("PluginVersionInfo"); ++} ++ ++std::string ChromeClassTester::GetNamespaceImpl(const DeclContext* context, ++ const std::string& candidate) { ++ switch (context->getDeclKind()) { ++ case Decl::TranslationUnit: { ++ return candidate; ++ } ++ case Decl::Namespace: { ++ const NamespaceDecl* decl = dyn_cast(context); ++ std::string name_str; ++ llvm::raw_string_ostream OS(name_str); ++ if (decl->isAnonymousNamespace()) ++ OS << ""; ++ else ++ OS << *decl; ++ return GetNamespaceImpl(context->getParent(), ++ OS.str()); ++ } ++ default: { ++ return GetNamespaceImpl(context->getParent(), candidate); ++ } ++ } ++} ++ ++bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { ++ std::string filename; ++ if (!GetFilename(loc, &filename)) { ++ // If the filename cannot be determined, simply treat this as a banned ++ // location, instead of going through the full lookup process. ++ return true; ++ } ++ ++ // We need to special case scratch space; which is where clang does its ++ // macro expansion. We explicitly want to allow people to do otherwise bad ++ // things through macros that were defined due to third party libraries. ++ if (filename == "") ++ return true; ++ ++ // Don't complain about autogenerated protobuf files. ++ if (ends_with(filename, ".pb.h")) { ++ return true; ++ } ++ ++ // We need to munge the paths so that they are relative to the repository ++ // srcroot. We first resolve the symlinktastic relative path and then ++ // remove our known srcroot from it if needed. ++ char resolvedPath[MAXPATHLEN]; ++ if (realpath(filename.c_str(), resolvedPath)) { ++ filename = resolvedPath; ++ } ++ ++ // On linux, chrome is often checked out to /usr/local/google. Due to the ++ // "usr" rule in banned_directories_, all diagnostics would be suppressed ++ // in that case. As a workaround, strip that prefix. ++ filename = lstrip(filename, "/usr/local/google"); ++ ++ for (std::vector::const_iterator it = ++ banned_directories_.begin(); ++ it != banned_directories_.end(); ++it) { ++ // If we can find any of the banned path components in this path, then ++ // this file is rejected. ++ size_t index = filename.find(*it); ++ if (index != std::string::npos) { ++ bool matches_full_dir_name = index == 0 || filename[index - 1] == '/'; ++ if ((*it)[0] == '/') ++ matches_full_dir_name = true; ++ if (matches_full_dir_name) ++ return true; ++ } ++ } ++ ++ return false; ++} ++ ++bool ChromeClassTester::IsIgnoredType(const std::string& base_name) { ++ return ignored_record_names_.find(base_name) != ignored_record_names_.end(); ++} ++ ++bool ChromeClassTester::GetFilename(SourceLocation loc, ++ std::string* filename) { ++ const SourceManager& source_manager = instance_.getSourceManager(); ++ SourceLocation spelling_location = source_manager.getSpellingLoc(loc); ++ PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); ++ if (ploc.isInvalid()) { ++ // If we're in an invalid location, we're looking at things that aren't ++ // actually stated in the source. ++ return false; ++ } ++ ++ *filename = ploc.getFilename(); ++ return true; ++} +diff --git a/tools/clang/plugins/ChromeClassTester.h b/tools/clang/plugins/ChromeClassTester.h +new file mode 100644 +index 0000000000..588ae9cae5 +--- /dev/null ++++ b/tools/clang/plugins/ChromeClassTester.h +@@ -0,0 +1,84 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ ++#define TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ ++ ++#include ++#include ++ ++#include "clang/AST/ASTConsumer.h" ++#include "clang/AST/TypeLoc.h" ++#include "clang/Frontend/CompilerInstance.h" ++ ++// A class on top of ASTConsumer that forwards classes defined in Chromium ++// headers to subclasses which implement CheckChromeClass(). ++class ChromeClassTester : public clang::ASTConsumer { ++ public: ++ explicit ChromeClassTester(clang::CompilerInstance& instance); ++ virtual ~ChromeClassTester(); ++ ++ // clang::ASTConsumer: ++ virtual void HandleTagDeclDefinition(clang::TagDecl* tag); ++ virtual bool HandleTopLevelDecl(clang::DeclGroupRef group_ref); ++ ++ protected: ++ clang::CompilerInstance& instance() { return instance_; } ++ clang::DiagnosticsEngine& diagnostic() { return diagnostic_; } ++ ++ // Emits a simple warning; this shouldn't be used if you require printf-style ++ // printing. ++ void emitWarning(clang::SourceLocation loc, const char* error); ++ ++ // Utility method for subclasses to check if this class is in a banned ++ // namespace. ++ bool InBannedNamespace(const clang::Decl* record); ++ ++ // Utility method for subclasses to determine the namespace of the ++ // specified record, if any. Unnamed namespaces will be identified as ++ // "". ++ std::string GetNamespace(const clang::Decl* record); ++ ++ // Utility method for subclasses to check if this class is within an ++ // implementation (.cc, .cpp, .mm) file. ++ bool InImplementationFile(clang::SourceLocation location); ++ ++ private: ++ void BuildBannedLists(); ++ ++ void CheckTag(clang::TagDecl*); ++ ++ // Filtered versions of tags that are only called with things defined in ++ // chrome header files. ++ virtual void CheckChromeClass(clang::SourceLocation record_location, ++ clang::CXXRecordDecl* record) = 0; ++ ++ // Utility methods used for filtering out non-chrome classes (and ones we ++ // deliberately ignore) in HandleTagDeclDefinition(). ++ std::string GetNamespaceImpl(const clang::DeclContext* context, ++ const std::string& candidate); ++ bool InBannedDirectory(clang::SourceLocation loc); ++ bool IsIgnoredType(const std::string& base_name); ++ ++ // Attempts to determine the filename for the given SourceLocation. ++ // Returns false if the filename could not be determined. ++ bool GetFilename(clang::SourceLocation loc, std::string* filename); ++ ++ clang::CompilerInstance& instance_; ++ clang::DiagnosticsEngine& diagnostic_; ++ ++ // List of banned namespaces. ++ std::vector banned_namespaces_; ++ ++ // List of banned directories. ++ std::vector banned_directories_; ++ ++ // List of types that we don't check. ++ std::set ignored_record_names_; ++ ++ // List of decls to check once the current top-level decl is parsed. ++ std::vector pending_class_decls_; ++}; ++ ++#endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ +diff --git a/tools/clang/plugins/FindBadConstructs.cpp b/tools/clang/plugins/FindBadConstructs.cpp +new file mode 100644 +index 0000000000..b79a64dbd1 +--- /dev/null ++++ b/tools/clang/plugins/FindBadConstructs.cpp +@@ -0,0 +1,435 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// This file defines a bunch of recurring problems in the Chromium C++ code. ++// ++// Checks that are implemented: ++// - Constructors/Destructors should not be inlined if they are of a complex ++// class type. ++// - Missing "virtual" keywords on methods that should be virtual. ++// - Non-annotated overriding virtual methods. ++// - Virtual methods with nonempty implementations in their headers. ++// - Classes that derive from base::RefCounted / base::RefCountedThreadSafe ++// should have protected or private destructors. ++ ++#include "clang/Frontend/FrontendPluginRegistry.h" ++#include "clang/AST/ASTConsumer.h" ++#include "clang/AST/AST.h" ++#include "clang/AST/CXXInheritance.h" ++#include "clang/AST/TypeLoc.h" ++#include "clang/Basic/SourceManager.h" ++#include "clang/Frontend/CompilerInstance.h" ++#include "llvm/Support/raw_ostream.h" ++ ++#include "ChromeClassTester.h" ++ ++using namespace clang; ++ ++namespace { ++ ++bool TypeHasNonTrivialDtor(const Type* type) { ++ if (const CXXRecordDecl* cxx_r = type->getCXXRecordDeclForPointerType()) ++ return cxx_r->hasTrivialDestructor(); ++ ++ return false; ++} ++ ++// Returns the underlying Type for |type| by expanding typedefs and removing ++// any namespace qualifiers. ++const Type* UnwrapType(const Type* type) { ++ if (const ElaboratedType* elaborated = dyn_cast(type)) ++ return UnwrapType(elaborated->getNamedType().getTypePtr()); ++ if (const TypedefType* typedefed = dyn_cast(type)) ++ return UnwrapType(typedefed->desugar().getTypePtr()); ++ return type; ++} ++ ++// Searches for constructs that we know we don't want in the Chromium code base. ++class FindBadConstructsConsumer : public ChromeClassTester { ++ public: ++ FindBadConstructsConsumer(CompilerInstance& instance, ++ bool check_refcounted_dtors, ++ bool check_virtuals_in_implementations) ++ : ChromeClassTester(instance), ++ check_refcounted_dtors_(check_refcounted_dtors), ++ check_virtuals_in_implementations_(check_virtuals_in_implementations) { ++ } ++ ++ virtual void CheckChromeClass(SourceLocation record_location, ++ CXXRecordDecl* record) { ++ bool implementation_file = InImplementationFile(record_location); ++ ++ if (!implementation_file) { ++ // Only check for "heavy" constructors/destructors in header files; ++ // within implementation files, there is no performance cost. ++ CheckCtorDtorWeight(record_location, record); ++ } ++ ++ if (!implementation_file || check_virtuals_in_implementations_) { ++ bool warn_on_inline_bodies = !implementation_file; ++ ++ // Check that all virtual methods are marked accordingly with both ++ // virtual and OVERRIDE. ++ CheckVirtualMethods(record_location, record, warn_on_inline_bodies); ++ } ++ ++ if (check_refcounted_dtors_) ++ CheckRefCountedDtors(record_location, record); ++ } ++ ++ private: ++ bool check_refcounted_dtors_; ++ bool check_virtuals_in_implementations_; ++ ++ // Returns true if |base| specifies one of the Chromium reference counted ++ // classes (base::RefCounted / base::RefCountedThreadSafe). |user_data| is ++ // ignored. ++ static bool IsRefCountedCallback(const CXXBaseSpecifier* base, ++ CXXBasePath& path, ++ void* user_data) { ++ FindBadConstructsConsumer* self = ++ static_cast(user_data); ++ ++ const TemplateSpecializationType* base_type = ++ dyn_cast( ++ UnwrapType(base->getType().getTypePtr())); ++ if (!base_type) { ++ // Base-most definition is not a template, so this cannot derive from ++ // base::RefCounted. However, it may still be possible to use with a ++ // scoped_refptr<> and support ref-counting, so this is not a perfect ++ // guarantee of safety. ++ return false; ++ } ++ ++ TemplateName name = base_type->getTemplateName(); ++ if (TemplateDecl* decl = name.getAsTemplateDecl()) { ++ std::string base_name = decl->getNameAsString(); ++ ++ // Check for both base::RefCounted and base::RefCountedThreadSafe. ++ if (base_name.compare(0, 10, "RefCounted") == 0 && ++ self->GetNamespace(decl) == "base") { ++ return true; ++ } ++ } ++ return false; ++ } ++ ++ // Prints errors if the destructor of a RefCounted class is public. ++ void CheckRefCountedDtors(SourceLocation record_location, ++ CXXRecordDecl* record) { ++ // Skip anonymous structs. ++ if (record->getIdentifier() == NULL) ++ return; ++ ++ CXXBasePaths paths; ++ if (!record->lookupInBases( ++ &FindBadConstructsConsumer::IsRefCountedCallback, this, paths)) { ++ return; // Class does not derive from a ref-counted base class. ++ } ++ ++ if (!record->hasUserDeclaredDestructor()) { ++ emitWarning( ++ record_location, ++ "Classes that are ref-counted should have explicit " ++ "destructors that are protected or private."); ++ } else if (CXXDestructorDecl* dtor = record->getDestructor()) { ++ if (dtor->getAccess() == AS_public) { ++ emitWarning( ++ dtor->getInnerLocStart(), ++ "Classes that are ref-counted should not have " ++ "public destructors."); ++ } ++ } ++ } ++ ++ // Prints errors if the constructor/destructor weight is too heavy. ++ void CheckCtorDtorWeight(SourceLocation record_location, ++ CXXRecordDecl* record) { ++ // We don't handle anonymous structs. If this record doesn't have a ++ // name, it's of the form: ++ // ++ // struct { ++ // ... ++ // } name_; ++ if (record->getIdentifier() == NULL) ++ return; ++ ++ // Count the number of templated base classes as a feature of whether the ++ // destructor can be inlined. ++ int templated_base_classes = 0; ++ for (CXXRecordDecl::base_class_const_iterator it = record->bases_begin(); ++ it != record->bases_end(); ++it) { ++ if (it->getTypeSourceInfo()->getTypeLoc().getTypeLocClass() == ++ TypeLoc::TemplateSpecialization) { ++ ++templated_base_classes; ++ } ++ } ++ ++ // Count the number of trivial and non-trivial member variables. ++ int trivial_member = 0; ++ int non_trivial_member = 0; ++ int templated_non_trivial_member = 0; ++ for (RecordDecl::field_iterator it = record->field_begin(); ++ it != record->field_end(); ++it) { ++ CountType(it->getType().getTypePtr(), ++ &trivial_member, ++ &non_trivial_member, ++ &templated_non_trivial_member); ++ } ++ ++ // Check to see if we need to ban inlined/synthesized constructors. Note ++ // that the cutoffs here are kind of arbitrary. Scores over 10 break. ++ int dtor_score = 0; ++ // Deriving from a templated base class shouldn't be enough to trigger ++ // the ctor warning, but if you do *anything* else, it should. ++ // ++ // TODO(erg): This is motivated by templated base classes that don't have ++ // any data members. Somehow detect when templated base classes have data ++ // members and treat them differently. ++ dtor_score += templated_base_classes * 9; ++ // Instantiating a template is an insta-hit. ++ dtor_score += templated_non_trivial_member * 10; ++ // The fourth normal class member should trigger the warning. ++ dtor_score += non_trivial_member * 3; ++ ++ int ctor_score = dtor_score; ++ // You should be able to have 9 ints before we warn you. ++ ctor_score += trivial_member; ++ ++ if (ctor_score >= 10) { ++ if (!record->hasUserDeclaredConstructor()) { ++ emitWarning(record_location, ++ "Complex class/struct needs an explicit out-of-line " ++ "constructor."); ++ } else { ++ // Iterate across all the constructors in this file and yell if we ++ // find one that tries to be inline. ++ for (CXXRecordDecl::ctor_iterator it = record->ctor_begin(); ++ it != record->ctor_end(); ++it) { ++ if (it->hasInlineBody()) { ++ if (it->isCopyConstructor() && ++ !record->hasUserDeclaredCopyConstructor()) { ++ emitWarning(record_location, ++ "Complex class/struct needs an explicit out-of-line " ++ "copy constructor."); ++ } else { ++ emitWarning(it->getInnerLocStart(), ++ "Complex constructor has an inlined body."); ++ } ++ } ++ } ++ } ++ } ++ ++ // The destructor side is equivalent except that we don't check for ++ // trivial members; 20 ints don't need a destructor. ++ if (dtor_score >= 10 && !record->hasTrivialDestructor()) { ++ if (!record->hasUserDeclaredDestructor()) { ++ emitWarning( ++ record_location, ++ "Complex class/struct needs an explicit out-of-line " ++ "destructor."); ++ } else if (CXXDestructorDecl* dtor = record->getDestructor()) { ++ if (dtor->hasInlineBody()) { ++ emitWarning(dtor->getInnerLocStart(), ++ "Complex destructor has an inline body."); ++ } ++ } ++ } ++ } ++ ++ void CheckVirtualMethod(const CXXMethodDecl* method, ++ bool warn_on_inline_bodies) { ++ if (!method->isVirtual()) ++ return; ++ ++ if (!method->isVirtualAsWritten()) { ++ SourceLocation loc = method->getTypeSpecStartLoc(); ++ if (isa(method)) ++ loc = method->getInnerLocStart(); ++ emitWarning(loc, "Overriding method must have \"virtual\" keyword."); ++ } ++ ++ // Virtual methods should not have inline definitions beyond "{}". This ++ // only matters for header files. ++ if (warn_on_inline_bodies && method->hasBody() && ++ method->hasInlineBody()) { ++ if (CompoundStmt* cs = dyn_cast(method->getBody())) { ++ if (cs->size()) { ++ emitWarning( ++ cs->getLBracLoc(), ++ "virtual methods with non-empty bodies shouldn't be " ++ "declared inline."); ++ } ++ } ++ } ++ } ++ ++ bool InTestingNamespace(const Decl* record) { ++ return GetNamespace(record).find("testing") != std::string::npos; ++ } ++ ++ bool IsMethodInBannedNamespace(const CXXMethodDecl* method) { ++ if (InBannedNamespace(method)) ++ return true; ++ for (CXXMethodDecl::method_iterator i = method->begin_overridden_methods(); ++ i != method->end_overridden_methods(); ++ ++i) { ++ const CXXMethodDecl* overridden = *i; ++ if (IsMethodInBannedNamespace(overridden)) ++ return true; ++ } ++ ++ return false; ++ } ++ ++ void CheckOverriddenMethod(const CXXMethodDecl* method) { ++ if (!method->size_overridden_methods() || method->getAttr()) ++ return; ++ ++ if (isa(method) || method->isPure()) ++ return; ++ ++ if (IsMethodInBannedNamespace(method)) ++ return; ++ ++ SourceLocation loc = method->getTypeSpecStartLoc(); ++ emitWarning(loc, "Overriding method must be marked with OVERRIDE."); ++ } ++ ++ // Makes sure there is a "virtual" keyword on virtual methods. ++ // ++ // Gmock objects trigger these for each MOCK_BLAH() macro used. So we have a ++ // trick to get around that. If a class has member variables whose types are ++ // in the "testing" namespace (which is how gmock works behind the scenes), ++ // there's a really high chance we won't care about these errors ++ void CheckVirtualMethods(SourceLocation record_location, ++ CXXRecordDecl* record, ++ bool warn_on_inline_bodies) { ++ for (CXXRecordDecl::field_iterator it = record->field_begin(); ++ it != record->field_end(); ++it) { ++ CXXRecordDecl* record_type = ++ it->getTypeSourceInfo()->getTypeLoc().getTypePtr()-> ++ getAsCXXRecordDecl(); ++ if (record_type) { ++ if (InTestingNamespace(record_type)) { ++ return; ++ } ++ } ++ } ++ ++ for (CXXRecordDecl::method_iterator it = record->method_begin(); ++ it != record->method_end(); ++it) { ++ if (it->isCopyAssignmentOperator() || isa(*it)) { ++ // Ignore constructors and assignment operators. ++ } else if (isa(*it) && ++ !record->hasUserDeclaredDestructor()) { ++ // Ignore non-user-declared destructors. ++ } else { ++ CheckVirtualMethod(*it, warn_on_inline_bodies); ++ CheckOverriddenMethod(*it); ++ } ++ } ++ } ++ ++ void CountType(const Type* type, ++ int* trivial_member, ++ int* non_trivial_member, ++ int* templated_non_trivial_member) { ++ switch (type->getTypeClass()) { ++ case Type::Record: { ++ // Simplifying; the whole class isn't trivial if the dtor is, but ++ // we use this as a signal about complexity. ++ if (TypeHasNonTrivialDtor(type)) ++ (*trivial_member)++; ++ else ++ (*non_trivial_member)++; ++ break; ++ } ++ case Type::TemplateSpecialization: { ++ TemplateName name = ++ dyn_cast(type)->getTemplateName(); ++ bool whitelisted_template = false; ++ ++ // HACK: I'm at a loss about how to get the syntax checker to get ++ // whether a template is exterened or not. For the first pass here, ++ // just do retarded string comparisons. ++ if (TemplateDecl* decl = name.getAsTemplateDecl()) { ++ std::string base_name = decl->getNameAsString(); ++ if (base_name == "basic_string") ++ whitelisted_template = true; ++ } ++ ++ if (whitelisted_template) ++ (*non_trivial_member)++; ++ else ++ (*templated_non_trivial_member)++; ++ break; ++ } ++ case Type::Elaborated: { ++ CountType( ++ dyn_cast(type)->getNamedType().getTypePtr(), ++ trivial_member, non_trivial_member, templated_non_trivial_member); ++ break; ++ } ++ case Type::Typedef: { ++ while (const TypedefType* TT = dyn_cast(type)) { ++ type = TT->getDecl()->getUnderlyingType().getTypePtr(); ++ } ++ CountType(type, trivial_member, non_trivial_member, ++ templated_non_trivial_member); ++ break; ++ } ++ default: { ++ // Stupid assumption: anything we see that isn't the above is one of ++ // the 20 integer types. ++ (*trivial_member)++; ++ break; ++ } ++ } ++ } ++}; ++ ++class FindBadConstructsAction : public PluginASTAction { ++ public: ++ FindBadConstructsAction() ++ : check_refcounted_dtors_(true), ++ check_virtuals_in_implementations_(true) { ++ } ++ ++ protected: ++ // Overridden from PluginASTAction: ++ virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance, ++ llvm::StringRef ref) { ++ return new FindBadConstructsConsumer( ++ instance, check_refcounted_dtors_, check_virtuals_in_implementations_); ++ } ++ ++ virtual bool ParseArgs(const CompilerInstance& instance, ++ const std::vector& args) { ++ bool parsed = true; ++ ++ for (size_t i = 0; i < args.size() && parsed; ++i) { ++ if (args[i] == "skip-refcounted-dtors") { ++ check_refcounted_dtors_ = false; ++ } else if (args[i] == "skip-virtuals-in-implementations") { ++ check_virtuals_in_implementations_ = false; ++ } else { ++ parsed = false; ++ llvm::errs() << "Unknown argument: " << args[i] << "\n"; ++ } ++ } ++ ++ return parsed; ++ } ++ ++ private: ++ bool check_refcounted_dtors_; ++ bool check_virtuals_in_implementations_; ++}; ++ ++} // namespace ++ ++static FrontendPluginRegistry::Add ++X("find-bad-constructs", "Finds bad C++ constructs"); +diff --git a/tools/clang/plugins/Makefile b/tools/clang/plugins/Makefile +new file mode 100644 +index 0000000000..0cfec71159 +--- /dev/null ++++ b/tools/clang/plugins/Makefile +@@ -0,0 +1,19 @@ ++# This file requires the clang build system, at least for now. So to use this ++# Makefile, you should execute the following commands to copy this directory ++# into a clang checkout: ++# ++# cp -R third_party/llvm/tools/clang/tools/chrome-plugin ++# cd third_party/llvm/tools/clang/tools/chrome-plugin ++# make ++ ++CLANG_LEVEL := ../.. ++LIBRARYNAME = FindBadConstructs ++ ++LINK_LIBS_IN_SHARED = 0 ++SHARED_LIBRARY = 1 ++ ++include $(CLANG_LEVEL)/Makefile ++ ++ifeq ($(OS),Darwin) ++ LDFLAGS=-Wl,-undefined,dynamic_lookup ++endif +diff --git a/tools/clang/plugins/OWNERS b/tools/clang/plugins/OWNERS +new file mode 100644 +index 0000000000..4733a4f06b +--- /dev/null ++++ b/tools/clang/plugins/OWNERS +@@ -0,0 +1 @@ ++erg@chromium.org +diff --git a/tools/clang/plugins/README.chromium b/tools/clang/plugins/README.chromium +new file mode 100644 +index 0000000000..a2ce0ff557 +--- /dev/null ++++ b/tools/clang/plugins/README.chromium +@@ -0,0 +1,4 @@ ++Documentation for this code is: ++ ++- http://code.google.com/p/chromium/wiki/Clang ++- http://code.google.com/p/chromium/wiki/WritingClangPlugins +diff --git a/tools/clang/plugins/tests/base_refcounted.cpp b/tools/clang/plugins/tests/base_refcounted.cpp +new file mode 100644 +index 0000000000..364a3e888c +--- /dev/null ++++ b/tools/clang/plugins/tests/base_refcounted.cpp +@@ -0,0 +1,72 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "base_refcounted.h" ++ ++#include ++ ++namespace { ++ ++// Unsafe; should error. ++class AnonymousDerivedProtectedToPublicInImpl ++ : public ProtectedRefCountedDtorInHeader { ++ public: ++ AnonymousDerivedProtectedToPublicInImpl() {} ++ ~AnonymousDerivedProtectedToPublicInImpl() {} ++}; ++ ++} // namespace ++ ++// Unsafe; should error. ++class PublicRefCountedDtorInImpl ++ : public base::RefCounted { ++ public: ++ PublicRefCountedDtorInImpl() {} ++ ~PublicRefCountedDtorInImpl() {} ++ ++ private: ++ friend class base::RefCounted; ++}; ++ ++class Foo { ++ public: ++ class BarInterface { ++ protected: ++ virtual ~BarInterface() {} ++ }; ++ ++ typedef base::RefCounted RefCountedBar; ++ typedef RefCountedBar AnotherTypedef; ++}; ++ ++class Baz { ++ public: ++ typedef typename Foo::AnotherTypedef MyLocalTypedef; ++}; ++ ++// Unsafe; should error. ++class UnsafeTypedefChainInImpl : public Baz::MyLocalTypedef { ++ public: ++ UnsafeTypedefChainInImpl() {} ++ ~UnsafeTypedefChainInImpl() {} ++}; ++ ++int main() { ++ PublicRefCountedDtorInHeader bad; ++ PublicRefCountedDtorInImpl also_bad; ++ ++ ProtectedRefCountedDtorInHeader* protected_ok = NULL; ++ PrivateRefCountedDtorInHeader* private_ok = NULL; ++ ++ DerivedProtectedToPublicInHeader still_bad; ++ PublicRefCountedThreadSafeDtorInHeader another_bad_variation; ++ AnonymousDerivedProtectedToPublicInImpl and_this_is_bad_too; ++ ImplicitDerivedProtectedToPublicInHeader bad_yet_again; ++ UnsafeTypedefChainInImpl and_again_this_is_bad; ++ ++ WebKitPublicDtorInHeader ignored; ++ WebKitDerivedPublicDtorInHeader still_ignored; ++ ++ return 0; ++} +diff --git a/tools/clang/plugins/tests/base_refcounted.h b/tools/clang/plugins/tests/base_refcounted.h +new file mode 100644 +index 0000000000..1e53215997 +--- /dev/null ++++ b/tools/clang/plugins/tests/base_refcounted.h +@@ -0,0 +1,121 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef BASE_REFCOUNTED_H_ ++#define BASE_REFCOUNTED_H_ ++ ++namespace base { ++ ++template ++class RefCounted { ++ public: ++ RefCounted() {} ++ ~RefCounted() {} ++}; ++ ++template ++class RefCountedThreadSafe { ++ public: ++ RefCountedThreadSafe() {} ++ ~RefCountedThreadSafe() {} ++}; ++ ++} // namespace base ++ ++// Ignore classes whose inheritance tree ends in WebKit's RefCounted base ++// class. Though prone to error, this pattern is very prevalent in WebKit ++// code, so do not issue any warnings. ++namespace WebKit { ++ ++template ++class RefCounted { ++ public: ++ RefCounted() {} ++ ~RefCounted() {} ++}; ++ ++} // namespace WebKit ++ ++// Unsafe; should error. ++class PublicRefCountedDtorInHeader ++ : public base::RefCounted { ++ public: ++ PublicRefCountedDtorInHeader() {} ++ ~PublicRefCountedDtorInHeader() {} ++ ++ private: ++ friend class base::RefCounted; ++}; ++ ++// Unsafe; should error. ++class PublicRefCountedThreadSafeDtorInHeader ++ : public base::RefCountedThreadSafe< ++ PublicRefCountedThreadSafeDtorInHeader> { ++ public: ++ PublicRefCountedThreadSafeDtorInHeader() {} ++ ~PublicRefCountedThreadSafeDtorInHeader() {} ++ ++ private: ++ friend class base::RefCountedThreadSafe< ++ PublicRefCountedThreadSafeDtorInHeader>; ++}; ++ ++// Safe; should not have errors. ++class ProtectedRefCountedDtorInHeader ++ : public base::RefCounted { ++ public: ++ ProtectedRefCountedDtorInHeader() {} ++ ++ protected: ++ ~ProtectedRefCountedDtorInHeader() {} ++ ++ private: ++ friend class base::RefCounted; ++}; ++ ++// Safe; should not have errors. ++class PrivateRefCountedDtorInHeader ++ : public base::RefCounted { ++ public: ++ PrivateRefCountedDtorInHeader() {} ++ ++ private: ++ ~PrivateRefCountedDtorInHeader() {} ++ friend class base::RefCounted; ++}; ++ ++// Unsafe; A grandchild class ends up exposing their parent and grandparent's ++// destructors. ++class DerivedProtectedToPublicInHeader ++ : public ProtectedRefCountedDtorInHeader { ++ public: ++ DerivedProtectedToPublicInHeader() {} ++ ~DerivedProtectedToPublicInHeader() {} ++}; ++ ++// Unsafe; A grandchild ends up implicitly exposing their parent and ++// grantparent's destructors. ++class ImplicitDerivedProtectedToPublicInHeader ++ : public ProtectedRefCountedDtorInHeader { ++ public: ++ ImplicitDerivedProtectedToPublicInHeader() {} ++}; ++ ++// Unsafe-but-ignored; should not have errors. ++class WebKitPublicDtorInHeader ++ : public WebKit::RefCounted { ++ public: ++ WebKitPublicDtorInHeader() {} ++ ~WebKitPublicDtorInHeader() {} ++}; ++ ++// Unsafe-but-ignored; should not have errors. ++class WebKitDerivedPublicDtorInHeader ++ : public WebKitPublicDtorInHeader { ++ public: ++ WebKitDerivedPublicDtorInHeader() {} ++ ~WebKitDerivedPublicDtorInHeader() {} ++}; ++ ++#endif // BASE_REFCOUNTED_H_ +diff --git a/tools/clang/plugins/tests/base_refcounted.txt b/tools/clang/plugins/tests/base_refcounted.txt +new file mode 100644 +index 0000000000..4626424177 +--- /dev/null ++++ b/tools/clang/plugins/tests/base_refcounted.txt +@@ -0,0 +1,23 @@ ++In file included from base_refcounted.cpp:5: ++./base_refcounted.h:45:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. ++ ~PublicRefCountedDtorInHeader() {} ++ ^ ++./base_refcounted.h:57:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. ++ ~PublicRefCountedThreadSafeDtorInHeader() {} ++ ^ ++./base_refcounted.h:94:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. ++ ~DerivedProtectedToPublicInHeader() {} ++ ^ ++./base_refcounted.h:99:1: warning: [chromium-style] Classes that are ref-counted should have explicit destructors that are protected or private. ++class ImplicitDerivedProtectedToPublicInHeader ++^ ++base_refcounted.cpp:16:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. ++ ~AnonymousDerivedProtectedToPublicInImpl() {} ++ ^ ++base_refcounted.cpp:26:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. ++ ~PublicRefCountedDtorInImpl() {} ++ ^ ++base_refcounted.cpp:52:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. ++ ~UnsafeTypedefChainInImpl() {} ++ ^ ++7 warnings generated. +diff --git a/tools/clang/plugins/tests/inline_copy_ctor.cpp b/tools/clang/plugins/tests/inline_copy_ctor.cpp +new file mode 100644 +index 0000000000..dcd90020c5 +--- /dev/null ++++ b/tools/clang/plugins/tests/inline_copy_ctor.cpp +@@ -0,0 +1,5 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "inline_copy_ctor.h" +diff --git a/tools/clang/plugins/tests/inline_copy_ctor.h b/tools/clang/plugins/tests/inline_copy_ctor.h +new file mode 100644 +index 0000000000..619a18392b +--- /dev/null ++++ b/tools/clang/plugins/tests/inline_copy_ctor.h +@@ -0,0 +1,12 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++struct C { ++ C(); ++ ~C(); ++ ++ static C foo() { return C(); } ++ ++ int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p , q, r, s, t, u, v, w, x; ++}; +diff --git a/tools/clang/plugins/tests/inline_copy_ctor.txt b/tools/clang/plugins/tests/inline_copy_ctor.txt +new file mode 100644 +index 0000000000..bc4bd8911e +--- /dev/null ++++ b/tools/clang/plugins/tests/inline_copy_ctor.txt +@@ -0,0 +1,5 @@ ++In file included from inline_copy_ctor.cpp:5: ++./inline_copy_ctor.h:5:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line copy constructor. ++struct C { ++^ ++1 warning generated. +diff --git a/tools/clang/plugins/tests/inline_ctor.cpp b/tools/clang/plugins/tests/inline_ctor.cpp +new file mode 100644 +index 0000000000..6a751fb405 +--- /dev/null ++++ b/tools/clang/plugins/tests/inline_ctor.cpp +@@ -0,0 +1,25 @@ ++// Copyright (c) 2011 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "inline_ctor.h" ++ ++#include ++#include ++ ++// We don't warn on classes that are in CPP files. ++class InlineInCPPOK { ++ public: ++ InlineInCPPOK() {} ++ ~InlineInCPPOK() {} ++ ++ private: ++ std::vector one_; ++ std::vector two_; ++}; ++ ++int main() { ++ InlineInCPPOK one; ++ InlineCtorsArentOKInHeader two; ++ return 0; ++} +diff --git a/tools/clang/plugins/tests/inline_ctor.h b/tools/clang/plugins/tests/inline_ctor.h +new file mode 100644 +index 0000000000..d053b2f57d +--- /dev/null ++++ b/tools/clang/plugins/tests/inline_ctor.h +@@ -0,0 +1,21 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef INLINE_CTOR_H_ ++#define INLINE_CTOR_H_ ++ ++#include ++#include ++ ++class InlineCtorsArentOKInHeader { ++ public: ++ InlineCtorsArentOKInHeader() {} ++ ~InlineCtorsArentOKInHeader() {} ++ ++ private: ++ std::vector one_; ++ std::vector two_; ++}; ++ ++#endif // INLINE_CTOR_H_ +diff --git a/tools/clang/plugins/tests/inline_ctor.txt b/tools/clang/plugins/tests/inline_ctor.txt +new file mode 100644 +index 0000000000..caa0cb4e3b +--- /dev/null ++++ b/tools/clang/plugins/tests/inline_ctor.txt +@@ -0,0 +1,8 @@ ++In file included from inline_ctor.cpp:5: ++./inline_ctor.h:13:3: warning: [chromium-style] Complex constructor has an inlined body. ++ InlineCtorsArentOKInHeader() {} ++ ^ ++./inline_ctor.h:14:3: warning: [chromium-style] Complex destructor has an inline body. ++ ~InlineCtorsArentOKInHeader() {} ++ ^ ++2 warnings generated. +diff --git a/tools/clang/plugins/tests/missing_ctor.cpp b/tools/clang/plugins/tests/missing_ctor.cpp +new file mode 100644 +index 0000000000..8ee2fb2ac8 +--- /dev/null ++++ b/tools/clang/plugins/tests/missing_ctor.cpp +@@ -0,0 +1,23 @@ ++// Copyright (c) 2011 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "missing_ctor.h" ++ ++#include ++#include ++ ++// We don't warn on classes that use default ctors in cpp files. ++class MissingInCPPOK { ++ public: ++ ++ private: ++ std::vector one_; ++ std::vector two_; ++}; ++ ++int main() { ++ MissingInCPPOK one; ++ MissingCtorsArentOKInHeader two; ++ return 0; ++} +diff --git a/tools/clang/plugins/tests/missing_ctor.h b/tools/clang/plugins/tests/missing_ctor.h +new file mode 100644 +index 0000000000..1050457a1a +--- /dev/null ++++ b/tools/clang/plugins/tests/missing_ctor.h +@@ -0,0 +1,19 @@ ++// Copyright (c) 2011 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef MISSING_CTOR_H_ ++#define MISSING_CTOR_H_ ++ ++#include ++#include ++ ++class MissingCtorsArentOKInHeader { ++ public: ++ ++ private: ++ std::vector one_; ++ std::vector two_; ++}; ++ ++#endif // MISSING_CTOR_H_ +diff --git a/tools/clang/plugins/tests/missing_ctor.txt b/tools/clang/plugins/tests/missing_ctor.txt +new file mode 100644 +index 0000000000..301449c4ac +--- /dev/null ++++ b/tools/clang/plugins/tests/missing_ctor.txt +@@ -0,0 +1,6 @@ ++In file included from missing_ctor.cpp:5: ++./missing_ctor.h:11:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line constructor. ++class MissingCtorsArentOKInHeader { ++^ ++./missing_ctor.h:11:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line destructor. ++2 warnings generated. +diff --git a/tools/clang/plugins/tests/nested_class_inline_ctor.cpp b/tools/clang/plugins/tests/nested_class_inline_ctor.cpp +new file mode 100644 +index 0000000000..aa90a95eb3 +--- /dev/null ++++ b/tools/clang/plugins/tests/nested_class_inline_ctor.cpp +@@ -0,0 +1,5 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "nested_class_inline_ctor.h" +diff --git a/tools/clang/plugins/tests/nested_class_inline_ctor.h b/tools/clang/plugins/tests/nested_class_inline_ctor.h +new file mode 100644 +index 0000000000..01cfea9232 +--- /dev/null ++++ b/tools/clang/plugins/tests/nested_class_inline_ctor.h +@@ -0,0 +1,22 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef NESTED_CLASS_INLINE_CTOR_H_ ++#define NESTED_CLASS_INLINE_CTOR_H_ ++ ++#include ++#include ++ ++// See crbug.com/136863. ++ ++class Foo { ++ class Bar { ++ Bar() {} ++ ~Bar() {} ++ ++ std::vector a; ++ }; ++}; ++ ++#endif // NESTED_CLASS_INLINE_CTOR_H_ +diff --git a/tools/clang/plugins/tests/nested_class_inline_ctor.txt b/tools/clang/plugins/tests/nested_class_inline_ctor.txt +new file mode 100644 +index 0000000000..39bd6e1dce +--- /dev/null ++++ b/tools/clang/plugins/tests/nested_class_inline_ctor.txt +@@ -0,0 +1,8 @@ ++In file included from nested_class_inline_ctor.cpp:5: ++./nested_class_inline_ctor.h:15:5: warning: [chromium-style] Complex constructor has an inlined body. ++ Bar() {} ++ ^ ++./nested_class_inline_ctor.h:16:5: warning: [chromium-style] Complex destructor has an inline body. ++ ~Bar() {} ++ ^ ++2 warnings generated. +diff --git a/tools/clang/plugins/tests/overridden_methods.cpp b/tools/clang/plugins/tests/overridden_methods.cpp +new file mode 100644 +index 0000000000..f572a41733 +--- /dev/null ++++ b/tools/clang/plugins/tests/overridden_methods.cpp +@@ -0,0 +1,38 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "overridden_methods.h" ++ ++// Fill in the implementations ++void DerivedClass::SomeMethod() {} ++void DerivedClass::SomeOtherMethod() {} ++void DerivedClass::WebKitModifiedSomething() {} ++ ++class ImplementationInterimClass : public BaseClass { ++ public: ++ // Should not warn about pure virtual methods. ++ virtual void SomeMethod() = 0; ++}; ++ ++class ImplementationDerivedClass : public ImplementationInterimClass, ++ public webkit_glue::WebKitObserverImpl { ++ public: ++ // Should not warn about destructors. ++ virtual ~ImplementationDerivedClass() {} ++ // Should warn. ++ virtual void SomeMethod(); ++ // Should not warn if marked as override. ++ virtual void SomeOtherMethod() override; ++ // Should not warn for inline implementations in implementation files. ++ virtual void SomeInlineMethod() {} ++ // Should not warn if overriding a method whose origin is WebKit. ++ virtual void WebKitModifiedSomething(); ++ // Should warn if overridden method isn't pure. ++ virtual void SomeNonPureBaseMethod() {} ++}; ++ ++int main() { ++ DerivedClass something; ++ ImplementationDerivedClass something_else; ++} +diff --git a/tools/clang/plugins/tests/overridden_methods.h b/tools/clang/plugins/tests/overridden_methods.h +new file mode 100644 +index 0000000000..150c79913f +--- /dev/null ++++ b/tools/clang/plugins/tests/overridden_methods.h +@@ -0,0 +1,54 @@ ++// Copyright (c) 2011 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef OVERRIDDEN_METHODS_H_ ++#define OVERRIDDEN_METHODS_H_ ++ ++// Should warn about overriding of methods. ++class BaseClass { ++ public: ++ virtual ~BaseClass() {} ++ virtual void SomeMethod() = 0; ++ virtual void SomeOtherMethod() = 0; ++ virtual void SomeInlineMethod() = 0; ++ virtual void SomeNonPureBaseMethod() {} ++}; ++ ++class InterimClass : public BaseClass { ++ // Should not warn about pure virtual methods. ++ virtual void SomeMethod() = 0; ++}; ++ ++namespace WebKit { ++class WebKitObserver { ++ public: ++ virtual void WebKitModifiedSomething() {}; ++}; ++} // namespace WebKit ++ ++namespace webkit_glue { ++class WebKitObserverImpl : WebKit::WebKitObserver { ++ public: ++ virtual void WebKitModifiedSomething() {}; ++}; ++} // namespace webkit_glue ++ ++class DerivedClass : public InterimClass, ++ public webkit_glue::WebKitObserverImpl { ++ public: ++ // Should not warn about destructors. ++ virtual ~DerivedClass() {} ++ // Should warn. ++ virtual void SomeMethod(); ++ // Should not warn if marked as override. ++ virtual void SomeOtherMethod() override; ++ // Should warn for inline implementations. ++ virtual void SomeInlineMethod() {} ++ // Should not warn if overriding a method whose origin is WebKit. ++ virtual void WebKitModifiedSomething(); ++ // Should warn if overridden method isn't pure. ++ virtual void SomeNonPureBaseMethod() {} ++}; ++ ++#endif // OVERRIDDEN_METHODS_H_ +diff --git a/tools/clang/plugins/tests/overridden_methods.txt b/tools/clang/plugins/tests/overridden_methods.txt +new file mode 100644 +index 0000000000..7553ade70e +--- /dev/null ++++ b/tools/clang/plugins/tests/overridden_methods.txt +@@ -0,0 +1,20 @@ ++In file included from overridden_methods.cpp:5: ++./overridden_methods.h:43:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. ++ virtual void SomeMethod(); ++ ^ ++./overridden_methods.h:47:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. ++ virtual void SomeInlineMethod() {} ++ ^ ++./overridden_methods.h:51:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. ++ virtual void SomeNonPureBaseMethod() {} ++ ^ ++overridden_methods.cpp:24:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. ++ virtual void SomeMethod(); ++ ^ ++overridden_methods.cpp:28:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. ++ virtual void SomeInlineMethod() {} ++ ^ ++overridden_methods.cpp:32:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. ++ virtual void SomeNonPureBaseMethod() {} ++ ^ ++6 warnings generated. +diff --git a/tools/clang/plugins/tests/test.sh b/tools/clang/plugins/tests/test.sh +new file mode 100755 +index 0000000000..262ebbba29 +--- /dev/null ++++ b/tools/clang/plugins/tests/test.sh +@@ -0,0 +1,72 @@ ++#!/bin/bash ++# ++# Copyright (c) 2011 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++# ++# Hacky, primitive testing: This runs the style plugin for a set of input files ++# and compares the output with golden result files. ++ ++E_BADARGS=65 ++E_FAILEDTEST=1 ++ ++failed_any_test= ++ ++# Prints usage information. ++usage() { ++ echo "Usage: $(basename "${0}")" \ ++ "" ++ echo "" ++ echo " Runs all the libFindBadConstructs unit tests" ++ echo "" ++} ++ ++# Runs a single test case. ++do_testcase() { ++ local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \ ++ -Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \ ++ -Xclang -plugin -Xclang find-bad-constructs ${1} 2>&1)" ++ local diffout="$(echo "${output}" | diff - "${2}")" ++ if [ "${diffout}" = "" ]; then ++ echo "PASS: ${1}" ++ else ++ failed_any_test=yes ++ echo "FAIL: ${1}" ++ echo "Output of compiler:" ++ echo "${output}" ++ echo "Expected output:" ++ cat "${2}" ++ echo ++ fi ++} ++ ++# Validate input to the script. ++if [[ -z "${1}" ]]; then ++ usage ++ exit ${E_BADARGS} ++elif [[ ! -d "${1}" ]]; then ++ echo "${1} is not a directory." ++ usage ++ exit ${E_BADARGS} ++else ++ export CLANG_DIR="${PWD}/${1}" ++ echo "Using clang directory ${CLANG_DIR}..." ++ ++ # The golden files assume that the cwd is this directory. To make the script ++ # work no matter what the cwd is, explicitly cd to there. ++ cd "$(dirname "${0}")" ++ ++ if [ "$(uname -s)" = "Linux" ]; then ++ export LIB=so ++ elif [ "$(uname -s)" = "Darwin" ]; then ++ export LIB=dylib ++ fi ++fi ++ ++for input in *.cpp; do ++ do_testcase "${input}" "${input%cpp}txt" ++done ++ ++if [[ "${failed_any_test}" ]]; then ++ exit ${E_FAILEDTEST} ++fi +diff --git a/tools/clang/plugins/tests/virtual_methods.cpp b/tools/clang/plugins/tests/virtual_methods.cpp +new file mode 100644 +index 0000000000..a07cbe4875 +--- /dev/null ++++ b/tools/clang/plugins/tests/virtual_methods.cpp +@@ -0,0 +1,36 @@ ++// Copyright (c) 2012 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "virtual_methods.h" ++ ++// Shouldn't warn about method usage in the implementation file. ++class VirtualMethodsInImplementation { ++ public: ++ virtual void MethodIsAbstract() = 0; ++ virtual void MethodHasNoArguments(); ++ virtual void MethodHasEmptyDefaultImpl() {} ++ virtual bool ComplainAboutThis() { return true; } ++}; ++ ++// Stubs to fill in the abstract method ++class ConcreteVirtualMethodsInHeaders : public VirtualMethodsInHeaders { ++ public: ++ virtual void MethodIsAbstract() override {} ++}; ++ ++class ConcreteVirtualMethodsInImplementation ++ : public VirtualMethodsInImplementation { ++ public: ++ virtual void MethodIsAbstract() override {} ++}; ++ ++// Fill in the implementations ++void VirtualMethodsInHeaders::MethodHasNoArguments() {} ++void WarnOnMissingVirtual::MethodHasNoArguments() {} ++void VirtualMethodsInImplementation::MethodHasNoArguments() {} ++ ++int main() { ++ ConcreteVirtualMethodsInHeaders one; ++ ConcreteVirtualMethodsInImplementation two; ++} +diff --git a/tools/clang/plugins/tests/virtual_methods.h b/tools/clang/plugins/tests/virtual_methods.h +new file mode 100644 +index 0000000000..d9fbf96ed3 +--- /dev/null ++++ b/tools/clang/plugins/tests/virtual_methods.h +@@ -0,0 +1,39 @@ ++// Copyright (c) 2011 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef VIRTUAL_METHODS_H_ ++#define VIRTUAL_METHODS_H_ ++ ++// Should warn about virtual method usage. ++class VirtualMethodsInHeaders { ++ public: ++ // Don't complain about these. ++ virtual void MethodIsAbstract() = 0; ++ virtual void MethodHasNoArguments(); ++ virtual void MethodHasEmptyDefaultImpl() {} ++ ++ // But complain about this: ++ virtual bool ComplainAboutThis() { return true; } ++}; ++ ++// Complain on missing 'virtual' keyword in overrides. ++class WarnOnMissingVirtual : public VirtualMethodsInHeaders { ++ public: ++ void MethodHasNoArguments() override; ++}; ++ ++// Don't complain about things in a 'testing' namespace. ++namespace testing { ++struct TestStruct {}; ++} // namespace testing ++ ++class VirtualMethodsInHeadersTesting : public VirtualMethodsInHeaders { ++ public: ++ // Don't complain about no virtual testing methods. ++ void MethodHasNoArguments(); ++ private: ++ testing::TestStruct tester_; ++}; ++ ++#endif // VIRTUAL_METHODS_H_ +diff --git a/tools/clang/plugins/tests/virtual_methods.txt b/tools/clang/plugins/tests/virtual_methods.txt +new file mode 100644 +index 0000000000..571d6d667d +--- /dev/null ++++ b/tools/clang/plugins/tests/virtual_methods.txt +@@ -0,0 +1,8 @@ ++In file included from virtual_methods.cpp:5: ++./virtual_methods.h:17:36: warning: [chromium-style] virtual methods with non-empty bodies shouldn't be declared inline. ++ virtual bool ComplainAboutThis() { return true; } ++ ^ ++./virtual_methods.h:23:3: warning: [chromium-style] Overriding method must have "virtual" keyword. ++ void MethodHasNoArguments() override; ++ ^ ++2 warnings generated. +diff --git a/tools/clang/scripts/package.sh b/tools/clang/scripts/package.sh +new file mode 100755 +index 0000000000..eb345810b9 +--- /dev/null ++++ b/tools/clang/scripts/package.sh +@@ -0,0 +1,87 @@ ++#!/bin/bash ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++# This script will check out llvm and clang, and then package the results up ++# to a tgz file. ++ ++THIS_DIR="$(dirname "${0}")" ++LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" ++LLVM_BOOTSTRAP_DIR="${THIS_DIR}/../../../third_party/llvm-bootstrap" ++LLVM_BUILD_DIR="${THIS_DIR}/../../../third_party/llvm-build" ++LLVM_BIN_DIR="${LLVM_BUILD_DIR}/Release+Asserts/bin" ++LLVM_LIB_DIR="${LLVM_BUILD_DIR}/Release+Asserts/lib" ++ ++echo "Diff in llvm:" | tee buildlog.txt ++svn stat "${LLVM_DIR}" 2>&1 | tee -a buildlog.txt ++svn diff "${LLVM_DIR}" 2>&1 | tee -a buildlog.txt ++echo "Diff in llvm/tools/clang:" | tee -a buildlog.txt ++svn stat "${LLVM_DIR}/tools/clang" 2>&1 | tee -a buildlog.txt ++svn diff "${LLVM_DIR}/tools/clang" 2>&1 | tee -a buildlog.txt ++echo "Diff in llvm/projects/compiler-rt:" | tee -a buildlog.txt ++svn stat "${LLVM_DIR}/projects/compiler-rt" 2>&1 | tee -a buildlog.txt ++svn diff "${LLVM_DIR}/projects/compiler-rt" 2>&1 | tee -a buildlog.txt ++ ++echo "Starting build" | tee -a buildlog.txt ++ ++set -ex ++ ++# Do a clobber build. ++rm -rf "${LLVM_BOOTSTRAP_DIR}" ++rm -rf "${LLVM_BUILD_DIR}" ++"${THIS_DIR}"/update.sh --run-tests --bootstrap --force-local-build 2>&1 | \ ++ tee -a buildlog.txt ++ ++R=$("${LLVM_BIN_DIR}/clang" --version | \ ++ sed -ne 's/clang version .*(trunk \([0-9]*\))/\1/p') ++ ++PDIR=clang-$R ++rm -rf $PDIR ++mkdir $PDIR ++mkdir $PDIR/bin ++mkdir $PDIR/lib ++ ++# Copy buildlog over. ++cp buildlog.txt $PDIR/ ++ ++# Copy clang into pdir, symlink clang++ to it. ++cp "${LLVM_BIN_DIR}/clang" $PDIR/bin/ ++(cd $PDIR/bin && ln -sf clang clang++ && cd -) ++ ++# Copy plugins. Some of the dylibs are pretty big, so copy only the ones we ++# care about. ++if [ "$(uname -s)" = "Darwin" ]; then ++ cp "${LLVM_LIB_DIR}/libFindBadConstructs.dylib" $PDIR/lib ++else ++ cp "${LLVM_LIB_DIR}/libFindBadConstructs.so" $PDIR/lib ++fi ++ ++# Copy built-in headers (lib/clang/3.2/include). ++# libcompiler-rt puts all kinds of libraries there too, but we want only ASan. ++if [ "$(uname -s)" = "Darwin" ]; then ++ # Keep only Release+Asserts/lib/clang/3.2/lib/darwin/libclang_rt.asan_osx.a ++ find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/darwin*' | grep -v asan | \ ++ xargs rm ++else ++ # Keep only ++ # Release+Asserts/lib/clang/3.2/lib/linux/libclang_rt.{asan,tsan}-x86_64.a ++ # TODO(thakis): Make sure the 32bit version of ASan runtime is kept too once ++ # that's built. TSan runtime exists only for 64 bits. ++ find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/linux*' | \ ++ grep -v "asan\|tsan" | xargs rm ++fi ++ ++cp -R "${LLVM_LIB_DIR}/clang" $PDIR/lib ++ ++tar zcf $PDIR.tgz -C $PDIR bin lib buildlog.txt ++ ++if [ "$(uname -s)" = "Darwin" ]; then ++ PLATFORM=Mac ++else ++ PLATFORM=Linux_x64 ++fi ++ ++echo To upload, run: ++echo gsutil cp -a public-read $PDIR.tgz \ ++ gs://chromium-browser-clang/$PLATFORM/$PDIR.tgz +diff --git a/tools/clang/scripts/plugin_flags.sh b/tools/clang/scripts/plugin_flags.sh +new file mode 100755 +index 0000000000..217c5c3bd6 +--- /dev/null ++++ b/tools/clang/scripts/plugin_flags.sh +@@ -0,0 +1,24 @@ ++#!/bin/bash ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++# This script returns the flags that should be used when GYP_DEFINES contains ++# clang_use_chrome_plugins. The flags are stored in a script so that they can ++# be changed on the bots without requiring a master restart. ++ ++THIS_ABS_DIR=$(cd $(dirname $0) && echo $PWD) ++CLANG_LIB_PATH=$THIS_ABS_DIR/../../../third_party/llvm-build/Release+Asserts/lib ++ ++if uname -s | grep -q Darwin; then ++ LIBSUFFIX=dylib ++else ++ LIBSUFFIX=so ++fi ++ ++echo -Xclang -load -Xclang $CLANG_LIB_PATH/libFindBadConstructs.$LIBSUFFIX \ ++ -Xclang -add-plugin -Xclang find-bad-constructs \ ++ -Xclang -plugin-arg-find-bad-constructs \ ++ -Xclang skip-virtuals-in-implementations \ ++ -Xclang -plugin-arg-find-bad-constructs \ ++ -Xclang check-cc-directory +diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py +new file mode 100755 +index 0000000000..bdc781f715 +--- /dev/null ++++ b/tools/clang/scripts/update.py +@@ -0,0 +1,34 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Windows can't run .sh files, so this is a small python wrapper around ++update.sh. ++""" ++ ++import os ++import subprocess ++import sys ++ ++ ++def main(): ++ if sys.platform in ['win32', 'cygwin']: ++ return 0 ++ ++ # This script is called by gclient. gclient opens its hooks subprocesses with ++ # (stdout=subprocess.PIPE, stderr=subprocess.STDOUT) and then does custom ++ # output processing that breaks printing '\r' characters for single-line ++ # updating status messages as printed by curl and wget. ++ # Work around this by setting stderr of the update.sh process to stdin (!): ++ # gclient doesn't redirect stdin, and while stdin itself is read-only, a ++ # dup()ed sys.stdin is writable, try ++ # fd2 = os.dup(sys.stdin.fileno()); os.write(fd2, 'hi') ++ # TODO: Fix gclient instead, http://crbug.com/95350 ++ return subprocess.call( ++ [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:], ++ stderr=os.fdopen(os.dup(sys.stdin.fileno()))) ++ ++ ++if __name__ == '__main__': ++ sys.exit(main()) +diff --git a/tools/clang/scripts/update.sh b/tools/clang/scripts/update.sh +new file mode 100755 +index 0000000000..e9448236c8 +--- /dev/null ++++ b/tools/clang/scripts/update.sh +@@ -0,0 +1,286 @@ ++#!/usr/bin/env bash ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++# This script will check out llvm and clang into third_party/llvm and build it. ++ ++# Do NOT CHANGE this if you don't know what you're doing -- see ++# https://code.google.com/p/chromium/wiki/UpdatingClang ++# Reverting problematic clang rolls is safe, though. ++CLANG_REVISION=163674 ++ ++THIS_DIR="$(dirname "${0}")" ++LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" ++LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" ++LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" ++CLANG_DIR="${LLVM_DIR}/tools/clang" ++COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" ++STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" ++ ++# ${A:-a} returns $A if it's set, a else. ++LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} ++ ++# Die if any command dies. ++set -e ++ ++OS="$(uname -s)" ++ ++# Parse command line options. ++force_local_build= ++mac_only= ++run_tests= ++bootstrap= ++while [[ $# > 0 ]]; do ++ case $1 in ++ --bootstrap) ++ bootstrap=yes ++ ;; ++ --force-local-build) ++ force_local_build=yes ++ ;; ++ --mac-only) ++ mac_only=yes ++ ;; ++ --run-tests) ++ run_tests=yes ++ ;; ++ --help) ++ echo "usage: $0 [--force-local-build] [--mac-only] [--run-tests] " ++ echo "--bootstrap: First build clang with CC, then with itself." ++ echo "--force-local-build: Don't try to download prebuilt binaries." ++ echo "--mac-only: Do initial download only on Mac systems." ++ echo "--run-tests: Run tests after building. Only for local builds." ++ exit 1 ++ ;; ++ esac ++ shift ++done ++ ++# --mac-only prevents the initial download on non-mac systems, but if clang has ++# already been downloaded in the past, this script keeps it up to date even if ++# --mac-only is passed in and the system isn't a mac. People who don't like this ++# can just delete their third_party/llvm-build directory. ++if [[ -n "$mac_only" ]] && [[ "${OS}" != "Darwin" ]] && ++ [[ "$GYP_DEFINES" != *clang=1* ]] && ! [[ -d "${LLVM_BUILD_DIR}" ]]; then ++ exit 0 ++fi ++ ++# Xcode and clang don't get along when predictive compilation is enabled. ++# http://crbug.com/96315 ++if [[ "${OS}" = "Darwin" ]] && xcodebuild -version | grep -q 'Xcode 3.2' ; then ++ XCONF=com.apple.Xcode ++ if [[ "${GYP_GENERATORS}" != "make" ]] && \ ++ [ "$(defaults read "${XCONF}" EnablePredictiveCompilation)" != "0" ]; then ++ echo ++ echo " HEARKEN!" ++ echo "You're using Xcode3 and you have 'Predictive Compilation' enabled." ++ echo "This does not work well with clang (http://crbug.com/96315)." ++ echo "Disable it in Preferences->Building (lower right), or run" ++ echo " defaults write ${XCONF} EnablePredictiveCompilation -boolean NO" ++ echo "while Xcode is not running." ++ echo ++ fi ++ ++ SUB_VERSION=$(xcodebuild -version | sed -Ene 's/Xcode 3\.2\.([0-9]+)/\1/p') ++ if [[ "${SUB_VERSION}" < 6 ]]; then ++ echo ++ echo " YOUR LD IS BUGGY!" ++ echo "Please upgrade Xcode to at least 3.2.6." ++ echo ++ fi ++fi ++ ++ ++# Check if there's anything to be done, exit early if not. ++if [[ -f "${STAMP_FILE}" ]]; then ++ PREVIOUSLY_BUILT_REVISON=$(cat "${STAMP_FILE}") ++ if [[ -z "$force_local_build" ]] && \ ++ [[ "${PREVIOUSLY_BUILT_REVISON}" = "${CLANG_REVISION}" ]]; then ++ echo "Clang already at ${CLANG_REVISION}" ++ exit 0 ++ fi ++fi ++# To always force a new build if someone interrupts their build half way. ++rm -f "${STAMP_FILE}" ++ ++# Clobber pch files, since they only work with the compiler version that ++# created them. Also clobber .o files, to make sure everything will be built ++# with the new compiler. ++if [[ "${OS}" = "Darwin" ]]; then ++ XCODEBUILD_DIR="${THIS_DIR}/../../../xcodebuild" ++ ++ # Xcode groups .o files by project first, configuration second. ++ if [[ -d "${XCODEBUILD_DIR}" ]]; then ++ echo "Clobbering .o files for Xcode build" ++ find "${XCODEBUILD_DIR}" -name '*.o' -exec rm {} + ++ fi ++fi ++ ++if [ -f "${THIS_DIR}/../../../WebKit.gyp" ]; then ++ # We're inside a WebKit checkout. ++ # TODO(thakis): try to unify the directory layout of the xcode- and ++ # make-based builds. http://crbug.com/110455 ++ MAKE_DIR="${THIS_DIR}/../../../../../../out" ++else ++ # We're inside a Chromium checkout. ++ MAKE_DIR="${THIS_DIR}/../../../out" ++fi ++ ++for CONFIG in Debug Release; do ++ if [[ -d "${MAKE_DIR}/${CONFIG}/obj.target" || ++ -d "${MAKE_DIR}/${CONFIG}/obj.host" ]]; then ++ echo "Clobbering ${CONFIG} PCH and .o files for make build" ++ if [[ -d "${MAKE_DIR}/${CONFIG}/obj.target" ]]; then ++ find "${MAKE_DIR}/${CONFIG}/obj.target" -name '*.gch' -exec rm {} + ++ find "${MAKE_DIR}/${CONFIG}/obj.target" -name '*.o' -exec rm {} + ++ fi ++ if [[ -d "${MAKE_DIR}/${CONFIG}/obj.host" ]]; then ++ find "${MAKE_DIR}/${CONFIG}/obj.host" -name '*.o' -exec rm {} + ++ fi ++ fi ++ ++ # ninja puts its output below ${MAKE_DIR} as well. ++ if [[ -d "${MAKE_DIR}/${CONFIG}/obj" ]]; then ++ echo "Clobbering ${CONFIG} PCH and .o files for ninja build" ++ find "${MAKE_DIR}/${CONFIG}/obj" -name '*.gch' -exec rm {} + ++ find "${MAKE_DIR}/${CONFIG}/obj" -name '*.o' -exec rm {} + ++ find "${MAKE_DIR}/${CONFIG}/obj" -name '*.o.d' -exec rm {} + ++ fi ++ ++ if [[ "${OS}" = "Darwin" ]]; then ++ if [[ -d "${XCODEBUILD_DIR}/${CONFIG}/SharedPrecompiledHeaders" ]]; then ++ echo "Clobbering ${CONFIG} PCH files for Xcode build" ++ rm -rf "${XCODEBUILD_DIR}/${CONFIG}/SharedPrecompiledHeaders" ++ fi ++ fi ++done ++ ++if [[ -z "$force_local_build" ]]; then ++ # Check if there's a prebuilt binary and if so just fetch that. That's faster, ++ # and goma relies on having matching binary hashes on client and server too. ++ CDS_URL=https://commondatastorage.googleapis.com/chromium-browser-clang ++ CDS_FILE="clang-${CLANG_REVISION}.tgz" ++ CDS_OUT_DIR=$(mktemp -d -t clang_download.XXXXXX) ++ CDS_OUTPUT="${CDS_OUT_DIR}/${CDS_FILE}" ++ if [ "${OS}" = "Linux" ]; then ++ CDS_FULL_URL="${CDS_URL}/Linux_x64/${CDS_FILE}" ++ elif [ "${OS}" = "Darwin" ]; then ++ CDS_FULL_URL="${CDS_URL}/Mac/${CDS_FILE}" ++ fi ++ echo Trying to download prebuilt clang ++ if which curl > /dev/null; then ++ curl -L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \ ++ rm -rf "${CDS_OUT_DIR}" ++ elif which wget > /dev/null; then ++ wget "${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}" ++ else ++ echo "Neither curl nor wget found. Please install one of these." ++ exit 1 ++ fi ++ if [ -f "${CDS_OUTPUT}" ]; then ++ rm -rf "${LLVM_BUILD_DIR}/Release+Asserts" ++ mkdir -p "${LLVM_BUILD_DIR}/Release+Asserts" ++ tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}/Release+Asserts" ++ echo clang "${CLANG_REVISION}" unpacked ++ echo "${CLANG_REVISION}" > "${STAMP_FILE}" ++ rm -rf "${CDS_OUT_DIR}" ++ exit 0 ++ else ++ echo Did not find prebuilt clang at r"${CLANG_REVISION}", building ++ fi ++fi ++ ++echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" ++if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ ++ "${LLVM_DIR}"; then ++ echo Checkout failed, retrying ++ rm -rf "${LLVM_DIR}" ++ svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" ++fi ++ ++echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" ++svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" ++ ++echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}" ++svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \ ++ "${COMPILER_RT_DIR}" ++ ++# Echo all commands. ++set -x ++ ++NUM_JOBS=3 ++if [[ "${OS}" = "Linux" ]]; then ++ NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)" ++elif [ "${OS}" = "Darwin" ]; then ++ NUM_JOBS="$(sysctl -n hw.ncpu)" ++fi ++ ++# Build bootstrap clang if requested. ++if [[ -n "${bootstrap}" ]]; then ++ echo "Building bootstrap compiler" ++ mkdir -p "${LLVM_BOOTSTRAP_DIR}" ++ cd "${LLVM_BOOTSTRAP_DIR}" ++ if [[ ! -f ./config.status ]]; then ++ # The bootstrap compiler only needs to be able to build the real compiler, ++ # so it needs no cross-compiler output support. In general, the host ++ # compiler should be as similar to the final compiler as possible, so do ++ # keep --disable-threads & co. ++ ../llvm/configure \ ++ --enable-optimized \ ++ --enable-targets=host-only \ ++ --disable-threads \ ++ --disable-pthreads \ ++ --without-llvmgcc \ ++ --without-llvmgxx ++ MACOSX_DEPLOYMENT_TARGET=10.5 make -j"${NUM_JOBS}" ++ fi ++ if [[ -n "${run_tests}" ]]; then ++ make check-all ++ fi ++ cd - ++ export CC="${PWD}/${LLVM_BOOTSTRAP_DIR}/Release+Asserts/bin/clang" ++ export CXX="${PWD}/${LLVM_BOOTSTRAP_DIR}/Release+Asserts/bin/clang++" ++ echo "Building final compiler" ++fi ++ ++# Build clang (in a separate directory). ++# The clang bots have this path hardcoded in built/scripts/slave/compile.py, ++# so if you change it you also need to change these links. ++mkdir -p "${LLVM_BUILD_DIR}" ++cd "${LLVM_BUILD_DIR}" ++if [[ ! -f ./config.status ]]; then ++ ../llvm/configure \ ++ --enable-optimized \ ++ --disable-threads \ ++ --disable-pthreads \ ++ --without-llvmgcc \ ++ --without-llvmgxx ++fi ++ ++MACOSX_DEPLOYMENT_TARGET=10.5 make -j"${NUM_JOBS}" ++cd - ++ ++# Build plugin. ++# Copy it into the clang tree and use clang's build system to compile the ++# plugin. ++PLUGIN_SRC_DIR="${THIS_DIR}/../plugins" ++PLUGIN_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-plugin" ++PLUGIN_BUILD_DIR="${LLVM_BUILD_DIR}/tools/clang/tools/chrome-plugin" ++rm -rf "${PLUGIN_DST_DIR}" ++cp -R "${PLUGIN_SRC_DIR}" "${PLUGIN_DST_DIR}" ++rm -rf "${PLUGIN_BUILD_DIR}" ++mkdir -p "${PLUGIN_BUILD_DIR}" ++cp "${PLUGIN_SRC_DIR}/Makefile" "${PLUGIN_BUILD_DIR}" ++MACOSX_DEPLOYMENT_TARGET=10.5 make -j"${NUM_JOBS}" -C "${PLUGIN_BUILD_DIR}" ++ ++if [[ -n "$run_tests" ]]; then ++ # Run a few tests. ++ "${PLUGIN_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" ++ cd "${LLVM_BUILD_DIR}" ++ make check-all ++ cd - ++fi ++ ++# After everything is done, log success for this revision. ++echo "${CLANG_REVISION}" > "${STAMP_FILE}" diff --git a/third_party/libwebrtc/moz-patch-stack/0098.patch b/third_party/libwebrtc/moz-patch-stack/0098.patch index 56c8dca72b..1faafdf8cf 100644 --- a/third_party/libwebrtc/moz-patch-stack/0098.patch +++ b/third_party/libwebrtc/moz-patch-stack/0098.patch @@ -1,2186 +1,35362 @@ -From: Dan Minor -Date: Thu, 24 Sep 2020 18:28:00 +0000 -Subject: Bug 1665166 - Move media/webrtc/trunk/* to third-party/libwebrtc; - r=ng +From: Nico Grunbaum +Date: Fri, 30 Apr 2021 21:51:00 +0000 +Subject: Bug 1654112 - Add grit dep for building webrtc on android; r=mjf -Differential Revision: https://phabricator.services.mozilla.com/D91317 -Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/57e3c54bd7b9a0203e19ff1df272d24bb551ed29 +Differential Revision: https://phabricator.services.mozilla.com/D114027 +Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/3cce5e6938f0df87bd9ab12a5f556aceb93dfa1d --- - tools/clang/OWNERS | 2 + - tools/clang/plugins/ChromeClassTester.cpp | 294 ++++++++++++ - tools/clang/plugins/ChromeClassTester.h | 84 ++++ - tools/clang/plugins/FindBadConstructs.cpp | 435 ++++++++++++++++++ - tools/clang/plugins/Makefile | 19 + - tools/clang/plugins/OWNERS | 1 + - tools/clang/plugins/README.chromium | 4 + - tools/clang/plugins/tests/base_refcounted.cpp | 72 +++ - tools/clang/plugins/tests/base_refcounted.h | 121 +++++ - tools/clang/plugins/tests/base_refcounted.txt | 23 + - .../clang/plugins/tests/inline_copy_ctor.cpp | 5 + - tools/clang/plugins/tests/inline_copy_ctor.h | 12 + - .../clang/plugins/tests/inline_copy_ctor.txt | 5 + - tools/clang/plugins/tests/inline_ctor.cpp | 25 + - tools/clang/plugins/tests/inline_ctor.h | 21 + - tools/clang/plugins/tests/inline_ctor.txt | 8 + - tools/clang/plugins/tests/missing_ctor.cpp | 23 + - tools/clang/plugins/tests/missing_ctor.h | 19 + - tools/clang/plugins/tests/missing_ctor.txt | 6 + - .../tests/nested_class_inline_ctor.cpp | 5 + - .../plugins/tests/nested_class_inline_ctor.h | 22 + - .../tests/nested_class_inline_ctor.txt | 8 + - .../plugins/tests/overridden_methods.cpp | 38 ++ - .../clang/plugins/tests/overridden_methods.h | 54 +++ - .../plugins/tests/overridden_methods.txt | 20 + - tools/clang/plugins/tests/test.sh | 72 +++ - tools/clang/plugins/tests/virtual_methods.cpp | 36 ++ - tools/clang/plugins/tests/virtual_methods.h | 39 ++ - tools/clang/plugins/tests/virtual_methods.txt | 8 + - tools/clang/scripts/package.sh | 87 ++++ - tools/clang/scripts/plugin_flags.sh | 24 + - tools/clang/scripts/update.py | 34 ++ - tools/clang/scripts/update.sh | 286 ++++++++++++ - 33 files changed, 1912 insertions(+) - create mode 100644 tools/clang/OWNERS - create mode 100644 tools/clang/plugins/ChromeClassTester.cpp - create mode 100644 tools/clang/plugins/ChromeClassTester.h - create mode 100644 tools/clang/plugins/FindBadConstructs.cpp - create mode 100644 tools/clang/plugins/Makefile - create mode 100644 tools/clang/plugins/OWNERS - create mode 100644 tools/clang/plugins/README.chromium - create mode 100644 tools/clang/plugins/tests/base_refcounted.cpp - create mode 100644 tools/clang/plugins/tests/base_refcounted.h - create mode 100644 tools/clang/plugins/tests/base_refcounted.txt - create mode 100644 tools/clang/plugins/tests/inline_copy_ctor.cpp - create mode 100644 tools/clang/plugins/tests/inline_copy_ctor.h - create mode 100644 tools/clang/plugins/tests/inline_copy_ctor.txt - create mode 100644 tools/clang/plugins/tests/inline_ctor.cpp - create mode 100644 tools/clang/plugins/tests/inline_ctor.h - create mode 100644 tools/clang/plugins/tests/inline_ctor.txt - create mode 100644 tools/clang/plugins/tests/missing_ctor.cpp - create mode 100644 tools/clang/plugins/tests/missing_ctor.h - create mode 100644 tools/clang/plugins/tests/missing_ctor.txt - create mode 100644 tools/clang/plugins/tests/nested_class_inline_ctor.cpp - create mode 100644 tools/clang/plugins/tests/nested_class_inline_ctor.h - create mode 100644 tools/clang/plugins/tests/nested_class_inline_ctor.txt - create mode 100644 tools/clang/plugins/tests/overridden_methods.cpp - create mode 100644 tools/clang/plugins/tests/overridden_methods.h - create mode 100644 tools/clang/plugins/tests/overridden_methods.txt - create mode 100755 tools/clang/plugins/tests/test.sh - create mode 100644 tools/clang/plugins/tests/virtual_methods.cpp - create mode 100644 tools/clang/plugins/tests/virtual_methods.h - create mode 100644 tools/clang/plugins/tests/virtual_methods.txt - create mode 100755 tools/clang/scripts/package.sh - create mode 100755 tools/clang/scripts/plugin_flags.sh - create mode 100755 tools/clang/scripts/update.py - create mode 100755 tools/clang/scripts/update.sh + tools/grit/.gitignore | 1 + + tools/grit/BUILD.gn | 48 + + tools/grit/MANIFEST.in | 3 + + tools/grit/OWNERS | 8 + + tools/grit/PRESUBMIT.py | 22 + + tools/grit/README.md | 19 + + tools/grit/grit.py | 31 + + tools/grit/grit/__init__.py | 19 + + tools/grit/grit/clique.py | 491 +++ + tools/grit/grit/clique_unittest.py | 265 ++ + tools/grit/grit/constants.py | 23 + + tools/grit/grit/exception.py | 139 + + tools/grit/grit/extern/BogoFP.py | 22 + + tools/grit/grit/extern/FP.py | 72 + + tools/grit/grit/extern/__init__.py | 0 + tools/grit/grit/extern/tclib.py | 503 +++ + tools/grit/grit/format/__init__.py | 8 + + tools/grit/grit/format/android_xml.py | 212 ++ + .../grit/grit/format/android_xml_unittest.py | 149 + + tools/grit/grit/format/c_format.py | 95 + + tools/grit/grit/format/c_format_unittest.py | 81 + + .../grit/grit/format/chrome_messages_json.py | 59 + + .../format/chrome_messages_json_unittest.py | 190 + + tools/grit/grit/format/data_pack.py | 321 ++ + tools/grit/grit/format/data_pack_unittest.py | 102 + + .../grit/grit/format/gen_predetermined_ids.py | 144 + + .../format/gen_predetermined_ids_unittest.py | 46 + + tools/grit/grit/format/gzip_string.py | 46 + + .../grit/grit/format/gzip_string_unittest.py | 65 + + tools/grit/grit/format/html_inline.py | 602 ++++ + .../grit/grit/format/html_inline_unittest.py | 927 +++++ + tools/grit/grit/format/minifier.py | 45 + + .../grit/grit/format/policy_templates_json.py | 26 + + .../format/policy_templates_json_unittest.py | 207 ++ + tools/grit/grit/format/rc.py | 474 +++ + tools/grit/grit/format/rc_header.py | 48 + + tools/grit/grit/format/rc_header_unittest.py | 138 + + tools/grit/grit/format/rc_unittest.py | 415 +++ + tools/grit/grit/format/resource_map.py | 159 + + .../grit/grit/format/resource_map_unittest.py | 345 ++ + tools/grit/grit/gather/__init__.py | 8 + + tools/grit/grit/gather/admin_template.py | 62 + + .../grit/gather/admin_template_unittest.py | 115 + + tools/grit/grit/gather/chrome_html.py | 377 ++ + .../grit/grit/gather/chrome_html_unittest.py | 610 ++++ + tools/grit/grit/gather/chrome_scaled_image.py | 157 + + .../gather/chrome_scaled_image_unittest.py | 209 ++ + tools/grit/grit/gather/interface.py | 172 + + tools/grit/grit/gather/json_loader.py | 27 + + tools/grit/grit/gather/policy_json.py | 325 ++ + .../grit/grit/gather/policy_json_unittest.py | 347 ++ + tools/grit/grit/gather/rc.py | 343 ++ + tools/grit/grit/gather/rc_unittest.py | 372 ++ + tools/grit/grit/gather/regexp.py | 82 + + tools/grit/grit/gather/skeleton_gatherer.py | 149 + + tools/grit/grit/gather/tr_html.py | 743 ++++ + tools/grit/grit/gather/tr_html_unittest.py | 524 +++ + tools/grit/grit/gather/txt.py | 38 + + tools/grit/grit/gather/txt_unittest.py | 35 + + tools/grit/grit/grd_reader.py | 238 ++ + tools/grit/grit/grd_reader_unittest.py | 346 ++ + tools/grit/grit/grit-todo.xml | 62 + + tools/grit/grit/grit_runner.py | 334 ++ + tools/grit/grit/grit_runner_unittest.py | 42 + + tools/grit/grit/lazy_re.py | 46 + + tools/grit/grit/lazy_re_unittest.py | 40 + + tools/grit/grit/node/__init__.py | 8 + + tools/grit/grit/node/base.py | 670 ++++ + tools/grit/grit/node/base_unittest.py | 259 ++ + tools/grit/grit/node/brotli_util.py | 29 + + tools/grit/grit/node/custom/__init__.py | 8 + + tools/grit/grit/node/custom/filename.py | 29 + + .../grit/node/custom/filename_unittest.py | 34 + + tools/grit/grit/node/empty.py | 64 + + tools/grit/grit/node/include.py | 170 + + tools/grit/grit/node/include_unittest.py | 134 + + tools/grit/grit/node/mapping.py | 60 + + tools/grit/grit/node/message.py | 362 ++ + tools/grit/grit/node/message_unittest.py | 380 ++ + tools/grit/grit/node/misc.py | 707 ++++ + tools/grit/grit/node/misc_unittest.py | 590 ++++ + tools/grit/grit/node/mock_brotli.py | 10 + + tools/grit/grit/node/node_io.py | 117 + + tools/grit/grit/node/node_io_unittest.py | 182 + + tools/grit/grit/node/structure.py | 375 ++ + tools/grit/grit/node/structure_unittest.py | 178 + + tools/grit/grit/node/variant.py | 41 + + tools/grit/grit/pseudo.py | 129 + + tools/grit/grit/pseudo_rtl.py | 104 + + tools/grit/grit/pseudo_unittest.py | 55 + + tools/grit/grit/shortcuts.py | 93 + + tools/grit/grit/shortcuts_unittest.py | 79 + + tools/grit/grit/tclib.py | 246 ++ + tools/grit/grit/tclib_unittest.py | 180 + + tools/grit/grit/test_suite_all.py | 34 + + tools/grit/grit/testdata/GoogleDesktop.adm | 945 +++++ + tools/grit/grit/testdata/README.txt | 87 + + tools/grit/grit/testdata/about.html | 45 + + tools/grit/grit/testdata/android.xml | 24 + + tools/grit/grit/testdata/bad_browser.html | 16 + + tools/grit/grit/testdata/browser.html | 42 + + tools/grit/grit/testdata/buildinfo.grd | 46 + + tools/grit/grit/testdata/cache_prefix.html | 24 + + .../grit/grit/testdata/cache_prefix_file.html | 25 + + tools/grit/grit/testdata/chat_result.html | 24 + + .../chrome/app/generated_resources.grd | 199 ++ + tools/grit/grit/testdata/chrome_html.html | 6 + + .../grit/testdata/default_100_percent/a.png | Bin 0 -> 159 bytes + .../grit/testdata/default_100_percent/b.png | 1 + + tools/grit/grit/testdata/del_footer.html | 8 + + tools/grit/grit/testdata/del_header.html | 60 + + tools/grit/grit/testdata/deleted.html | 21 + + tools/grit/grit/testdata/depfile.grd | 18 + + tools/grit/grit/testdata/details.html | 10 + + .../grit/testdata/duplicate-name-input.xml | 26 + + tools/grit/grit/testdata/email_result.html | 34 + + tools/grit/grit/testdata/email_thread.html | 10 + + tools/grit/grit/testdata/error.html | 8 + + tools/grit/grit/testdata/explicit_web.html | 11 + + tools/grit/grit/testdata/footer.html | 14 + + .../grit/testdata/generated_resources_fr.xtb | 3079 +++++++++++++++++ + .../grit/testdata/generated_resources_iw.xtb | 4 + + .../grit/testdata/generated_resources_no.xtb | 4 + + tools/grit/grit/testdata/grit_part.grdp | 5 + + tools/grit/grit/testdata/header.html | 39 + + tools/grit/grit/testdata/homepage.html | 37 + + tools/grit/grit/testdata/hover.html | 177 + + tools/grit/grit/testdata/include_test.html | 31 + + tools/grit/grit/testdata/included_sample.html | 1 + + tools/grit/grit/testdata/indexing_speed.html | 58 + + tools/grit/grit/testdata/install_prefs.html | 92 + + tools/grit/grit/testdata/install_prefs2.html | 52 + + .../grit/testdata/klonk-alternate-skeleton.rc | Bin 0 -> 1088 bytes + tools/grit/grit/testdata/klonk.ico | Bin 0 -> 766 bytes + tools/grit/grit/testdata/klonk.rc | Bin 0 -> 9824 bytes + .../grit/grit/testdata/ko_oem_enable_bug.html | 1 + + .../grit/testdata/ko_oem_non_admin_bug.html | 1 + + tools/grit/grit/testdata/mini.html | 36 + + tools/grit/grit/testdata/oem_enable.html | 106 + + tools/grit/grit/testdata/oem_non_admin.html | 39 + + tools/grit/grit/testdata/onebox.html | 21 + + tools/grit/grit/testdata/oneclick.html | 34 + + tools/grit/grit/testdata/password.html | 37 + + tools/grit/grit/testdata/preferences.html | 234 ++ + tools/grit/grit/testdata/preprocess_test.html | 7 + + tools/grit/grit/testdata/privacy.html | 35 + + tools/grit/grit/testdata/quit_apps.html | 49 + + tools/grit/grit/testdata/recrawl.html | 30 + + tools/grit/grit/testdata/resource_ids | 13 + + tools/grit/grit/testdata/script.html | 38 + + tools/grit/grit/testdata/searchbox.html | 22 + + tools/grit/grit/testdata/sidebar_h.html | 82 + + tools/grit/grit/testdata/sidebar_v.html | 267 ++ + tools/grit/grit/testdata/simple-input.xml | 52 + + tools/grit/grit/testdata/simple.html | 3 + + tools/grit/grit/testdata/source.rc | 57 + + .../grit/testdata/special_100_percent/a.png | Bin 0 -> 159 bytes + tools/grit/grit/testdata/status.html | 44 + + .../grit/testdata/structure_variables.html | 4 + + tools/grit/grit/testdata/substitute.grd | 31 + + tools/grit/grit/testdata/substitute.xmb | 10 + + .../grit/grit/testdata/substitute_no_ids.grd | 31 + + tools/grit/grit/testdata/substitute_tmpl.grd | 31 + + tools/grit/grit/testdata/test_css.css | 1 + + tools/grit/grit/testdata/test_html.html | 1 + + tools/grit/grit/testdata/test_js.js | 1 + + tools/grit/grit/testdata/test_svg.svg | 1 + + tools/grit/grit/testdata/test_text.txt | 1 + + tools/grit/grit/testdata/time_related.html | 11 + + tools/grit/grit/testdata/toolbar_about.html | 138 + + .../grit/testdata/tools/grit/resource_ids | 176 + + tools/grit/grit/testdata/transl.rc | 56 + + tools/grit/grit/testdata/versions.html | 7 + + tools/grit/grit/testdata/whitelist.txt | 4 + + .../grit/testdata/whitelist_resources.grd | 54 + + .../grit/grit/testdata/whitelist_strings.grd | 23 + + tools/grit/grit/tool/__init__.py | 8 + + tools/grit/grit/tool/android2grd.py | 484 +++ + tools/grit/grit/tool/android2grd_unittest.py | 181 + + tools/grit/grit/tool/build.py | 556 +++ + tools/grit/grit/tool/build_unittest.py | 341 ++ + tools/grit/grit/tool/buildinfo.py | 78 + + tools/grit/grit/tool/buildinfo_unittest.py | 90 + + tools/grit/grit/tool/count.py | 52 + + tools/grit/grit/tool/diff_structures.py | 119 + + .../grit/tool/diff_structures_unittest.py | 46 + + tools/grit/grit/tool/interface.py | 62 + + tools/grit/grit/tool/menu_from_parts.py | 79 + + tools/grit/grit/tool/newgrd.py | 85 + + tools/grit/grit/tool/newgrd_unittest.py | 51 + + tools/grit/grit/tool/postprocess_interface.py | 29 + + tools/grit/grit/tool/postprocess_unittest.py | 64 + + tools/grit/grit/tool/preprocess_interface.py | 25 + + tools/grit/grit/tool/preprocess_unittest.py | 50 + + tools/grit/grit/tool/rc2grd.py | 418 +++ + tools/grit/grit/tool/rc2grd_unittest.py | 163 + + tools/grit/grit/tool/resize.py | 295 ++ + tools/grit/grit/tool/test.py | 24 + + tools/grit/grit/tool/transl2tc.py | 251 ++ + tools/grit/grit/tool/transl2tc_unittest.py | 133 + + tools/grit/grit/tool/unit.py | 43 + + .../grit/tool/update_resource_ids/__init__.py | 305 ++ + .../grit/tool/update_resource_ids/assigner.py | 286 ++ + .../update_resource_ids/assigner_unittest.py | 154 + + .../grit/tool/update_resource_ids/common.py | 101 + + .../grit/tool/update_resource_ids/parser.py | 231 ++ + .../grit/tool/update_resource_ids/reader.py | 83 + + tools/grit/grit/tool/xmb.py | 295 ++ + tools/grit/grit/tool/xmb_unittest.py | 132 + + tools/grit/grit/util.py | 691 ++++ + tools/grit/grit/util_unittest.py | 118 + + tools/grit/grit/xtb_reader.py | 140 + + tools/grit/grit/xtb_reader_unittest.py | 110 + + tools/grit/grit_info.py | 173 + + tools/grit/grit_rule.gni | 485 +++ + tools/grit/minify_with_uglify.py | 44 + + tools/grit/minimize_css.py | 105 + + tools/grit/minimize_css_unittest.py | 58 + + tools/grit/pak_util.py | 223 ++ + tools/grit/repack.gni | 189 + + tools/grit/setup.py | 46 + + tools/grit/stamp_grit_sources.py | 57 + + tools/grit/third_party/six/LICENSE | 18 + + tools/grit/third_party/six/README | 16 + + tools/grit/third_party/six/README.chromium | 13 + + tools/grit/third_party/six/__init__.py | 868 +++++ + 226 files changed, 33440 insertions(+) + create mode 100644 tools/grit/.gitignore + create mode 100644 tools/grit/BUILD.gn + create mode 100644 tools/grit/MANIFEST.in + create mode 100644 tools/grit/OWNERS + create mode 100644 tools/grit/PRESUBMIT.py + create mode 100644 tools/grit/README.md + create mode 100644 tools/grit/grit.py + create mode 100644 tools/grit/grit/__init__.py + create mode 100644 tools/grit/grit/clique.py + create mode 100644 tools/grit/grit/clique_unittest.py + create mode 100644 tools/grit/grit/constants.py + create mode 100644 tools/grit/grit/exception.py + create mode 100644 tools/grit/grit/extern/BogoFP.py + create mode 100644 tools/grit/grit/extern/FP.py + create mode 100644 tools/grit/grit/extern/__init__.py + create mode 100644 tools/grit/grit/extern/tclib.py + create mode 100644 tools/grit/grit/format/__init__.py + create mode 100644 tools/grit/grit/format/android_xml.py + create mode 100644 tools/grit/grit/format/android_xml_unittest.py + create mode 100644 tools/grit/grit/format/c_format.py + create mode 100644 tools/grit/grit/format/c_format_unittest.py + create mode 100644 tools/grit/grit/format/chrome_messages_json.py + create mode 100644 tools/grit/grit/format/chrome_messages_json_unittest.py + create mode 100644 tools/grit/grit/format/data_pack.py + create mode 100644 tools/grit/grit/format/data_pack_unittest.py + create mode 100644 tools/grit/grit/format/gen_predetermined_ids.py + create mode 100644 tools/grit/grit/format/gen_predetermined_ids_unittest.py + create mode 100644 tools/grit/grit/format/gzip_string.py + create mode 100644 tools/grit/grit/format/gzip_string_unittest.py + create mode 100644 tools/grit/grit/format/html_inline.py + create mode 100644 tools/grit/grit/format/html_inline_unittest.py + create mode 100644 tools/grit/grit/format/minifier.py + create mode 100644 tools/grit/grit/format/policy_templates_json.py + create mode 100644 tools/grit/grit/format/policy_templates_json_unittest.py + create mode 100644 tools/grit/grit/format/rc.py + create mode 100644 tools/grit/grit/format/rc_header.py + create mode 100644 tools/grit/grit/format/rc_header_unittest.py + create mode 100644 tools/grit/grit/format/rc_unittest.py + create mode 100644 tools/grit/grit/format/resource_map.py + create mode 100644 tools/grit/grit/format/resource_map_unittest.py + create mode 100644 tools/grit/grit/gather/__init__.py + create mode 100644 tools/grit/grit/gather/admin_template.py + create mode 100644 tools/grit/grit/gather/admin_template_unittest.py + create mode 100644 tools/grit/grit/gather/chrome_html.py + create mode 100644 tools/grit/grit/gather/chrome_html_unittest.py + create mode 100644 tools/grit/grit/gather/chrome_scaled_image.py + create mode 100644 tools/grit/grit/gather/chrome_scaled_image_unittest.py + create mode 100644 tools/grit/grit/gather/interface.py + create mode 100644 tools/grit/grit/gather/json_loader.py + create mode 100644 tools/grit/grit/gather/policy_json.py + create mode 100644 tools/grit/grit/gather/policy_json_unittest.py + create mode 100644 tools/grit/grit/gather/rc.py + create mode 100644 tools/grit/grit/gather/rc_unittest.py + create mode 100644 tools/grit/grit/gather/regexp.py + create mode 100644 tools/grit/grit/gather/skeleton_gatherer.py + create mode 100644 tools/grit/grit/gather/tr_html.py + create mode 100644 tools/grit/grit/gather/tr_html_unittest.py + create mode 100644 tools/grit/grit/gather/txt.py + create mode 100644 tools/grit/grit/gather/txt_unittest.py + create mode 100644 tools/grit/grit/grd_reader.py + create mode 100644 tools/grit/grit/grd_reader_unittest.py + create mode 100644 tools/grit/grit/grit-todo.xml + create mode 100644 tools/grit/grit/grit_runner.py + create mode 100644 tools/grit/grit/grit_runner_unittest.py + create mode 100644 tools/grit/grit/lazy_re.py + create mode 100644 tools/grit/grit/lazy_re_unittest.py + create mode 100644 tools/grit/grit/node/__init__.py + create mode 100644 tools/grit/grit/node/base.py + create mode 100644 tools/grit/grit/node/base_unittest.py + create mode 100644 tools/grit/grit/node/brotli_util.py + create mode 100644 tools/grit/grit/node/custom/__init__.py + create mode 100644 tools/grit/grit/node/custom/filename.py + create mode 100644 tools/grit/grit/node/custom/filename_unittest.py + create mode 100644 tools/grit/grit/node/empty.py + create mode 100644 tools/grit/grit/node/include.py + create mode 100644 tools/grit/grit/node/include_unittest.py + create mode 100644 tools/grit/grit/node/mapping.py + create mode 100644 tools/grit/grit/node/message.py + create mode 100644 tools/grit/grit/node/message_unittest.py + create mode 100644 tools/grit/grit/node/misc.py + create mode 100644 tools/grit/grit/node/misc_unittest.py + create mode 100644 tools/grit/grit/node/mock_brotli.py + create mode 100644 tools/grit/grit/node/node_io.py + create mode 100644 tools/grit/grit/node/node_io_unittest.py + create mode 100644 tools/grit/grit/node/structure.py + create mode 100644 tools/grit/grit/node/structure_unittest.py + create mode 100644 tools/grit/grit/node/variant.py + create mode 100644 tools/grit/grit/pseudo.py + create mode 100644 tools/grit/grit/pseudo_rtl.py + create mode 100644 tools/grit/grit/pseudo_unittest.py + create mode 100644 tools/grit/grit/shortcuts.py + create mode 100644 tools/grit/grit/shortcuts_unittest.py + create mode 100644 tools/grit/grit/tclib.py + create mode 100644 tools/grit/grit/tclib_unittest.py + create mode 100644 tools/grit/grit/test_suite_all.py + create mode 100644 tools/grit/grit/testdata/GoogleDesktop.adm + create mode 100644 tools/grit/grit/testdata/README.txt + create mode 100644 tools/grit/grit/testdata/about.html + create mode 100644 tools/grit/grit/testdata/android.xml + create mode 100644 tools/grit/grit/testdata/bad_browser.html + create mode 100644 tools/grit/grit/testdata/browser.html + create mode 100644 tools/grit/grit/testdata/buildinfo.grd + create mode 100644 tools/grit/grit/testdata/cache_prefix.html + create mode 100644 tools/grit/grit/testdata/cache_prefix_file.html + create mode 100644 tools/grit/grit/testdata/chat_result.html + create mode 100644 tools/grit/grit/testdata/chrome/app/generated_resources.grd + create mode 100644 tools/grit/grit/testdata/chrome_html.html + create mode 100644 tools/grit/grit/testdata/default_100_percent/a.png + create mode 100644 tools/grit/grit/testdata/default_100_percent/b.png + create mode 100644 tools/grit/grit/testdata/del_footer.html + create mode 100644 tools/grit/grit/testdata/del_header.html + create mode 100644 tools/grit/grit/testdata/deleted.html + create mode 100644 tools/grit/grit/testdata/depfile.grd + create mode 100644 tools/grit/grit/testdata/details.html + create mode 100644 tools/grit/grit/testdata/duplicate-name-input.xml + create mode 100644 tools/grit/grit/testdata/email_result.html + create mode 100644 tools/grit/grit/testdata/email_thread.html + create mode 100644 tools/grit/grit/testdata/error.html + create mode 100644 tools/grit/grit/testdata/explicit_web.html + create mode 100644 tools/grit/grit/testdata/footer.html + create mode 100644 tools/grit/grit/testdata/generated_resources_fr.xtb + create mode 100644 tools/grit/grit/testdata/generated_resources_iw.xtb + create mode 100644 tools/grit/grit/testdata/generated_resources_no.xtb + create mode 100644 tools/grit/grit/testdata/grit_part.grdp + create mode 100644 tools/grit/grit/testdata/header.html + create mode 100644 tools/grit/grit/testdata/homepage.html + create mode 100644 tools/grit/grit/testdata/hover.html + create mode 100644 tools/grit/grit/testdata/include_test.html + create mode 100644 tools/grit/grit/testdata/included_sample.html + create mode 100644 tools/grit/grit/testdata/indexing_speed.html + create mode 100644 tools/grit/grit/testdata/install_prefs.html + create mode 100644 tools/grit/grit/testdata/install_prefs2.html + create mode 100644 tools/grit/grit/testdata/klonk-alternate-skeleton.rc + create mode 100644 tools/grit/grit/testdata/klonk.ico + create mode 100644 tools/grit/grit/testdata/klonk.rc + create mode 100644 tools/grit/grit/testdata/ko_oem_enable_bug.html + create mode 100644 tools/grit/grit/testdata/ko_oem_non_admin_bug.html + create mode 100644 tools/grit/grit/testdata/mini.html + create mode 100644 tools/grit/grit/testdata/oem_enable.html + create mode 100644 tools/grit/grit/testdata/oem_non_admin.html + create mode 100644 tools/grit/grit/testdata/onebox.html + create mode 100644 tools/grit/grit/testdata/oneclick.html + create mode 100644 tools/grit/grit/testdata/password.html + create mode 100644 tools/grit/grit/testdata/preferences.html + create mode 100644 tools/grit/grit/testdata/preprocess_test.html + create mode 100644 tools/grit/grit/testdata/privacy.html + create mode 100644 tools/grit/grit/testdata/quit_apps.html + create mode 100644 tools/grit/grit/testdata/recrawl.html + create mode 100644 tools/grit/grit/testdata/resource_ids + create mode 100644 tools/grit/grit/testdata/script.html + create mode 100644 tools/grit/grit/testdata/searchbox.html + create mode 100644 tools/grit/grit/testdata/sidebar_h.html + create mode 100644 tools/grit/grit/testdata/sidebar_v.html + create mode 100644 tools/grit/grit/testdata/simple-input.xml + create mode 100644 tools/grit/grit/testdata/simple.html + create mode 100644 tools/grit/grit/testdata/source.rc + create mode 100644 tools/grit/grit/testdata/special_100_percent/a.png + create mode 100644 tools/grit/grit/testdata/status.html + create mode 100644 tools/grit/grit/testdata/structure_variables.html + create mode 100644 tools/grit/grit/testdata/substitute.grd + create mode 100644 tools/grit/grit/testdata/substitute.xmb + create mode 100644 tools/grit/grit/testdata/substitute_no_ids.grd + create mode 100644 tools/grit/grit/testdata/substitute_tmpl.grd + create mode 100644 tools/grit/grit/testdata/test_css.css + create mode 100644 tools/grit/grit/testdata/test_html.html + create mode 100644 tools/grit/grit/testdata/test_js.js + create mode 100644 tools/grit/grit/testdata/test_svg.svg + create mode 100644 tools/grit/grit/testdata/test_text.txt + create mode 100644 tools/grit/grit/testdata/time_related.html + create mode 100644 tools/grit/grit/testdata/toolbar_about.html + create mode 100644 tools/grit/grit/testdata/tools/grit/resource_ids + create mode 100644 tools/grit/grit/testdata/transl.rc + create mode 100644 tools/grit/grit/testdata/versions.html + create mode 100644 tools/grit/grit/testdata/whitelist.txt + create mode 100644 tools/grit/grit/testdata/whitelist_resources.grd + create mode 100644 tools/grit/grit/testdata/whitelist_strings.grd + create mode 100644 tools/grit/grit/tool/__init__.py + create mode 100644 tools/grit/grit/tool/android2grd.py + create mode 100644 tools/grit/grit/tool/android2grd_unittest.py + create mode 100644 tools/grit/grit/tool/build.py + create mode 100644 tools/grit/grit/tool/build_unittest.py + create mode 100644 tools/grit/grit/tool/buildinfo.py + create mode 100644 tools/grit/grit/tool/buildinfo_unittest.py + create mode 100644 tools/grit/grit/tool/count.py + create mode 100644 tools/grit/grit/tool/diff_structures.py + create mode 100644 tools/grit/grit/tool/diff_structures_unittest.py + create mode 100644 tools/grit/grit/tool/interface.py + create mode 100644 tools/grit/grit/tool/menu_from_parts.py + create mode 100644 tools/grit/grit/tool/newgrd.py + create mode 100644 tools/grit/grit/tool/newgrd_unittest.py + create mode 100644 tools/grit/grit/tool/postprocess_interface.py + create mode 100644 tools/grit/grit/tool/postprocess_unittest.py + create mode 100644 tools/grit/grit/tool/preprocess_interface.py + create mode 100644 tools/grit/grit/tool/preprocess_unittest.py + create mode 100644 tools/grit/grit/tool/rc2grd.py + create mode 100644 tools/grit/grit/tool/rc2grd_unittest.py + create mode 100644 tools/grit/grit/tool/resize.py + create mode 100644 tools/grit/grit/tool/test.py + create mode 100644 tools/grit/grit/tool/transl2tc.py + create mode 100644 tools/grit/grit/tool/transl2tc_unittest.py + create mode 100644 tools/grit/grit/tool/unit.py + create mode 100644 tools/grit/grit/tool/update_resource_ids/__init__.py + create mode 100644 tools/grit/grit/tool/update_resource_ids/assigner.py + create mode 100644 tools/grit/grit/tool/update_resource_ids/assigner_unittest.py + create mode 100644 tools/grit/grit/tool/update_resource_ids/common.py + create mode 100644 tools/grit/grit/tool/update_resource_ids/parser.py + create mode 100644 tools/grit/grit/tool/update_resource_ids/reader.py + create mode 100644 tools/grit/grit/tool/xmb.py + create mode 100644 tools/grit/grit/tool/xmb_unittest.py + create mode 100644 tools/grit/grit/util.py + create mode 100644 tools/grit/grit/util_unittest.py + create mode 100644 tools/grit/grit/xtb_reader.py + create mode 100644 tools/grit/grit/xtb_reader_unittest.py + create mode 100644 tools/grit/grit_info.py + create mode 100644 tools/grit/grit_rule.gni + create mode 100644 tools/grit/minify_with_uglify.py + create mode 100644 tools/grit/minimize_css.py + create mode 100644 tools/grit/minimize_css_unittest.py + create mode 100644 tools/grit/pak_util.py + create mode 100644 tools/grit/repack.gni + create mode 100644 tools/grit/setup.py + create mode 100644 tools/grit/stamp_grit_sources.py + create mode 100644 tools/grit/third_party/six/LICENSE + create mode 100644 tools/grit/third_party/six/README + create mode 100644 tools/grit/third_party/six/README.chromium + create mode 100644 tools/grit/third_party/six/__init__.py -diff --git a/tools/clang/OWNERS b/tools/clang/OWNERS +diff --git a/tools/grit/.gitignore b/tools/grit/.gitignore new file mode 100644 -index 0000000000..d86ef9424a +index 0000000000..0d20b6487c --- /dev/null -+++ b/tools/clang/OWNERS -@@ -0,0 +1,2 @@ -+hans@chromium.org -+thakis@chromium.org -diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp ++++ b/tools/grit/.gitignore +@@ -0,0 +1 @@ ++*.pyc +diff --git a/tools/grit/BUILD.gn b/tools/grit/BUILD.gn new file mode 100644 -index 0000000000..055866c5c5 +index 0000000000..1cd3c75b55 --- /dev/null -+++ b/tools/clang/plugins/ChromeClassTester.cpp -@@ -0,0 +1,294 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// A general interface for filtering and only acting on classes in Chromium C++ -+// code. -+ -+#include "ChromeClassTester.h" ++++ b/tools/grit/BUILD.gn +@@ -0,0 +1,48 @@ ++# Copyright 2014 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+#include ++# This target creates a stamp file that depends on all the sources in the grit ++# directory. By depending on this, a target can force itself to be rebuilt if ++# grit itself changes. + -+#include "clang/AST/AST.h" -+#include "clang/Basic/FileManager.h" -+#include "clang/Basic/SourceManager.h" ++import("//build/config/sanitizers/sanitizers.gni") + -+using namespace clang; ++action("grit_sources") { ++ depfile = "$target_out_dir/grit_sources.d" ++ script = "stamp_grit_sources.py" + -+namespace { ++ inputs = [ "grit.py" ] + -+bool starts_with(const std::string& one, const std::string& two) { -+ return one.compare(0, two.size(), two) == 0; -+} ++ # Note that we can't call this "grit_sources.stamp" because that file is ++ # implicitly created by GN for script actions. ++ outputs = [ "$target_out_dir/grit_sources.script.stamp" ] + -+std::string lstrip(const std::string& one, const std::string& two) { -+ if (starts_with(one, two)) -+ return one.substr(two.size()); -+ return one; ++ args = [ ++ rebase_path("//tools/grit", root_build_dir), ++ rebase_path(outputs[0], root_build_dir), ++ rebase_path(depfile, root_build_dir), ++ ] +} + -+bool ends_with(const std::string& one, const std::string& two) { -+ if (two.size() > one.size()) -+ return false; ++group("grit_python_unittests") { ++ testonly = true + -+ return one.compare(one.size() - two.size(), two.size(), two) == 0; ++ data = [ ++ "//testing/scripts/common.py", ++ "//testing/scripts/run_isolated_script_test.py", ++ "//testing/xvfb.py", ++ "//tools/grit/", ++ "//third_party/catapult/third_party/typ/", ++ ] +} + -+} // namespace ++# See https://crbug.com/983200 ++if (is_mac && is_asan) { ++ create_bundle("brotli_mac_asan_workaround") { ++ bundle_root_dir = "$target_out_dir/$target_name" ++ bundle_executable_dir = bundle_root_dir + -+ChromeClassTester::ChromeClassTester(CompilerInstance& instance) -+ : instance_(instance), -+ diagnostic_(instance.getDiagnostics()) { -+ BuildBannedLists(); ++ public_deps = [ "//third_party/brotli:brotli($host_toolchain)" ] ++ } +} +diff --git a/tools/grit/MANIFEST.in b/tools/grit/MANIFEST.in +new file mode 100644 +index 0000000000..1cbff42400 +--- /dev/null ++++ b/tools/grit/MANIFEST.in +@@ -0,0 +1,3 @@ ++exclude grit/test_suite_all.py ++exclude grit/tool/test.py ++global-exclude *_unittest.py +diff --git a/tools/grit/OWNERS b/tools/grit/OWNERS +new file mode 100644 +index 0000000000..6a8f447b82 +--- /dev/null ++++ b/tools/grit/OWNERS +@@ -0,0 +1,8 @@ ++agrieve@chromium.org ++flackr@chromium.org ++thakis@chromium.org ++thestig@chromium.org + -+ChromeClassTester::~ChromeClassTester() {} ++# Admin policy related grit tools. ++per-file *policy*=file://components/policy/tools/OWNERS ++per-file *admin_template*=file://components/policy/tools/OWNERS +diff --git a/tools/grit/PRESUBMIT.py b/tools/grit/PRESUBMIT.py +new file mode 100644 +index 0000000000..03b7188551 +--- /dev/null ++++ b/tools/grit/PRESUBMIT.py +@@ -0,0 +1,22 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+void ChromeClassTester::HandleTagDeclDefinition(TagDecl* tag) { -+ pending_class_decls_.push_back(tag); -+} ++"""grit unittests presubmit script. + -+bool ChromeClassTester::HandleTopLevelDecl(DeclGroupRef group_ref) { -+ for (size_t i = 0; i < pending_class_decls_.size(); ++i) -+ CheckTag(pending_class_decls_[i]); -+ pending_class_decls_.clear(); ++See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for ++details on the presubmit API built into gcl. ++""" + -+ return true; // true means continue parsing. -+} + -+void ChromeClassTester::CheckTag(TagDecl* tag) { -+ // We handle class types here where we have semantic information. We can only -+ // check structs/classes/enums here, but we get a bunch of nice semantic -+ // information instead of just parsing information. ++def RunUnittests(input_api, output_api): ++ return input_api.canned_checks.RunUnitTests(input_api, output_api, ++ [input_api.os_path.join('grit', 'test_suite_all.py')]) + -+ if (CXXRecordDecl* record = dyn_cast(tag)) { -+ // If this is a POD or a class template or a type dependent on a -+ // templated class, assume there's no ctor/dtor/virtual method -+ // optimization that we can do. -+ if (record->isPOD() || -+ record->getDescribedClassTemplate() || -+ record->getTemplateSpecializationKind() || -+ record->isDependentType()) -+ return; + -+ if (InBannedNamespace(record)) -+ return; ++def CheckChangeOnUpload(input_api, output_api): ++ return RunUnittests(input_api, output_api) + -+ SourceLocation record_location = record->getInnerLocStart(); -+ if (InBannedDirectory(record_location)) -+ return; + -+ // We sadly need to maintain a blacklist of types that violate these -+ // rules, but do so for good reason or due to limitations of this -+ // checker (i.e., we don't handle extern templates very well). -+ std::string base_name = record->getNameAsString(); -+ if (IsIgnoredType(base_name)) -+ return; ++def CheckChangeOnCommit(input_api, output_api): ++ return RunUnittests(input_api, output_api) +diff --git a/tools/grit/README.md b/tools/grit/README.md +new file mode 100644 +index 0000000000..b5c3f4b51b +--- /dev/null ++++ b/tools/grit/README.md +@@ -0,0 +1,19 @@ ++# GRIT (Google Resource and Internationalization Tool) + -+ // We ignore all classes that end with "Matcher" because they're probably -+ // GMock artifacts. -+ if (ends_with(base_name, "Matcher")) -+ return; ++This is a tool for projects to manage resources and simplify the localization ++workflow. + -+ CheckChromeClass(record_location, record); -+ } -+} ++See the user guide for more details on using this project: ++https://dev.chromium.org/developers/tools-we-use-in-chromium/grit/grit-users-guide + -+void ChromeClassTester::emitWarning(SourceLocation loc, -+ const char* raw_error) { -+ FullSourceLoc full(loc, instance().getSourceManager()); -+ std::string err; -+ err = "[chromium-style] "; -+ err += raw_error; -+ DiagnosticsEngine::Level level = -+ diagnostic().getWarningsAsErrors() ? -+ DiagnosticsEngine::Error : -+ DiagnosticsEngine::Warning; -+ unsigned id = diagnostic().getCustomDiagID(level, err); -+ DiagnosticBuilder builder = diagnostic().Report(full, id); -+} -+ -+bool ChromeClassTester::InBannedNamespace(const Decl* record) { -+ std::string n = GetNamespace(record); -+ if (!n.empty()) { -+ return std::find(banned_namespaces_.begin(), banned_namespaces_.end(), n) -+ != banned_namespaces_.end(); -+ } ++## History + -+ return false; -+} ++This code previously used to live at ++https://code.google.com/p/grit-i18n/source/checkout which still contains the ++project's history. https://chromium.googlesource.com/external/grit-i18n/ is ++a git mirror of the SVN repository that's identical except for the last two ++commits. The project is now developed in the Chromium project directly. + -+std::string ChromeClassTester::GetNamespace(const Decl* record) { -+ return GetNamespaceImpl(record->getDeclContext(), ""); -+} ++There is a read-only mirror of just this directory at ++https://chromium.googlesource.com/chromium/src/tools/grit/ if you don't want to ++check out all of Chromium. +diff --git a/tools/grit/grit.py b/tools/grit/grit.py +new file mode 100644 +index 0000000000..abd1ab6449 +--- /dev/null ++++ b/tools/grit/grit.py +@@ -0,0 +1,31 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { -+ std::string filename; -+ if (!GetFilename(record_location, &filename)) -+ return false; ++'''Bootstrapping for GRIT. ++''' + -+ if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || -+ ends_with(filename, ".mm")) { -+ return true; -+ } ++from __future__ import print_function + -+ return false; -+} ++import os ++import sys + -+void ChromeClassTester::BuildBannedLists() { -+ banned_namespaces_.push_back("std"); -+ banned_namespaces_.push_back("__gnu_cxx"); -+ banned_namespaces_.push_back("WebKit"); -+ -+ banned_directories_.push_back("third_party/"); -+ banned_directories_.push_back("native_client/"); -+ banned_directories_.push_back("breakpad/"); -+ banned_directories_.push_back("courgette/"); -+ banned_directories_.push_back("pdf/"); -+ banned_directories_.push_back("ppapi/"); -+ banned_directories_.push_back("usr/"); -+ banned_directories_.push_back("testing/"); -+ banned_directories_.push_back("googleurl/"); -+ banned_directories_.push_back("v8/"); -+ banned_directories_.push_back("dart/"); -+ banned_directories_.push_back("sdch/"); -+ banned_directories_.push_back("icu4c/"); -+ banned_directories_.push_back("frameworks/"); -+ -+ // Don't check autogenerated headers. -+ // Make puts them below $(builddir_name)/.../gen and geni. -+ // Ninja puts them below OUTPUT_DIR/.../gen -+ // Xcode has a fixed output directory for everything. -+ banned_directories_.push_back("gen/"); -+ banned_directories_.push_back("geni/"); -+ banned_directories_.push_back("xcodebuild/"); -+ -+ // You are standing in a mazy of twisty dependencies, all resolved by -+ // putting everything in the header. -+ banned_directories_.push_back("automation/"); -+ -+ // Don't check system headers. -+ banned_directories_.push_back("/Developer/"); -+ -+ // Used in really low level threading code that probably shouldn't be out of -+ // lined. -+ ignored_record_names_.insert("ThreadLocalBoolean"); -+ -+ // A complicated pickle derived struct that is all packed integers. -+ ignored_record_names_.insert("Header"); -+ -+ // Part of the GPU system that uses multiple included header -+ // weirdness. Never getting this right. -+ ignored_record_names_.insert("Validators"); -+ -+ // Has a UNIT_TEST only constructor. Isn't *terribly* complex... -+ ignored_record_names_.insert("AutocompleteController"); -+ ignored_record_names_.insert("HistoryURLProvider"); -+ -+ // Because of chrome frame -+ ignored_record_names_.insert("ReliabilityTestSuite"); -+ -+ // Used over in the net unittests. A large enough bundle of integers with 1 -+ // non-pod class member. Probably harmless. -+ ignored_record_names_.insert("MockTransaction"); -+ -+ // Used heavily in ui_unittests and once in views_unittests. Fixing this -+ // isn't worth the overhead of an additional library. -+ ignored_record_names_.insert("TestAnimationDelegate"); -+ -+ // Part of our public interface that nacl and friends use. (Arguably, this -+ // should mean that this is a higher priority but fixing this looks hard.) -+ ignored_record_names_.insert("PluginVersionInfo"); -+} -+ -+std::string ChromeClassTester::GetNamespaceImpl(const DeclContext* context, -+ const std::string& candidate) { -+ switch (context->getDeclKind()) { -+ case Decl::TranslationUnit: { -+ return candidate; -+ } -+ case Decl::Namespace: { -+ const NamespaceDecl* decl = dyn_cast(context); -+ std::string name_str; -+ llvm::raw_string_ostream OS(name_str); -+ if (decl->isAnonymousNamespace()) -+ OS << ""; -+ else -+ OS << *decl; -+ return GetNamespaceImpl(context->getParent(), -+ OS.str()); -+ } -+ default: { -+ return GetNamespaceImpl(context->getParent(), candidate); -+ } -+ } -+} ++import grit.grit_runner + -+bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { -+ std::string filename; -+ if (!GetFilename(loc, &filename)) { -+ // If the filename cannot be determined, simply treat this as a banned -+ // location, instead of going through the full lookup process. -+ return true; -+ } ++sys.path.append( ++ os.path.join( ++ os.path.dirname(os.path.dirname(os.path.abspath(__file__))), ++ 'diagnosis')) ++try: ++ import crbug_1001171 ++except ImportError: ++ crbug_1001171 = None + -+ // We need to special case scratch space; which is where clang does its -+ // macro expansion. We explicitly want to allow people to do otherwise bad -+ // things through macros that were defined due to third party libraries. -+ if (filename == "") -+ return true; + -+ // Don't complain about autogenerated protobuf files. -+ if (ends_with(filename, ".pb.h")) { -+ return true; -+ } ++if __name__ == '__main__': ++ if crbug_1001171: ++ with crbug_1001171.DumpStateOnLookupError(): ++ sys.exit(grit.grit_runner.Main(sys.argv[1:])) ++ else: ++ sys.exit(grit.grit_runner.Main(sys.argv[1:])) +diff --git a/tools/grit/grit/__init__.py b/tools/grit/grit/__init__.py +new file mode 100644 +index 0000000000..91ac9ee896 +--- /dev/null ++++ b/tools/grit/grit/__init__.py +@@ -0,0 +1,19 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+ // We need to munge the paths so that they are relative to the repository -+ // srcroot. We first resolve the symlinktastic relative path and then -+ // remove our known srcroot from it if needed. -+ char resolvedPath[MAXPATHLEN]; -+ if (realpath(filename.c_str(), resolvedPath)) { -+ filename = resolvedPath; -+ } ++'''Package 'grit' ++''' + -+ // On linux, chrome is often checked out to /usr/local/google. Due to the -+ // "usr" rule in banned_directories_, all diagnostics would be suppressed -+ // in that case. As a workaround, strip that prefix. -+ filename = lstrip(filename, "/usr/local/google"); -+ -+ for (std::vector::const_iterator it = -+ banned_directories_.begin(); -+ it != banned_directories_.end(); ++it) { -+ // If we can find any of the banned path components in this path, then -+ // this file is rejected. -+ size_t index = filename.find(*it); -+ if (index != std::string::npos) { -+ bool matches_full_dir_name = index == 0 || filename[index - 1] == '/'; -+ if ((*it)[0] == '/') -+ matches_full_dir_name = true; -+ if (matches_full_dir_name) -+ return true; -+ } -+ } ++from __future__ import print_function + -+ return false; -+} ++import os ++import sys + -+bool ChromeClassTester::IsIgnoredType(const std::string& base_name) { -+ return ignored_record_names_.find(base_name) != ignored_record_names_.end(); -+} + -+bool ChromeClassTester::GetFilename(SourceLocation loc, -+ std::string* filename) { -+ const SourceManager& source_manager = instance_.getSourceManager(); -+ SourceLocation spelling_location = source_manager.getSpellingLoc(loc); -+ PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); -+ if (ploc.isInvalid()) { -+ // If we're in an invalid location, we're looking at things that aren't -+ // actually stated in the source. -+ return false; -+ } ++_CUR_DIR = os.path.abspath(os.path.dirname(__file__)) ++_GRIT_DIR = os.path.dirname(_CUR_DIR) ++_THIRD_PARTY_DIR = os.path.join(_GRIT_DIR, 'third_party') + -+ *filename = ploc.getFilename(); -+ return true; -+} -diff --git a/tools/clang/plugins/ChromeClassTester.h b/tools/clang/plugins/ChromeClassTester.h ++if _THIRD_PARTY_DIR not in sys.path: ++ sys.path.insert(0, _THIRD_PARTY_DIR) +diff --git a/tools/grit/grit/clique.py b/tools/grit/grit/clique.py new file mode 100644 -index 0000000000..588ae9cae5 +index 0000000000..e7be3ec164 --- /dev/null -+++ b/tools/clang/plugins/ChromeClassTester.h -@@ -0,0 +1,84 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ -+#define TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ -+ -+#include -+#include -+ -+#include "clang/AST/ASTConsumer.h" -+#include "clang/AST/TypeLoc.h" -+#include "clang/Frontend/CompilerInstance.h" -+ -+// A class on top of ASTConsumer that forwards classes defined in Chromium -+// headers to subclasses which implement CheckChromeClass(). -+class ChromeClassTester : public clang::ASTConsumer { -+ public: -+ explicit ChromeClassTester(clang::CompilerInstance& instance); -+ virtual ~ChromeClassTester(); -+ -+ // clang::ASTConsumer: -+ virtual void HandleTagDeclDefinition(clang::TagDecl* tag); -+ virtual bool HandleTopLevelDecl(clang::DeclGroupRef group_ref); ++++ b/tools/grit/grit/clique.py +@@ -0,0 +1,491 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+ protected: -+ clang::CompilerInstance& instance() { return instance_; } -+ clang::DiagnosticsEngine& diagnostic() { return diagnostic_; } ++'''Collections of messages and their translations, called cliques. Also ++collections of cliques (uber-cliques). ++''' ++ ++from __future__ import print_function ++ ++import re ++ ++import six ++ ++from grit import constants ++from grit import exception ++from grit import lazy_re ++from grit import pseudo ++from grit import pseudo_rtl ++from grit import tclib ++ ++ ++class UberClique(object): ++ '''A factory (NOT a singleton factory) for making cliques. It has several ++ methods for working with the cliques created using the factory. ++ ''' ++ ++ def __init__(self): ++ # A map from message ID to list of cliques whose source messages have ++ # that ID. This will contain all cliques created using this factory. ++ # Different messages can have the same ID because they have the ++ # same translateable portion and placeholder names, but occur in different ++ # places in the resource tree. ++ # ++ # Each list of cliques is kept sorted by description, to achieve ++ # stable results from the BestClique method, see below. ++ self.cliques_ = {} ++ ++ # A map of clique IDs to list of languages to indicate translations where we ++ # fell back to English. ++ self.fallback_translations_ = {} ++ ++ # A map of clique IDs to list of languages to indicate missing translations. ++ self.missing_translations_ = {} ++ ++ def _AddMissingTranslation(self, lang, clique, is_error): ++ tl = self.fallback_translations_ ++ if is_error: ++ tl = self.missing_translations_ ++ id = clique.GetId() ++ if id not in tl: ++ tl[id] = {} ++ if lang not in tl[id]: ++ tl[id][lang] = 1 ++ ++ def HasMissingTranslations(self): ++ return len(self.missing_translations_) > 0 ++ ++ def MissingTranslationsReport(self): ++ '''Returns a string suitable for printing to report missing ++ and fallback translations to the user. ++ ''' ++ def ReportTranslation(clique, langs): ++ text = clique.GetMessage().GetPresentableContent() ++ # The text 'error' (usually 'Error:' but we are conservative) ++ # can trigger some build environments (Visual Studio, we're ++ # looking at you) to consider invocation of grit to have failed, ++ # so we make sure never to output that word. ++ extract = re.sub(r'(?i)error', 'REDACTED', text[0:40])[0:40] ++ ellipsis = '' ++ if len(text) > 40: ++ ellipsis = '...' ++ langs_extract = langs[0:6] ++ describe_langs = ','.join(langs_extract) ++ if len(langs) > 6: ++ describe_langs += " and %d more" % (len(langs) - 6) ++ return " %s \"%s%s\" %s" % (clique.GetId(), extract, ellipsis, ++ describe_langs) ++ lines = [] ++ if len(self.fallback_translations_): ++ lines.append( ++ "WARNING: Fell back to English for the following translations:") ++ for (id, langs) in self.fallback_translations_.items(): ++ lines.append( ++ ReportTranslation(self.cliques_[id][0], list(langs.keys()))) ++ if len(self.missing_translations_): ++ lines.append("ERROR: The following translations are MISSING:") ++ for (id, langs) in self.missing_translations_.items(): ++ lines.append( ++ ReportTranslation(self.cliques_[id][0], list(langs.keys()))) ++ return '\n'.join(lines) ++ ++ def MakeClique(self, message, translateable=True): ++ '''Create a new clique initialized with a message. ++ ++ Args: ++ message: tclib.Message() ++ translateable: True | False ++ ''' ++ clique = MessageClique(self, message, translateable) ++ ++ # Enable others to find this clique by its message ID ++ if message.GetId() in self.cliques_: ++ presentable_text = clique.GetMessage().GetPresentableContent() ++ if not message.HasAssignedId(): ++ for c in self.cliques_[message.GetId()]: ++ assert c.GetMessage().GetPresentableContent() == presentable_text ++ self.cliques_[message.GetId()].append(clique) ++ # We need to keep each list of cliques sorted by description, to ++ # achieve stable results from the BestClique method, see below. ++ self.cliques_[message.GetId()].sort( ++ key=lambda c:c.GetMessage().GetDescription()) ++ else: ++ self.cliques_[message.GetId()] = [clique] ++ ++ return clique ++ ++ def FindCliqueAndAddTranslation(self, translation, language): ++ '''Adds the specified translation to the clique with the source message ++ it is a translation of. ++ ++ Args: ++ translation: tclib.Translation() ++ language: 'en' | 'fr' ... ++ ++ Return: ++ True if the source message was found, otherwise false. ++ ''' ++ if translation.GetId() in self.cliques_: ++ for clique in self.cliques_[translation.GetId()]: ++ clique.AddTranslation(translation, language) ++ return True ++ else: ++ return False ++ ++ def BestClique(self, id): ++ '''Returns the "best" clique from a list of cliques. All the cliques ++ must have the same ID. The "best" clique is chosen in the following ++ order of preference: ++ - The first clique that has a non-ID-based description. ++ - If no such clique found, the first clique with an ID-based description. ++ - Otherwise the first clique. ++ ++ This method is stable in terms of always returning a clique with ++ an identical description (on different runs of GRIT on the same ++ data) because self.cliques_ is sorted by description. ++ ''' ++ clique_list = self.cliques_[id] ++ clique_with_id = None ++ clique_default = None ++ for clique in clique_list: ++ if not clique_default: ++ clique_default = clique ++ ++ description = clique.GetMessage().GetDescription() ++ if description and len(description) > 0: ++ if not description.startswith('ID:'): ++ # this is the preferred case so we exit right away ++ return clique ++ elif not clique_with_id: ++ clique_with_id = clique ++ if clique_with_id: ++ return clique_with_id ++ else: ++ return clique_default ++ ++ def BestCliquePerId(self): ++ '''Iterates over the list of all cliques and returns the best clique for ++ each ID. This will be the first clique with a source message that has a ++ non-empty description, or an arbitrary clique if none of them has a ++ description. ++ ''' ++ for id in self.cliques_: ++ yield self.BestClique(id) ++ ++ def BestCliqueByOriginalText(self, text, meaning): ++ '''Finds the "best" (as in BestClique()) clique that has original text ++ 'text' and meaning 'meaning'. Returns None if there is no such clique. ++ ''' ++ # If needed, this can be optimized by maintaining a map of ++ # fingerprints of original text+meaning to cliques. ++ for c in self.BestCliquePerId(): ++ msg = c.GetMessage() ++ if msg.GetRealContent() == text and msg.GetMeaning() == meaning: ++ return msg ++ return None ++ ++ def AllMessageIds(self): ++ '''Returns a list of all defined message IDs. ++ ''' ++ return list(self.cliques_.keys()) ++ ++ def AllCliques(self): ++ '''Iterates over all cliques. Note that this can return multiple cliques ++ with the same ID. ++ ''' ++ for cliques in self.cliques_.values(): ++ for c in cliques: ++ yield c ++ ++ def GenerateXtbParserCallback(self, lang, debug=False): ++ '''Creates a callback function as required by grit.xtb_reader.Parse(). ++ This callback will create Translation objects for each message from ++ the XTB that exists in this uberclique, and add them as translations for ++ the relevant cliques. The callback will add translations to the language ++ specified by 'lang' ++ ++ Args: ++ lang: 'fr' ++ debug: True | False ++ ''' ++ def Callback(id, structure): ++ if id not in self.cliques_: ++ if debug: ++ print("Ignoring translation #%s" % id) ++ return ++ ++ if debug: ++ print("Adding translation #%s" % id) ++ ++ # We fetch placeholder information from the original message (the XTB file ++ # only contains placeholder names). ++ original_msg = self.BestClique(id).GetMessage() ++ ++ translation = tclib.Translation(id=id) ++ for is_ph,text in structure: ++ if not is_ph: ++ translation.AppendText(text) ++ else: ++ found_placeholder = False ++ for ph in original_msg.GetPlaceholders(): ++ if ph.GetPresentation() == text: ++ translation.AppendPlaceholder(tclib.Placeholder( ++ ph.GetPresentation(), ph.GetOriginal(), ph.GetExample())) ++ found_placeholder = True ++ break ++ if not found_placeholder: ++ raise exception.MismatchingPlaceholders( ++ 'Translation for message ID %s had , no match\n' ++ 'in original message' % (id, text)) ++ self.FindCliqueAndAddTranslation(translation, lang) ++ return Callback ++ ++ ++class CustomType(object): ++ '''A base class you should implement if you wish to specify a custom type ++ for a message clique (i.e. custom validation and optional modification of ++ translations).''' ++ ++ def Validate(self, message): ++ '''Returns true if the message (a tclib.Message object) is valid, ++ otherwise false. ++ ''' ++ raise NotImplementedError() ++ ++ def ValidateAndModify(self, lang, translation): ++ '''Returns true if the translation (a tclib.Translation object) is valid, ++ otherwise false. The language is also passed in. This method may modify ++ the translation that is passed in, if it so wishes. ++ ''' ++ raise NotImplementedError() ++ ++ def ModifyTextPart(self, lang, text): ++ '''If you call ModifyEachTextPart, it will turn around and call this method ++ for each text part of the translation. You should return the modified ++ version of the text, or just the original text to not change anything. ++ ''' ++ raise NotImplementedError() ++ ++ def ModifyEachTextPart(self, lang, translation): ++ '''Call this to easily modify one or more of the textual parts of a ++ translation. It will call ModifyTextPart for each part of the ++ translation. ++ ''' ++ contents = translation.GetContent() ++ for ix in range(len(contents)): ++ if (isinstance(contents[ix], six.string_types)): ++ contents[ix] = self.ModifyTextPart(lang, contents[ix]) ++ ++ ++class OneOffCustomType(CustomType): ++ '''A very simple custom type that performs the validation expressed by ++ the input expression on all languages including the source language. ++ The expression can access the variables 'lang', 'msg' and 'text()' where ++ 'lang' is the language of 'msg', 'msg' is the message or translation being ++ validated and 'text()' returns the real contents of 'msg' (for shorthand). ++ ''' ++ def __init__(self, expression): ++ self.expr = expression ++ def Validate(self, message): ++ return self.ValidateAndModify(MessageClique.source_language, message) ++ def ValidateAndModify(self, lang, msg): ++ def text(): ++ return msg.GetRealContent() ++ return eval(self.expr, {}, ++ {'lang' : lang, ++ 'text' : text, ++ 'msg' : msg, ++ }) ++ ++ ++class MessageClique(object): ++ '''A message along with all of its translations. Also code to bring ++ translations together with their original message.''' ++ ++ # change this to the language code of Messages you add to cliques_. ++ # TODO(joi) Actually change this based on the node's source language ++ source_language = 'en' ++ ++ # A constant translation we use when asked for a translation into the ++ # special language constants.CONSTANT_LANGUAGE. ++ CONSTANT_TRANSLATION = tclib.Translation(text='TTTTTT') ++ ++ # A pattern to match messages that are empty or whitespace only. ++ WHITESPACE_MESSAGE = lazy_re.compile(r'^\s*$') ++ ++ def __init__(self, uber_clique, message, translateable=True, ++ custom_type=None): ++ '''Create a new clique initialized with just a message. ++ ++ Note that messages with a body comprised only of whitespace will implicitly ++ be marked non-translatable. ++ ++ Args: ++ uber_clique: Our uber-clique (collection of cliques) ++ message: tclib.Message() ++ translateable: True | False ++ custom_type: instance of clique.CustomType interface ++ ''' ++ # Our parent ++ self.uber_clique = uber_clique ++ # If not translateable, we only store the original message. ++ self.translateable = translateable ++ ++ # We implicitly mark messages that have a whitespace-only body as ++ # non-translateable. ++ if MessageClique.WHITESPACE_MESSAGE.match(message.GetRealContent()): ++ self.translateable = False ++ ++ # A mapping of language identifiers to tclib.BaseMessage and its ++ # subclasses (i.e. tclib.Message and tclib.Translation). ++ self.clique = { MessageClique.source_language : message } ++ # A list of the "shortcut groups" this clique is ++ # part of. Within any given shortcut group, no shortcut key (e.g. &J) ++ # must appear more than once in each language for all cliques that ++ # belong to the group. ++ self.shortcut_groups = [] ++ # An instance of the CustomType interface, or None. If this is set, it will ++ # be used to validate the original message and translations thereof, and ++ # will also get a chance to modify translations of the message. ++ self.SetCustomType(custom_type) ++ ++ def GetMessage(self): ++ '''Retrieves the tclib.Message that is the source for this clique.''' ++ return self.clique[MessageClique.source_language] ++ ++ def GetId(self): ++ '''Retrieves the message ID of the messages in this clique.''' ++ return self.GetMessage().GetId() ++ ++ def IsTranslateable(self): ++ return self.translateable ++ ++ def AddToShortcutGroup(self, group): ++ self.shortcut_groups.append(group) ++ ++ def SetCustomType(self, custom_type): ++ '''Makes this clique use custom_type for validating messages and ++ translations, and optionally modifying translations. ++ ''' ++ self.custom_type = custom_type ++ if custom_type and not custom_type.Validate(self.GetMessage()): ++ raise exception.InvalidMessage(self.GetMessage().GetRealContent()) ++ ++ def MessageForLanguage(self, lang, pseudo_if_no_match=True, ++ fallback_to_english=False): ++ '''Returns the message/translation for the specified language, providing ++ a pseudotranslation if there is no available translation and a pseudo- ++ translation is requested. ++ ++ The translation of any message whatsoever in the special language ++ 'x_constant' is the message "TTTTTT". ++ ++ Args: ++ lang: 'en' ++ pseudo_if_no_match: True ++ fallback_to_english: False ++ ++ Return: ++ tclib.BaseMessage ++ ''' ++ if not self.translateable: ++ return self.GetMessage() ++ ++ if lang == constants.CONSTANT_LANGUAGE: ++ return self.CONSTANT_TRANSLATION ++ ++ for msglang in self.clique: ++ if lang == msglang: ++ return self.clique[msglang] ++ ++ if lang == constants.FAKE_BIDI: ++ return pseudo_rtl.PseudoRTLMessage(self.GetMessage()) ++ ++ if fallback_to_english: ++ self.uber_clique._AddMissingTranslation(lang, self, is_error=False) ++ return self.GetMessage() ++ ++ # If we're not supposed to generate pseudotranslations, we add an error ++ # report to a list of errors, then fail at a higher level, so that we ++ # get a list of all messages that are missing translations. ++ if not pseudo_if_no_match: ++ self.uber_clique._AddMissingTranslation(lang, self, is_error=True) ++ ++ return pseudo.PseudoMessage(self.GetMessage()) ++ ++ def AllMessagesThatMatch(self, lang_re, include_pseudo = True): ++ '''Returns a map of all messages that match 'lang', including the pseudo ++ translation if requested. ++ ++ Args: ++ lang_re: re.compile(r'fr|en') ++ include_pseudo: True ++ ++ Return: ++ { 'en' : tclib.Message, ++ 'fr' : tclib.Translation, ++ pseudo.PSEUDO_LANG : tclib.Translation } ++ ''' ++ if not self.translateable: ++ return [self.GetMessage()] ++ ++ matches = {} ++ for msglang in self.clique: ++ if lang_re.match(msglang): ++ matches[msglang] = self.clique[msglang] ++ ++ if include_pseudo: ++ matches[pseudo.PSEUDO_LANG] = pseudo.PseudoMessage(self.GetMessage()) ++ ++ return matches ++ ++ def AddTranslation(self, translation, language): ++ '''Add a translation to this clique. The translation must have the same ++ ID as the message that is the source for this clique. ++ ++ If this clique is not translateable, the function just returns. ++ ++ Args: ++ translation: tclib.Translation() ++ language: 'en' ++ ++ Throws: ++ grit.exception.InvalidTranslation if the translation you're trying to add ++ doesn't have the same message ID as the source message of this clique. ++ ''' ++ if not self.translateable: ++ return ++ if translation.GetId() != self.GetId(): ++ raise exception.InvalidTranslation( ++ 'Msg ID %s, transl ID %s' % (self.GetId(), translation.GetId())) ++ ++ assert not language in self.clique ++ ++ # Because two messages can differ in the original content of their ++ # placeholders yet share the same ID (because they are otherwise the ++ # same), the translation we are getting may have different original ++ # content for placeholders than our message, yet it is still the right ++ # translation for our message (because it is for the same ID). We must ++ # therefore fetch the original content of placeholders from our original ++ # English message. ++ # ++ # See grit.clique_unittest.MessageCliqueUnittest.testSemiIdenticalCliques ++ # for a concrete explanation of why this is necessary. ++ ++ original = self.MessageForLanguage(self.source_language, False) ++ if len(original.GetPlaceholders()) != len(translation.GetPlaceholders()): ++ print("ERROR: '%s' translation of message id %s does not match" % ++ (language, translation.GetId())) ++ assert False ++ ++ transl_msg = tclib.Translation(id=self.GetId(), ++ text=translation.GetPresentableContent(), ++ placeholders=original.GetPlaceholders()) ++ ++ if (self.custom_type and ++ not self.custom_type.ValidateAndModify(language, transl_msg)): ++ print("WARNING: %s translation failed validation: %s" % ++ (language, transl_msg.GetId())) ++ ++ self.clique[language] = transl_msg +diff --git a/tools/grit/grit/clique_unittest.py b/tools/grit/grit/clique_unittest.py +new file mode 100644 +index 0000000000..7d2d7318ba +--- /dev/null ++++ b/tools/grit/grit/clique_unittest.py +@@ -0,0 +1,265 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+ // Emits a simple warning; this shouldn't be used if you require printf-style -+ // printing. -+ void emitWarning(clang::SourceLocation loc, const char* error); ++'''Unit tests for grit.clique''' + -+ // Utility method for subclasses to check if this class is in a banned -+ // namespace. -+ bool InBannedNamespace(const clang::Decl* record); ++from __future__ import print_function + -+ // Utility method for subclasses to determine the namespace of the -+ // specified record, if any. Unnamed namespaces will be identified as -+ // "". -+ std::string GetNamespace(const clang::Decl* record); ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import re ++import unittest ++ ++from six import StringIO ++ ++from grit import clique ++from grit import exception ++from grit import pseudo ++from grit import tclib ++from grit import grd_reader ++from grit import util ++ ++class MessageCliqueUnittest(unittest.TestCase): ++ def testClique(self): ++ factory = clique.UberClique() ++ msg = tclib.Message(text='Hello USERNAME, how are you?', ++ placeholders=[ ++ tclib.Placeholder('USERNAME', '%s', 'Joi')]) ++ c = factory.MakeClique(msg) ++ ++ self.failUnless(c.GetMessage() == msg) ++ self.failUnless(c.GetId() == msg.GetId()) ++ ++ msg_fr = tclib.Translation(text='Bonjour USERNAME, comment ca va?', ++ id=msg.GetId(), placeholders=[ ++ tclib.Placeholder('USERNAME', '%s', 'Joi')]) ++ msg_de = tclib.Translation(text='Guten tag USERNAME, wie geht es dir?', ++ id=msg.GetId(), placeholders=[ ++ tclib.Placeholder('USERNAME', '%s', 'Joi')]) ++ ++ c.AddTranslation(msg_fr, 'fr') ++ factory.FindCliqueAndAddTranslation(msg_de, 'de') ++ ++ # sort() sorts lists in-place and does not return them ++ for lang in ('en', 'fr', 'de'): ++ self.failUnless(lang in c.clique) ++ ++ self.failUnless(c.MessageForLanguage('fr').GetRealContent() == ++ msg_fr.GetRealContent()) ++ ++ try: ++ c.MessageForLanguage('zh-CN', False) ++ self.fail('Should have gotten exception') ++ except: ++ pass ++ ++ self.failUnless(c.MessageForLanguage('zh-CN', True) != None) ++ ++ rex = re.compile('fr|de|bingo') ++ self.failUnless(len(c.AllMessagesThatMatch(rex, False)) == 2) ++ self.failUnless( ++ c.AllMessagesThatMatch(rex, True)[pseudo.PSEUDO_LANG] is not None) ++ ++ def testBestClique(self): ++ factory = clique.UberClique() ++ factory.MakeClique(tclib.Message(text='Alfur', description='alfaholl')) ++ factory.MakeClique(tclib.Message(text='Alfur', description='')) ++ factory.MakeClique(tclib.Message(text='Vaettur', description='')) ++ factory.MakeClique(tclib.Message(text='Vaettur', description='')) ++ factory.MakeClique(tclib.Message(text='Troll', description='')) ++ factory.MakeClique(tclib.Message(text='Gryla', description='ID: IDS_GRYLA')) ++ factory.MakeClique(tclib.Message(text='Gryla', description='vondakerling')) ++ factory.MakeClique(tclib.Message(text='Leppaludi', description='ID: IDS_LL')) ++ factory.MakeClique(tclib.Message(text='Leppaludi', description='')) ++ ++ count_best_cliques = 0 ++ for c in factory.BestCliquePerId(): ++ count_best_cliques += 1 ++ msg = c.GetMessage() ++ text = msg.GetRealContent() ++ description = msg.GetDescription() ++ if text == 'Alfur': ++ self.failUnless(description == 'alfaholl') ++ elif text == 'Gryla': ++ self.failUnless(description == 'vondakerling') ++ elif text == 'Leppaludi': ++ self.failUnless(description == 'ID: IDS_LL') ++ self.failUnless(count_best_cliques == 5) ++ ++ def testAllInUberClique(self): ++ resources = grd_reader.Parse( ++ StringIO(u''' ++ ++ ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ ++ ++ ++ ++ ++ ++'''), util.PathFromRoot('.')) ++ resources.SetOutputLanguage('en') ++ resources.RunGatherers() ++ content_list = [] ++ for clique_list in resources.UberClique().cliques_.values(): ++ for clique in clique_list: ++ content_list.append(clique.GetMessage().GetRealContent()) ++ self.failUnless('Hello %s, how are you doing today?' in content_list) ++ self.failUnless('Jack "Black" Daniels' in content_list) ++ self.failUnless('Hello!' in content_list) ++ ++ def testCorrectExceptionIfWrongEncodingOnResourceFile(self): ++ '''This doesn't really belong in this unittest file, but what the heck.''' ++ resources = grd_reader.Parse( ++ StringIO(u''' ++ ++ ++ ++ ++ ++ ++'''), util.PathFromRoot('.')) ++ self.assertRaises(exception.SectionNotFound, resources.RunGatherers) ++ ++ def testSemiIdenticalCliques(self): ++ messages = [ ++ tclib.Message(text='Hello USERNAME', ++ placeholders=[tclib.Placeholder('USERNAME', '$1', 'Joi')]), ++ tclib.Message(text='Hello USERNAME', ++ placeholders=[tclib.Placeholder('USERNAME', '%s', 'Joi')]), ++ ] ++ self.failUnless(messages[0].GetId() == messages[1].GetId()) ++ ++ # Both of the above would share a translation. ++ translation = tclib.Translation(id=messages[0].GetId(), ++ text='Bonjour USERNAME', ++ placeholders=[tclib.Placeholder( ++ 'USERNAME', '$1', 'Joi')]) ++ ++ factory = clique.UberClique() ++ cliques = [factory.MakeClique(msg) for msg in messages] ++ ++ for clq in cliques: ++ clq.AddTranslation(translation, 'fr') ++ ++ self.failUnless(cliques[0].MessageForLanguage('fr').GetRealContent() == ++ 'Bonjour $1') ++ self.failUnless(cliques[1].MessageForLanguage('fr').GetRealContent() == ++ 'Bonjour %s') ++ ++ def testMissingTranslations(self): ++ messages = [ tclib.Message(text='Hello'), tclib.Message(text='Goodbye') ] ++ factory = clique.UberClique() ++ cliques = [factory.MakeClique(msg) for msg in messages] ++ ++ cliques[1].MessageForLanguage('fr', False, True) ++ ++ self.failUnless(not factory.HasMissingTranslations()) ++ ++ cliques[0].MessageForLanguage('de', False, False) ++ ++ self.failUnless(factory.HasMissingTranslations()) ++ ++ report = factory.MissingTranslationsReport() ++ self.failUnless(report.count('WARNING') == 1) ++ self.failUnless(report.count('8053599568341804890 "Goodbye" fr') == 1) ++ self.failUnless(report.count('ERROR') == 1) ++ self.failUnless(report.count('800120468867715734 "Hello" de') == 1) ++ ++ def testCustomTypes(self): ++ factory = clique.UberClique() ++ message = tclib.Message(text='Bingo bongo') ++ c = factory.MakeClique(message) ++ try: ++ c.SetCustomType(DummyCustomType()) ++ self.fail() ++ except: ++ pass # expected case - 'Bingo bongo' does not start with 'jjj' ++ ++ message = tclib.Message(text='jjjBingo bongo') ++ c = factory.MakeClique(message) ++ c.SetCustomType(util.NewClassInstance( ++ 'grit.clique_unittest.DummyCustomType', clique.CustomType)) ++ translation = tclib.Translation(id=message.GetId(), text='Bilingo bolongo') ++ c.AddTranslation(translation, 'fr') ++ self.failUnless(c.MessageForLanguage('fr').GetRealContent().startswith('jjj')) ++ ++ def testWhitespaceMessagesAreNontranslateable(self): ++ factory = clique.UberClique() ++ ++ message = tclib.Message(text=' \t') ++ c = factory.MakeClique(message, translateable=True) ++ self.failIf(c.IsTranslateable()) ++ ++ message = tclib.Message(text='\n \n ') ++ c = factory.MakeClique(message, translateable=True) ++ self.failIf(c.IsTranslateable()) ++ ++ message = tclib.Message(text='\n hello') ++ c = factory.MakeClique(message, translateable=True) ++ self.failUnless(c.IsTranslateable()) ++ ++ def testEachCliqueKeptSorted(self): ++ factory = clique.UberClique() ++ msg_a = tclib.Message(text='hello', description='a') ++ msg_b = tclib.Message(text='hello', description='b') ++ msg_c = tclib.Message(text='hello', description='c') ++ # Insert out of order ++ clique_b = factory.MakeClique(msg_b, translateable=True) ++ clique_a = factory.MakeClique(msg_a, translateable=True) ++ clique_c = factory.MakeClique(msg_c, translateable=True) ++ clique_list = factory.cliques_[clique_a.GetId()] ++ self.failUnless(len(clique_list) == 3) ++ self.failUnless(clique_list[0] == clique_a) ++ self.failUnless(clique_list[1] == clique_b) ++ self.failUnless(clique_list[2] == clique_c) ++ ++ def testBestCliqueSortIsStable(self): ++ factory = clique.UberClique() ++ text = 'hello' ++ msg_no_description = tclib.Message(text=text) ++ msg_id_description_a = tclib.Message(text=text, description='ID: a') ++ msg_id_description_b = tclib.Message(text=text, description='ID: b') ++ msg_description_x = tclib.Message(text=text, description='x') ++ msg_description_y = tclib.Message(text=text, description='y') ++ clique_id = msg_no_description.GetId() ++ ++ # Insert in an order that tests all outcomes. ++ clique_no_description = factory.MakeClique(msg_no_description, ++ translateable=True) ++ self.failUnless(factory.BestClique(clique_id) == clique_no_description) ++ clique_id_description_b = factory.MakeClique(msg_id_description_b, ++ translateable=True) ++ self.failUnless(factory.BestClique(clique_id) == clique_id_description_b) ++ clique_id_description_a = factory.MakeClique(msg_id_description_a, ++ translateable=True) ++ self.failUnless(factory.BestClique(clique_id) == clique_id_description_a) ++ clique_description_y = factory.MakeClique(msg_description_y, ++ translateable=True) ++ self.failUnless(factory.BestClique(clique_id) == clique_description_y) ++ clique_description_x = factory.MakeClique(msg_description_x, ++ translateable=True) ++ self.failUnless(factory.BestClique(clique_id) == clique_description_x) ++ ++ ++class DummyCustomType(clique.CustomType): ++ def Validate(self, message): ++ return message.GetRealContent().startswith('jjj') ++ def ValidateAndModify(self, lang, translation): ++ is_ok = self.Validate(translation) ++ self.ModifyEachTextPart(lang, translation) ++ def ModifyTextPart(self, lang, text): ++ return 'jjj%s' % text + -+ // Utility method for subclasses to check if this class is within an -+ // implementation (.cc, .cpp, .mm) file. -+ bool InImplementationFile(clang::SourceLocation location); + -+ private: -+ void BuildBannedLists(); ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/constants.py b/tools/grit/grit/constants.py +new file mode 100644 +index 0000000000..8229c94b09 +--- /dev/null ++++ b/tools/grit/grit/constants.py +@@ -0,0 +1,23 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+ void CheckTag(clang::TagDecl*); ++'''Constant definitions for GRIT. ++''' + -+ // Filtered versions of tags that are only called with things defined in -+ // chrome header files. -+ virtual void CheckChromeClass(clang::SourceLocation record_location, -+ clang::CXXRecordDecl* record) = 0; ++from __future__ import print_function + -+ // Utility methods used for filtering out non-chrome classes (and ones we -+ // deliberately ignore) in HandleTagDeclDefinition(). -+ std::string GetNamespaceImpl(const clang::DeclContext* context, -+ const std::string& candidate); -+ bool InBannedDirectory(clang::SourceLocation loc); -+ bool IsIgnoredType(const std::string& base_name); ++# This is the Icelandic noun meaning "grit" and is used to check that our ++# input files are in the correct encoding. The middle character gets encoded ++# as two bytes in UTF-8, so this is sufficient to detect incorrect encoding. ++ENCODING_CHECK = u'm\u00f6l' + -+ // Attempts to determine the filename for the given SourceLocation. -+ // Returns false if the filename could not be determined. -+ bool GetFilename(clang::SourceLocation loc, std::string* filename); ++# A special language, translations into which are always "TTTTTT". ++CONSTANT_LANGUAGE = 'x_constant' + -+ clang::CompilerInstance& instance_; -+ clang::DiagnosticsEngine& diagnostic_; ++FAKE_BIDI = 'fake-bidi' + -+ // List of banned namespaces. -+ std::vector banned_namespaces_; ++# Magic number added to the header of resources brotli compressed by grit. Used ++# to easily identify resources as being brotli compressed. See ++# ui/base/resource/resource_bundle.h for decompression usage. ++BROTLI_CONST = b'\x1e\x9b' +diff --git a/tools/grit/grit/exception.py b/tools/grit/grit/exception.py +new file mode 100644 +index 0000000000..2a363fb077 +--- /dev/null ++++ b/tools/grit/grit/exception.py +@@ -0,0 +1,139 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+ // List of banned directories. -+ std::vector banned_directories_; ++'''Exception types for GRIT. ++''' + -+ // List of types that we don't check. -+ std::set ignored_record_names_; ++from __future__ import print_function + -+ // List of decls to check once the current top-level decl is parsed. -+ std::vector pending_class_decls_; -+}; ++class Base(Exception): ++ '''A base exception that uses the class's docstring in addition to any ++ user-provided message as the body of the Base. ++ ''' ++ def __init__(self, msg=''): ++ if len(msg): ++ if self.__doc__: ++ msg = self.__doc__ + ': ' + msg ++ else: ++ msg = self.__doc__ ++ super(Base, self).__init__(msg) + -+#endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ -diff --git a/tools/clang/plugins/FindBadConstructs.cpp b/tools/clang/plugins/FindBadConstructs.cpp -new file mode 100644 -index 0000000000..b79a64dbd1 ---- /dev/null -+++ b/tools/clang/plugins/FindBadConstructs.cpp -@@ -0,0 +1,435 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. + -+// This file defines a bunch of recurring problems in the Chromium C++ code. -+// -+// Checks that are implemented: -+// - Constructors/Destructors should not be inlined if they are of a complex -+// class type. -+// - Missing "virtual" keywords on methods that should be virtual. -+// - Non-annotated overriding virtual methods. -+// - Virtual methods with nonempty implementations in their headers. -+// - Classes that derive from base::RefCounted / base::RefCountedThreadSafe -+// should have protected or private destructors. ++class Parsing(Base): ++ '''An error occurred parsing a GRD or XTB file.''' ++ pass + -+#include "clang/Frontend/FrontendPluginRegistry.h" -+#include "clang/AST/ASTConsumer.h" -+#include "clang/AST/AST.h" -+#include "clang/AST/CXXInheritance.h" -+#include "clang/AST/TypeLoc.h" -+#include "clang/Basic/SourceManager.h" -+#include "clang/Frontend/CompilerInstance.h" -+#include "llvm/Support/raw_ostream.h" + -+#include "ChromeClassTester.h" ++class UnknownElement(Parsing): ++ '''An unknown node type was encountered.''' ++ pass + -+using namespace clang; + -+namespace { ++class MissingElement(Parsing): ++ '''An expected element was missing.''' ++ pass + -+bool TypeHasNonTrivialDtor(const Type* type) { -+ if (const CXXRecordDecl* cxx_r = type->getCXXRecordDeclForPointerType()) -+ return cxx_r->hasTrivialDestructor(); + -+ return false; -+} ++class UnexpectedChild(Parsing): ++ '''An unexpected child element was encountered (on a leaf node).''' ++ pass + -+// Returns the underlying Type for |type| by expanding typedefs and removing -+// any namespace qualifiers. -+const Type* UnwrapType(const Type* type) { -+ if (const ElaboratedType* elaborated = dyn_cast(type)) -+ return UnwrapType(elaborated->getNamedType().getTypePtr()); -+ if (const TypedefType* typedefed = dyn_cast(type)) -+ return UnwrapType(typedefed->desugar().getTypePtr()); -+ return type; -+} -+ -+// Searches for constructs that we know we don't want in the Chromium code base. -+class FindBadConstructsConsumer : public ChromeClassTester { -+ public: -+ FindBadConstructsConsumer(CompilerInstance& instance, -+ bool check_refcounted_dtors, -+ bool check_virtuals_in_implementations) -+ : ChromeClassTester(instance), -+ check_refcounted_dtors_(check_refcounted_dtors), -+ check_virtuals_in_implementations_(check_virtuals_in_implementations) { -+ } + -+ virtual void CheckChromeClass(SourceLocation record_location, -+ CXXRecordDecl* record) { -+ bool implementation_file = InImplementationFile(record_location); ++class UnexpectedAttribute(Parsing): ++ '''The attribute was not expected''' ++ pass + -+ if (!implementation_file) { -+ // Only check for "heavy" constructors/destructors in header files; -+ // within implementation files, there is no performance cost. -+ CheckCtorDtorWeight(record_location, record); -+ } + -+ if (!implementation_file || check_virtuals_in_implementations_) { -+ bool warn_on_inline_bodies = !implementation_file; ++class UnexpectedContent(Parsing): ++ '''This element should not have content''' ++ pass + -+ // Check that all virtual methods are marked accordingly with both -+ // virtual and OVERRIDE. -+ CheckVirtualMethods(record_location, record, warn_on_inline_bodies); -+ } ++class MissingMandatoryAttribute(Parsing): ++ '''This element is missing a mandatory attribute''' ++ pass + -+ if (check_refcounted_dtors_) -+ CheckRefCountedDtors(record_location, record); -+ } + -+ private: -+ bool check_refcounted_dtors_; -+ bool check_virtuals_in_implementations_; -+ -+ // Returns true if |base| specifies one of the Chromium reference counted -+ // classes (base::RefCounted / base::RefCountedThreadSafe). |user_data| is -+ // ignored. -+ static bool IsRefCountedCallback(const CXXBaseSpecifier* base, -+ CXXBasePath& path, -+ void* user_data) { -+ FindBadConstructsConsumer* self = -+ static_cast(user_data); -+ -+ const TemplateSpecializationType* base_type = -+ dyn_cast( -+ UnwrapType(base->getType().getTypePtr())); -+ if (!base_type) { -+ // Base-most definition is not a template, so this cannot derive from -+ // base::RefCounted. However, it may still be possible to use with a -+ // scoped_refptr<> and support ref-counting, so this is not a perfect -+ // guarantee of safety. -+ return false; -+ } ++class MutuallyExclusiveMandatoryAttribute(Parsing): ++ '''This element has 2 mutually exclusive mandatory attributes''' ++ pass + -+ TemplateName name = base_type->getTemplateName(); -+ if (TemplateDecl* decl = name.getAsTemplateDecl()) { -+ std::string base_name = decl->getNameAsString(); + -+ // Check for both base::RefCounted and base::RefCountedThreadSafe. -+ if (base_name.compare(0, 10, "RefCounted") == 0 && -+ self->GetNamespace(decl) == "base") { -+ return true; -+ } -+ } -+ return false; -+ } ++class DuplicateKey(Parsing): ++ '''A duplicate key attribute was found.''' ++ pass + -+ // Prints errors if the destructor of a RefCounted class is public. -+ void CheckRefCountedDtors(SourceLocation record_location, -+ CXXRecordDecl* record) { -+ // Skip anonymous structs. -+ if (record->getIdentifier() == NULL) -+ return; -+ -+ CXXBasePaths paths; -+ if (!record->lookupInBases( -+ &FindBadConstructsConsumer::IsRefCountedCallback, this, paths)) { -+ return; // Class does not derive from a ref-counted base class. -+ } + -+ if (!record->hasUserDeclaredDestructor()) { -+ emitWarning( -+ record_location, -+ "Classes that are ref-counted should have explicit " -+ "destructors that are protected or private."); -+ } else if (CXXDestructorDecl* dtor = record->getDestructor()) { -+ if (dtor->getAccess() == AS_public) { -+ emitWarning( -+ dtor->getInnerLocStart(), -+ "Classes that are ref-counted should not have " -+ "public destructors."); -+ } -+ } -+ } ++class TooManyExamples(Parsing): ++ '''Only one element is allowed for each element.''' ++ pass + -+ // Prints errors if the constructor/destructor weight is too heavy. -+ void CheckCtorDtorWeight(SourceLocation record_location, -+ CXXRecordDecl* record) { -+ // We don't handle anonymous structs. If this record doesn't have a -+ // name, it's of the form: -+ // -+ // struct { -+ // ... -+ // } name_; -+ if (record->getIdentifier() == NULL) -+ return; -+ -+ // Count the number of templated base classes as a feature of whether the -+ // destructor can be inlined. -+ int templated_base_classes = 0; -+ for (CXXRecordDecl::base_class_const_iterator it = record->bases_begin(); -+ it != record->bases_end(); ++it) { -+ if (it->getTypeSourceInfo()->getTypeLoc().getTypeLocClass() == -+ TypeLoc::TemplateSpecialization) { -+ ++templated_base_classes; -+ } -+ } + -+ // Count the number of trivial and non-trivial member variables. -+ int trivial_member = 0; -+ int non_trivial_member = 0; -+ int templated_non_trivial_member = 0; -+ for (RecordDecl::field_iterator it = record->field_begin(); -+ it != record->field_end(); ++it) { -+ CountType(it->getType().getTypePtr(), -+ &trivial_member, -+ &non_trivial_member, -+ &templated_non_trivial_member); -+ } ++class FileNotFound(Parsing): ++ '''The resource file was not found.''' ++ pass + -+ // Check to see if we need to ban inlined/synthesized constructors. Note -+ // that the cutoffs here are kind of arbitrary. Scores over 10 break. -+ int dtor_score = 0; -+ // Deriving from a templated base class shouldn't be enough to trigger -+ // the ctor warning, but if you do *anything* else, it should. -+ // -+ // TODO(erg): This is motivated by templated base classes that don't have -+ // any data members. Somehow detect when templated base classes have data -+ // members and treat them differently. -+ dtor_score += templated_base_classes * 9; -+ // Instantiating a template is an insta-hit. -+ dtor_score += templated_non_trivial_member * 10; -+ // The fourth normal class member should trigger the warning. -+ dtor_score += non_trivial_member * 3; -+ -+ int ctor_score = dtor_score; -+ // You should be able to have 9 ints before we warn you. -+ ctor_score += trivial_member; -+ -+ if (ctor_score >= 10) { -+ if (!record->hasUserDeclaredConstructor()) { -+ emitWarning(record_location, -+ "Complex class/struct needs an explicit out-of-line " -+ "constructor."); -+ } else { -+ // Iterate across all the constructors in this file and yell if we -+ // find one that tries to be inline. -+ for (CXXRecordDecl::ctor_iterator it = record->ctor_begin(); -+ it != record->ctor_end(); ++it) { -+ if (it->hasInlineBody()) { -+ if (it->isCopyConstructor() && -+ !record->hasUserDeclaredCopyConstructor()) { -+ emitWarning(record_location, -+ "Complex class/struct needs an explicit out-of-line " -+ "copy constructor."); -+ } else { -+ emitWarning(it->getInnerLocStart(), -+ "Complex constructor has an inlined body."); -+ } -+ } -+ } -+ } -+ } + -+ // The destructor side is equivalent except that we don't check for -+ // trivial members; 20 ints don't need a destructor. -+ if (dtor_score >= 10 && !record->hasTrivialDestructor()) { -+ if (!record->hasUserDeclaredDestructor()) { -+ emitWarning( -+ record_location, -+ "Complex class/struct needs an explicit out-of-line " -+ "destructor."); -+ } else if (CXXDestructorDecl* dtor = record->getDestructor()) { -+ if (dtor->hasInlineBody()) { -+ emitWarning(dtor->getInnerLocStart(), -+ "Complex destructor has an inline body."); -+ } -+ } -+ } -+ } ++class InvalidMessage(Base): ++ '''The specified message failed validation.''' ++ pass + -+ void CheckVirtualMethod(const CXXMethodDecl* method, -+ bool warn_on_inline_bodies) { -+ if (!method->isVirtual()) -+ return; + -+ if (!method->isVirtualAsWritten()) { -+ SourceLocation loc = method->getTypeSpecStartLoc(); -+ if (isa(method)) -+ loc = method->getInnerLocStart(); -+ emitWarning(loc, "Overriding method must have \"virtual\" keyword."); -+ } ++class InvalidTranslation(Base): ++ '''Attempt to add an invalid translation to a clique.''' ++ pass + -+ // Virtual methods should not have inline definitions beyond "{}". This -+ // only matters for header files. -+ if (warn_on_inline_bodies && method->hasBody() && -+ method->hasInlineBody()) { -+ if (CompoundStmt* cs = dyn_cast(method->getBody())) { -+ if (cs->size()) { -+ emitWarning( -+ cs->getLBracLoc(), -+ "virtual methods with non-empty bodies shouldn't be " -+ "declared inline."); -+ } -+ } -+ } -+ } + -+ bool InTestingNamespace(const Decl* record) { -+ return GetNamespace(record).find("testing") != std::string::npos; -+ } ++class NoSuchTranslation(Base): ++ '''Requested translation not available''' ++ pass + -+ bool IsMethodInBannedNamespace(const CXXMethodDecl* method) { -+ if (InBannedNamespace(method)) -+ return true; -+ for (CXXMethodDecl::method_iterator i = method->begin_overridden_methods(); -+ i != method->end_overridden_methods(); -+ ++i) { -+ const CXXMethodDecl* overridden = *i; -+ if (IsMethodInBannedNamespace(overridden)) -+ return true; -+ } + -+ return false; -+ } ++class NotReady(Base): ++ '''Attempt to use an object before it is ready, or attempt to translate \ ++an empty document.''' ++ pass + -+ void CheckOverriddenMethod(const CXXMethodDecl* method) { -+ if (!method->size_overridden_methods() || method->getAttr()) -+ return; + -+ if (isa(method) || method->isPure()) -+ return; ++class MismatchingPlaceholders(Base): ++ '''Placeholders do not match.''' ++ pass + -+ if (IsMethodInBannedNamespace(method)) -+ return; + -+ SourceLocation loc = method->getTypeSpecStartLoc(); -+ emitWarning(loc, "Overriding method must be marked with OVERRIDE."); -+ } ++class InvalidPlaceholderName(Base): ++ '''Placeholder name can only contain A-Z, a-z, 0-9 and underscore.''' ++ pass + -+ // Makes sure there is a "virtual" keyword on virtual methods. -+ // -+ // Gmock objects trigger these for each MOCK_BLAH() macro used. So we have a -+ // trick to get around that. If a class has member variables whose types are -+ // in the "testing" namespace (which is how gmock works behind the scenes), -+ // there's a really high chance we won't care about these errors -+ void CheckVirtualMethods(SourceLocation record_location, -+ CXXRecordDecl* record, -+ bool warn_on_inline_bodies) { -+ for (CXXRecordDecl::field_iterator it = record->field_begin(); -+ it != record->field_end(); ++it) { -+ CXXRecordDecl* record_type = -+ it->getTypeSourceInfo()->getTypeLoc().getTypePtr()-> -+ getAsCXXRecordDecl(); -+ if (record_type) { -+ if (InTestingNamespace(record_type)) { -+ return; -+ } -+ } -+ } + -+ for (CXXRecordDecl::method_iterator it = record->method_begin(); -+ it != record->method_end(); ++it) { -+ if (it->isCopyAssignmentOperator() || isa(*it)) { -+ // Ignore constructors and assignment operators. -+ } else if (isa(*it) && -+ !record->hasUserDeclaredDestructor()) { -+ // Ignore non-user-declared destructors. -+ } else { -+ CheckVirtualMethod(*it, warn_on_inline_bodies); -+ CheckOverriddenMethod(*it); -+ } -+ } -+ } ++class BlockTagInTranslateableChunk(Base): ++ '''A block tag was encountered where it wasn't expected.''' ++ pass + -+ void CountType(const Type* type, -+ int* trivial_member, -+ int* non_trivial_member, -+ int* templated_non_trivial_member) { -+ switch (type->getTypeClass()) { -+ case Type::Record: { -+ // Simplifying; the whole class isn't trivial if the dtor is, but -+ // we use this as a signal about complexity. -+ if (TypeHasNonTrivialDtor(type)) -+ (*trivial_member)++; -+ else -+ (*non_trivial_member)++; -+ break; -+ } -+ case Type::TemplateSpecialization: { -+ TemplateName name = -+ dyn_cast(type)->getTemplateName(); -+ bool whitelisted_template = false; -+ -+ // HACK: I'm at a loss about how to get the syntax checker to get -+ // whether a template is exterened or not. For the first pass here, -+ // just do retarded string comparisons. -+ if (TemplateDecl* decl = name.getAsTemplateDecl()) { -+ std::string base_name = decl->getNameAsString(); -+ if (base_name == "basic_string") -+ whitelisted_template = true; -+ } + -+ if (whitelisted_template) -+ (*non_trivial_member)++; -+ else -+ (*templated_non_trivial_member)++; -+ break; -+ } -+ case Type::Elaborated: { -+ CountType( -+ dyn_cast(type)->getNamedType().getTypePtr(), -+ trivial_member, non_trivial_member, templated_non_trivial_member); -+ break; -+ } -+ case Type::Typedef: { -+ while (const TypedefType* TT = dyn_cast(type)) { -+ type = TT->getDecl()->getUnderlyingType().getTypePtr(); -+ } -+ CountType(type, trivial_member, non_trivial_member, -+ templated_non_trivial_member); -+ break; -+ } -+ default: { -+ // Stupid assumption: anything we see that isn't the above is one of -+ // the 20 integer types. -+ (*trivial_member)++; -+ break; -+ } -+ } -+ } -+}; ++class SectionNotFound(Base): ++ '''The section you requested was not found in the RC file. Make \ ++sure the section ID is correct (matches the section's ID in the RC file). \ ++Also note that you may need to specify the RC file's encoding (using the \ ++encoding="" attribute) if it is not in the default Windows-1252 encoding. \ ++''' ++ pass + -+class FindBadConstructsAction : public PluginASTAction { -+ public: -+ FindBadConstructsAction() -+ : check_refcounted_dtors_(true), -+ check_virtuals_in_implementations_(true) { -+ } + -+ protected: -+ // Overridden from PluginASTAction: -+ virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance, -+ llvm::StringRef ref) { -+ return new FindBadConstructsConsumer( -+ instance, check_refcounted_dtors_, check_virtuals_in_implementations_); -+ } ++class IdRangeOverlap(Base): ++ '''ID range overlap.''' ++ pass + -+ virtual bool ParseArgs(const CompilerInstance& instance, -+ const std::vector& args) { -+ bool parsed = true; + -+ for (size_t i = 0; i < args.size() && parsed; ++i) { -+ if (args[i] == "skip-refcounted-dtors") { -+ check_refcounted_dtors_ = false; -+ } else if (args[i] == "skip-virtuals-in-implementations") { -+ check_virtuals_in_implementations_ = false; -+ } else { -+ parsed = false; -+ llvm::errs() << "Unknown argument: " << args[i] << "\n"; -+ } -+ } ++class ReservedHeaderCollision(Base): ++ '''Resource included with first 3 bytes matching reserved header.''' ++ pass + -+ return parsed; -+ } + -+ private: -+ bool check_refcounted_dtors_; -+ bool check_virtuals_in_implementations_; -+}; ++class PlaceholderNotInsidePhNode(Base): ++ '''Placeholder formatters should be inside element.''' ++ pass + -+} // namespace + -+static FrontendPluginRegistry::Add -+X("find-bad-constructs", "Finds bad C++ constructs"); -diff --git a/tools/clang/plugins/Makefile b/tools/clang/plugins/Makefile ++class InvalidCharactersInsidePhNode(Base): ++ '''Invalid characters found inside element.''' ++ pass +diff --git a/tools/grit/grit/extern/BogoFP.py b/tools/grit/grit/extern/BogoFP.py new file mode 100644 -index 0000000000..0cfec71159 +index 0000000000..fc90145833 --- /dev/null -+++ b/tools/clang/plugins/Makefile -@@ -0,0 +1,19 @@ -+# This file requires the clang build system, at least for now. So to use this -+# Makefile, you should execute the following commands to copy this directory -+# into a clang checkout: -+# -+# cp -R third_party/llvm/tools/clang/tools/chrome-plugin -+# cd third_party/llvm/tools/clang/tools/chrome-plugin -+# make ++++ b/tools/grit/grit/extern/BogoFP.py +@@ -0,0 +1,22 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+CLANG_LEVEL := ../.. -+LIBRARYNAME = FindBadConstructs ++"""Bogus fingerprint implementation, do not use for production, ++provided only as an example. + -+LINK_LIBS_IN_SHARED = 0 -+SHARED_LIBRARY = 1 ++Usage: ++ grit.py -h grit.extern.BogoFP xmb /tmp/foo ++""" + -+include $(CLANG_LEVEL)/Makefile ++from __future__ import print_function + -+ifeq ($(OS),Darwin) -+ LDFLAGS=-Wl,-undefined,dynamic_lookup -+endif -diff --git a/tools/clang/plugins/OWNERS b/tools/clang/plugins/OWNERS -new file mode 100644 -index 0000000000..4733a4f06b ---- /dev/null -+++ b/tools/clang/plugins/OWNERS -@@ -0,0 +1 @@ -+erg@chromium.org -diff --git a/tools/clang/plugins/README.chromium b/tools/clang/plugins/README.chromium -new file mode 100644 -index 0000000000..a2ce0ff557 ---- /dev/null -+++ b/tools/clang/plugins/README.chromium -@@ -0,0 +1,4 @@ -+Documentation for this code is: ++import grit.extern.FP + -+- http://code.google.com/p/chromium/wiki/Clang -+- http://code.google.com/p/chromium/wiki/WritingClangPlugins -diff --git a/tools/clang/plugins/tests/base_refcounted.cpp b/tools/clang/plugins/tests/base_refcounted.cpp ++ ++def UnsignedFingerPrint(str, encoding='utf-8'): ++ """Generate a fingerprint not intended for production from str (it ++ reduces the precision of the production fingerprint by one bit). ++ """ ++ return (0xFFFFF7FFFFFFFFFF & ++ grit.extern.FP._UnsignedFingerPrintImpl(str, encoding)) +diff --git a/tools/grit/grit/extern/FP.py b/tools/grit/grit/extern/FP.py new file mode 100644 -index 0000000000..364a3e888c +index 0000000000..f4ec4d943f --- /dev/null -+++ b/tools/clang/plugins/tests/base_refcounted.cpp ++++ b/tools/grit/grit/extern/FP.py @@ -0,0 +1,72 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+#include "base_refcounted.h" ++from __future__ import print_function + -+#include ++try: ++ import hashlib ++ _new_md5 = hashlib.md5 ++except ImportError: ++ import md5 ++ _new_md5 = md5.new + -+namespace { + -+// Unsafe; should error. -+class AnonymousDerivedProtectedToPublicInImpl -+ : public ProtectedRefCountedDtorInHeader { -+ public: -+ AnonymousDerivedProtectedToPublicInImpl() {} -+ ~AnonymousDerivedProtectedToPublicInImpl() {} -+}; ++"""64-bit fingerprint support for strings. + -+} // namespace ++Usage: ++ from extern import FP ++ print('Fingerprint is %ld' % FP.FingerPrint('Hello world!')) ++""" + -+// Unsafe; should error. -+class PublicRefCountedDtorInImpl -+ : public base::RefCounted { -+ public: -+ PublicRefCountedDtorInImpl() {} -+ ~PublicRefCountedDtorInImpl() {} + -+ private: -+ friend class base::RefCounted; -+}; ++def _UnsignedFingerPrintImpl(str, encoding='utf-8'): ++ """Generate a 64-bit fingerprint by taking the first half of the md5 ++ of the string. ++ """ ++ hex128 = _new_md5(str.encode(encoding)).hexdigest() ++ int64 = int(hex128[:16], 16) ++ return int64 + -+class Foo { -+ public: -+ class BarInterface { -+ protected: -+ virtual ~BarInterface() {} -+ }; + -+ typedef base::RefCounted RefCountedBar; -+ typedef RefCountedBar AnotherTypedef; -+}; ++def UnsignedFingerPrint(str, encoding='utf-8'): ++ """Generate a 64-bit fingerprint. + -+class Baz { -+ public: -+ typedef typename Foo::AnotherTypedef MyLocalTypedef; -+}; ++ The default implementation uses _UnsignedFingerPrintImpl, which ++ takes the first half of the md5 of the string, but the ++ implementation may be switched using SetUnsignedFingerPrintImpl. ++ """ ++ return _UnsignedFingerPrintImpl(str, encoding) + -+// Unsafe; should error. -+class UnsafeTypedefChainInImpl : public Baz::MyLocalTypedef { -+ public: -+ UnsafeTypedefChainInImpl() {} -+ ~UnsafeTypedefChainInImpl() {} -+}; + -+int main() { -+ PublicRefCountedDtorInHeader bad; -+ PublicRefCountedDtorInImpl also_bad; ++def FingerPrint(str, encoding='utf-8'): ++ fp = UnsignedFingerPrint(str, encoding=encoding) ++ # interpret fingerprint as signed longs ++ if fp & 0x8000000000000000: ++ fp = -((~fp & 0xFFFFFFFFFFFFFFFF) + 1) ++ return fp + -+ ProtectedRefCountedDtorInHeader* protected_ok = NULL; -+ PrivateRefCountedDtorInHeader* private_ok = NULL; + -+ DerivedProtectedToPublicInHeader still_bad; -+ PublicRefCountedThreadSafeDtorInHeader another_bad_variation; -+ AnonymousDerivedProtectedToPublicInImpl and_this_is_bad_too; -+ ImplicitDerivedProtectedToPublicInHeader bad_yet_again; -+ UnsafeTypedefChainInImpl and_again_this_is_bad; ++def UseUnsignedFingerPrintFromModule(module_name): ++ """Imports module_name and replaces UnsignedFingerPrint in the ++ current module with the function of the same name from the imported ++ module. + -+ WebKitPublicDtorInHeader ignored; -+ WebKitDerivedPublicDtorInHeader still_ignored; ++ Returns the function object previously known as ++ grit.extern.FP.UnsignedFingerPrint. ++ """ ++ hash_module = __import__(module_name, fromlist=[module_name]) ++ return SetUnsignedFingerPrint(hash_module.UnsignedFingerPrint) + -+ return 0; -+} -diff --git a/tools/clang/plugins/tests/base_refcounted.h b/tools/clang/plugins/tests/base_refcounted.h ++ ++def SetUnsignedFingerPrint(function_object): ++ """Sets grit.extern.FP.UnsignedFingerPrint to point to ++ function_object. ++ ++ Returns the function object previously known as ++ grit.extern.FP.UnsignedFingerPrint. ++ """ ++ global UnsignedFingerPrint ++ original_function_object = UnsignedFingerPrint ++ UnsignedFingerPrint = function_object ++ return original_function_object +diff --git a/tools/grit/grit/extern/__init__.py b/tools/grit/grit/extern/__init__.py +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/tools/grit/grit/extern/tclib.py b/tools/grit/grit/extern/tclib.py new file mode 100644 -index 0000000000..1e53215997 +index 0000000000..9952a87c11 --- /dev/null -+++ b/tools/clang/plugins/tests/base_refcounted.h -@@ -0,0 +1,121 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++++ b/tools/grit/grit/extern/tclib.py +@@ -0,0 +1,503 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+#ifndef BASE_REFCOUNTED_H_ -+#define BASE_REFCOUNTED_H_ ++# The tclib module contains tools for aggregating, verifying, and storing ++# messages destined for the Translation Console, as well as for reading ++# translations back and outputting them in some desired format. ++# ++# This has been stripped down to include only the functionality needed by grit ++# for creating Windows .rc and .h files. These are the only parts needed by ++# the Chrome build process. + -+namespace base { ++from __future__ import print_function + -+template -+class RefCounted { -+ public: -+ RefCounted() {} -+ ~RefCounted() {} -+}; ++from grit.extern import FP + -+template -+class RefCountedThreadSafe { -+ public: -+ RefCountedThreadSafe() {} -+ ~RefCountedThreadSafe() {} -+}; ++# This module assumes that within a bundle no two messages can have the ++# same id unless they're identical. + -+} // namespace base ++# The basic classes defined here for external use are Message and Translation, ++# where the former is used for English messages and the latter for ++# translations. These classes have a lot of common functionality, as expressed ++# by the common parent class BaseMessage. Perhaps the most important ++# distinction is that translated text is stored in UTF-8, whereas original text ++# is stored in whatever encoding the client uses (presumably Latin-1). + -+// Ignore classes whose inheritance tree ends in WebKit's RefCounted base -+// class. Though prone to error, this pattern is very prevalent in WebKit -+// code, so do not issue any warnings. -+namespace WebKit { ++# -------------------- ++# The public interface ++# -------------------- + -+template -+class RefCounted { -+ public: -+ RefCounted() {} -+ ~RefCounted() {} -+}; ++# Generate message id from message text and meaning string (optional), ++# both in utf-8 encoding ++# ++def GenerateMessageId(message, meaning=''): ++ fp = FP.FingerPrint(message) ++ if meaning: ++ # combine the fingerprints of message and meaning ++ fp2 = FP.FingerPrint(meaning) ++ if fp < 0: ++ fp = fp2 + (fp << 1) + 1 ++ else: ++ fp = fp2 + (fp << 1) ++ # To avoid negative ids we strip the high-order bit ++ return str(fp & 0x7fffffffffffffff) ++ ++# ------------------------------------------------------------------------- ++# The MessageTranslationError class is used to signal tclib-specific errors. ++ ++ ++class MessageTranslationError(Exception): ++ ++ def __init__(self, args = ''): ++ self.args = args ++ ++ ++# ----------------------------------------------------------- ++# The Placeholder class represents a placeholder in a message. ++ ++class Placeholder(object): ++ # String representation ++ def __str__(self): ++ return '%s, "%s", "%s"' % \ ++ (self.__presentation, self.__original, self.__example) ++ ++ # Getters ++ def GetOriginal(self): ++ return self.__original ++ ++ def GetPresentation(self): ++ return self.__presentation ++ ++ def GetExample(self): ++ return self.__example ++ ++ def __eq__(self, other): ++ return self.EqualTo(other, strict=1, ignore_trailing_spaces=0) ++ ++ # Equality test ++ # ++ # ignore_trailing_spaces: TC is using varchar to store the ++ # phrwr fields, as a result of that, the trailing spaces ++ # are removed by MySQL when the strings are stored into TC:-( ++ # ignore_trailing_spaces parameter is used to ignore ++ # trailing spaces during equivalence comparison. ++ # ++ def EqualTo(self, other, strict = 1, ignore_trailing_spaces = 1): ++ if type(other) is not Placeholder: ++ return 0 ++ if StringEquals(self.__presentation, other.__presentation, ++ ignore_trailing_spaces): ++ if not strict or (StringEquals(self.__original, other.__original, ++ ignore_trailing_spaces) and ++ StringEquals(self.__example, other.__example, ++ ignore_trailing_spaces)): ++ return 1 ++ return 0 + -+} // namespace WebKit + -+// Unsafe; should error. -+class PublicRefCountedDtorInHeader -+ : public base::RefCounted { -+ public: -+ PublicRefCountedDtorInHeader() {} -+ ~PublicRefCountedDtorInHeader() {} ++# ----------------------------------------------------------------- ++# BaseMessage is the common parent class of Message and Translation. ++# It is not meant for direct use. ++ ++class BaseMessage(object): ++ # Three types of message construction is supported. If the message text is a ++ # simple string with no dynamic content, you can pass it to the constructor ++ # as the "text" parameter. Otherwise, you can omit "text" and assemble the ++ # message step by step using AppendText() and AppendPlaceholder(). Or, as an ++ # alternative, you can give the constructor the "presentable" version of the ++ # message and a list of placeholders; it will then parse the presentation and ++ # build the message accordingly. For example: ++ # Message(text = "There are NUM_BUGS bugs in your code", ++ # placeholders = [Placeholder("NUM_BUGS", "%d", "33")], ++ # description = "Bla bla bla") ++ def __eq__(self, other): ++ # "source encoding" is nonsense, so ignore it ++ return _ObjectEquals(self, other, ['_BaseMessage__source_encoding']) ++ ++ def GetName(self): ++ return self.__name ++ ++ def GetSourceEncoding(self): ++ return self.__source_encoding ++ ++ # Append a placeholder to the message ++ def AppendPlaceholder(self, placeholder): ++ if not isinstance(placeholder, Placeholder): ++ raise MessageTranslationError("Invalid message placeholder %s in " ++ "message %s" % (placeholder, self.GetId())) ++ # Are there other placeholders with the same presentation? ++ # If so, they need to be the same. ++ for other in self.GetPlaceholders(): ++ if placeholder.GetPresentation() == other.GetPresentation(): ++ if not placeholder.EqualTo(other): ++ raise MessageTranslationError( ++ "Conflicting declarations of %s within message" % ++ placeholder.GetPresentation()) ++ # update placeholder list ++ dup = 0 ++ for item in self.__content: ++ if isinstance(item, Placeholder) and placeholder.EqualTo(item): ++ dup = 1 ++ break ++ if not dup: ++ self.__placeholders.append(placeholder) ++ ++ # update content ++ self.__content.append(placeholder) ++ ++ # Strips leading and trailing whitespace, and returns a tuple ++ # containing the leading and trailing space that was removed. ++ def Strip(self): ++ leading = trailing = '' ++ if len(self.__content) > 0: ++ s0 = self.__content[0] ++ if not isinstance(s0, Placeholder): ++ s = s0.lstrip() ++ leading = s0[:-len(s)] ++ self.__content[0] = s ++ ++ s0 = self.__content[-1] ++ if not isinstance(s0, Placeholder): ++ s = s0.rstrip() ++ trailing = s0[len(s):] ++ self.__content[-1] = s ++ return leading, trailing ++ ++ # Return the id of this message ++ def GetId(self): ++ if self.__id is None: ++ return self.GenerateId() ++ return self.__id ++ ++ # Set the id of this message ++ def SetId(self, id): ++ if id is None: ++ self.__id = None ++ else: ++ self.__id = str(id) # Treat numerical ids as strings ++ ++ # Return content of this message as a list (internal use only) ++ def GetContent(self): ++ return self.__content ++ ++ # Return a human-readable version of this message ++ def GetPresentableContent(self): ++ presentable_content = "" ++ for item in self.__content: ++ if isinstance(item, Placeholder): ++ presentable_content += item.GetPresentation() ++ else: ++ presentable_content += item ++ ++ return presentable_content ++ ++ # Return a fragment of a message in escaped format ++ def EscapeFragment(self, fragment): ++ return fragment.replace('%', '%%') ++ ++ # Return the "original" version of this message, doing %-escaping ++ # properly. If source_msg is specified, the placeholder original ++ # information inside source_msg will be used instead. ++ def GetOriginalContent(self, source_msg = None): ++ original_content = "" ++ for item in self.__content: ++ if isinstance(item, Placeholder): ++ if source_msg: ++ ph = source_msg.GetPlaceholder(item.GetPresentation()) ++ if not ph: ++ raise MessageTranslationError( ++ "Placeholder %s doesn't exist in message: %s" % ++ (item.GetPresentation(), source_msg)) ++ original_content += ph.GetOriginal() ++ else: ++ original_content += item.GetOriginal() ++ else: ++ original_content += self.EscapeFragment(item) ++ return original_content ++ ++ # Return the example of this message ++ def GetExampleContent(self): ++ example_content = "" ++ for item in self.__content: ++ if isinstance(item, Placeholder): ++ example_content += item.GetExample() ++ else: ++ example_content += item ++ return example_content ++ ++ # Return a list of all unique placeholders in this message ++ def GetPlaceholders(self): ++ return self.__placeholders ++ ++ # Return a placeholder in this message ++ def GetPlaceholder(self, presentation): ++ for item in self.__content: ++ if (isinstance(item, Placeholder) and ++ item.GetPresentation() == presentation): ++ return item ++ return None ++ ++ # Return this message's description ++ def GetDescription(self): ++ return self.__description ++ ++ # Add a message source ++ def AddSource(self, source): ++ self.__sources.append(source) ++ ++ # Return this message's sources as a list ++ def GetSources(self): ++ return self.__sources ++ ++ # Return this message's sources as a string ++ def GetSourcesAsText(self, delimiter = "; "): ++ return delimiter.join(self.__sources) ++ ++ # Set the obsolete flag for a message (internal use only) ++ def SetObsolete(self): ++ self.__obsolete = 1 ++ ++ # Get the obsolete flag for a message (internal use only) ++ def IsObsolete(self): ++ return self.__obsolete ++ ++ # Get the sequence number (0 by default) ++ def GetSequenceNumber(self): ++ return self.__sequence_number ++ ++ # Set the sequence number ++ def SetSequenceNumber(self, number): ++ self.__sequence_number = number ++ ++ # Increment instance counter ++ def AddInstance(self): ++ self.__num_instances += 1 ++ ++ # Return instance count ++ def GetNumInstances(self): ++ return self.__num_instances ++ ++ def GetErrors(self, from_tc=0): ++ """ ++ Returns a description of the problem if the message is not ++ syntactically valid, or None if everything is fine. ++ ++ Args: ++ from_tc: indicates whether this message came from the TC. We let ++ the TC get away with some things we normally wouldn't allow for ++ historical reasons. ++ """ ++ # check that placeholders are unambiguous ++ pos = 0 ++ phs = {} ++ for item in self.__content: ++ if isinstance(item, Placeholder): ++ phs[pos] = item ++ pos += len(item.GetPresentation()) ++ else: ++ pos += len(item) ++ presentation = self.GetPresentableContent() ++ for ph in self.GetPlaceholders(): ++ for pos in FindOverlapping(presentation, ph.GetPresentation()): ++ # message contains the same text as a placeholder presentation ++ other_ph = phs.get(pos) ++ if ((not other_ph ++ and not IsSubstringInPlaceholder(pos, len(ph.GetPresentation()), phs)) ++ or ++ (other_ph and len(other_ph.GetPresentation()) < len(ph.GetPresentation()))): ++ return "message contains placeholder name '%s':\n%s" % ( ++ ph.GetPresentation(), presentation) ++ return None ++ ++ ++ def __CopyTo(self, other): ++ """ ++ Returns a copy of this BaseMessage. ++ """ ++ assert isinstance(other, self.__class__) or isinstance(self, other.__class__) ++ other.__source_encoding = self.__source_encoding ++ other.__content = self.__content[:] ++ other.__description = self.__description ++ other.__id = self.__id ++ other.__num_instances = self.__num_instances ++ other.__obsolete = self.__obsolete ++ other.__name = self.__name ++ other.__placeholders = self.__placeholders[:] ++ other.__sequence_number = self.__sequence_number ++ other.__sources = self.__sources[:] ++ ++ return other ++ ++ def HasText(self): ++ """Returns true iff this message has anything other than placeholders.""" ++ for item in self.__content: ++ if not isinstance(item, Placeholder): ++ return True ++ return False ++ ++# -------------------------------------------------------- ++# The Message class represents original (English) messages ++ ++class Message(BaseMessage): ++ # See BaseMessage constructor ++ def __init__(self, source_encoding, text=None, id=None, ++ description=None, meaning="", placeholders=None, ++ source=None, sequence_number=0, clone_from=None, ++ time_created=0, name=None, is_hidden = 0): ++ ++ if clone_from is not None: ++ BaseMessage.__init__(self, None, clone_from=clone_from) ++ self.__meaning = clone_from.__meaning ++ self.__time_created = clone_from.__time_created ++ self.__is_hidden = clone_from.__is_hidden ++ return ++ ++ BaseMessage.__init__(self, source_encoding, text, id, description, ++ placeholders, source, sequence_number, ++ name=name) ++ self.__meaning = meaning ++ self.__time_created = time_created ++ self.SetIsHidden(is_hidden) ++ ++ # String representation ++ def __str__(self): ++ s = 'source: %s, id: %s, content: "%s", meaning: "%s", ' \ ++ 'description: "%s"' % \ ++ (self.GetSourcesAsText(), self.GetId(), self.GetPresentableContent(), ++ self.__meaning, self.GetDescription()) ++ if self.GetName() is not None: ++ s += ', name: "%s"' % self.GetName() ++ placeholders = self.GetPlaceholders() ++ for i in range(len(placeholders)): ++ s += ", placeholder[%d]: %s" % (i, placeholders[i]) ++ return s ++ ++ # Strips leading and trailing whitespace, and returns a tuple ++ # containing the leading and trailing space that was removed. ++ def Strip(self): ++ leading = trailing = '' ++ content = self.GetContent() ++ if len(content) > 0: ++ s0 = content[0] ++ if not isinstance(s0, Placeholder): ++ s = s0.lstrip() ++ leading = s0[:-len(s)] ++ content[0] = s ++ ++ s0 = content[-1] ++ if not isinstance(s0, Placeholder): ++ s = s0.rstrip() ++ trailing = s0[len(s):] ++ content[-1] = s ++ return leading, trailing ++ ++ # Generate an id by hashing message content ++ def GenerateId(self): ++ self.SetId(GenerateMessageId(self.GetPresentableContent(), ++ self.__meaning)) ++ return self.GetId() ++ ++ def GetMeaning(self): ++ return self.__meaning ++ ++ def GetTimeCreated(self): ++ return self.__time_created ++ ++ # Equality operator ++ def EqualTo(self, other, strict = 1): ++ # Check id, meaning, content ++ if self.GetId() != other.GetId(): ++ return 0 ++ if self.__meaning != other.__meaning: ++ return 0 ++ if self.GetPresentableContent() != other.GetPresentableContent(): ++ return 0 ++ # Check descriptions if comparison is strict ++ if (strict and ++ self.GetDescription() is not None and ++ other.GetDescription() is not None and ++ self.GetDescription() != other.GetDescription()): ++ return 0 ++ # Check placeholders ++ ph1 = self.GetPlaceholders() ++ ph2 = other.GetPlaceholders() ++ if len(ph1) != len(ph2): ++ return 0 ++ for i in range(len(ph1)): ++ if not ph1[i].EqualTo(ph2[i], strict): ++ return 0 ++ ++ return 1 ++ ++ def Copy(self): ++ """ ++ Returns a copy of this Message. ++ """ ++ assert isinstance(self, Message) ++ return Message(None, clone_from=self) ++ ++ def SetIsHidden(self, is_hidden): ++ """Sets whether this message should be hidden. ++ ++ Args: ++ is_hidden : 0 or 1 - if the message should be hidden, 0 otherwise ++ """ ++ if is_hidden not in [0, 1]: ++ raise MessageTranslationError("is_hidden must be 0 or 1, got %s") ++ self.__is_hidden = is_hidden ++ ++ def IsHidden(self): ++ """Returns 1 if this message is hidden, and 0 otherwise.""" ++ return self.__is_hidden ++ ++# ---------------------------------------------------- ++# The Translation class represents translated messages ++ ++class Translation(BaseMessage): ++ # See BaseMessage constructor ++ def __init__(self, source_encoding, text=None, id=None, ++ description=None, placeholders=None, source=None, ++ sequence_number=0, clone_from=None, ignore_ph_errors=0, ++ name=None): ++ if clone_from is not None: ++ BaseMessage.__init__(self, None, clone_from=clone_from) ++ return ++ ++ BaseMessage.__init__(self, source_encoding, text, id, description, ++ placeholders, source, sequence_number, ++ ignore_ph_errors=ignore_ph_errors, name=name) ++ ++ # String representation ++ def __str__(self): ++ s = 'source: %s, id: %s, content: "%s", description: "%s"' % \ ++ (self.GetSourcesAsText(), self.GetId(), self.GetPresentableContent(), ++ self.GetDescription()); ++ placeholders = self.GetPlaceholders() ++ for i in range(len(placeholders)): ++ s += ", placeholder[%d]: %s" % (i, placeholders[i]) ++ return s ++ ++ # Equality operator ++ def EqualTo(self, other, strict=1): ++ # Check id and content ++ if self.GetId() != other.GetId(): ++ return 0 ++ if self.GetPresentableContent() != other.GetPresentableContent(): ++ return 0 ++ # Check placeholders ++ ph1 = self.GetPlaceholders() ++ ph2 = other.GetPlaceholders() ++ if len(ph1) != len(ph2): ++ return 0 ++ for i in range(len(ph1)): ++ if not ph1[i].EqualTo(ph2[i], strict): ++ return 0 ++ ++ return 1 ++ ++ def Copy(self): ++ """ ++ Returns a copy of this Translation. ++ """ ++ return Translation(None, clone_from=self) +diff --git a/tools/grit/grit/format/__init__.py b/tools/grit/grit/format/__init__.py +new file mode 100644 +index 0000000000..55d56b8cfd +--- /dev/null ++++ b/tools/grit/grit/format/__init__.py +@@ -0,0 +1,8 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+ private: -+ friend class base::RefCounted; -+}; ++'''Module grit.format ++''' + -+// Unsafe; should error. -+class PublicRefCountedThreadSafeDtorInHeader -+ : public base::RefCountedThreadSafe< -+ PublicRefCountedThreadSafeDtorInHeader> { -+ public: -+ PublicRefCountedThreadSafeDtorInHeader() {} -+ ~PublicRefCountedThreadSafeDtorInHeader() {} -+ -+ private: -+ friend class base::RefCountedThreadSafe< -+ PublicRefCountedThreadSafeDtorInHeader>; -+}; ++pass +diff --git a/tools/grit/grit/format/android_xml.py b/tools/grit/grit/format/android_xml.py +new file mode 100644 +index 0000000000..7eb288891f +--- /dev/null ++++ b/tools/grit/grit/format/android_xml.py +@@ -0,0 +1,212 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+// Safe; should not have errors. -+class ProtectedRefCountedDtorInHeader -+ : public base::RefCounted { -+ public: -+ ProtectedRefCountedDtorInHeader() {} ++"""Produces localized strings.xml files for Android. + -+ protected: -+ ~ProtectedRefCountedDtorInHeader() {} ++In cases where an "android" type output file is requested in a grd, the classes ++in android_xml will process the messages and translations to produce a valid ++strings.xml that is properly localized with the specified language. + -+ private: -+ friend class base::RefCounted; -+}; ++For example if the following output tag were to be included in a grd file ++ ++ ... ++ ++ ... ++ + -+// Safe; should not have errors. -+class PrivateRefCountedDtorInHeader -+ : public base::RefCounted { -+ public: -+ PrivateRefCountedDtorInHeader() {} ++for a grd file with the following messages: + -+ private: -+ ~PrivateRefCountedDtorInHeader() {} -+ friend class base::RefCounted; -+}; ++ Hello ++ world + -+// Unsafe; A grandchild class ends up exposing their parent and grandparent's -+// destructors. -+class DerivedProtectedToPublicInHeader -+ : public ProtectedRefCountedDtorInHeader { -+ public: -+ DerivedProtectedToPublicInHeader() {} -+ ~DerivedProtectedToPublicInHeader() {} -+}; ++and there existed an appropriate xtb file containing the Spanish translations, ++then the output would be: + -+// Unsafe; A grandchild ends up implicitly exposing their parent and -+// grantparent's destructors. -+class ImplicitDerivedProtectedToPublicInHeader -+ : public ProtectedRefCountedDtorInHeader { -+ public: -+ ImplicitDerivedProtectedToPublicInHeader() {} -+}; ++ ++ ++ "Hola" ++ "mundo" ++ + -+// Unsafe-but-ignored; should not have errors. -+class WebKitPublicDtorInHeader -+ : public WebKit::RefCounted { -+ public: -+ WebKitPublicDtorInHeader() {} -+ ~WebKitPublicDtorInHeader() {} -+}; ++which would be written to values-es/strings.xml and usable by the Android ++resource framework. + -+// Unsafe-but-ignored; should not have errors. -+class WebKitDerivedPublicDtorInHeader -+ : public WebKitPublicDtorInHeader { -+ public: -+ WebKitDerivedPublicDtorInHeader() {} -+ ~WebKitDerivedPublicDtorInHeader() {} -+}; ++Advanced usage ++-------------- + -+#endif // BASE_REFCOUNTED_H_ -diff --git a/tools/clang/plugins/tests/base_refcounted.txt b/tools/clang/plugins/tests/base_refcounted.txt -new file mode 100644 -index 0000000000..4626424177 ---- /dev/null -+++ b/tools/clang/plugins/tests/base_refcounted.txt -@@ -0,0 +1,23 @@ -+In file included from base_refcounted.cpp:5: -+./base_refcounted.h:45:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. -+ ~PublicRefCountedDtorInHeader() {} -+ ^ -+./base_refcounted.h:57:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. -+ ~PublicRefCountedThreadSafeDtorInHeader() {} -+ ^ -+./base_refcounted.h:94:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. -+ ~DerivedProtectedToPublicInHeader() {} -+ ^ -+./base_refcounted.h:99:1: warning: [chromium-style] Classes that are ref-counted should have explicit destructors that are protected or private. -+class ImplicitDerivedProtectedToPublicInHeader -+^ -+base_refcounted.cpp:16:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. -+ ~AnonymousDerivedProtectedToPublicInImpl() {} -+ ^ -+base_refcounted.cpp:26:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. -+ ~PublicRefCountedDtorInImpl() {} -+ ^ -+base_refcounted.cpp:52:3: warning: [chromium-style] Classes that are ref-counted should not have public destructors. -+ ~UnsafeTypedefChainInImpl() {} -+ ^ -+7 warnings generated. -diff --git a/tools/clang/plugins/tests/inline_copy_ctor.cpp b/tools/clang/plugins/tests/inline_copy_ctor.cpp -new file mode 100644 -index 0000000000..dcd90020c5 ---- /dev/null -+++ b/tools/clang/plugins/tests/inline_copy_ctor.cpp -@@ -0,0 +1,5 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++To process only certain messages in a grd file, tag each desired message by ++adding "android_java" to formatter_data. Then set the environmental variable ++ANDROID_JAVA_TAGGED_ONLY to "true" when building the grd file. For example: + -+#include "inline_copy_ctor.h" -diff --git a/tools/clang/plugins/tests/inline_copy_ctor.h b/tools/clang/plugins/tests/inline_copy_ctor.h -new file mode 100644 -index 0000000000..619a18392b ---- /dev/null -+++ b/tools/clang/plugins/tests/inline_copy_ctor.h -@@ -0,0 +1,12 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++ Hello + -+struct C { -+ C(); -+ ~C(); ++To generate Android plurals (aka "quantity strings"), use the ICU plural syntax ++in the grd file. This will automatically be transformed into a element ++in the output xml file. For example: + -+ static C foo() { return C(); } ++ ++ {NUM_CATS, plural, ++ =1 {1 cat} ++ other {# cats}} ++ + -+ int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p , q, r, s, t, u, v, w, x; -+}; -diff --git a/tools/clang/plugins/tests/inline_copy_ctor.txt b/tools/clang/plugins/tests/inline_copy_ctor.txt -new file mode 100644 -index 0000000000..bc4bd8911e ---- /dev/null -+++ b/tools/clang/plugins/tests/inline_copy_ctor.txt -@@ -0,0 +1,5 @@ -+In file included from inline_copy_ctor.cpp:5: -+./inline_copy_ctor.h:5:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line copy constructor. -+struct C { -+^ -+1 warning generated. -diff --git a/tools/clang/plugins/tests/inline_ctor.cpp b/tools/clang/plugins/tests/inline_ctor.cpp -new file mode 100644 -index 0000000000..6a751fb405 ---- /dev/null -+++ b/tools/clang/plugins/tests/inline_ctor.cpp -@@ -0,0 +1,25 @@ -+// Copyright (c) 2011 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++ will produce + -+#include "inline_ctor.h" ++ ++ 1 Katze ++ %d Katzen ++ ++""" + -+#include -+#include ++from __future__ import print_function + -+// We don't warn on classes that are in CPP files. -+class InlineInCPPOK { -+ public: -+ InlineInCPPOK() {} -+ ~InlineInCPPOK() {} ++import os ++import re ++import xml.sax.saxutils ++ ++from grit import lazy_re ++from grit.node import message ++ ++ ++# When this environmental variable has value "true", only tagged messages will ++# be outputted. ++_TAGGED_ONLY_ENV_VAR = 'ANDROID_JAVA_TAGGED_ONLY' ++_TAGGED_ONLY_DEFAULT = False ++ ++# In tagged-only mode, only messages with this tag will be ouputted. ++_EMIT_TAG = 'android_java' ++ ++_NAME_PATTERN = lazy_re.compile(r'IDS_(?P[A-Z0-9_]+)\Z') ++ ++# Most strings are output as a element. Note the double quotes ++# around the value to preserve whitespace. ++_STRING_TEMPLATE = u'"%s"\n' ++ ++# Some strings are output as a element. ++_PLURALS_TEMPLATE = '\n%s\n' ++_PLURALS_ITEM_TEMPLATE = ' %s\n' ++ ++# Matches e.g. "{HELLO, plural, HOW ARE YOU DOING}", while capturing ++# "HOW ARE YOU DOING" in . ++_PLURALS_PATTERN = lazy_re.compile(r'\{[A-Z_]+,\s*plural,(?P.*)\}$', ++ flags=re.S) ++ ++# Repeatedly matched against the capture in _PLURALS_PATTERN, ++# to match "{}". ++_PLURALS_ITEM_PATTERN = lazy_re.compile(r'(?P\S+?)\s*' ++ r'\{(?P.*?)\}') ++_PLURALS_QUANTITY_MAP = { ++ '=0': 'zero', ++ 'zero': 'zero', ++ '=1': 'one', ++ 'one': 'one', ++ '=2': 'two', ++ 'two': 'two', ++ 'few': 'few', ++ 'many': 'many', ++ 'other': 'other', ++} + -+ private: -+ std::vector one_; -+ std::vector two_; -+}; + -+int main() { -+ InlineInCPPOK one; -+ InlineCtorsArentOKInHeader two; -+ return 0; -+} -diff --git a/tools/clang/plugins/tests/inline_ctor.h b/tools/clang/plugins/tests/inline_ctor.h ++def Format(root, lang='en', output_dir='.'): ++ yield ('\n' ++ '\n') ++ ++ tagged_only = _TAGGED_ONLY_DEFAULT ++ if _TAGGED_ONLY_ENV_VAR in os.environ: ++ tagged_only = os.environ[_TAGGED_ONLY_ENV_VAR].lower() ++ if tagged_only == 'true': ++ tagged_only = True ++ elif tagged_only == 'false': ++ tagged_only = False ++ else: ++ raise Exception('env variable ANDROID_JAVA_TAGGED_ONLY must have value ' ++ 'true or false. Invalid value: %s' % tagged_only) ++ ++ for item in root.ActiveDescendants(): ++ with item: ++ if ShouldOutputNode(item, tagged_only): ++ yield _FormatMessage(item, lang) ++ ++ yield '\n' ++ ++ ++def ShouldOutputNode(node, tagged_only): ++ """Returns true if node should be outputted. ++ ++ Args: ++ node: a Node from the grd dom ++ tagged_only: true, if only tagged messages should be outputted ++ """ ++ return (isinstance(node, message.MessageNode) and ++ (not tagged_only or _EMIT_TAG in node.formatter_data)) ++ ++ ++def _FormatPluralMessage(message): ++ """Compiles ICU plural syntax to the body of an Android element. ++ ++ 1. In a .grd file, we can write a plural string like this: ++ ++ ++ {NUM_THINGS, plural, ++ =1 {1 thing} ++ other {# things}} ++ ++ ++ 2. The Android equivalent looks like this: ++ ++ ++ 1 thing ++ %d things ++ ++ ++ This method takes the body of (1) and converts it to the body of (2). ++ ++ If the message is *not* a plural string, this function returns `None`. ++ If the message includes quantities without an equivalent format in Android, ++ it raises an exception. ++ """ ++ ret = {} ++ plural_match = _PLURALS_PATTERN.match(message) ++ if not plural_match: ++ return None ++ body_in = plural_match.group('items').strip() ++ lines = [] ++ quantities_so_far = set() ++ for item_match in _PLURALS_ITEM_PATTERN.finditer(body_in): ++ quantity_in = item_match.group('quantity') ++ quantity_out = _PLURALS_QUANTITY_MAP.get(quantity_in) ++ value_in = item_match.group('value') ++ value_out = '"' + value_in.replace('#', '%d') + '"' ++ if quantity_out: ++ # only one line per quantity out (https://crbug.com/787488) ++ if quantity_out not in quantities_so_far: ++ quantities_so_far.add(quantity_out) ++ lines.append(_PLURALS_ITEM_TEMPLATE % (quantity_out, value_out)) ++ else: ++ raise Exception('Unsupported plural quantity for android ' ++ 'strings.xml: %s' % quantity_in) ++ return ''.join(lines) ++ ++ ++def _FormatMessage(item, lang): ++ """Writes out a single string as a element.""" ++ ++ mangled_name = item.GetTextualIds()[0] ++ match = _NAME_PATTERN.match(mangled_name) ++ if not match: ++ raise Exception('Unexpected resource name: %s' % mangled_name) ++ name = match.group('name').lower() ++ ++ value = item.ws_at_start + item.Translate(lang) + item.ws_at_end ++ # Replace < > & with < > & to ensure we generate valid XML and ++ # replace ' " with \' \" to conform to Android's string formatting rules. ++ value = xml.sax.saxutils.escape(value, {"'": "\\'", '"': '\\"'}) ++ ++ plurals = _FormatPluralMessage(value) ++ if plurals: ++ return _PLURALS_TEMPLATE % (name, plurals) ++ else: ++ return _STRING_TEMPLATE % (name, value) +diff --git a/tools/grit/grit/format/android_xml_unittest.py b/tools/grit/grit/format/android_xml_unittest.py new file mode 100644 -index 0000000000..d053b2f57d +index 0000000000..d9f476fddf --- /dev/null -+++ b/tools/clang/plugins/tests/inline_ctor.h -@@ -0,0 +1,21 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++++ b/tools/grit/grit/format/android_xml_unittest.py +@@ -0,0 +1,149 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+#ifndef INLINE_CTOR_H_ -+#define INLINE_CTOR_H_ ++"""Unittest for android_xml.py.""" + -+#include -+#include ++from __future__ import print_function + -+class InlineCtorsArentOKInHeader { -+ public: -+ InlineCtorsArentOKInHeader() {} -+ ~InlineCtorsArentOKInHeader() {} ++import os ++import sys ++import unittest + -+ private: -+ std::vector one_; -+ std::vector two_; -+}; ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++from six import StringIO ++ ++from grit import util ++from grit.format import android_xml ++from grit.node import message ++from grit.tool import build ++ ++ ++class AndroidXmlUnittest(unittest.TestCase): ++ ++ def testMessages(self): ++ root = util.ParseGrdForUnittest(r""" ++ ++ ++ Martha ++ ++ sat and wondered ++ ++ out loud, "Why don't I build a flying car?" ++ ++ ++ She gathered ++wood, charcoal, and ++a sledge hammer. ++ ++ ++ ''' How old fashioned -- she thought. ''' ++ ++ ++ I'll buy a %d200 nm laser at %sthe grocery store. ++ ++ ++ {NUM_THINGS, plural, ++ =1 {Maybe I'll get one laser.} ++ other {Maybe I'll get # lasers.}} ++ ++ ++ {NUM_MISSISSIPPIS, plural, ++ =1{OneMississippi}other{ManyMississippis}} ++ ++ ++ """) ++ ++ buf = StringIO() ++ build.RcBuilder.ProcessNode(root, DummyOutput('android', 'en'), buf) ++ output = buf.getvalue() ++ expected = r""" ++ ++ ++"Martha" ++"sat and wondered" ++"out loud, \"Why don\'t I build a flying car?\"" ++"She gathered ++wood, charcoal, and ++a sledge hammer." ++" How old fashioned -- she thought. " ++"I\'ll buy a %d nm laser at %s." ++ ++ "Maybe I\'ll get one laser." ++ "Maybe I\'ll get %d lasers." ++ ++ ++ "OneMississippi" ++ "ManyMississippis" ++ ++ ++""" ++ self.assertEqual(output.strip(), expected.strip()) ++ ++ ++ def testConflictingPlurals(self): ++ root = util.ParseGrdForUnittest(r""" ++ ++ ++ {NUM_THINGS, plural, ++ =1 {Maybe I'll get one laser.} ++ one {Maybe I'll get one laser.} ++ other {Maybe I'll get # lasers.}} ++ ++ ++ """) ++ ++ buf = StringIO() ++ build.RcBuilder.ProcessNode(root, DummyOutput('android', 'en'), buf) ++ output = buf.getvalue() ++ expected = r""" ++ ++ ++ ++ "Maybe I\'ll get one laser." ++ "Maybe I\'ll get %d lasers." ++ ++ ++""" ++ self.assertEqual(output.strip(), expected.strip()) + -+#endif // INLINE_CTOR_H_ -diff --git a/tools/clang/plugins/tests/inline_ctor.txt b/tools/clang/plugins/tests/inline_ctor.txt -new file mode 100644 -index 0000000000..caa0cb4e3b ---- /dev/null -+++ b/tools/clang/plugins/tests/inline_ctor.txt -@@ -0,0 +1,8 @@ -+In file included from inline_ctor.cpp:5: -+./inline_ctor.h:13:3: warning: [chromium-style] Complex constructor has an inlined body. -+ InlineCtorsArentOKInHeader() {} -+ ^ -+./inline_ctor.h:14:3: warning: [chromium-style] Complex destructor has an inline body. -+ ~InlineCtorsArentOKInHeader() {} -+ ^ -+2 warnings generated. -diff --git a/tools/clang/plugins/tests/missing_ctor.cpp b/tools/clang/plugins/tests/missing_ctor.cpp -new file mode 100644 -index 0000000000..8ee2fb2ac8 ---- /dev/null -+++ b/tools/clang/plugins/tests/missing_ctor.cpp -@@ -0,0 +1,23 @@ -+// Copyright (c) 2011 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. + -+#include "missing_ctor.h" ++ def testTaggedOnly(self): ++ root = util.ParseGrdForUnittest(r""" ++ ++ ++ Hello ++ ++ ++ world ++ ++ ++ """) + -+#include -+#include ++ msg_hello, msg_world = root.GetChildrenOfType(message.MessageNode) ++ self.assertTrue(android_xml.ShouldOutputNode(msg_hello, tagged_only=True)) ++ self.assertFalse(android_xml.ShouldOutputNode(msg_world, tagged_only=True)) ++ self.assertTrue(android_xml.ShouldOutputNode(msg_hello, tagged_only=False)) ++ self.assertTrue(android_xml.ShouldOutputNode(msg_world, tagged_only=False)) + -+// We don't warn on classes that use default ctors in cpp files. -+class MissingInCPPOK { -+ public: + -+ private: -+ std::vector one_; -+ std::vector two_; -+}; ++class DummyOutput(object): + -+int main() { -+ MissingInCPPOK one; -+ MissingCtorsArentOKInHeader two; -+ return 0; -+} -diff --git a/tools/clang/plugins/tests/missing_ctor.h b/tools/clang/plugins/tests/missing_ctor.h -new file mode 100644 -index 0000000000..1050457a1a ---- /dev/null -+++ b/tools/clang/plugins/tests/missing_ctor.h -@@ -0,0 +1,19 @@ -+// Copyright (c) 2011 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++ def __init__(self, type, language): ++ self.type = type ++ self.language = language + -+#ifndef MISSING_CTOR_H_ -+#define MISSING_CTOR_H_ ++ def GetType(self): ++ return self.type + -+#include -+#include ++ def GetLanguage(self): ++ return self.language + -+class MissingCtorsArentOKInHeader { -+ public: ++ def GetOutputFilename(self): ++ return 'hello.gif' + -+ private: -+ std::vector one_; -+ std::vector two_; -+}; ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/format/c_format.py b/tools/grit/grit/format/c_format.py +new file mode 100644 +index 0000000000..16809a9f70 +--- /dev/null ++++ b/tools/grit/grit/format/c_format.py +@@ -0,0 +1,95 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Formats as a .C file for compilation. ++""" ++ ++from __future__ import print_function + -+#endif // MISSING_CTOR_H_ -diff --git a/tools/clang/plugins/tests/missing_ctor.txt b/tools/clang/plugins/tests/missing_ctor.txt ++import codecs ++import os ++import re ++ ++import six ++ ++from grit import util ++ ++ ++def _FormatHeader(root, output_dir): ++ """Returns the required preamble for C files.""" ++ # Find the location of the resource header file, so that we can include ++ # it. ++ resource_header = 'resource.h' # fall back to this ++ for output in root.GetOutputFiles(): ++ if output.attrs['type'] == 'rc_header': ++ resource_header = os.path.abspath(output.GetOutputFilename()) ++ resource_header = util.MakeRelativePath(output_dir, resource_header) ++ return """// This file is automatically generated by GRIT. Do not edit. ++ ++#include "%s" ++ ++// All strings are UTF-8 ++""" % (resource_header) ++# end _FormatHeader() function ++ ++ ++def Format(root, lang='en', output_dir='.'): ++ """Outputs a C switch statement representing the string table.""" ++ from grit.node import message ++ assert isinstance(lang, six.string_types) ++ ++ yield _FormatHeader(root, output_dir) ++ ++ yield 'const char* GetString(int id) {\n switch (id) {' ++ ++ for item in root.ActiveDescendants(): ++ with item: ++ if isinstance(item, message.MessageNode): ++ yield _FormatMessage(item, lang) ++ ++ yield '\n default:\n return 0;\n }\n}\n' ++ ++ ++def _HexToOct(match): ++ "Return the octal form of the hex numbers" ++ hex = match.group("hex") ++ result = "" ++ while len(hex): ++ next_num = int(hex[2:4], 16) ++ result += "\\" + '%03o' % next_num ++ hex = hex[4:] ++ return match.group("escaped_backslashes") + result ++ ++ ++def _FormatMessage(item, lang): ++ """Format a single element.""" ++ ++ message = item.ws_at_start + item.Translate(lang) + item.ws_at_end ++ # Output message with non-ascii chars escaped as octal numbers C's grammar ++ # allows escaped hexadecimal numbers to be infinite, but octal is always of ++ # the form \OOO. Python 3 doesn't support string-escape, so we have to jump ++ # through some hoops here via codecs.escape_encode. ++ # This basically does: ++ # - message - the starting string ++ # - message.encode(...) - convert to bytes ++ # - codecs.escape_encode(...) - convert non-ASCII bytes to \x## escapes ++ # - (...).decode() - convert bytes back to a string ++ message = codecs.escape_encode(message.encode('utf-8'))[0].decode('utf-8') ++ # an escaped char is (\xHH)+ but only if the initial ++ # backslash is not escaped. ++ not_a_backslash = r"(^|[^\\])" # beginning of line or a non-backslash char ++ escaped_backslashes = not_a_backslash + r"(\\\\)*" ++ hex_digits = r"((\\x)[0-9a-f]{2})+" ++ two_digit_hex_num = re.compile( ++ r"(?P%s)(?P%s)" ++ % (escaped_backslashes, hex_digits)) ++ message = two_digit_hex_num.sub(_HexToOct, message) ++ # unescape \ (convert \\ back to \) ++ message = message.replace('\\\\', '\\') ++ message = message.replace('"', '\\"') ++ message = util.LINEBREAKS.sub(r'\\n', message) ++ ++ name_attr = item.GetTextualIds()[0] ++ ++ return '\n case %s:\n return "%s";' % (name_attr, message) +diff --git a/tools/grit/grit/format/c_format_unittest.py b/tools/grit/grit/format/c_format_unittest.py new file mode 100644 -index 0000000000..301449c4ac +index 0000000000..380120c42f --- /dev/null -+++ b/tools/clang/plugins/tests/missing_ctor.txt -@@ -0,0 +1,6 @@ -+In file included from missing_ctor.cpp:5: -+./missing_ctor.h:11:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line constructor. -+class MissingCtorsArentOKInHeader { -+^ -+./missing_ctor.h:11:1: warning: [chromium-style] Complex class/struct needs an explicit out-of-line destructor. -+2 warnings generated. -diff --git a/tools/clang/plugins/tests/nested_class_inline_ctor.cpp b/tools/clang/plugins/tests/nested_class_inline_ctor.cpp ++++ b/tools/grit/grit/format/c_format_unittest.py +@@ -0,0 +1,81 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Unittest for c_format.py. ++""" ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++from six import StringIO ++ ++from grit import util ++from grit.tool import build ++ ++ ++class CFormatUnittest(unittest.TestCase): ++ ++ def testMessages(self): ++ root = util.ParseGrdForUnittest(u""" ++ ++ Do you want to play questions? ++ ++ "What's in a name, %sBrandon?" ++ ++ ++ Was that rhetoric? ++No. ++Statement. Two all. Game point. ++ ++ ++ \u00f5\\xc2\\xa4\\\u00a4\\\\xc3\\xb5\u4924 ++ ++ ++ """) ++ ++ buf = StringIO() ++ build.RcBuilder.ProcessNode(root, DummyOutput('c_format', 'en'), buf) ++ output = util.StripBlankLinesAndComments(buf.getvalue()) ++ self.assertEqual(u"""\ ++#include "resource.h" ++const char* GetString(int id) { ++ switch (id) { ++ case IDS_QUESTIONS: ++ return "Do you want to play questions?"; ++ case IDS_QUOTES: ++ return "\\"What\\'s in a name, %s?\\""; ++ case IDS_LINE_BREAKS: ++ return "Was that rhetoric?\\nNo.\\nStatement. Two all. Game point."; ++ case IDS_NON_ASCII: ++ return "\\303\\265\\xc2\\xa4\\\\302\\244\\\\xc3\\xb5\\344\\244\\244"; ++ default: ++ return 0; ++ } ++}""", output) ++ ++ ++class DummyOutput(object): ++ ++ def __init__(self, type, language): ++ self.type = type ++ self.language = language ++ ++ def GetType(self): ++ return self.type ++ ++ def GetLanguage(self): ++ return self.language ++ ++ def GetOutputFilename(self): ++ return 'hello.gif' ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/format/chrome_messages_json.py b/tools/grit/grit/format/chrome_messages_json.py new file mode 100644 -index 0000000000..aa90a95eb3 +index 0000000000..88ec1d914b --- /dev/null -+++ b/tools/clang/plugins/tests/nested_class_inline_ctor.cpp -@@ -0,0 +1,5 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++++ b/tools/grit/grit/format/chrome_messages_json.py +@@ -0,0 +1,59 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+#include "nested_class_inline_ctor.h" -diff --git a/tools/clang/plugins/tests/nested_class_inline_ctor.h b/tools/clang/plugins/tests/nested_class_inline_ctor.h ++"""Formats as a .json file that can be used to localize Google Chrome ++extensions.""" ++ ++from __future__ import print_function ++ ++from json import JSONEncoder ++ ++from grit import constants ++from grit.node import message ++ ++def Format(root, lang='en', output_dir='.'): ++ """Format the messages as JSON.""" ++ yield '{' ++ ++ encoder = JSONEncoder(ensure_ascii=False) ++ format = '"%s":{"message":%s%s}' ++ placeholder_format = '"%i":{"content":"$%i"}' ++ first = True ++ for child in root.ActiveDescendants(): ++ if isinstance(child, message.MessageNode): ++ id = child.attrs['name'] ++ if id.startswith('IDR_') or id.startswith('IDS_'): ++ id = id[4:] ++ ++ translation_missing = child.GetCliques()[0].clique.get(lang) is None; ++ if (child.ShouldFallbackToEnglish() and translation_missing and ++ lang != constants.FAKE_BIDI): ++ # Skip the string if it's not translated. Chrome will fallback ++ # to English automatically. ++ continue ++ ++ loc_message = encoder.encode(child.ws_at_start + child.Translate(lang) + ++ child.ws_at_end) ++ ++ # Replace $n place-holders with $n$ and add an appropriate "placeholders" ++ # entry. Note that chrome.i18n.getMessage only supports 9 placeholders: ++ # https://developer.chrome.com/extensions/i18n#method-getMessage ++ placeholders = '' ++ for i in range(1, 10): ++ if loc_message.find('$%d' % i) == -1: ++ break ++ loc_message = loc_message.replace('$%d' % i, '$%d$' % i) ++ if placeholders: ++ placeholders += ',' ++ placeholders += placeholder_format % (i, i) ++ ++ if not first: ++ yield ',' ++ first = False ++ ++ if placeholders: ++ placeholders = ',"placeholders":{%s}' % placeholders ++ yield format % (id, loc_message, placeholders) ++ ++ yield '}' +diff --git a/tools/grit/grit/format/chrome_messages_json_unittest.py b/tools/grit/grit/format/chrome_messages_json_unittest.py new file mode 100644 -index 0000000000..01cfea9232 +index 0000000000..a54e6bdc1c --- /dev/null -+++ b/tools/clang/plugins/tests/nested_class_inline_ctor.h -@@ -0,0 +1,22 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++++ b/tools/grit/grit/format/chrome_messages_json_unittest.py +@@ -0,0 +1,190 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Unittest for chrome_messages_json.py. ++""" ++ ++from __future__ import print_function + -+#ifndef NESTED_CLASS_INLINE_CTOR_H_ -+#define NESTED_CLASS_INLINE_CTOR_H_ ++import json ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++from six import StringIO ++ ++from grit import grd_reader ++from grit import util ++from grit.tool import build ++ ++class ChromeMessagesJsonFormatUnittest(unittest.TestCase): ++ ++ # The default unittest diff limit is too low for our unittests. ++ # Allow the framework to show the full diff output all the time. ++ maxDiff = None ++ ++ def testMessages(self): ++ root = util.ParseGrdForUnittest(u""" ++ ++ ++ Simple message. ++ ++ ++ element\u2019s \u201c%sname\u201d attribute ++ ++ ++ %1$d1 error, %2$d1 warning ++ ++ ++ $1atest$2b ++ ++ ++ ''' (%d2) ++ ++ ++ (%d2) ''' ++ ++ ++ ''' (%d2) ''' ++ ++ ++ A "double quoted" message. ++ ++ ++ \\ ++ ++ ++ """) ++ ++ buf = StringIO() ++ build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'en'), ++ buf) ++ output = buf.getvalue() ++ test = u""" ++{ ++ "SIMPLE_MESSAGE": { ++ "message": "Simple message." ++ }, ++ "QUOTES": { ++ "message": "element\u2019s \u201c%s\u201d attribute" ++ }, ++ "PLACEHOLDERS": { ++ "message": "%1$d error, %2$d warning" ++ }, ++ "PLACEHOLDERS_SUBSTITUTED_BY_GETMESSAGE": { ++ "message": "$1$test$2$", ++ "placeholders": { ++ "1": { ++ "content": "$1" ++ }, ++ "2": { ++ "content": "$2" ++ } ++ } ++ }, ++ "STARTS_WITH_SPACE": { ++ "message": " (%d)" ++ }, ++ "ENDS_WITH_SPACE": { ++ "message": "(%d) " ++ }, ++ "SPACE_AT_BOTH_ENDS": { ++ "message": " (%d) " ++ }, ++ "DOUBLE_QUOTES": { ++ "message": "A \\"double quoted\\" message." ++ }, ++ "BACKSLASH": { ++ "message": "\\\\" ++ } ++} ++""" ++ self.assertEqual(json.loads(test), json.loads(output)) ++ ++ def testTranslations(self): ++ root = util.ParseGrdForUnittest(""" ++ ++ Hello! ++ Hello %s ++ Joi ++ ++ """) ++ ++ buf = StringIO() ++ build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'fr'), ++ buf) ++ output = buf.getvalue() ++ test = u""" ++{ ++ "ID_HELLO": { ++ "message": "H\u00e9P\u00e9ll\u00f4P\u00f4!" ++ }, ++ "ID_HELLO_USER": { ++ "message": "H\u00e9P\u00e9ll\u00f4P\u00f4 %s" ++ } ++} ++""" ++ self.assertEqual(json.loads(test), json.loads(output)) ++ ++ def testSkipMissingTranslations(self): ++ grd = """ ++ ++ ++ ++ ++ ++ Hello not translated ++ ++ ++""" ++ root = grd_reader.Parse(StringIO(grd), dir=".") ++ ++ buf = StringIO() ++ build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'fr'), ++ buf) ++ output = buf.getvalue() ++ test = u'{}' ++ self.assertEqual(test, output) ++ ++ def testVerifyMinification(self): ++ root = util.ParseGrdForUnittest(u""" ++ ++ ++ $1atest$2b ++ ++ ++ """) ++ ++ buf = StringIO() ++ build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'en'), ++ buf) ++ output = buf.getvalue() ++ test = (u'{"IDS":{"message":"$1$test$2$","placeholders":' ++ u'{"1":{"content":"$1"},"2":{"content":"$2"}}}}') ++ self.assertEqual(test, output) ++ ++ ++class DummyOutput(object): ++ ++ def __init__(self, type, language): ++ self.type = type ++ self.language = language ++ ++ def GetType(self): ++ return self.type ++ ++ def GetLanguage(self): ++ return self.language ++ ++ def GetOutputFilename(self): ++ return 'hello.gif' + -+#include -+#include + -+// See crbug.com/136863. ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/format/data_pack.py b/tools/grit/grit/format/data_pack.py +new file mode 100644 +index 0000000000..f7128a4725 +--- /dev/null ++++ b/tools/grit/grit/format/data_pack.py +@@ -0,0 +1,321 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+class Foo { -+ class Bar { -+ Bar() {} -+ ~Bar() {} ++"""Support for formatting a data pack file used for platform agnostic resource ++files. ++""" + -+ std::vector a; -+ }; -+}; ++from __future__ import print_function + -+#endif // NESTED_CLASS_INLINE_CTOR_H_ -diff --git a/tools/clang/plugins/tests/nested_class_inline_ctor.txt b/tools/clang/plugins/tests/nested_class_inline_ctor.txt ++import collections ++import os ++import struct ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import six ++ ++from grit import util ++from grit.node import include ++from grit.node import message ++from grit.node import structure ++ ++ ++PACK_FILE_VERSION = 5 ++BINARY, UTF8, UTF16 = range(3) ++ ++ ++GrdInfoItem = collections.namedtuple('GrdInfoItem', ++ ['textual_id', 'id', 'path']) ++ ++ ++class WrongFileVersion(Exception): ++ pass ++ ++ ++class CorruptDataPack(Exception): ++ pass ++ ++ ++class DataPackSizes(object): ++ def __init__(self, header, id_table, alias_table, data): ++ self.header = header ++ self.id_table = id_table ++ self.alias_table = alias_table ++ self.data = data ++ ++ @property ++ def total(self): ++ return sum(v for v in self.__dict__.values()) ++ ++ def __iter__(self): ++ yield ('header', self.header) ++ yield ('id_table', self.id_table) ++ yield ('alias_table', self.alias_table) ++ yield ('data', self.data) ++ ++ def __eq__(self, other): ++ return self.__dict__ == other.__dict__ ++ ++ def __repr__(self): ++ return self.__class__.__name__ + repr(self.__dict__) ++ ++ ++class DataPackContents(object): ++ def __init__(self, resources, encoding, version, aliases, sizes): ++ # Map of resource_id -> str. ++ self.resources = resources ++ # Encoding (int). ++ self.encoding = encoding ++ # Version (int). ++ self.version = version ++ # Map of resource_id->canonical_resource_id ++ self.aliases = aliases ++ # DataPackSizes instance. ++ self.sizes = sizes ++ ++ ++def Format(root, lang='en', output_dir='.'): ++ """Writes out the data pack file format (platform agnostic resource file).""" ++ id_map = root.GetIdMap() ++ data = {} ++ root.info = [] ++ for node in root.ActiveDescendants(): ++ with node: ++ if isinstance(node, (include.IncludeNode, message.MessageNode, ++ structure.StructureNode)): ++ value = node.GetDataPackValue(lang, util.BINARY) ++ if value is not None: ++ resource_id = id_map[node.GetTextualIds()[0]] ++ data[resource_id] = value ++ root.info.append('{},{},{}'.format( ++ node.attrs.get('name'), resource_id, node.source)) ++ return WriteDataPackToString(data, UTF8) ++ ++ ++def ReadDataPack(input_file): ++ return ReadDataPackFromString(util.ReadFile(input_file, util.BINARY)) ++ ++ ++def ReadDataPackFromString(data): ++ """Reads a data pack file and returns a dictionary.""" ++ # Read the header. ++ version = struct.unpack('data in the data pack format.""" ++ ret = [] ++ ++ # Compute alias map. ++ resource_ids = sorted(resources) ++ # Use reversed() so that for duplicates lower IDs clobber higher ones. ++ id_by_data = {resources[k]: k for k in reversed(resource_ids)} ++ # Map of resource_id -> resource_id, where value < key. ++ alias_map = {k: id_by_data[v] for k, v in resources.items() ++ if id_by_data[v] != k} ++ ++ # Write file header. ++ resource_count = len(resources) - len(alias_map) ++ # Padding bytes added for alignment. ++ ret.append(struct.pack('data into output_file as a data pack.""" ++ content = WriteDataPackToString(resources, encoding) ++ with open(output_file, 'wb') as file: ++ file.write(content) ++ ++ ++def ReadGrdInfo(grd_file): ++ info_dict = {} ++ with open(grd_file + '.info', 'rt') as f: ++ for line in f: ++ item = GrdInfoItem._make(line.strip().split(',')) ++ info_dict[int(item.id)] = item ++ return info_dict ++ ++ ++def RePack(output_file, input_files, whitelist_file=None, ++ suppress_removed_key_output=False, ++ output_info_filepath=None): ++ """Write a new data pack file by combining input pack files. ++ ++ Args: ++ output_file: path to the new data pack file. ++ input_files: a list of paths to the data pack files to combine. ++ whitelist_file: path to the file that contains the list of resource IDs ++ that should be kept in the output file or None to include ++ all resources. ++ suppress_removed_key_output: allows the caller to suppress the output from ++ RePackFromDataPackStrings. ++ output_info_file: If not None, specify the output .info filepath. ++ ++ Raises: ++ KeyError: if there are duplicate keys or resource encoding is ++ inconsistent. ++ """ ++ input_data_packs = [ReadDataPack(filename) for filename in input_files] ++ input_info_files = [filename + '.info' for filename in input_files] ++ whitelist = None ++ if whitelist_file: ++ lines = util.ReadFile(whitelist_file, 'utf-8').strip().splitlines() ++ if not lines: ++ raise Exception('Whitelist file should not be empty') ++ whitelist = set(int(x) for x in lines) ++ inputs = [(p.resources, p.encoding) for p in input_data_packs] ++ resources, encoding = RePackFromDataPackStrings( ++ inputs, whitelist, suppress_removed_key_output) ++ WriteDataPack(resources, output_file, encoding) ++ if output_info_filepath is None: ++ output_info_filepath = output_file + '.info' ++ with open(output_info_filepath, 'w') as output_info_file: ++ for filename in input_info_files: ++ with open(filename, 'r') as info_file: ++ output_info_file.writelines(info_file.readlines()) ++ ++ ++def RePackFromDataPackStrings(inputs, whitelist, ++ suppress_removed_key_output=False): ++ """Combines all inputs into one. ++ ++ Args: ++ inputs: a list of (resources_by_id, encoding) tuples to be combined. ++ whitelist: a list of resource IDs that should be kept in the output string ++ or None to include all resources. ++ suppress_removed_key_output: Do not print removed keys. ++ ++ Returns: ++ Returns (resources_by_id, encoding). ++ ++ Raises: ++ KeyError: if there are duplicate keys or resource encoding is ++ inconsistent. ++ """ ++ resources = {} ++ encoding = None ++ for input_resources, input_encoding in inputs: ++ # Make sure we have no dups. ++ duplicate_keys = set(input_resources.keys()) & set(resources.keys()) ++ if duplicate_keys: ++ raise KeyError('Duplicate keys: ' + str(list(duplicate_keys))) ++ ++ # Make sure encoding is consistent. ++ if encoding in (None, BINARY): ++ encoding = input_encoding ++ elif input_encoding not in (BINARY, encoding): ++ raise KeyError('Inconsistent encodings: ' + str(encoding) + ++ ' vs ' + str(input_encoding)) ++ ++ if whitelist: ++ whitelisted_resources = dict([(key, input_resources[key]) ++ for key in input_resources.keys() ++ if key in whitelist]) ++ resources.update(whitelisted_resources) ++ removed_keys = [key for key in input_resources.keys() ++ if key not in whitelist] ++ if not suppress_removed_key_output: ++ for key in removed_keys: ++ print('RePackFromDataPackStrings Removed Key:', key) ++ else: ++ resources.update(input_resources) ++ ++ # Encoding is 0 for BINARY, 1 for UTF8 and 2 for UTF16 ++ if encoding is None: ++ encoding = BINARY ++ return resources, encoding ++ ++ ++def main(): ++ # Write a simple file. ++ data = {1: '', 4: 'this is id 4', 6: 'this is id 6', 10: ''} ++ WriteDataPack(data, 'datapack1.pak', UTF8) ++ data2 = {1000: 'test', 5: 'five'} ++ WriteDataPack(data2, 'datapack2.pak', UTF8) ++ print('wrote datapack1 and datapack2 to current directory.') ++ ++ ++if __name__ == '__main__': ++ main() +diff --git a/tools/grit/grit/format/data_pack_unittest.py b/tools/grit/grit/format/data_pack_unittest.py new file mode 100644 -index 0000000000..39bd6e1dce +index 0000000000..fcd7035473 --- /dev/null -+++ b/tools/clang/plugins/tests/nested_class_inline_ctor.txt -@@ -0,0 +1,8 @@ -+In file included from nested_class_inline_ctor.cpp:5: -+./nested_class_inline_ctor.h:15:5: warning: [chromium-style] Complex constructor has an inlined body. -+ Bar() {} -+ ^ -+./nested_class_inline_ctor.h:16:5: warning: [chromium-style] Complex destructor has an inline body. -+ ~Bar() {} -+ ^ -+2 warnings generated. -diff --git a/tools/clang/plugins/tests/overridden_methods.cpp b/tools/clang/plugins/tests/overridden_methods.cpp -new file mode 100644 -index 0000000000..f572a41733 ---- /dev/null -+++ b/tools/clang/plugins/tests/overridden_methods.cpp -@@ -0,0 +1,38 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. ++++ b/tools/grit/grit/format/data_pack_unittest.py +@@ -0,0 +1,102 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+#include "overridden_methods.h" ++'''Unit tests for grit.format.data_pack''' + -+// Fill in the implementations -+void DerivedClass::SomeMethod() {} -+void DerivedClass::SomeOtherMethod() {} -+void DerivedClass::WebKitModifiedSomething() {} ++from __future__ import print_function + -+class ImplementationInterimClass : public BaseClass { -+ public: -+ // Should not warn about pure virtual methods. -+ virtual void SomeMethod() = 0; -+}; ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++from grit.format import data_pack ++ ++ ++class FormatDataPackUnittest(unittest.TestCase): ++ def testReadDataPackV4(self): ++ expected_data = ( ++ b'\x04\x00\x00\x00' # header(version ++ b'\x04\x00\x00\x00' # no. entries, ++ b'\x01' # encoding) ++ b'\x01\x00\x27\x00\x00\x00' # index entry 1 ++ b'\x04\x00\x27\x00\x00\x00' # index entry 4 ++ b'\x06\x00\x33\x00\x00\x00' # index entry 6 ++ b'\x0a\x00\x3f\x00\x00\x00' # index entry 10 ++ b'\x00\x00\x3f\x00\x00\x00' # extra entry for the size of last ++ b'this is id 4this is id 6') # data ++ expected_data_pack = data_pack.DataPackContents( ++ { ++ 1: b'', ++ 4: b'this is id 4', ++ 6: b'this is id 6', ++ 10: b'', ++ }, data_pack.UTF8, 4, {}, data_pack.DataPackSizes(9, 30, 0, 24)) ++ loaded = data_pack.ReadDataPackFromString(expected_data) ++ self.assertDictEqual(expected_data_pack.__dict__, loaded.__dict__) ++ ++ def testReadWriteDataPackV5(self): ++ expected_data = ( ++ b'\x05\x00\x00\x00' # version ++ b'\x01\x00\x00\x00' # encoding & padding ++ b'\x03\x00' # resource_count ++ b'\x01\x00' # alias_count ++ b'\x01\x00\x28\x00\x00\x00' # index entry 1 ++ b'\x04\x00\x28\x00\x00\x00' # index entry 4 ++ b'\x06\x00\x34\x00\x00\x00' # index entry 6 ++ b'\x00\x00\x40\x00\x00\x00' # extra entry for the size of last ++ b'\x0a\x00\x01\x00' # alias table ++ b'this is id 4this is id 6') # data ++ input_resources = { ++ 1: b'', ++ 4: b'this is id 4', ++ 6: b'this is id 6', ++ 10: b'this is id 4', ++ } ++ data = data_pack.WriteDataPackToString(input_resources, data_pack.UTF8) ++ self.assertEquals(data, expected_data) ++ ++ expected_data_pack = data_pack.DataPackContents({ ++ 1: b'', ++ 4: input_resources[4], ++ 6: input_resources[6], ++ 10: input_resources[4], ++ }, data_pack.UTF8, 5, {10: 4}, data_pack.DataPackSizes(12, 24, 4, 24)) ++ loaded = data_pack.ReadDataPackFromString(expected_data) ++ self.assertDictEqual(expected_data_pack.__dict__, loaded.__dict__) ++ ++ def testRePackUnittest(self): ++ expected_with_whitelist = { ++ 1: 'Never gonna', 10: 'give you up', 20: 'Never gonna let', ++ 30: 'you down', 40: 'Never', 50: 'gonna run around and', ++ 60: 'desert you'} ++ expected_without_whitelist = { ++ 1: 'Never gonna', 10: 'give you up', 20: 'Never gonna let', 65: 'Close', ++ 30: 'you down', 40: 'Never', 50: 'gonna run around and', 4: 'click', ++ 60: 'desert you', 6: 'chirr', 32: 'oops, try again', 70: 'Awww, snap!'} ++ inputs = [{1: 'Never gonna', 4: 'click', 6: 'chirr', 10: 'give you up'}, ++ {20: 'Never gonna let', 30: 'you down', 32: 'oops, try again'}, ++ {40: 'Never', 50: 'gonna run around and', 60: 'desert you'}, ++ {65: 'Close', 70: 'Awww, snap!'}] ++ whitelist = [1, 10, 20, 30, 40, 50, 60] ++ inputs = [(i, data_pack.UTF8) for i in inputs] ++ ++ # RePack using whitelist ++ output, _ = data_pack.RePackFromDataPackStrings( ++ inputs, whitelist, suppress_removed_key_output=True) ++ self.assertDictEqual(expected_with_whitelist, output, ++ 'Incorrect resource output') ++ ++ # RePack a None whitelist ++ output, _ = data_pack.RePackFromDataPackStrings( ++ inputs, None, suppress_removed_key_output=True) ++ self.assertDictEqual(expected_without_whitelist, output, ++ 'Incorrect resource output') + -+class ImplementationDerivedClass : public ImplementationInterimClass, -+ public webkit_glue::WebKitObserverImpl { -+ public: -+ // Should not warn about destructors. -+ virtual ~ImplementationDerivedClass() {} -+ // Should warn. -+ virtual void SomeMethod(); -+ // Should not warn if marked as override. -+ virtual void SomeOtherMethod() override; -+ // Should not warn for inline implementations in implementation files. -+ virtual void SomeInlineMethod() {} -+ // Should not warn if overriding a method whose origin is WebKit. -+ virtual void WebKitModifiedSomething(); -+ // Should warn if overridden method isn't pure. -+ virtual void SomeNonPureBaseMethod() {} -+}; + -+int main() { -+ DerivedClass something; -+ ImplementationDerivedClass something_else; -+} -diff --git a/tools/clang/plugins/tests/overridden_methods.h b/tools/clang/plugins/tests/overridden_methods.h ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/format/gen_predetermined_ids.py b/tools/grit/grit/format/gen_predetermined_ids.py new file mode 100644 -index 0000000000..150c79913f +index 0000000000..9b2aa7b1a5 --- /dev/null -+++ b/tools/clang/plugins/tests/overridden_methods.h -@@ -0,0 +1,54 @@ -+// Copyright (c) 2011 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef OVERRIDDEN_METHODS_H_ -+#define OVERRIDDEN_METHODS_H_ -+ -+// Should warn about overriding of methods. -+class BaseClass { -+ public: -+ virtual ~BaseClass() {} -+ virtual void SomeMethod() = 0; -+ virtual void SomeOtherMethod() = 0; -+ virtual void SomeInlineMethod() = 0; -+ virtual void SomeNonPureBaseMethod() {} -+}; ++++ b/tools/grit/grit/format/gen_predetermined_ids.py +@@ -0,0 +1,144 @@ ++#!/usr/bin/env python ++# Copyright 2017 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. + -+class InterimClass : public BaseClass { -+ // Should not warn about pure virtual methods. -+ virtual void SomeMethod() = 0; -+}; ++""" ++A tool to generate a predetermined resource ids file that can be used as an ++input to grit via the -p option. This is meant to be run manually every once in ++a while and its output checked in. See tools/gritsettings/README.md for details. ++""" + -+namespace WebKit { -+class WebKitObserver { -+ public: -+ virtual void WebKitModifiedSomething() {}; -+}; -+} // namespace WebKit ++from __future__ import print_function + -+namespace webkit_glue { -+class WebKitObserverImpl : WebKit::WebKitObserver { -+ public: -+ virtual void WebKitModifiedSomething() {}; -+}; -+} // namespace webkit_glue -+ -+class DerivedClass : public InterimClass, -+ public webkit_glue::WebKitObserverImpl { -+ public: -+ // Should not warn about destructors. -+ virtual ~DerivedClass() {} -+ // Should warn. -+ virtual void SomeMethod(); -+ // Should not warn if marked as override. -+ virtual void SomeOtherMethod() override; -+ // Should warn for inline implementations. -+ virtual void SomeInlineMethod() {} -+ // Should not warn if overriding a method whose origin is WebKit. -+ virtual void WebKitModifiedSomething(); -+ // Should warn if overridden method isn't pure. -+ virtual void SomeNonPureBaseMethod() {} -+}; ++import os ++import re ++import sys + -+#endif // OVERRIDDEN_METHODS_H_ -diff --git a/tools/clang/plugins/tests/overridden_methods.txt b/tools/clang/plugins/tests/overridden_methods.txt -new file mode 100644 -index 0000000000..7553ade70e ---- /dev/null -+++ b/tools/clang/plugins/tests/overridden_methods.txt -@@ -0,0 +1,20 @@ -+In file included from overridden_methods.cpp:5: -+./overridden_methods.h:43:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. -+ virtual void SomeMethod(); -+ ^ -+./overridden_methods.h:47:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. -+ virtual void SomeInlineMethod() {} -+ ^ -+./overridden_methods.h:51:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. -+ virtual void SomeNonPureBaseMethod() {} -+ ^ -+overridden_methods.cpp:24:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. -+ virtual void SomeMethod(); -+ ^ -+overridden_methods.cpp:28:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. -+ virtual void SomeInlineMethod() {} -+ ^ -+overridden_methods.cpp:32:11: warning: [chromium-style] Overriding method must be marked with OVERRIDE. -+ virtual void SomeNonPureBaseMethod() {} -+ ^ -+6 warnings generated. -diff --git a/tools/clang/plugins/tests/test.sh b/tools/clang/plugins/tests/test.sh -new file mode 100755 -index 0000000000..262ebbba29 ---- /dev/null -+++ b/tools/clang/plugins/tests/test.sh -@@ -0,0 +1,72 @@ -+#!/bin/bash -+# -+# Copyright (c) 2011 The Chromium Authors. All rights reserved. ++# Regular expression for parsing the #define macro format. Matches both the ++# version of the macro with whitelist support and the one without. For example, ++# Without generate whitelist flag: ++# #define IDS_FOO_MESSAGE 1234 ++# With generate whitelist flag: ++# #define IDS_FOO_MESSAGE (::ui::WhitelistedResource<1234>(), 1234) ++RESOURCE_EXTRACT_REGEX = re.compile(r'^#define (\S*).* (\d+)\)?$', re.MULTILINE) ++ ++ORDERED_RESOURCE_IDS_REGEX = re.compile(r'^Resource=(\d*)$', re.MULTILINE) ++ ++ ++def _GetResourceNameIdPairsIter(string_to_scan): ++ """Gets an iterator of the resource name and id pairs of the given string. ++ ++ Scans the input string for lines of the form "#define NAME ID" and returns ++ an iterator over all matching (NAME, ID) pairs. ++ ++ Args: ++ string_to_scan: The input string to scan. ++ ++ Yields: ++ A tuple of name and id. ++ """ ++ for match in RESOURCE_EXTRACT_REGEX.finditer(string_to_scan): ++ yield match.group(1, 2) ++ ++ ++def _ReadOrderedResourceIds(path): ++ """Reads ordered resource ids from the given file. ++ ++ The resources are expected to be of the format produced by running Chrome ++ with --print-resource-ids command line. ++ ++ Args: ++ path: File path to read resource ids from. ++ ++ Returns: ++ An array of ordered resource ids. ++ """ ++ ordered_resource_ids = [] ++ with open(path, "r") as f: ++ for match in ORDERED_RESOURCE_IDS_REGEX.finditer(f.read()): ++ ordered_resource_ids.append(int(match.group(1))) ++ return ordered_resource_ids ++ ++ ++def GenerateResourceMapping(original_resources, ordered_resource_ids): ++ """Generates a resource mapping from the ordered ids and the original mapping. ++ ++ The returned dict will assign new ids to ordered_resource_ids numerically ++ increasing from 101. ++ ++ Args: ++ original_resources: A dict of original resource ids to resource names. ++ ordered_resource_ids: An array of ordered resource ids. ++ ++ Returns: ++ A dict of resource ids to resource names. ++ """ ++ output_resource_map = {} ++ # 101 is used as the starting value since other parts of GRIT require it to be ++ # the minimum (e.g. rc_header.py) based on Windows resource numbering. ++ next_id = 101 ++ for original_id in ordered_resource_ids: ++ resource_name = original_resources[original_id] ++ output_resource_map[next_id] = resource_name ++ next_id += 1 ++ return output_resource_map ++ ++ ++def ReadResourceIdsFromFile(file, original_resources): ++ """Reads resource ids from a GRIT-produced header file. ++ ++ Args: ++ file: File to a GRIT-produced header file to read from. ++ original_resources: Dict of resource ids to resource names to add to. ++ """ ++ for resource_name, resource_id in _GetResourceNameIdPairsIter(file.read()): ++ original_resources[int(resource_id)] = resource_name ++ ++ ++def _ReadOriginalResourceIds(out_dir): ++ """Reads resource ids from GRIT header files in the specified directory. ++ ++ Args: ++ out_dir: A Chrome build output directory (e.g. out/gn) to scan. ++ ++ Returns: ++ A dict of resource ids to resource names. ++ """ ++ original_resources = {} ++ for root, dirnames, filenames in os.walk(out_dir + '/gen'): ++ for filename in filenames: ++ if filename.endswith(('_resources.h', '_settings.h', '_strings.h')): ++ with open(os.path.join(root, filename), "r") as f: ++ ReadResourceIdsFromFile(f, original_resources) ++ return original_resources ++ ++ ++def _GeneratePredeterminedIdsFile(ordered_resources_file, out_dir): ++ """Generates a predetermined ids file. ++ ++ Args: ++ ordered_resources_file: File path to read ordered resource ids from. ++ out_dir: A Chrome build output directory (e.g. out/gn) to scan. ++ ++ Returns: ++ A dict of resource ids to resource names. ++ """ ++ original_resources = _ReadOriginalResourceIds(out_dir) ++ ordered_resource_ids = _ReadOrderedResourceIds(ordered_resources_file) ++ output_resource_map = GenerateResourceMapping(original_resources, ++ ordered_resource_ids) ++ for res_id in sorted(output_resource_map.keys()): ++ print(output_resource_map[res_id], res_id) ++ ++ ++def main(argv): ++ if len(argv) != 2: ++ print("usage: gen_predetermined_ids.py ") ++ sys.exit(1) ++ ordered_resources_file, out_dir = argv[0], argv[1] ++ _GeneratePredeterminedIdsFile(ordered_resources_file, out_dir) ++ ++ ++if '__main__' == __name__: ++ main(sys.argv[1:]) +diff --git a/tools/grit/grit/format/gen_predetermined_ids_unittest.py b/tools/grit/grit/format/gen_predetermined_ids_unittest.py +new file mode 100644 +index 0000000000..bd0331adb4 +--- /dev/null ++++ b/tools/grit/grit/format/gen_predetermined_ids_unittest.py +@@ -0,0 +1,46 @@ ++#!/usr/bin/env python ++# Copyright 2017 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. -+# -+# Hacky, primitive testing: This runs the style plugin for a set of input files -+# and compares the output with golden result files. -+ -+E_BADARGS=65 -+E_FAILEDTEST=1 -+ -+failed_any_test= -+ -+# Prints usage information. -+usage() { -+ echo "Usage: $(basename "${0}")" \ -+ "" -+ echo "" -+ echo " Runs all the libFindBadConstructs unit tests" -+ echo "" -+} -+ -+# Runs a single test case. -+do_testcase() { -+ local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \ -+ -Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \ -+ -Xclang -plugin -Xclang find-bad-constructs ${1} 2>&1)" -+ local diffout="$(echo "${output}" | diff - "${2}")" -+ if [ "${diffout}" = "" ]; then -+ echo "PASS: ${1}" -+ else -+ failed_any_test=yes -+ echo "FAIL: ${1}" -+ echo "Output of compiler:" -+ echo "${output}" -+ echo "Expected output:" -+ cat "${2}" -+ echo -+ fi -+} -+ -+# Validate input to the script. -+if [[ -z "${1}" ]]; then -+ usage -+ exit ${E_BADARGS} -+elif [[ ! -d "${1}" ]]; then -+ echo "${1} is not a directory." -+ usage -+ exit ${E_BADARGS} -+else -+ export CLANG_DIR="${PWD}/${1}" -+ echo "Using clang directory ${CLANG_DIR}..." -+ -+ # The golden files assume that the cwd is this directory. To make the script -+ # work no matter what the cwd is, explicitly cd to there. -+ cd "$(dirname "${0}")" -+ -+ if [ "$(uname -s)" = "Linux" ]; then -+ export LIB=so -+ elif [ "$(uname -s)" = "Darwin" ]; then -+ export LIB=dylib -+ fi -+fi -+ -+for input in *.cpp; do -+ do_testcase "${input}" "${input%cpp}txt" -+done -+ -+if [[ "${failed_any_test}" ]]; then -+ exit ${E_FAILEDTEST} -+fi -diff --git a/tools/clang/plugins/tests/virtual_methods.cpp b/tools/clang/plugins/tests/virtual_methods.cpp -new file mode 100644 -index 0000000000..a07cbe4875 ---- /dev/null -+++ b/tools/clang/plugins/tests/virtual_methods.cpp -@@ -0,0 +1,36 @@ -+// Copyright (c) 2012 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "virtual_methods.h" -+ -+// Shouldn't warn about method usage in the implementation file. -+class VirtualMethodsInImplementation { -+ public: -+ virtual void MethodIsAbstract() = 0; -+ virtual void MethodHasNoArguments(); -+ virtual void MethodHasEmptyDefaultImpl() {} -+ virtual bool ComplainAboutThis() { return true; } -+}; + -+// Stubs to fill in the abstract method -+class ConcreteVirtualMethodsInHeaders : public VirtualMethodsInHeaders { -+ public: -+ virtual void MethodIsAbstract() override {} -+}; ++'''Unit tests for the gen_predetermined_ids module.''' + -+class ConcreteVirtualMethodsInImplementation -+ : public VirtualMethodsInImplementation { -+ public: -+ virtual void MethodIsAbstract() override {} -+}; ++from __future__ import print_function + -+// Fill in the implementations -+void VirtualMethodsInHeaders::MethodHasNoArguments() {} -+void WarnOnMissingVirtual::MethodHasNoArguments() {} -+void VirtualMethodsInImplementation::MethodHasNoArguments() {} ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) + -+int main() { -+ ConcreteVirtualMethodsInHeaders one; -+ ConcreteVirtualMethodsInImplementation two; -+} -diff --git a/tools/clang/plugins/tests/virtual_methods.h b/tools/clang/plugins/tests/virtual_methods.h ++import unittest ++ ++from six import StringIO ++ ++from grit.format import gen_predetermined_ids ++ ++class GenPredeterminedIdsUnittest(unittest.TestCase): ++ def testGenerateResourceMapping(self): ++ original_resources = {200: 'A', 201: 'B', 300: 'C', 350: 'D', 370: 'E'} ++ ordered_resource_ids = [300, 201, 370] ++ mapping = gen_predetermined_ids.GenerateResourceMapping( ++ original_resources, ordered_resource_ids) ++ self.assertEqual({101: 'C', 102: 'B', 103: 'E'}, mapping) ++ ++ def testReadResourceIdsFromFile(self): ++ f = StringIO(''' ++// This file is automatically generated by GRIT. Do not edit. ++ ++#pragma once ++ ++#define IDS_BOOKMARKS_NO_ITEMS 12500 ++#define IDS_BOOKMARK_BAR_IMPORT_LINK (::ui::WhitelistedResource<12501>(), 12501) ++#define IDS_BOOKMARK_X (::ui::WhitelistedResource<12502>(), 12502) ++''') ++ resources = {} ++ gen_predetermined_ids.ReadResourceIdsFromFile(f, resources) ++ self.assertEqual({12500: 'IDS_BOOKMARKS_OPEN_ALL', ++ 12501: 'IDS_BOOKMARKS_OPEN_ALL_INCOGNITO', ++ 12502: 'IDS_BOOKMARK_X'}, resources) ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/format/gzip_string.py b/tools/grit/grit/format/gzip_string.py new file mode 100644 -index 0000000000..d9fbf96ed3 +index 0000000000..3cd17185c9 --- /dev/null -+++ b/tools/clang/plugins/tests/virtual_methods.h -@@ -0,0 +1,39 @@ -+// Copyright (c) 2011 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef VIRTUAL_METHODS_H_ -+#define VIRTUAL_METHODS_H_ -+ -+// Should warn about virtual method usage. -+class VirtualMethodsInHeaders { -+ public: -+ // Don't complain about these. -+ virtual void MethodIsAbstract() = 0; -+ virtual void MethodHasNoArguments(); -+ virtual void MethodHasEmptyDefaultImpl() {} -+ -+ // But complain about this: -+ virtual bool ComplainAboutThis() { return true; } -+}; ++++ b/tools/grit/grit/format/gzip_string.py +@@ -0,0 +1,46 @@ ++# Copyright (c) 2016 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++"""Provides gzip utilities for strings. ++""" + -+// Complain on missing 'virtual' keyword in overrides. -+class WarnOnMissingVirtual : public VirtualMethodsInHeaders { -+ public: -+ void MethodHasNoArguments() override; -+}; ++from __future__ import print_function + -+// Don't complain about things in a 'testing' namespace. -+namespace testing { -+struct TestStruct {}; -+} // namespace testing -+ -+class VirtualMethodsInHeadersTesting : public VirtualMethodsInHeaders { -+ public: -+ // Don't complain about no virtual testing methods. -+ void MethodHasNoArguments(); -+ private: -+ testing::TestStruct tester_; -+}; ++import gzip ++import io ++import subprocess + -+#endif // VIRTUAL_METHODS_H_ -diff --git a/tools/clang/plugins/tests/virtual_methods.txt b/tools/clang/plugins/tests/virtual_methods.txt ++ ++def GzipStringRsyncable(data): ++ # Make call to host system's gzip to get access to --rsyncable option. This ++ # option makes updates much smaller - if one line is changed in the resource, ++ # it won't have to push the entire compressed resource with the update. ++ # Instead, --rsyncable breaks the file into small chunks, so that one doesn't ++ # affect the other in compression, and then only that chunk will have to be ++ # updated. ++ gzip_proc = subprocess.Popen(['gzip', '--stdout', '--rsyncable', ++ '--best', '--no-name'], ++ stdin=subprocess.PIPE, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ data, stderr = gzip_proc.communicate(data) ++ if gzip_proc.returncode != 0: ++ raise subprocess.CalledProcessError(gzip_proc.returncode, 'gzip', ++ stderr) ++ return data ++ ++ ++def GzipString(data): ++ # Gzipping using Python's built in gzip: Windows doesn't ship with gzip, and ++ # OSX's gzip does not have an --rsyncable option built in. Although this is ++ # not preferable to --rsyncable, it is an option for the systems that do ++ # not have --rsyncable. If used over GzipStringRsyncable, the primary ++ # difference of this function's compression will be larger updates every time ++ # a compressed resource is changed. ++ gzip_output = io.BytesIO() ++ with gzip.GzipFile(mode='wb', compresslevel=9, fileobj=gzip_output, ++ mtime=0) as gzip_file: ++ gzip_file.write(data) ++ data = gzip_output.getvalue() ++ gzip_output.close() ++ return data +diff --git a/tools/grit/grit/format/gzip_string_unittest.py b/tools/grit/grit/format/gzip_string_unittest.py new file mode 100644 -index 0000000000..571d6d667d +index 0000000000..c0cfbe1837 --- /dev/null -+++ b/tools/clang/plugins/tests/virtual_methods.txt -@@ -0,0 +1,8 @@ -+In file included from virtual_methods.cpp:5: -+./virtual_methods.h:17:36: warning: [chromium-style] virtual methods with non-empty bodies shouldn't be declared inline. -+ virtual bool ComplainAboutThis() { return true; } -+ ^ -+./virtual_methods.h:23:3: warning: [chromium-style] Overriding method must have "virtual" keyword. -+ void MethodHasNoArguments() override; -+ ^ -+2 warnings generated. -diff --git a/tools/clang/scripts/package.sh b/tools/clang/scripts/package.sh -new file mode 100755 -index 0000000000..eb345810b9 ---- /dev/null -+++ b/tools/clang/scripts/package.sh -@@ -0,0 +1,87 @@ -+#!/bin/bash -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+# This script will check out llvm and clang, and then package the results up -+# to a tgz file. -+ -+THIS_DIR="$(dirname "${0}")" -+LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" -+LLVM_BOOTSTRAP_DIR="${THIS_DIR}/../../../third_party/llvm-bootstrap" -+LLVM_BUILD_DIR="${THIS_DIR}/../../../third_party/llvm-build" -+LLVM_BIN_DIR="${LLVM_BUILD_DIR}/Release+Asserts/bin" -+LLVM_LIB_DIR="${LLVM_BUILD_DIR}/Release+Asserts/lib" -+ -+echo "Diff in llvm:" | tee buildlog.txt -+svn stat "${LLVM_DIR}" 2>&1 | tee -a buildlog.txt -+svn diff "${LLVM_DIR}" 2>&1 | tee -a buildlog.txt -+echo "Diff in llvm/tools/clang:" | tee -a buildlog.txt -+svn stat "${LLVM_DIR}/tools/clang" 2>&1 | tee -a buildlog.txt -+svn diff "${LLVM_DIR}/tools/clang" 2>&1 | tee -a buildlog.txt -+echo "Diff in llvm/projects/compiler-rt:" | tee -a buildlog.txt -+svn stat "${LLVM_DIR}/projects/compiler-rt" 2>&1 | tee -a buildlog.txt -+svn diff "${LLVM_DIR}/projects/compiler-rt" 2>&1 | tee -a buildlog.txt -+ -+echo "Starting build" | tee -a buildlog.txt -+ -+set -ex -+ -+# Do a clobber build. -+rm -rf "${LLVM_BOOTSTRAP_DIR}" -+rm -rf "${LLVM_BUILD_DIR}" -+"${THIS_DIR}"/update.sh --run-tests --bootstrap --force-local-build 2>&1 | \ -+ tee -a buildlog.txt -+ -+R=$("${LLVM_BIN_DIR}/clang" --version | \ -+ sed -ne 's/clang version .*(trunk \([0-9]*\))/\1/p') -+ -+PDIR=clang-$R -+rm -rf $PDIR -+mkdir $PDIR -+mkdir $PDIR/bin -+mkdir $PDIR/lib -+ -+# Copy buildlog over. -+cp buildlog.txt $PDIR/ -+ -+# Copy clang into pdir, symlink clang++ to it. -+cp "${LLVM_BIN_DIR}/clang" $PDIR/bin/ -+(cd $PDIR/bin && ln -sf clang clang++ && cd -) -+ -+# Copy plugins. Some of the dylibs are pretty big, so copy only the ones we -+# care about. -+if [ "$(uname -s)" = "Darwin" ]; then -+ cp "${LLVM_LIB_DIR}/libFindBadConstructs.dylib" $PDIR/lib -+else -+ cp "${LLVM_LIB_DIR}/libFindBadConstructs.so" $PDIR/lib -+fi -+ -+# Copy built-in headers (lib/clang/3.2/include). -+# libcompiler-rt puts all kinds of libraries there too, but we want only ASan. -+if [ "$(uname -s)" = "Darwin" ]; then -+ # Keep only Release+Asserts/lib/clang/3.2/lib/darwin/libclang_rt.asan_osx.a -+ find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/darwin*' | grep -v asan | \ -+ xargs rm -+else -+ # Keep only -+ # Release+Asserts/lib/clang/3.2/lib/linux/libclang_rt.{asan,tsan}-x86_64.a -+ # TODO(thakis): Make sure the 32bit version of ASan runtime is kept too once -+ # that's built. TSan runtime exists only for 64 bits. -+ find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/linux*' | \ -+ grep -v "asan\|tsan" | xargs rm -+fi -+ -+cp -R "${LLVM_LIB_DIR}/clang" $PDIR/lib -+ -+tar zcf $PDIR.tgz -C $PDIR bin lib buildlog.txt -+ -+if [ "$(uname -s)" = "Darwin" ]; then -+ PLATFORM=Mac -+else -+ PLATFORM=Linux_x64 -+fi -+ -+echo To upload, run: -+echo gsutil cp -a public-read $PDIR.tgz \ -+ gs://chromium-browser-clang/$PLATFORM/$PDIR.tgz -diff --git a/tools/clang/scripts/plugin_flags.sh b/tools/clang/scripts/plugin_flags.sh -new file mode 100755 -index 0000000000..217c5c3bd6 ---- /dev/null -+++ b/tools/clang/scripts/plugin_flags.sh -@@ -0,0 +1,24 @@ -+#!/bin/bash -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++++ b/tools/grit/grit/format/gzip_string_unittest.py +@@ -0,0 +1,65 @@ ++#!/usr/bin/env python ++# Copyright (c) 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + -+# This script returns the flags that should be used when GYP_DEFINES contains -+# clang_use_chrome_plugins. The flags are stored in a script so that they can -+# be changed on the bots without requiring a master restart. ++'''Unit tests for grit.format.gzip_string''' ++ ++from __future__ import print_function ++ ++import gzip ++import io ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++from grit.format import gzip_string ++ ++ ++class FormatGzipStringUnittest(unittest.TestCase): ++ ++ def testGzipStringRsyncable(self): ++ # Can only test the rsyncable version on platforms which support rsyncable, ++ # which at the moment is Linux. ++ if sys.platform == 'linux2': ++ header_begin = (b'\x1f\x8b') # gzip first two bytes ++ input = (b'TEST STRING STARTING NOW' ++ b'continuing' ++ b'' ++ b'') + -+THIS_ABS_DIR=$(cd $(dirname $0) && echo $PWD) -+CLANG_LIB_PATH=$THIS_ABS_DIR/../../../third_party/llvm-build/Release+Asserts/lib ++ compressed = gzip_string.GzipStringRsyncable(input) ++ self.failUnless(header_begin == compressed[:2]) + -+if uname -s | grep -q Darwin; then -+ LIBSUFFIX=dylib -+else -+ LIBSUFFIX=so -+fi ++ compressed_file = io.BytesIO() ++ compressed_file.write(compressed) ++ compressed_file.seek(0) + -+echo -Xclang -load -Xclang $CLANG_LIB_PATH/libFindBadConstructs.$LIBSUFFIX \ -+ -Xclang -add-plugin -Xclang find-bad-constructs \ -+ -Xclang -plugin-arg-find-bad-constructs \ -+ -Xclang skip-virtuals-in-implementations \ -+ -Xclang -plugin-arg-find-bad-constructs \ -+ -Xclang check-cc-directory -diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py -new file mode 100755 -index 0000000000..bdc781f715 ++ with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f: ++ output = f.read() ++ self.failUnless(output == input) ++ ++ def testGzipString(self): ++ header_begin = b'\x1f\x8b' # gzip first two bytes ++ input = (b'TEST STRING STARTING NOW' ++ b'continuing' ++ b'' ++ b'') ++ ++ compressed = gzip_string.GzipString(input) ++ self.failUnless(header_begin == compressed[:2]) ++ ++ compressed_file = io.BytesIO() ++ compressed_file.write(compressed) ++ compressed_file.seek(0) ++ ++ with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f: ++ output = f.read() ++ self.failUnless(output == input) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/format/html_inline.py b/tools/grit/grit/format/html_inline.py +new file mode 100644 +index 0000000000..da55216ea4 --- /dev/null -+++ b/tools/clang/scripts/update.py -@@ -0,0 +1,34 @@ ++++ b/tools/grit/grit/format/html_inline.py +@@ -0,0 +1,602 @@ +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + -+"""Windows can't run .sh files, so this is a small python wrapper around -+update.sh. ++"""Flattens a HTML file by inlining its external resources. ++ ++This is a small script that takes a HTML file, looks for src attributes ++and inlines the specified file, producing one HTML file with no external ++dependencies. It recursively inlines the included files. +""" + ++from __future__ import print_function ++ +import os -+import subprocess ++import re +import sys ++import base64 ++import mimetypes ++ ++from grit import lazy_re ++from grit import util ++from grit.format import minifier ++ ++# There is a python bug that makes mimetypes crash if the Windows ++# registry contains non-Latin keys ( http://bugs.python.org/issue9291 ++# ). Initing manually and blocking external mime-type databases will ++# prevent that bug and if we add svg manually, it will still give us ++# the data we need. ++mimetypes.init([]) ++mimetypes.add_type('image/svg+xml', '.svg') ++ ++# webm video type is not always available if mimetype package is outdated. ++mimetypes.add_type('video/webm', '.webm') ++ ++DIST_DEFAULT = 'chromium' ++DIST_ENV_VAR = 'CHROMIUM_BUILD' ++DIST_SUBSTR = '%DISTRIBUTION%' ++ ++# Matches beginning of an "if" block. ++_BEGIN_IF_BLOCK = lazy_re.compile( ++ r']*?expr=("(?P[^">]*)"|\'(?P[^\'>]*)\')[^>]*?>') ++ ++# Matches ending of an "if" block. ++_END_IF_BLOCK = lazy_re.compile(r'') ++ ++# Used by DoInline to replace various links with inline content. ++_STYLESHEET_RE = lazy_re.compile( ++ r']+?href="(?P[^"]*)".*?>(\s*)?', ++ re.DOTALL) ++_INCLUDE_RE = lazy_re.compile( ++ r'(?P\/\/ )?]+?' ++ r'src=("(?P[^">]*)"|\'(?P[^\'>]*)\').*?>(\s*)?', ++ re.DOTALL) ++_SRC_RE = lazy_re.compile( ++ r'<(?!script)(?:[^>]+?\s)src="(?!\[\[|{{)(?P[^"\']*)"', ++ re.MULTILINE) ++# This re matches ']*?\s)srcset="(?!\[\[|{{|\$i18n{)' ++ r'(?P[^"\']*)"', ++ re.MULTILINE) ++# This re is for splitting srcset value string into "image candidate strings". ++# Notes: ++# - HTML 5.2 states that URL cannot start or end with comma. ++# - the "descriptor" is either "width descriptor" or "pixel density descriptor". ++# The first one consists of "valid non-negative integer + letter 'x'", ++# the second one is formed of "positive valid floating-point number + ++# letter 'w'". As a reasonable compromise, we match a list of characters ++# that form both of them. ++# Matches for example "img2.png 2x" or "img9.png 11E-2w". ++_SRCSET_ENTRY_RE = lazy_re.compile( ++ r'\s*(?P[^,\s]\S+[^,\s])' ++ r'(?:\s+(?P[\deE.-]+[wx]))?\s*' ++ r'(?P,|$)', ++ re.MULTILINE) ++_ICON_RE = lazy_re.compile( ++ r']+?\s)?' ++ r'href=(?P")(?P[^"\']*)\1', ++ re.MULTILINE) ++ ++ ++def GetDistribution(): ++ """Helper function that gets the distribution we are building. ++ ++ Returns: ++ string ++ """ ++ distribution = DIST_DEFAULT ++ if DIST_ENV_VAR in os.environ: ++ distribution = os.environ[DIST_ENV_VAR] ++ if len(distribution) > 1 and distribution[0] == '_': ++ distribution = distribution[1:].lower() ++ return distribution ++ ++def ConvertFileToDataURL(filename, base_path, distribution, inlined_files, ++ names_only): ++ """Convert filename to inlined data URI. ++ ++ Takes a filename from ether "src" or "srcset", and attempts to read the file ++ at 'filename'. Returns data URI as string with given file inlined. ++ If it finds DIST_SUBSTR string in file name, replaces it with distribution. ++ If filename contains ':', it is considered URL and not translated. ++ ++ Args: ++ filename: filename string from ether src or srcset attributes. ++ base_path: path that to look for files in ++ distribution: string that should replace DIST_SUBSTR ++ inlined_files: The name of the opened file is appended to this list. ++ names_only: If true, the function will not read the file but just return "". ++ It will still add the filename to |inlined_files|. ++ ++ Returns: ++ string ++ """ ++ if filename.find(':') != -1: ++ # filename is probably a URL, which we don't want to bother inlining ++ return filename ++ ++ filename = filename.replace(DIST_SUBSTR , distribution) ++ filepath = os.path.normpath(os.path.join(base_path, filename)) ++ inlined_files.add(filepath) ++ ++ if names_only: ++ return "" ++ ++ mimetype = mimetypes.guess_type(filename)[0] ++ if mimetype is None: ++ raise Exception('%s is of an an unknown type and ' ++ 'cannot be stored in a data url.' % filename) ++ inline_data = base64.standard_b64encode(util.ReadFile(filepath, util.BINARY)) ++ return 'data:%s;base64,%s' % (mimetype, inline_data.decode('utf-8')) ++ ++ ++def SrcInlineAsDataURL( ++ src_match, base_path, distribution, inlined_files, names_only=False, ++ filename_expansion_function=None): ++ """regex replace function. ++ ++ Takes a regex match for src="filename", attempts to read the file ++ at 'filename' and returns the src attribute with the file inlined ++ as a data URI. If it finds DIST_SUBSTR string in file name, replaces ++ it with distribution. ++ ++ Args: ++ src_match: regex match object with 'filename' named capturing group ++ base_path: path that to look for files in ++ distribution: string that should replace DIST_SUBSTR ++ inlined_files: The name of the opened file is appended to this list. ++ names_only: If true, the function will not read the file but just return "". ++ It will still add the filename to |inlined_files|. ++ ++ Returns: ++ string ++ """ ++ filename = src_match.group('filename') ++ if filename_expansion_function: ++ filename = filename_expansion_function(filename) ++ ++ data_url = ConvertFileToDataURL(filename, base_path, distribution, ++ inlined_files, names_only) ++ ++ if not data_url: ++ return data_url ++ ++ prefix = src_match.string[src_match.start():src_match.start('filename')] ++ suffix = src_match.string[src_match.end('filename'):src_match.end()] ++ return prefix + data_url + suffix ++ ++def SrcsetInlineAsDataURL( ++ srcset_match, base_path, distribution, inlined_files, names_only=False, ++ filename_expansion_function=None): ++ """regex replace function to inline files in srcset="..." attributes ++ ++ Takes a regex match for srcset="filename 1x, filename 2x, ...", attempts to ++ read the files referenced by filenames and returns the srcset attribute with ++ the files inlined as a data URI. If it finds DIST_SUBSTR string in file name, ++ replaces it with distribution. ++ ++ Args: ++ srcset_match: regex match object with 'srcset' named capturing group ++ base_path: path that to look for files in ++ distribution: string that should replace DIST_SUBSTR ++ inlined_files: The name of the opened file is appended to this list. ++ names_only: If true, the function will not read the file but just return "". ++ It will still add the filename to |inlined_files|. ++ ++ Returns: ++ string ++ """ ++ srcset = srcset_match.group('srcset') ++ ++ if not srcset: ++ return srcset_match.group(0) ++ ++ # HTML 5.2 defines srcset as a list of "image candidate strings". ++ # Each of them consists of URL and descriptor. ++ # _SRCSET_ENTRY_RE splits srcset into a list of URLs, descriptors and ++ # commas. ++ # The descriptor part will be None if that optional regex didn't match ++ parts = _SRCSET_ENTRY_RE.split(srcset) ++ ++ if not parts: ++ return srcset_match.group(0) ++ ++ # List of image candidate strings that will form new srcset="..." ++ new_candidates = [] ++ ++ # When iterating over split srcset we fill this parts of a single image ++ # candidate string: [url, descriptor] ++ candidate = []; ++ ++ # Each entry should consist of some text before the entry, the url, ++ # the descriptor or None if the entry has no descriptor, a comma separator or ++ # the end of the line, and finally some text after the entry (which is the ++ # same as the text before the next entry). ++ for i in range(0, len(parts) - 1, 4): ++ before, url, descriptor, separator, after = parts[i:i+5] ++ ++ # There must be a comma-separated next entry or this must be the last entry. ++ assert separator == "," or (separator == "" and i == len(parts) - 5), ( ++ "Bad srcset format in {}".format(srcset_match.group(0))) ++ # Both before and after the entry must be empty ++ assert before == after == "", ( ++ "Bad srcset format in {}".format(srcset_match.group(0))) ++ ++ if filename_expansion_function: ++ filename = filename_expansion_function(url) ++ else: ++ filename = url ++ ++ data_url = ConvertFileToDataURL(filename, base_path, distribution, ++ inlined_files, names_only) ++ ++ # This is not "names_only" mode ++ if data_url: ++ candidate = [data_url] ++ if descriptor: ++ candidate.append(descriptor) ++ ++ new_candidates.append(" ".join(candidate)) ++ ++ prefix = srcset_match.string[srcset_match.start(): ++ srcset_match.start('srcset')] ++ suffix = srcset_match.string[srcset_match.end('srcset'):srcset_match.end()] ++ return prefix + ','.join(new_candidates) + suffix ++ ++class InlinedData: ++ """Helper class holding the results from DoInline(). ++ ++ Holds the inlined data and the set of filenames of all the inlined ++ files. ++ """ ++ def __init__(self, inlined_data, inlined_files): ++ self.inlined_data = inlined_data ++ self.inlined_files = inlined_files ++ ++def DoInline( ++ input_filename, grd_node, allow_external_script=False, ++ preprocess_only=False, names_only=False, strip_whitespace=False, ++ rewrite_function=None, filename_expansion_function=None): ++ """Helper function that inlines the resources in a specified file. ++ ++ Reads input_filename, finds all the src attributes and attempts to ++ inline the files they are referring to, then returns the result and ++ the set of inlined files. ++ ++ Args: ++ input_filename: name of file to read in ++ grd_node: html node from the grd file for this include tag ++ preprocess_only: Skip all HTML processing, only handle and . ++ names_only: |nil| will be returned for the inlined contents (faster). ++ strip_whitespace: remove whitespace and comments in the input files. ++ rewrite_function: function(filepath, text, distribution) which will be ++ called to rewrite html content before inlining images. ++ filename_expansion_function: function(filename) which will be called to ++ rewrite filenames before attempting to read them. ++ Returns: ++ a tuple of the inlined data as a string and the set of filenames ++ of all the inlined files ++ """ ++ if filename_expansion_function: ++ input_filename = filename_expansion_function(input_filename) ++ input_filepath = os.path.dirname(input_filename) ++ distribution = GetDistribution() ++ ++ # Keep track of all the files we inline. ++ inlined_files = set() ++ ++ def SrcReplace(src_match, filepath=input_filepath, ++ inlined_files=inlined_files): ++ """Helper function to provide SrcInlineAsDataURL with the base file path""" ++ return SrcInlineAsDataURL( ++ src_match, filepath, distribution, inlined_files, names_only=names_only, ++ filename_expansion_function=filename_expansion_function) ++ ++ def SrcsetReplace(srcset_match, filepath=input_filepath, ++ inlined_files=inlined_files): ++ """Helper function to provide SrcsetInlineAsDataURL with the base file ++ path. ++ """ ++ return SrcsetInlineAsDataURL( ++ srcset_match, filepath, distribution, inlined_files, ++ names_only=names_only, ++ filename_expansion_function=filename_expansion_function) ++ ++ def GetFilepath(src_match, base_path = input_filepath): ++ filename = [v for k, v in src_match.groupdict().items() ++ if k.startswith('file') and v][0] ++ ++ if filename.find(':') != -1: ++ # filename is probably a URL, which we don't want to bother inlining ++ return None ++ ++ filename = filename.replace('%DISTRIBUTION%', distribution) ++ if filename_expansion_function: ++ filename = filename_expansion_function(filename) ++ return os.path.normpath(os.path.join(base_path, filename)) ++ ++ def IsConditionSatisfied(src_match): ++ expr1 = src_match.group('expr1') or '' ++ expr2 = src_match.group('expr2') or '' ++ return grd_node is None or grd_node.EvaluateCondition(expr1 + expr2) ++ ++ def CheckConditionalElements(str): ++ """Helper function to conditionally inline inner elements""" ++ while True: ++ begin_if = _BEGIN_IF_BLOCK.search(str) ++ if begin_if is None: ++ if _END_IF_BLOCK.search(str) is not None: ++ raise Exception('Unmatched ') ++ return str ++ ++ condition_satisfied = IsConditionSatisfied(begin_if) ++ leading = str[0:begin_if.start()] ++ content_start = begin_if.end() ++ ++ # Find matching "if" block end. ++ count = 1 ++ pos = begin_if.end() ++ while True: ++ end_if = _END_IF_BLOCK.search(str, pos) ++ if end_if is None: ++ raise Exception('Unmatched ') ++ ++ next_if = _BEGIN_IF_BLOCK.search(str, pos) ++ if next_if is None or next_if.start() >= end_if.end(): ++ count = count - 1 ++ if count == 0: ++ break ++ pos = end_if.end() ++ else: ++ count = count + 1 ++ pos = next_if.end() ++ ++ content = str[content_start:end_if.start()] ++ trailing = str[end_if.end():] ++ ++ if condition_satisfied: ++ str = leading + CheckConditionalElements(content) + trailing ++ else: ++ str = leading + trailing ++ ++ def InlineFileContents(src_match, ++ pattern, ++ inlined_files=inlined_files, ++ strip_whitespace=False): ++ """Helper function to inline external files of various types""" ++ filepath = GetFilepath(src_match) ++ if filepath is None: ++ return src_match.group(0) ++ inlined_files.add(filepath) ++ ++ if names_only: ++ inlined_files.update(GetResourceFilenames( ++ filepath, ++ grd_node, ++ allow_external_script, ++ rewrite_function, ++ filename_expansion_function=filename_expansion_function)) ++ return "" ++ # To recursively save inlined files, we need InlinedData instance returned ++ # by DoInline. ++ inlined_data_inst=DoInline(filepath, grd_node, ++ allow_external_script=allow_external_script, ++ preprocess_only=preprocess_only, ++ strip_whitespace=strip_whitespace, ++ filename_expansion_function=filename_expansion_function) ++ ++ inlined_files.update(inlined_data_inst.inlined_files) ++ ++ return pattern % inlined_data_inst.inlined_data; ++ ++ ++ def InlineIncludeFiles(src_match): ++ """Helper function to directly inline generic external files (without ++ wrapping them with any kind of tags). ++ """ ++ return InlineFileContents(src_match, '%s') ++ ++ def InlineScript(match): ++ """Helper function to inline external script files""" ++ attrs = (match.group('attrs1') + match.group('attrs2')).strip() ++ if attrs: ++ attrs = ' ' + attrs ++ return InlineFileContents(match, '%s', ++ strip_whitespace=True) ++ ++ def InlineCSSText(text, css_filepath): ++ """Helper function that inlines external resources in CSS text""" ++ filepath = os.path.dirname(css_filepath) ++ # Allow custom modifications before inlining images. ++ if rewrite_function: ++ text = rewrite_function(filepath, text, distribution) ++ text = InlineCSSImages(text, filepath) ++ return InlineCSSImports(text, filepath) ++ ++ def InlineCSSFile(src_match, pattern, base_path=input_filepath): ++ """Helper function to inline external CSS files. ++ ++ Args: ++ src_match: A regular expression match with a named group named "filename". ++ pattern: The pattern to replace with the contents of the CSS file. ++ base_path: The base path to use for resolving the CSS file. ++ ++ Returns: ++ The text that should replace the reference to the CSS file. ++ """ ++ filepath = GetFilepath(src_match, base_path) ++ if filepath is None: ++ return src_match.group(0) ++ ++ # Even if names_only is set, the CSS file needs to be opened, because it ++ # can link to images that need to be added to the file set. ++ inlined_files.add(filepath) ++ ++ # Inline stylesheets included in this css file. ++ text = _INCLUDE_RE.sub(InlineIncludeFiles, util.ReadFile(filepath, 'utf-8')) ++ # When resolving CSS files we need to pass in the path so that relative URLs ++ # can be resolved. ++ ++ return pattern % InlineCSSText(text, filepath) ++ ++ def GetUrlRegexString(postfix=''): ++ """Helper function that returns a string for a regex that matches url('') ++ but not url([[ ]]) or url({{ }}). Appends |postfix| to group names. ++ """ ++ url_re = (r'url\((?!\[\[|{{)(?P"|\'|)(?P[^"\'()]*)' ++ r'(?P=q%s)\)') ++ return url_re % (postfix, postfix, postfix) ++ ++ def InlineCSSImages(text, filepath=input_filepath): ++ """Helper function that inlines external images in CSS backgrounds.""" ++ # Replace contents of url() for css attributes: content, background, ++ # or *-image. ++ property_re = r'(content|background|[\w-]*-image):[^;]*' ++ # Replace group names to prevent duplicates when forming value_re. ++ image_set_value_re = (r'image-set\(([ ]*' + GetUrlRegexString('2') + ++ r'[ ]*[0-9.]*x[ ]*(,[ ]*)?)+\)') ++ value_re = '(%s|%s)' % (GetUrlRegexString(), image_set_value_re) ++ css_re = property_re + value_re ++ return re.sub(css_re, lambda m: InlineCSSUrls(m, filepath), text) ++ ++ def InlineCSSUrls(src_match, filepath=input_filepath): ++ """Helper function that inlines each url on a CSS image rule match.""" ++ # Replace contents of url() references in matches. ++ return re.sub(GetUrlRegexString(), ++ lambda m: SrcReplace(m, filepath), ++ src_match.group(0)) ++ ++ def InlineCSSImports(text, filepath=input_filepath): ++ """Helper function that inlines CSS files included via the @import ++ directive. ++ """ ++ return re.sub(r'@import\s+' + GetUrlRegexString() + r';', ++ lambda m: InlineCSSFile(m, '%s', filepath), ++ text) ++ ++ ++ flat_text = util.ReadFile(input_filename, 'utf-8') ++ ++ # Check conditional elements, remove unsatisfied ones from the file. We do ++ # this twice. The first pass is so that we don't even bother calling ++ # InlineScript, InlineCSSFile and InlineIncludeFiles on text we're eventually ++ # going to throw out anyway. ++ flat_text = CheckConditionalElements(flat_text) ++ ++ flat_text = _INCLUDE_RE.sub(InlineIncludeFiles, flat_text) ++ ++ if not preprocess_only: ++ if strip_whitespace: ++ flat_text = minifier.Minify(flat_text.encode('utf-8'), ++ input_filename).decode('utf-8') ++ ++ if not allow_external_script: ++ # We need to inline css and js before we inline images so that image ++ # references gets inlined in the css and js ++ flat_text = re.sub(r'', ++ InlineScript, ++ flat_text) ++ ++ flat_text = _STYLESHEET_RE.sub( ++ lambda m: InlineCSSFile(m, ''), ++ flat_text) ++ ++ # Check conditional elements, second pass. This catches conditionals in any ++ # of the text we just inlined. ++ flat_text = CheckConditionalElements(flat_text) ++ ++ # Allow custom modifications before inlining images. ++ if rewrite_function: ++ flat_text = rewrite_function(input_filepath, flat_text, distribution) ++ ++ if not preprocess_only: ++ flat_text = _SRC_RE.sub(SrcReplace, flat_text) ++ flat_text = _SRCSET_RE.sub(SrcsetReplace, flat_text) ++ ++ # TODO(arv): Only do this inside ++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(util.normpath(filename))) ++ ++ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ ++ tmp_dir.CleanUp() ++ ++ def testInlineIgnoresPolymerBindings(self): ++ '''Tests that polymer bindings are ignored when inlining. ++ ''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ++ ++
++
++
++
++ ++ ++ ''', ++ ++ 'test.css': ''' ++ .image { ++ background: url('test.png'); ++ background-image: url([[ignoreMe]]); ++ background-image: image-set(url({{alsoMe}}), 1x); ++ background-image: image-set( ++ url({{ignore}}) 1x, ++ url('test.png') 2x); ++ } ++ ''', ++ ++ 'test.png': 'PNG DATA' ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++ ++ ++ ++
++
++
++
++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(util.normpath(filename))) ++ ++ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ ++ tmp_dir.CleanUp() ++ ++ def testInlineCSSWithIncludeDirective(self): ++ '''Tests that include directive in external css files also inlined''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ''', ++ ++ 'foo.css': '''''', ++ ++ 'style.css': ''' ++ ++ blink { ++ display: none; ++ } ++ ''', ++ 'style2.css': '''h1 {}''', ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testCssIncludedFileNames(self): ++ '''Tests that all included files from css are returned''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ''', ++ ++ 'test.css': ''' ++ ++ ''', ++ ++ 'test2.css': ''' ++ ++ .image { ++ background: url('test.png'); ++ } ++ ''', ++ ++ 'test3.css': '''h1 {}''', ++ ++ 'test.png': 'PNG DATA' ++ } ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ resources = html_inline.GetResourceFilenames(tmp_dir.GetPath('index.html'), ++ None) ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ tmp_dir.CleanUp() ++ ++ def testInlineCSSLinks(self): ++ '''Tests that only CSS files referenced via relative URLs are inlined.''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ''', ++ ++ 'foo.css': ''' ++ @import url(chrome://resources/blurp.css); ++ blink { ++ display: none; ++ } ++ ''', ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testFilenameVariableExpansion(self): ++ '''Tests that variables are expanded in filenames before inlining.''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ''', ++ 'style1.css': '''h1 {}''', ++ 'tmpl1.html': '''

''', ++ 'script1.js': '''console.log('hello');''', ++ 'img1.png': '''abc''', ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++

++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ def replacer(var, repl): ++ return lambda filename: filename.replace('[%s]' % var, repl) ++ ++ # Test normal inlining. ++ result = html_inline.DoInline( ++ tmp_dir.GetPath('index.html'), ++ None, ++ filename_expansion_function=replacer('WHICH', '1')) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ ++ # Test names-only inlining. ++ result = html_inline.DoInline( ++ tmp_dir.GetPath('index.html'), ++ None, ++ names_only=True, ++ filename_expansion_function=replacer('WHICH', '1')) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ tmp_dir.CleanUp() ++ ++ def testWithCloseTags(self): ++ '''Tests that close tags are removed.''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''', ++ 'style1.css': '''h1 {}''', ++ 'style2.css': '''h2 {}''', ++ 'tmpl1.html': '''

''', ++ 'tmpl2.html': '''

''', ++ 'script1.js': '''console.log('hello');''', ++ 'img1.png': '''abc''', ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++ ++ ++

++

++

++ ++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ # Test normal inlining. ++ result = html_inline.DoInline( ++ tmp_dir.GetPath('index.html'), ++ None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testCommentedJsInclude(self): ++ '''Tests that works inside a comment.''' ++ ++ files = { ++ 'include.js': '// ', ++ 'other.js': '// Copyright somebody\nalert(1);', ++ } ++ ++ expected_inlined = '// Copyright somebody\nalert(1);' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ result = html_inline.DoInline(tmp_dir.GetPath('include.js'), None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('include.js')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testCommentedJsIf(self): ++ '''Tests that works inside a comment.''' ++ ++ files = { ++ 'if.js': ''' ++ // ++ yep(); ++ // ++ ++ // ++ nope(); ++ // ++ ''', ++ } ++ ++ expected_inlined = ''' ++ // ++ yep(); ++ // ++ ++ // ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ class FakeGrdNode(object): ++ def EvaluateCondition(self, cond): ++ return eval(cond) ++ ++ result = html_inline.DoInline(tmp_dir.GetPath('if.js'), FakeGrdNode()) ++ resources = result.inlined_files ++ ++ resources.add(tmp_dir.GetPath('if.js')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testImgSrcset(self): ++ '''Tests that img srcset="" attributes are converted.''' ++ ++ # Note that there is no space before "img10.png" and that ++ # "img11.png" has no descriptor. ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''', ++ 'img1.png': '''a1''', ++ 'img2.png': '''a2''', ++ 'img3.png': '''a3''', ++ 'img4.png': '''a4''', ++ 'img5.png': '''a5''', ++ 'img6.png': '''a6''', ++ 'img7.png': '''a7''', ++ 'img8.png': '''a8''', ++ 'img9.png': '''a9''', ++ 'img10.png': '''a10''', ++ 'img11.png': '''a11''', ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ # Test normal inlining. ++ result = html_inline.DoInline( ++ tmp_dir.GetPath('index.html'), ++ None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testImgSrcsetIgnoresI18n(self): ++ '''Tests that $i18n{...} strings are ignored when inlining. ++ ''' ++ ++ src_html = ''' ++ ++ ++ ++ ++ ++ ++ ''' ++ ++ files = { ++ 'index.html': src_html, ++ } ++ ++ expected_inlined = src_html ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(util.normpath(filename))) ++ ++ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testSourceSrcset(self): ++ '''Tests that source srcset="" attributes are converted.''' ++ ++ # Note that there is no space before "img10.png" and that ++ # "img11.png" has no descriptor. ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ++ ''', ++ 'img1.png': '''a1''', ++ 'img2.png': '''a2''', ++ 'img3.png': '''a3''', ++ 'img4.png': '''a4''', ++ 'img5.png': '''a5''', ++ 'img6.png': '''a6''', ++ 'img7.png': '''a7''', ++ 'img8.png': '''a8''', ++ 'img9.png': '''a9''', ++ 'img10.png': '''a10''', ++ 'img11.png': '''a11''', ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++ ++ ++ ''' ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ # Test normal inlining. ++ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ self.failUnlessEqual(expected_inlined, ++ util.FixLineEnd(result.inlined_data, '\n')) ++ tmp_dir.CleanUp() ++ ++ def testConditionalInclude(self): ++ '''Tests that output and dependency generation includes only files not'''\ ++ ''' blocked by macros.''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''', ++ 'img1.png': '''a1''', ++ 'img2.png': '''a2''', ++ 'img3.png': '''a3''', ++ 'img4.png': '''a4''', ++ 'img5.png': '''a5''', ++ 'img6.png': '''a6''', ++ 'img7.png': '''a7''', ++ 'img8.png': '''a8''', ++ 'img9.png': '''a9''', ++ 'img10.png': '''a10''', ++ } ++ ++ expected_inlined = ''' ++ ++ ++ ++ ++ ++ ''' ++ ++ expected_files = [ ++ 'index.html', ++ 'img1.png', ++ 'img2.png', ++ 'img3.png', ++ 'img7.png', ++ 'img8.png', ++ 'img9.png', ++ 'img10.png' ++ ] ++ ++ source_resources = set() ++ tmp_dir = util.TempDir(files) ++ for filename in expected_files: ++ source_resources.add(tmp_dir.GetPath(filename)) ++ ++ class FakeGrdNode(object): ++ def EvaluateCondition(self, cond): ++ return eval(cond) ++ ++ # Test normal inlining. ++ result = html_inline.DoInline( ++ tmp_dir.GetPath('index.html'), ++ FakeGrdNode()) ++ resources = result.inlined_files ++ resources.add(tmp_dir.GetPath('index.html')) ++ self.failUnlessEqual(resources, source_resources) ++ ++ # ignore whitespace ++ expected_inlined = re.sub(r'\s+', ' ', expected_inlined) ++ actually_inlined = re.sub(r'\s+', ' ', ++ util.FixLineEnd(result.inlined_data, '\n')) ++ self.failUnlessEqual(expected_inlined, actually_inlined); ++ tmp_dir.CleanUp() ++ ++ def testPreprocessOnlyEvaluatesIncludeAndIf(self): ++ '''Tests that preprocess_only=true evaluates and only. ''' ++ ++ files = { ++ 'index.html': ''' ++ ++ ++ ++ ++ ++
++ ++
++ ++
++ ++ ++
++ ++
++    ++
++ ++
++
++ ''')) ++ html.Parse() ++ trans = html.Translate('en') ++ if (html.GetText() != trans): ++ self.fail() ++ ++ ++ def testHtmlToMessageWithBlockTags(self): ++ msg = tr_html.HtmlToMessage( ++ 'Hello

Howdiebingo', True) ++ result = msg.GetPresentableContent() ++ self.failUnless( ++ result == 'HelloBEGIN_PARAGRAPHHowdieBEGIN_BLOCKbingoEND_BLOCK') ++ ++ msg = tr_html.HtmlToMessage( ++ 'Hello

Howdie', True) ++ result = msg.GetPresentableContent() ++ self.failUnless( ++ result == 'HelloBEGIN_PARAGRAPHHowdieBEGIN_BLOCKbingoEND_BLOCK') ++ ++ ++ def testHtmlToMessageRegressions(self): ++ msg = tr_html.HtmlToMessage(' - ', True) ++ result = msg.GetPresentableContent() ++ self.failUnless(result == ' - ') ++ ++ ++ def testEscapeUnescaped(self): ++ text = '©  & "<hello>"' ++ unescaped = util.UnescapeHtml(text) ++ self.failUnless(unescaped == u'\u00a9\u00a0 & ""') ++ escaped_unescaped = util.EscapeHtml(unescaped, True) ++ self.failUnless(escaped_unescaped == ++ u'\u00a9\u00a0 & "<hello>"') ++ ++ def testRegressionCjkHtmlFile(self): ++ # TODO(joi) Fix this problem where unquoted attributes that ++ # have a value that is CJK characters causes the regular expression ++ # match never to return. (culprit is the _ELEMENT regexp( ++ if False: ++ html = self.HtmlFromFileWithManualCheck(util.PathFromRoot( ++ r'grit/testdata/ko_oem_enable_bug.html')) ++ self.failUnless(True) ++ ++ def testRegressionCpuHang(self): ++ # If this regression occurs, the unit test will never return ++ html = tr_html.TrHtml(StringIO( ++ '''''')) ++ html.Parse() ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/gather/txt.py b/tools/grit/grit/gather/txt.py +new file mode 100644 +index 0000000000..e5c10abc28 +--- /dev/null ++++ b/tools/grit/grit/gather/txt.py +@@ -0,0 +1,38 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Supports making amessage from a text file. ++''' ++ ++from __future__ import print_function ++ ++from grit.gather import interface ++from grit import tclib ++ ++ ++class TxtFile(interface.GathererBase): ++ '''A text file gatherer. Very simple, all text from the file becomes a ++ single clique. ++ ''' ++ ++ def Parse(self): ++ self.text_ = self._LoadInputFile() ++ self.clique_ = self.uberclique.MakeClique(tclib.Message(text=self.text_)) ++ ++ def GetText(self): ++ '''Returns the text of what is being gathered.''' ++ return self.text_ ++ ++ def GetTextualIds(self): ++ return [self.extkey] ++ ++ def GetCliques(self): ++ '''Returns the MessageClique objects for all translateable portions.''' ++ return [self.clique_] ++ ++ def Translate(self, lang, pseudo_if_not_available=True, ++ skeleton_gatherer=None, fallback_to_english=False): ++ return self.clique_.MessageForLanguage(lang, ++ pseudo_if_not_available, ++ fallback_to_english).GetRealContent() +diff --git a/tools/grit/grit/gather/txt_unittest.py b/tools/grit/grit/gather/txt_unittest.py +new file mode 100644 +index 0000000000..abb9ed98d7 +--- /dev/null ++++ b/tools/grit/grit/gather/txt_unittest.py +@@ -0,0 +1,35 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for TxtFile gatherer''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++ ++import unittest ++ ++from six import StringIO ++ ++from grit.gather import txt ++ ++ ++class TxtUnittest(unittest.TestCase): ++ def testGather(self): ++ input = StringIO('Hello there\nHow are you?') ++ gatherer = txt.TxtFile(input) ++ gatherer.Parse() ++ self.failUnless(gatherer.GetText() == input.getvalue()) ++ self.failUnless(len(gatherer.GetCliques()) == 1) ++ self.failUnless(gatherer.GetCliques()[0].GetMessage().GetRealContent() == ++ input.getvalue()) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/grd_reader.py b/tools/grit/grit/grd_reader.py +new file mode 100644 +index 0000000000..b7bb782977 +--- /dev/null ++++ b/tools/grit/grit/grd_reader.py +@@ -0,0 +1,238 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Class for reading GRD files into memory, without processing them. ++''' ++ ++from __future__ import print_function ++ ++import os.path ++import sys ++import xml.sax ++import xml.sax.handler ++ ++import six ++ ++from grit import exception ++from grit import util ++from grit.node import mapping ++from grit.node import misc ++ ++ ++class StopParsingException(Exception): ++ '''An exception used to stop parsing.''' ++ pass ++ ++ ++class GrdContentHandler(xml.sax.handler.ContentHandler): ++ def __init__(self, stop_after, debug, dir, defines, tags_to_ignore, ++ target_platform, source): ++ # Invariant of data: ++ # 'root' is the root of the parse tree being created, or None if we haven't ++ # parsed out any elements. ++ # 'stack' is the a stack of elements that we push new nodes onto and ++ # pop from when they finish parsing, or [] if we are not currently parsing. ++ # 'stack[-1]' is the top of the stack. ++ self.root = None ++ self.stack = [] ++ self.stop_after = stop_after ++ self.debug = debug ++ self.dir = dir ++ self.defines = defines ++ self.tags_to_ignore = tags_to_ignore or set() ++ self.ignore_depth = 0 ++ self.target_platform = target_platform ++ self.source = source ++ ++ def startElement(self, name, attrs): ++ if self.ignore_depth or name in self.tags_to_ignore: ++ if self.debug and self.ignore_depth == 0: ++ print("Ignoring element %s and its children" % name) ++ self.ignore_depth += 1 ++ return ++ ++ if self.debug: ++ attr_list = ' '.join('%s="%s"' % kv for kv in attrs.items()) ++ print("Starting parsing of element %s with attributes %r" % ++ (name, attr_list or '(none)')) ++ ++ typeattr = attrs.get('type') ++ node = mapping.ElementToClass(name, typeattr)() ++ node.source = self.source ++ ++ if self.stack: ++ self.stack[-1].AddChild(node) ++ node.StartParsing(name, self.stack[-1]) ++ else: ++ assert self.root is None ++ self.root = node ++ if isinstance(self.root, misc.GritNode): ++ if self.target_platform: ++ self.root.SetTargetPlatform(self.target_platform) ++ node.StartParsing(name, None) ++ if self.defines: ++ node.SetDefines(self.defines) ++ self.stack.append(node) ++ ++ for attr, attrval in attrs.items(): ++ node.HandleAttribute(attr, attrval) ++ ++ def endElement(self, name): ++ if self.ignore_depth: ++ self.ignore_depth -= 1 ++ return ++ ++ if name == 'part': ++ partnode = self.stack[-1] ++ partnode.started_inclusion = True ++ # Add the contents of the sub-grd file as children of the node. ++ partname = os.path.join(self.dir, partnode.GetInputPath()) ++ # Check the GRDP file exists. ++ if not os.path.exists(partname): ++ raise exception.FileNotFound(partname) ++ # Exceptions propagate to the handler in grd_reader.Parse(). ++ oldsource = self.source ++ try: ++ self.source = partname ++ xml.sax.parse(partname, GrdPartContentHandler(self)) ++ finally: ++ self.source = oldsource ++ ++ if self.debug: ++ print("End parsing of element %s" % name) ++ self.stack.pop().EndParsing() ++ ++ if name == self.stop_after: ++ raise StopParsingException() ++ ++ def characters(self, content): ++ if self.ignore_depth == 0: ++ if self.stack[-1]: ++ self.stack[-1].AppendContent(content) ++ ++ def ignorableWhitespace(self, whitespace): ++ # TODO(joi): This is not supported by expat. Should use a different XML ++ # parser? ++ pass ++ ++ ++class GrdPartContentHandler(xml.sax.handler.ContentHandler): ++ def __init__(self, parent): ++ self.parent = parent ++ self.depth = 0 ++ ++ def startElement(self, name, attrs): ++ if self.depth: ++ self.parent.startElement(name, attrs) ++ else: ++ if name != 'grit-part': ++ raise exception.MissingElement("root tag must be ") ++ if attrs: ++ raise exception.UnexpectedAttribute( ++ " tag must not have attributes") ++ self.depth += 1 ++ ++ def endElement(self, name): ++ self.depth -= 1 ++ if self.depth: ++ self.parent.endElement(name) ++ ++ def characters(self, content): ++ self.parent.characters(content) ++ ++ def ignorableWhitespace(self, whitespace): ++ self.parent.ignorableWhitespace(whitespace) ++ ++ ++def Parse(filename_or_stream, dir=None, stop_after=None, first_ids_file=None, ++ debug=False, defines=None, tags_to_ignore=None, target_platform=None, ++ predetermined_ids_file=None): ++ '''Parses a GRD file into a tree of nodes (from grit.node). ++ ++ If filename_or_stream is a stream, 'dir' should point to the directory ++ notionally containing the stream (this feature is only used in unit tests). ++ ++ If 'stop_after' is provided, the parsing will stop once the first node ++ with this name has been fully parsed (including all its contents). ++ ++ If 'debug' is true, lots of information about the parsing events will be ++ printed out during parsing of the file. ++ ++ If 'first_ids_file' is non-empty, it is used to override the setting for the ++ first_ids_file attribute of the root node. Note that the first_ids_file ++ parameter should be relative to the cwd, even though the first_ids_file ++ attribute of the node is relative to the grd file. ++ ++ If 'target_platform' is set, this is used to determine the target ++ platform of builds, instead of using |sys.platform|. ++ ++ Args: ++ filename_or_stream: './bla.xml' ++ dir: None (if filename_or_stream is a filename) or '.' ++ stop_after: 'inputs' ++ first_ids_file: 'GRIT_DIR/../gritsettings/resource_ids' ++ debug: False ++ defines: dictionary of defines, like {'chromeos': '1'} ++ target_platform: None or the value that would be returned by sys.platform ++ on your target platform. ++ predetermined_ids_file: File path to a file containing a pre-determined ++ mapping from resource names to resource ids which will be used to assign ++ resource ids to those resources. ++ ++ Return: ++ Subclass of grit.node.base.Node ++ ++ Throws: ++ grit.exception.Parsing ++ ''' ++ ++ if isinstance(filename_or_stream, six.string_types): ++ source = filename_or_stream ++ if dir is None: ++ dir = util.dirname(filename_or_stream) ++ else: ++ source = None ++ ++ handler = GrdContentHandler(stop_after=stop_after, debug=debug, dir=dir, ++ defines=defines, tags_to_ignore=tags_to_ignore, ++ target_platform=target_platform, source=source) ++ try: ++ xml.sax.parse(filename_or_stream, handler) ++ except StopParsingException: ++ assert stop_after ++ pass ++ except: ++ if not debug: ++ print("parse exception: run GRIT with the -x flag to debug .grd problems") ++ raise ++ ++ if handler.root.name != 'grit': ++ raise exception.MissingElement("root tag must be ") ++ ++ if hasattr(handler.root, 'SetOwnDir'): ++ # Fix up the base_dir so it is relative to the input file. ++ assert dir is not None ++ handler.root.SetOwnDir(dir) ++ ++ if isinstance(handler.root, misc.GritNode): ++ handler.root.SetPredeterminedIdsFile(predetermined_ids_file) ++ if first_ids_file: ++ # Make the path to the first_ids_file relative to the grd file, ++ # unless it begins with GRIT_DIR. ++ GRIT_DIR_PREFIX = 'GRIT_DIR' ++ if not (first_ids_file.startswith(GRIT_DIR_PREFIX) ++ and first_ids_file[len(GRIT_DIR_PREFIX)] in ['/', '\\']): ++ rel_dir = os.path.relpath(os.getcwd(), dir) ++ first_ids_file = util.normpath(os.path.join(rel_dir, first_ids_file)) ++ handler.root.attrs['first_ids_file'] = first_ids_file ++ # Assign first ids to the nodes that don't have them. ++ handler.root.AssignFirstIds(filename_or_stream, defines) ++ ++ return handler.root ++ ++ ++if __name__ == '__main__': ++ util.ChangeStdoutEncoding() ++ print(six.text_type(Parse(sys.argv[1]))) +diff --git a/tools/grit/grit/grd_reader_unittest.py b/tools/grit/grit/grd_reader_unittest.py +new file mode 100644 +index 0000000000..920a92f9c0 +--- /dev/null ++++ b/tools/grit/grit/grd_reader_unittest.py +@@ -0,0 +1,346 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grd_reader package''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import unittest ++ ++import six ++from six import StringIO ++ ++from grit import exception ++from grit import grd_reader ++from grit import util ++from grit.node import empty ++from grit.node import message ++ ++ ++class GrdReaderUnittest(unittest.TestCase): ++ def testParsingAndXmlOutput(self): ++ input = u''' ++ ++ ++ ++ ++ ++ ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++''' ++ pseudo_file = StringIO(input) ++ tree = grd_reader.Parse(pseudo_file, '.') ++ output = six.text_type(tree) ++ expected_output = input.replace(u' base_dir="."', u'') ++ self.assertEqual(expected_output, output) ++ self.failUnless(tree.GetNodeById('IDS_GREETING')) ++ ++ ++ def testStopAfter(self): ++ input = u''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++''' ++ pseudo_file = StringIO(input) ++ tree = grd_reader.Parse(pseudo_file, '.', stop_after='outputs') ++ # only an child ++ self.failUnless(len(tree.children) == 1) ++ self.failUnless(tree.children[0].name == 'outputs') ++ ++ def testLongLinesWithComments(self): ++ input = u''' ++ ++ ++ ++ ++ This is a very long line with no linebreaks yes yes it stretches on and on and on! ++ ++ ++ ++''' ++ pseudo_file = StringIO(input) ++ tree = grd_reader.Parse(pseudo_file, '.') ++ ++ greeting = tree.GetNodeById('IDS_GREETING') ++ self.failUnless(greeting.GetCliques()[0].GetMessage().GetRealContent() == ++ 'This is a very long line with no linebreaks yes yes it ' ++ 'stretches on and on and on!') ++ ++ def doTestAssignFirstIds(self, first_ids_path): ++ input = u''' ++ ++ ++ ++ ++ test ++ ++ ++ ++''' % first_ids_path ++ pseudo_file = StringIO(input) ++ grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), ++ '..') ++ fake_input_path = os.path.join( ++ grit_root_dir, "grit/testdata/chrome/app/generated_resources.grd") ++ root = grd_reader.Parse(pseudo_file, os.path.split(fake_input_path)[0]) ++ root.AssignFirstIds(fake_input_path, {}) ++ messages_node = root.children[0].children[0] ++ self.failUnless(isinstance(messages_node, empty.MessagesNode)) ++ self.failUnless(messages_node.attrs["first_id"] != ++ empty.MessagesNode().DefaultAttributes()["first_id"]) ++ ++ def testAssignFirstIds(self): ++ self.doTestAssignFirstIds("../../tools/grit/resource_ids") ++ ++ def testAssignFirstIdsUseGritDir(self): ++ self.doTestAssignFirstIds("GRIT_DIR/grit/testdata/tools/grit/resource_ids") ++ ++ def testAssignFirstIdsMultipleMessages(self): ++ """If there are multiple messages sections, the resource_ids file ++ needs to list multiple first_id values.""" ++ input = u''' ++ ++ ++ ++ ++ test ++ ++ ++ ++ ++ test2 ++ ++ ++ ++''' ++ pseudo_file = StringIO(input) ++ grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), ++ '..') ++ fake_input_path = os.path.join(grit_root_dir, "grit/testdata/test.grd") ++ ++ root = grd_reader.Parse(pseudo_file, os.path.split(fake_input_path)[0]) ++ root.AssignFirstIds(fake_input_path, {}) ++ messages_node = root.children[0].children[0] ++ self.assertTrue(isinstance(messages_node, empty.MessagesNode)) ++ self.assertEqual('100', messages_node.attrs["first_id"]) ++ messages_node = root.children[0].children[1] ++ self.assertTrue(isinstance(messages_node, empty.MessagesNode)) ++ self.assertEqual('10000', messages_node.attrs["first_id"]) ++ ++ def testUseNameForIdAndPpIfdef(self): ++ input = u''' ++ ++ ++ ++ ++ ++ Hello! ++ ++ ++ ++ ++''' ++ pseudo_file = StringIO(input) ++ root = grd_reader.Parse(pseudo_file, '.', defines={'hello': '1'}) ++ ++ # Check if the ID is set to the name. In the past, there was a bug ++ # that caused the ID to be a generated number. ++ hello = root.GetNodeById('IDS_HELLO') ++ self.failUnless(hello.GetCliques()[0].GetId() == 'IDS_HELLO') ++ ++ def testUseNameForIdWithIfElse(self): ++ input = u''' ++ ++ ++ ++ ++ ++ ++ Hello! ++ ++ ++ ++ ++ Yellow! ++ ++ ++ ++ ++ ++''' ++ pseudo_file = StringIO(input) ++ root = grd_reader.Parse(pseudo_file, '.', defines={'hello': '1'}) ++ ++ # Check if the ID is set to the name. In the past, there was a bug ++ # that caused the ID to be a generated number. ++ hello = root.GetNodeById('IDS_HELLO') ++ self.failUnless(hello.GetCliques()[0].GetId() == 'IDS_HELLO') ++ ++ def testPartInclusionAndCorrectSource(self): ++ arbitrary_path_grd = u'''\ ++ ++ test5 ++ ''' ++ tmp_dir = util.TempDir({'arbitrary_path.grp': arbitrary_path_grd}) ++ arbitrary_path_grd_file = tmp_dir.GetPath('arbitrary_path.grp') ++ top_grd = u'''\ ++ ++ ++ ++ ++ test ++ ++ ++ ++ ++ ++ ''' % arbitrary_path_grd_file ++ sub_grd = u'''\ ++ ++ test2 ++ ++ test3 ++ ''' ++ subsub_grd = u'''\ ++ ++ test4 ++ ''' ++ expected_output = u'''\ ++ ++ ++ ++ ++ test ++ ++ ++ ++ test2 ++ ++ ++ ++ test4 ++ ++ ++ ++ test3 ++ ++ ++ ++ ++ test5 ++ ++ ++ ++ ++ ''' % arbitrary_path_grd_file ++ ++ with util.TempDir({'sub.grp': sub_grd, ++ 'subsub.grp': subsub_grd}) as tmp_sub_dir: ++ output = grd_reader.Parse(StringIO(top_grd), ++ tmp_sub_dir.GetPath()) ++ correct_sources = { ++ 'IDS_TEST': None, ++ 'IDS_TEST2': tmp_sub_dir.GetPath('sub.grp'), ++ 'IDS_TEST3': tmp_sub_dir.GetPath('sub.grp'), ++ 'IDS_TEST4': tmp_sub_dir.GetPath('subsub.grp'), ++ 'IDS_TEST5': arbitrary_path_grd_file, ++ } ++ ++ for node in output.ActiveDescendants(): ++ with node: ++ if isinstance(node, message.MessageNode): ++ self.assertEqual(correct_sources[node.attrs.get('name')], node.source) ++ self.assertEqual(expected_output.split(), output.FormatXml().split()) ++ tmp_dir.CleanUp() ++ ++ def testPartInclusionFailure(self): ++ template = u''' ++ ++ ++ %s ++ ++ ''' ++ ++ part_failures = [ ++ (exception.UnexpectedContent, u'fnord'), ++ (exception.UnexpectedChild, ++ u''), ++ (exception.FileNotFound, u''), ++ ] ++ for raises, data in part_failures: ++ data = StringIO(template % data) ++ self.assertRaises(raises, grd_reader.Parse, data, '.') ++ ++ gritpart_failures = [ ++ (exception.UnexpectedAttribute, u''), ++ (exception.MissingElement, u''), ++ ] ++ for raises, data in gritpart_failures: ++ top_grd = StringIO(template % u'') ++ with util.TempDir({'bad.grp': data}) as temp_dir: ++ self.assertRaises(raises, grd_reader.Parse, top_grd, temp_dir.GetPath()) ++ ++ def testEarlyEnoughPlatformSpecification(self): ++ # This is a regression test for issue ++ # https://code.google.com/p/grit-i18n/issues/detail?id=23 ++ grd_text = u''' ++ ++ ++ ++ ++ foo ++ ++ ++ ++ boo ++ ++ ++ ++ ''' % sys.platform ++ with util.TempDir({}) as temp_dir: ++ grd_reader.Parse(StringIO(grd_text), temp_dir.GetPath(), ++ target_platform='android') ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/grit-todo.xml b/tools/grit/grit/grit-todo.xml +new file mode 100644 +index 0000000000..b8c20fdfad +--- /dev/null ++++ b/tools/grit/grit/grit-todo.xml +@@ -0,0 +1,62 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/grit_runner.py b/tools/grit/grit/grit_runner.py +new file mode 100644 +index 0000000000..26aa0d58c4 +--- /dev/null ++++ b/tools/grit/grit/grit_runner.py +@@ -0,0 +1,334 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Command processor for GRIT. This is the script you invoke to run the various ++GRIT tools. ++""" ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import getopt ++ ++from grit import util ++ ++import grit.extern.FP ++ ++# Tool info factories; these import only within each factory to avoid ++# importing most of the GRIT code until required. ++def ToolFactoryBuild(): ++ import grit.tool.build ++ return grit.tool.build.RcBuilder() ++ ++def ToolFactoryBuildInfo(): ++ import grit.tool.buildinfo ++ return grit.tool.buildinfo.DetermineBuildInfo() ++ ++def ToolFactoryCount(): ++ import grit.tool.count ++ return grit.tool.count.CountMessage() ++ ++def ToolFactoryDiffStructures(): ++ import grit.tool.diff_structures ++ return grit.tool.diff_structures.DiffStructures() ++ ++def ToolFactoryMenuTranslationsFromParts(): ++ import grit.tool.menu_from_parts ++ return grit.tool.menu_from_parts.MenuTranslationsFromParts() ++ ++def ToolFactoryNewGrd(): ++ import grit.tool.newgrd ++ return grit.tool.newgrd.NewGrd() ++ ++def ToolFactoryResizeDialog(): ++ import grit.tool.resize ++ return grit.tool.resize.ResizeDialog() ++ ++def ToolFactoryRc2Grd(): ++ import grit.tool.rc2grd ++ return grit.tool.rc2grd.Rc2Grd() ++ ++def ToolFactoryTest(): ++ import grit.tool.test ++ return grit.tool.test.TestTool() ++ ++def ToolFactoryTranslationToTc(): ++ import grit.tool.transl2tc ++ return grit.tool.transl2tc.TranslationToTc() ++ ++def ToolFactoryUnit(): ++ import grit.tool.unit ++ return grit.tool.unit.UnitTestTool() ++ ++ ++def ToolFactoryUpdateResourceIds(): ++ import grit.tool.update_resource_ids ++ return grit.tool.update_resource_ids.UpdateResourceIds() ++ ++ ++def ToolFactoryXmb(): ++ import grit.tool.xmb ++ return grit.tool.xmb.OutputXmb() ++ ++def ToolAndroid2Grd(): ++ import grit.tool.android2grd ++ return grit.tool.android2grd.Android2Grd() ++ ++# Keys for the following map ++_FACTORY = 1 ++_REQUIRES_INPUT = 2 ++_HIDDEN = 3 # optional key - presence indicates tool is hidden ++ ++# Maps tool names to the tool's module. Done as a list of (key, value) tuples ++# instead of a map to preserve ordering. ++_TOOLS = [ ++ ['android2grd', { ++ _FACTORY: ToolAndroid2Grd, ++ _REQUIRES_INPUT: False ++ }], ++ ['build', { ++ _FACTORY: ToolFactoryBuild, ++ _REQUIRES_INPUT: True ++ }], ++ ['buildinfo', { ++ _FACTORY: ToolFactoryBuildInfo, ++ _REQUIRES_INPUT: True ++ }], ++ ['count', { ++ _FACTORY: ToolFactoryCount, ++ _REQUIRES_INPUT: True ++ }], ++ [ ++ 'menufromparts', ++ { ++ _FACTORY: ToolFactoryMenuTranslationsFromParts, ++ _REQUIRES_INPUT: True, ++ _HIDDEN: True ++ } ++ ], ++ ['newgrd', { ++ _FACTORY: ToolFactoryNewGrd, ++ _REQUIRES_INPUT: False ++ }], ++ ['rc2grd', { ++ _FACTORY: ToolFactoryRc2Grd, ++ _REQUIRES_INPUT: False ++ }], ++ ['resize', { ++ _FACTORY: ToolFactoryResizeDialog, ++ _REQUIRES_INPUT: True ++ }], ++ ['sdiff', { ++ _FACTORY: ToolFactoryDiffStructures, ++ _REQUIRES_INPUT: False ++ }], ++ ['test', { ++ _FACTORY: ToolFactoryTest, ++ _REQUIRES_INPUT: True, ++ _HIDDEN: True ++ }], ++ [ ++ 'transl2tc', ++ { ++ _FACTORY: ToolFactoryTranslationToTc, ++ _REQUIRES_INPUT: False ++ } ++ ], ++ ['unit', { ++ _FACTORY: ToolFactoryUnit, ++ _REQUIRES_INPUT: False ++ }], ++ [ ++ 'update_resource_ids', ++ { ++ _FACTORY: ToolFactoryUpdateResourceIds, ++ _REQUIRES_INPUT: False ++ } ++ ], ++ ['xmb', { ++ _FACTORY: ToolFactoryXmb, ++ _REQUIRES_INPUT: True ++ }], ++] ++ ++ ++def PrintUsage(): ++ tool_list = '' ++ for (tool, info) in _TOOLS: ++ if not _HIDDEN in info: ++ tool_list += ' %-12s %s\n' % ( ++ tool, info[_FACTORY]().ShortDescription()) ++ ++ print("""GRIT - the Google Resource and Internationalization Tool ++ ++Usage: grit [GLOBALOPTIONS] TOOL [args to tool] ++ ++Global options: ++ ++ -i INPUT Specifies the INPUT file to use (a .grd file). If this is not ++ specified, GRIT will look for the environment variable GRIT_INPUT. ++ If it is not present either, GRIT will try to find an input file ++ named 'resource.grd' in the current working directory. ++ ++ -h MODULE Causes GRIT to use MODULE.UnsignedFingerPrint instead of ++ grit.extern.FP.UnsignedFingerprint. MODULE must be ++ available somewhere in the PYTHONPATH search path. ++ ++ -v Print more verbose runtime information. ++ ++ -x Print extremely verbose runtime information. Implies -v ++ ++ -p FNAME Specifies that GRIT should profile its execution and output the ++ results to the file FNAME. ++ ++Tools: ++ ++ TOOL can be one of the following: ++%s ++ For more information on how to use a particular tool, and the specific ++ arguments you can send to that tool, execute 'grit help TOOL' ++""" % (tool_list)) ++ ++ ++class Options(object): ++ """Option storage and parsing.""" ++ ++ def __init__(self): ++ self.hash = None ++ self.input = None ++ self.verbose = False ++ self.extra_verbose = False ++ self.output_stream = sys.stdout ++ self.profile_dest = None ++ ++ def ReadOptions(self, args): ++ """Reads options from the start of args and returns the remainder.""" ++ (opts, args) = getopt.getopt(args, 'vxi:p:h:', ('help',)) ++ for (key, val) in opts: ++ if key == '-h': self.hash = val ++ elif key == '-i': self.input = val ++ elif key == '-v': ++ self.verbose = True ++ util.verbose = True ++ elif key == '-x': ++ self.verbose = True ++ util.verbose = True ++ self.extra_verbose = True ++ util.extra_verbose = True ++ elif key == '-p': self.profile_dest = val ++ elif key == '--help': ++ PrintUsage() ++ sys.exit(0) ++ ++ if not self.input: ++ if 'GRIT_INPUT' in os.environ: ++ self.input = os.environ['GRIT_INPUT'] ++ else: ++ self.input = 'resource.grd' ++ ++ return args ++ ++ def __repr__(self): ++ return '(verbose: %d, input: %s)' % ( ++ self.verbose, self.input) ++ ++ ++def _GetToolInfo(tool): ++ """Returns the info map for the tool named 'tool' or None if there is no ++ such tool.""" ++ matches = [t for t in _TOOLS if t[0] == tool] ++ if not matches: ++ return None ++ else: ++ return matches[0][1] ++ ++ ++def Main(args=None): ++ """Parses arguments and does the appropriate thing.""" ++ util.ChangeStdoutEncoding() ++ ++ # Support for setuptools console wrappers. ++ if args is None: ++ args = sys.argv[1:] ++ ++ options = Options() ++ try: ++ args = options.ReadOptions(args) # args may be shorter after this ++ except getopt.GetoptError as e: ++ print("grit:", str(e)) ++ print("Try running 'grit help' for valid options.") ++ return 1 ++ if not args: ++ print("No tool provided. Try running 'grit help' for a list of tools.") ++ return 2 ++ ++ tool = args[0] ++ if tool == 'help': ++ if len(args) == 1: ++ PrintUsage() ++ return 0 ++ else: ++ tool = args[1] ++ if not _GetToolInfo(tool): ++ print("No such tool. Try running 'grit help' for a list of tools.") ++ return 2 ++ ++ print("Help for 'grit %s' (for general help, run 'grit help'):\n" % ++ (tool,)) ++ _GetToolInfo(tool)[_FACTORY]().ShowUsage() ++ return 0 ++ if not _GetToolInfo(tool): ++ print("No such tool. Try running 'grit help' for a list of tools.") ++ return 2 ++ ++ try: ++ if _GetToolInfo(tool)[_REQUIRES_INPUT]: ++ os.stat(options.input) ++ except OSError: ++ print('Input file %s not found.\n' ++ 'To specify a different input file:\n' ++ ' 1. Use the GRIT_INPUT environment variable.\n' ++ ' 2. Use the -i command-line option. This overrides ' ++ 'GRIT_INPUT.\n' ++ ' 3. Specify neither GRIT_INPUT or -i and GRIT will try to load ' ++ "'resource.grd'\n" ++ ' from the current directory.' % options.input) ++ return 2 ++ ++ if options.hash: ++ grit.extern.FP.UseUnsignedFingerPrintFromModule(options.hash) ++ ++ try: ++ toolobject = _GetToolInfo(tool)[_FACTORY]() ++ if options.profile_dest: ++ import hotshot ++ prof = hotshot.Profile(options.profile_dest) ++ return prof.runcall(toolobject.Run, options, args[1:]) ++ else: ++ return toolobject.Run(options, args[1:]) ++ except getopt.GetoptError as e: ++ print("grit: %s: %s" % (tool, str(e))) ++ print("Try running 'grit help %s' for valid options." % (tool,)) ++ return 1 ++ ++ ++if __name__ == '__main__': ++ sys.path.append( ++ os.path.join( ++ os.path.dirname( ++ os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), ++ 'diagnosis')) ++ try: ++ import crbug_1001171 ++ with crbug_1001171.DumpStateOnLookupError(): ++ sys.exit(Main(sys.argv[1:])) ++ except ImportError: ++ pass ++ ++ sys.exit(Main(sys.argv[1:])) +diff --git a/tools/grit/grit/grit_runner_unittest.py b/tools/grit/grit/grit_runner_unittest.py +new file mode 100644 +index 0000000000..1487001d81 +--- /dev/null ++++ b/tools/grit/grit/grit_runner_unittest.py +@@ -0,0 +1,42 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.py''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import unittest ++ ++from six import StringIO ++ ++from grit import util ++import grit.grit_runner ++ ++class OptionArgsUnittest(unittest.TestCase): ++ def setUp(self): ++ self.buf = StringIO() ++ self.old_stdout = sys.stdout ++ sys.stdout = self.buf ++ ++ def tearDown(self): ++ sys.stdout = self.old_stdout ++ ++ def testSimple(self): ++ grit.grit_runner.Main(['-i', ++ util.PathFromRoot('grit/testdata/simple-input.xml'), ++ 'test', 'bla', 'voff', 'ga']) ++ output = self.buf.getvalue() ++ self.failUnless(output.count("'test'") == 0) # tool name doesn't occur ++ self.failUnless(output.count('bla')) ++ self.failUnless(output.count('simple-input.xml')) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/lazy_re.py b/tools/grit/grit/lazy_re.py +new file mode 100644 +index 0000000000..5c461e87e7 +--- /dev/null ++++ b/tools/grit/grit/lazy_re.py +@@ -0,0 +1,46 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''In GRIT, we used to compile a lot of regular expressions at parse ++time. Since many of them never get used, we use lazy_re to compile ++them on demand the first time they are used, thus speeding up startup ++time in some cases. ++''' ++ ++from __future__ import print_function ++ ++import re ++ ++ ++class LazyRegexObject(object): ++ '''This object creates a RegexObject with the arguments passed in ++ its constructor, the first time any attribute except the several on ++ the class itself is accessed. This accomplishes lazy compilation of ++ the regular expression while maintaining a nearly-identical ++ interface. ++ ''' ++ ++ def __init__(self, *args, **kwargs): ++ self._stash_args = args ++ self._stash_kwargs = kwargs ++ self._lazy_re = None ++ ++ def _LazyInit(self): ++ if not self._lazy_re: ++ self._lazy_re = re.compile(*self._stash_args, **self._stash_kwargs) ++ ++ def __getattribute__(self, name): ++ if name in ('_LazyInit', '_lazy_re', '_stash_args', '_stash_kwargs'): ++ return object.__getattribute__(self, name) ++ else: ++ self._LazyInit() ++ return getattr(self._lazy_re, name) ++ ++ ++def compile(*args, **kwargs): ++ '''Creates a LazyRegexObject that, when invoked on, will compile a ++ re.RegexObject (via re.compile) with the same arguments passed to ++ this function, and delegate almost all of its methods to it. ++ ''' ++ return LazyRegexObject(*args, **kwargs) +diff --git a/tools/grit/grit/lazy_re_unittest.py b/tools/grit/grit/lazy_re_unittest.py +new file mode 100644 +index 0000000000..8488b454ee +--- /dev/null ++++ b/tools/grit/grit/lazy_re_unittest.py +@@ -0,0 +1,40 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit test for lazy_re. ++''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import re ++import unittest ++ ++from grit import lazy_re ++ ++ ++class LazyReUnittest(unittest.TestCase): ++ ++ def testCreatedOnlyOnDemand(self): ++ rex = lazy_re.compile('bingo') ++ self.assertEqual(None, rex._lazy_re) ++ self.assertTrue(rex.match('bingo')) ++ self.assertNotEqual(None, rex._lazy_re) ++ ++ def testJustKwargsWork(self): ++ rex = lazy_re.compile(flags=re.I, pattern='BiNgO') ++ self.assertTrue(rex.match('bingo')) ++ ++ def testPositionalAndKwargsWork(self): ++ rex = lazy_re.compile('BiNgO', flags=re.I) ++ self.assertTrue(rex.match('bingo')) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/__init__.py b/tools/grit/grit/node/__init__.py +new file mode 100644 +index 0000000000..2fc0d3360c +--- /dev/null ++++ b/tools/grit/grit/node/__init__.py +@@ -0,0 +1,8 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Package 'grit.node' ++''' ++ ++pass +diff --git a/tools/grit/grit/node/base.py b/tools/grit/grit/node/base.py +new file mode 100644 +index 0000000000..40859d301d +--- /dev/null ++++ b/tools/grit/grit/node/base.py +@@ -0,0 +1,670 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Base types for nodes in a GRIT resource tree. ++''' ++ ++from __future__ import print_function ++ ++import ast ++import os ++import struct ++import sys ++from xml.sax import saxutils ++ ++import six ++ ++from grit import constants ++from grit import clique ++from grit import exception ++from grit import util ++from grit.node import brotli_util ++import grit.format.gzip_string ++ ++ ++class Node(object): ++ '''An item in the tree that has children.''' ++ ++ # Valid content types that can be returned by _ContentType() ++ _CONTENT_TYPE_NONE = 0 # No CDATA content but may have children ++ _CONTENT_TYPE_CDATA = 1 # Only CDATA, no children. ++ _CONTENT_TYPE_MIXED = 2 # CDATA and children, possibly intermingled ++ ++ # Types of files to be compressed by default. ++ _COMPRESS_BY_DEFAULT_EXTENSIONS = ('.js', '.html', '.css', '.svg') ++ ++ # Default nodes to not whitelist skipped ++ _whitelist_marked_as_skip = False ++ ++ # A class-static cache to speed up EvaluateExpression(). ++ # Keys are expressions (e.g. 'is_ios and lang == "fr"'). Values are tuples ++ # (code, variables_in_expr) where code is the compiled expression and can be ++ # directly eval'd, and variables_in_expr is the list of variable and method ++ # names used in the expression (e.g. ['is_ios', 'lang']). ++ eval_expr_cache = {} ++ ++ def __init__(self): ++ self.children = [] # A list of child elements ++ self.mixed_content = [] # A list of u'' and/or child elements (this ++ # duplicates 'children' but ++ # is needed to preserve markup-type content). ++ self.name = u'' # The name of this element ++ self.attrs = {} # The set of attributes (keys to values) ++ self.parent = None # Our parent unless we are the root element. ++ self.uberclique = None # Allows overriding uberclique for parts of tree ++ self.source = None # File that this node was parsed from ++ ++ # This context handler allows you to write "with node:" and get a ++ # line identifying the offending node if an exception escapes from the body ++ # of the with statement. ++ def __enter__(self): ++ return self ++ ++ def __exit__(self, exc_type, exc_value, traceback): ++ if exc_type is not None: ++ print(u'Error processing node %s: %s' % (six.text_type(self), exc_value)) ++ ++ def __iter__(self): ++ '''A preorder iteration through the tree that this node is the root of.''' ++ return self.Preorder() ++ ++ def Preorder(self): ++ '''Generator that generates first this node, then the same generator for ++ any child nodes.''' ++ yield self ++ for child in self.children: ++ for iterchild in child.Preorder(): ++ yield iterchild ++ ++ def ActiveChildren(self): ++ '''Returns the children of this node that should be included in the current ++ configuration. Overridden by .''' ++ return [node for node in self.children if not node.WhitelistMarkedAsSkip()] ++ ++ def ActiveDescendants(self): ++ '''Yields the current node and all descendants that should be included in ++ the current configuration, in preorder.''' ++ yield self ++ for child in self.ActiveChildren(): ++ for descendant in child.ActiveDescendants(): ++ yield descendant ++ ++ def GetRoot(self): ++ '''Returns the root Node in the tree this Node belongs to.''' ++ curr = self ++ while curr.parent: ++ curr = curr.parent ++ return curr ++ ++ # TODO(joi) Use this (currently untested) optimization?: ++ #if hasattr(self, '_root'): ++ # return self._root ++ #curr = self ++ #while curr.parent and not hasattr(curr, '_root'): ++ # curr = curr.parent ++ #if curr.parent: ++ # self._root = curr._root ++ #else: ++ # self._root = curr ++ #return self._root ++ ++ def StartParsing(self, name, parent): ++ '''Called at the start of parsing. ++ ++ Args: ++ name: u'elementname' ++ parent: grit.node.base.Node or subclass or None ++ ''' ++ assert isinstance(name, six.string_types) ++ assert not parent or isinstance(parent, Node) ++ self.name = name ++ self.parent = parent ++ ++ def AddChild(self, child): ++ '''Adds a child to the list of children of this node, if it is a valid ++ child for the node.''' ++ assert isinstance(child, Node) ++ if (not self._IsValidChild(child) or ++ self._ContentType() == self._CONTENT_TYPE_CDATA): ++ explanation = 'invalid child %s for parent %s' % (str(child), self.name) ++ raise exception.UnexpectedChild(explanation) ++ self.children.append(child) ++ self.mixed_content.append(child) ++ ++ def RemoveChild(self, child_id): ++ '''Removes the first node that has a "name" attribute which ++ matches "child_id" in the list of immediate children of ++ this node. ++ ++ Args: ++ child_id: String identifying the child to be removed ++ ''' ++ index = 0 ++ # Safe not to copy since we only remove the first element found ++ for child in self.children: ++ name_attr = child.attrs['name'] ++ if name_attr == child_id: ++ self.children.pop(index) ++ self.mixed_content.pop(index) ++ break ++ index += 1 ++ ++ def AppendContent(self, content): ++ '''Appends a chunk of text as content of this node. ++ ++ Args: ++ content: u'hello' ++ ++ Return: ++ None ++ ''' ++ assert isinstance(content, six.string_types) ++ if self._ContentType() != self._CONTENT_TYPE_NONE: ++ self.mixed_content.append(content) ++ elif content.strip() != '': ++ raise exception.UnexpectedContent() ++ ++ def HandleAttribute(self, attrib, value): ++ '''Informs the node of an attribute that was parsed out of the GRD file ++ for it. ++ ++ Args: ++ attrib: 'name' ++ value: 'fooblat' ++ ++ Return: ++ None ++ ''' ++ assert isinstance(attrib, six.string_types) ++ assert isinstance(value, six.string_types) ++ if self._IsValidAttribute(attrib, value): ++ self.attrs[attrib] = value ++ else: ++ raise exception.UnexpectedAttribute(attrib) ++ ++ def EndParsing(self): ++ '''Called at the end of parsing.''' ++ ++ # TODO(joi) Rewrite this, it's extremely ugly! ++ if len(self.mixed_content): ++ if isinstance(self.mixed_content[0], six.string_types): ++ # Remove leading and trailing chunks of pure whitespace. ++ while (len(self.mixed_content) and ++ isinstance(self.mixed_content[0], six.string_types) and ++ self.mixed_content[0].strip() == ''): ++ self.mixed_content = self.mixed_content[1:] ++ # Strip leading and trailing whitespace from mixed content chunks ++ # at front and back. ++ if (len(self.mixed_content) and ++ isinstance(self.mixed_content[0], six.string_types)): ++ self.mixed_content[0] = self.mixed_content[0].lstrip() ++ # Remove leading and trailing ''' (used to demarcate whitespace) ++ if (len(self.mixed_content) and ++ isinstance(self.mixed_content[0], six.string_types)): ++ if self.mixed_content[0].startswith("'''"): ++ self.mixed_content[0] = self.mixed_content[0][3:] ++ if len(self.mixed_content): ++ if isinstance(self.mixed_content[-1], six.string_types): ++ # Same stuff all over again for the tail end. ++ while (len(self.mixed_content) and ++ isinstance(self.mixed_content[-1], six.string_types) and ++ self.mixed_content[-1].strip() == ''): ++ self.mixed_content = self.mixed_content[:-1] ++ if (len(self.mixed_content) and ++ isinstance(self.mixed_content[-1], six.string_types)): ++ self.mixed_content[-1] = self.mixed_content[-1].rstrip() ++ if (len(self.mixed_content) and ++ isinstance(self.mixed_content[-1], six.string_types)): ++ if self.mixed_content[-1].endswith("'''"): ++ self.mixed_content[-1] = self.mixed_content[-1][:-3] ++ ++ # Check that all mandatory attributes are there. ++ for node_mandatt in self.MandatoryAttributes(): ++ mandatt_list = [] ++ if node_mandatt.find('|') >= 0: ++ mandatt_list = node_mandatt.split('|') ++ else: ++ mandatt_list.append(node_mandatt) ++ ++ mandatt_option_found = False ++ for mandatt in mandatt_list: ++ assert mandatt not in self.DefaultAttributes() ++ if mandatt in self.attrs: ++ if not mandatt_option_found: ++ mandatt_option_found = True ++ else: ++ raise exception.MutuallyExclusiveMandatoryAttribute(mandatt) ++ ++ if not mandatt_option_found: ++ raise exception.MissingMandatoryAttribute(mandatt) ++ ++ # Add default attributes if not specified in input file. ++ for defattr in self.DefaultAttributes(): ++ if not defattr in self.attrs: ++ self.attrs[defattr] = self.DefaultAttributes()[defattr] ++ ++ def GetCdata(self): ++ '''Returns all CDATA of this element, concatenated into a single ++ string. Note that this ignores any elements embedded in CDATA.''' ++ return ''.join([c for c in self.mixed_content ++ if isinstance(c, six.string_types)]) ++ ++ def __str__(self): ++ '''Returns this node and all nodes below it as an XML document in a Unicode ++ string.''' ++ header = u'\n' ++ return header + self.FormatXml() ++ ++ # Some Python 2 glue. ++ __unicode__ = __str__ ++ ++ def FormatXml(self, indent = u'', one_line = False): ++ '''Returns this node and all nodes below it as an XML ++ element in a Unicode string. This differs from __unicode__ in that it does ++ not include the stuff at the top of the string. If one_line is true, ++ children and CDATA are layed out in a way that preserves internal ++ whitespace. ++ ''' ++ assert isinstance(indent, six.string_types) ++ ++ content_one_line = (one_line or ++ self._ContentType() == self._CONTENT_TYPE_MIXED) ++ inside_content = self.ContentsAsXml(indent, content_one_line) ++ ++ # Then the attributes for this node. ++ attribs = u'' ++ default_attribs = self.DefaultAttributes() ++ for attrib, value in sorted(self.attrs.items()): ++ # Only print an attribute if it is other than the default value. ++ if attrib not in default_attribs or value != default_attribs[attrib]: ++ attribs += u' %s=%s' % (attrib, saxutils.quoteattr(value)) ++ ++ # Finally build the XML for our node and return it ++ if len(inside_content) > 0: ++ if one_line: ++ return u'<%s%s>%s' % (self.name, attribs, inside_content, ++ self.name) ++ elif content_one_line: ++ return u'%s<%s%s>\n%s %s\n%s' % ( ++ indent, self.name, attribs, ++ indent, inside_content, ++ indent, self.name) ++ else: ++ return u'%s<%s%s>\n%s\n%s' % ( ++ indent, self.name, attribs, ++ inside_content, ++ indent, self.name) ++ else: ++ return u'%s<%s%s />' % (indent, self.name, attribs) ++ ++ def ContentsAsXml(self, indent, one_line): ++ '''Returns the contents of this node (CDATA and child elements) in XML ++ format. If 'one_line' is true, the content will be laid out on one line.''' ++ assert isinstance(indent, six.string_types) ++ ++ # Build the contents of the element. ++ inside_parts = [] ++ last_item = None ++ for mixed_item in self.mixed_content: ++ if isinstance(mixed_item, Node): ++ inside_parts.append(mixed_item.FormatXml(indent + u' ', one_line)) ++ if not one_line: ++ inside_parts.append(u'\n') ++ else: ++ message = mixed_item ++ # If this is the first item and it starts with whitespace, we add ++ # the ''' delimiter. ++ if not last_item and message.lstrip() != message: ++ message = u"'''" + message ++ inside_parts.append(util.EncodeCdata(message)) ++ last_item = mixed_item ++ ++ # If there are only child nodes and no cdata, there will be a spurious ++ # trailing \n ++ if len(inside_parts) and inside_parts[-1] == '\n': ++ inside_parts = inside_parts[:-1] ++ ++ # If the last item is a string (not a node) and ends with whitespace, ++ # we need to add the ''' delimiter. ++ if (isinstance(last_item, six.string_types) and ++ last_item.rstrip() != last_item): ++ inside_parts[-1] = inside_parts[-1] + u"'''" ++ ++ return u''.join(inside_parts) ++ ++ def SubstituteMessages(self, substituter): ++ '''Applies substitutions to all messages in the tree. ++ ++ Called as a final step of RunGatherers. ++ ++ Args: ++ substituter: a grit.util.Substituter object. ++ ''' ++ for child in self.children: ++ child.SubstituteMessages(substituter) ++ ++ def _IsValidChild(self, child): ++ '''Returns true if 'child' is a valid child of this node. ++ Overridden by subclasses.''' ++ return False ++ ++ def _IsValidAttribute(self, name, value): ++ '''Returns true if 'name' is the name of a valid attribute of this element ++ and 'value' is a valid value for that attribute. Overriden by ++ subclasses unless they have only mandatory attributes.''' ++ return (name in self.MandatoryAttributes() or ++ name in self.DefaultAttributes()) ++ ++ def _ContentType(self): ++ '''Returns the type of content this element can have. Overridden by ++ subclasses. The content type can be one of the _CONTENT_TYPE_XXX constants ++ above.''' ++ return self._CONTENT_TYPE_NONE ++ ++ def MandatoryAttributes(self): ++ '''Returns a list of attribute names that are mandatory (non-optional) ++ on the current element. One can specify a list of ++ "mutually exclusive mandatory" attributes by specifying them as one ++ element in the list, separated by a "|" character. ++ ''' ++ return [] ++ ++ def DefaultAttributes(self): ++ '''Returns a dictionary of attribute names that have defaults, mapped to ++ the default value. Overridden by subclasses.''' ++ return {} ++ ++ def GetCliques(self): ++ '''Returns all MessageClique objects belonging to this node. Overridden ++ by subclasses. ++ ++ Return: ++ [clique1, clique2] or [] ++ ''' ++ return [] ++ ++ def ToRealPath(self, path_from_basedir): ++ '''Returns a real path (which can be absolute or relative to the current ++ working directory), given a path that is relative to the base directory ++ set for the GRIT input file. ++ ++ Args: ++ path_from_basedir: '..' ++ ++ Return: ++ 'resource' ++ ''' ++ return util.normpath(os.path.join(self.GetRoot().GetBaseDir(), ++ os.path.expandvars(path_from_basedir))) ++ ++ def GetInputPath(self): ++ '''Returns a path, relative to the base directory set for the grd file, ++ that points to the file the node refers to. ++ ''' ++ # This implementation works for most nodes that have an input file. ++ return self.attrs['file'] ++ ++ def UberClique(self): ++ '''Returns the uberclique that should be used for messages originating in ++ a given node. If the node itself has its uberclique set, that is what we ++ use, otherwise we search upwards until we find one. If we do not find one ++ even at the root node, we set the root node's uberclique to a new ++ uberclique instance. ++ ''' ++ node = self ++ while not node.uberclique and node.parent: ++ node = node.parent ++ if not node.uberclique: ++ node.uberclique = clique.UberClique() ++ return node.uberclique ++ ++ def IsTranslateable(self): ++ '''Returns false if the node has contents that should not be translated, ++ otherwise returns false (even if the node has no contents). ++ ''' ++ if not 'translateable' in self.attrs: ++ return True ++ else: ++ return self.attrs['translateable'] == 'true' ++ ++ def IsAccessibilityWithNoUI(self): ++ '''Returns true if the node is marked as an accessibility label and the ++ message isn't shown in the UI. Otherwise returns false. This label is ++ used to determine if the text requires screenshots.''' ++ if not 'is_accessibility_with_no_ui' in self.attrs: ++ return False ++ else: ++ return self.attrs['is_accessibility_with_no_ui'] == 'true' ++ ++ def GetNodeById(self, id): ++ '''Returns the node in the subtree parented by this node that has a 'name' ++ attribute matching 'id'. Returns None if no such node is found. ++ ''' ++ for node in self: ++ if 'name' in node.attrs and node.attrs['name'] == id: ++ return node ++ return None ++ ++ def GetChildrenOfType(self, type): ++ '''Returns a list of all subnodes (recursing to all leaves) of this node ++ that are of the indicated type (or tuple of types). ++ ++ Args: ++ type: A type you could use with isinstance(). ++ ++ Return: ++ A list, possibly empty. ++ ''' ++ return [child for child in self if isinstance(child, type)] ++ ++ def GetTextualIds(self): ++ '''Returns a list of the textual ids of this node. ++ ''' ++ if 'name' in self.attrs: ++ return [self.attrs['name']] ++ return [] ++ ++ @classmethod ++ def EvaluateExpression(cls, expr, defs, target_platform, extra_variables={}): ++ '''Worker for EvaluateCondition (below) and conditions in XTB files.''' ++ if expr in cls.eval_expr_cache: ++ code, variables_in_expr = cls.eval_expr_cache[expr] ++ else: ++ # Get a list of all variable and method names used in the expression. ++ syntax_tree = ast.parse(expr, mode='eval') ++ variables_in_expr = [node.id for node in ast.walk(syntax_tree) if ++ isinstance(node, ast.Name) and node.id not in ('True', 'False')] ++ code = compile(syntax_tree, filename='', mode='eval') ++ cls.eval_expr_cache[expr] = code, variables_in_expr ++ ++ # Set values only for variables that are needed to eval the expression. ++ variable_map = {} ++ for name in variables_in_expr: ++ if name == 'os': ++ value = target_platform ++ elif name == 'defs': ++ value = defs ++ ++ elif name == 'is_linux': ++ value = target_platform.startswith('linux') ++ elif name == 'is_macosx': ++ value = target_platform == 'darwin' ++ elif name == 'is_win': ++ value = target_platform in ('cygwin', 'win32') ++ elif name == 'is_android': ++ value = target_platform == 'android' ++ elif name == 'is_ios': ++ value = target_platform == 'ios' ++ elif name == 'is_bsd': ++ value = 'bsd' in target_platform ++ elif name == 'is_posix': ++ value = (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5', ++ 'android', 'ios') ++ or 'bsd' in target_platform) ++ ++ elif name == 'pp_ifdef': ++ def pp_ifdef(symbol): ++ return symbol in defs ++ value = pp_ifdef ++ elif name == 'pp_if': ++ def pp_if(symbol): ++ return defs.get(symbol, False) ++ value = pp_if ++ ++ elif name in defs: ++ value = defs[name] ++ elif name in extra_variables: ++ value = extra_variables[name] ++ else: ++ # Undefined variables default to False. ++ value = False ++ ++ variable_map[name] = value ++ ++ eval_result = eval(code, {}, variable_map) ++ assert isinstance(eval_result, bool) ++ return eval_result ++ ++ def EvaluateCondition(self, expr): ++ '''Returns true if and only if the Python expression 'expr' evaluates ++ to true. ++ ++ The expression is given a few local variables: ++ - 'lang' is the language currently being output ++ (the 'lang' attribute of the element). ++ - 'context' is the current output context ++ (the 'context' attribute of the element). ++ - 'defs' is a map of C preprocessor-style symbol names to their values. ++ - 'os' is the current platform (likely 'linux2', 'win32' or 'darwin'). ++ - 'pp_ifdef(symbol)' is a shorthand for "symbol in defs". ++ - 'pp_if(symbol)' is a shorthand for "symbol in defs and defs[symbol]". ++ - 'is_linux', 'is_macosx', 'is_win', 'is_posix' are true if 'os' ++ matches the given platform. ++ ''' ++ root = self.GetRoot() ++ lang = getattr(root, 'output_language', '') ++ context = getattr(root, 'output_context', '') ++ defs = getattr(root, 'defines', {}) ++ target_platform = getattr(root, 'target_platform', '') ++ extra_variables = { ++ 'lang': lang, ++ 'context': context, ++ } ++ return Node.EvaluateExpression( ++ expr, defs, target_platform, extra_variables) ++ ++ def OnlyTheseTranslations(self, languages): ++ '''Turns off loading of translations for languages not in the provided list. ++ ++ Attrs: ++ languages: ['fr', 'zh_cn'] ++ ''' ++ for node in self: ++ if (hasattr(node, 'IsTranslation') and ++ node.IsTranslation() and ++ node.GetLang() not in languages): ++ node.DisableLoading() ++ ++ def FindBooleanAttribute(self, attr, default, skip_self): ++ '''Searches all ancestors of the current node for the nearest enclosing ++ definition of the given boolean attribute. ++ ++ Args: ++ attr: 'fallback_to_english' ++ default: What to return if no node defines the attribute. ++ skip_self: Don't check the current node, only its parents. ++ ''' ++ p = self.parent if skip_self else self ++ while p: ++ value = p.attrs.get(attr, 'default').lower() ++ if value != 'default': ++ return (value == 'true') ++ p = p.parent ++ return default ++ ++ def PseudoIsAllowed(self): ++ '''Returns true if this node is allowed to use pseudo-translations. This ++ is true by default, unless this node is within a node that has ++ the allow_pseudo attribute set to false. ++ ''' ++ return self.FindBooleanAttribute('allow_pseudo', ++ default=True, skip_self=True) ++ ++ def ShouldFallbackToEnglish(self): ++ '''Returns true iff this node should fall back to English when ++ pseudotranslations are disabled and no translation is available for a ++ given message. ++ ''' ++ return self.FindBooleanAttribute('fallback_to_english', ++ default=False, skip_self=True) ++ ++ def WhitelistMarkedAsSkip(self): ++ '''Returns true if the node is marked to be skipped in the output by a ++ whitelist. ++ ''' ++ return self._whitelist_marked_as_skip ++ ++ def SetWhitelistMarkedAsSkip(self, mark_skipped): ++ '''Sets WhitelistMarkedAsSkip. ++ ''' ++ self._whitelist_marked_as_skip = mark_skipped ++ ++ def ExpandVariables(self): ++ '''Whether we need to expand variables on a given node.''' ++ return False ++ ++ def IsResourceMapSource(self): ++ '''Whether this node is a resource map source.''' ++ return False ++ ++ def CompressDataIfNeeded(self, data): ++ '''Compress data using the format specified in the compress attribute. ++ ++ Args: ++ data: The data to compressed. ++ Returns: ++ The data in gzipped or brotli compressed format. If the format is ++ unspecified then this returns the data uncompressed. ++ ''' ++ ++ compress = self.attrs.get('compress') ++ ++ # Compress JS, HTML, CSS and SVG files by default (gzip), unless |compress| ++ # is explicitly specified. ++ compress_by_default = (compress == 'default' ++ and self.attrs.get('file').endswith( ++ self._COMPRESS_BY_DEFAULT_EXTENSIONS)) ++ ++ if compress == 'gzip' or compress_by_default: ++ # We only use rsyncable compression on Linux. ++ # We exclude ChromeOS since ChromeOS bots are Linux based but do not have ++ # the --rsyncable option built in for gzip. See crbug.com/617950. ++ if sys.platform == 'linux2' and 'chromeos' not in self.GetRoot().defines: ++ return grit.format.gzip_string.GzipStringRsyncable(data) ++ return grit.format.gzip_string.GzipString(data) ++ ++ if compress == 'brotli': ++ # The length of the uncompressed data as 8 bytes little-endian. ++ size_bytes = struct.pack(" ') ++ ++ ph = message.PhNode() ++ ph.StartParsing(u'ph', None) ++ ph.HandleAttribute(u'name', u'USERNAME') ++ ph.AppendContent(u'$1') ++ ex = message.ExNode() ++ ex.StartParsing(u'ex', None) ++ ex.AppendContent(u'Joi') ++ ex.EndParsing() ++ ph.AddChild(ex) ++ ph.EndParsing() ++ ++ node.AddChild(ph) ++ node.EndParsing() ++ ++ non_indented_xml = node.FormatXml() ++ self.failUnless(non_indented_xml == u'\n Hello ' ++ u'<young> $1Joi' ++ u'\n') ++ ++ indented_xml = node.FormatXml(u' ') ++ self.failUnless(indented_xml == u' \n Hello ' ++ u'<young> $1Joi' ++ u'\n ') ++ ++ def testXmlFormatMixedContentWithLeadingWhitespace(self): ++ # Again test using the Message node type, because it is the only mixed ++ # content node. ++ node = message.MessageNode() ++ node.StartParsing(u'message', None) ++ node.HandleAttribute(u'name', u'name') ++ node.AppendContent(u"''' Hello ") ++ ++ ph = message.PhNode() ++ ph.StartParsing(u'ph', None) ++ ph.HandleAttribute(u'name', u'USERNAME') ++ ph.AppendContent(u'$1') ++ ex = message.ExNode() ++ ex.StartParsing(u'ex', None) ++ ex.AppendContent(u'Joi') ++ ex.EndParsing() ++ ph.AddChild(ex) ++ ph.EndParsing() ++ ++ node.AddChild(ph) ++ node.AppendContent(u" yessiree '''") ++ node.EndParsing() ++ ++ non_indented_xml = node.FormatXml() ++ self.failUnless(non_indented_xml == ++ u"\n ''' Hello" ++ u' <young> $1Joi' ++ u" yessiree '''\n") ++ ++ indented_xml = node.FormatXml(u' ') ++ self.failUnless(indented_xml == ++ u" \n ''' Hello" ++ u' <young> $1Joi' ++ u" yessiree '''\n ") ++ ++ self.failUnless(node.GetNodeById('name')) ++ ++ def testXmlFormatContentWithEntities(self): ++ '''Tests a bug where   would not be escaped correctly.''' ++ from grit import tclib ++ msg_node = message.MessageNode.Construct(None, tclib.Message( ++ text = 'BEGIN_BOLDHelloWHITESPACEthere!END_BOLD Bingo!', ++ placeholders = [ ++ tclib.Placeholder('BEGIN_BOLD', '', 'bla'), ++ tclib.Placeholder('WHITESPACE', ' ', 'bla'), ++ tclib.Placeholder('END_BOLD', '', 'bla')]), ++ 'BINGOBONGO') ++ xml = msg_node.FormatXml() ++ self.failUnless(xml.find(' ') == -1, 'should have no entities') ++ ++ def testIter(self): ++ # First build a little tree of message and ph nodes. ++ node = message.MessageNode() ++ node.StartParsing(u'message', None) ++ node.HandleAttribute(u'name', u'bla') ++ node.AppendContent(u" ''' two spaces ") ++ node.AppendContent(u' space before and after ') ++ ph = message.PhNode() ++ ph.StartParsing(u'ph', None) ++ ph.AddChild(message.ExNode()) ++ ph.HandleAttribute(u'name', u'BINGO') ++ ph.AppendContent(u'bongo') ++ node.AddChild(ph) ++ node.AddChild(message.PhNode()) ++ node.AppendContent(u" space before two after '''") ++ ++ order = [message.MessageNode, message.PhNode, message.ExNode, message.PhNode] ++ for n in node: ++ self.failUnless(type(n) == order[0]) ++ order = order[1:] ++ self.failUnless(len(order) == 0) ++ ++ def testGetChildrenOfType(self): ++ xml = ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Hello! ++ ++ ++ ''' ++ grd = grd_reader.Parse(StringIO(xml), ++ util.PathFromRoot('grit/test/data')) ++ from grit.node import node_io ++ output_nodes = grd.GetChildrenOfType(node_io.OutputNode) ++ self.failUnlessEqual(len(output_nodes), 3) ++ self.failUnlessEqual(output_nodes[2].attrs['filename'], ++ 'de/generated_resources.rc') ++ ++ def testEvaluateExpression(self): ++ def AssertExpr(expected_value, expr, defs, target_platform, ++ extra_variables): ++ self.failUnlessEqual(expected_value, base.Node.EvaluateExpression( ++ expr, defs, target_platform, extra_variables)) ++ ++ AssertExpr(True, "True", {}, 'linux', {}) ++ AssertExpr(False, "False", {}, 'linux', {}) ++ AssertExpr(True, "True or False", {}, 'linux', {}) ++ AssertExpr(False, "True and False", {}, 'linux', {}) ++ AssertExpr(True, "os == 'linux'", {}, 'linux', {}) ++ AssertExpr(False, "os == 'linux'", {}, 'ios', {}) ++ AssertExpr(True, "'foo' in defs", {'foo': 'bar'}, 'ios', {}) ++ AssertExpr(False, "'foo' in defs", {'baz': 'bar'}, 'ios', {}) ++ AssertExpr(False, "'foo' in defs", {}, 'ios', {}) ++ AssertExpr(True, "is_linux", {}, 'linux2', {}) ++ AssertExpr(False, "is_linux", {}, 'win32', {}) ++ AssertExpr(True, "is_macosx", {}, 'darwin', {}) ++ AssertExpr(False, "is_macosx", {}, 'ios', {}) ++ AssertExpr(True, "is_win", {}, 'win32', {}) ++ AssertExpr(False, "is_win", {}, 'darwin', {}) ++ AssertExpr(True, "is_android", {}, 'android', {}) ++ AssertExpr(False, "is_android", {}, 'linux3', {}) ++ AssertExpr(True, "is_ios", {}, 'ios', {}) ++ AssertExpr(False, "is_ios", {}, 'darwin', {}) ++ AssertExpr(True, "is_posix", {}, 'linux2', {}) ++ AssertExpr(True, "is_posix", {}, 'darwin', {}) ++ AssertExpr(True, "is_posix", {}, 'android', {}) ++ AssertExpr(True, "is_posix", {}, 'ios', {}) ++ AssertExpr(True, "is_posix", {}, 'freebsd7', {}) ++ AssertExpr(False, "is_posix", {}, 'win32', {}) ++ AssertExpr(True, "pp_ifdef('foo')", {'foo': True}, 'win32', {}) ++ AssertExpr(True, "pp_ifdef('foo')", {'foo': False}, 'win32', {}) ++ AssertExpr(False, "pp_ifdef('foo')", {'bar': True}, 'win32', {}) ++ AssertExpr(True, "pp_if('foo')", {'foo': True}, 'win32', {}) ++ AssertExpr(False, "pp_if('foo')", {'foo': False}, 'win32', {}) ++ AssertExpr(False, "pp_if('foo')", {'bar': True}, 'win32', {}) ++ AssertExpr(True, "foo", {'foo': True}, 'win32', {}) ++ AssertExpr(False, "foo", {'foo': False}, 'win32', {}) ++ AssertExpr(False, "foo", {'bar': True}, 'win32', {}) ++ AssertExpr(True, "foo == 'baz'", {'foo': 'baz'}, 'win32', {}) ++ AssertExpr(False, "foo == 'baz'", {'foo': True}, 'win32', {}) ++ AssertExpr(False, "foo == 'baz'", {}, 'win32', {}) ++ AssertExpr(True, "lang == 'de'", {}, 'win32', {'lang': 'de'}) ++ AssertExpr(False, "lang == 'de'", {}, 'win32', {'lang': 'fr'}) ++ AssertExpr(False, "lang == 'de'", {}, 'win32', {}) ++ ++ # Test a couple more complex expressions for good measure. ++ AssertExpr(True, "is_ios and (lang in ['de', 'fr'] or foo)", ++ {'foo': 'bar'}, 'ios', {'lang': 'fr', 'context': 'today'}) ++ AssertExpr(False, "is_ios and (lang in ['de', 'fr'] or foo)", ++ {'foo': False}, 'linux2', {'lang': 'fr', 'context': 'today'}) ++ AssertExpr(False, "is_ios and (lang in ['de', 'fr'] or foo)", ++ {'baz': 'bar'}, 'ios', {'lang': 'he', 'context': 'today'}) ++ AssertExpr(True, "foo == 'bar' or not baz", ++ {'foo': 'bar', 'fun': True}, 'ios', {'lang': 'en'}) ++ AssertExpr(True, "foo == 'bar' or not baz", ++ {}, 'ios', {'lang': 'en', 'context': 'java'}) ++ AssertExpr(False, "foo == 'bar' or not baz", ++ {'foo': 'ruz', 'baz': True}, 'ios', {'lang': 'en'}) ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/brotli_util.py b/tools/grit/grit/node/brotli_util.py +new file mode 100644 +index 0000000000..77f70e49d5 +--- /dev/null ++++ b/tools/grit/grit/node/brotli_util.py +@@ -0,0 +1,29 @@ ++# Copyright 2019 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Framework for compressing resources using Brotli.""" ++ ++import subprocess ++ ++__brotli_executable = None ++ ++ ++def SetBrotliCommand(brotli): ++ # brotli is a list. In production it contains the path to the Brotli executable. ++ # During testing it contains [python, mock_brotli.py] for testing on Windows. ++ global __brotli_executable ++ __brotli_executable = brotli ++ ++ ++def BrotliCompress(data): ++ if not __brotli_executable: ++ raise Exception('Add "use_brotli = true" to you GN grit(...) target ' + ++ 'if you want to use brotli.') ++ compress = subprocess.Popen(__brotli_executable + ['-', '-f'], ++ stdin=subprocess.PIPE, stdout=subprocess.PIPE) ++ return compress.communicate(data)[0] ++ ++def IsInitialized(): ++ global __brotli_executable ++ return __brotli_executable is not None +diff --git a/tools/grit/grit/node/custom/__init__.py b/tools/grit/grit/node/custom/__init__.py +new file mode 100644 +index 0000000000..e179cf7730 +--- /dev/null ++++ b/tools/grit/grit/node/custom/__init__.py +@@ -0,0 +1,8 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Package 'grit.node.custom' ++''' ++ ++pass +diff --git a/tools/grit/grit/node/custom/filename.py b/tools/grit/grit/node/custom/filename.py +new file mode 100644 +index 0000000000..55a27e58c1 +--- /dev/null ++++ b/tools/grit/grit/node/custom/filename.py +@@ -0,0 +1,29 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''A CustomType for filenames.''' ++ ++from __future__ import print_function ++ ++from grit import clique ++from grit import lazy_re ++ ++ ++class WindowsFilename(clique.CustomType): ++ '''Validates that messages can be used as Windows filenames, and strips ++ illegal characters out of translations. ++ ''' ++ ++ BANNED = lazy_re.compile(r'\+|:|\/|\\\\|\*|\?|\"|\<|\>|\|') ++ ++ def Validate(self, message): ++ return not self.BANNED.search(message.GetPresentableContent()) ++ ++ def ValidateAndModify(self, lang, translation): ++ is_ok = self.Validate(translation) ++ self.ModifyEachTextPart(lang, translation) ++ return is_ok ++ ++ def ModifyTextPart(self, lang, text): ++ return self.BANNED.sub(' ', text) +diff --git a/tools/grit/grit/node/custom/filename_unittest.py b/tools/grit/grit/node/custom/filename_unittest.py +new file mode 100644 +index 0000000000..8e2a6dd64a +--- /dev/null ++++ b/tools/grit/grit/node/custom/filename_unittest.py +@@ -0,0 +1,34 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.node.custom.filename''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../../..')) ++ ++import unittest ++from grit.node.custom import filename ++from grit import clique ++from grit import tclib ++ ++ ++class WindowsFilenameUnittest(unittest.TestCase): ++ ++ def testValidate(self): ++ factory = clique.UberClique() ++ msg = tclib.Message(text='Bingo bongo') ++ c = factory.MakeClique(msg) ++ c.SetCustomType(filename.WindowsFilename()) ++ translation = tclib.Translation(id=msg.GetId(), text='Bilingo bolongo:') ++ c.AddTranslation(translation, 'fr') ++ self.failUnless(c.MessageForLanguage('fr').GetRealContent() == 'Bilingo bolongo ') ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/empty.py b/tools/grit/grit/node/empty.py +new file mode 100644 +index 0000000000..e19d2c4ddb +--- /dev/null ++++ b/tools/grit/grit/node/empty.py +@@ -0,0 +1,64 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Container nodes that don't have any logic. ++''' ++ ++from __future__ import print_function ++ ++from grit.node import base ++from grit.node import include ++from grit.node import message ++from grit.node import misc ++from grit.node import node_io ++from grit.node import structure ++ ++ ++class GroupingNode(base.Node): ++ '''Base class for all the grouping elements (, , ++ and ).''' ++ def DefaultAttributes(self): ++ return { ++ 'first_id' : '', ++ 'comment' : '', ++ 'fallback_to_english' : 'false', ++ 'fallback_to_low_resolution' : 'false', ++ } ++ ++ ++class IncludesNode(GroupingNode): ++ '''The element.''' ++ def _IsValidChild(self, child): ++ return isinstance(child, (include.IncludeNode, misc.IfNode, misc.PartNode)) ++ ++ ++class MessagesNode(GroupingNode): ++ '''The element.''' ++ def _IsValidChild(self, child): ++ return isinstance(child, (message.MessageNode, misc.IfNode, misc.PartNode)) ++ ++ ++class StructuresNode(GroupingNode): ++ '''The element.''' ++ def _IsValidChild(self, child): ++ return isinstance(child, (structure.StructureNode, ++ misc.IfNode, misc.PartNode)) ++ ++ ++class TranslationsNode(base.Node): ++ '''The element.''' ++ def _IsValidChild(self, child): ++ return isinstance(child, (node_io.FileNode, misc.IfNode, misc.PartNode)) ++ ++ ++class OutputsNode(base.Node): ++ '''The element.''' ++ def _IsValidChild(self, child): ++ return isinstance(child, (node_io.OutputNode, misc.IfNode, misc.PartNode)) ++ ++ ++class IdentifiersNode(GroupingNode): ++ '''The element.''' ++ def _IsValidChild(self, child): ++ return isinstance(child, misc.IdentifierNode) +diff --git a/tools/grit/grit/node/include.py b/tools/grit/grit/node/include.py +new file mode 100644 +index 0000000000..b06b9889bb +--- /dev/null ++++ b/tools/grit/grit/node/include.py +@@ -0,0 +1,170 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Handling of the element. ++""" ++ ++from __future__ import print_function ++ ++import os ++ ++from grit import util ++import grit.format.html_inline ++import grit.format.rc ++from grit.format import minifier ++from grit.node import base ++ ++class IncludeNode(base.Node): ++ """An element.""" ++ ++ def __init__(self): ++ super(IncludeNode, self).__init__() ++ ++ # Cache flattened data so that we don't flatten the same file ++ # multiple times. ++ self._flattened_data = None ++ # Also keep track of the last filename we flattened to, so we can ++ # avoid doing it more than once. ++ self._last_flat_filename = None ++ ++ def _IsValidChild(self, child): ++ return False ++ ++ def _GetFlattenedData( ++ self, allow_external_script=False, preprocess_only=False): ++ if not self._flattened_data: ++ filename = self.ToRealPath(self.GetInputPath()) ++ self._flattened_data = ( ++ grit.format.html_inline.InlineToString(filename, self, ++ preprocess_only=preprocess_only, ++ allow_external_script=allow_external_script)) ++ return self._flattened_data.encode('utf-8') ++ ++ def MandatoryAttributes(self): ++ return ['name', 'type', 'file'] ++ ++ def DefaultAttributes(self): ++ """Attributes: ++ translateable: False if the node has contents that should not be ++ translated. ++ preprocess: Takes the same code path as flattenhtml, but it ++ disables any processing/inlining outside of ++ and . ++ compress: The format to compress the data with, e.g. 'gzip' ++ or 'false' if data should not be compressed. ++ skip_minify: If true, skips minifying the node's contents. ++ skip_in_resource_map: If true, do not add to the resource map. ++ """ ++ return { ++ 'translateable': 'true', ++ 'generateid': 'true', ++ 'filenameonly': 'false', ++ 'mkoutput': 'false', ++ 'preprocess': 'false', ++ 'flattenhtml': 'false', ++ 'compress': 'default', ++ 'allowexternalscript': 'false', ++ 'relativepath': 'false', ++ 'use_base_dir': 'true', ++ 'skip_minify': 'false', ++ 'skip_in_resource_map': 'false', ++ } ++ ++ def GetInputPath(self): ++ # Do not mess with absolute paths, that would make them invalid. ++ if os.path.isabs(os.path.expandvars(self.attrs['file'])): ++ return self.attrs['file'] ++ ++ # We have no control over code that calls ToRealPath later, so convert ++ # the path to be relative against our basedir. ++ if self.attrs.get('use_base_dir', 'true') != 'true': ++ # Normalize the directory path to use the appropriate OS separator. ++ # GetBaseDir() may return paths\like\this or paths/like/this, since it is ++ # read from the base_dir attribute in the grd file. ++ norm_base_dir = util.normpath(self.GetRoot().GetBaseDir()) ++ return os.path.relpath(self.attrs['file'], norm_base_dir) ++ ++ return self.attrs['file'] ++ ++ def FileForLanguage(self, lang, output_dir): ++ """Returns the file for the specified language. This allows us to return ++ different files for different language variants of the include file. ++ """ ++ input_path = self.GetInputPath() ++ if input_path is None: ++ return None ++ ++ return self.ToRealPath(input_path) ++ ++ def GetDataPackValue(self, lang, encoding): ++ '''Returns bytes or a str represenation for a data_pack entry.''' ++ filename = self.ToRealPath(self.GetInputPath()) ++ if self.attrs['flattenhtml'] == 'true': ++ allow_external_script = self.attrs['allowexternalscript'] == 'true' ++ data = self._GetFlattenedData(allow_external_script=allow_external_script) ++ elif self.attrs['preprocess'] == 'true': ++ data = self._GetFlattenedData(preprocess_only=True) ++ else: ++ data = util.ReadFile(filename, util.BINARY) ++ ++ if self.attrs['skip_minify'] != 'true': ++ # Note that the minifier will only do anything if a minifier command ++ # has been set in the command line. ++ data = minifier.Minify(data, filename) ++ ++ # Include does not care about the encoding, because it only returns binary ++ # data. ++ return self.CompressDataIfNeeded(data) ++ ++ def Process(self, output_dir): ++ """Rewrite file references to be base64 encoded data URLs. The new file ++ will be written to output_dir and the name of the new file is returned.""" ++ filename = self.ToRealPath(self.GetInputPath()) ++ flat_filename = os.path.join(output_dir, ++ self.attrs['name'] + '_' + os.path.basename(filename)) ++ ++ if self._last_flat_filename == flat_filename: ++ return ++ ++ with open(flat_filename, 'wb') as outfile: ++ outfile.write(self._GetFlattenedData()) ++ ++ self._last_flat_filename = flat_filename ++ return os.path.basename(flat_filename) ++ ++ def GetHtmlResourceFilenames(self): ++ """Returns a set of all filenames inlined by this file.""" ++ allow_external_script = self.attrs['allowexternalscript'] == 'true' ++ return grit.format.html_inline.GetResourceFilenames( ++ self.ToRealPath(self.GetInputPath()), ++ self, ++ allow_external_script=allow_external_script) ++ ++ def IsResourceMapSource(self): ++ skip = self.attrs.get('skip_in_resource_map', 'false') == 'true' ++ return not skip ++ ++ @staticmethod ++ def Construct(parent, name, type, file, translateable=True, ++ filenameonly=False, mkoutput=False, relativepath=False): ++ """Creates a new node which is a child of 'parent', with attributes set ++ by parameters of the same name. ++ """ ++ # Convert types to appropriate strings ++ translateable = util.BoolToString(translateable) ++ filenameonly = util.BoolToString(filenameonly) ++ mkoutput = util.BoolToString(mkoutput) ++ relativepath = util.BoolToString(relativepath) ++ ++ node = IncludeNode() ++ node.StartParsing('include', parent) ++ node.HandleAttribute('name', name) ++ node.HandleAttribute('type', type) ++ node.HandleAttribute('file', file) ++ node.HandleAttribute('translateable', translateable) ++ node.HandleAttribute('filenameonly', filenameonly) ++ node.HandleAttribute('mkoutput', mkoutput) ++ node.HandleAttribute('relativepath', relativepath) ++ node.EndParsing() ++ return node +diff --git a/tools/grit/grit/node/include_unittest.py b/tools/grit/grit/node/include_unittest.py +new file mode 100644 +index 0000000000..4c658f1ffe +--- /dev/null ++++ b/tools/grit/grit/node/include_unittest.py +@@ -0,0 +1,134 @@ ++#!/usr/bin/env python ++# Copyright (c) 2013 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for include.IncludeNode''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++import unittest ++import zlib ++ ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++from grit.node import misc ++from grit.node import include ++from grit.node import empty ++from grit import util ++ ++ ++def checkIsGzipped(filename, compress_attr): ++ test_data_root = util.PathFromRoot('grit/testdata') ++ root = util.ParseGrdForUnittest( ++ ''' ++ ++ ++ ''' % (filename, compress_attr), ++ base_dir=test_data_root) ++ node, = root.GetChildrenOfType(include.IncludeNode) ++ compressed = node.GetDataPackValue(lang='en', encoding=util.BINARY) ++ ++ decompressed_data = zlib.decompress(compressed, 16 + zlib.MAX_WBITS) ++ expected = util.ReadFile(os.path.join(test_data_root, filename), util.BINARY) ++ return expected == decompressed_data ++ ++ ++class IncludeNodeUnittest(unittest.TestCase): ++ def testGetPath(self): ++ root = misc.GritNode() ++ root.StartParsing(u'grit', None) ++ root.HandleAttribute(u'latest_public_release', u'0') ++ root.HandleAttribute(u'current_release', u'1') ++ root.HandleAttribute(u'base_dir', r'..\resource') ++ release = misc.ReleaseNode() ++ release.StartParsing(u'release', root) ++ release.HandleAttribute(u'seq', u'1') ++ root.AddChild(release) ++ includes = empty.IncludesNode() ++ includes.StartParsing(u'includes', release) ++ release.AddChild(includes) ++ include_node = include.IncludeNode() ++ include_node.StartParsing(u'include', includes) ++ include_node.HandleAttribute(u'file', r'flugel\kugel.pdf') ++ includes.AddChild(include_node) ++ root.EndParsing() ++ ++ self.assertEqual(root.ToRealPath(include_node.GetInputPath()), ++ util.normpath( ++ os.path.join(r'../resource', r'flugel/kugel.pdf'))) ++ ++ def testGetPathNoBasedir(self): ++ root = misc.GritNode() ++ root.StartParsing(u'grit', None) ++ root.HandleAttribute(u'latest_public_release', u'0') ++ root.HandleAttribute(u'current_release', u'1') ++ root.HandleAttribute(u'base_dir', r'..\resource') ++ release = misc.ReleaseNode() ++ release.StartParsing(u'release', root) ++ release.HandleAttribute(u'seq', u'1') ++ root.AddChild(release) ++ includes = empty.IncludesNode() ++ includes.StartParsing(u'includes', release) ++ release.AddChild(includes) ++ include_node = include.IncludeNode() ++ include_node.StartParsing(u'include', includes) ++ include_node.HandleAttribute(u'file', r'flugel\kugel.pdf') ++ include_node.HandleAttribute(u'use_base_dir', u'false') ++ includes.AddChild(include_node) ++ root.EndParsing() ++ ++ last_dir = os.path.basename(os.getcwd()) ++ expected_path = util.normpath(os.path.join( ++ u'..', last_dir, u'flugel/kugel.pdf')) ++ self.assertEqual(root.ToRealPath(include_node.GetInputPath()), ++ expected_path) ++ ++ def testCompressGzip(self): ++ self.assertTrue(checkIsGzipped('test_text.txt', 'compress="gzip"')) ++ ++ def testCompressGzipByDefault(self): ++ self.assertTrue(checkIsGzipped('test_html.html', '')) ++ self.assertTrue(checkIsGzipped('test_js.js', '')) ++ self.assertTrue(checkIsGzipped('test_css.css', '')) ++ self.assertTrue(checkIsGzipped('test_svg.svg', '')) ++ ++ self.assertTrue(checkIsGzipped('test_html.html', 'compress="default"')) ++ self.assertTrue(checkIsGzipped('test_js.js', 'compress="default"')) ++ self.assertTrue(checkIsGzipped('test_css.css', 'compress="default"')) ++ self.assertTrue(checkIsGzipped('test_svg.svg', 'compress="default"')) ++ ++ def testSkipInResourceMap(self): ++ root = util.ParseGrdForUnittest(''' ++ ++ ++ ++ ++ ''', base_dir = util.PathFromRoot('grit/testdata')) ++ inc = root.GetChildrenOfType(include.IncludeNode) ++ self.assertTrue(inc[0].IsResourceMapSource()) ++ self.assertFalse(inc[1].IsResourceMapSource()) ++ self.assertTrue(inc[2].IsResourceMapSource()) ++ ++ def testAcceptsPreprocess(self): ++ root = util.ParseGrdForUnittest( ++ ''' ++ ++ ++ ''', ++ base_dir=util.PathFromRoot('grit/testdata')) ++ inc, = root.GetChildrenOfType(include.IncludeNode) ++ result = inc.GetDataPackValue(lang='en', encoding=util.BINARY) ++ self.assertIn(b'should be kept', result) ++ self.assertIn(b'in the middle...', result) ++ self.assertNotIn(b'should be removed', result) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/mapping.py b/tools/grit/grit/node/mapping.py +new file mode 100644 +index 0000000000..6297f0b666 +--- /dev/null ++++ b/tools/grit/grit/node/mapping.py +@@ -0,0 +1,60 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Maps each node type to an implementation class. ++When adding a new node type, you add to this mapping. ++''' ++ ++from __future__ import print_function ++ ++from grit import exception ++ ++from grit.node import empty ++from grit.node import include ++from grit.node import message ++from grit.node import misc ++from grit.node import node_io ++from grit.node import structure ++from grit.node import variant ++ ++ ++_ELEMENT_TO_CLASS = { ++ 'identifiers' : empty.IdentifiersNode, ++ 'includes' : empty.IncludesNode, ++ 'messages' : empty.MessagesNode, ++ 'outputs' : empty.OutputsNode, ++ 'structures' : empty.StructuresNode, ++ 'translations' : empty.TranslationsNode, ++ 'include' : include.IncludeNode, ++ 'emit' : node_io.EmitNode, ++ 'file' : node_io.FileNode, ++ 'output' : node_io.OutputNode, ++ 'ex' : message.ExNode, ++ 'message' : message.MessageNode, ++ 'ph' : message.PhNode, ++ 'else' : misc.ElseNode, ++ 'grit' : misc.GritNode, ++ 'identifier' : misc.IdentifierNode, ++ 'if' : misc.IfNode, ++ 'part' : misc.PartNode, ++ 'release' : misc.ReleaseNode, ++ 'then' : misc.ThenNode, ++ 'structure' : structure.StructureNode, ++ 'skeleton' : variant.SkeletonNode, ++} ++ ++ ++def ElementToClass(name, typeattr): ++ '''Maps an element to a class that handles the element. ++ ++ Args: ++ name: 'element' (the name of the element) ++ typeattr: 'type' (the value of the type attribute, if present, else None) ++ ++ Return: ++ type ++ ''' ++ if name not in _ELEMENT_TO_CLASS: ++ raise exception.UnknownElement() ++ return _ELEMENT_TO_CLASS[name] +diff --git a/tools/grit/grit/node/message.py b/tools/grit/grit/node/message.py +new file mode 100644 +index 0000000000..4fa83cf26b +--- /dev/null ++++ b/tools/grit/grit/node/message.py +@@ -0,0 +1,362 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Handling of the element. ++''' ++ ++from __future__ import print_function ++ ++import re ++ ++import six ++ ++from grit.node import base ++ ++from grit import clique ++from grit import exception ++from grit import lazy_re ++from grit import tclib ++from grit import util ++ ++ ++# Matches exactly three dots ending a line or followed by whitespace. ++_ELLIPSIS_PATTERN = lazy_re.compile(r'(?\s*)(?P.+?)(?P\s*)\Z', ++ re.DOTALL | re.MULTILINE) ++ ++# placeholder elements should contain the special character formatters ++# used to format element content. ++# Android format. ++_ANDROID_FORMAT = (r'%[1-9]+\$' ++ r'([-#+ 0,(]*)([0-9]+)?(\.[0-9]+)?' ++ r'([bBhHsScCdoxXeEfgGaAtT%n])') ++# Chrome l10n format. ++_CHROME_FORMAT = r'\$+\d' ++# Windows EWT numeric and GRIT %s %d formats. ++_OTHER_FORMAT = r'%[0-9sd]' ++ ++# Finds formatters that must be in a placeholder () element. ++_FORMATTERS = lazy_re.compile( ++ '(%s)|(%s)|(%s)' % (_ANDROID_FORMAT, _CHROME_FORMAT, _OTHER_FORMAT)) ++_BAD_PLACEHOLDER_MSG = ('ERROR: Placeholder formatter found outside of ' ++ 'tag in message "%s" in %s.') ++_INVALID_PH_CHAR_MSG = ('ERROR: Invalid format characters found in message ' ++ '"%s" tag in %s.') ++ ++# Finds HTML tag tokens. ++_HTMLTOKEN = lazy_re.compile(r'<[/]?[a-z][a-z0-9]*[^>]*>', re.I) ++ ++# Finds HTML entities. ++_HTMLENTITY = lazy_re.compile(r'&[^\s]*;') ++ ++ ++class MessageNode(base.ContentNode): ++ '''A element.''' ++ ++ # For splitting a list of things that can be separated by commas or ++ # whitespace ++ _SPLIT_RE = lazy_re.compile(r'\s*,\s*|\s+') ++ ++ def __init__(self): ++ super(MessageNode, self).__init__() ++ # Valid after EndParsing, this is the MessageClique that contains the ++ # source message and any translations of it that have been loaded. ++ self.clique = None ++ ++ # We don't send leading and trailing whitespace into the translation ++ # console, but rather tack it onto the source message and any ++ # translations when formatting them into RC files or what have you. ++ self.ws_at_start = '' # Any whitespace characters at the start of the text ++ self.ws_at_end = '' # --"-- at the end of the text ++ ++ # A list of "shortcut groups" this message is in. We check to make sure ++ # that shortcut keys (e.g. &J) within each shortcut group are unique. ++ self.shortcut_groups_ = [] ++ ++ # Formatter-specific data used to control the output of individual strings. ++ # formatter_data is a space separated list of C preprocessor-style ++ # definitions. Names without values are given the empty string value. ++ # Example: "foo=5 bar baz=100" ++ self.formatter_data = {} ++ ++ # Whether or not to convert ... -> U+2026 within Translate(). ++ self._replace_ellipsis = False ++ ++ def _IsValidChild(self, child): ++ return isinstance(child, (PhNode)) ++ ++ def _IsValidAttribute(self, name, value): ++ if name not in [ ++ 'name', 'offset', 'translateable', 'desc', 'meaning', ++ 'internal_comment', 'shortcut_groups', 'custom_type', 'validation_expr', ++ 'use_name_for_id', 'sub_variable', 'formatter_data', ++ 'is_accessibility_with_no_ui' ++ ]: ++ return False ++ if (name in ('translateable', 'sub_variable') and ++ value not in ['true', 'false']): ++ return False ++ return True ++ ++ def SetReplaceEllipsis(self, value): ++ r'''Sets whether to replace ... with \u2026. ++ ''' ++ self._replace_ellipsis = value ++ ++ def MandatoryAttributes(self): ++ return ['name|offset'] ++ ++ def DefaultAttributes(self): ++ return { ++ 'custom_type': '', ++ 'desc': '', ++ 'formatter_data': '', ++ 'internal_comment': '', ++ 'is_accessibility_with_no_ui': 'false', ++ 'meaning': '', ++ 'shortcut_groups': '', ++ 'sub_variable': 'false', ++ 'translateable': 'true', ++ 'use_name_for_id': 'false', ++ 'validation_expr': '', ++ } ++ ++ def HandleAttribute(self, attrib, value): ++ base.ContentNode.HandleAttribute(self, attrib, value) ++ if attrib != 'formatter_data': ++ return ++ ++ # Parse value, a space-separated list of defines, into a dict. ++ # Example: "foo=5 bar" -> {'foo':'5', 'bar':''} ++ for item in value.split(): ++ name, _, val = item.partition('=') ++ self.formatter_data[name] = val ++ ++ def GetTextualIds(self): ++ ''' ++ Returns the concatenation of the parent's node first_id and ++ this node's offset if it has one, otherwise just call the ++ superclass' implementation ++ ''' ++ if 'offset' not in self.attrs: ++ return super(MessageNode, self).GetTextualIds() ++ ++ # we search for the first grouping node in the parents' list ++ # to take care of the case where the first parent is an node ++ grouping_parent = self.parent ++ import grit.node.empty ++ while grouping_parent and not isinstance(grouping_parent, ++ grit.node.empty.GroupingNode): ++ grouping_parent = grouping_parent.parent ++ ++ assert 'first_id' in grouping_parent.attrs ++ return [grouping_parent.attrs['first_id'] + '_' + self.attrs['offset']] ++ ++ def IsTranslateable(self): ++ return self.attrs['translateable'] == 'true' ++ ++ def EndParsing(self): ++ super(MessageNode, self).EndParsing() ++ ++ # Make the text (including placeholder references) and list of placeholders, ++ # verify placeholder formats, then strip and store leading and trailing ++ # whitespace and create the tclib.Message() and a clique to contain it. ++ ++ text = '' ++ placeholders = [] ++ ++ for item in self.mixed_content: ++ if isinstance(item, six.string_types): ++ # Not a element: fail if any formatters are detected. ++ if _FORMATTERS.search(item): ++ print(_BAD_PLACEHOLDER_MSG % (item, self.source)) ++ raise exception.PlaceholderNotInsidePhNode ++ text += item ++ else: ++ # Extract the element components. ++ presentation = item.attrs['name'].upper() ++ text += presentation ++ ex = ' ' # example element cdata if present. ++ if len(item.children): ++ ex = item.children[0].GetCdata() ++ original = item.GetCdata() ++ ++ # Sanity check the element content. ++ cdata = original ++ # Replace all HTML tag tokens in cdata. ++ match = _HTMLTOKEN.search(cdata) ++ while match: ++ cdata = cdata.replace(match.group(0), '_') ++ match = _HTMLTOKEN.search(cdata) ++ # Replace all HTML entities in cdata. ++ match = _HTMLENTITY.search(cdata) ++ while match: ++ cdata = cdata.replace(match.group(0), '_') ++ match = _HTMLENTITY.search(cdata) ++ # Remove first matching formatter from cdata. ++ match = _FORMATTERS.search(cdata) ++ if match: ++ cdata = cdata.replace(match.group(0), '') ++ # Fail if special chars remain in cdata. ++ if re.search(r'[%\$]', cdata): ++ message_id = self.attrs['name'] + ' ' + original; ++ print(_INVALID_PH_CHAR_MSG % (message_id, self.source)) ++ raise exception.InvalidCharactersInsidePhNode ++ ++ # Otherwise, accept this placeholder. ++ placeholders.append(tclib.Placeholder(presentation, original, ex)) ++ ++ m = _WHITESPACE.match(text) ++ if m: ++ self.ws_at_start = m.group('start') ++ self.ws_at_end = m.group('end') ++ text = m.group('body') ++ ++ self.shortcut_groups_ = self._SPLIT_RE.split(self.attrs['shortcut_groups']) ++ self.shortcut_groups_ = [i for i in self.shortcut_groups_ if i != ''] ++ ++ description_or_id = self.attrs['desc'] ++ if description_or_id == '' and 'name' in self.attrs: ++ description_or_id = 'ID: %s' % self.attrs['name'] ++ ++ assigned_id = None ++ if self.attrs['use_name_for_id'] == 'true': ++ assigned_id = self.attrs['name'] ++ message = tclib.Message(text=text, placeholders=placeholders, ++ description=description_or_id, ++ meaning=self.attrs['meaning'], ++ assigned_id=assigned_id) ++ self.InstallMessage(message) ++ ++ def InstallMessage(self, message): ++ '''Sets this node's clique from a tclib.Message instance. ++ ++ Args: ++ message: A tclib.Message. ++ ''' ++ self.clique = self.UberClique().MakeClique(message, self.IsTranslateable()) ++ for group in self.shortcut_groups_: ++ self.clique.AddToShortcutGroup(group) ++ if self.attrs['custom_type'] != '': ++ self.clique.SetCustomType(util.NewClassInstance(self.attrs['custom_type'], ++ clique.CustomType)) ++ elif self.attrs['validation_expr'] != '': ++ self.clique.SetCustomType( ++ clique.OneOffCustomType(self.attrs['validation_expr'])) ++ ++ def SubstituteMessages(self, substituter): ++ '''Applies substitution to this message. ++ ++ Args: ++ substituter: a grit.util.Substituter object. ++ ''' ++ message = substituter.SubstituteMessage(self.clique.GetMessage()) ++ if message is not self.clique.GetMessage(): ++ self.InstallMessage(message) ++ ++ def GetCliques(self): ++ return [self.clique] if self.clique else [] ++ ++ def Translate(self, lang): ++ '''Returns a translated version of this message. ++ ''' ++ assert self.clique ++ msg = self.clique.MessageForLanguage(lang, ++ self.PseudoIsAllowed(), ++ self.ShouldFallbackToEnglish() ++ ).GetRealContent() ++ if self._replace_ellipsis: ++ msg = _ELLIPSIS_PATTERN.sub(_ELLIPSIS_SYMBOL, msg) ++ # Always remove all byte order marks (\uFEFF) https://crbug.com/1033305 ++ msg = msg.replace(u'\uFEFF','') ++ return msg.replace('[GRITLANGCODE]', lang) ++ ++ def NameOrOffset(self): ++ key = 'name' if 'name' in self.attrs else 'offset' ++ return self.attrs[key] ++ ++ def ExpandVariables(self): ++ '''We always expand variables on Messages.''' ++ return True ++ ++ def GetDataPackValue(self, lang, encoding): ++ '''Returns a str represenation for a data_pack entry.''' ++ message = self.ws_at_start + self.Translate(lang) + self.ws_at_end ++ return util.Encode(message, encoding) ++ ++ def IsResourceMapSource(self): ++ return True ++ ++ @staticmethod ++ def Construct(parent, message, name, desc='', meaning='', translateable=True): ++ '''Constructs a new message node that is a child of 'parent', with the ++ name, desc, meaning and translateable attributes set using the same-named ++ parameters and the text of the message and any placeholders taken from ++ 'message', which must be a tclib.Message() object.''' ++ # Convert type to appropriate string ++ translateable = 'true' if translateable else 'false' ++ ++ node = MessageNode() ++ node.StartParsing('message', parent) ++ node.HandleAttribute('name', name) ++ node.HandleAttribute('desc', desc) ++ node.HandleAttribute('meaning', meaning) ++ node.HandleAttribute('translateable', translateable) ++ ++ items = message.GetContent() ++ for ix, item in enumerate(items): ++ if isinstance(item, six.string_types): ++ # Ensure whitespace at front and back of message is correctly handled. ++ if ix == 0: ++ item = "'''" + item ++ if ix == len(items) - 1: ++ item = item + "'''" ++ ++ node.AppendContent(item) ++ else: ++ phnode = PhNode() ++ phnode.StartParsing('ph', node) ++ phnode.HandleAttribute('name', item.GetPresentation()) ++ phnode.AppendContent(item.GetOriginal()) ++ ++ if len(item.GetExample()) and item.GetExample() != ' ': ++ exnode = ExNode() ++ exnode.StartParsing('ex', phnode) ++ exnode.AppendContent(item.GetExample()) ++ exnode.EndParsing() ++ phnode.AddChild(exnode) ++ ++ phnode.EndParsing() ++ node.AddChild(phnode) ++ ++ node.EndParsing() ++ return node ++ ++ ++class PhNode(base.ContentNode): ++ '''A element.''' ++ ++ def _IsValidChild(self, child): ++ return isinstance(child, ExNode) ++ ++ def MandatoryAttributes(self): ++ return ['name'] ++ ++ def EndParsing(self): ++ super(PhNode, self).EndParsing() ++ # We only allow a single example for each placeholder ++ if len(self.children) > 1: ++ raise exception.TooManyExamples() ++ ++ def GetTextualIds(self): ++ # The 'name' attribute is not an ID. ++ return [] ++ ++ ++class ExNode(base.ContentNode): ++ '''An element.''' ++ pass +diff --git a/tools/grit/grit/node/message_unittest.py b/tools/grit/grit/node/message_unittest.py +new file mode 100644 +index 0000000000..7a4cbbedc2 +--- /dev/null ++++ b/tools/grit/grit/node/message_unittest.py +@@ -0,0 +1,380 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.node.message''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++import unittest ++ ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++from grit import exception ++from grit import tclib ++from grit import util ++from grit.node import message ++ ++class MessageUnittest(unittest.TestCase): ++ def testMessage(self): ++ root = util.ParseGrdForUnittest(''' ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ ''') ++ msg, = root.GetChildrenOfType(message.MessageNode) ++ cliques = msg.GetCliques() ++ content = cliques[0].GetMessage().GetPresentableContent() ++ self.failUnless(content == 'Hello USERNAME, how are you doing today?') ++ ++ def testMessageWithWhitespace(self): ++ root = util.ParseGrdForUnittest("""\ ++ ++ ++ ''' Hello there %s ''' ++ ++ """) ++ msg, = root.GetChildrenOfType(message.MessageNode) ++ content = msg.GetCliques()[0].GetMessage().GetPresentableContent() ++ self.failUnless(content == 'Hello there USERNAME') ++ self.failUnless(msg.ws_at_start == ' ') ++ self.failUnless(msg.ws_at_end == ' ') ++ ++ def testConstruct(self): ++ msg = tclib.Message(text=" Hello USERNAME, how are you? BINGO\t\t", ++ placeholders=[tclib.Placeholder('USERNAME', '%s', 'Joi'), ++ tclib.Placeholder('BINGO', '%d', '11')]) ++ msg_node = message.MessageNode.Construct(None, msg, 'BINGOBONGO') ++ self.failUnless(msg_node.children[0].name == 'ph') ++ self.failUnless(msg_node.children[0].children[0].name == 'ex') ++ self.failUnless(msg_node.children[0].children[0].GetCdata() == 'Joi') ++ self.failUnless(msg_node.children[1].children[0].GetCdata() == '11') ++ self.failUnless(msg_node.ws_at_start == ' ') ++ self.failUnless(msg_node.ws_at_end == '\t\t') ++ ++ def testUnicodeConstruct(self): ++ text = u'Howdie \u00fe' ++ msg = tclib.Message(text=text) ++ msg_node = message.MessageNode.Construct(None, msg, 'BINGOBONGO') ++ msg_from_node = msg_node.GetCdata() ++ self.failUnless(msg_from_node == text) ++ ++ def testFormatterData(self): ++ root = util.ParseGrdForUnittest("""\ ++ ++ ++ Text ++ ++ """) ++ msg, = root.GetChildrenOfType(message.MessageNode) ++ expected_formatter_data = { ++ 'foo': '123', ++ 'bar': '', ++ 'qux': 'low'} ++ ++ # Can't use assertDictEqual, not available in Python 2.6, so do it ++ # by hand. ++ self.failUnlessEqual(len(expected_formatter_data), ++ len(msg.formatter_data)) ++ for key in expected_formatter_data: ++ self.failUnlessEqual(expected_formatter_data[key], ++ msg.formatter_data[key]) ++ ++ def testReplaceEllipsis(self): ++ root = util.ParseGrdForUnittest(''' ++ ++ ++ A...B.... %sA... B... C... ++ ++ ''') ++ msg, = root.GetChildrenOfType(message.MessageNode) ++ msg.SetReplaceEllipsis(True) ++ content = msg.Translate('en') ++ self.failUnlessEqual(u'A...B.... %s\u2026 B\u2026 C\u2026', content) ++ ++ def testRemoveByteOrderMark(self): ++ root = util.ParseGrdForUnittest(u''' ++ ++ ++ \uFEFFThis\uFEFF i\uFEFFs OK\uFEFF ++ ++ ''') ++ msg, = root.GetChildrenOfType(message.MessageNode) ++ content = msg.Translate('en') ++ self.failUnlessEqual(u'This is OK', content) ++ ++ def testPlaceholderHasTooManyExamples(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ Hi $1JoiJoy ++ ++ """) ++ except exception.TooManyExamples: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testPlaceholderHasInvalidName(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ Hi $1 ++ ++ """) ++ except exception.InvalidPlaceholderName: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testChromeLocalizedFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing the ph node: $1 ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testAndroidStringFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing a ph node: %1$s ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testAndroidIntegerFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing a ph node: %2$d ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testAndroidIntegerWidthFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing a ph node: %2$3d ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testValidAndroidIntegerWidthFormatInPhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ %2$3d042 ++ ++ """) ++ except: ++ self.fail('Should not have gotten exception') ++ ++ def testAndroidFloatFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing a ph node: %3$4.5f ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testGritStringFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing the ph node: %s ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testGritIntegerFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing the ph node: %d ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testWindowsETWIntegerFormatIsInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ This message is missing the ph node: %1 ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testValidMultipleFormattersInsidePhNodes(self): ++ root = util.ParseGrdForUnittest("""\ ++ ++ ++ %1$d1 error, %2$d1 warning ++ ++ """) ++ msg, = root.GetChildrenOfType(message.MessageNode) ++ cliques = msg.GetCliques() ++ content = cliques[0].GetMessage().GetPresentableContent() ++ self.failUnless(content == 'ERROR_COUNT error, WARNING_COUNT warning') ++ ++ def testMultipleFormattersAreInsidePhNodes(self): ++ failed = True ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ %1$d error, %2$d warning ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ failed = False ++ if failed: ++ self.fail('Should have gotten exception') ++ return ++ ++ failed = True ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ %1$d1 error, %2$d warning ++ ++ """) ++ except exception.PlaceholderNotInsidePhNode: ++ failed = False ++ if failed: ++ self.fail('Should have gotten exception') ++ return ++ ++ failed = True ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ %1$d %2$d ++ ++ """) ++ except exception.InvalidCharactersInsidePhNode: ++ failed = False ++ if failed: ++ self.fail('Should have gotten exception') ++ return ++ ++ def testValidHTMLFormatInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ <span>$1</span>1 ++ ++ """) ++ except: ++ self.fail('Should not have gotten exception') ++ ++ def testValidHTMLWithAttributesFormatInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ <span attribute="js:$this %">$2</span>2 ++ ++ """) ++ except: ++ self.fail('Should not have gotten exception') ++ ++ def testValidHTMLEntityFormatInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ >%1$d<1 ++ ++ """) ++ except: ++ self.fail('Should not have gotten exception') ++ ++ def testValidMultipleDollarFormatInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ $$1 ++ ++ """) ++ except: ++ self.fail('Should not have gotten exception') ++ ++ def testInvalidDollarCharacterInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ %1$d $ ++ ++ """) ++ except exception.InvalidCharactersInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testInvalidPercentCharacterInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ %1$d % ++ ++ """) ++ except exception.InvalidCharactersInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ def testInvalidMixedFormatCharactersInsidePhNode(self): ++ try: ++ util.ParseGrdForUnittest("""\ ++ ++ ++ %1$2 ++ ++ """) ++ except exception.InvalidCharactersInsidePhNode: ++ return ++ self.fail('Should have gotten exception') ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/misc.py b/tools/grit/grit/node/misc.py +new file mode 100644 +index 0000000000..2d8b06d6a5 +--- /dev/null ++++ b/tools/grit/grit/node/misc.py +@@ -0,0 +1,707 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Miscellaneous node types. ++""" ++ ++from __future__ import print_function ++ ++import os.path ++import re ++import sys ++ ++import six ++ ++from grit import constants ++from grit import exception ++from grit import util ++from grit.extern import FP ++from grit.node import base ++from grit.node import message ++from grit.node import node_io ++ ++ ++# Python 3 doesn't have long() as int() works everywhere. But we really do need ++# the long() behavior on Python 2 as our ids are much too large for int(). ++try: ++ long ++except NameError: ++ long = int ++ ++ ++# RTL languages ++# TODO(jennyz): remove this fixed set of RTL language array ++# now that generic expand_variable code exists. ++_RTL_LANGS = ( ++ 'ar', # Arabic ++ 'fa', # Farsi ++ 'iw', # Hebrew ++ 'ks', # Kashmiri ++ 'ku', # Kurdish ++ 'ps', # Pashto ++ 'ur', # Urdu ++ 'yi', # Yiddish ++) ++ ++ ++def _ReadFirstIdsFromFile(filename, defines): ++ """Read the starting resource id values from |filename|. We also ++ expand variables of the form <(FOO) based on defines passed in on ++ the command line. ++ ++ Returns a tuple, the absolute path of SRCDIR followed by the ++ first_ids dictionary. ++ """ ++ first_ids_dict = eval(util.ReadFile(filename, 'utf-8')) ++ src_root_dir = os.path.abspath(os.path.join(os.path.dirname(filename), ++ first_ids_dict['SRCDIR'])) ++ ++ def ReplaceVariable(matchobj): ++ for key, value in defines.items(): ++ if matchobj.group(1) == key: ++ return value ++ return '' ++ ++ renames = [] ++ for grd_filename in first_ids_dict: ++ new_grd_filename = re.sub(r'<\(([A-Za-z_]+)\)', ReplaceVariable, ++ grd_filename) ++ if new_grd_filename != grd_filename: ++ abs_grd_filename = os.path.abspath(new_grd_filename) ++ if abs_grd_filename[:len(src_root_dir)] != src_root_dir: ++ new_grd_filename = os.path.basename(abs_grd_filename) ++ else: ++ new_grd_filename = abs_grd_filename[len(src_root_dir) + 1:] ++ new_grd_filename = new_grd_filename.replace('\\', '/') ++ renames.append((grd_filename, new_grd_filename)) ++ ++ for grd_filename, new_grd_filename in renames: ++ first_ids_dict[new_grd_filename] = first_ids_dict[grd_filename] ++ del(first_ids_dict[grd_filename]) ++ ++ return (src_root_dir, first_ids_dict) ++ ++ ++def _ComputeIds(root, predetermined_tids): ++ """Returns a dict of textual id -> numeric id for all nodes in root. ++ ++ IDs are mostly assigned sequentially, but will vary based on: ++ * first_id node attribute (from first_ids_file) ++ * hash of textual id (if not first_id is defined) ++ * offset node attribute ++ * whether the textual id matches a system id ++ * whether the node generates its own ID via GetId() ++ ++ Args: ++ predetermined_tids: Dict of textual id -> numeric id to use in return dict. ++ """ ++ from grit.node import empty, include, misc, structure ++ ++ ids = {} # Maps numeric id to textual id ++ tids = {} # Maps textual id to numeric id ++ id_reasons = {} # Maps numeric id to text id and a human-readable explanation ++ group = None ++ last_id = None ++ predetermined_ids = {value: key ++ for key, value in predetermined_tids.items()} ++ ++ for item in root: ++ if isinstance(item, empty.GroupingNode): ++ # Note: this won't work if any GroupingNode can be contained inside ++ # another. ++ group = item ++ last_id = None ++ continue ++ ++ assert not item.GetTextualIds() or isinstance(item, ++ (include.IncludeNode, message.MessageNode, ++ misc.IdentifierNode, structure.StructureNode)) ++ ++ # Resources that use the RES protocol don't need ++ # any numerical ids generated, so we skip them altogether. ++ # This is accomplished by setting the flag 'generateid' to false ++ # in the GRD file. ++ if item.attrs.get('generateid', 'true') == 'false': ++ continue ++ ++ for tid in item.GetTextualIds(): ++ if util.SYSTEM_IDENTIFIERS.match(tid): ++ # Don't emit a new ID for predefined IDs ++ continue ++ ++ if tid in tids: ++ continue ++ ++ if predetermined_tids and tid in predetermined_tids: ++ id = predetermined_tids[tid] ++ reason = "from predetermined_tids map" ++ ++ # Some identifier nodes can provide their own id, ++ # and we use that id in the generated header in that case. ++ elif hasattr(item, 'GetId') and item.GetId(): ++ id = long(item.GetId()) ++ reason = 'returned by GetId() method' ++ ++ elif ('offset' in item.attrs and group and ++ group.attrs.get('first_id', '') != ''): ++ offset_text = item.attrs['offset'] ++ parent_text = group.attrs['first_id'] ++ ++ try: ++ offset_id = long(offset_text) ++ except ValueError: ++ offset_id = tids[offset_text] ++ ++ try: ++ parent_id = long(parent_text) ++ except ValueError: ++ parent_id = tids[parent_text] ++ ++ id = parent_id + offset_id ++ reason = 'first_id %d + offset %d' % (parent_id, offset_id) ++ ++ # We try to allocate IDs sequentially for blocks of items that might ++ # be related, for instance strings in a stringtable (as their IDs might be ++ # used e.g. as IDs for some radio buttons, in which case the IDs must ++ # be sequential). ++ # ++ # We do this by having the first item in a section store its computed ID ++ # (computed from a fingerprint) in its parent object. Subsequent children ++ # of the same parent will then try to get IDs that sequentially follow ++ # the currently stored ID (on the parent) and increment it. ++ elif last_id is None: ++ # First check if the starting ID is explicitly specified by the parent. ++ if group and group.attrs.get('first_id', '') != '': ++ id = long(group.attrs['first_id']) ++ reason = "from parent's first_id attribute" ++ else: ++ # Automatically generate the ID based on the first clique from the ++ # first child of the first child node of our parent (i.e. when we ++ # first get to this location in the code). ++ ++ # According to ++ # http://msdn.microsoft.com/en-us/library/t2zechd4(VS.71).aspx ++ # the safe usable range for resource IDs in Windows is from decimal ++ # 101 to 0x7FFF. ++ ++ id = FP.UnsignedFingerPrint(tid) ++ id = id % (0x7FFF - 101) + 101 ++ reason = 'chosen by random fingerprint -- use first_id to override' ++ ++ last_id = id ++ else: ++ id = last_id = last_id + 1 ++ reason = 'sequentially assigned' ++ ++ reason = "%s (%s)" % (tid, reason) ++ # Don't fail when 'offset' is specified, as the base and the 0th ++ # offset will have the same ID. ++ if id in id_reasons and not 'offset' in item.attrs: ++ raise exception.IdRangeOverlap('ID %d was assigned to both %s and %s.' ++ % (id, id_reasons[id], reason)) ++ ++ if id < 101: ++ print('WARNING: Numeric resource IDs should be greater than 100 to\n' ++ 'avoid conflicts with system-defined resource IDs.') ++ ++ if tid not in predetermined_tids and id in predetermined_ids: ++ raise exception.IdRangeOverlap('ID %d overlaps between %s and %s' ++ % (id, tid, predetermined_ids[tid])) ++ ++ ids[id] = tid ++ tids[tid] = id ++ id_reasons[id] = reason ++ ++ return tids ++ ++class SplicingNode(base.Node): ++ """A node whose children should be considered to be at the same level as ++ its siblings for most purposes. This includes and nodes. ++ """ ++ ++ def _IsValidChild(self, child): ++ assert self.parent, '<%s> node should never be root.' % self.name ++ if isinstance(child, SplicingNode): ++ return True # avoid O(n^2) behavior ++ return self.parent._IsValidChild(child) ++ ++ ++class IfNode(SplicingNode): ++ """A node for conditional inclusion of resources. ++ """ ++ ++ def MandatoryAttributes(self): ++ return ['expr'] ++ ++ def _IsValidChild(self, child): ++ return (isinstance(child, (ThenNode, ElseNode)) or ++ super(IfNode, self)._IsValidChild(child)) ++ ++ def EndParsing(self): ++ children = self.children ++ self.if_then_else = False ++ if any(isinstance(node, (ThenNode, ElseNode)) for node in children): ++ if (len(children) != 2 or not isinstance(children[0], ThenNode) or ++ not isinstance(children[1], ElseNode)): ++ raise exception.UnexpectedChild( ++ ' element must be ......') ++ self.if_then_else = True ++ ++ def ActiveChildren(self): ++ cond = self.EvaluateCondition(self.attrs['expr']) ++ if self.if_then_else: ++ return self.children[0 if cond else 1].ActiveChildren() ++ else: ++ # Equivalent to having all children inside with an empty ++ return super(IfNode, self).ActiveChildren() if cond else [] ++ ++ ++class ThenNode(SplicingNode): ++ """A node. Can only appear directly inside an node.""" ++ pass ++ ++ ++class ElseNode(SplicingNode): ++ """An node. Can only appear directly inside an node.""" ++ pass ++ ++ ++class PartNode(SplicingNode): ++ """A node for inclusion of sub-grd (*.grp) files. ++ """ ++ ++ def __init__(self): ++ super(PartNode, self).__init__() ++ self.started_inclusion = False ++ ++ def MandatoryAttributes(self): ++ return ['file'] ++ ++ def _IsValidChild(self, child): ++ return self.started_inclusion and super(PartNode, self)._IsValidChild(child) ++ ++ ++class ReleaseNode(base.Node): ++ """The element.""" ++ ++ def _IsValidChild(self, child): ++ from grit.node import empty ++ return isinstance(child, (empty.IncludesNode, empty.MessagesNode, ++ empty.StructuresNode, empty.IdentifiersNode)) ++ ++ def _IsValidAttribute(self, name, value): ++ return ( ++ (name == 'seq' and int(value) <= self.GetRoot().GetCurrentRelease()) or ++ name == 'allow_pseudo' ++ ) ++ ++ def MandatoryAttributes(self): ++ return ['seq'] ++ ++ def DefaultAttributes(self): ++ return { 'allow_pseudo' : 'true' } ++ ++ ++class GritNode(base.Node): ++ """The root element.""" ++ ++ def __init__(self): ++ super(GritNode, self).__init__() ++ self.output_language = '' ++ self.defines = {} ++ self.substituter = None ++ self.target_platform = sys.platform ++ self.whitelist_support = False ++ self._predetermined_ids_file = None ++ self._id_map = None # Dict of textual_id -> numeric_id. ++ ++ def _IsValidChild(self, child): ++ from grit.node import empty ++ return isinstance(child, (ReleaseNode, empty.TranslationsNode, ++ empty.OutputsNode)) ++ ++ def _IsValidAttribute(self, name, value): ++ if name not in ['base_dir', 'first_ids_file', 'source_lang_id', ++ 'latest_public_release', 'current_release', ++ 'enc_check', 'tc_project', 'grit_version', ++ 'output_all_resource_defines']: ++ return False ++ if name in ['latest_public_release', 'current_release'] and value.strip( ++ '0123456789') != '': ++ return False ++ return True ++ ++ def MandatoryAttributes(self): ++ return ['latest_public_release', 'current_release'] ++ ++ def DefaultAttributes(self): ++ return { ++ 'base_dir' : '.', ++ 'first_ids_file': '', ++ 'grit_version': 1, ++ 'source_lang_id' : 'en', ++ 'enc_check' : constants.ENCODING_CHECK, ++ 'tc_project' : 'NEED_TO_SET_tc_project_ATTRIBUTE', ++ } ++ ++ def EndParsing(self): ++ super(GritNode, self).EndParsing() ++ if (int(self.attrs['latest_public_release']) ++ > int(self.attrs['current_release'])): ++ raise exception.Parsing('latest_public_release cannot have a greater ' ++ 'value than current_release') ++ ++ self.ValidateUniqueIds() ++ ++ # Add the encoding check if it's not present (should ensure that it's always ++ # present in all .grd files generated by GRIT). If it's present, assert if ++ # it's not correct. ++ if 'enc_check' not in self.attrs or self.attrs['enc_check'] == '': ++ self.attrs['enc_check'] = constants.ENCODING_CHECK ++ else: ++ assert self.attrs['enc_check'] == constants.ENCODING_CHECK, ( ++ 'Are you sure your .grd file is in the correct encoding (UTF-8)?') ++ ++ def ValidateUniqueIds(self): ++ """Validate that 'name' attribute is unique in all nodes in this tree ++ except for nodes that are children of nodes. ++ """ ++ unique_names = {} ++ duplicate_names = [] ++ # To avoid false positives from mutually exclusive clauses, check ++ # against whatever the output condition happens to be right now. ++ # TODO(benrg): do something better. ++ for node in self.ActiveDescendants(): ++ if node.attrs.get('generateid', 'true') == 'false': ++ continue # Duplication not relevant in that case ++ ++ for node_id in node.GetTextualIds(): ++ if util.SYSTEM_IDENTIFIERS.match(node_id): ++ continue # predefined IDs are sometimes used more than once ++ ++ if node_id in unique_names and node_id not in duplicate_names: ++ duplicate_names.append(node_id) ++ unique_names[node_id] = 1 ++ ++ if len(duplicate_names): ++ raise exception.DuplicateKey(', '.join(duplicate_names)) ++ ++ ++ def GetCurrentRelease(self): ++ """Returns the current release number.""" ++ return int(self.attrs['current_release']) ++ ++ def GetLatestPublicRelease(self): ++ """Returns the latest public release number.""" ++ return int(self.attrs['latest_public_release']) ++ ++ def GetSourceLanguage(self): ++ """Returns the language code of the source language.""" ++ return self.attrs['source_lang_id'] ++ ++ def GetTcProject(self): ++ """Returns the name of this project in the TranslationConsole, or ++ 'NEED_TO_SET_tc_project_ATTRIBUTE' if it is not defined.""" ++ return self.attrs['tc_project'] ++ ++ def SetOwnDir(self, dir): ++ """Informs the 'grit' element of the directory the file it is in resides. ++ This allows it to calculate relative paths from the input file, which is ++ what we desire (rather than from the current path). ++ ++ Args: ++ dir: r'c:\bla' ++ ++ Return: ++ None ++ """ ++ assert dir ++ self.base_dir = os.path.normpath(os.path.join(dir, self.attrs['base_dir'])) ++ ++ def GetBaseDir(self): ++ """Returns the base directory, relative to the working directory. To get ++ the base directory as set in the .grd file, use GetOriginalBaseDir() ++ """ ++ if hasattr(self, 'base_dir'): ++ return self.base_dir ++ else: ++ return self.GetOriginalBaseDir() ++ ++ def GetOriginalBaseDir(self): ++ """Returns the base directory, as set in the .grd file. ++ """ ++ return self.attrs['base_dir'] ++ ++ def IsWhitelistSupportEnabled(self): ++ return self.whitelist_support ++ ++ def SetWhitelistSupportEnabled(self, whitelist_support): ++ self.whitelist_support = whitelist_support ++ ++ def GetInputFiles(self): ++ """Returns the list of files that are read to produce the output.""" ++ ++ # Importing this here avoids a circular dependency in the imports. ++ # pylint: disable-msg=C6204 ++ from grit.node import include ++ from grit.node import misc ++ from grit.node import structure ++ from grit.node import variant ++ ++ # Check if the input is required for any output configuration. ++ input_files = set() ++ # Collect even inactive PartNodes since they affect ID assignments. ++ for node in self: ++ if isinstance(node, misc.PartNode): ++ input_files.add(self.ToRealPath(node.GetInputPath())) ++ ++ old_output_language = self.output_language ++ for lang, ctx, fallback in self.GetConfigurations(): ++ self.SetOutputLanguage(lang or self.GetSourceLanguage()) ++ self.SetOutputContext(ctx) ++ self.SetFallbackToDefaultLayout(fallback) ++ ++ for node in self.ActiveDescendants(): ++ if isinstance(node, (node_io.FileNode, include.IncludeNode, ++ structure.StructureNode, variant.SkeletonNode)): ++ input_path = node.GetInputPath() ++ if input_path is not None: ++ input_files.add(self.ToRealPath(input_path)) ++ ++ # If it's a flattened node, grab inlined resources too. ++ if ((node.name == 'structure' or node.name == 'include') ++ and node.attrs['flattenhtml'] == 'true'): ++ if node.name == 'structure': ++ node.RunPreSubstitutionGatherer() ++ input_files.update(node.GetHtmlResourceFilenames()) ++ ++ self.SetOutputLanguage(old_output_language) ++ return sorted(input_files) ++ ++ def GetFirstIdsFile(self): ++ """Returns a usable path to the first_ids file, if set, otherwise ++ returns None. ++ ++ The first_ids_file attribute is by default relative to the ++ base_dir of the .grd file, but may be prefixed by GRIT_DIR/, ++ which makes it relative to the directory of grit.py ++ (e.g. GRIT_DIR/../gritsettings/resource_ids). ++ """ ++ if not self.attrs['first_ids_file']: ++ return None ++ ++ path = self.attrs['first_ids_file'] ++ GRIT_DIR_PREFIX = 'GRIT_DIR' ++ if (path.startswith(GRIT_DIR_PREFIX) ++ and path[len(GRIT_DIR_PREFIX)] in ['/', '\\']): ++ return util.PathFromRoot(path[len(GRIT_DIR_PREFIX) + 1:]) ++ else: ++ return self.ToRealPath(path) ++ ++ def GetOutputFiles(self): ++ """Returns the list of nodes that are descendants of this node's ++ child and are not enclosed by unsatisfied conditionals. ++ """ ++ for child in self.children: ++ if child.name == 'outputs': ++ return [node for node in child.ActiveDescendants() ++ if node.name == 'output'] ++ raise exception.MissingElement() ++ ++ def GetConfigurations(self): ++ """Returns the distinct (language, context, fallback_to_default_layout) ++ triples from the output nodes. ++ """ ++ return set((n.GetLanguage(), n.GetContext(), n.GetFallbackToDefaultLayout()) ++ for n in self.GetOutputFiles()) ++ ++ def GetSubstitutionMessages(self): ++ """Returns the list of nodes.""" ++ return [n for n in self.ActiveDescendants() ++ if isinstance(n, message.MessageNode) ++ and n.attrs['sub_variable'] == 'true'] ++ ++ def SetOutputLanguage(self, output_language): ++ """Set the output language. Prepares substitutions. ++ ++ The substitutions are reset every time the language is changed. ++ They include messages designated as variables, and language codes for html ++ and rc files. ++ ++ Args: ++ output_language: a two-letter language code (eg: 'en', 'ar'...) or '' ++ """ ++ if not output_language: ++ # We do not specify the output language for .grh files, ++ # so we get an empty string as the default. ++ # The value should match grit.clique.MessageClique.source_language. ++ output_language = self.GetSourceLanguage() ++ if output_language != self.output_language: ++ self.output_language = output_language ++ self.substituter = None # force recalculate ++ ++ def SetOutputContext(self, output_context): ++ self.output_context = output_context ++ self.substituter = None # force recalculate ++ ++ def SetFallbackToDefaultLayout(self, fallback_to_default_layout): ++ self.fallback_to_default_layout = fallback_to_default_layout ++ self.substituter = None # force recalculate ++ ++ def SetDefines(self, defines): ++ self.defines = defines ++ self.substituter = None # force recalculate ++ ++ def SetTargetPlatform(self, target_platform): ++ self.target_platform = target_platform ++ ++ def GetSubstituter(self): ++ if self.substituter is None: ++ self.substituter = util.Substituter() ++ self.substituter.AddMessages(self.GetSubstitutionMessages(), ++ self.output_language) ++ if self.output_language in _RTL_LANGS: ++ direction = 'dir="RTL"' ++ else: ++ direction = 'dir="LTR"' ++ self.substituter.AddSubstitutions({ ++ 'GRITLANGCODE': self.output_language, ++ 'GRITDIR': direction, ++ }) ++ from grit.format import rc # avoid circular dep ++ rc.RcSubstitutions(self.substituter, self.output_language) ++ return self.substituter ++ ++ def AssignFirstIds(self, filename_or_stream, defines): ++ """Assign first ids to each grouping node based on values from the ++ first_ids file (if specified on the node). ++ """ ++ assert self._id_map is None, 'AssignFirstIds() after InitializeIds()' ++ # If the input is a stream, then we're probably in a unit test and ++ # should skip this step. ++ if not isinstance(filename_or_stream, six.string_types): ++ return ++ ++ # Nothing to do if the first_ids_filename attribute isn't set. ++ first_ids_filename = self.GetFirstIdsFile() ++ if not first_ids_filename: ++ return ++ ++ src_root_dir, first_ids = _ReadFirstIdsFromFile(first_ids_filename, ++ defines) ++ from grit.node import empty ++ for node in self.Preorder(): ++ if isinstance(node, empty.GroupingNode): ++ abs_filename = os.path.abspath(filename_or_stream) ++ if abs_filename[:len(src_root_dir)] != src_root_dir: ++ filename = os.path.basename(filename_or_stream) ++ else: ++ filename = abs_filename[len(src_root_dir) + 1:] ++ filename = filename.replace('\\', '/') ++ ++ if node.attrs['first_id'] != '': ++ raise Exception( ++ "Don't set the first_id attribute when using the first_ids_file " ++ "attribute on the node, update %s instead." % ++ first_ids_filename) ++ ++ try: ++ id_list = first_ids[filename][node.name] ++ except KeyError as e: ++ print('-' * 78) ++ print('Resource id not set for %s (%s)!' % (filename, node.name)) ++ print('Please update %s to include an entry for %s. See the ' ++ 'comments in resource_ids for information on why you need to ' ++ 'update that file.' % (first_ids_filename, filename)) ++ print('-' * 78) ++ raise e ++ ++ try: ++ node.attrs['first_id'] = str(id_list.pop(0)) ++ except IndexError as e: ++ raise Exception('Please update %s and add a first id for %s (%s).' ++ % (first_ids_filename, filename, node.name)) ++ ++ def GetIdMap(self): ++ '''Return a dictionary mapping textual ids to numeric ids.''' ++ return self._id_map ++ ++ def SetPredeterminedIdsFile(self, predetermined_ids_file): ++ assert self._id_map is None, ( ++ 'SetPredeterminedIdsFile() after InitializeIds()') ++ self._predetermined_ids_file = predetermined_ids_file ++ ++ def InitializeIds(self): ++ '''Initializes the text ID -> numeric ID mapping.''' ++ predetermined_id_map = {} ++ if self._predetermined_ids_file: ++ with open(self._predetermined_ids_file) as f: ++ for line in f: ++ tid, nid = line.split() ++ predetermined_id_map[tid] = int(nid) ++ self._id_map = _ComputeIds(self, predetermined_id_map) ++ ++ def RunGatherers(self, debug=False): ++ '''Call RunPreSubstitutionGatherer() on every node of the tree, then apply ++ substitutions, then call RunPostSubstitutionGatherer() on every node. ++ ++ The substitutions step requires that the output language has been set. ++ Locally, get the Substitution messages and add them to the substituter. ++ Also add substitutions for language codes in the Rc. ++ ++ Args: ++ debug: will print information while running gatherers. ++ ''' ++ for node in self.ActiveDescendants(): ++ if hasattr(node, 'RunPreSubstitutionGatherer'): ++ with node: ++ node.RunPreSubstitutionGatherer(debug=debug) ++ ++ assert self.output_language ++ self.SubstituteMessages(self.GetSubstituter()) ++ ++ for node in self.ActiveDescendants(): ++ if hasattr(node, 'RunPostSubstitutionGatherer'): ++ with node: ++ node.RunPostSubstitutionGatherer(debug=debug) ++ ++ ++class IdentifierNode(base.Node): ++ """A node for specifying identifiers that should appear in the resource ++ header file, and be unique amongst all other resource identifiers, but don't ++ have any other attributes or reference any resources. ++ """ ++ ++ def MandatoryAttributes(self): ++ return ['name'] ++ ++ def DefaultAttributes(self): ++ return { 'comment' : '', 'id' : '', 'systemid': 'false' } ++ ++ def GetId(self): ++ """Returns the id of this identifier if it has one, None otherwise ++ """ ++ if 'id' in self.attrs: ++ return self.attrs['id'] ++ return None ++ ++ def EndParsing(self): ++ """Handles system identifiers.""" ++ super(IdentifierNode, self).EndParsing() ++ if self.attrs['systemid'] == 'true': ++ util.SetupSystemIdentifiers((self.attrs['name'],)) ++ ++ @staticmethod ++ def Construct(parent, name, id, comment, systemid='false'): ++ """Creates a new node which is a child of 'parent', with attributes set ++ by parameters of the same name. ++ """ ++ node = IdentifierNode() ++ node.StartParsing('identifier', parent) ++ node.HandleAttribute('name', name) ++ node.HandleAttribute('id', id) ++ node.HandleAttribute('comment', comment) ++ node.HandleAttribute('systemid', systemid) ++ node.EndParsing() ++ return node +diff --git a/tools/grit/grit/node/misc_unittest.py b/tools/grit/grit/node/misc_unittest.py +new file mode 100644 +index 0000000000..c192b096f4 +--- /dev/null ++++ b/tools/grit/grit/node/misc_unittest.py +@@ -0,0 +1,590 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for misc.GritNode''' ++ ++from __future__ import print_function ++ ++import contextlib ++import os ++import sys ++import tempfile ++import unittest ++ ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++from six import StringIO ++ ++from grit import grd_reader ++import grit.exception ++from grit import util ++from grit.format import rc ++from grit.format import rc_header ++from grit.node import misc ++ ++ ++@contextlib.contextmanager ++def _MakeTempPredeterminedIdsFile(content): ++ """Write the |content| string to a temporary file. ++ ++ The temporary file must be deleted by the caller. ++ ++ Example: ++ with _MakeTempPredeterminedIdsFile('foo') as path: ++ ... ++ os.remove(path) ++ ++ Args: ++ content: The string to write. ++ ++ Yields: ++ The name of the temporary file. ++ """ ++ with tempfile.NamedTemporaryFile(mode='w', delete=False) as f: ++ f.write(content) ++ f.flush() ++ f.close() ++ yield f.name ++ ++ ++class GritNodeUnittest(unittest.TestCase): ++ def testUniqueNameAttribute(self): ++ try: ++ restree = grd_reader.Parse( ++ util.PathFromRoot('grit/testdata/duplicate-name-input.xml')) ++ self.fail('Expected parsing exception because of duplicate names.') ++ except grit.exception.Parsing: ++ pass # Expected case ++ ++ def testReadFirstIdsFromFile(self): ++ test_resource_ids = os.path.join(os.path.dirname(__file__), '..', ++ 'testdata', 'resource_ids') ++ base_dir = os.path.dirname(test_resource_ids) ++ ++ src_dir, id_dict = misc._ReadFirstIdsFromFile( ++ test_resource_ids, ++ { ++ 'FOO': os.path.join(base_dir, 'bar'), ++ 'SHARED_INTERMEDIATE_DIR': os.path.join(base_dir, ++ 'out/Release/obj/gen'), ++ }) ++ self.assertEqual({}, id_dict.get('bar/file.grd', None)) ++ self.assertEqual({}, ++ id_dict.get('out/Release/obj/gen/devtools/devtools.grd', None)) ++ ++ src_dir, id_dict = misc._ReadFirstIdsFromFile( ++ test_resource_ids, ++ { ++ 'SHARED_INTERMEDIATE_DIR': '/outside/src_dir', ++ }) ++ self.assertEqual({}, id_dict.get('devtools.grd', None)) ++ ++ # Verifies that GetInputFiles() returns the correct list of files ++ # corresponding to ChromeScaledImage nodes when assets are missing. ++ def testGetInputFilesChromeScaledImage(self): ++ chrome_html_path = util.PathFromRoot('grit/testdata/chrome_html.html') ++ xml = ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''' % chrome_html_path ++ ++ grd = grd_reader.Parse(StringIO(xml), ++ util.PathFromRoot('grit/testdata')) ++ expected = ['chrome_html.html', 'default_100_percent/a.png', ++ 'default_100_percent/b.png', 'included_sample.html', ++ 'special_100_percent/a.png'] ++ actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for ++ path in grd.GetInputFiles()] ++ # Convert path separator for Windows paths. ++ actual = [path.replace('\\', '/') for path in actual] ++ self.assertEquals(expected, actual) ++ ++ # Verifies that GetInputFiles() returns the correct list of files ++ # when files include other files. ++ def testGetInputFilesFromIncludes(self): ++ chrome_html_path = util.PathFromRoot('grit/testdata/chrome_html.html') ++ xml = ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''' % chrome_html_path ++ ++ grd = grd_reader.Parse(StringIO(xml), util.PathFromRoot('grit/testdata')) ++ expected = ['chrome_html.html', 'included_sample.html'] ++ actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for ++ path in grd.GetInputFiles()] ++ # Convert path separator for Windows paths. ++ actual = [path.replace('\\', '/') for path in actual] ++ self.assertEquals(expected, actual) ++ ++ def testNonDefaultEntry(self): ++ grd = util.ParseGrdForUnittest(''' ++ ++ bar ++ ++ bar ++ ++ ''') ++ grd.SetOutputLanguage('fr') ++ output = ''.join(rc_header.Format(grd, 'fr', '.')) ++ self.assertIn('#define IDS_A 2378\n#define IDS_B 2379', output) ++ ++ def testExplicitFirstIdOverlaps(self): ++ # second first_id will overlap preexisting range ++ self.assertRaises(grit.exception.IdRangeOverlap, ++ util.ParseGrdForUnittest, ''' ++ ++ ++ ++ ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ Frubegfrums ++ ''') ++ ++ def testImplicitOverlapsPreexisting(self): ++ # second message in will overlap preexisting range ++ self.assertRaises(grit.exception.IdRangeOverlap, ++ util.ParseGrdForUnittest, ''' ++ ++ ++ ++ ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ Frubegfrums ++ ''') ++ ++ def testPredeterminedIds(self): ++ with _MakeTempPredeterminedIdsFile('IDS_A 101\nIDS_B 102') as ids_file: ++ grd = util.ParseGrdForUnittest(''' ++ ++ ++ ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ ++ Bongo! ++ ++ ''', predetermined_ids_file=ids_file) ++ output = rc_header.FormatDefines(grd) ++ self.assertEqual(('#define IDS_B 102\n' ++ '#define IDS_GREETING 10000\n' ++ '#define IDS_A 101\n'), ''.join(output)) ++ os.remove(ids_file) ++ ++ def testPredeterminedIdsOverlap(self): ++ with _MakeTempPredeterminedIdsFile('ID_LOGO 10000') as ids_file: ++ self.assertRaises(grit.exception.IdRangeOverlap, ++ util.ParseGrdForUnittest, ''' ++ ++ ++ ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ ++ Bongo! ++ ++ ''', predetermined_ids_file=ids_file) ++ os.remove(ids_file) ++ ++ ++class IfNodeUnittest(unittest.TestCase): ++ def testIffyness(self): ++ grd = grd_reader.Parse(StringIO(''' ++ ++ ++ ++ ++ ++ Bingo! ++ ++ ++ ++ ++ Hello! ++ ++ ++ ++ ++ Good morning ++ ++ ++ ++ is_win ++ ++ ++ ++ '''), dir='.') ++ ++ messages_node = grd.children[0].children[0] ++ bingo_message = messages_node.children[0].children[0] ++ hello_message = messages_node.children[1].children[0] ++ french_message = messages_node.children[2].children[0] ++ is_win_message = messages_node.children[3].children[0] ++ ++ self.assertTrue(bingo_message.name == 'message') ++ self.assertTrue(hello_message.name == 'message') ++ self.assertTrue(french_message.name == 'message') ++ ++ grd.SetOutputLanguage('fr') ++ grd.SetDefines({'hello': '1'}) ++ active = set(grd.ActiveDescendants()) ++ self.failUnless(bingo_message not in active) ++ self.failUnless(hello_message in active) ++ self.failUnless(french_message in active) ++ ++ grd.SetOutputLanguage('en') ++ grd.SetDefines({'bingo': 1}) ++ active = set(grd.ActiveDescendants()) ++ self.failUnless(bingo_message in active) ++ self.failUnless(hello_message not in active) ++ self.failUnless(french_message not in active) ++ ++ grd.SetOutputLanguage('en') ++ grd.SetDefines({'FORCE_FRENCH': '1', 'bingo': '1'}) ++ active = set(grd.ActiveDescendants()) ++ self.failUnless(bingo_message in active) ++ self.failUnless(hello_message not in active) ++ self.failUnless(french_message in active) ++ ++ grd.SetOutputLanguage('en') ++ grd.SetDefines({}) ++ self.failUnless(grd.target_platform == sys.platform) ++ grd.SetTargetPlatform('darwin') ++ active = set(grd.ActiveDescendants()) ++ self.failUnless(is_win_message not in active) ++ grd.SetTargetPlatform('win32') ++ active = set(grd.ActiveDescendants()) ++ self.failUnless(is_win_message in active) ++ ++ def testElsiness(self): ++ grd = util.ParseGrdForUnittest(''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''') ++ included = [msg.attrs['name'] for msg in grd.ActiveDescendants() ++ if msg.name == 'message'] ++ self.assertEqual(['IDS_YES1', 'IDS_YES2', 'IDS_YES3', 'IDS_YES4'], included) ++ ++ def testIffynessWithOutputNodes(self): ++ grd = grd_reader.Parse(StringIO(''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ '''), dir='.') ++ ++ outputs_node = grd.children[0] ++ uncond1_output = outputs_node.children[0] ++ only_fr_adm_output = outputs_node.children[1].children[0] ++ only_fr_plist_output = outputs_node.children[1].children[1] ++ doc_output = outputs_node.children[2].children[0] ++ uncond2_output = outputs_node.children[0] ++ self.assertTrue(uncond1_output.name == 'output') ++ self.assertTrue(only_fr_adm_output.name == 'output') ++ self.assertTrue(only_fr_plist_output.name == 'output') ++ self.assertTrue(doc_output.name == 'output') ++ self.assertTrue(uncond2_output.name == 'output') ++ ++ grd.SetOutputLanguage('ru') ++ grd.SetDefines({'hello': '1'}) ++ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] ++ self.assertEquals( ++ outputs, ++ ['uncond1.rc', 'only_fr.adm', 'only_fr.plist', 'doc.html', ++ 'uncond2.adm', 'iftest.h']) ++ ++ grd.SetOutputLanguage('ru') ++ grd.SetDefines({'bingo': '2'}) ++ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] ++ self.assertEquals( ++ outputs, ++ ['uncond1.rc', 'doc.html', 'uncond2.adm', 'iftest.h']) ++ ++ grd.SetOutputLanguage('fr') ++ grd.SetDefines({'hello': '1'}) ++ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] ++ self.assertEquals( ++ outputs, ++ ['uncond1.rc', 'only_fr.adm', 'only_fr.plist', 'uncond2.adm', ++ 'iftest.h']) ++ ++ grd.SetOutputLanguage('en') ++ grd.SetDefines({'bingo': '1'}) ++ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] ++ self.assertEquals(outputs, ['uncond1.rc', 'uncond2.adm', 'iftest.h']) ++ ++ grd.SetOutputLanguage('fr') ++ grd.SetDefines({'bingo': '1'}) ++ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] ++ self.assertNotEquals(outputs, ['uncond1.rc', 'uncond2.adm', 'iftest.h']) ++ ++ def testChildrenAccepted(self): ++ grd_reader.Parse(StringIO(r''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Bingo! ++ ++ ++ ++ Bingo! ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ '''), dir='.') ++ ++ def testIfBadChildrenNesting(self): ++ # includes ++ xml = StringIO(r''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ''') ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ # messages ++ xml = StringIO(r''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ''') ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ # structures ++ xml = StringIO(''' ++ ++ ++ ++ ++ Bingo! ++ ++ ++ ++ ''') ++ # translations ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ xml = StringIO(''' ++ ++ ++ ++ Bingo! ++ ++ ++ ''') ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ # same with nesting ++ xml = StringIO(r''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''') ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ xml = StringIO(r''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ''') ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ xml = StringIO(''' ++ ++ ++ ++ ++ ++ Bingo! ++ ++ ++ ++ ++ ''') ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ xml = StringIO(''' ++ ++ ++ ++ ++ Bingo! ++ ++ ++ ++ ''') ++ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) ++ ++ ++class ReleaseNodeUnittest(unittest.TestCase): ++ def testPseudoControl(self): ++ grd = grd_reader.Parse(StringIO(''' ++ ++ ++ ++ ++ Hello ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Bingo ++ ++ ++ ++ ++ ++ ++ '''), util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ ++ hello = grd.GetNodeById('IDS_HELLO') ++ aboutbox = grd.GetNodeById('IDD_ABOUTBOX') ++ bingo = grd.GetNodeById('IDS_BINGO') ++ menu = grd.GetNodeById('IDC_KLONKMENU') ++ ++ for node in [hello, aboutbox]: ++ self.failUnless(not node.PseudoIsAllowed()) ++ ++ for node in [bingo, menu]: ++ self.failUnless(node.PseudoIsAllowed()) ++ ++ # TODO(benrg): There was a test here that formatting hello and aboutbox with ++ # a pseudo language should fail, but they do not fail and the test was ++ # broken and failed to catch it. Fix this. ++ ++ # Should not raise an exception since pseudo is allowed ++ rc.FormatMessage(bingo, 'xyz-pseudo') ++ rc.FormatStructure(menu, 'xyz-pseudo', '.') ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/mock_brotli.py b/tools/grit/grit/node/mock_brotli.py +new file mode 100644 +index 0000000000..14237aab20 +--- /dev/null ++++ b/tools/grit/grit/node/mock_brotli.py +@@ -0,0 +1,10 @@ ++#!/usr/bin/env python ++# Copyright 2019 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Mock Brotli Executable for testing purposes.""" ++ ++import sys ++ ++sys.stdout.write('This has been mock compressed!') +diff --git a/tools/grit/grit/node/node_io.py b/tools/grit/grit/node/node_io.py +new file mode 100644 +index 0000000000..ccbc2c0647 +--- /dev/null ++++ b/tools/grit/grit/node/node_io.py +@@ -0,0 +1,117 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''The and elements. ++''' ++ ++from __future__ import print_function ++ ++import os ++ ++from grit import xtb_reader ++from grit.node import base ++ ++ ++class FileNode(base.Node): ++ '''A element.''' ++ ++ def __init__(self): ++ super(FileNode, self).__init__() ++ self.re = None ++ self.should_load_ = True ++ ++ def IsTranslation(self): ++ return True ++ ++ def GetLang(self): ++ return self.attrs['lang'] ++ ++ def DisableLoading(self): ++ self.should_load_ = False ++ ++ def MandatoryAttributes(self): ++ return ['path', 'lang'] ++ ++ def RunPostSubstitutionGatherer(self, debug=False): ++ if not self.should_load_: ++ return ++ ++ root = self.GetRoot() ++ defs = getattr(root, 'defines', {}) ++ target_platform = getattr(root, 'target_platform', '') ++ ++ xtb_file = open(self.ToRealPath(self.GetInputPath()), 'rb') ++ try: ++ lang = xtb_reader.Parse(xtb_file, ++ self.UberClique().GenerateXtbParserCallback( ++ self.attrs['lang'], debug=debug), ++ defs=defs, ++ target_platform=target_platform) ++ except: ++ print("Exception during parsing of %s" % self.GetInputPath()) ++ raise ++ # Translation console uses non-standard language codes 'iw' and 'no' for ++ # Hebrew and Norwegian Bokmal instead of 'he' and 'nb' used in Chrome. ++ # Note that some Chrome's .grd still use 'no' instead of 'nb', but 'nb' is ++ # always used for generated .pak files. ++ ALTERNATIVE_LANG_CODE_MAP = { 'he': 'iw', 'nb': 'no' } ++ assert (lang == self.attrs['lang'] or ++ lang == ALTERNATIVE_LANG_CODE_MAP[self.attrs['lang']]), ( ++ 'The XTB file you reference must contain messages in the language ' ++ 'specified\nby the \'lang\' attribute.') ++ ++ def GetInputPath(self): ++ return os.path.expandvars(self.attrs['path']) ++ ++ ++class OutputNode(base.Node): ++ '''An element.''' ++ ++ def MandatoryAttributes(self): ++ return ['filename', 'type'] ++ ++ def DefaultAttributes(self): ++ return { ++ 'lang' : '', # empty lang indicates all languages ++ 'language_section' : 'neutral', # defines a language neutral section ++ 'context' : '', ++ 'fallback_to_default_layout' : 'true', ++ } ++ ++ def GetType(self): ++ return self.attrs['type'] ++ ++ def GetLanguage(self): ++ '''Returns the language ID, default 'en'.''' ++ return self.attrs['lang'] ++ ++ def GetContext(self): ++ return self.attrs['context'] ++ ++ def GetFilename(self): ++ return self.attrs['filename'] ++ ++ def GetOutputFilename(self): ++ path = None ++ if hasattr(self, 'output_filename'): ++ path = self.output_filename ++ else: ++ path = self.attrs['filename'] ++ return os.path.expandvars(path) ++ ++ def GetFallbackToDefaultLayout(self): ++ return self.attrs['fallback_to_default_layout'].lower() == 'true' ++ ++ def _IsValidChild(self, child): ++ return isinstance(child, EmitNode) ++ ++class EmitNode(base.ContentNode): ++ ''' An element.''' ++ ++ def DefaultAttributes(self): ++ return { 'emit_type' : 'prepend'} ++ ++ def GetEmitType(self): ++ '''Returns the emit_type for this node. Default is 'append'.''' ++ return self.attrs['emit_type'] +diff --git a/tools/grit/grit/node/node_io_unittest.py b/tools/grit/grit/node/node_io_unittest.py +new file mode 100644 +index 0000000000..1f45e51af8 +--- /dev/null ++++ b/tools/grit/grit/node/node_io_unittest.py +@@ -0,0 +1,182 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for node_io.FileNode''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++import unittest ++ ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++from six import StringIO ++ ++from grit.node import misc ++from grit.node import node_io ++from grit.node import empty ++from grit import grd_reader ++from grit import util ++ ++ ++def _GetAllCliques(root_node): ++ """Return all cliques in the |root_node| tree.""" ++ ret = [] ++ for node in root_node: ++ ret.extend(node.GetCliques()) ++ return ret ++ ++ ++class FileNodeUnittest(unittest.TestCase): ++ def testGetPath(self): ++ root = misc.GritNode() ++ root.StartParsing(u'grit', None) ++ root.HandleAttribute(u'latest_public_release', u'0') ++ root.HandleAttribute(u'current_release', u'1') ++ root.HandleAttribute(u'base_dir', r'..\resource') ++ translations = empty.TranslationsNode() ++ translations.StartParsing(u'translations', root) ++ root.AddChild(translations) ++ file_node = node_io.FileNode() ++ file_node.StartParsing(u'file', translations) ++ file_node.HandleAttribute(u'path', r'flugel\kugel.pdf') ++ translations.AddChild(file_node) ++ root.EndParsing() ++ ++ self.failUnless(root.ToRealPath(file_node.GetInputPath()) == ++ util.normpath( ++ os.path.join(r'../resource', r'flugel/kugel.pdf'))) ++ ++ def VerifyCliquesContainEnglishAndFrenchAndNothingElse(self, cliques): ++ self.assertEqual(2, len(cliques)) ++ for clique in cliques: ++ self.assertEqual({'en', 'fr'}, set(clique.clique.keys())) ++ ++ def testLoadTranslations(self): ++ xml = ''' ++ ++ ++ ++ ++ ++ ++ Hello! ++ Hello %sJoi ++ ++ ++ ''' ++ grd = grd_reader.Parse(StringIO(xml), ++ util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ self.VerifyCliquesContainEnglishAndFrenchAndNothingElse(_GetAllCliques(grd)) ++ ++ def testIffyness(self): ++ grd = grd_reader.Parse(StringIO(''' ++ ++ ++ ++ ++ ++ ++ ++ ++ Hello! ++ Hello %sJoi ++ ++ ++ '''), util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ cliques = _GetAllCliques(grd) ++ self.assertEqual(2, len(cliques)) ++ for clique in cliques: ++ self.assertEqual({'en'}, set(clique.clique.keys())) ++ ++ grd.SetOutputLanguage('fr') ++ grd.RunGatherers() ++ self.VerifyCliquesContainEnglishAndFrenchAndNothingElse(_GetAllCliques(grd)) ++ ++ def testConditionalLoadTranslations(self): ++ xml = ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Hello! ++ Hello %s ++ Joi ++ ++ ++ ''' ++ grd = grd_reader.Parse(StringIO(xml), ++ util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ self.VerifyCliquesContainEnglishAndFrenchAndNothingElse(_GetAllCliques(grd)) ++ ++ def testConditionalOutput(self): ++ xml = ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Hello! ++ ++ ++ ''' ++ grd = grd_reader.Parse(StringIO(xml), ++ util.PathFromRoot('grit/test/data'), ++ defines={}) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ outputs = grd.GetChildrenOfType(node_io.OutputNode) ++ active = set(grd.ActiveDescendants()) ++ self.failUnless(outputs[0] in active) ++ self.failUnless(outputs[0].GetType() == 'rc_header') ++ self.failUnless(outputs[1] in active) ++ self.failUnless(outputs[1].GetType() == 'rc_all') ++ self.failUnless(outputs[2] not in active) ++ self.failUnless(outputs[2].GetType() == 'rc_all') ++ ++ # Verify that 'iw' and 'no' language codes in xtb files are mapped to 'he' and ++ # 'nb'. ++ def testLangCodeMapping(self): ++ grd = grd_reader.Parse(StringIO(''' ++ ++ ++ ++ ++ ++ ++ ++ ++ '''), util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ self.assertEqual([], _GetAllCliques(grd)) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/structure.py b/tools/grit/grit/node/structure.py +new file mode 100644 +index 0000000000..ec170faebb +--- /dev/null ++++ b/tools/grit/grit/node/structure.py +@@ -0,0 +1,375 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''The element. ++''' ++ ++from __future__ import print_function ++ ++import os ++import platform ++import re ++ ++from grit import exception ++from grit import util ++from grit.node import base ++from grit.node import variant ++ ++import grit.gather.admin_template ++import grit.gather.chrome_html ++import grit.gather.chrome_scaled_image ++import grit.gather.policy_json ++import grit.gather.rc ++import grit.gather.tr_html ++import grit.gather.txt ++ ++import grit.format.rc ++ ++# Type of the gatherer to use for each type attribute ++_GATHERERS = { ++ 'accelerators' : grit.gather.rc.Accelerators, ++ 'admin_template' : grit.gather.admin_template.AdmGatherer, ++ 'chrome_html' : grit.gather.chrome_html.ChromeHtml, ++ 'chrome_scaled_image' : grit.gather.chrome_scaled_image.ChromeScaledImage, ++ 'dialog' : grit.gather.rc.Dialog, ++ 'menu' : grit.gather.rc.Menu, ++ 'rcdata' : grit.gather.rc.RCData, ++ 'tr_html' : grit.gather.tr_html.TrHtml, ++ 'txt' : grit.gather.txt.TxtFile, ++ 'version' : grit.gather.rc.Version, ++ 'policy_template_metafile' : grit.gather.policy_json.PolicyJson, ++} ++ ++ ++# TODO(joi) Print a warning if the 'variant_of_revision' attribute indicates ++# that a skeleton variant is older than the original file. ++ ++ ++class StructureNode(base.Node): ++ '''A element.''' ++ ++ # Regular expression for a local variable definition. Each definition ++ # is of the form NAME=VALUE, where NAME cannot contain '=' or ',' and ++ # VALUE must escape all commas: ',' -> ',,'. Each variable definition ++ # should be separated by a comma with no extra whitespace. ++ # Example: THING1=foo,THING2=bar ++ variable_pattern = re.compile(r'([^,=\s]+)=((?:,,|[^,])*)') ++ ++ def __init__(self): ++ super(StructureNode, self).__init__() ++ ++ # Keep track of the last filename we flattened to, so we can ++ # avoid doing it more than once. ++ self._last_flat_filename = None ++ ++ # See _Substitute; this substituter is used for local variables and ++ # the root substituter is used for global variables. ++ self.substituter = None ++ ++ def _IsValidChild(self, child): ++ return isinstance(child, variant.SkeletonNode) ++ ++ def _ParseVariables(self, variables): ++ '''Parse a variable string into a dictionary.''' ++ matches = StructureNode.variable_pattern.findall(variables) ++ return dict((name, value.replace(',,', ',')) for name, value in matches) ++ ++ def EndParsing(self): ++ super(StructureNode, self).EndParsing() ++ ++ # Now that we have attributes and children, instantiate the gatherers. ++ gathertype = _GATHERERS[self.attrs['type']] ++ ++ self.gatherer = gathertype(self.attrs['file'], ++ self.attrs['name'], ++ self.attrs['encoding']) ++ self.gatherer.SetGrdNode(self) ++ self.gatherer.SetUberClique(self.UberClique()) ++ if hasattr(self.GetRoot(), 'defines'): ++ self.gatherer.SetDefines(self.GetRoot().defines) ++ self.gatherer.SetAttributes(self.attrs) ++ if self.ExpandVariables(): ++ self.gatherer.SetFilenameExpansionFunction(self._Substitute) ++ ++ # Parse local variables and instantiate the substituter. ++ if self.attrs['variables']: ++ variables = self.attrs['variables'] ++ self.substituter = util.Substituter() ++ self.substituter.AddSubstitutions(self._ParseVariables(variables)) ++ ++ self.skeletons = {} # Maps expressions to skeleton gatherers ++ for child in self.children: ++ assert isinstance(child, variant.SkeletonNode) ++ skel = gathertype(child.attrs['file'], ++ self.attrs['name'], ++ child.GetEncodingToUse(), ++ is_skeleton=True) ++ skel.SetGrdNode(self) # TODO(benrg): Or child? Only used for ToRealPath ++ skel.SetUberClique(self.UberClique()) ++ if hasattr(self.GetRoot(), 'defines'): ++ skel.SetDefines(self.GetRoot().defines) ++ if self.ExpandVariables(): ++ skel.SetFilenameExpansionFunction(self._Substitute) ++ self.skeletons[child.attrs['expr']] = skel ++ ++ def MandatoryAttributes(self): ++ return ['type', 'name', 'file'] ++ ++ def DefaultAttributes(self): ++ return { ++ 'encoding': 'cp1252', ++ 'exclude_from_rc': 'false', ++ 'line_end': 'unix', ++ 'output_encoding': 'utf-8', ++ 'generateid': 'true', ++ 'expand_variables': 'false', ++ 'output_filename': '', ++ 'fold_whitespace': 'false', ++ # Run an arbitrary command after translation is complete ++ # so that it doesn't interfere with what's in translation ++ # console. ++ 'run_command': '', ++ # Leave empty to run on all platforms, comma-separated ++ # for one or more specific platforms. Values must match ++ # output of platform.system(). ++ 'run_command_on_platforms': '', ++ 'allowexternalscript': 'false', ++ # preprocess takes the same code path as flattenhtml, but it ++ # disables any processing/inlining outside of and . ++ 'preprocess': 'false', ++ 'flattenhtml': 'false', ++ 'fallback_to_low_resolution': 'default', ++ 'variables': '', ++ 'compress': 'default', ++ 'use_base_dir': 'true', ++ } ++ ++ def IsExcludedFromRc(self): ++ return self.attrs['exclude_from_rc'] == 'true' ++ ++ def Process(self, output_dir): ++ """Writes the processed data to output_dir. In the case of a chrome_html ++ structure this will add references to other scale factors. If flattening ++ this will also write file references to be base64 encoded data URLs. The ++ name of the new file is returned.""" ++ filename = self.ToRealPath(self.GetInputPath()) ++ flat_filename = os.path.join(output_dir, ++ self.attrs['name'] + '_' + os.path.basename(filename)) ++ ++ if self._last_flat_filename == flat_filename: ++ return ++ ++ with open(flat_filename, 'wb') as outfile: ++ if self.ExpandVariables(): ++ text = self.gatherer.GetText() ++ file_contents = self._Substitute(text) ++ else: ++ file_contents = self.gatherer.GetData('', 'utf-8') ++ outfile.write(file_contents.encode('utf-8')) ++ ++ self._last_flat_filename = flat_filename ++ return os.path.basename(flat_filename) ++ ++ def GetLineEnd(self): ++ '''Returns the end-of-line character or characters for files output because ++ of this node ('\r\n', '\n', or '\r' depending on the 'line_end' attribute). ++ ''' ++ if self.attrs['line_end'] == 'unix': ++ return '\n' ++ elif self.attrs['line_end'] == 'windows': ++ return '\r\n' ++ elif self.attrs['line_end'] == 'mac': ++ return '\r' ++ else: ++ raise exception.UnexpectedAttribute( ++ "Attribute 'line_end' must be one of 'unix' (default), 'windows' or " ++ "'mac'") ++ ++ def GetCliques(self): ++ return self.gatherer.GetCliques() ++ ++ def GetDataPackValue(self, lang, encoding): ++ """Returns a bytes representation for a data_pack entry.""" ++ if self.ExpandVariables(): ++ text = self.gatherer.GetText() ++ data = util.Encode(self._Substitute(text), encoding) ++ else: ++ data = self.gatherer.GetData(lang, encoding) ++ if encoding != util.BINARY: ++ data = data.encode(encoding) ++ return self.CompressDataIfNeeded(data) ++ ++ def GetHtmlResourceFilenames(self): ++ """Returns a set of all filenames inlined by this node.""" ++ return self.gatherer.GetHtmlResourceFilenames() ++ ++ def GetInputPath(self): ++ path = self.gatherer.GetInputPath() ++ if path is None: ++ return path ++ ++ # Do not mess with absolute paths, that would make them invalid. ++ if os.path.isabs(os.path.expandvars(path)): ++ return path ++ ++ # We have no control over code that calls ToRealPath later, so convert ++ # the path to be relative against our basedir. ++ if self.attrs.get('use_base_dir', 'true') != 'true': ++ # Normalize the directory path to use the appropriate OS separator. ++ # GetBaseDir() may return paths\like\this or paths/like/this, since it is ++ # read from the base_dir attribute in the grd file. ++ norm_base_dir = util.normpath(self.GetRoot().GetBaseDir()) ++ return os.path.relpath(path, norm_base_dir) ++ ++ return path ++ ++ def GetTextualIds(self): ++ if not hasattr(self, 'gatherer'): ++ # This case is needed because this method is called by ++ # GritNode.ValidateUniqueIds before RunGatherers has been called. ++ # TODO(benrg): Fix this? ++ return [self.attrs['name']] ++ return self.gatherer.GetTextualIds() ++ ++ def RunPreSubstitutionGatherer(self, debug=False): ++ if debug: ++ print('Running gatherer %s for file %s' % ++ (type(self.gatherer), self.GetInputPath())) ++ ++ # Note: Parse() is idempotent, therefore this method is also. ++ self.gatherer.Parse() ++ for skel in self.skeletons.values(): ++ skel.Parse() ++ ++ def GetSkeletonGatherer(self): ++ '''Returns the gatherer for the alternate skeleton that should be used, ++ based on the expressions for selecting skeletons, or None if the skeleton ++ from the English version of the structure should be used. ++ ''' ++ for expr in self.skeletons: ++ if self.EvaluateCondition(expr): ++ return self.skeletons[expr] ++ return None ++ ++ def HasFileForLanguage(self): ++ return self.attrs['type'] in ['tr_html', 'admin_template', 'txt', ++ 'chrome_scaled_image', ++ 'chrome_html'] ++ ++ def ExpandVariables(self): ++ '''Variable expansion on structures is controlled by an XML attribute. ++ ++ However, old files assume that expansion is always on for Rc files. ++ ++ Returns: ++ A boolean. ++ ''' ++ attrs = self.GetRoot().attrs ++ if 'grit_version' in attrs and attrs['grit_version'] > 1: ++ return self.attrs['expand_variables'] == 'true' ++ else: ++ return (self.attrs['expand_variables'] == 'true' or ++ self.attrs['file'].lower().endswith('.rc')) ++ ++ def _Substitute(self, text): ++ '''Perform local and global variable substitution.''' ++ if self.substituter: ++ text = self.substituter.Substitute(text) ++ return self.GetRoot().GetSubstituter().Substitute(text) ++ ++ def RunCommandOnCurrentPlatform(self): ++ if self.attrs['run_command_on_platforms'] == '': ++ return True ++ else: ++ target_platforms = self.attrs['run_command_on_platforms'].split(',') ++ return platform.system() in target_platforms ++ ++ def FileForLanguage(self, lang, output_dir, create_file=True, ++ return_if_not_generated=True): ++ '''Returns the filename of the file associated with this structure, ++ for the specified language. ++ ++ Args: ++ lang: 'fr' ++ output_dir: 'c:\temp' ++ create_file: True ++ ''' ++ assert self.HasFileForLanguage() ++ # If the source language is requested, and no extra changes are requested, ++ # use the existing file. ++ if ((not lang or lang == self.GetRoot().GetSourceLanguage()) and ++ self.attrs['expand_variables'] != 'true' and ++ (not self.attrs['run_command'] or ++ not self.RunCommandOnCurrentPlatform())): ++ if return_if_not_generated: ++ input_path = self.GetInputPath() ++ if input_path is None: ++ return None ++ return self.ToRealPath(input_path) ++ else: ++ return None ++ ++ if self.attrs['output_filename'] != '': ++ filename = self.attrs['output_filename'] ++ else: ++ filename = os.path.basename(self.attrs['file']) ++ assert len(filename) ++ filename = '%s_%s' % (lang, filename) ++ filename = os.path.join(output_dir, filename) ++ ++ # Only create the output if it was requested by the call. ++ if create_file: ++ text = self.gatherer.Translate( ++ lang, ++ pseudo_if_not_available=self.PseudoIsAllowed(), ++ fallback_to_english=self.ShouldFallbackToEnglish(), ++ skeleton_gatherer=self.GetSkeletonGatherer()) ++ ++ file_contents = util.FixLineEnd(text, self.GetLineEnd()) ++ if self.ExpandVariables(): ++ # Note that we reapply substitution a second time here. ++ # This is because a) we need to look inside placeholders ++ # b) the substitution values are language-dependent ++ file_contents = self._Substitute(file_contents) ++ ++ with open(filename, 'wb') as file_object: ++ output_stream = util.WrapOutputStream(file_object, ++ self.attrs['output_encoding']) ++ output_stream.write(file_contents) ++ ++ if self.attrs['run_command'] and self.RunCommandOnCurrentPlatform(): ++ # Run arbitrary commands after translation is complete so that it ++ # doesn't interfere with what's in translation console. ++ command = self.attrs['run_command'] % {'filename': filename} ++ result = os.system(command) ++ assert result == 0, '"%s" failed.' % command ++ ++ return filename ++ ++ def IsResourceMapSource(self): ++ return True ++ ++ @staticmethod ++ def Construct(parent, name, type, file, encoding='cp1252'): ++ '''Creates a new node which is a child of 'parent', with attributes set ++ by parameters of the same name. ++ ''' ++ node = StructureNode() ++ node.StartParsing('structure', parent) ++ node.HandleAttribute('name', name) ++ node.HandleAttribute('type', type) ++ node.HandleAttribute('file', file) ++ node.HandleAttribute('encoding', encoding) ++ node.EndParsing() ++ return node ++ ++ def SubstituteMessages(self, substituter): ++ '''Propagates substitution to gatherer. ++ ++ Args: ++ substituter: a grit.util.Substituter object. ++ ''' ++ assert hasattr(self, 'gatherer') ++ if self.ExpandVariables(): ++ self.gatherer.SubstituteMessages(substituter) +diff --git a/tools/grit/grit/node/structure_unittest.py b/tools/grit/grit/node/structure_unittest.py +new file mode 100644 +index 0000000000..0e66dce37a +--- /dev/null ++++ b/tools/grit/grit/node/structure_unittest.py +@@ -0,0 +1,178 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for nodes. ++''' ++ ++from __future__ import print_function ++ ++import os ++import os.path ++import sys ++import zlib ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import platform ++import tempfile ++import unittest ++import struct ++ ++from grit import constants ++from grit import util ++from grit.node import brotli_util ++from grit.node import structure ++from grit.format import rc ++ ++ ++def checkIsGzipped(filename, compress_attr): ++ test_data_root = util.PathFromRoot('grit/testdata') ++ root = util.ParseGrdForUnittest( ++ ''' ++ ++ ++ ''' % (filename, compress_attr), ++ base_dir=test_data_root) ++ node, = root.GetChildrenOfType(structure.StructureNode) ++ node.RunPreSubstitutionGatherer() ++ compressed = node.GetDataPackValue(lang='en', encoding=util.BINARY) ++ ++ decompressed_data = zlib.decompress(compressed, 16 + zlib.MAX_WBITS) ++ expected = util.ReadFile(os.path.join(test_data_root, filename), util.BINARY) ++ return expected == decompressed_data ++ ++ ++class StructureUnittest(unittest.TestCase): ++ def testSkeleton(self): ++ grd = util.ParseGrdForUnittest(''' ++ ++ ++ ++ ++ ''', base_dir=util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('fr') ++ grd.RunGatherers() ++ transl = ''.join(rc.Format(grd, 'fr', '.')) ++ self.failUnless(transl.count('040704') and transl.count('110978')) ++ self.failUnless(transl.count('2005",IDC_STATIC')) ++ ++ def testRunCommandOnCurrentPlatform(self): ++ node = structure.StructureNode() ++ node.attrs = node.DefaultAttributes() ++ self.failUnless(node.RunCommandOnCurrentPlatform()) ++ node.attrs['run_command_on_platforms'] = 'Nosuch' ++ self.failIf(node.RunCommandOnCurrentPlatform()) ++ node.attrs['run_command_on_platforms'] = ( ++ 'Nosuch,%s,Othernot' % platform.system()) ++ self.failUnless(node.RunCommandOnCurrentPlatform()) ++ ++ def testVariables(self): ++ grd = util.ParseGrdForUnittest(''' ++ ++ ++ ''', base_dir=util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ node, = grd.GetChildrenOfType(structure.StructureNode) ++ filename = node.Process(tempfile.gettempdir()) ++ filepath = os.path.join(tempfile.gettempdir(), filename) ++ with open(filepath) as f: ++ result = f.read() ++ self.failUnlessEqual(('

Hello!

\n' ++ 'Some cool things are foo, bar, baz.\n' ++ 'Did you know that 2+2==4?\n' ++ '

\n' ++ ' Hello!\n' ++ '

\n'), result) ++ os.remove(filepath) ++ ++ def testGetPath(self): ++ base_dir = util.PathFromRoot('grit/testdata') ++ grd = util.ParseGrdForUnittest(''' ++ ++ ++ ''', base_dir) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ node, = grd.GetChildrenOfType(structure.StructureNode) ++ self.assertEqual(grd.ToRealPath(node.GetInputPath()), ++ os.path.abspath(os.path.join( ++ base_dir, r'structure_variables.html'))) ++ ++ def testGetPathNoBasedir(self): ++ base_dir = util.PathFromRoot('grit/testdata') ++ abs_path = os.path.join(base_dir, r'structure_variables.html') ++ rel_path = os.path.relpath(abs_path, os.getcwd()) ++ grd = util.ParseGrdForUnittest(''' ++ ++ ++ ''', util.PathFromRoot('grit/testdata')) ++ grd.SetOutputLanguage('en') ++ grd.RunGatherers() ++ node, = grd.GetChildrenOfType(structure.StructureNode) ++ self.assertEqual(grd.ToRealPath(node.GetInputPath()), ++ os.path.abspath(os.path.join( ++ base_dir, r'structure_variables.html'))) ++ ++ def testCompressGzip(self): ++ self.assertTrue(checkIsGzipped('test_text.txt', 'compress="gzip"')) ++ ++ def testCompressGzipByDefault(self): ++ self.assertTrue(checkIsGzipped('test_html.html', '')) ++ self.assertTrue(checkIsGzipped('test_js.js', '')) ++ self.assertTrue(checkIsGzipped('test_css.css', '')) ++ self.assertTrue(checkIsGzipped('test_svg.svg', '')) ++ ++ self.assertTrue(checkIsGzipped('test_html.html', 'compress="default"')) ++ self.assertTrue(checkIsGzipped('test_js.js', 'compress="default"')) ++ self.assertTrue(checkIsGzipped('test_css.css', 'compress="default"')) ++ self.assertTrue(checkIsGzipped('test_svg.svg', 'compress="default"')) ++ ++ def testCompressBrotli(self): ++ test_data_root = util.PathFromRoot('grit/testdata') ++ root = util.ParseGrdForUnittest( ++ ''' ++ ++ ++ ''', ++ base_dir=test_data_root) ++ node, = root.GetChildrenOfType(structure.StructureNode) ++ node.RunPreSubstitutionGatherer() ++ ++ # Using the mock brotli decompression executable. ++ brotli_util.SetBrotliCommand([sys.executable, ++ os.path.join(os.path.dirname(__file__), ++ 'mock_brotli.py')]) ++ compressed = node.GetDataPackValue(lang='en', encoding=util.BINARY) ++ # Assert that the first two bytes in compressed format is BROTLI_CONST. ++ self.assertEqual(constants.BROTLI_CONST, compressed[0:2]) ++ ++ # Compare the actual size of the uncompressed test data with ++ # the size appended during compression. ++ actual_size = len(util.ReadFile( ++ os.path.join(test_data_root, 'test_text.txt'), util.BINARY)) ++ uncompress_size = struct.unpack(' ++ ++ ''', base_dir=test_data_root) ++ node, = root.GetChildrenOfType(structure.StructureNode) ++ node.RunPreSubstitutionGatherer() ++ data = node.GetDataPackValue(lang='en', encoding=util.BINARY) ++ ++ self.assertEqual(util.ReadFile( ++ os.path.join(test_data_root, 'test_text.txt'), util.BINARY), data) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/node/variant.py b/tools/grit/grit/node/variant.py +new file mode 100644 +index 0000000000..9f5845f954 +--- /dev/null ++++ b/tools/grit/grit/node/variant.py +@@ -0,0 +1,41 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''The element. ++''' ++ ++from __future__ import print_function ++ ++from grit.node import base ++ ++ ++class SkeletonNode(base.Node): ++ '''A element.''' ++ ++ # TODO(joi) Support inline skeleton variants as CDATA instead of requiring ++ # a 'file' attribute. ++ ++ def MandatoryAttributes(self): ++ return ['expr', 'variant_of_revision', 'file'] ++ ++ def DefaultAttributes(self): ++ '''If not specified, 'encoding' will actually default to the parent node's ++ encoding. ++ ''' ++ return {'encoding' : ''} ++ ++ def _ContentType(self): ++ if 'file' in self.attrs: ++ return self._CONTENT_TYPE_NONE ++ else: ++ return self._CONTENT_TYPE_CDATA ++ ++ def GetEncodingToUse(self): ++ if self.attrs['encoding'] == '': ++ return self.parent.attrs['encoding'] ++ else: ++ return self.attrs['encoding'] ++ ++ def GetInputPath(self): ++ return self.attrs['file'] +diff --git a/tools/grit/grit/pseudo.py b/tools/grit/grit/pseudo.py +new file mode 100644 +index 0000000000..b607bfc6bb +--- /dev/null ++++ b/tools/grit/grit/pseudo.py +@@ -0,0 +1,129 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Pseudotranslation support. Our pseudotranslations are based on the ++P-language, which is a simple vowel-extending language. Examples of P: ++ - "hello" becomes "hepellopo" ++ - "howdie" becomes "hopowdiepie" ++ - "because" becomes "bepecaupause" (but in our implementation we don't ++ handle the silent e at the end so it actually would return "bepecaupausepe" ++ ++The P-language has the excellent quality of increasing the length of text ++by around 30-50% which is great for pseudotranslations, to stress test any ++GUI layouts etc. ++ ++To make the pseudotranslations more obviously "not a translation" and to make ++them exercise any code that deals with encodings, we also transform all English ++vowels into equivalent vowels with diacriticals on them (rings, acutes, ++diaresis, and circumflex), and we write the "p" in the P-language as a Hebrew ++character Qof. It looks sort of like a latin character "p" but it is outside ++the latin-1 character set which will stress character encoding bugs. ++''' ++ ++from __future__ import print_function ++ ++from grit import lazy_re ++from grit import tclib ++ ++ ++# An RFC language code for the P pseudolanguage. ++PSEUDO_LANG = 'x-P-pseudo' ++ ++# Hebrew character Qof. It looks kind of like a 'p' but is outside ++# the latin-1 character set which is good for our purposes. ++# TODO(joi) For now using P instead of Qof, because of some bugs it used. Find ++# a better solution, i.e. one that introduces a non-latin1 character into the ++# pseudotranslation. ++#_QOF = u'\u05e7' ++_QOF = u'P' ++ ++# How we map each vowel. ++_VOWELS = { ++ u'a' : u'\u00e5', # a with ring ++ u'e' : u'\u00e9', # e acute ++ u'i' : u'\u00ef', # i diaresis ++ u'o' : u'\u00f4', # o circumflex ++ u'u' : u'\u00fc', # u diaresis ++ u'y' : u'\u00fd', # y acute ++ u'A' : u'\u00c5', # A with ring ++ u'E' : u'\u00c9', # E acute ++ u'I' : u'\u00cf', # I diaresis ++ u'O' : u'\u00d4', # O circumflex ++ u'U' : u'\u00dc', # U diaresis ++ u'Y' : u'\u00dd', # Y acute ++} ++_VOWELS_KEYS = set(_VOWELS.keys()) ++ ++# Matches vowels and P ++_PSUB_RE = lazy_re.compile("(%s)" % '|'.join(_VOWELS_KEYS | {'P'})) ++ ++ ++# Pseudotranslations previously created. This is important for performance ++# reasons, especially since we routinely pseudotranslate the whole project ++# several or many different times for each build. ++_existing_translations = {} ++ ++ ++def MapVowels(str, also_p = False): ++ '''Returns a copy of 'str' where characters that exist as keys in _VOWELS ++ have been replaced with the corresponding value. If also_p is true, this ++ function will also change capital P characters into a Hebrew character Qof. ++ ''' ++ def Repl(match): ++ if match.group() == 'p': ++ if also_p: ++ return _QOF ++ else: ++ return 'p' ++ else: ++ return _VOWELS[match.group()] ++ return _PSUB_RE.sub(Repl, str) ++ ++ ++def PseudoString(str): ++ '''Returns a pseudotranslation of the provided string, in our enhanced ++ P-language.''' ++ if str in _existing_translations: ++ return _existing_translations[str] ++ ++ outstr = u'' ++ ix = 0 ++ while ix < len(str): ++ if str[ix] not in _VOWELS_KEYS: ++ outstr += str[ix] ++ ix += 1 ++ else: ++ # We want to treat consecutive vowels as one composite vowel. This is not ++ # always accurate e.g. in composite words but good enough. ++ consecutive_vowels = u'' ++ while ix < len(str) and str[ix] in _VOWELS_KEYS: ++ consecutive_vowels += str[ix] ++ ix += 1 ++ changed_vowels = MapVowels(consecutive_vowels) ++ outstr += changed_vowels ++ outstr += _QOF ++ outstr += changed_vowels ++ ++ _existing_translations[str] = outstr ++ return outstr ++ ++ ++def PseudoMessage(message): ++ '''Returns a pseudotranslation of the provided message. ++ ++ Args: ++ message: tclib.Message() ++ ++ Return: ++ tclib.Translation() ++ ''' ++ transl = tclib.Translation() ++ ++ for part in message.GetContent(): ++ if isinstance(part, tclib.Placeholder): ++ transl.AppendPlaceholder(part) ++ else: ++ transl.AppendText(PseudoString(part)) ++ ++ return transl +diff --git a/tools/grit/grit/pseudo_rtl.py b/tools/grit/grit/pseudo_rtl.py +new file mode 100644 +index 0000000000..2240b571de +--- /dev/null ++++ b/tools/grit/grit/pseudo_rtl.py +@@ -0,0 +1,104 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Pseudo RTL, (aka Fake Bidi) support. It simply wraps each word with ++Unicode RTL overrides. ++More info at https://sites.google.com/a/chromium.org/dev/Home/fake-bidi ++''' ++ ++from __future__ import print_function ++ ++import re ++ ++from grit import lazy_re ++from grit import tclib ++ ++ACCENTED_STRINGS = { ++ 'a': u"\u00e5", 'e': u"\u00e9", 'i': u"\u00ee", 'o': u"\u00f6", ++ 'u': u"\u00fb", 'A': u"\u00c5", 'E': u"\u00c9", 'I': u"\u00ce", ++ 'O': u"\u00d6", 'U': u"\u00db", 'c': u"\u00e7", 'd': u"\u00f0", ++ 'n': u"\u00f1", 'p': u"\u00fe", 'y': u"\u00fd", 'C': u"\u00c7", ++ 'D': u"\u00d0", 'N': u"\u00d1", 'P': u"\u00de", 'Y': u"\u00dd", ++ 'f': u"\u0192", 's': u"\u0161", 'S': u"\u0160", 'z': u"\u017e", ++ 'Z': u"\u017d", 'g': u"\u011d", 'G': u"\u011c", 'h': u"\u0125", ++ 'H': u"\u0124", 'j': u"\u0135", 'J': u"\u0134", 'k': u"\u0137", ++ 'K': u"\u0136", 'l': u"\u013c", 'L': u"\u013b", 't': u"\u0163", ++ 'T': u"\u0162", 'w': u"\u0175", 'W': u"\u0174", ++ '$': u"\u20ac", '?': u"\u00bf", 'R': u"\u00ae", r'!': u"\u00a1", ++} ++ ++# a character set containing the keys in ACCENTED_STRINGS ++# We should not accent characters in an escape sequence such as "\n". ++# To be safe, we assume every character following a backslash is an escaped ++# character. We also need to consider the case like "\\n", which means ++# a blackslash and a character "n", we will accent the character "n". ++TO_ACCENT = lazy_re.compile( ++ r'[%s]|\\[a-z\\]' % ''.join(ACCENTED_STRINGS.keys())) ++ ++# Lex text so that we don't interfere with html tokens and entities. ++# This lexing scheme will handle all well formed tags and entities, html or ++# xhtml. It will not handle comments, CDATA sections, or the unescaping tags: ++# script, style, xmp or listing. If any of those appear in messages, ++# something is wrong. ++TOKENS = [ lazy_re.compile( ++ '^%s' % pattern, # match at the beginning of input ++ re.I | re.S # html tokens are case-insensitive ++ ) ++ for pattern in ++ ( ++ # a run of non html special characters ++ r'[^<&]+', ++ # a tag ++ (r']+|"[^\"]*"|\'[^\']*\'))?' # attribute value ++ r')*\s*/?>'), ++ # an entity ++ r'&(?:[a-z]\w+|#\d+|#x[\da-f]+);', ++ # an html special character not part of a special sequence ++ r'.' ++ ) ] ++ ++ALPHABETIC_RUN = lazy_re.compile(r'([^\W0-9_]+)') ++ ++RLO = u'\u202e' ++PDF = u'\u202c' ++ ++def PseudoRTLString(text): ++ '''Returns a fake bidirectional version of the source string. This code is ++ based on accentString above, in turn copied from Frank Tang. ++ ''' ++ parts = [] ++ while text: ++ m = None ++ for token in TOKENS: ++ m = token.search(text) ++ if m: ++ part = m.group(0) ++ text = text[len(part):] ++ if part[0] not in ('<', '&'): ++ # not a tag or entity, so accent ++ part = ALPHABETIC_RUN.sub(lambda run: RLO + run.group() + PDF, part) ++ parts.append(part) ++ break ++ return ''.join(parts) ++ ++ ++def PseudoRTLMessage(message): ++ '''Returns a pseudo-RTL (aka Fake-Bidi) translation of the provided message. ++ ++ Args: ++ message: tclib.Message() ++ ++ Return: ++ tclib.Translation() ++ ''' ++ transl = tclib.Translation() ++ for part in message.GetContent(): ++ if isinstance(part, tclib.Placeholder): ++ transl.AppendPlaceholder(part) ++ else: ++ transl.AppendText(PseudoRTLString(part)) ++ ++ return transl +diff --git a/tools/grit/grit/pseudo_unittest.py b/tools/grit/grit/pseudo_unittest.py +new file mode 100644 +index 0000000000..b1d53ff401 +--- /dev/null ++++ b/tools/grit/grit/pseudo_unittest.py +@@ -0,0 +1,55 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.pseudo''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import unittest ++ ++from grit import pseudo ++from grit import tclib ++ ++ ++class PseudoUnittest(unittest.TestCase): ++ def testVowelMapping(self): ++ self.failUnless(pseudo.MapVowels('abebibobuby') == ++ u'\u00e5b\u00e9b\u00efb\u00f4b\u00fcb\u00fd') ++ self.failUnless(pseudo.MapVowels('ABEBIBOBUBY') == ++ u'\u00c5B\u00c9B\u00cfB\u00d4B\u00dcB\u00dd') ++ ++ def testPseudoString(self): ++ out = pseudo.PseudoString('hello') ++ self.failUnless(out == pseudo.MapVowels(u'hePelloPo', True)) ++ ++ def testConsecutiveVowels(self): ++ out = pseudo.PseudoString("beautiful weather, ain't it?") ++ self.failUnless(out == pseudo.MapVowels( ++ u"beauPeautiPifuPul weaPeathePer, aiPain't iPit?", 1)) ++ ++ def testCapitals(self): ++ out = pseudo.PseudoString("HOWDIE DOODIE, DR. JONES") ++ self.failUnless(out == pseudo.MapVowels( ++ u"HOPOWDIEPIE DOOPOODIEPIE, DR. JOPONEPES", 1)) ++ ++ def testPseudoMessage(self): ++ msg = tclib.Message(text='Hello USERNAME, how are you?', ++ placeholders=[ ++ tclib.Placeholder('USERNAME', '%s', 'Joi')]) ++ trans = pseudo.PseudoMessage(msg) ++ # TODO(joi) It would be nicer if 'you' -> 'youPou' instead of ++ # 'you' -> 'youPyou' and if we handled the silent e in 'are' ++ self.failUnless(trans.GetPresentableContent() == ++ pseudo.MapVowels( ++ u'HePelloPo USERNAME, hoPow aParePe youPyou?', 1)) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/shortcuts.py b/tools/grit/grit/shortcuts.py +new file mode 100644 +index 0000000000..0db2ce436c +--- /dev/null ++++ b/tools/grit/grit/shortcuts.py +@@ -0,0 +1,93 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Stuff to prevent conflicting shortcuts. ++''' ++ ++from __future__ import print_function ++ ++from grit import lazy_re ++ ++ ++class ShortcutGroup(object): ++ '''Manages a list of cliques that belong together in a single shortcut ++ group. Knows how to detect conflicting shortcut keys. ++ ''' ++ ++ # Matches shortcut keys, e.g. &J ++ SHORTCUT_RE = lazy_re.compile('([^&]|^)(&[A-Za-z])') ++ ++ def __init__(self, name): ++ self.name = name ++ # Map of language codes to shortcut keys used (which is a map of ++ # shortcut keys to counts). ++ self.keys_by_lang = {} ++ # List of cliques in this group ++ self.cliques = [] ++ ++ def AddClique(self, c): ++ for existing_clique in self.cliques: ++ if existing_clique.GetId() == c.GetId(): ++ # This happens e.g. when we have e.g. ++ # ++ # where only one will really be included in the output. ++ return ++ ++ self.cliques.append(c) ++ for (lang, msg) in c.clique.items(): ++ if lang not in self.keys_by_lang: ++ self.keys_by_lang[lang] = {} ++ keymap = self.keys_by_lang[lang] ++ ++ content = msg.GetRealContent() ++ keys = [groups[1] for groups in self.SHORTCUT_RE.findall(content)] ++ for key in keys: ++ key = key.upper() ++ if key in keymap: ++ keymap[key] += 1 ++ else: ++ keymap[key] = 1 ++ ++ def GenerateWarnings(self, tc_project): ++ # For any language that has more than one occurrence of any shortcut, ++ # make a list of the conflicting shortcuts. ++ problem_langs = {} ++ for (lang, keys) in self.keys_by_lang.items(): ++ for (key, count) in keys.items(): ++ if count > 1: ++ if lang not in problem_langs: ++ problem_langs[lang] = [] ++ problem_langs[lang].append(key) ++ ++ warnings = [] ++ if len(problem_langs): ++ warnings.append("WARNING - duplicate keys exist in shortcut group %s" % ++ self.name) ++ for (lang,keys) in problem_langs.items(): ++ warnings.append(" %6s duplicates: %s" % (lang, ', '.join(keys))) ++ return warnings ++ ++ ++def GenerateDuplicateShortcutsWarnings(uberclique, tc_project): ++ '''Given an UberClique and a project name, will print out helpful warnings ++ if there are conflicting shortcuts within shortcut groups in the provided ++ UberClique. ++ ++ Args: ++ uberclique: clique.UberClique() ++ tc_project: 'MyProjectNameInTheTranslationConsole' ++ ++ Returns: ++ ['warning line 1', 'warning line 2', ...] ++ ''' ++ warnings = [] ++ groups = {} ++ for c in uberclique.AllCliques(): ++ for group in c.shortcut_groups: ++ if group not in groups: ++ groups[group] = ShortcutGroup(group) ++ groups[group].AddClique(c) ++ for group in groups.values(): ++ warnings += group.GenerateWarnings(tc_project) ++ return warnings +diff --git a/tools/grit/grit/shortcuts_unittest.py b/tools/grit/grit/shortcuts_unittest.py +new file mode 100644 +index 0000000000..30e7c4f758 +--- /dev/null ++++ b/tools/grit/grit/shortcuts_unittest.py +@@ -0,0 +1,79 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.shortcuts ++''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import unittest ++ ++from six import StringIO ++ ++from grit import shortcuts ++from grit import clique ++from grit import tclib ++from grit.gather import rc ++ ++class ShortcutsUnittest(unittest.TestCase): ++ ++ def setUp(self): ++ self.uq = clique.UberClique() ++ ++ def testFunctionality(self): ++ c = self.uq.MakeClique(tclib.Message(text="Hello &there")) ++ c.AddToShortcutGroup('group_name') ++ c = self.uq.MakeClique(tclib.Message(text="Howdie &there partner")) ++ c.AddToShortcutGroup('group_name') ++ ++ warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT') ++ self.failUnless(warnings) ++ ++ def testAmpersandEscaping(self): ++ c = self.uq.MakeClique(tclib.Message(text="Hello &there")) ++ c.AddToShortcutGroup('group_name') ++ c = self.uq.MakeClique(tclib.Message(text="S&&T are the &letters S and T")) ++ c.AddToShortcutGroup('group_name') ++ ++ warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT') ++ self.failUnless(len(warnings) == 0) ++ ++ def testDialog(self): ++ dlg = rc.Dialog(StringIO('''\ ++IDD_SIDEBAR_RSS_PANEL_PROPPAGE DIALOGEX 0, 0, 239, 221 ++STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD ++FONT 8, "MS Shell Dlg", 400, 0, 0x1 ++BEGIN ++ PUSHBUTTON "Add &URL",IDC_SIDEBAR_RSS_ADD_URL,182,53,57,14 ++ EDITTEXT IDC_SIDEBAR_RSS_NEW_URL,0,53,178,15,ES_AUTOHSCROLL ++ PUSHBUTTON "&Remove",IDC_SIDEBAR_RSS_REMOVE,183,200,56,14 ++ PUSHBUTTON "&Edit",IDC_SIDEBAR_RSS_EDIT,123,200,56,14 ++ CONTROL "&Automatically add commonly viewed clips", ++ IDC_SIDEBAR_RSS_AUTO_ADD,"Button",BS_AUTOCHECKBOX | ++ BS_MULTILINE | WS_TABSTOP,0,200,120,17 ++ PUSHBUTTON "",IDC_SIDEBAR_RSS_HIDDEN,179,208,6,6,NOT WS_VISIBLE ++ LTEXT "You can display clips from blogs, news sites, and other online sources.", ++ IDC_STATIC,0,0,239,10 ++ LISTBOX IDC_SIDEBAR_DISPLAYED_FEED_LIST,0,69,239,127,LBS_SORT | ++ LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | ++ LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | ++ WS_TABSTOP ++ LTEXT "Add a clip from a recently viewed website by clicking Add Recent Clips.", ++ IDC_STATIC,0,13,141,19 ++ LTEXT "Or, if you know a site supports RSS or Atom, you can enter the RSS or Atom URL below and add it to your list of Web Clips.", ++ IDC_STATIC,0,33,239,18 ++ PUSHBUTTON "Add Recent &Clips (10)...", ++ IDC_SIDEBAR_RSS_ADD_RECENT_CLIPS,146,14,93,14 ++END'''), 'IDD_SIDEBAR_RSS_PANEL_PROPPAGE') ++ dlg.SetUberClique(self.uq) ++ dlg.Parse() ++ ++ warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT') ++ self.failUnless(len(warnings) == 0) ++ +diff --git a/tools/grit/grit/tclib.py b/tools/grit/grit/tclib.py +new file mode 100644 +index 0000000000..27ba366924 +--- /dev/null ++++ b/tools/grit/grit/tclib.py +@@ -0,0 +1,246 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Adaptation of the extern.tclib classes for our needs. ++''' ++ ++from __future__ import print_function ++ ++import functools ++import re ++ ++import six ++ ++from grit import exception ++from grit import lazy_re ++import grit.extern.tclib ++ ++ ++# Matches whitespace sequences which can be folded into a single whitespace ++# character. This matches single characters so that non-spaces are replaced ++# with spaces. ++_FOLD_WHITESPACE = re.compile(r'\s+') ++ ++# Caches compiled regexp used to split tags in BaseMessage.__init__() ++_RE_CACHE = {} ++ ++def Identity(i): ++ return i ++ ++ ++class BaseMessage(object): ++ '''Base class with methods shared by Message and Translation. ++ ''' ++ ++ def __init__(self, text='', placeholders=[], description='', meaning=''): ++ self.parts = [] ++ self.placeholders = [] ++ self.meaning = meaning ++ self.dirty = True # True if self.id is (or might be) wrong ++ self.id = 0 ++ self.SetDescription(description) ++ ++ if text != '': ++ if not placeholders or placeholders == []: ++ self.AppendText(text) ++ else: ++ tag_map = {} ++ for placeholder in placeholders: ++ tag_map[placeholder.GetPresentation()] = [placeholder, 0] ++ # This creates a regexp like '(TAG1|TAG2|TAG3)'. ++ # The tags have to be sorted in order of decreasing length, so that ++ # longer tags are substituted before shorter tags that happen to be ++ # substrings of the longer tag. ++ # E.g. "EXAMPLE_FOO_NAME" must be matched before "EXAMPLE_FOO", ++ # otherwise "EXAMPLE_FOO" splits "EXAMPLE_FOO_NAME" too. ++ tags = sorted(tag_map.keys(), ++ key=functools.cmp_to_key( ++ lambda x, y: len(x) - len(y) or ((x > y) - (x < y))), ++ reverse=True) ++ tag_re = '(' + '|'.join(tags) + ')' ++ ++ # This caching improves the time to build ++ # chrome/app:generated_resources from 21.562s to 17.672s on Linux. ++ compiled_re = _RE_CACHE.get(tag_re, None) ++ if compiled_re is None: ++ compiled_re = re.compile(tag_re) ++ _RE_CACHE[tag_re] = compiled_re ++ ++ chunked_text = compiled_re.split(text) ++ ++ for chunk in chunked_text: ++ if chunk: # ignore empty chunk ++ if chunk in tag_map: ++ self.AppendPlaceholder(tag_map[chunk][0]) ++ tag_map[chunk][1] += 1 # increase placeholder use count ++ else: ++ self.AppendText(chunk) ++ for key in tag_map: ++ assert tag_map[key][1] != 0 ++ ++ def GetRealContent(self, escaping_function=Identity): ++ '''Returns the original content, i.e. what your application and users ++ will see. ++ ++ Specify a function to escape each translateable bit, if you like. ++ ''' ++ bits = [] ++ for item in self.parts: ++ if isinstance(item, six.string_types): ++ bits.append(escaping_function(item)) ++ else: ++ bits.append(item.GetOriginal()) ++ return ''.join(bits) ++ ++ def GetPresentableContent(self): ++ presentable_content = [] ++ for part in self.parts: ++ if isinstance(part, Placeholder): ++ presentable_content.append(part.GetPresentation()) ++ else: ++ presentable_content.append(part) ++ return ''.join(presentable_content) ++ ++ def AppendPlaceholder(self, placeholder): ++ assert isinstance(placeholder, Placeholder) ++ dup = False ++ for other in self.GetPlaceholders(): ++ if other.presentation == placeholder.presentation: ++ assert other.original == placeholder.original ++ dup = True ++ ++ if not dup: ++ self.placeholders.append(placeholder) ++ self.parts.append(placeholder) ++ self.dirty = True ++ ++ def AppendText(self, text): ++ assert isinstance(text, six.string_types) ++ assert text != '' ++ ++ self.parts.append(text) ++ self.dirty = True ++ ++ def GetContent(self): ++ '''Returns the parts of the message. You may modify parts if you wish. ++ Note that you must not call GetId() on this object until you have finished ++ modifying the contents. ++ ''' ++ self.dirty = True # user might modify content ++ return self.parts ++ ++ def GetDescription(self): ++ return self.description ++ ++ def SetDescription(self, description): ++ self.description = _FOLD_WHITESPACE.sub(' ', description) ++ ++ def GetMeaning(self): ++ return self.meaning ++ ++ def GetId(self): ++ if self.dirty: ++ self.id = self.GenerateId() ++ self.dirty = False ++ return self.id ++ ++ def GenerateId(self): ++ return grit.extern.tclib.GenerateMessageId(self.GetPresentableContent(), ++ self.meaning) ++ ++ def GetPlaceholders(self): ++ return self.placeholders ++ ++ def FillTclibBaseMessage(self, msg): ++ msg.SetDescription(self.description.encode('utf-8')) ++ ++ for part in self.parts: ++ if isinstance(part, Placeholder): ++ ph = grit.extern.tclib.Placeholder( ++ part.presentation.encode('utf-8'), ++ part.original.encode('utf-8'), ++ part.example.encode('utf-8')) ++ msg.AppendPlaceholder(ph) ++ else: ++ msg.AppendText(part.encode('utf-8')) ++ ++ ++class Message(BaseMessage): ++ '''A message.''' ++ ++ def __init__(self, text='', placeholders=[], description='', meaning='', ++ assigned_id=None): ++ super(Message, self).__init__(text, placeholders, description, meaning) ++ self.assigned_id = assigned_id ++ ++ def ToTclibMessage(self): ++ msg = grit.extern.tclib.Message('utf-8', meaning=self.meaning) ++ self.FillTclibBaseMessage(msg) ++ return msg ++ ++ def GetId(self): ++ '''Use the assigned id if we have one.''' ++ if self.assigned_id: ++ return self.assigned_id ++ ++ return super(Message, self).GetId() ++ ++ def HasAssignedId(self): ++ '''Returns True if this message has an assigned id.''' ++ return bool(self.assigned_id) ++ ++ ++class Translation(BaseMessage): ++ '''A translation.''' ++ ++ def __init__(self, text='', id='', placeholders=[], description='', meaning=''): ++ super(Translation, self).__init__(text, placeholders, description, meaning) ++ self.id = id ++ ++ def GetId(self): ++ assert id != '', "ID has not been set." ++ return self.id ++ ++ def SetId(self, id): ++ self.id = id ++ ++ def ToTclibMessage(self): ++ msg = grit.extern.tclib.Message( ++ 'utf-8', id=self.id, meaning=self.meaning) ++ self.FillTclibBaseMessage(msg) ++ return msg ++ ++ ++class Placeholder(grit.extern.tclib.Placeholder): ++ '''Modifies constructor to accept a Unicode string ++ ''' ++ ++ # Must match placeholder presentation names ++ _NAME_RE = lazy_re.compile('^[A-Za-z0-9_]+$') ++ ++ def __init__(self, presentation, original, example): ++ '''Creates a new placeholder. ++ ++ Args: ++ presentation: 'USERNAME' ++ original: '%s' ++ example: 'Joi' ++ ''' ++ assert presentation != '' ++ assert original != '' ++ assert example != '' ++ if not self._NAME_RE.match(presentation): ++ raise exception.InvalidPlaceholderName(presentation) ++ self.presentation = presentation ++ self.original = original ++ self.example = example ++ ++ def GetPresentation(self): ++ return self.presentation ++ ++ def GetOriginal(self): ++ return self.original ++ ++ def GetExample(self): ++ return self.example +diff --git a/tools/grit/grit/tclib_unittest.py b/tools/grit/grit/tclib_unittest.py +new file mode 100644 +index 0000000000..7a08654e1b +--- /dev/null ++++ b/tools/grit/grit/tclib_unittest.py +@@ -0,0 +1,180 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.tclib''' ++ ++from __future__ import print_function ++ ++import sys ++import os.path ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) ++ ++import unittest ++ ++import six ++ ++from grit import tclib ++ ++from grit import exception ++import grit.extern.tclib ++ ++ ++class TclibUnittest(unittest.TestCase): ++ def testInit(self): ++ msg = tclib.Message(text=u'Hello Earthlings', ++ description='Greetings\n\t message') ++ self.failUnlessEqual(msg.GetPresentableContent(), 'Hello Earthlings') ++ self.failUnless(isinstance(msg.GetPresentableContent(), six.string_types)) ++ self.failUnlessEqual(msg.GetDescription(), 'Greetings message') ++ ++ def testGetAttr(self): ++ msg = tclib.Message() ++ msg.AppendText(u'Hello') # Tests __getattr__ ++ self.failUnless(msg.GetPresentableContent() == 'Hello') ++ self.failUnless(isinstance(msg.GetPresentableContent(), six.string_types)) ++ ++ def testAll(self): ++ text = u'Howdie USERNAME' ++ phs = [tclib.Placeholder(u'USERNAME', u'%s', 'Joi')] ++ msg = tclib.Message(text=text, placeholders=phs) ++ self.failUnless(msg.GetPresentableContent() == 'Howdie USERNAME') ++ ++ trans = tclib.Translation(text=text, placeholders=phs) ++ self.failUnless(trans.GetPresentableContent() == 'Howdie USERNAME') ++ self.failUnless(isinstance(trans.GetPresentableContent(), six.string_types)) ++ ++ def testUnicodeReturn(self): ++ text = u'\u00fe' ++ msg = tclib.Message(text=text) ++ self.failUnless(msg.GetPresentableContent() == text) ++ from_list = msg.GetContent()[0] ++ self.failUnless(from_list == text) ++ ++ def testRegressionTranslationInherited(self): ++ '''Regression tests a bug that was caused by grit.tclib.Translation ++ inheriting from the translation console's Translation object ++ instead of only owning an instance of it. ++ ''' ++ msg = tclib.Message(text=u"BLA1\r\nFrom: BLA2 \u00fe BLA3", ++ placeholders=[ ++ tclib.Placeholder('BLA1', '%s', '%s'), ++ tclib.Placeholder('BLA2', '%s', '%s'), ++ tclib.Placeholder('BLA3', '%s', '%s')]) ++ transl = tclib.Translation(text=msg.GetPresentableContent(), ++ placeholders=msg.GetPlaceholders()) ++ content = transl.GetContent() ++ self.failUnless(isinstance(content[3], six.string_types)) ++ ++ def testFingerprint(self): ++ # This has Windows line endings. That is on purpose. ++ id = grit.extern.tclib.GenerateMessageId( ++ 'Google Desktop for Enterprise\r\n' ++ 'All Rights Reserved\r\n' ++ '\r\n' ++ '---------\r\n' ++ 'Contents\r\n' ++ '---------\r\n' ++ 'This distribution contains the following files:\r\n' ++ '\r\n' ++ 'GoogleDesktopSetup.msi - Installation and setup program\r\n' ++ 'GoogleDesktop.adm - Group Policy administrative template file\r\n' ++ 'AdminGuide.pdf - Google Desktop for Enterprise administrative guide\r\n' ++ '\r\n' ++ '\r\n' ++ '--------------\r\n' ++ 'Documentation\r\n' ++ '--------------\r\n' ++ 'Full documentation and installation instructions are in the \r\n' ++ 'administrative guide, and also online at \r\n' ++ 'http://desktop.google.com/enterprise/adminguide.html.\r\n' ++ '\r\n' ++ '\r\n' ++ '------------------------\r\n' ++ 'IBM Lotus Notes Plug-In\r\n' ++ '------------------------\r\n' ++ 'The Lotus Notes plug-in is included in the release of Google \r\n' ++ 'Desktop for Enterprise. The IBM Lotus Notes Plug-in for Google \r\n' ++ 'Desktop indexes mail, calendar, task, contact and journal \r\n' ++ 'documents from Notes. Discussion documents including those from \r\n' ++ 'the discussion and team room templates can also be indexed by \r\n' ++ 'selecting an option from the preferences. Once indexed, this data\r\n' ++ 'will be returned in Google Desktop searches. The corresponding\r\n' ++ 'document can be opened in Lotus Notes from the Google Desktop \r\n' ++ 'results page.\r\n' ++ '\r\n' ++ 'Install: The plug-in will install automatically during the Google \r\n' ++ 'Desktop setup process if Lotus Notes is already installed. Lotus \r\n' ++ 'Notes must not be running in order for the install to occur. \r\n' ++ '\r\n' ++ 'Preferences: Preferences and selection of databases to index are\r\n' ++ 'set in the \'Google Desktop for Notes\' dialog reached through the \r\n' ++ '\'Actions\' menu.\r\n' ++ '\r\n' ++ 'Reindexing: Selecting \'Reindex all databases\' will index all the \r\n' ++ 'documents in each database again.\r\n' ++ '\r\n' ++ '\r\n' ++ 'Notes Plug-in Known Issues\r\n' ++ '---------------------------\r\n' ++ '\r\n' ++ 'If the \'Google Desktop for Notes\' item is not available from the \r\n' ++ 'Lotus Notes Actions menu, then installation was not successful. \r\n' ++ 'Installation consists of writing one file, notesgdsplugin.dll, to \r\n' ++ 'the Notes application directory and a setting to the notes.ini \r\n' ++ 'configuration file. The most likely cause of an unsuccessful \r\n' ++ 'installation is that the installer was not able to locate the \r\n' ++ 'notes.ini file. Installation will complete if the user closes Notes\r\n' ++ 'and manually adds the following setting to this file on a new line:\r\n' ++ 'AddinMenus=notegdsplugin.dll\r\n' ++ '\r\n' ++ 'If the notesgdsplugin.dll file is not in the application directory\r\n' ++ r'(e.g., C:\Program Files\Lotus\Notes) after Google Desktop \r\n' ++ 'installation, it is likely that Notes was not installed correctly. \r\n' ++ '\r\n' ++ 'Only local databases can be indexed. If they can be determined, \r\n' ++ 'the user\'s local mail file and address book will be included in the\r\n' ++ 'list automatically. Mail archives and other databases must be \r\n' ++ 'added with the \'Add\' button.\r\n' ++ '\r\n' ++ 'Some users may experience performance issues during the initial \r\n' ++ 'indexing of a database. The \'Perform the initial index of a \r\n' ++ 'database only when I\'m idle\' option will limit the indexing process\r\n' ++ 'to times when the user is not using the machine. If this does not \r\n' ++ 'alleviate the problem or the user would like to continually index \r\n' ++ 'but just do so more slowly or quickly, the GoogleWaitTime notes.ini\r\n' ++ 'value can be set. Increasing the GoogleWaitTime value will slow \r\n' ++ 'down the indexing process, and lowering the value will speed it up.\r\n' ++ 'A value of zero causes the fastest possible indexing. Removing the\r\n' ++ 'ini parameter altogether returns it to the default (20).\r\n' ++ '\r\n' ++ 'Crashes have been known to occur with certain types of history \r\n' ++ 'bookmarks. If the Notes client seems to crash randomly, try \r\n' ++ 'disabling the \'Index note history\' option. If it crashes before,\r\n' ++ 'you can get to the preferences, add the following line to your \r\n' ++ 'notes.ini file:\r\n' ++ 'GDSNoIndexHistory=1\r\n') ++ self.assertEqual(id, '7660964495923572726') ++ ++ def testPlaceholderNameChecking(self): ++ try: ++ ph = tclib.Placeholder('BINGO BONGO', 'bla', 'bla') ++ raise Exception("We shouldn't get here") ++ except exception.InvalidPlaceholderName: ++ pass # Expect exception to be thrown because presentation contained space ++ ++ def testTagsWithCommonSubstring(self): ++ word = 'ABCDEFGHIJ' ++ text = ' '.join([word[:i] for i in range(1, 11)]) ++ phs = [tclib.Placeholder(word[:i], str(i), str(i)) for i in range(1, 11)] ++ try: ++ msg = tclib.Message(text=text, placeholders=phs) ++ self.failUnless(msg.GetRealContent() == '1 2 3 4 5 6 7 8 9 10') ++ except: ++ self.fail('tclib.Message() should handle placeholders that are ' ++ 'substrings of each other') ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/test_suite_all.py b/tools/grit/grit/test_suite_all.py +new file mode 100644 +index 0000000000..3bfe2a79d5 +--- /dev/null ++++ b/tools/grit/grit/test_suite_all.py +@@ -0,0 +1,34 @@ ++#!/usr/bin/env python3 ++# Copyright (c) 2011 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit test suite that collects all test cases for GRIT.''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++ ++ ++CUR_DIR = os.path.dirname(os.path.realpath(__file__)) ++SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(CUR_DIR))) ++TYP_DIR = os.path.join( ++ SRC_DIR, 'third_party', 'catapult', 'third_party', 'typ') ++ ++if TYP_DIR not in sys.path: ++ sys.path.insert(0, TYP_DIR) ++ ++ ++import typ # pylint: disable=import-error,unused-import ++ ++ ++def main(args): ++ return typ.main( ++ top_level_dirs=[os.path.join(CUR_DIR, '..')], ++ skip=['grit.format.gen_predetermined_ids_unittest.*', ++ 'grit.pseudo_unittest.*'] ++ ) ++ ++if __name__ == '__main__': ++ sys.exit(main(sys.argv[1:])) +diff --git a/tools/grit/grit/testdata/GoogleDesktop.adm b/tools/grit/grit/testdata/GoogleDesktop.adm +new file mode 100644 +index 0000000000..082f56bb1a +--- /dev/null ++++ b/tools/grit/grit/testdata/GoogleDesktop.adm +@@ -0,0 +1,945 @@ ++CLASS MACHINE ++ CATEGORY !!Cat_Google ++ CATEGORY !!Cat_GoogleDesktopSearch ++ KEYNAME "Software\Policies\Google\Google Desktop" ++ ++ CATEGORY !!Cat_Preferences ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences" ++ ++ CATEGORY !!Cat_IndexAndCaptureControl ++ POLICY !!Blacklist_Email ++ EXPLAIN !!Explain_Blacklist_Email ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ VALUENAME "1" ++ END POLICY ++ ++ POLICY !!Blacklist_Gmail ++ EXPLAIN !!Explain_Blacklist_Gmail ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-pop" ++ VALUENAME "gmail" ++ END POLICY ++ ++ POLICY !!Blacklist_WebHistory ++ EXPLAIN !!Explain_Blacklist_WebHistory ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ VALUENAME "2" ++ END POLICY ++ ++ POLICY !!Blacklist_Chat ++ EXPLAIN !!Explain_Blacklist_Chat ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "3" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Text ++ EXPLAIN !!Explain_Blacklist_Text ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "4" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Media ++ EXPLAIN !!Explain_Blacklist_Media ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "5" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Contact ++ EXPLAIN !!Explain_Blacklist_Contact ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "9" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Calendar ++ EXPLAIN !!Explain_Blacklist_Calendar ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "10" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Task ++ EXPLAIN !!Explain_Blacklist_Task ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "11" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Note ++ EXPLAIN !!Explain_Blacklist_Note ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "12" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Journal ++ EXPLAIN !!Explain_Blacklist_Journal ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "13" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Word ++ EXPLAIN !!Explain_Blacklist_Word ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "DOC" ++ END POLICY ++ ++ POLICY !!Blacklist_Excel ++ EXPLAIN !!Explain_Blacklist_Excel ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "XLS" ++ END POLICY ++ ++ POLICY !!Blacklist_Powerpoint ++ EXPLAIN !!Explain_Blacklist_Powerpoint ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "PPT" ++ END POLICY ++ ++ POLICY !!Blacklist_PDF ++ EXPLAIN !!Explain_Blacklist_PDF ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "PDF" ++ END POLICY ++ ++ POLICY !!Blacklist_ZIP ++ EXPLAIN !!Explain_Blacklist_ZIP ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "ZIP" ++ END POLICY ++ ++ POLICY !!Blacklist_HTTPS ++ EXPLAIN !!Explain_Blacklist_HTTPS ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-3" ++ VALUENAME "HTTPS" ++ END POLICY ++ ++ POLICY !!Blacklist_PasswordProtectedOffice ++ EXPLAIN !!Explain_Blacklist_PasswordProtectedOffice ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-13" ++ VALUENAME "SECUREOFFICE" ++ END POLICY ++ ++ POLICY !!Blacklist_URI_Contains ++ EXPLAIN !!Explain_Blacklist_URI_Contains ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-6" ++ PART !!Blacklist_URI_Contains LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Blacklist_Extensions ++ EXPLAIN !!Explain_Blacklist_Extensions ++ PART !!Blacklist_Extensions EDITTEXT ++ VALUENAME "file_extensions_to_skip" ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Disallow_UserSearchLocations ++ EXPLAIN !!Explain_Disallow_UserSearchLocations ++ VALUENAME user_search_locations ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Search_Location_Whitelist ++ EXPLAIN !!Explain_Search_Location_Whitelist ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\policy_search_location_whitelist" ++ PART !!Search_Locations_Whitelist LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Email_Retention ++ EXPLAIN !!Explain_Email_Retention ++ PART !!Email_Retention_Edit NUMERIC ++ VALUENAME "email_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Webpage_Retention ++ EXPLAIN !!Explain_Webpage_Retention ++ PART !!Webpage_Retention_Edit NUMERIC ++ VALUENAME "webpage_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!File_Retention ++ EXPLAIN !!Explain_File_Retention ++ PART !!File_Retention_Edit NUMERIC ++ VALUENAME "file_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!IM_Retention ++ EXPLAIN !!Explain_IM_Retention ++ PART !!IM_Retention_Edit NUMERIC ++ VALUENAME "im_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Remove_Deleted_Items ++ EXPLAIN !!Explain_Remove_Deleted_Items ++ VALUENAME remove_deleted_items ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Allow_Simultaneous_Indexing ++ EXPLAIN !!Explain_Allow_Simultaneous_Indexing ++ VALUENAME simultaneous_indexing ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ END CATEGORY ++ ++ POLICY !!Pol_TurnOffAdvancedFeatures ++ EXPLAIN !!Explain_TurnOffAdvancedFeatures ++ VALUENAME error_report_on ++ VALUEON NUMERIC 0 ++ END POLICY ++ ++ POLICY !!Pol_TurnOffImproveGd ++ EXPLAIN !!Explain_TurnOffImproveGd ++ VALUENAME improve_gd ++ VALUEON NUMERIC 0 ++ VALUEOFF NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_NoPersonalizationInfo ++ EXPLAIN !!Explain_NoPersonalizationInfo ++ VALUENAME send_personalization_info ++ VALUEON NUMERIC 0 ++ VALUEOFF NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_OneBoxMode ++ EXPLAIN !!Explain_OneBoxMode ++ VALUENAME onebox_mode ++ VALUEON NUMERIC 0 ++ END POLICY ++ ++ POLICY !!Pol_EncryptIndex ++ EXPLAIN !!Explain_EncryptIndex ++ VALUENAME encrypt_index ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Hyper ++ EXPLAIN !!Explain_Hyper ++ VALUENAME hyper_off ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Display_Mode ++ EXPLAIN !!Explain_Display_Mode ++ PART !!Pol_Display_Mode DROPDOWNLIST ++ VALUENAME display_mode ++ ITEMLIST ++ NAME !!Sidebar VALUE NUMERIC 1 ++ NAME !!Deskbar VALUE NUMERIC 8 ++ NAME !!FloatingDeskbar VALUE NUMERIC 4 ++ NAME !!None VALUE NUMERIC 0 ++ END ITEMLIST ++ END PART ++ END POLICY ++ ++ END CATEGORY ; Preferences ++ ++ CATEGORY !!Cat_Enterprise ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise" ++ ++ POLICY !!Pol_Autoupdate ++ EXPLAIN !!Explain_Autoupdate ++ VALUENAME autoupdate_host ++ VALUEON "" ++ END POLICY ++ ++ POLICY !!Pol_AutoupdateAsSystem ++ EXPLAIN !!Explain_AutoupdateAsSystem ++ VALUENAME autoupdate_impersonate_user ++ VALUEON NUMERIC 0 ++ VALUEOFF NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_EnterpriseTab ++ EXPLAIN !!Explain_EnterpriseTab ++ PART !!EnterpriseTabText EDITTEXT ++ VALUENAME enterprise_tab_text ++ END PART ++ PART !!EnterpriseTabHomepage EDITTEXT ++ VALUENAME enterprise_tab_homepage ++ END PART ++ PART !!EnterpriseTabHomepageQuery CHECKBOX ++ VALUENAME enterprise_tab_homepage_query ++ END PART ++ PART !!EnterpriseTabResults EDITTEXT ++ VALUENAME enterprise_tab_results ++ END PART ++ PART !!EnterpriseTabResultsQuery CHECKBOX ++ VALUENAME enterprise_tab_results_query ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_GSAHosts ++ EXPLAIN !!Explain_GSAHosts ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\GSAHosts" ++ PART !!Pol_GSAHosts LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_PolicyUnawareClientProhibitedFlag ++ EXPLAIN !!Explain_PolicyUnawareClientProhibitedFlag ++ KEYNAME "Software\Policies\Google\Google Desktop" ++ VALUENAME PolicyUnawareClientProhibitedFlag ++ END POLICY ++ ++ POLICY !!Pol_MinimumAllowedVersion ++ EXPLAIN !!Explain_MinimumAllowedVersion ++ PART !!Pol_MinimumAllowedVersion EDITTEXT ++ VALUENAME minimum_allowed_version ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_MaximumAllowedVersion ++ EXPLAIN !!Explain_MaximumAllowedVersion ++ PART !!Pol_MaximumAllowedVersion EDITTEXT ++ VALUENAME maximum_allowed_version ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Disallow_Gadgets ++ EXPLAIN !!Explain_Disallow_Gadgets ++ VALUENAME disallow_gadgets ++ VALUEON NUMERIC 1 ++ PART !!Disallow_Only_Non_Builtin_Gadgets CHECKBOX DEFCHECKED ++ VALUENAME disallow_only_non_builtin_gadgets ++ VALUEON NUMERIC 1 ++ VALUEOFF NUMERIC 0 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Gadget_Whitelist ++ EXPLAIN !!Explain_Gadget_Whitelist ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\gadget_whitelist" ++ PART !!Pol_Gadget_Whitelist LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Gadget_Install_Confirmation_Whitelist ++ EXPLAIN !!Explain_Gadget_Install_Confirmation_Whitelist ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\install_confirmation_whitelist" ++ PART !!Pol_Gadget_Install_Confirmation_Whitelist LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Alternate_User_Data_Dir ++ EXPLAIN !!Explain_Alternate_User_Data_Dir ++ PART !!Pol_Alternate_User_Data_Dir EDITTEXT ++ VALUENAME alternate_user_data_dir ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_MaxAllowedOutlookConnections ++ EXPLAIN !!Explain_MaxAllowedOutlookConnections ++ PART !!Pol_MaxAllowedOutlookConnections NUMERIC ++ VALUENAME max_allowed_outlook_connections ++ MIN 1 MAX 65535 DEFAULT 400 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_DisallowSsdService ++ EXPLAIN !!Explain_DisallowSsdService ++ VALUENAME disallow_ssd_service ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_DisallowSsdOutbound ++ EXPLAIN !!Explain_DisallowSsdOutbound ++ VALUENAME disallow_ssd_outbound ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Disallow_Store_Gadget_Service ++ EXPLAIN !!Explain_Disallow_Store_Gadget_Service ++ VALUENAME disallow_store_gadget_service ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_MaxExchangeIndexingRate ++ EXPLAIN !!Explain_MaxExchangeIndexingRate ++ PART !!Pol_MaxExchangeIndexingRate NUMERIC ++ VALUENAME max_exchange_indexing_rate ++ MIN 1 MAX 1000 DEFAULT 60 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_EnableSafeweb ++ EXPLAIN !!Explain_Safeweb ++ VALUENAME safe_browsing ++ VALUEON NUMERIC 1 ++ VALUEOFF NUMERIC 0 ++ END POLICY ++ ++ END CATEGORY ; Enterprise ++ ++ END CATEGORY ; GoogleDesktopSearch ++ END CATEGORY ; Google ++ ++ ++CLASS USER ++ CATEGORY !!Cat_Google ++ CATEGORY !!Cat_GoogleDesktopSearch ++ KEYNAME "Software\Policies\Google\Google Desktop" ++ ++ CATEGORY !!Cat_Preferences ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences" ++ ++ CATEGORY !!Cat_IndexAndCaptureControl ++ POLICY !!Blacklist_Email ++ EXPLAIN !!Explain_Blacklist_Email ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ VALUENAME "1" ++ END POLICY ++ ++ POLICY !!Blacklist_Gmail ++ EXPLAIN !!Explain_Blacklist_Gmail ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-pop" ++ VALUENAME "gmail" ++ END POLICY ++ ++ POLICY !!Blacklist_WebHistory ++ EXPLAIN !!Explain_Blacklist_WebHistory ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ VALUENAME "2" ++ END POLICY ++ ++ POLICY !!Blacklist_Chat ++ EXPLAIN !!Explain_Blacklist_Chat ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "3" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Text ++ EXPLAIN !!Explain_Blacklist_Text ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "4" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Media ++ EXPLAIN !!Explain_Blacklist_Media ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "5" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Contact ++ EXPLAIN !!Explain_Blacklist_Contact ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "9" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Calendar ++ EXPLAIN !!Explain_Blacklist_Calendar ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "10" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Task ++ EXPLAIN !!Explain_Blacklist_Task ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "11" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Note ++ EXPLAIN !!Explain_Blacklist_Note ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "12" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Journal ++ EXPLAIN !!Explain_Blacklist_Journal ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" ++ ACTIONLISTON ++ VALUENAME "13" VALUE NUMERIC 1 ++ END ACTIONLISTON ++ END POLICY ++ ++ POLICY !!Blacklist_Word ++ EXPLAIN !!Explain_Blacklist_Word ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "DOC" ++ END POLICY ++ ++ POLICY !!Blacklist_Excel ++ EXPLAIN !!Explain_Blacklist_Excel ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "XLS" ++ END POLICY ++ ++ POLICY !!Blacklist_Powerpoint ++ EXPLAIN !!Explain_Blacklist_Powerpoint ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "PPT" ++ END POLICY ++ ++ POLICY !!Blacklist_PDF ++ EXPLAIN !!Explain_Blacklist_PDF ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "PDF" ++ END POLICY ++ ++ POLICY !!Blacklist_ZIP ++ EXPLAIN !!Explain_Blacklist_ZIP ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" ++ VALUENAME "ZIP" ++ END POLICY ++ ++ POLICY !!Blacklist_HTTPS ++ EXPLAIN !!Explain_Blacklist_HTTPS ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-3" ++ VALUENAME "HTTPS" ++ END POLICY ++ ++ POLICY !!Blacklist_PasswordProtectedOffice ++ EXPLAIN !!Explain_Blacklist_PasswordProtectedOffice ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-13" ++ VALUENAME "SECUREOFFICE" ++ END POLICY ++ ++ POLICY !!Blacklist_URI_Contains ++ EXPLAIN !!Explain_Blacklist_URI_Contains ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-6" ++ PART !!Blacklist_URI_Contains LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Blacklist_Extensions ++ EXPLAIN !!Explain_Blacklist_Extensions ++ PART !!Blacklist_Extensions EDITTEXT ++ VALUENAME "file_extensions_to_skip" ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Disallow_UserSearchLocations ++ EXPLAIN !!Explain_Disallow_UserSearchLocations ++ VALUENAME user_search_locations ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Search_Location_Whitelist ++ EXPLAIN !!Explain_Search_Location_Whitelist ++ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\policy_search_location_whitelist" ++ PART !!Search_Locations_Whitelist LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Email_Retention ++ EXPLAIN !!Explain_Email_Retention ++ PART !!Email_Retention_Edit NUMERIC ++ VALUENAME "email_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Webpage_Retention ++ EXPLAIN !!Explain_Webpage_Retention ++ PART !!Webpage_Retention_Edit NUMERIC ++ VALUENAME "webpage_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!File_Retention ++ EXPLAIN !!Explain_File_Retention ++ PART !!File_Retention_Edit NUMERIC ++ VALUENAME "file_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!IM_Retention ++ EXPLAIN !!Explain_IM_Retention ++ PART !!IM_Retention_Edit NUMERIC ++ VALUENAME "im_days_to_retain" ++ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Remove_Deleted_Items ++ EXPLAIN !!Explain_Remove_Deleted_Items ++ VALUENAME remove_deleted_items ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Allow_Simultaneous_Indexing ++ EXPLAIN !!Explain_Allow_Simultaneous_Indexing ++ VALUENAME simultaneous_indexing ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ END CATEGORY ++ ++ POLICY !!Pol_TurnOffAdvancedFeatures ++ EXPLAIN !!Explain_TurnOffAdvancedFeatures ++ VALUENAME error_report_on ++ VALUEON NUMERIC 0 ++ END POLICY ++ ++ POLICY !!Pol_TurnOffImproveGd ++ EXPLAIN !!Explain_TurnOffImproveGd ++ VALUENAME improve_gd ++ VALUEON NUMERIC 0 ++ VALUEOFF NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_NoPersonalizationInfo ++ EXPLAIN !!Explain_NoPersonalizationInfo ++ VALUENAME send_personalization_info ++ VALUEON NUMERIC 0 ++ VALUEOFF NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_OneBoxMode ++ EXPLAIN !!Explain_OneBoxMode ++ VALUENAME onebox_mode ++ VALUEON NUMERIC 0 ++ END POLICY ++ ++ POLICY !!Pol_EncryptIndex ++ EXPLAIN !!Explain_EncryptIndex ++ VALUENAME encrypt_index ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Hyper ++ EXPLAIN !!Explain_Hyper ++ VALUENAME hyper_off ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Display_Mode ++ EXPLAIN !!Explain_Display_Mode ++ PART !!Pol_Display_Mode DROPDOWNLIST ++ VALUENAME display_mode ++ ITEMLIST ++ NAME !!Sidebar VALUE NUMERIC 1 ++ NAME !!Deskbar VALUE NUMERIC 8 ++ NAME !!FloatingDeskbar VALUE NUMERIC 4 ++ NAME !!None VALUE NUMERIC 0 ++ END ITEMLIST ++ END PART ++ END POLICY ++ ++ END CATEGORY ; Preferences ++ ++ CATEGORY !!Cat_Enterprise ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise" ++ ++ POLICY !!Pol_Autoupdate ++ EXPLAIN !!Explain_Autoupdate ++ VALUENAME autoupdate_host ++ VALUEON "" ++ END POLICY ++ ++ POLICY !!Pol_AutoupdateAsSystem ++ EXPLAIN !!Explain_AutoupdateAsSystem ++ VALUENAME autoupdate_impersonate_user ++ VALUEON NUMERIC 0 ++ VALUEOFF NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_EnterpriseTab ++ EXPLAIN !!Explain_EnterpriseTab ++ PART !!EnterpriseTabText EDITTEXT ++ VALUENAME enterprise_tab_text ++ END PART ++ PART !!EnterpriseTabHomepage EDITTEXT ++ VALUENAME enterprise_tab_homepage ++ END PART ++ PART !!EnterpriseTabHomepageQuery CHECKBOX ++ VALUENAME enterprise_tab_homepage_query ++ END PART ++ PART !!EnterpriseTabResults EDITTEXT ++ VALUENAME enterprise_tab_results ++ END PART ++ PART !!EnterpriseTabResultsQuery CHECKBOX ++ VALUENAME enterprise_tab_results_query ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_GSAHosts ++ EXPLAIN !!Explain_GSAHosts ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\GSAHosts" ++ PART !!Pol_GSAHosts LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Disallow_Gadgets ++ EXPLAIN !!Explain_Disallow_Gadgets ++ VALUENAME disallow_gadgets ++ VALUEON NUMERIC 1 ++ PART !!Disallow_Only_Non_Builtin_Gadgets CHECKBOX DEFCHECKED ++ VALUENAME disallow_only_non_builtin_gadgets ++ VALUEON NUMERIC 1 ++ VALUEOFF NUMERIC 0 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Gadget_Whitelist ++ EXPLAIN !!Explain_Gadget_Whitelist ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\gadget_whitelist" ++ PART !!Pol_Gadget_Whitelist LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Gadget_Install_Confirmation_Whitelist ++ EXPLAIN !!Explain_Gadget_Install_Confirmation_Whitelist ++ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\install_confirmation_whitelist" ++ PART !!Pol_Gadget_Install_Confirmation_Whitelist LISTBOX ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_Alternate_User_Data_Dir ++ EXPLAIN !!Explain_Alternate_User_Data_Dir ++ PART !!Pol_Alternate_User_Data_Dir EDITTEXT ++ VALUENAME alternate_user_data_dir ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_MaxAllowedOutlookConnections ++ EXPLAIN !!Explain_MaxAllowedOutlookConnections ++ PART !!Pol_MaxAllowedOutlookConnections NUMERIC ++ VALUENAME max_allowed_outlook_connections ++ MIN 1 MAX 65535 DEFAULT 400 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_DisallowSsdService ++ EXPLAIN !!Explain_DisallowSsdService ++ VALUENAME disallow_ssd_service ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_DisallowSsdOutbound ++ EXPLAIN !!Explain_DisallowSsdOutbound ++ VALUENAME disallow_ssd_outbound ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_Disallow_Store_Gadget_Service ++ EXPLAIN !!Explain_Disallow_Store_Gadget_Service ++ VALUENAME disallow_store_gadget_service ++ VALUEON NUMERIC 1 ++ END POLICY ++ ++ POLICY !!Pol_MaxExchangeIndexingRate ++ EXPLAIN !!Explain_MaxExchangeIndexingRate ++ PART !!Pol_MaxExchangeIndexingRate NUMERIC ++ VALUENAME max_exchange_indexing_rate ++ MIN 1 MAX 1000 DEFAULT 60 SPIN 1 ++ END PART ++ END POLICY ++ ++ POLICY !!Pol_EnableSafeweb ++ EXPLAIN !!Explain_Safeweb ++ VALUENAME safe_browsing ++ VALUEON NUMERIC 1 ++ VALUEOFF NUMERIC 0 ++ END POLICY ++ ++ END CATEGORY ; Enterprise ++ ++ END CATEGORY ; GoogleDesktopSearch ++ END CATEGORY ; Google ++ ++;------------------------------------------------------------------------------ ++ ++[strings] ++Cat_Google="Google" ++Cat_GoogleDesktopSearch="Google Desktop" ++ ++;------------------------------------------------------------------------------ ++; Preferences ++;------------------------------------------------------------------------------ ++Cat_Preferences="Preferences" ++Explain_Preferences="Controls Google Desktop preferences" ++ ++Cat_IndexAndCaptureControl="Indexing and Capture Control" ++Explain_IndexAndCaptureControl="Controls what files, web pages, and other content will be indexed by Google Desktop." ++ ++Blacklist_Email="Prevent indexing of email" ++Explain_Blacklist_Email="Enabling this policy will prevent Google Desktop from indexing emails.\n\nIf this policy is not configured, the user can choose whether or not to index emails." ++Blacklist_Gmail="Prevent indexing of Gmail" ++Explain_Blacklist_Gmail="Enabling this policy prevents Google Desktop from indexing Gmail messages.\n\nThis policy is in effect only when the policy "Prevent indexing of email" is disabled. When that policy is enabled, all email indexing is disabled, including Gmail indexing.\n\nIf both this policy and "Prevent indexing of email" are disabled or not configured, a user can choose whether or not to index Gmail messages." ++Blacklist_WebHistory="Prevent indexing of web pages" ++Explain_Blacklist_WebHistory="Enabling this policy will prevent Google Desktop from indexing web pages.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index web pages." ++Blacklist_Text="Prevent indexing of text files" ++Explain_Blacklist_Text="Enabling this policy will prevent Google Desktop from indexing text files.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index text files." ++Blacklist_Media="Prevent indexing of media files" ++Explain_Blacklist_Media="Enabling this policy will prevent Google Desktop from indexing media files.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index media files." ++Blacklist_Contact="Prevent indexing of contacts" ++Explain_Blacklist_Contact="Enabling this policy will prevent Google Desktop from indexing contacts.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index contacts." ++Blacklist_Calendar="Prevent indexing of calendar entries" ++Explain_Blacklist_Calendar="Enabling this policy will prevent Google Desktop from indexing calendar entries.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index calendar entries." ++Blacklist_Task="Prevent indexing of tasks" ++Explain_Blacklist_Task="Enabling this policy will prevent Google Desktop from indexing tasks.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index tasks." ++Blacklist_Note="Prevent indexing of notes" ++Explain_Blacklist_Note="Enabling this policy will prevent Google Desktop from indexing notes.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index notes." ++Blacklist_Journal="Prevent indexing of journal entries" ++Explain_Blacklist_Journal="Enabling this policy will prevent Google Desktop from indexing journal entries.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index journal entries." ++Blacklist_Word="Prevent indexing of Word documents" ++Explain_Blacklist_Word="Enabling this policy will prevent Google Desktop from indexing Word documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index Word documents." ++Blacklist_Excel="Prevent indexing of Excel documents" ++Explain_Blacklist_Excel="Enabling this policy will prevent Google Desktop from indexing Excel documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index Excel documents." ++Blacklist_Powerpoint="Prevent indexing of PowerPoint documents" ++Explain_Blacklist_Powerpoint="Enabling this policy will prevent Google Desktop from indexing PowerPoint documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index PowerPoint documents." ++Blacklist_PDF="Prevent indexing of PDF documents" ++Explain_Blacklist_PDF="Enabling this policy will prevent Google Desktop from indexing PDF documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index PDF documents." ++Blacklist_ZIP="Prevent indexing of ZIP files" ++Explain_Blacklist_ZIP="Enabling this policy will prevent Google Desktop from indexing ZIP files.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index ZIP files." ++Blacklist_HTTPS="Prevent indexing of secure web pages" ++Explain_Blacklist_HTTPS="Enabling this policy will prevent Google Desktop from indexing secure web pages (pages with HTTPS in the URL).\n\nIf this policy is disabled or not configured, the user can choose whether or not to index secure web pages." ++Blacklist_URI_Contains="Prevent indexing of specific web sites and folders" ++Explain_Blacklist_URI_Contains="This policy allows you to prevent Google Desktop from indexing specific websites or folders. If an item's URL or path name contains any of these specified strings, it will not be indexed. These restrictions will be applied in addition to any websites or folders that the user has specified.\n\nThis policy has no effect when disabled or not configured." ++Blacklist_Chat="Prevent indexing of IM chats" ++Explain_Blacklist_Chat="Enabling this policy will prevent Google Desktop from indexing IM chat conversations.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index IM chat conversations." ++Blacklist_PasswordProtectedOffice="Prevent indexing of password-protected Office documents (Word, Excel)" ++Explain_Blacklist_PasswordProtectedOffice="Enabling this policy will prevent Google Desktop from indexing password-protected office documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index password-protected office documents." ++Blacklist_Extensions="Prevent indexing of specific file extensions" ++Explain_Blacklist_Extensions="This policy allows you to prevent Google Desktop from indexing files with specific extensions. Enter a list of file extensions, separated by commas, that you wish to exclude from indexing.\n\nThis policy has no effect when disabled or not configured." ++Pol_Disallow_UserSearchLocations="Disallow adding search locations for indexing" ++Explain_Disallow_UserSearchLocations="Enabling this policy will prevent the user from specifying additional drives or networked folders to be indexed by Google Desktop.\n\nIf this policy is disabled or not configured, users may specify additional drives and networked folders to be indexed." ++Pol_Search_Location_Whitelist="Allow indexing of specific folders" ++Explain_Search_Location_Whitelist="This policy allows you to add additional drives and networked folders to index." ++Search_Locations_Whitelist="Search these locations" ++Email_Retention="Only retain emails that are less than x days old" ++Explain_Email_Retention="This policy allows you to configure Google Desktop to only retain emails that are less than the specified number of days old in the index. Enter the number of days to retain emails for\n\nThis policy has no effect when disabled or not configured." ++Email_Retention_Edit="Number of days to retain emails" ++Webpage_Retention="Only retain webpages that are less than x days old" ++Explain_Webpage_Retention="This policy allows you to configure Google Desktop to only retain webpages that are less than the specified number of days old in the index. Enter the number of days to retain webpages for\n\nThis policy has no effect when disabled or not configured." ++Webpage_Retention_Edit="Number of days to retain webpages" ++File_Retention="Only retain files that are less than x days old" ++Explain_File_Retention="This policy allows you to configure Google Desktop to only retain files that are less than the specified number of days old in the index. Enter the number of days to retain files for\n\nThis policy has no effect when disabled or not configured." ++File_Retention_Edit="Number of days to retain files" ++IM_Retention="Only retain IM that are less than x days old" ++Explain_IM_Retention="This policy allows you to configure Google Desktop to only retain IM that are less than the specified number of days old in the index. Enter the number of days to retain IM for\n\nThis policy has no effect when disabled or not configured." ++IM_Retention_Edit="Number of days to retain IM" ++ ++Pol_Remove_Deleted_Items="Remove deleted items from the index." ++Explain_Remove_Deleted_Items="Enabling this policy will remove all deleted items from the index and cache. Any items that are deleted will no longer be searchable." ++ ++Pol_Allow_Simultaneous_Indexing="Allow historical indexing for multiple users simultaneously." ++Explain_Allow_Simultaneous_Indexing="Enabling this policy will allow a computer to generate first-time indexes for multiple users simultaneously. \n\nIf this policy is disabled or not configured, historical indexing will happen only for the logged-in user that was connected last; historical indexing for any other logged-in user will happen the next time that other user connects." ++ ++Pol_TurnOffAdvancedFeatures="Turn off Advanced Features options" ++Explain_TurnOffAdvancedFeatures="Enabling this policy will prevent Google Desktop from sending Advanced Features data to Google (for either improvements or personalization), and users won't be able to change these options. Enabling this policy also prevents older versions of Google Desktop from sending data.\n\nIf this policy is disabled or not configured and the user has a pre-5.5 version of Google Desktop, the user can choose whether or not to enable sending data to Google. If the user has version 5.5 or later, the 'Turn off Improve Google Desktop option' and 'Do not send personalization info' policies will be used instead." ++ ++Pol_TurnOffImproveGd="Turn off Improve Google Desktop option" ++Explain_TurnOffImproveGd="Enabling this policy will prevent Google Desktop from sending improvement data, including crash reports and anonymous usage data, to Google.\n\nIf this policy is disabled, improvement data will be sent to Google and the user won't be able to change the option.\n\nIf this policy is not configured, the user can choose whether or not to enable the Improve Google Desktop option.\n\nNote that this policy applies only to version 5.5 or later and doesn't affect previous versions of Google Desktop.\n\nAlso note that this policy can be overridden by the 'Turn off Advanced Features options' policy." ++ ++Pol_NoPersonalizationInfo="Do not send personalization info" ++Explain_NoPersonalizationInfo="Enabling this policy will prevent Google Desktop from displaying personalized content, such as news that reflects the user's past interest in articles. Personalized content is derived from anonymous usage data sent to Google.\n\nIf this policy is disabled, personalized content will be displayed for all users, and users won't be able to disable this feature.\n\nIf this policy is not configured, users can choose whether or not to enable personalization in each gadget that supports this feature.\n\nNote that this policy applies only to version 5.5 or later and doesn't affect previous versions of Google Desktop.\n\nAlso note that this policy can be overridden by the 'Turn off Advanced Features options' policy." ++ ++Pol_OneBoxMode="Turn off Google Web Search Integration" ++Explain_OneBoxMode="Enabling this policy will prevent Google Desktop from displaying Desktop Search results in queries to google.com.\n\nIf this policy is disabled or not configured, the user can choose whether or not to include Desktop Search results in queries to google.com." ++ ++Pol_EncryptIndex="Encrypt index data" ++Explain_EncryptIndex="Enabling this policy will cause Google Desktop to turn on Windows file encryption for the folder containing the Google Desktop index and related user data the next time it is run.\n\nNote that Windows EFS is only available on NTFS volumes. If the user's data is stored on a FAT volume, this policy will have no effect.\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_Hyper="Turn off Quick Find" ++Explain_Hyper="Enabling this policy will cause Google Desktop to turn off Quick Find feature. Quick Find allows you to see results as you type.\n\nIf this policy is disabled or not configured, the user can choose whether or not to enable it." ++ ++Pol_Display_Mode="Choose display option" ++Explain_Display_Mode="This policy sets the Google Desktop display option: Sidebar, Deskbar, Floating Deskbar or none.\n\nNote that on 64-bit systems, a setting of Deskbar will be interpreted as Floating Deskbar.\n\nIf this policy is disabled or not configured, the user can choose a display option." ++Sidebar="Sidebar" ++Deskbar="Deskbar" ++FloatingDeskbar="Floating Deskbar" ++None="None" ++ ++;------------------------------------------------------------------------------ ++; Enterprise ++;------------------------------------------------------------------------------ ++Cat_Enterprise="Enterprise Integration" ++Explain_Enterprise="Controls features specific to Enterprise installations of Google Desktop" ++ ++Pol_Autoupdate="Block Auto-update" ++Explain_Autoupdate="Enabling this policy prevents Google Desktop from automatically checking for and installing updates from google.com.\n\nIf you enable this policy, you must distribute updates to Google Desktop using Group Policy, SMS, or a similar enterprise software distribution mechanism. You should check http://desktop.google.com/enterprise/ for updates.\n\nIf this policy is disabled or not configured, Google Desktop will periodically check for updates from desktop.google.com." ++ ++Pol_AutoupdateAsSystem="Use system proxy settings when auto-updating" ++Explain_AutoupdateAsSystem="Enabling this policy makes Google Desktop use the machine-wide proxy settings (as specified using e.g. proxycfg.exe) when performing autoupdates (if enabled).\n\nIf this policy is disabled or not configured, Google Desktop will use the logged-on user's Internet Explorer proxy settings when checking for auto-updates (if enabled)." ++ ++Pol_EnterpriseTab="Enterprise search tab" ++Explain_EnterpriseTab="This policy allows you to add a search tab for your Google Search Appliance to Google Desktop and google.com web pages.\n\nYou must provide the name of the tab, such as "Intranet", as well as URLs for the search homepage and for retrieving search results. Use [DISP_QUERY] in place of the query term for the search results URL.\n\nSee the administrator's guide for more details." ++EnterpriseTabText="Tab name" ++EnterpriseTabHomepage="Search homepage URL" ++EnterpriseTabHomepageQuery="Check if search homepage supports '&&q='" ++EnterpriseTabResults="Search results URL" ++EnterpriseTabResultsQuery="Check if search results page supports '&&q='" ++ ++Pol_GSAHosts="Google Search Appliances" ++Explain_GSAHosts="This policy allows you to list any Google Search Appliances in your intranet. When properly configured, Google Desktop will insert Google Desktop results into the results of queries on the Google Search Appliance" ++ ++Pol_PolicyUnawareClientProhibitedFlag="Prohibit Policy-Unaware versions" ++Explain_PolicyUnawareClientProhibitedFlag="Prohibits installation and execution of versions of Google Desktop that are unaware of group policy.\n\nEnabling this policy will prevent users from installing or running version 1.0 of Google Desktop.\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_MinimumAllowedVersion="Minimum allowed version" ++Explain_MinimumAllowedVersion="This policy allows you to prevent installation and/or execution of older versions of Google Desktop by specifying the minimum version you wish to allow. When enabling this policy, you should also enable the "Prohibit Policy-Unaware versions" policy to block versions of Google Desktop that did not support group policy.\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_MaximumAllowedVersion="Maximum allowed version" ++Explain_MaximumAllowedVersion="This policy allows you to prevent installation and/or execution of newer versions of Google Desktop by specifying the maximum version you wish to allow.\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_Disallow_Gadgets="Disallow gadgets and indexing plug-ins" ++Explain_Disallow_Gadgets="This policy prevents the use of all Google Desktop gadgets and indexing plug-ins. The policy applies to gadgets that are included in the Google Desktop installation package (built-in gadgets), built-in indexing plug-ins (currently only the Lotus Notes plug-in), and to gadgets or indexing plug-ins that a user might want to add later (non-built-in gadgets and indexing plug-ins).\n\nYou can prohibit use of all non-built-in gadgets and indexing plug-ins, but allow use of built-in gadgets and indexing plug-ins. To do so, enable this policy and then select the option "Disallow only non-built-in gadgets and indexing plug-ins.\n\nYou can supersede this policy to allow specified built-in and non-built-in gadgets and indexing plug-ins. To do so, enable this policy and then specify the gadgets and/or indexing plug-ins you want to allow under "Gadget and Plug-in Whitelist."" ++Disallow_Only_Non_Builtin_Gadgets="Disallow only non-built-in gadgets and indexing plug-ins" ++ ++Pol_Gadget_Whitelist="Gadget and plug-in whitelist" ++Explain_Gadget_Whitelist="This policy specifies a list of Google Desktop gadgets and indexing plug-ins that you want to allow, as exceptions to the "Disallow gadgets and indexing plug-ins" policy. This policy is valid only when the "Disallow gadgets and indexing plug-ins" policy is enabled.\n\nFor each gadget or indexing plug-in you wish to allow, add the CLSID or PROGID of the gadget or indexing plug-in (see the administrator's guide for more details).\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_Gadget_Install_Confirmation_Whitelist="Allow silent installation of gadgets" ++Explain_Gadget_Install_Confirmation_Whitelist="Enabling this policy lets you specify a list of Google Desktop gadgets or indexing plug-ins that can be installed without confirmation from the user.\n\nAdd a gadget or indexing plug-in by placing its class ID (CLSID) or program identifier (PROGID) in the list, surrounded with curly braces ({ }).\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_Alternate_User_Data_Dir="Alternate user data directory" ++Explain_Alternate_User_Data_Dir="This policy allows you to specify a directory to be used to store user data for Google Desktop (such as index data and cached documents).\n\nYou may use [USER_NAME] or [DOMAIN_NAME] in the path to specify the current user's name or domain. If [USER_NAME] is not specified, the user name will be appended at the end of the path.\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_MaxAllowedOutlookConnections="Maximum allowed Outlook connections" ++Explain_MaxAllowedOutlookConnections="This policy specifies the maximum number of open connections that Google Desktop maintains with the Exchange server. Google Desktop opens a connection for each email folder that it indexes. If insufficient connections are allowed, Google Desktop cannot index all the user email folders.\n\nThe default value is 400. Because users rarely have as many as 400 email folders, Google Desktop rarely reaches the limit.\n\nIf you set this policy's value above 400, you must also configure the number of open connections between Outlook and the Exchange server. By default, approximately 400 connections are allowed. If Google Desktop uses too many of these connections, Outlook might be unable to access email.\n\nThis policy has no effect when disabled or not configured." ++ ++Pol_DisallowSsdService="Disallow sharing and receiving of web history and documents across computers" ++Explain_DisallowSsdService="Enabling this policy will prevent Google Desktop from sharing the user's web history and document contents across the user's different Google Desktop installations, and will also prevent it from receiving such shared items from the user's other machines. To allow reception but disallow sharing, use DisallowSsdOutbound.\nThis policy has no effect when disabled or not configured." ++ ++Pol_DisallowSsdOutbound="Disallow sharing of web history and documents to user's other computers." ++Explain_DisallowSsdOutbound="Enabling this policy will prevent Google Desktop from sending the user's web history and document contents from this machine to the user's other machines. It does not prevent reception of items from the user's other machines; to disallow both, use DisallowSsdService.\nThis policy has no effect when disabled or not configured." ++ ++Pol_Disallow_Store_Gadget_Service="Disallow storage of gadget content and settings." ++Explain_Disallow_Store_Gadget_Service="Enabling this policy will prevent users from storing their gadget content and settings with Google. Users will be unable to access their gadget content and settings from other computers and all content and settings will be lost if Google Desktop is uninstalled." ++ ++Pol_MaxExchangeIndexingRate="Maximum allowed Exchange indexing rate" ++Explain_MaxExchangeIndexingRate="This policy allows you to specify the maximum number of emails that are indexed per minute. \n\nThis policy has no effect when disabled or not configured." ++ ++Pol_EnableSafeweb="Enable or disable safe browsing" ++Explain_Safeweb="Google Desktop safe browsing informs the user whenever they visit any site which is a suspected forgery site or may harm their computer. Enabling this policy turns on safe browsing; disabling the policy turns it off. \n\nIf this policy is not configured, the user can select whether to turn on safe browsing." +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/README.txt b/tools/grit/grit/testdata/README.txt +new file mode 100644 +index 0000000000..a683b3b9e3 +--- /dev/null ++++ b/tools/grit/grit/testdata/README.txt +@@ -0,0 +1,87 @@ ++Google Desktop for Enterprise ++Copyright (C) 2007 Google Inc. ++All Rights Reserved ++ ++--------- ++Contents ++--------- ++This distribution contains the following files: ++ ++GoogleDesktopSetup.msi - Installation and setup program ++GoogleDesktop.adm - Group Policy administrative template file ++AdminGuide.pdf - Google Desktop for Enterprise administrative guide ++ ++ ++-------------- ++Documentation ++-------------- ++Full documentation and installation instructions are in the ++administrative guide, and also online at ++http://desktop.google.com/enterprise/adminguide.html. ++ ++ ++------------------------ ++IBM Lotus Notes Plug-In ++------------------------ ++The Lotus Notes plug-in is included in the release of Google ++Desktop for Enterprise. The IBM Lotus Notes Plug-in for Google ++Desktop indexes mail, calendar, task, contact and journal ++documents from Notes. Discussion documents including those from ++the discussion and team room templates can also be indexed by ++selecting an option from the preferences. Once indexed, this data ++will be returned in Google Desktop searches. The corresponding ++document can be opened in Lotus Notes from the Google Desktop ++results page. ++ ++Install: The plug-in will install automatically during the Google ++Desktop setup process if Lotus Notes is already installed. Lotus ++Notes must not be running in order for the install to occur. The ++Class ID for this plug-in is {8F42BDFB-33E8-427B-AFDC-A04E046D3F07}. ++ ++Preferences: Preferences and selection of databases to index are ++set in the 'Google Desktop for Notes' dialog reached through the ++'Actions' menu. ++ ++Reindexing: Selecting 'Reindex all databases' will index all the ++documents in each database again. ++ ++ ++Notes Plug-in Known Issues ++--------------------------- ++ ++If the 'Google Desktop for Notes' item is not available from the ++Lotus Notes Actions menu, then installation was not successful. ++Installation consists of writing one file, notesgdsplugin.dll, to ++the Notes application directory and a setting to the notes.ini ++configuration file. The most likely cause of an unsuccessful ++installation is that the installer was not able to locate the ++notes.ini file. Installation will complete if the user closes Notes ++and manually adds the following setting to this file on a new line: ++AddinMenus=notesgdsplugin.dll ++ ++If the notesgdsplugin.dll file is not in the application directory ++(e.g., C:\Program Files\Lotus\Notes) after Google Desktop ++installation, it is likely that Notes was not installed correctly. ++ ++Only local databases can be indexed. If they can be determined, ++the user's local mail file and address book will be included in the ++list automatically. Mail archives and other databases must be ++added with the 'Add' button. ++ ++Some users may experience performance issues during the initial ++indexing of a database. The 'Perform the initial index of a ++database only when I'm idle' option will limit the indexing process ++to times when the user is not using the machine. If this does not ++alleviate the problem or the user would like to continually index ++but just do so more slowly or quickly, the GoogleWaitTime notes.ini ++value can be set. Increasing the GoogleWaitTime value will slow ++down the indexing process, and lowering the value will speed it up. ++A value of zero causes the fastest possible indexing. Removing the ++ini parameter altogether returns it to the default (20). ++ ++Crashes have been known to occur with certain types of history ++bookmarks. If the Notes client seems to crash randomly, try ++disabling the 'Index note history' option. If it crashes before, ++you can get to the preferences, add the following line to your ++notes.ini file: ++GDSNoIndexHistory=1 +diff --git a/tools/grit/grit/testdata/about.html b/tools/grit/grit/testdata/about.html +new file mode 100644 +index 0000000000..8e5fad7b2b +--- /dev/null ++++ b/tools/grit/grit/testdata/about.html +@@ -0,0 +1,45 @@ ++[HEADER] ++
++
 [TITLE]
++
Google Desktop Search: Search your own computer.

++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
  Outlook Email   Netscape Mail / Thunderbird
  Outlook Express   Netscape / Firefox / Mozilla
  Word   PDF
  Excel   Music
  PowerPoint   Images
  Internet Explorer   Video
  AOL Instant Messenger   Even more with these plug-ins
  Text and others
++
++

++ ++ ++ ++ ++ ++
Getting Started - Learn more about using Google Desktop Search
Online Help - Up-to-date answers to your questions
Privacy - A few words about privacy and Google Desktop Search
Uninstall - How to uninstall Google Desktop Search
Submit Feedback - Send us your comments and ideas

Google Desktop Search [$~BUILDNUMBER~$]

++[FOOTER] +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/android.xml b/tools/grit/grit/testdata/android.xml +new file mode 100644 +index 0000000000..cc3b141f70 +--- /dev/null ++++ b/tools/grit/grit/testdata/android.xml +@@ -0,0 +1,24 @@ ++ ++ ++ ++ ++ ++ Open %s? ++ ++ ++ ++ A simple string. ++ ++ ++ Contains a comment. ++ ++ ++ Another simple string. ++ ++ ++ Do not translate me. ++ +diff --git a/tools/grit/grit/testdata/bad_browser.html b/tools/grit/grit/testdata/bad_browser.html +new file mode 100644 +index 0000000000..e8cf34664d +--- /dev/null ++++ b/tools/grit/grit/testdata/bad_browser.html +@@ -0,0 +1,16 @@ ++

We're sorry, but we don't seem to be compatible.

++

Our software suggests that you're using a browser incompatible with Google Desktop Search. ++ Google Desktop Search currently supports the following:

++ ++ ++

You may click here to use your ++ unsupported browser, though you likely will encounter some areas that don't ++ work as expected. You need to have Javascript enabled, regardless of the ++ browser you use. ++

We hope to expand this list in the near future and announce new ++ browsers as they become available. +diff --git a/tools/grit/grit/testdata/browser.html b/tools/grit/grit/testdata/browser.html +new file mode 100644 +index 0000000000..45d364d56f +--- /dev/null ++++ b/tools/grit/grit/testdata/browser.html +@@ -0,0 +1,42 @@ ++ ++[$~TITLE~$] ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
[$~IMAGE~$] ++   ++ ++ ++ ++ ++
++ ++ ++ ++ ++
 [$~CHROME_TITLE~$]
++
++ ++ ++ ++ ++ ++
++ [$~BODY~$] ++
++[$~FOOTER~$] ++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/buildinfo.grd b/tools/grit/grit/testdata/buildinfo.grd +new file mode 100644 +index 0000000000..80458a8265 +--- /dev/null ++++ b/tools/grit/grit/testdata/buildinfo.grd +@@ -0,0 +1,46 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Copyright 2008 Google Inc. All Rights Reserved. ++ ++ ++ Google Desktop News gadget ++[IDS_COPYRIGHT_GOOGLE_LONG] ++View news that is personalized based on the articles you read. ++ ++For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/cache_prefix.html b/tools/grit/grit/testdata/cache_prefix.html +new file mode 100644 +index 0000000000..b1f91dd82b +--- /dev/null ++++ b/tools/grit/grit/testdata/cache_prefix.html +@@ -0,0 +1,24 @@ ++ ++ ++ ++ ++ ++ ++
++ ++ ++
This is one version of ++[URL-DISP] from your personal cache.
++The page may have changed since that time. Click here for the current page.
++Since this page is stored on your computer, publicly linking to this page will not work.[$~EXTRA~$]

++Google may not be affiliated with the authors of this page nor responsible for its content. This page may be protected by copyright. ++
++ ++ ++


++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/cache_prefix_file.html b/tools/grit/grit/testdata/cache_prefix_file.html +new file mode 100644 +index 0000000000..f3eb8e0f11 +--- /dev/null ++++ b/tools/grit/grit/testdata/cache_prefix_file.html +@@ -0,0 +1,25 @@ ++ ++ ++ ++ ++ ++ ++
++ ++ ++
This is one version of [URL-DISP] ++from your personal cache.
++The file may have changed since that time. Click here for the current file.
++Since this file is stored on your computer, publicly linking to it will not work.[$~EXTRA~$]

++Google may not be affiliated with the authors of this page nor responsible for its content. This page may be protected by copyright. ++
++
++ ++ ++
++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/chat_result.html b/tools/grit/grit/testdata/chat_result.html +new file mode 100644 +index 0000000000..318078bc3d +--- /dev/null ++++ b/tools/grit/grit/testdata/chat_result.html +@@ -0,0 +1,24 @@ ++[HEADER] ++[CHROME] ++ ++ ++
[$~STARTCHAT~$]
++
++
++   [$~TITLE~$] ++

Participants: [USERNAME], [BUDDYNAME]
++Date: [TIME]
++
++ ++
++ ++ ++
[$~STARTCHAT~$]
++ ++ ++[FOOTER] +diff --git a/tools/grit/grit/testdata/chrome/app/generated_resources.grd b/tools/grit/grit/testdata/chrome/app/generated_resources.grd +new file mode 100644 +index 0000000000..c2efb77fd8 +--- /dev/null ++++ b/tools/grit/grit/testdata/chrome/app/generated_resources.grd +@@ -0,0 +1,199 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ New background app installed ++ ++ ++ $1Background App will launch at system startup and continue to run in the background even once you've closed all other $2Google Chrome windows. ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/chrome_html.html b/tools/grit/grit/testdata/chrome_html.html +new file mode 100644 +index 0000000000..7f7633c5cf +--- /dev/null ++++ b/tools/grit/grit/testdata/chrome_html.html +@@ -0,0 +1,6 @@ ++ ++ +diff --git a/tools/grit/grit/testdata/default_100_percent/a.png b/tools/grit/grit/testdata/default_100_percent/a.png +new file mode 100644 +index 0000000000000000000000000000000000000000..5d5089038ca71172e95db9e7aae1e1fa5cebd505 +GIT binary patch +literal 159 +zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>0wld=oSO}#(mY)pLnNjq|2Y3)zGGzYPN&L+ +zMSC}CcCfp=Dtxv4%6W%G#Q=|R|L;6pCCLUWO)Z<5eoL%TkDTw=s4X!^d(Qa<2khAN +zZPy!XToBAic1Ss}vcWiD27B3&`Zj^H6CO>7R1{ToQ;=ggdEYbV=IISvfHpFCy85}S +Ib4q9e0O9jEh5!Hn + +literal 0 +HcmV?d00001 + +diff --git a/tools/grit/grit/testdata/default_100_percent/b.png b/tools/grit/grit/testdata/default_100_percent/b.png +new file mode 100644 +index 0000000000..6178079822 +--- /dev/null ++++ b/tools/grit/grit/testdata/default_100_percent/b.png +@@ -0,0 +1 @@ ++b +diff --git a/tools/grit/grit/testdata/del_footer.html b/tools/grit/grit/testdata/del_footer.html +new file mode 100644 +index 0000000000..4e19950bfc +--- /dev/null ++++ b/tools/grit/grit/testdata/del_footer.html +@@ -0,0 +1,8 @@ ++ ++ ++ ++
 Remove checked results and return to search.Check all - Uncheck all   ++ ++
++

[$~BOTTOMLINE~$] - ©2005 Google
++ +diff --git a/tools/grit/grit/testdata/del_header.html b/tools/grit/grit/testdata/del_header.html +new file mode 100644 +index 0000000000..72bc6756eb +--- /dev/null ++++ b/tools/grit/grit/testdata/del_header.html +@@ -0,0 +1,60 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
Go to Google Desktop Search  ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++
 Remove Specific ItemsHelp  
++
++ ++ ++ ++ ++ ++ ++
 Remove checked results and return to search.Check all - ++Uncheck all  
++
++ ++ ++ ++ ++
 Remove ++checked items from Google Desktop Search. Other copies of the same items will not be ++affected.
++ If you view the item again, it will be added back to Google Desktop Search.
++
+\ No newline at end of file +diff --git a/tools/grit/grit/testdata/deleted.html b/tools/grit/grit/testdata/deleted.html +new file mode 100644 +index 0000000000..5ae5f355fa +--- /dev/null ++++ b/tools/grit/grit/testdata/deleted.html +@@ -0,0 +1,21 @@ ++ ++Database Deleted ++ ++ ++ ++ ++ ++ ++ ++
++ ++
Google Desktop Search ++

++
The database has been deleted. Click here to continue.
++ ++ ++
[$~BOTTOMLINE~$]

++

©2005 Google

+\ No newline at end of file +diff --git a/tools/grit/grit/testdata/depfile.grd b/tools/grit/grit/testdata/depfile.grd +new file mode 100644 +index 0000000000..e2f7191218 +--- /dev/null ++++ b/tools/grit/grit/testdata/depfile.grd +@@ -0,0 +1,18 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/details.html b/tools/grit/grit/testdata/details.html +new file mode 100644 +index 0000000000..0ab0e2a90c +--- /dev/null ++++ b/tools/grit/grit/testdata/details.html +@@ -0,0 +1,10 @@ ++[!] ++title Improve Google Desktop Search by Sending Non-Personal Information ++template ++bottomline ++hp_image ++ ++

This documentation is not yet available

++

++[$~BOTTOMLINE~$] - ©2005 Google ++
+diff --git a/tools/grit/grit/testdata/duplicate-name-input.xml b/tools/grit/grit/testdata/duplicate-name-input.xml +new file mode 100644 +index 0000000000..cc4d1d65c5 +--- /dev/null ++++ b/tools/grit/grit/testdata/duplicate-name-input.xml +@@ -0,0 +1,26 @@ ++ ++ ++ ++ ++ ++ Hello %sJoi, how are you doing today? ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/email_result.html b/tools/grit/grit/testdata/email_result.html +new file mode 100644 +index 0000000000..8bb04b988c +--- /dev/null ++++ b/tools/grit/grit/testdata/email_result.html +@@ -0,0 +1,34 @@ ++[HEADER] ++[CHROME] ++ ++ ++
[CONV] ++Reply | Reply to All[$~FORWARD_URL~$] | Compose[$~OUTLOOKVIEW~$] ++
++
++
++   [SUBJECT] ++

[FROM-DISP] ++[TO-DISP] ++[CC-DISP] ++[BCC-DISP] ++[REPLYTO-DISP] ++[DATE-DISP] ++[VIEW-DISP] ++[$~ATTACH~$] ++

++

++ ++
++ ++
[CONV] ++Reply | Reply to All[$~FORWARD_URL~$] | Compose[$~OUTLOOKVIEW~$] ++
++ ++ ++[FOOTER] +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/email_thread.html b/tools/grit/grit/testdata/email_thread.html +new file mode 100644 +index 0000000000..3c7279b841 +--- /dev/null ++++ b/tools/grit/grit/testdata/email_thread.html +@@ -0,0 +1,10 @@ ++[HEADER] ++[CHROME] ++
++   [SUBJECT]

++ ++[CONTENTS] ++
++
++[NEXT_PREV] ++[FOOTER] +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/error.html b/tools/grit/grit/testdata/error.html +new file mode 100644 +index 0000000000..66875a234c +--- /dev/null ++++ b/tools/grit/grit/testdata/error.html +@@ -0,0 +1,8 @@ ++[HEADER] ++[CHROME] ++
++
++[ERROR]

++If you think this is an error, please contact us. ++
++[FOOTER] +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/explicit_web.html b/tools/grit/grit/testdata/explicit_web.html +new file mode 100644 +index 0000000000..1424adc617 +--- /dev/null ++++ b/tools/grit/grit/testdata/explicit_web.html +@@ -0,0 +1,11 @@ ++[HEADER] ++ ++[WEB_TOP_CHROME] ++[$~STATUS~$] ++[$~MESSAGE~$] ++[WEB_FILES] ++
[NEXT_PREV] ++[FOOTER] +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/footer.html b/tools/grit/grit/testdata/footer.html +new file mode 100644 +index 0000000000..3372d6afac +--- /dev/null ++++ b/tools/grit/grit/testdata/footer.html +@@ -0,0 +1,14 @@ ++


++
++ ++ ++

++ ++ ++ ++
[$~BOTTOM~$]

++
++

++[$~BOTTOMLINE~$] - ©2005 Google
++[SCRIPT] ++ +diff --git a/tools/grit/grit/testdata/generated_resources_fr.xtb b/tools/grit/grit/testdata/generated_resources_fr.xtb +new file mode 100644 +index 0000000000..373c40feea +--- /dev/null ++++ b/tools/grit/grit/testdata/generated_resources_fr.xtb +@@ -0,0 +1,3079 @@ ++ ++ ++ ++Salut! ++Salut ++Supprime&r ++Activer la barre de favoris ++Déconnexion du réseau privé ++ sur  ++Déconnecter ce compte... ++&Vérifier l'orthographe dans ce champ ++Aucune donnée reçue. ++Une erreur s'est produite lors de la tentative de lecture du fichier : . ++Le mot de passe multiterme est obligatoire. ++Importer les données d'un autre navigateur... ++Saisie automatique ++API P2P ++Exécuter automatiquement (recommandé) ++Le certificat de sécurité du site a expiré ! ++Clé publique de l'objet ++Importer ++Afficher dan&s un onglet ++ID : ++Le certificat n'indique aucun mécanisme permettant de vérifier s'il a été révoqué. ++Touches de modification... ++Signé par : ++Utiliser un service Web pour résoudre les erreurs de navigation ++Guillemet ++Une nouvelle tentative de connexion avec SSL 3.0 a dû être effectuée. Cette opération indique généralement que le serveur utilise un logiciel très ancien et qu'il est susceptible de présenter d'autres problèmes de sécurité. ++Autoriser le stockage des données locales (recommandé) ++Ouvrir dans une fenêtre ++Google pense qu'un logiciel malveillant pourrait être installé sur votre ordinateur si vous continuez. Nous vous conseillons de ne pas continuer, même si vous avez déjà consulté ce site auparavant ou si vous avez confiance en celui-ci. Il se peut qu'il ait été piraté récemment. Réessayez demain ou utilisez un autre site. ++&Rechercher : ++Échec de génération de clé privée RSA aléatoire ++Certificat en attente ++Technologie réseau : ++Le certificat du serveur ne figure pas dans le DNS. ++Demander le mot de passe au retour de veille ++Désactiver la synchronisation ++Base de données indexée ++Ne pas enregistrer ++ synchronise vos données avec votre compte Google en toute sécurité. Synchronisez toutes vos données ou personnalisez les types de données synchronisées et les options de chiffrement. ++Le délai imparti à l'opération est dépassé. ++Nordique ++Créer des raccourcis vers des applications ++Pas encore chargé ++Confirmer le nouveau code PIN : ++L2TP/IPSec + Certificat utilisateur ++Préfecture ++Extraction de l'image de récupération... ++Terminé ++Il se peut que la page Web à l'adresse soit temporairement inaccessible ou qu'elle ait été déplacée de façon permanente à une autre adresse Web. ++Cache des scripts ++Barre d'outils Google ++Importés depuis Safari ++Le plug-in n'est pas autorisé. ++Vous exécutez à partir de son image disque. Si vous l'installez sur votre ordinateur, vous pourrez l'utiliser sans image disque et bénéficierez de mises à jour automatiques. ++Certificat du serveur SSL ++Z&oom arrière ++Indique si la suggestion du moteur de recherche doit être entrée immédiatement via la saisie semi-automatique lorsque la fonctionnalité Recherche instantanée est activée. ++Mise à jour du système : % téléchargés ++Les informations d'identification associées au partage de vos imprimantes via sont arrivées à expiration. Cliquez ici pour saisir à nouveau votre nom d'utilisateur et votre mot de passe. ++Erreur de définition du paramètre de confiance du certificat ++ peut maintenant synchroniser vos mots de passe. ++Sélectionnez le certificat à présenter pour l'identification : ++ a planté. Cliquez sur cette info-bulle pour actualiser l'extension. ++Compatibilité expérimentale avec des méthodes Wi-Fi Extensible Authentication Protocol supplémentaires, telles que EAP-TLS et LEAP. ++Échec de lecture de la clé privée ++Les plug-ins suivants ont été bloqués sur cette page : ++Configuration de la synchronisation ++Case d'option cochée ++Très petite ++URL de révocation de l'autorité de certification Netscape ++Style de pavé numérique ++Active les feuilles de style CSS 3D et la composition graphique haute performance des pages Web via le processeur graphique. ++&Rétablir ++Redémarrer ++La connexion n'est pas compressée. ++Fin ++&Nouvelle fenêtre ++Configuration automatique du proxy ++Afficher l'orthographe et la grammaire ++Aucune imprimante n'a été trouvée. Veuillez en installer une. ++Saisissez les caractères visibles dans l'image ci-dessous. ++Certificat d'authentification de client SSL incorrect ++Le certificat du serveur ou un certificat AC intermédiaire présenté au navigateur a été signé avec un algorithme de signature faible tel que RSA-MD2. D'après des études récentes menées par des informaticiens, les algorithmes de signature seraient plus faibles qu'on ne le pensait jusqu'alors. Aujourd'hui, ils sont très rarement utilisés par les sites Web jugés dignes de confiance. Ce certificat a peut-être été contrefait. Nous vous déconseillons vivement de continuer. ++Rechercher le précédent ++I&nspecter l'élément ++État d'itinérance : ++&Non ++Effacer les données de navigation... ++Nombre maximal de suggestions ++L'accessibilité est désactivée. ++Sélectionner par domaine ++Tout réduire... ++Ne jamais traduire les pages rédigées en ++Non confirmé ++Avant de vous connecter, démarrez une session en tant qu'invité afin d'activer le réseau . ++La gravure de l'image est terminée. ++Si vous supprimez le certificat d'une autorité de certification, votre navigateur ne fera plus confiance aux certificats émis par cette autorité de certification. ++Synchronisez toutes les données de cet ordinateur ou sélectionnez celles que vous souhaitez synchroniser. ++ hours ago ++Domaine : ++Aperçu ++Associe chaque fenêtre du navigateur à un profil et ajoute une option de sélection des profils en haut à droite. Chaque profil possède ses propres favoris, extensions, applications, etc. ++Ignorer le verrouillage des majuscules et saisir des minuscules par défaut ++Aucune parole détectée ++Changer de moteur de recherche par défaut ++Cliquer pour revenir en arrière, maintenir pour voir l'historique ++ secondes restantes ++Unicode ++Ouverture à la fin du téléchargement ++Les extensions, les applications et les thèmes peuvent endommager votre ordinateur. Voulez-vous vraiment continuer ? ++Schéma du pinyin double ++Déconnecter ce compte... ++&Fichier ++Microsoft Internet Explorer ++Aucune correspondance trouvée ++État de votre commentaire ++Mise à jour terminée. Veuillez redémarrer le système. ++Lorsque vous supprimez un certificat de serveur, vous rétablissez les contrôles de sécurité habituels du serveur et un certificat valide lui est demandé. ++Essayez d'ajouter ++ ++ aux programmes autorisés dans les paramètres de votre pare-feu ou de votre antivirus. S'il ++ est déjà autorisé, tentez de le supprimer de la liste et de l'ajouter à nouveau à ++ la liste des programmes autorisés. ++Réseaux sans fil ++Masquer ++Zoom arrière ++Méthode EAP : ++Développer ++Veuillez vous connecter ++de n'importe quand ++Désactiver la validation des formulaires interactifs HTML5 ++Le suivi de votre position géographique sur cette page a été bloqué pour les sites suivants : ++La gravure de l'image a été interrompue. ++&Afficher dans le dossier ++Continuer à bloquer JavaScript ++Enregistrer la page sous... ++Le serveur à l'adresse requiert un nom d'utilisateur et un mot de passe. ++Exceptions de géolocalisation ++13px ++Contenu : ++Le plug-in a été bloqué, car il n'est plus à jour. ++Taille ré&elle ++Échec de la connexion au serveur proxy. ++Vérification de pilote matériel Microsoft Windows ++Paysage ++Détecter automatiquement ++Page ++Nom d'utilisateur : ++Nous aider à améliorer en envoyant automatiquement les statistiques d'utilisation et les rapports d'erreur à Google ++Réseau ++Connexion en cours ++Ajouter tous les onglets aux favoris... ++Onglets ou fenêtres ++Sites récemment consultés ++Ouvrir dans une fenêtre de navigation privée ++Préférences de saisie automatique... ++Compteur d'images par seconde ++Mot de passe ++Afficher le compte ++ : ++Le suivi de votre position géographique a été bloqué pour cette page. ++Connexion à l'aide de votre compte Google ++Le mot de passe multiterme entré est incorrect. ++télécopie : # ++Le navigateur par défaut est actuellement . ++ secondes restantes ++Mot de passe précédent ++Code PIN incorrect ++Modifier l'adresse ++Zoom avant ++Micrologiciel ++Une erreur s'est produite lors de l'affichage de cette page Web. Pour continuer, actualisez cette page ou ouvrez-en une autre. ++Récupération de clé Microsoft ++recto verso ++Fichier ou répertoire introuvable ++Aucun forfait de données actif ++Tout sélectionner ++Le fichier manifeste est incorrect. ++Les pages suivantes ne répondent plus. Vous pouvez attendre qu'elles soient de nouveau accessibles ou les supprimer. ++ minutes restantes ++Le certificat du serveur n'est pas encore valide. ++Menu contenant des extensions masquées ++Enregistrer les infos ++Configuration de l'accès à distance à cet ordinateur. ++Point ++Ajouter un moteur de recherche ++Impossible d'atteindre le serveur. ++Importer mes favoris... ++Enregistrer le &cadre sous... ++Vous n'êtes pas autorisé à accéder à la page Web . Votre connexion peut être requise. ++Envoyer la capture d'écran du dernier onglet actif ++Erreur ++Utiliser le thème GTK+ ++Ouvrir une fenêtre du navigateur ++ a planté. Cliquez sur cette info-bulle pour redémarrer l'application. ++Définir comme navigateur par défaut ++Certificat de courrier électronique ++Clavier en superposition ++La connexion est compressée avec . ++Exporter mes favoris... ++Format : ++Ignorer ++Déplacer un mot ++Index de ++Mémoire ++Impossible d'utiliser cette langue pour corriger l'orthographe. ++Recherche ++Ajouter une autre carte de paiement... ++Envoyer la dernière capture d'écran enregistrée ++Ce fichier contient du code malveillant. Voulez-vous vraiment continuer ? ++Erreur de synchronisation... ++Clavier brésilien ++Utiliser TLS 1.0 ++&Signaler un problème... ++Créer des raccourci&s vers des applications... ++Le certificat "" a été émis par : ++ ne contrôlant pas la façon dont les extensions gèrent vos données personnelles, toutes les extensions sont désactivées dans les fenêtres de navigation privée. Vous pouvez les réactiver individuellement dans le gestionnaire des extensions. ++Logiciels malveillants ++Mise en page ou mise en forme de la page ++Acheter davantage... ++Traduire ++Tout ++Créé : ++Annuler l'importation ++Le mode indiqué est incorrect. ++ copié(s) sur ++L'accès à distance à cet ordinateur est activé pour . ++Options... ++Un problème est survenu lors de la création du support de récupération du système d'exploitation. Le périphérique de stockage utilisé est introuvable. ++Toujours &afficher la barre de favoris ++Erreur SSL ++Confirmer les préférences de synchronisation ++Utiliser les valeurs par défaut ++Code secret manquant ++L'accès à distance à cet ordinateur est désactivé. ++API des extensions expérimentales ++Inclure les informations système ++Date d'expiration ++Autorité de certification compromise ++À propos de la saisie automatique ++Activer la fonction "Taper pour cliquer" ++Accès à la page Web refusé ++&Gestionnaire de favoris ++Erreur serveur ++Cette carte SIM est désactivée et ne peut être utilisée. Veuillez demander à votre fournisseur de services de la remplacer. ++Outils ++Clavier néerlandais ++EAP-TTLS ++Choisissez une image à associer à votre compte. Celle-ci s'affichera sur l'écran de connexion. ++Configurer le blocage des fenêtres pop-up... ++des 4 dernières semaines ++Une situation inattendue s'est produite tandis que le serveur tentait de traiter la demande. ++Impossible d'afficher certaines parties de ce document PDF. Souhaitez-vous l'ouvrir dans Adobe Reader ? ++Proxy FTP ++Si vous utilisez la version PPAPI de Flash, exécutez-la dans chaque processus de moteur du rendu plutôt que dans un processus de plug-in dédié. ++Cela signifie que le certificat présenté à votre navigateur contient des erreurs et qu'il ne peut pas être compris. Il est possible que les informations sur l'identité du certificat ou que d'autres informations du certificat relatives à la sécurité de la connexion soient incompréhensibles. Ne poursuivez pas. ++Activer l'onglet 1 ++Communication à distance ++Importer les favoris et les paramètres... ++À propos ++Modifier le favori de cette page ++Ajouter un format d'exception ++Configurer l'accès à distance... ++Supprimer le certificat "" ? ++Cache des images ++Configuration du proxy ++En l'absence de connexion Wi-Fi, Google Chrome utilise les données 3G. ++Appuyez sur pour sélectionner le mode de saisie précédent. ++La création du support de récupération du système d'exploitation a été annulée. ++Le plug-in suivant est bloqué : ++Erreur de connexion réseau ++Mot de passe multiterme ++Internet ++Configurer les paramètres de blocage des plug-ins... ++Afficher dan&s un onglet ++Synchroniser vos mots de passe ++Le serveur proxy agit comme un intermédiaire entre votre ordinateur et les autres serveurs. Votre configuration système utilise actuellement un proxy, mais ++ ++ ne parvient pas à s'y connecter. ++Sélectionner par type d'application ++Procéder à l'i&nspection de l'élément ++Impossible de valider entièrement l'identité du serveur auquel vous êtes connecté. Le nom utilisé pour cette connexion n'est valide que sur votre réseau et aucune autorité de certification externe ne peut en vérifier la propriété. Certaines autorités de certification délivrent tout de même des certificats pour ces types de nom, par conséquent nous ne sommes pas en mesure de vérifier que vous êtes connecté au site voulu et non à un site malveillant. ++Impossible de déplacer le répertoire d'extensions dans le profil. ++Supprimer ces paramètres pour les prochaines visites ++L'accessibilité est activée. ++Appuyer sur la touche Espace pour sélectionner la suggestion ++Vos favoris ++ () ++Fermer les onglets ++Applications en arrière-plan ++Favoris ++Supprimer les données synchronisées de Google Dashboard ++Veuillez patienter pendant que installe les dernières mises à jour système. ++Utilisez les touches Maj gauche et droite pour sélectionner les 2e et 3e propositions ++WEP ++Mode Zhuyin complet. La sélection automatique de la suggestion et les options associées sont désactivées ou ignorées. ++&Paramètres linguistiques... ++CRX-less Web Apps ++Connexion au réseau ++Reliure bord long ++ utilise les paramètres proxy du système pour se connecter au réseau. ++Application : ++&Descendre ++? Toutes les données présentes sur le périphérique seront supprimées. ++Adresse IP ++Active le nouveau design de la page "Nouvel onglet" (en cours de développement). ++Échec de l'activation ++Ne pas vérifier ++Le chinois simplifié est le mode de saisie initial ++Paramètres SSL sur tout l'ordinateur : ++Votre connexion à n'est pas chiffrée. ++matériel requis ++Gérer les exceptions... ++Rechercher des mises à jour ++Utiliser un mot de passe multiterme pour chiffrer mes données de synchronisation ++Connexion en cours... ++Le serveur ne parvient pas à traiter la demande pour le moment. Ce code indique une situation temporaire. Le serveur sera de nouveau opérationnel ultérieurement. ++Historique ++Destination ++Web audio ++Cookies placés par cette page ++Accès partagé ++Afficher... ++Veuillez vous connecter à . ++Ajouter un nouvel e-mail ++Personnaliser les polices... ++Matériel : ++Erreur de connexion au réseau. ++Cette page Web est introuvable. ++En&registrer la vidéo sous... ++Le certificat du serveur n'est pas approuvé. ++Cop&ier l'image ++Sebeol-sik 390 ++ mins ago ++Autre réseau mobile... ++Erreur HTTP () : ++Signature du code ++Aide ++<sans nom> ++Version du micrologiciel : ++La page ne se charge pas ++Attention, ces fonctionnalités expérimentales peuvent mordre. ++Verrouiller l'écran ou éteindre ++La connexion est chiffrée au moyen de , avec pour l'authentification des messages et pour la méthode d'échange de clés. ++Clavier portugais ++Importation ++Connexion au réseau ++Langues ++Cette erreur peut se produire lors de la connexion à un serveur sécurisé (HTTPS). ++ Elle indique que le serveur tente d'établir une connexion sécurisée, mais ++ que celle-ci ne sera pas du tout sécurisée en raison d'une grave erreur de configuration. ++ Dans ce cas, une intervention ++ est requise sur le serveur. ++ ++ n'utilise pas de connexion non sécurisée pour protéger la confidentialité ++ de vos données. ++La synchronisation de vous permet de partager vos données (favoris, préférences) sur vos ordinateurs en toute simplicité. Pour ce faire, enregistre vos données en ligne via Google lorsque vous vous connectez à votre compte. ++Format ou mise en forme de la page ++Clavier suisse ++En&registrer l'image sous... ++Basculer en mode pleine chasse ou demi-chasse ++Sélectionner... ++Effacer les paramètres d'ouverture automatique ++Ajouter un réseau privé ++ secondes ++Ne pas envoyer de capture d'écran ++Hébreu ++Toujours afficher la barre de favoris ++Impossible de trouver le chemin d'accès absolu du répertoire à empaqueter. ++Créer un profil ++Diners Club ++Paramètres de contenu... ++Activer la recherche instantanée pour accélérer la recherche et la navigation ? ++Plus d'extensions >> ++La valeur d'entrée de la clé privée est obligatoire. ++PEAP ++Fonctionnalités de localisation expérimentales ++Ou&vrir la vidéo dans un nouvel onglet ++Toujours afficher la barre de favoris ++Reliure ++Utilisation de la clé du certificat ++Clavier belge ++ heures restantes ++Afficher toutes les images (recommandé) ++Cliquez sur ++ Démarrer, ++ puis sur ++ Exécuter. ++ Saisissez ++ et cliquez sur ++ OK. ++Nom de volume ++Reliure bord court ++ va configurer les mises à jour automatiques pour tous les utilisateurs de cet ordinateur. ++Effacer les éléments datant : ++Interdire à tous les sites d'afficher des notifications sur le Bureau ++Appuyez sur pour passer d'un mode de saisie à l'autre. ++Ajouter un nouveau fax ++Recherche de contenu en cours... ++Style d'entrée avec Espace ++Vous avez tenté d'accéder à , mais, au lieu de cela, vous communiquez actuellement avec un serveur identifié comme . Cela est peut-être dû à un défaut de configuration du serveur ou à quelque chose de plus grave. Un pirate informatique sur votre réseau cherche peut-être à vous faire visiter une version falsifiée de , donc potentiellement préjudiciable. Nous vous déconseillons vivement de continuer. ++Masquer le bouton ++Modifier l'image ++Ne pas synchroniser mes mots de passe ++JavaScript ++Activer les notifications de ++Afficher les incompatibilités ++Nouvel onglet ++Impossible de charger l'icône "" d'action de page. ++Fermer l'onglet ++Nom d'hôte du serveur : ++Ajouter une carte de paiement ++ : type de fichier inconnu ++Non défini ++Gérer les paramètres de saisie automatique... ++Respecter la &casse ++Autoriser tous les sites à exécuter JavaScript (recommandé) ++Gérer vos périphériques depuis le cloud ++Clavier catalan ++Me demander lorsqu'un site essaie de stocker des données ++Menu ++Sélectionnez le périphérique de stockage amovible à utiliser. ++La traduction a échoué, car nous n'avons pas pu déterminer la langue de la page. ++Vous pouvez créer des profils supplémentaires pour autoriser plusieurs personnes à utiliser et personnaliser Google Chrome. ++Deux-points ++Toujours traduire en ++(désactivée) ++Cela signifie que le certificat n'a pas été vérifié par un tiers reconnu par votre ordinateur. N'importe qui peut émettre un certificat en se faisant passer pour un autre site Web. Ce certificat doit donc être vérifié par un tiers approuvé. Sans cette vérification, les informations sur l'identité du certificat sont sans intérêt. Par conséquent, il nous est impossible de vérifier que vous communiquez bien avec et non avec un pirate informatique ayant émis son propre certificat en prétendant être . Nous vous déconseillons vivement de continuer. ++ requiert que vous cryptiez vos données à l'aide de votre mot de passe Google ou de votre propre mot de passe multiterme. ++ ++N'est pas une autorité de certification ++Date et heure : ++Impossible de charger "" pour le thème. ++Rechercher à nouveau ++En attente de ... ++Masquer ce plug-in ++Enregistrer &sous... ++Ajouter une langue : ++Annuler ++Ouvrir une &adresse... ++Supprimer le mot ++Vous devez saisir deux fois le même mot de passe multiterme. ++Ouvrir dans un onglet épinglé ++Page Web, tout type de contenu ++Activer ++Considérer ce certificat comme fiable pour identifier les développeurs de logiciels. ++Ajouter tous les onglets aux favoris ++Impossible de créer le dossier de favoris. ++Copier l'URL ++Si vous pensez ne pas avoir à utiliser de serveur proxy, procédez comme suit : ++ ++Définir les utilisateurs autorisés à se connecter à un périphérique et autoriser les sessions de navigation en tant qu'invité ++Sélectionnez le répertoire racine de l'extension à empaqueter. Pour mettre à jour une extension, sélectionnez également le fichier de clé privée à réutiliser. ++Pool restreint : ++&Rafraîchir cette page ++&Normal ++PKCS #1 SHA-384 avec chiffrement RSA ++Numéro de série : ++HTTPS/SSL ++Toutes les données de votre ordinateur et des sites Web que vous visitez ++Ceci est une installation secondaire de et ce dernier ne peut pas être défini comme navigateur par défaut. ++Erreur lors de la signature de l'extension ++ permet d'effectuer des recherches sur Internet à l'aide du champ polyvalent. Sélectionnez le moteur de recherche à utiliser : ++Sécurité : ++Adobe Reader n'est pas à jour ++Extensions ou applications ++Effacer les cookies et autres données de site et de plug-in lorsque je ferme le navigateur ++Téléchargement de l'image terminé. ++Favoris ++Afficher les vignettes ++Ne plus afficher ce message ++Agent de récupération de clé Microsoft ++Page de diagnostic de navigation sécurisée ++Adresse ligne 2 ++Décrivez-nous le problème recontré. (Champ obligatoire) ++Cela peut prendre quelques minutes. ++Options de base ++Niveau de zoom par défaut : ++Stockage externe ++Modifi&er les moteurs de recherche... ++Cartes de paiement ++Nom du fichier ++Arrêter la synchronisation ++Actualiser le cadre ++Connexion ++Mémoire privée ++Tout effacer ++Activer la correction orthographique automatique ++Afficher les &infos sur la page ++favoris_.html ++Autoriser uniquement les utilisateurs suivants à se connecter : ++&Muet ++Nouvel ongle&t ++Erreur de synchronisation ++Zoom ++ sur ++Type de clavier ++Délai d'expiration atteint au niveau de la passerelle ou du serveur proxy en attente d'une réponse d'un serveur en amont. ++Déplacer ++Mode de saisie du vietnamien (VIQR) ++Ajouter la page actuelle aux favoris ++<aucun cookie sélectionné> ++Le mot de passe de l'application est incorrect. ++Sélectionner "un mot à la fois" ++Tout bloquer ++Chargement en cours… ++&Rouvrir la fenêtre fermée ++Gérer les exceptions... ++URL ++Katakana demi-chasse ++Ouvrir une adresse ++Données de navigation ++Code PIN incorrect. Veuillez réessayer. ++Non ++Utiliser cette langue pour corriger l'orthographe ++Fermer les autres onglets ++Clé privée non valide. ++Une erreur réseau s'est produite pendant la communication avec le service de gestion des périphériques. ++Importer les données d'un autre navigateur... ++&Ajouter au dictionnaire ++Voulez-vous vraiment ouvrir  onglets ? ++Fabricant du périphérique : ++Afficher l'historique complet ++Illimité ++Clavier Neo2 allemand ++Liste déroulante ++Clé : ++Coller en texte brut ++Afficher les &commandes ++Cette page suit votre position géographique. ++Certificat de chiffrement de courrier électronique ++&Profilage activé ++En savoir plus sur la récupération du système ++Essentielle ++Type MIME ++Autoriser le téléchargement ? ++Clavier croate ++Interdire à tous les sites de suivre ma position géographique ++Utiliser la barre de titre du système et les bordures de la fenêtre ++En bas à gauche ++Informations sur l'erreur : ++Essayez : saisissez "orchidées", puis appuyez sur Entrée. ++Pour utiliser Chrome Web Store, vous devez être connecté à un compte Google. ++Configurer ++Petit problème... Nous n'avons pas réussi à vous authentifier. Veuillez vérifier vos identifiants de connexion puis réessayer. ++Pour gérer à distance la configuration de ce périphérique depuis le cloud, connectez-vous avec votre compte Google Apps. ++Réactiver ++Fermer la fenêtre ++Présentation ++Vous avez saisi un trop grand nombre de codes PIN incorrects. Veuillez contacter pour obtenir une nouvelle clé de déverrouillage du code PIN à 8 chiffres. ++Bloquer le contenu inapproprié ++Configuration avancée ++Utiliser SSL 3.0 ++Règles de confidentialité liées à la navigation sécurisée ++Vous devez être connecté à votre compte Google pour importer les favoris de la barre d'outils Google dans Google Chrome. Connectez-vous et relancez l'importation. ++Ouvrir le lien dans une nouvelle &fenêtre ++Les cookies de ont été bloqués. ++Copies ++&Ouvrir le fichier audio dans un nouvel onglet ++Afficher les noms d'utilisateurs et leur photo sur la page de connexion ++URL de révocation de certificat Netscape ++Ajoute des options de regroupement des onglets dans le menu contextuel des onglets. ++Clavier finnois ++Vérifiez votre connexion Internet. Redémarrez votre routeur, votre modem ++ ou tout autre périphérique réseau que vous utilisez. ++&Afficher le code source de la page ++Le serveur ne prend pas en charge la version HTTP utilisée dans la demande. ++Vos mots de passe enregistrés s'afficheront ici. ++Fermer les onglets sur la droite ++ heures ++ ++ indique qu'un produit ESET intercepte les connexions sécurisées. ++ En général, cela ne constitue pas un problème de sécurité car le ++ logiciel ESET s'exécute souvent sur le même ordinateur. Toutefois, en raison ++ de certaines incompatibilités avec les connexions sécurisées ++ , ++ vous devez configurer les produits ESET de manière à éviter ces ++ interceptions. Cliquez sur le lien En savoir plus pour obtenir des instructions. ++Les requêtes adressées au serveur ont été temporairement limitées. ++Impossible de télécharger l'image. Gravure annulée. ++Activer/désactiver le mode Hanja ++Effacer les paramètres d'ouverture automatique ++Pas après le ++Manifeste : ++Visa ++Clavier anglais canadien ++Récupération de fichier Microsoft ++En&registrer l'image sous... ++Zone ++Chemin : ++Prendre la photo ++Inactif ++Certains de vos certificats enregistrés identifient ces autorités de certification : ++Impossible d'afficher la page Web, car le serveur n'a envoyé aucune donnée. ++Considérer ce certificat comme fiable pour identifier les utilisateurs de messageries. ++Ce type de fichier peut endommager votre ordinateur. Voulez-vous vraiment télécharger  ? ++Importés depuis la barre d'outils Google ++Recherche instantanée et saisie semi-automatique ++Tout synchroniser ++Dvorak (Hsu) ++Exécuter la commande  : ++Le fichier contenait un certificat, qui n'a pas été importé : ++Vous utilisez actuellement un mot de passe multiterme. Si vous l'oubliez, vous pouvez réinitialiser la synchronisation afin de supprimer vos données des serveurs Google à l'aide de Google Dashboard. ++Impossible de détecter les modules chargés. ++Cette fonctionnalité affiche une bordure autour des couches de rendu afin de déboguer et d'étudier leur composition. ++Processus de traitement Web : ++Invité ++Nom du fichier : ++Un élément est manquant. ++Échec de la tentative de connexion au serveur. ++Des fenêtres pop-up ont été bloquées sur cette page. ++Personnaliser les langues et la saisie... ++Proxy HTTP ++Mot de passe multiterme de chiffrement ++Nouvelle fenêtre ++Certains certificats provenant de ces organisations vous identifient : ++Autoriser l'itinérance des données mobiles ++Alt ++Utiliser les pages actuelles ++Version ++En&registrer le fichier audio sous... ++Itinérance ++Romaji ++ minutes ++Synchroniser uniquement les paramètres et\ndonnées qui ont changé depuis la dernière connexion\n(requiert votre mot de passe précédent) ++Autoriser tous les sites à afficher des notifications sur le Bureau ++Ouvrir le fichier... ++Changer de fenêtre ++Chèvres téléportées ++Si vous arrêtez la synchronisation, les données stockées sur cet ordinateur et dans votre compte Google demeureront à ces deux emplacements. Toutefois, les nouvelles données ou les modifications apportées au contenu existant ne seront pas synchronisées. ++Le certificat du serveur ne correspond pas à l'URL. ++Commune ++Impossible d'activer les plug-ins désactivés par une stratégie d'entreprise. ++Ne pas afficher sur cette page ++Méthodes EAP en Wi-Fi expérimentales ++Disque dur ++Nouveau dossier ++intégration sur ++Autorité de certification de messagerie ++Cache CSS ++En haut à gauche ++Saisissez le nom du nouveau dossier. ++L'extension de renégociation SSL était introuvable lors de la négociation sécurisée. Avec certains sites, connus pour leur prise en charge de l'extension de renégociation, Google Chrome exige une négociation mieux sécurisée afin de prévenir certaines attaques. L'absence de cette extension suggère que votre connexion a été interceptée et manipulée au cours du transfert. ++Petit problème... Une erreur de communication avec le réseau est survenue lors de la tentative d'inscription de ce périphérique. Veuillez vérifier votre connexion réseau et réessayer. ++pause ++Afficher tous les téléchargements... ++Connexion à ++Impossible de résoudre l'adresse DNS du serveur. ++En attente de l'affichage du cache ++Thèmes ++Impossible de se connecter au serveur proxy. ++Ignorer la synchronisation des données chiffrées ? ++Oui ++Nombre de suggestions par page ++Modifier le code PIN ++Un problème est survenu lors de la copie de l'image de récupération sur le périphérique. ++ jours restants ++La connexion Internet a été interrompue. ++Début ++« Précédent ++C&opier l'URL de la vidéo ++Vos données sur et ++Langue ++Mappages des stratégies de certificat ++ minutes restantes ++Sélectionner la position ++Le site Web à l'adresse contient des éléments provenant de sites signalés comme étant des sites de phishing. Ces derniers incitent les internautes à divulguer leurs informations personnelles en se faisant passer pour des institutions de confiance, telles que des banques. ++ ++Hors de portée ++Effacer l'historique de navigation ++Aucune page Web trouvée à l'adresse : ++Nouveau moteur de recherche : ++Jamais pour ce site ++ jours restants ++Impossible d'accéder au réseau. ++Modifier l'adresse ++&Masquer le panneau de la vérification orthographique ++1 cookie ++Activer ces fonctionnalités... ++ secondes restantes ++Cou&per ++Fermer la barre de recherche ++Signataire de la liste de révocation de certificats ++Afficher des informations à propos du site ++UC ++Fermer les pages ++MSPY ++ () ++Très petite ++Afficher les réseaux privés dans le menu Réseau pour activer la connexion à un VPN ++Vérification de la mise à jour du système... ++L'entrée demandée est introuvable dans le cache. ++Connectez-vous à pour importer le certificat client. ++Modifier la mise en page ++Se déconnecter ++Espace insuffisant. ++Préférences synchronisées ++Imp&rimer le cadre... ++MSCHAP ++Continuer à bloquer les images ++Lorsqu'un site utilise des plug-ins : ++Échec d'exportation de la clé publique ++Choisir les éléments à synchroniser ++Paramètres de saisie du Pinyin ++Ouvrir les pages suivantes : ++Déconnexion ++Moteurs de recherche ++Erreur de suppression de certificat ++Ne rien faire ++Épingler l'onglet ++réinitialiser la synchronisation ++PKCS #1 SHA-256 avec chiffrement RSA ++Katakana ++Choisir un réseau mobile ++&Historique ++Mode développeur : ++Lien ++Système ++Sélectionnez le fichier de clé privée. ++Insérez une carte SD ou une carte mémoire USB. ++Temps restant : ++Cliquez ici pour exécuter le plug-in . ++Hanyu ++pages ++Configuration en cours ++Erreur inconnue ++ days ago ++La langue utilisée pour Google Chrome est passée de "" à "" après la synchronisation de vos paramètres. ++&Aucune suggestion orthographique ++Erreur de protocole SSL ++Mode de saisie du thaï (clavier Pattachote) ++Ce compte utilisateur n'est pas compatible avec ce service. ++ ne peut pas être exécuté en tant que root. ++C&oller ++Paramètres de contenu... ++Dimensions de l'image ++Sélectionner le fichier à enregistrer sous ++Disque Flash ++Moteur de recherche actuel : ++L'identité de situé à a été vérifiée par . ++Version de l'autorité de certification Microsoft ++Enregistrer une capture d'écran ++Page sur ++Console &JavaScript ++Réponse reçue incorrecte lors de la tentative de chargement de . ++ Cela peut être dû à une opération de maintenance ou à une configuration incorrecte sur le serveur. ++Serveur DNS : ++Pré-rendu : ++Impossible d'accéder à la bibliothèque réseau. ++Des images ont été bloquées sur cette page. ++Toujours autoriser à afficher les images ++Copier l'adr&esse du lien ++Ouvrir dans une fenêtre de navigation privée ++Mode développeur ++Chiffrement des données ++Activer la protection contre le phishing et les logiciels malveillants ++Appuyez sur pour rechercher sur ++Voulez-vous utiliser () au lieu de pour gérer les liens :// à partir de maintenant ? ++Démarrer une session en tant qu'invité ++Nombre maximal de caractères chinois dans la mémoire tampon de pré-édition, notamment les entrées de symboles Zhuyin ++Barre de menus GNOME expérimentale disponible ++Effacer l'historique des téléchargements ++Navigateur bloqué... ++Parenthèse drte ++Calcul du temps de chargement ++Ajouter une carte de paiement... ++Itinérance : ++Arrêter ++Erreur de synchronisation... ++ID de clé de l'autorité de certification ++Extensions ++Imprimez où que vous soyez. ++Un problème est survenu lors du téléchargement de l'image de récupération. ++Cloud Print Proxy ++Une erreur s'est produite lors de la configuration de la synchronisation. ++Fichiers personnalisés ++Impossible de définir le mode une fois la fenêtre créée. ++Date et heure ++Personnaliser les préférences de synchronisation ++Aucune information disponible sur le forfait ++Signaler un problème ++Importer mes favoris et paramètres ++Sélectionnez le menu clé à molette > Paramètres > Options avancées > Modifier les paramètres du proxy et vérifiez que vos paramètres sont définis sur "sans proxy" ou "direct". ++Fermer et annuler les téléchargements ++Autres moteurs de recherche ++ peut maintenant synchroniser vos mots de passe. Pour protéger vos données, vous devez confirmer les informations relatives à votre compte. ++Cette fonctionnalité active les API P2P Pepper et P2P JavaScript. L'API est en cours de développement et n'est pas encore opérationnelle. ++L'identité de ce site Web n'a pas été vérifiée. ++Sessions à l'étranger ++Cette page répertorie tous les modules chargés dans le processus principal et les modules enregistrés de manière à être chargés ultérieurement. ++Afficher les &infos sur le cadre ++Connecté ++Paramètres d'entrée en Chewing ++Conserver sur cette page ++Votre support de récupération est prêt. Vous pouvez le retirer du système. ++Copi&er l'adresse e-mail ++Interdire à tous les sites d'afficher des fenêtres pop-up (recommandé) ++Console &JavaScript ++Empêcher cette page de générer des boîtes de dialogue supplémentaires ++En haut à droite ++Entrez le mot de passe associé à votre application : ++Mode de saisie Google du japonais (pour clavier japonais) ++ est à jour () ++Le serveur a mis fin à la connexion de manière inattendue. ++Il est possible que le serveur hébergeant la page Web soit surchargé ou ait rencontré une erreur. Pour éviter de générer ++ trop de trafic et d'aggraver la situation, ++ a temporairement ++ bloqué l'acceptation des requêtes adressées au serveur. ++ ++ Si vous pensez que ce comportement n'est pas souhaitable, (par exemple, dans le cas où vous déboguez votre propre site Web), vous pouvez ++ consulter la page , ++ sur laquelle vous pourrez trouver plus d'informations ou désactiver cette fonctionnalité. ++Gestionnaire de &fichiers ++Arrêter la synchronisation du compte ++Ajouter ++Sélectionnez le fichier à ouvrir ++Aucun forfait de données ++Créer un compte Google ++Code postal ++&Gestionnaire de tâches ++Téléphone ++Sélectionner l'onglet précédent ++Sélectionner un certificat ++Mots de passe enregistrés ++Autoriser l'accès aux URL de fichier ++Modifi&er les moteurs de recherche... ++Gérer les moteurs de recherche... ++PKCS #7, chaîne de certificats ++Clé pré-partagée : ++Contrôlez et partagez l'accès à vos imprimantes depuis n'importe quel compte Google. ++Ajoute l'option "Utiliser les onglets latéraux" au menu contextuel de la barre d'onglets. Utilisez cette option pour déplacer les onglets du haut de l'écran (affichage par défaut) vers le côté. Particulièrement utile sur les grands écrans. ++S'inscrire ++, ++Saisissez un nouveau nom. ++ ne peut pas être affiché dans cette langue. ++Erreur : impossible de décoder l'extension. ++Clavier bulgare ++Accès aux informations de l'autorité ++Ajouter un réseau privé... ++C&opier l'URL du fichier audio ++Masque de sous-réseau : ++Impossible d'accéder à votre compte ? ++Utiliser les touches - et = pour paginer une liste d'entrées ++Le serveur ne prend pas en charge l'extension de renégociation TLS. ++Résolution de l'hôte... ++Récemment fermés ++Le certificat de sécurité du site a été signé avec un algorithme de signature faible. ++Votre mot de passe a été modifié ++Gérer les paramètres de saisie automatique... ++La page Web n'est pas disponible pour le moment. Cela peut être dû à une surcharge ou à une opération de maintenance. ++Éjecter ++Impossible de lancer le processus de service. ++ Mo restants ++Nouvelle fenêtre ++Sélectionnez ++ ++ Applications > Préférences système > Réseau > Avancé > Proxys ++ ++ et désélectionnez les serveurs proxy sélectionnés. ++Gravure en cours d'initialisation... ++Téléchargement de l'image de récupération... ++il y a  minutes ++Mode de saisie du chinois (cangjie) ++Comté ++Ouvrir l'adresse dans un nouvel onglet ++&Rouvrir l'onglet fermé ++Impossible d'afficher la page Web, car votre ordinateur est passé en mode ++ veille ou hibernation. Dans ce cas, les connexions réseau sont ++ coupées et les requêtes réseau échouent. L'actualisation de la page ++ devrait permettre de résoudre ce problème. ++Certificat utilisateur : ++Autoriser ++Appuyer sur Entrée pour revenir en arrière et sur la touche de menu contextuel pour afficher l'historique ++ZRM ++Cookies et autres données ++Page(s) ne répondant pas ++Paramètres d'entrée hangûl ++Configurer la synchronisation... ++Modules (). Conflits connus : , conflits probables : ++Date de renouvellement du certificat Netscape ++Ouvrir tous les favoris dans une nouvelle fenêtre ++bouton radio concernant l'étendue de pages ++Saisissez votre mot de passe ++ est conçu pour rendre l'impression plus intuitive, accessible et utile. vous permet de rendre vos imprimantes accessibles depuis n'importe quelle application Web ou mobile associée à . ++Dictionnaire de kanji unique ++Rétablir tous les onglets ++Échec de l'installation de l'extension ++En savoir plus sur la manière de se protéger des logiciels malveillants en ligne ++Toujours afficher les fenêtres pop-up de ++Authentification phase 2 : ++Aucun résultat de recherche trouvé ++Ouvrir une fois le téléchargement &terminé ++ cookies ++Mode de saisie du japonais (pour clavier américain) ++Continuer à bloquer les plug-ins ++Épingler sur la barre des tâches ++Les certificats ont une période de validité, comme tous les documents relatifs à votre identité (tel qu'un passeport). Le certificat présenté à votre navigateur n'est pas encore valide ! Lorsqu'un certificat est en dehors de sa période de validité, il n'est pas nécessaire d'assurer la maintenance de certaines informations relatives à son état (s'il a été révoqué ou s'il n'est plus approuvé). Par conséquent, il est impossible de vérifier que le certificat est fiable. Ne poursuivez pas. ++Fermer la session d'invité ++Contrôlez vos tâches d'impression et l'état de connexion de vos imprimantes en ligne. ++Désinstallation ++Empreinte SHA-1 ++Modifier le code PIN de la carte SIM ++État du réseau : ++sans limite ++(Choisir une autre capture d'écran) ++Désactivation ++Aucune erreur n'a été signalée récemment. Les erreurs n'apparaissent ici que lorsque l'envoi de rapports d'erreur est activé. ++Rouvrir les dernières pages ouvertes ++Ouvrir en mode plein écran ++Ajouter une carte de paiement ++Désactivé ++Chargement des informations sur votre forfait Internet mobile, veuillez patienter... ++Acheter un forfait de données... ++Inclure cet e-mail : ++Le titre doit comporter au moins un caractère. ++Espaces de noms réseau ++ n'a pas pu terminer l'installation, mais va poursuivre son exécution à partir de son image disque. ++Gestion des services Internet mobiles ++Utiliser les onglets latéraux ++Non ++Saisir le code PIN de la carte SIM ++&Afficher dans le Finder ++Maintenez la touche Ctrl, Alt ou Maj enfoncée<br>pour afficher le raccourci clavier qui lui est associé. ++Vraiment désolé, aucun prototype n'est disponible pour le moment. ++&Afficher dans le Finder ++Informations relatives au certificat ++/ ++La synchronisation des mots de passe requiert votre attention. ++Veuillez saisir l'ancien et le nouveau code PIN. ++Langue : ++Résultats de recherche ++Serveur SSL avec fonction d'optimisation ++Enregistrer en PDF ++Mémoire USB détectée ++M'avertir lorsque le flux de données est faible ou presque inexistant ++Saisir le mot de passe multiterme ++Clavier lituanien ++Les éléments saisis dans le champ polyvalent peuvent être enregistrés. ++Les informations de connexion à votre compte sont obsolètes. Cliquez ici pour saisir à nouveau votre mot de passe. ++Vietnamien ++feuilles de papier ++URL de mot de passe perdu Netscape ++Rouvrir l'onglet fermé ++Effacer les mots de passe enregistrés ++Créer un nouveau dossier... ++Basculer en mode ponctuation pleine chasse ou demi-chasse ++Gérer les paramètres de localisation... ++Synchronisé... ++Options de recherche par défaut ++Aucune sélection ++Mode de saisie du vietnamien (TELEX) ++ minute restante ++Le nombre maximal d'autorités de certification intermédiaires a été dépassé : ++Saisissez un mot de passe pour chiffrer ce fichier de certificat. ++Organiser ++Votre mot de passe a changé. Veuillez réessayer avec votre nouveau mot de passe. ++PKCS #1 MD5 avec chiffrement RSA ++Utiliser le thème classique ++Échap efface toute la mémoire tampon de pré-édition ++Ajouter aux favoris ++Un incident est survenu sur une partie de cette page (HTML WebWorker). Elle risque de ne pas fonctionner correctement. ++Clavier américain ++Signataire de code ++Adobe Reader n'est pas à jour et risque de ne plus être sécurisé. ++Personnaliser les paramètres de synchronisation... ++Co&ller et rechercher ++Détails du certificat sélectionné : ++Impossible de se connecter ++Activation : ++Système de révocation introuvable dans le certificat du serveur ++Numéro de série ++Afficher la page "Nouvel onglet" ++il y a  heure ++Votre ordinateur redémarrera une fois la mise à jour effectuée. ++Verr. maj. ++L'accès au répertoire de l'hôte de communication à distance a été refusé. Essayez avec un autre compte. ++Accessible aux scripts : ++Cette page place des cookies. ++Proxy ++Avec sous-menu ++Afficher dans le dossier ++il y a  minutes ++<saisir une requête> ++Appuyez sur pour envoyer des commandes à . ++Prévisualiser le rapport ++Activer le dernier onglet ++Lorsque je quitte le navigateur ++Continuer sans mettre à jour Adobe Reader (non recommandé) ++Le champ de mot clé doit être vide ou comporter un mot unique ++Déplacer le curseur automatiquement au caractère suivant ++Enregistrer ++Ouvrir le lien dans un nouvel ongle&t ++Nouvelle fenêtre de navigation privée ++Celtique ++Réinitialiser le zoom ++Prototypes ++Mémoriser mes choix pour tous les liens de ce type ++Les plug-ins de cette page ont été bloqués. ++Site ++Sélectionner ++Couper ++Restaurer toutes les miniatures supprimées ++Utiliser les onglets latéraux ++Se connecter au dispositif de sécurité ++Enregistrer le fichier ++Pages ++Options de ++Barre de lancement rapide ++Annuler ++Choisir un fichier ++&Rechercher avec ++(pas encore valide) ++Mettre à jour le plug-in... ++Police Sans-Serif ++Impossible de charger le JavaScript "" du script de contenu. ++Connexion... ++Mots de passe ++Fichiers PKCS #12 ++Options de saisie automatique de ++Fenêtre précédente ++Astuce ++ / fichiers ++Localisation utilisée, mais les paramètres régionaux par défaut (default_locale) n'ont pas été indiqués dans le manifeste. ++Si vous n'êtes pas à l'origine de cette requête, il s'agit probablement d'une attaque contre votre système. Si vous n'avez pas lancé cette requête de manière intentionnelle, cliquez sur Ne rien faire. ++Votre commentaire a bien été envoyé. ++Fonction d'optimisation internationale Netscape ++Taille de police minimale ++Suivant ++Utilitaire : ++Cette opération peut prendre une minute... ++Le format du mot de passe est incorrect. ++Chargement... ++Ajouter la page... ++Masquer ce plug-in ++&Paramètres linguistiques... ++Créer un support de récupération du système d'exploitation ++Le fichier de clé privée est incorrect. ++Valeur : ++Stable ++Grande ++Certificat serveur invalide ++Jamais enregistrés ++Cette page a été préchargée. ++Google Chrome ne peut pas afficher l'aperçu avant impression lorsque la visionneuse de documents PDF intégrée est désactivée. Pour l'afficher, veuillez accéder à chrome://plugins, activer "Chrome PDF Viewer" et réessayer. ++Nouveau ! ++Vous êtes passé en navigation privée. Les pages que vous consultez dans cette fenêtre n'apparaîtront ni dans l'historique de votre navigateur, ni dans l'historique des recherches, et ne laisseront aucune trace (comme les cookies) sur votre ordinateur une fois que vous aurez fermé la fenêtre de navigation privée. Tous les fichiers téléchargés et les favoris créés seront toutefois conservés. Passer en navigation privée n'a aucun effet sur les autres utilisateurs, serveurs ou logiciels. Méfiez-vous : Des sites Web qui collectent ou partagent des informations vous concernant Des fournisseurs d'accès Internet ou des employeurs qui conservent une trace des pages que vous visitez Des programmes indésirables qui enregistrent vos frappes en échange d'émoticônes gratuites Des personnes qui pourraient surveiller vos activités Des personnes qui se tiennent derrière vous En savoir plus sur la navigation privée ++Le certificat du serveur a été révoqué. ++&Reprendre ++Sélectionnez un réseau : ++Impossible d'extraire les fichiers de l'extension. Pour effectuer cette opération en toute sécurité, vous devez disposer d'un chemin d'accès à votre répertoire de profils ne contenant pas de lien symbolique. Aucun chemin de ce type n'existe pour votre profil. ++Effacer les données de navigation ++Si vous êtes conscient que la visite de ce site peut être préjudiciable à votre ordinateur, vous pouvez . ++Votre périphérique est inscrit pour bénéficier de la gestion d'entreprise. ++Serveur de mise à jour non disponible (erreur : ) ++Module client natif : ++Rechercher sur  : ++Style de symboles ++ hours ++Département ++Continuer à utiliser ++OK ++Essayez de désactiver les prédictions d'actions du réseau en procédant comme suit : ++ Sélectionnez le ++ ++ menu clé à molette > ++ ++ > ++ ++ ++ et désélectionnez "". ++ Si le problème n'est pas résolu, nous vous conseillons de sélectionner de nouveau ++ cette option pour améliorer les performances. ++Date ++Sélectionnez un certificat pour vous authentifier sur . ++Barre latérale ++La clé publique éphémère Diffie-Hellman associée au serveur est peu sûre. ++Rechercher dans Dictionnaire ++Sélectionnez un moteur de recherche ++Clavier russe ++Nom Microsoft principal ++Clavier polonais ++Clavier serbe ++ minute ++Erreur lors de la lecture des données du cache. ++Canary ++Commentaire du certificat Netscape ++Page suivante ++ est à jour. ++Paramètres de saisie automatique... ++Tout ramener au premier plan ++Sélectionner le dossier à ouvrir ++Activer le mode Pinyin fuzzy ++Résolution du proxy... ++Le téléchargement de l'image a été interrompu. ++Eten 26 ++URI ++Clavier Dvorak américain ++Rechercher sur le Web... ++Si vous utilisez un serveur proxy, vérifiez les paramètres associés ou demandez à votre administrateur réseau ++ si ce serveur fonctionne. ++Impossible de charger l'icône de l'extension "". ++Définir un proxy pour se connecter au réseau ++zone de texte concernant l'étendue de pages ++Activation ++Clavier Dvorak britannique ++ jours ++MS-IME ++Aucun forfait de données ++Les fenêtres pop-up suivantes ont été bloquées sur cette page : ++ heures restantes ++Impossible de charger le modèle du favori. ++Échec d'exportation de la clé privée ++Utiliser comme page d'accueil ++Compte ++Plein écran ++Autoriser tous les sites à suivre ma position géographique ++Si la restauration du système d'exploitation de votre ordinateur s'avère nécessaire, une carte SD ou une clé USB de récupération vous sera demandée. ++Les cookies suivants ont été bloqués : ++Inclure les adresses de ma fiche de Carnet d’adresses ++Le certificat de sécurité du site n'est pas approuvé ! ++Votre liste d'applications, d'extensions et de thèmes installés ++Exécuter tous les plug-ins de cette page ++Augmente la taille du texte ++Accepter et continuer » ++Fichiers ++ ++Appliquer uniquement à cette session de navigation privée ++Latin large ++Exécuter ce plug-in ++MasterCard ++Sur le Web, Tab permet de sélectionner les liens, ainsi que les champs de formulaire. ++À propos de ++Paramètres de sécurité du système ++Images ++Cyrillique ++Pas maintenant ++Attendre la fin du téléchargement ++Thème "" installé ++&Supprimer ++Menu Démarrer ++&Zoom ++Transfert en cours ( %)... ++Géré par ++&Rafraîchir ++Configuration du module de plate-forme sécurisée (TPM) en cours. Veuillez patienter, cela peut prendre quelques minutes. ++Vous avez acheté une quantité illimitée de données le . ++Confirmer avant de quitter () ++Mémoire partagée ++Rech. dans les paramètres ++mot de passe d'accès au réseau ++Activer la vérification orthographique ++Types de données ++Bloquer ++Certificat de l'autorité de certification du serveur : ++Clavier grec ++Taille réelle ++Toujours en haut ++Aucun plug-in installé. ++Alerte JavaScript ++Autoriser en mode navigation privée ++Rétablir ++, expire le : ++Confirmer la désinstallation ++Impossible de désactiver les plug-ins ayant été activés par une stratégie d'entreprise. ++Cette fonctionnalité active l'option "Lire en un clic" dans les paramètres de contenu du plug-in. ++Attendre la fin des téléchargements ++Synchronisation ++&Rouvrir l'onglet fermé ++Votre mot de passe de compte Google a changé depuis votre dernière connexion à partir de cet ordinateur. ++Le fichier contenait plusieurs certificats, aucun d'eux n'a été importé : ++Afficher le bouton ++La saisie dans le champ polyvalent d'une URL déjà ouverte dans un autre onglet entraîne l'affichage de l'onglet en question, et non l'affichage de l'URL dans l'onglet actuel. ++Configuration en cours... ++Rechercher dans les téléchargements ++Me demander lorsqu'un site tente de suivre ma position géographique (recommandé) ++La nouvelle version de "" a été désactivée, car elle nécessite davantage d'autorisations. ++Clavier phonétique russe ++American Express ++Ce serveur exige un certificat d'authentification et n'a pas accepté celui envoyé par le navigateur. ++Votre certificat a peut-être expiré ou le serveur n'a pas approuvé l'émetteur. ++Réessayez avec un autre certificat si vous en avez un. ++Sinon, vous devrez en obtenir un nouveau d'un autre émetteur. ++Lorsque vous vous connectez à un site Web sécurisé, le serveur hébergeant ce site présente à votre navigateur un "certificat" afin de vérifier l'identité du site. Ce certificat contient des informations d'identité, telles que l'adresse du site Web, laquelle est vérifiée par un tiers approuvé par votre ordinateur. En vérifiant que l'adresse du certificat correspond à l'adresse du site Web, il est possible de s'assurer que vous êtes connecté de façon sécurisée avec le site Web souhaité et non pas avec un tiers (tel qu'un pirate informatique sur votre réseau). ++À l'instant ++Votre carte SIM sera définitivement désactivée si vous ne saisissez pas correctement la clé de déverrouillage du code PIN. Nombre de tentatives restantes : ++ / octets, Interrompu ++Importés depuis Firefox ++Détection automatique ++&Aide ++Les codes PIN sont différents ! ++Contenu Web ++Vider le cache ++Rétablir le thème par défaut ++Le service de communication à distance a démarré correctement. Vous devriez maintenant pouvoir vous connecter à distance à cet ordinateur. ++Outils de développement ++Police Serif ++Copier ++Adresse e-mail ou mot de passe incorrect. Veuillez réessayer. ++Le plug-in suivant ne répond pas : souhaitez-vous interrompre ? ++Sens ++ secondes ++Clavier tchèque ++Voulez-vous que "" soit considérée comme une autorité de certification fiable ? ++Gestionnaire de sécurité natif du client ++<p>Lorsque vous exécutez dans un environnement de bureau pris en charge, les paramètres proxy du système sont utilisés. Toutefois, soit votre système n'est pas pris en charge, soit un problème est survenu lors du lancement de votre configuration système.</p> ++ ++ <p>Vous avez toujours la possibilité d'effectuer la configuration via la ligne de commande. Pour plus d'informations sur les indicateurs et les variables d'environnement, veuillez vous reporter à <code>man </code>.</p> ++La page Web à l'adresse a déclenché trop de redirections. Pour résoudre le problème, effacez les cookies de ce site ou autorisez les cookies tiers. Si le problème persiste, il peut être dû à une mauvaise configuration du serveur et n'être aucunement lié à votre ordinateur. ++SSID : ++Nom du forfait : ++Adresse X.400 ++Fermer l'onglet ++Impossible de trouver un navigateur pris en charge. ++Le compte associé à la boutique en ligne est le suivant : . L'utilisation d'un autre compte pour la synchronisation provoque des erreurs. ++Enregistrer la p&age sous... ++ importe actuellement les éléments suivants à partir de  : ++Appuyez sur Entrée pour avancer et sur la touche de menu contextuel pour afficher l'historique ++Actualiser le cadre ++Annulé ++Autorités ++Sélectionnez votre clavier : ++Signaler un problème... ++Ignorer ce réseau ++Nouveau matériel détecté ++Vous disposez de certificats qui n'appartiennent à aucune autre catégorie : ++&Profilage activé ++(Navigation privée) ++&Nouveau dossier ++Types MIME : ++Afficher les pages en arrière-plan () ++Fichiers audio ++Plug-ins ++Plus d'informations... ++Se connecter automatiquement à ce réseau ++Titulaire de la carte ++Elle peut désormais accéder à : ++Noir et blanc ++Ignorer la connexion et naviguer en tant qu'invité ++Toutefois, cette page inclut d'autres ressources qui ne sont pas sécurisées. Ces ressources peuvent être consultées par des tiers pendant leur transfert, et modifiées par un pirate informatique dans le but de changer l'aspect et le comportement de cette page. ++Accès réseau interrompu ++La dernière version de l'extension "" requiert d'autres permissions. Elle a donc été désactivée. ++Dans ce cas, le certificat du serveur ou un certificat d'autorité intermédiaire présenté à votre navigateur n'est pas valide. Cela peut signifier que le certificat est incorrect, qu'il contient des champs non valides ou qu'il n'est pas compatible. ++Veuillez saisir la clé de déverrouillage du code PIN à 8 chiffres fournie par . ++Exceptions... ++Connexion à ++Voulez-vous vraiment quitter alors qu'un téléchargement est en cours ? ++Le site Web ne parvient pas à gérer la demande associée à . ++Précédent ++&Arrêter ++Lorsque l'option permettant de bloquer l'enregistrement des cookies tiers est activée, la lecture de ces cookies est également bloquée. ++ : ++Console JavaScript ++Les sites pour lesquels vos mots de passe ne seront jamais enregistrés s'afficheront ici. ++Inconnu ++Mode de saisie du thaï (clavier TIS-820.2538) ++&Favoris ++Désinstaller ++Voulez-vous vraiment quitter alors que  téléchargements sont en cours ? ++Configurer le blocage des cookies... ++ABC ++L'application hébergée par est inaccessible, car vous êtes déconnecté du réseau. Cette page s'affichera dès que la connexion réseau sera rétablie. <br> ++Gestionnaire de favoris ++ secs ago ++Quitter le mode plein écran ++Ouvrir l'&image dans un nouvel onglet ++Favori ajouté ! ++Choisir un autre dossier... ++Kotoeri ++Hier ++Synchroniser automatiquement les éléments suivants : ++Votre ordinateur intègre un périphérique de sécurité TPM (module de plate-forme sécurisée) qui permet de mettre en œuvre plusieurs fonctionnalités de sécurité critiques dans Google Chrome OS. ++Contraintes des stratégies de certificat ++Créer un support de récupération ++Emplacement : ++Toutes les pages que vous consultez apparaîtront ici à moins que vous ne les ouvriez dans une fenêtre en navigation privée. Vous pouvez utiliser le bouton Rechercher de cette page pour rechercher dans toutes les pages de votre historique. ++Options pour les développeurs ++Cookies ++Toujours exécuter pour ce site ++Afficher le dossier ++Autres favoris ++Clavier français ++ ne parvient pas à déterminer ou à définir le navigateur par défaut. ++Sélectionner l'onglet suivant ++Voulez-vous vraiment supprimer ces pages de votre historique ? ++Déverrouiller ++ID de clé : ++Exécuter ce plug-in ++Utilisateurs ++Ajouter un moteur ++Répondeur OCSP : ++Ignorer ++Champs de certificat ++Modules () : aucun conflit détecté. ++Onglet : ++Impossible de charger la page d'options "". ++Coller en adaptant le style ++Veuillez ajouter une autre langue avant de supprimer celle-ci. ++nom du réseau ++ synchronise de manière sécurisée vos données avec votre compte Google. ++Taille ++Activer... ++Recherche ++Poursuivre quand même ++Nouveau code PIN : ++La capacité du périphérique doit être d'au moins 4 Go. ++De droite à gauche ++Activer le mode Pinyin double ++Menu contenant des favoris masqués ++Utiliser le dictionnaire système ++Vous avez choisi de chiffrer les données à l'aide de votre mot de passe Google. Vous pouvez modifier vos paramètres de synchronisation à tout moment, si vous changez d'avis. ++Personnaliser les polices... ++Enregistrement des informations de date ++&Vérifier l'orthographe du texte de ce champ ++Ceci est un modèle expérimental qui permet aux enregistrements DNS (utilisant le protocole de sécurité DNSSEC) d'autoriser ou de refuser des certificats HTTPS. Ce message s'affiche lorsque vous activez des fonctionnalités expérimentales via des options de ligne de commande. Vous pouvez supprimer ces options de ligne de commande pour ignorer cette erreur. ++ minutes restantes ++Île ++Contraintes de base du certificat ++Autres... ++Activer l'onglet 4 ++Données personnelles ++Afficher l'original ++Nom de la société ++Définir Adobe Reader comme visionneuse de documents PDF par défaut ? ++Pour gérer les extensions installées, cliquez sur Extensions dans le menu Fenêtre. ++Accédez à vos imprimantes depuis n'importe quel ordinateur ou smartphone. En savoir plus ++Me &le rappeler plus tard ++Opération réussie ! ++Carte SD détectée. ++ - Propriétaire ++Clavier japonais ++WPA ++janv.^févr.^mars^avr.^mai^juin^juil.^août^sept.^oct.^nov.^déc. ++Sélectionnez ++ ++ Applications > Préférences système > Réseau > Assistant ++ ++ pour tester votre connexion. ++&Afficher le code source de la page ++Micrologiciel : ++Créer un profil ++Date de modification ++Sandbox seccomp ++Signale&r un problème... ++Entrée de symboles simplifiée ++Chinois simplifié ++Hôte SOCKS ++Considérer ce certificat comme fiable pour identifier les sites Web. ++Exceptions de localisation ++Hiragana ++Le mot de passe TPM ci-dessous, généré de façon aléatoire, a été attribué à votre ordinateur : ++Importer mes favoris maintenant... ++ ++Avertissement : Un problème a été détecté sur cette page. ++Avec Google Chrome OS for business, vous pouvez connecter votre périphérique à Google Apps, ce qui vous permet de le rechercher et de le contrôler depuis le panneau de configuration de Google Apps. ++Ajouter tous les onglets aux favoris... ++Émis le ++Lorsque je ferme le navigateur ++Localisation ++Attendre ++Infos sur la clé publique de l'objet ++Plug-in inconnu ++Connexion en mode invité ++Toujours autoriser à paramétrer les cookies ++Résumé ++Le certificat du serveur n'est pas valide. ++Chaîne de certificats codés Base 64 ASCII ++Choisir mon propre mot de passe multiterme ++Certificat de serveur non répertorié ++Rechercher la sélection ++Activer ++L'accès à ce réseau est protégé. ++E-mail ++Erreur () : ++Signature permanente Microsoft ++Sélectionnez ++ ++ Démarrer > Panneau de configuration > Réseau et Internet > Centre Réseau et partage > Résolution des problèmes (en bas) > Connexions Internet. ++ ++Gestionnaire de &fichiers ++Service client ++Impossible de se connecter au réseau "". ++J'accepte ces termes ++Copier l'adr&esse du lien ++Veuillez démarrer en tant qu'utilisateur normal. Pour l'exécuter en tant que root, vous devez indiquer un autre répertoire de données utilisateur pour stocker les informations du profil. ++Le processus du connecteur est bloqué. Voulez-vous le redémarrer ? ++Contenu Web ++Clé compromise ++Supprimer ++Si vous fermez maintenant, ces téléchargements seront annulés. ++Dachen 26 ++Voulez-vous vraiment graver l'image sur le périphérique suivant : ++Mémoire SQLite ++/, ++ est affiché dans cette langue. ++Fenêtre pop-up bloquée ++ : ++Ouvrir tous les favoris ++Effacer les cookies et autres données de site et de plug-in lorsque je ferme le navigateur ++Page d'accueil ++Onglet ++Non configuré ++Opération réussie ! ++Relancez pour terminer la mise à jour. ++Chiffrer toutes mes données ++Veuillez patienter pendant que nous configurons votre réseau pour mobile. ++Points de distribution de listes de révocation des certificats ++Association ++Appuyez sur Maj+Alt pour changer la disposition du clavier. ++Utiliser l'horloge au format 24 heures ++ est prêt à terminer l'installation. ++Lancez votre recherche à partir d'ici ++OK, synchroniser tout ++Afin d'être correctement affichée, cette page requiert des données que vous avez précédemment entrées. Vous pouvez de nouveau transmettre ces données, mais, en procédant ainsi, vous devrez répéter chaque action que cette page a effectuée auparavant. Cliquez sur Rafraîchir pour transmettre de nouveau ces données et pour afficher cette page. ++Cela signifie que le certificat présenté à votre navigateur a été révoqué par son émetteur. L'intégrité de ce certificat a certainement été compromise, et il ne doit donc pas être approuvé. Ne poursuivez pas. ++Clavier slovaque ++Nom de partie EDI ++Vous avez déjà chiffré des données avec un mot de passe multiterme. Saisissez-le ci-dessous. ++Informations sur le site ++Créer un raccourci vers l'application... ++Authentification requise ++ n'est pas parvenu à se connecter à . Sélectionnez un autre réseau ou réessayez. ++Votre compte n'est pas compatible avec . Contactez l'administrateur de votre domaine ou utilisez un compte Google standard pour vous connecter. ++Adresse e-mail ++Client natif ++Chargé depuis : ++Active les balises canvas hautes performances dans un contexte 2D, pour effectuer le rendu via le processeur graphique. ++Cette page ena été traduite en ++Seule une personne en possession de votre mot de passe multiterme peut lire vos données chiffrées. Google ne reçoit ni n'enregistre votre mot de passe multiterme. Si vous oubliez votre mot de passe multiterme, vous devrez ++Autorité de certification SSL ++ contient un logiciel malveillant. Votre ordinateur pourrait être infecté par un virus si vous consultez ce site. ++Aucune donnée disponible. ++Im&primer... ++Description ++Voix non reconnue. ++Aucun fichier sélectionné ++Souhaitez-vous installer  ? ++Activité récente ++de la dernière semaine ++Profil ++Actualiser sans utiliser le cache ++Logiciels malveillants et sites de phishing détectés ! ++Onglet fermé ! ++il y a  jours ++Paramètres ++Ce site exige que vous vous identifiiez avec un certificat : ++Supprimer... ++&Aucune suggestion orthographique ++Clavier franco-canadien ++Clavier étendu américain ++Le serveur a mis fin à la connexion sans envoyer de données. ++Autoriser à afficher des notifications sur le Bureau ? ++Pour gérer les extensions installées, cliquez sur Extensions dans le menu Outils. ++Erreur de synchronisation, veuillez vous connecter à nouveau. ++La liste suivante fait état des éléments dangereux détectés sur la page. Cliquez sur le lien "Diagnostic" pour obtenir plus d'informations sur un élément particulier. ++Émirat ++Synchroniser tous les paramètres et toutes les données\n(peut prendre un certain temps) ++Toujours demander où enregistrer les fichiers ++Créer un raccourci ++Tous les fichiers ++Sebeol-sik No-shift ++Anglais (pleine chasse) ++2D avec canvas et accélération matérielle ++Cette fonctionnalité autorise l'installation d'applications Google Chrome déployées à partir d'un manifeste situé sur une page Web, plutôt qu'avec un fichier crx contenant le manifeste et les icônes. ++Nouvelle connexion ++GPU ++Moins de 1 Mo disponible ++Nouvelle fenêtre de navigation privée ++Europe du Sud ++Sélectionner les éléments à synchroniser ++Attributs du répertoire de l'objet du certificat ++Accédez à vos imprimantes et partagez-les en ligne via . ++&Ajouter... ++Afficher dans cette langue ++il y a  jour ++Police Sans-Serif ++Ne rien faire ++ seconde ++Configurer les mises à jour automatiques pour tous les utilisateurs ++Échec de la création du répertoire des données ++Fermer et annuler le chargement ++ ++Adresse : ++Détails ++Notification : ++Cette opération peut prendre quelques minutes. ++Géré par () ++Type de certificat Netscape ++Impossible d'afficher certaines parties de ce document PDF. Souhaitez-vous installer Adobe Reader ? ++Vos certificats ++Vos données personnelles sur , et ++URL de stratégie de l'autorité de certification Netscape ++Dernier accès : ++Synchroniser les mots de passe ++&Quitter ++&Fermer l'onglet ++, ++Le site Web à l'adresse contient des éléments provenant de sites qui semblent héberger des logiciels malveillants. Ces derniers peuvent nuire à votre ordinateur ou agir à votre insu. Le simple fait de visiter un site hébergeant ce type de logiciels peut infecter votre ordinateur. ++Total : ++Les cookies de plusieurs sites ont été autorisés pour la session uniquement. ++Nom du service : ++Imprimer une page de test ++Aperçu avant impression - ++ ++ ne peut pas à afficher la page Web, car votre ordinateur n'est pas connecté à Internet. ++Exécuter cette fois ++Chiffrement de la clé ++Échec de la vérification AAA ++Ouverture dans ... ++&Copier ++Logiciel ++Moteurs de recherche ++&Méthodes d'entrée ++Jamais enregistrés ++Impossible d'analyser le fichier. ++Subordination qualifiée Microsoft ++Bureau ++Toujours traduire en les pages en ++Thaï ++Activer l'onglet suivant ++: de chargement ++Style de mappage du clavier ++Un problème lié à votre microphone s'est produit. ++ vous permet d'accéder aux imprimantes de cet ordinateur, où que vous soyez. Connectez-vous pour l'activer. ++District ++Ethernet ++Erreur de réseau inconnue. ++Nom du certificat ++Plus d'informations ++Mise à jour du système disponible. Préparation du téléchargement… ++Galerie des thèmes Google Chrome ++Copi&er l'adresse e-mail ++Activer l'onglet 3 ++Adresses ++Plug-in : () ++Pas maintenant ++Pays ++<Ne fait pas partie du certificat> ++il y a  seconde ++Fichiers image ++Europe centrale ++Certificat client SSL ++Pour accélérer l'affichage des pages Web, ++ ++ enregistre temporairement les fichiers téléchargés sur le disque. Si ++ ++ ne s'arrête pas correctement, ces fichiers peuvent être endommagés, ce qui ++ génère cette erreur. L'actualisation de la page devrait permettre de résoudre ++ ce problème ; celui-ci ne se reproduira vraisemblablement plus si l'arrêt s'effectue ++ correctement. ++ ++ Si le problème persiste, essayez de supprimer le contenu du cache. Cette ++ erreur peut aussi indiquer que le matériel est sur le point de tomber ++ en panne. ++Thème créé par ++Données de navigation ++Ajouter cette page aux favoris ++Le serveur a refusé la connexion. ++Module ( bits) :\n\n\nExposant public ( bits) :\n ++ secondes restantes ++Vous utilisez un indicateur de ligne de commande non pris en charge : . La stabilité et la sécurité en seront affectées. ++Emplacement de téléchargement ++À propos de Google Traduction ++Les lettres ne sont pas sensibles à la casse. ++Mot clé ++Connexion ++Redémarrez pour appliquer la mise à jour. ++Sélectionner un carré dans l'image ++Bases de données Web ++Codage ++Mise en route ++Utiliser les pages actuelles ++Signaler une erreur ++Recherche de réseaux en cours ++Effacer les données de navigation ++Ouvrir le lien dans une nouvelle &fenêtre ++Nom d'utilisateur ++Clavier letton ++Forcer l'actualisation de cette page ++Disposition du clavier : ++Non utilisé ++ minutes ++Chiffrement RSA PKCS #1 ++Ce n'est probablement pas le site que vous recherchez ! ++&Général ++Configurer la synchronisation ++État de connexion : ++Ancien code PIN : ++Désactiver le contrôle des liens hypertexte ++&Modifier ++Chinois ++Navigateur par défaut ++Extension en mode navigation privée : ++Mot clé : ++Un problème est survenu lors du téléchargement de l'image de récupération. La connexion réseau a été perdue. ++Votre administrateur a désactivé certaines préférences. ++Forfait de données épuisé ++Veuillez indiquer à quel niveau vous rencontrez des problèmes avant d'envoyer vos commentaires. ++Authentification du serveur WWW TLS ++Le service de synchronisation n'est pas disponible pour votre domaine. ++Modifier les paramètres du proxy... ++Cette fonctionnalité active les API des extensions expérimentales. Notez que vous ne pouvez pas mettre en ligne des extensions qui font appel aux API expérimentales dans la galerie d'extensions. ++Un logiciel malveillant a été détecté ! ++Forfait de données presque épuisé ++des dernières 24 heures ++Une fois activée, la recherche instantanée charge la plupart des pages Web dès que vous saisissez l'URL dans le champ polyvalent, avant même que vous n'appuyiez sur Entrée. Si votre moteur de recherche par défaut est compatible, toute lettre saisie dans ce champ offre de nouveaux résultats et les prédictions intégrées vous guident dans vos recherches.\n\nChaque touche utilisée fait l'objet d'une requête, par conséquent il se peut que les éléments saisies dans le champ polyvalent soient enregistrés par votre moteur de recherche par défaut.\n ++ hours left ++poursuivre quand même ++Autorisé ++Retirer l'onglet ++Moins de ++Impossible de charger l'icône "" d'action du navigateur. ++Consulter Google Dashboard ++Plus d'informations ++Ajoutez des langues puis faites-les glisser pour les classer dans l'ordre souhaité. ++ sera lancé au démarrage du système et continuera de s'exécuter en arrière-plan, même toutes les fenêtres de sont fermées. ++Non (HttpOnly) ++Saisir votre mot de passe multiterme pour la synchronisation ++Police standard ++ (par défaut) ++Cette fonctionnalité active la prise en charge du client natif. ++La puce du module de plate-forme sécurisée (TPM) est désactivée ou inexistante. ++L'index de l'onglet indiqué est incorrect. ++Nom du serveur SSL du certificat Netscape ++Est une autorité de certification ++Wi-Fi ++Connexion à ++Confirmer le mot de passe : ++Aperçu avant impression ++Clavier italien ++Impossible d'établir une connexion sécurisée à cause de l'antivirus ESET. ++(expiré) ++Voulez-vous vraiment quitter cette page ? ++Faire défiler d'une page vers le haut ++Empreintes ++Le plus récent ++ heures ++Agrandir ++La page Web est introuvable dans le cache. Certaines ressources ne sont restituées fidèlement que si elles sont extraites du cache, notamment les pages générées à partir de données que vous avez envoyées. Cette erreur peut également être due à un cache endommagé lors d'une fermeture incorrecte. Si le problème persiste, essayez d'effacer le cache. ++Le plug-in n'est plus à jour. ++Vous avez changé de position. Souhaitez-vous utiliser  ? ++EAP-TLS ++ heures ++Rafraîchir cette page ++Non-répudiation ++Extension : ++Active l'API Web audio. ++Zone de saisie de mot de passe ++Effacer les cookies et autres données de site lorsque je quitte le navigateur ++Ajouter l'option de regroupement au menu contextuel des onglets ++Version ++Latin ++Le connecteur requiert l'installation du pack Microsoft XML Paper Specification Essentials. ++Effacer les cookies et autres données de site lorsque je ferme le navigateur ++Case décochée ++Mise en page ++Saisir un nom ou une adresse ++Choix de l'image du compte ++Me montrer ++ minutes restantes ++De : ++Ouvrir un rapport de phishing ++Page de phishing ++Inspecter le pop-up ++Importer... ++Modifier la carte de paiement ++Cette langue est utilisée pour corriger l'orthographe. ++Le type d'enregistrement indiqué est incorrect. ++Forfait de données arrivé à expiration ++Exporter mes favoris... ++Clavier britannique ++Importer des favoris... ++ ++Nom d'utilisateur ou mot de passe incorrect ++&Tout sélectionner ++Erreur inconnue liée au certificat du serveur. ++Envoyer une capture d'écran enregistrée ++Émis pour : ++Page précédente ++Hsu ++Réduire ++Navigateur par défaut ++Afficher le mot de passe ++Activer les fonctionnalités d'accessibilité ++Inclure la capture d'écran actuelle : ++ - ++(cette extension est gérée et ne peut être désinstallée ni désactivée) ++OID enregistré ++Importés depuis IE ++Fichier de clé privée (facultatif) : ++Autoriser pour la session uniquement ++ mins ++Mise à jour en cours ++Aucun microphone trouvé. ++Connexion à ++ n'est pas votre navigateur par défaut. ++Forfait ++Cette page contient des éléments des sites ci-dessous qui suivent votre position géographique : ++Plusieurs profils ++Plantages ++Par défaut ++ jours ++PKCS #1 MD4 avec chiffrement RSA ++Modifier le moteur de recherche ++ minutes ++Indiquez le mot de passe approprié ci-dessus, puis saisissez les caractères figurant dans l'image ci-dessous. ++Expiration de imminente ++Activer l'onglet précédent ++Désactiver l'accès à distance ++Afficher les incompatibilités ++Carte de débit Solo ++Actualisez cette page Web ultérieurement. ++Pour utiliser cette extension, saisissez "", TAB, puis votre commande ou votre recherche. ++ synchronisera les applications installées, afin que vous puissiez y accéder en vous connectant depuis tout navigateur . ++Langues et paramètres du correcteur orthographique... ++Erreur de sécurité ++Applications ++La ressource demandée n'existe plus et aucune adresse de transfert n'est disponible. Il semble que cet état de fait soit permanent. ++Certificat unique binaire codé DER ++&Plein écran ++Fichiers vidéo ++ indique que ++ NetNanny intercepte les connexions sécurisées. En général, cela ++ ne constitue pas un problème de sécurité, car le logiciel NetNanny s'exécute souvent ++ sur le même ordinateur. Toutefois, en raison de certaines incompatibilités avec ++ les connexions sécurisées Google Chrome, vous devez configurer NetNanny ++ de manière à éviter ces interceptions. Cliquez sur le lien En savoir plus pour obtenir des instructions. ++Vos onglets et activités de navigation ++Créer ++Turc ++Une erreur s'est produite lors de la tentative d'enregistrement du certificat client. Erreur  () ++Bienvenue dans ++Sélectionner ++Nom du modèle de certificat Microsoft ++Configuration de l'adresse IP pour ++Immortalisez votre plus beau sourire et utilisez la photo comme image de compte. ++Extension créée : ++ ++ ++Mot de passe incorrect. Veuillez réessayer. ++LEAP ++Échec de la connexion aux serveurs de reconnaissance vocale. ++Très grande ++Sélectionner le répertoire de l'extension ++&Téléchargements ++Gestionnaire des certificats ++ souhaite suivre votre position géographique ++Quitter ++ sur ++Proposer d'enregistrer les mots de passe ++Modification de l'affiliation ++par exemple : 1-5, 8, 11-13 ++(Activé par une stratégie d'entreprise) ++Qu'est-ce que c'est ? ++Les cookies de plusieurs sites ont été bloqués. ++Serveur DNS spécifié par l'utilisateur et utilisé par Google Chrome, à la place du paramètre système par défaut, pour les résolutions DNS. ++Désactivé ++Annuler ++Répertoire racine de l'extension : ++Mode de saisie du vietnamien (TCVN6064) ++Échec de l'activation ++Ajouter cette page aux favoris ++L'identité de ce site Web a été vérifiée par . ++Adresse e-mail : ++Activation... ++PAP ++Sites de phishing ++ secs ago ++Interdire à tous les sites d'exécuter JavaScript ++Vouliez-vous accéder à  ? ++La connexion avec le service de configuration a été perdue. Veuillez réinitialiser votre périphérique ou contacter votre représentant de l'assistance technique. ++Paramètres des fenêtres pop-up : ++Tout exporter... ++Barre de favoris ++Stocké dans : ++Développer... ++Gin Yieh ++Rechercher sur ++Modifier la carte de paiement ++Au démarrage ++Nous examinons actuellement le problème. ++Notifications ++Navigateur ++Case d'option décochée ++ days ++Anglais ++Modifier le nom du dossier ++Grammaire et orthographe ++Réseaux privés ++Toutes sortes de connexions ++Exceptions liées aux notifications ++Épingler les onglets ++Barre d'onglets ++Activer l'onglet 6 ++Gestionnaire de &tâches ++Paramètres de stockage d'Adobe Flash Player... ++Connexion au réseau ++Mode de saisie du vietnamien (VNI) ++L'application suivante va être lancée si vous acceptez cette requête :\n\n ++Importation... ++N° de carte ++Gérer les moteurs de recherche... ++Utiliser un moniteur externe ++Gravure de l'image en cours... ++État ++Éteindre ++Enregistrer les fichiers dans le dossier : ++Fermer les autres onglets ++Répertoire de fichiers ++Masquer les autres ++Annuler l'épinglage des onglets ++Plus ++Échec de la vérification de la révocation ++Ajouter www. et .com, puis ouvrir la page ++Pour inspecter un pop-up, cliquez avec le bouton droit sur la page ou sur l'icône d'action du navigateur, puis sélectionnez Inspecter le pop-up. ++&Répéter ++ est à présent activé. a enregistré les imprimantes installées sur cette machine en les associant à <b></b>. Vous pouvez désormais utiliser vos imprimantes depuis n'importe quelle application Web ou mobile associée à . ++Le serveur de ++ est introuvable, car la résolution DNS a échoué. DNS est le service Web qui ++ traduit les noms de site Web en adresses Internet. Cette erreur est ++ généralement due à l'absence de connexion Internet ou à une configuration ++ incorrecte du réseau. Cela peut également venir d'un serveur DNS qui ne ++ répond pas ou d'un pare-feu interdisant l'accès de ++ ++ au réseau. ++ZGPY ++Impossible de charger le fichier css "" du script de contenu. ++Créer des raccourcis vers des applications aux emplacements suivants : ++Moyenne ++Envoyé pour : ++Aider Google à détecter les logiciels malveillants en envoyant des données supplémentaires concernant les sites pour lesquels cet avertissement s'affiche. Ces données seront gérées conformément aux règles définies sur la page . ++[répertoire parent] ++Touches de sélection du clavier Hsu ++Copie de l'image de récupération... ++Tout supprimer ++Seule une personne en possession de votre mot de passe multiterme peut lire vos données chiffrées. Google ne reçoit ni n'enregistre votre mot de passe multiterme. Si vous oubliez votre mot de passe multiterme, vous devrez réinitialiser la synchronisation. ++Ouvrir dans une nouvelle fenêtre ++Dommage... Aucune extension n'est installée. :-( ++Style de ponctuation ++Historique de navigation ++Ce site tente de télécharger plusieurs fichiers. Voulez-vous autoriser le chargement ? ++Établissement de la liaison avec le service de gestion des périphériques en attente... ++ heures ++Ne pas utiliser les paramètres du proxy pour les hôtes et domaines suivants : ++&Avancer ++Impossible de charger "" pour le plug-in. ++À propos du système ++Utilisation de la clé du certificat : ++Mode de saisie du chinois (quick) ++Une erreur s'est produite lors de la tentative d'écriture du fichier : . ++Renommer ++La synchronisation requiert votre attention. ++Aujourd'hui ++Imp&rimer le cadre... ++Le site a déjà été informé qu'un logiciel malveillant a été détecté sur ses pages. Pour plus d'informations concernant les problèmes rencontrés sur , consultez notre Google. ++Adresse de serveur DNS spécifiée par l'utilisateur. ++&Rechercher... ++, ++&Afficher dans le dossier ++Non connecté à Internet. ++Sélectionnez ++ ++ Démarrer > Panneau de configuration > Connexions réseau > Assistant Nouvelle connexion ++ ++ pour tester votre connexion. ++Cette icône s'affiche lorsque l'extension peut agir sur la page active. ++Reconnexion ++Réponses OCSP de signature ++Erreur d'importation de l'autorité de certification ++Gravure de l'image terminée. ++&Historique ++Installer ++Ajouter des utilisateurs ++Enregistrer l'authentification et le mot de passe ++Clavier norvégien ++Basculer en mode chinois/anglais ++Traduction de la page en ... ++À propos de & ++ onglets ++il y a  minutes ++Qu'est-ce que c'est ? ++Tout &sélectionner ++&Ajouter au dictionnaire ++Utilisation étendue de la clé ++Le chinois est la langue de saisie initiale ++Agent utilisateur ++Émetteurs de l'autorité de certification : ++ jours ++Code source ++Redémarrer maintenant ++La largeur de caractères initiale est Complète ++Pour masquer l'accès à ce programme, vous devez le désinstaller au moyen de \n du Panneau de configuration.\n\nSouhaitez-vous exécuter  ? ++Paramètres du microphone ++Port ++&Toujours ouvrir les fichiers de ce type ++Uniquement les connexions sécurisées ++Les informations de connexion au compte sont obsolètes. ++La traduction a échoué, car la page est déjà en . ++Sandbox SUID ++(vide) ++Échec de l'authentification basée sur le certificat ++Envoyer le code source de la page actuelle ++Votre administrateur a désactivé certains paramètres. ++Coréen ++Avertissement : Il s'agit peut-être d'un site de phishing ! ++Dvorak ++Étendue de pages incorrecte ++ heures restantes ++Exceptions liées aux cookies et aux données de site ++ n'est pas accessible ++P&lus grand ++Connecté à ++Le certificat de sécurité du site a été révoqué ! ++Désactiver ++ risque de ne pas rester à jour. ++intégré sur tout autre site ++ ++ ne parvient pas à atteindre le site Web. Cela vient probablement d'un problème de réseau, ++ mais peut également être dû à un pare-feu ou à un serveur proxy mal configuré. ++À propos de la reconnaissance vocale ++Langues et paramètres du correcteur orthographique... ++ seconde restante ++Nom d'utilisateur : ++Le stockage des cookies n'est pas autorisé pour cette page. ++JavaScript ++La connexion utilise . ++Échec de l'installation ++Afficher les &infos sur la page ++Serveurs ++Système de fichiers de chiffrement Microsoft ++Un plug-in supplémentaire est requis pour afficher certains éléments sur cette page. ++Appuyez sur Ctrl+Alt+/ ou sur Échap pour masquer ++Cette fonctionnalité effectue des vérifications en arrière-plan et vous avertit en cas d'incompatibilité logicielle (modules tiers bloquant le navigateur, par exemple). ++Connexion avec ++Imprimer depuis la boîte de dialogue système… ++ heure restante ++Échec de l'initialisation de l'appareil photo ++Importés ++Type de fournisseur : ++IP restreinte : ++Refuser ++Démarrage du téléchargement en cours... ++Une nouvelle version de est disponible. ++Clavier hébreu ++Police à largeur fixe ++Safari ++Les champs obligatoires ne doivent pas rester vides. ++Ouvrir une fois le téléchargement &terminé ++Stratégies de certificat ++Pavé tactile ++Aucun ++Activer la barre d'adresse en mode recherche ++Exceptions pour JavaScript ++Ouvrir dans une nouvelle fenêtre ++Veuillez saisir le code PIN. ++Options de saisie automatique... ++Arabe ++Nouveau dossier ++E/S réseau interrompue ++Rechercher le précédent ++Ne jamais enregistrer les mots de passe ++Ouvrir dans un nouvel onglet ++Fenêtre suivante ++&Rechercher le suivant ++JCB ++Signature de liste d'approbation Microsoft ++Gérer les certificats... ++Sélectionnez le fichier de certificat. ++Fabricant : ++Bloquer le contenu inapproprié ++Le fichier contenait plusieurs certificats, dont certains n'ont pas été importés : ++Exceptions pour les images ++Autoriser tous les sites à afficher des fenêtres pop-up ++Vous devez indiquer un chemin valide comme valeur de clé privée. ++Sans mot de passe multiterme, vos mots de passe et autres données chiffrées ne seront pas synchronisés sur cet ordinateur. ++Extensions ou applications ++Ce site recommande Google Chrome Frame (déjà installé). ++Les plus visités ++Vous n'êtes pas autorisé à vous connecter. Consultez le propriétaire de cet ordinateur portable. ++Remarque : Lorsque vous cliquez sur "Envoyer", Google Chrome joint à votre ++ envoi un journal indiquant votre version de Google Chrome et celle du système ++ d'exploitation utilisé, ainsi que l'URL associée à votre rapport. Vous pouvez ++ également joindre une capture d'écran. Ces informations nous ++ permettent de diagnostiquer les problèmes et d'améliorer les performances de ++ Google Chrome. Les informations personnelles fournies sciemment dans vos ++ commentaires ou involontairement dans le journal, l'URL ou la capture ++ d'écran sont protégées conformément à nos règles de ++ confidentialité. Si vous ne souhaitez pas indiquer d'URL et/ou de capture ++ d'écran, décochez les cases "Inclure cette URL" et/ou "Inclure cette capture d'écran". Vous acceptez que Google utilise vos commentaires pour améliorer ses produits ou services. ++Vos modifications seront prises en compte au prochain démarrage de . ++Taille de police minimale ++Entrée directe ++Fermer la fenêtre ++Mode de saisie du japonais (pour clavier japonais) ++Inscription réussie ++Échec de création du fichier zip temporaire lors de la création du pack ++Modifier les paramètres de confiance : ++Votre historique de navigation ++&Masquer le panneau de la vérification orthographique ++Plug-in ne répondant pas ++IBM ++Les paramètres seront effacés lors de la prochaine actualisation. ++ introuvable ++Démarrage... ++Nouvelle fenêtre de nav&igation privée ++Ajouter une adresse postale... ++Authentification en cours... ++Ouvrir dans un nouvel onglet ++Déconnecté ++Action du navigateur ++Le mot de passe multiterme saisi ne peut pas être utilisé, car vous avez déjà chiffré des données avec un mot de passe multiterme. Entrez ci-dessous le mot de passe multiterme actuellement défini pour la synchronisation. ++Ouvrir cette page : ++Voulez-vous vraiment supprimer tous les mots de passe ? ++Sélectionner par domaine ++Ouvrir le lien dans une fenêtre en navi&gation privée ++Émetteur ++Options de saisie automatique ++Les nouveaux paramètres des cookies seront appliqués quand vous aurez actualisé la page. ++Votre connexion à est sécurisée par un chiffrement bits. ++Menu Applications ++Outi&ls ++Onglets latéraux ++Reprendre ++Zoom ++Inspecteur de DOM ++Document sans titre ++Police standard ++Activer ++Opération en cours... ++C&opier l'URL de l'image ++La saisie automatique des numéros de carte de paiement est désactivée, car la connexion utilisée par ce formulaire n'est pas sécurisée. ++Enregistrer le &cadre sous... ++Général ++Défaillance ++Demander ++Coller l'URL et y a&ccéder ++Pour plus de sécurité, va chiffrer vos mots de passe. ++Si vous avez oublié votre mot de passe multiterme, vous devrez arrêter la synchronisation via Google Dashboard. ++ sur  ++Adresse ligne 1 ++Impossible de créer le favori. ++Basculer en mode chinois simplifié/traditionnel ++Votre système Sandbox n'est pas correctement configuré. ++Sélectionnez le menu clé à molette > Préférences > Options avancées > Modifier les paramètres du proxy et vérifiez que vos paramètres sont définis sur "sans proxy" ou "direct". ++Impossible de vérifier si le certificat a été révoqué. ++Stockage des données ++/, Interrompu ++Acheter un forfait ++Installer le plug-in... ++Afficher le code source ++Fermer les onglets sur la droite ++Afficher le bouton "Accueil" ++Version  ++Parenthèse gche ++Microsoft Server Gated Cryptography ++Zoom avant ++Protection du courrier électronique ++Les cookies suivants ont été bloqués (tous les cookies tiers sont bloqués, sans exception) : ++Connectez-vous à pour importer le certificat client de ++La batterie est chargée. ++Créer un nouveau profil... ++Maintenez la touche enfoncée pour quitter. ++Masquer ce plug-in ++Ouvrir le fichier ++Conteneur de barres d'infos ++Le certificat du serveur a expiré. ++Utiliser ++Réduit la taille du texte ++Épingler l'onglet ++Mise à jour du système ++ days left ++Inclure les informations système ++Google Chrome n'avait pas suffisamment de mémoire ou le processus de la page Web a été arrêté pour une autre raison. Pour continuer, actualisez la page ou ouvrez-en une autre. ++Impossible de valider votre mot de passe sur le réseau actuel. Sélectionnez un autre réseau. ++Cette page n'est pas rédigée en  ? Signaler l'erreur ++Certificat unique codé Base 64 ASCII ++Activer le mode plein écran ++Codag&e ++ est déjà utilisé pour gérer les liens ://. ++Touches de sélection ++Clavier international américain ++Je comprends que la visite de ce site peut être préjudiciable à mon ordinateur. ++Ressource cache manquante. ++Impossible d'accéder à mon compte ++C&opier l'URL de la vidéo ++Vous préférez parcourir la galerie ? ++Impossible de vérifier le certificat du serveur. ++Outils de &développement ++Exporter... ++Paramètres de saisie automatique ++Téléchargement de l'image en cours... ++&Options du vérificateur d'orthographe ++Impossible d'ouvrir votre profil correctement.\n\nIl est possible que certaines fonctionnalités ne soient pas disponibles. Vérifiez que ce profil existe et que vous disposez d'une autorisation d'accès à son contenu en lecture et en écriture. ++Vérifier le document maintenant ++Zone de liste ++Clavier slovène ++Sens de l'écriture ++Vos données sur ++Ouvrir une fenêtre du navigateur ++Conversion de la date et de l'heure ++PKCS #1 SHA-512 avec chiffrement RSA ++Clavier coréen ++Dupliquer ++Ne pas conserver sur cette page ++Désactiver ++ATOK ++téléchargement ++E-mail : ++Ouvrir tous les favoris dans une nouvelle &fenêtre ++Rafraîchir la page actuelle ++Accessibilité ++Exceptions pour les plug-ins ++Remplissage automatique des formulaires ++Nom d'utilisateur ++Enregistrer le lie&n sous... ++Réessayer ++Personnaliser et configurer ++Préférences de saisie automatique ++Votre position géographique ++Afficher les pages en arrière-plan () ++Configurer les mises à jour automatiques ++il y a  heures ++Valeur du champ ++Les dernières versions d'Unity et GNOME (ainsi que la prochaine version d'Ubuntu, Natty Narwhal) affichent une barre de menus de type OSX sur toute la largeur supérieure de l'écran. ++Index erroné. ++Préparation du module de plate-forme sécurisée (TPM) en cours. Veuillez patienter, l'opération peut prendre quelques minutes. ++Nombre de copies incorrect ++Personnaliser ++Prédire les actions du réseau pour améliorer les performances de chargement des pages ++Données restantes : ++N'est pas une autorité de certification. ++L'URL doit être valide. ++Envoyer automatiquement les statistiques d'utilisation et les rapports d'erreur à Google ++Cette fonctionnalité active la géolocalisation dans les extensions expérimentales. Cela implique l'utilisation des API de localisation du système d'exploitation (si disponibles) et l'envoi de données sur la configuration réseau locale au service de localisation de Google afin de déterminer une position précise. ++Impossible de charger le profil. ++Toujours exécuter JavaScript sur ++Version PRL : ++Confirmer la réactivation ++Ajouter une adresse postale... ++PKCS #1 MD2 avec chiffrement RSA ++Dim.^Lun.^Mar.^Mer.^Jeu.^Ven.^Sam. ++Zone de saisie ++Trier par nom ++Fenêtre ++Nouvel onglet ++Vous tentez d'accéder au site , mais le certificat présenté par le serveur a été révoqué par son émetteur. Cela signifie que les informations d'identification présentées par le serveur ne sont pas approuvées. Vous communiquez peut-être avec un pirate informatique. Nous vous déconseillons vivement de continuer. ++Composition hors écran ++ mins left ++Technologie : ++Accédez à la page d'accueil du site : ++Configurer la communication à distance ++L'émetteur d'un certificat n'ayant pas expiré est tenu d'assurer la maintenance de ce qui s'appelle "une liste de révocation". Si un certificat est compromis, l'émetteur peut le révoquer en l'ajoutant à la liste de révocation. Ce certificat n'est alors plus approuvé par votre navigateur. Il n'est pas nécessaire d'assurer la maintenance de l'état "révoqué" des certificats expirés. Donc, bien qu'un certificat ait été qualifié de valide pour le site Web que vous visitez actuellement, il est impossible de déterminer s'il a été, depuis, compromis puis révoqué ou s'il est toujours valide. Par conséquent, il n'est pas possible de s'assurer si vous communiquez avec un site Web légitime ou si le certificat a été compromis et se trouve maintenant en la possession d'un pirate informatique avec lequel vous communiquez. Ne poursuivez pas. ++Néanmoins, si vous travaillez dans une entreprise qui génère ses propres certificats, et que vous essayez de vous connecter au site Web interne de l'entreprise avec un certificat de ce type, vous pouvez résoudre ce problème en toute sécurité. Pour ce faire, importez le certificat racine de l'entreprise en tant que "certificat racine". Par la suite, les certificats émis ou vérifiés par votre entreprise seront approuvés et vous ne verrez plus cette erreur lorsque vous tenterez de vous connecter à nouveau au site Web interne. Contactez le support informatique de votre entreprise pour savoir comment ajouter un nouveau certificat racine sur votre ordinateur. ++Définir en tant que navigateur par défaut ++Avertissement ++Préférences de recherche ++Clavier Colemak américain ++Activer la navigation en tant qu'invité ++Utiliser les paramètres par défaut ++Rétablir ++Désinstaller "" ? ++Établissement de la connexion sécurisée... ++Dossier : ++Erreur non reconnue ++Consultez les conflits connus avec des modules tiers. ++Co&ller et rechercher ++&Remonter ++Échec de la traduction en raison d'une erreur de serveur ++Version : ++Polices et codage ++ - ++Signature du code commercial Microsoft ++Sélectionnez les éléments à importer : ++De gauche à droite ++Votre connexion à est sécurisée par le biais d'un faible chiffrement. ++sans objet ++Toujours afficher la barre de favoris ++Activer l'onglet 2 ++Aperçu des onglets ++Redémarrer ++Configuration en cours... ++Une erreur s'est produite lors de la récupération des fonctions de l'imprimante . Cette imprimante n'a pas pu être enregistrée dans . ++Exceptions pour les fenêtres pop-up ++Signataire du certificat ++La page Web n'existe plus. ++Vous n'avez jamais visité ce site auparavant. ++Personnaliser... ++Fe&rmer la fenêtre ++Arrêter le chargement de cette page ++Autres favoris ++ a été mis à jour. ++Mode hors connexion ++Erreur d'importation de fichier PKCS #12 ++Algorithme de clé publique de l'objet ++Le site Web a rencontré une erreur lors de l'extraction de . ++ Cela peut être dû à une opération de maintenance ou à une configuration incorrecte. ++Échec du chargement de la page ++Mot de passe : ++Conserver en tant que moteur de recherche par défaut ++Fichier manifeste absent ou illisible ++La connexion a été réinitialisée. ++Le mot de passe choisi vous sera demandé pour restaurer le fichier. Veillez à le conserver en lieu sûr. ++La vérification de la provenance du certificat DNS est activée, ce qui peut entraîner l'envoi d'informations privées à Google. ++À propos de la reconnaissance vocale ++Aller à la sélection ++Ajouter un certificat ++Espaces de noms PID ++Préférences de saisie automatique ++Activer l'onglet 8 ++Le certificat "" représente une autorité de certification. ++Envoyer par e-mail l'emplacement de la page ++Enregistrement des informations de date Microsoft ++Validité ++&Traduire en ++Batterie :  % ++Désactivé ++Japonais ++ () ++L'application est actuellement inaccessible. ++Lecteur du certificat : ++ jour restant ++Gestionnaire de tâches ++Gérer les extensions... ++Continuer ++Synchronisation avec effectuée. Dernière synchronisation : ++Le certificat de sécurité du site n'est pas encore valide ! ++Ouverture de session par carte à puce Microsoft ++Format ++Tapez votre requête ou saisissez une URL pour commencer la navigation : c'est à vous de choisir. ++Enregistrer &sous... ++Le serveur requiert un nom d'utilisateur et un mot de passe. ++Supprimer tous les mots de passe ++Le certificat du serveur contient des erreurs. ++Recherche de réseaux Wi-Fi... ++Description : ++Séparateur ++Si vous supprimez l'un de vos propres certificats, vous ne pouvez plus l'utiliser pour vous identifier. ++Rafraîchir cette page ++État d'activation : ++Créer des raccourcis vers des applications ++Clavier franco-suisse ++GUID de domaine Microsoft ++Entrer ++Supprimer ++Échec de l'enregistrement de cet ordinateur pour l'accès à distance. ++Ouvrir l'&image dans un nouvel onglet ++Préférences... ++L'administrateur a désactivé les mises à jour. ++À propos de la version ++Veuillez nous indiquer ce qu'il se passe avant d'envoyer votre rapport. ++Connectez-vous à afin de générer une clé pour . ++Clavier roumain ++Autres ++Sécurité : ++Imprimer ++Mode de saisie standard ++Signature ++Erreur lors de la connexion ++Pour cette session uniquement ++Une erreur s'est produite. ++(Désactivé par une stratégie d'entreprise) ++Erreur lors de la tentative d'impression. Vérifiez votre imprimante et réessayez. ++Grec ++Ignorer les exceptions et bloquer l'enregistrement des cookies tiers ++Cet outil vous permet de sélectionner une capture d'écran enregistrée. Aucune capture d'écran n'est disponible pour le moment. Appuyez simultanément sur Ctrl et sur la touche "Mode Présentation" pour enregistrer une capture d'écran. Vos trois dernières captures apparaissent ici. ++Activation effectuée ++Aucun système de révocation trouvé ++Bouton ++Interrompu ++Dictionnaire de symboles ++Technologie EvDo requise ++Internet mobile ++Envoyer le commentaire ++Associé au profil Chrome . Dernière synchronisation : ++Carte de crédit (autre) ++Langues et saisie ++Utiliser la barre de titre et les bordures de fenêtre du système ++Ann&uler ++ () ++Le serveur a refusé d'exécuter la demande. ++ Ko ++ a été mis à jour vers la version . ++Navigateur de contenu ++&Rouvrir la fenêtre fermée ++Se connecter directement à Internet ++Émis pour ++Ouverture de en cours ++Cibles disponibles pour l'image ++Signaler un problème ++Taille de police : ++Aide pour la configuration de proxy ++Petite ++ hours ago ++Rester sur cette page ++Type de bug : ++Inclure cette URL : ++Cookies et données de site... ++Police Serif ++Avertissement : ne peut pas empêcher les extensions d'enregistrer votre historique de navigation. Pour désactiver cette extension en mode navigation privée, désélectionnez-la. ++ChromiumOs Image Burn ++Services ++Paramètres du proxy... ++1 onglet ++Vous naviguez en tant qu'invité. Les pages que vous consultez dans cette fenêtre n'apparaîtront pas dans l'historique de votre navigateur ni dans votre historique des recherches. Les autres traces telles que les cookies seront supprimées de l'ordinateur à la fin de votre session. En revanche, les fichiers téléchargés et les favoris créés seront conservés. ++ ++ En savoir plus sur le mode invité ++Chargement des pages impossible ++Inclure cette capture d'écran : ++Certificat ++&Effacer les données de navigation... ++Valeur de signature du certificat ++URL de renouvellement du certificat Netscape ++Afficher la s&ource ++ - , ++Reprendre ++ secs ago ++Activé ++Carte SIM désactivée ++Compatibilité avec VPN ++Développement - Instable ++Échec de création du raccourci vers l'application ++Barre de favoris ++Le serveur est en mesure de répondre à la demande. ++Modifier les paramètres du proxy... ++(non empaquetée) ++Rechercher le suivant ++Paramètres réseau ++Votre service Internet mobile est activé et prêt à l'emploi. ++Modifier la police et la langue par défaut des pages Web ++Composition graphique avec accélération matérielle ++Autre nom de l'émetteur du certificat ++ ++&Afficher le code source du cadre ++Mode de saisie du persan (clavier ISIRI 2901) ++OpenVPN ++Arrêter le processus ++Votre compte a peut-être été supprimé ou désactivé. Veuillez vous déconnecter. ++Authentification anonyme : ++Bases de données indexées ++En savoir plus sur les escroqueries par phishing ++Page à l'apparence anormale ++Adresse e-mail ou mot de passe incorrect. Essayez tout d'abord de vous connecter à un réseau. ++Périphérique ++Informations sur la connexion ++Confirmer la navigation ++Nom du point d'accès : ++Rechercher ++Au démarrage ++Paramètres... ++Lire en un clic ++Connectez-vous à pour vous authentifier auprès de avec votre certificat. ++Votre administrateur informatique a désactivé certaines options. ++Supprimer le certificat de serveur ""? ++Configurer la synchronisation... ++Valider automatiquement une chaîne ++Empreinte SHA-256 ++Retour ++Réseau domestique, sans itinérance ++ - ++Gérer les mots de passe enregistrés... ++Sélectionnez ++ ++ Menu clé à molette > Options > Options avancées > Modifier les paramètres du proxy > Paramètres réseau ++ ++ et désélectionnez l'option "Utiliser un serveur proxy pour votre réseau local". ++Ne jamais traduire ce site ++(suite) ++Trop de redirections ++Ces paramètres ne peuvent être modifiés que par le propriétaire : ++Active la protection XSS Auditor de WebKit (protection contre le Cross-site Scripting), une fonctionnalité qui vous protège de certaines attaques de sites malveillants et offre une sécurité accrue, mais qui n'est pas compatible avec tous les sites Web. ++Clavier latino-américain ++Phishing détecté ! ++Voulez-vous utiliser () pour gérer les liens :// à partir de maintenant ? ++ (Navigation privée) ++Prendre une photo ++Non merci ++Ne pas afficher les images ++Toujours autoriser ces plug-ins sur ++Sélectionner un dossier ++&Paramètres ++Informations sur l'erreur : ++Toujours autoriser les plug-ins sur ++Effacer les données de saisie automatique enregistrées ++Changer de moteur de recherche ++En attente du tunnel proxy... ++Veuillez ajouter un autre mode de saisie avant de supprimer celui-ci. ++ secondes ++Paramètres de contenu ++Impossible d'extraire les fichiers de l'extension. Pour effectuer cette opération en toute sécurité, vous devez disposer d'un chemin d'accès à votre répertoire de profils commençant par une lettre de lecteur et ne contenant ni jonction, ni point de montage, ni lien symbolique. Aucun chemin de ce type n'existe pour votre profil. ++ va être installé. ++Code postal ++En bas à droite ++&Ouvrir ++ téléchargé(s) sur ++Commentaires d'ordre général/Autres ++Ou&vrir la vidéo dans un nouvel onglet ++Identité : ++Échec de l'opération OTASP ++Action sur la page ++Modifier des éléments... ++Le répertoire d'extensions est obligatoire. ++ Mo disponibles ++Ancien ++ fournit du contenu provenant de , un site connu pour distribuer des logiciels malveillants. Votre ordinateur pourrait être infecté par un virus si vous consultez ce site. ++Ces fonctionnalités expérimentales sont susceptibles d'être modifiées, interrompues ou supprimées à tout moment. Nous ne fournissons aucune garantie quant aux effets de leur activation. Votre navigateur pourrait bien prendre feu. Trêve de plaisanterie, il est possible que votre navigateur supprime toutes vos données ou que votre sécurité et votre vie privée soient compromises de manière inattendue. Nous vous prions d'agir avec précaution. ++Configuration manuelle du proxy ++Mettre à jour Adobe Reader maintenant ++ days ago ++Désactiver les plug-ins individuels... ++Envoyer une capture d'écran de la page en cours ++Point d'exclamation ++ n'est plus à jour, car il n'a pas été relancé depuis quelque temps. La mise à jour disponible sera installée dès que vous le relancerez. ++Petit problème... Tentons de le résoudre. ++Cette fonctionnalité permet d'établir des correspondances entre les sous-chaînes et plusieurs fragments d'URL figurant dans l'historique. ++Page "Nouvel onglet" expérimentale ++Les cookies suivants étaient autorisés lorsque vous avez consulté cette page : ++votre opérateur ++Activer ces fonctionnalités... ++Quitter Firefox avant l'importation ++Ajouter un nouveau téléphone ++Proxy HTTP sécurisé ++Accès à refusé. ++Finalisation de la mise à jour du système... ++Voulez-vous continuer ? ++ Ko ( Ko effectifs) ++Autre réseau Wi-Fi... ++Choisir un autre répertoire... ++L'extension indiquée est déjà associée à une clé privée. Utilisez cette clé ou supprimez-la. ++Ajouter une adresse ++Stockage local ++Afficher tous les téléchargements ++Navigateur de contenu ++Magasin de certificats ++Émis par ++Quitter le mode plein écran () ++Le certificat du serveur a été signé avec un algorithme de signature faible. ++Ajouter un utilisateur ++Me proposer de traduire les pages qui sont écrites dans une langue que je ne sais pas lire ++Récemment fermés ++Saisir la clé de déverrouillage du code PIN ++ jours ++Rechercher du texte ++Sans-Serif ++Zoom &avant ++Confirmer le nouvel envoi du formulaire ++ heure ++Cet élément doit être installé depuis . ++Mise en veille ou reprise ++Mettre à jour maintenant ++Ajouter une page ++Chiffrer seulement ++Ne jamais intervertir les touches de modification ++Conversion des numéros spéciaux ++Relancer maintenant ++Synchronisation avec effectuée ++il y a  minute ++Édition ++Préférences synchronisées ++ hours ago ++Personnalisé ++Rechercher à partir de la barre d'adresse ++Ouvrir ++Inspecter les vues actives : ++Contraintes de nom du certificat ++Ajouter une adresse ++Mot de passe incorrect. ++Statistiques avancées ++Clavier espagnol ++Sélectionnez votre réseau ++ jour ++Le serveur de synchronisation est occupé. Veuillez réessayer ultérieurement. ++Quitter cette page ++Naviguer en tant qu'invité ++Discover ++&Toujours afficher la barre de favoris ++Options de recherche ++Taille : ++il y a  secondes ++La liste suivante fait état des éléments dangereux détectés sur la page. Cliquez sur le lien "Diagnostic" pour obtenir plus d'informations sur une ressource particulière. Si une ressource a été signalée comme site de phishing alors que vous êtes certain de sa fiabilité, cliquez sur le lien "Signaler une erreur". ++Cette page rédigée dans une langue non identifiée a été traduite en . ++Les exceptions ci-dessous s'appliquent uniquement à la session de navigation privée actuelle. ++Ne plus afficher la boîte de dialogue pour les liens de ce type ++ secondes restantes ++Insérez dans l'URL où les termes de recherche devraient apparaître. ++En&registrer la vidéo sous... ++Nom : ++Si vous rencontrez des problèmes fréquents avec ce module, vous pouvez tenter d'y remédier en suivant la procédure ci-après : ++Informations relatives au certificat ++Activer l'onglet 7 ++En savoir plus sur ce problème. ++Version du matériel : ++Le site Web à l'adresse contient des éléments provenant de sites qui semblent héberger des logiciels malveillants. Ces derniers peuvent nuire à votre ordinateur ou agir à votre insu. Le simple fait de visiter un site hébergeant ce type de logiciels peut infecter votre ordinateur. Ce site héberge également des informations provenant de sites signalés comme étant des sites de phishing. Ces derniers incitent les internautes à divulguer des informations personnelles en se faisant passer pour des institutions de confiance, telles que des banques. ++Afficher la liste ++Désactivez l'affichage des messages de confirmation et le blocage de l'envoi des formulaires. ++Ce cadre a été bloqué, car il contient des éléments non sécurisés. ++Tout ++Kana ++Gérer les mots de passe enregistrés... ++Boîte de dialogue "Effacer les données de navigation" ++Mettre à jour les extensions maintenant ++Nouvelle application en arrière-plan installée ++Envoyer une capture d'écran de la page actuelle ++L'URL indiquée est incorrecte. ++Un problème est survenu lors de l'affichage de la liste des imprimantes. Certaines de vos imprimantes ne sont peut-être pas correctement enregistrées dans . ++Actuellement connecté ++La page que vous recherchez a utilisé des informations que vous avez envoyées. Si vous revenez sur cette page, chaque action précédemment effectuée sera répétée. Souhaitez-vous continuer ? ++Cette fonctionnalité indique la vitesse d'affichage réelle d'une page, en images par seconde, lorsque l'accélération matérielle est active. ++E&xporter... ++&Ouvrir un fichier... ++Configurer le contrôle d'accès pour vos périphériques ++Ouvrir un rapport de phishing ++Activer la barre d'adresse ++ secs ago ++Cartes de paiement ++Code opérateur : ++Erreur de connexion ++Vous avez la possibilité de désactiver ces services. ++Essayer d'afficher la page malgré tout ++Impossible d'établir une connexion sécurisée avec le serveur. Le serveur a peut-être rencontré un problème ou exige un certificat d'authentification du client dont vous ne disposez pas. ++Ajouter un nouveau nom ++Obtenir d'autres thèmes ++Rétablir les valeurs par défaut ++Aucun Plug-in installé. ++Action ++Extensions de fichier ++Les plus visités ++&Gestionnaire de favoris ++Caches des applications ++Cette langue est actuellement utilisée par . ++ % ++Empaqueter l'extension ++Activer l'onglet 5 ++Sélectionner le mode de saisie précédent ++Configurer le blocage de JavaScript... ++Réseaux mémorisés ++Impossible de se connecter à Internet. ++URL incorrecte ++Informations sur la sécurité ++Impossible d'installer l'application, car elle est en conflit avec "", qui est déjà installé. ++Votre périphérique n'est pas connecté. ++Fermer ++Accord de la clé ++ mins ago ++Vous ne trouvez pas ce que vous recherchez ? ++Désactivez l'envoi des pings de contrôle des liens hypertexte. ++En&registrer le fichier audio sous... ++Accédez rapidement à vos favoris en les ajoutant à la barre de favoris. ++Vérifier la grammaire et l'orthographe ++Épingler les onglets ++Sélectionner par type d'application ++assembler ++ souhaite devenir votre moteur de recherche. ++Utiliser l'historique d'entrée ++Fermer les onglets ++Voici quelques suggestions : ++Sélectionnez un ou plusieurs fichiers ++Afficher le panneau de la &vérification orthographique ++Veuillez relancer . ++Sans titre ++Pour saisir du texte, sélectionnez une langue et consultez la liste des modes de saisie disponibles. ++Ville ++Modifier... ++Réinitialiser la synchronisation ++Inclure une capture d'écran enregistrée : ++Tout supprimer ++Passer automatiquement en demi-chasse ++&Accéder à ++La capacité de ce périphérique de stockage est de . Veuillez insérer une carte SD ou une clé USB d'au moins 4 Go. ++Rouvrir le dernier onglet fermé ++(blocage) ++Erreurs () ++Traitement de la sélection... ++Aide ++Désolé ! La visionneuse de documents PDF intégrée à Google Chrome, nécessaire à l'affichage de l'aperçu avant impression, n'est pas incluse dans Chromium. ++Impossible d'ouvrir , car vous êtes déconnecté du réseau. Cette page s'affichera dès que la connexion réseau sera rétablie. <br> ++Télécopie ++version ++La passerelle ou le serveur proxy a reçu une réponse incorrecte d'un serveur en amont. ++Nouvelle fenêtre ouverte dans la session du navigateur ++Réessayer ++ peut maintenant synchroniser vos mots de passe. Vos données seront chiffrées avec le mot de passe de votre compte Google ou le mot de passe multiterme de votre choix. ++Les paramètres réseau de votre proxy sont gérés par une extension. ++Retirer l'onglet ++Valable du au ++Case cochée ++Mode de saisie ++AVERTISSEMENT ++Clavier estonien ++Ajout de bordures aux couches de rendu composées ++Imp&rimer... ++Paramètres de saisie automatique ++Rafraîchir ++Barre d'outils ++Nom de la base de données : ++Certificat du répondeur d'état ++Utiliser le mot de passe de mon compte Google ++Vos favoris sont maintenant synchronisés avec Google Documents ! ++Pour fusionner et synchroniser vos favoris dans sur un autre ordinateur, procédez de la même manière que précédemment sur l'ordinateur voulu. ++Renommer... ++ a été désactivé. Si vous arrêtez la synchronisation des favoris, vous pouvez la réactiver sur la page des extensions, via le menu Outils. ++Affichage des pages impossible ++Utiliser par défaut ++La carte SIM est verrouillée. Veuillez saisir votre code PIN. Nombre de tentatives restantes : ++Point-virgule ++Réseau domestique requis ++PKCS #7, certificat unique ++Langues baltes ++Vous avez saisi un trop grand nombre de clés de verrouillage du code PIN incorrectes. Votre carte SIM est définitivement désactivée. ++Données de diagnostic système ++Page Web, contenu HTML uniquement ++Continuer » ++Gérez vos imprimantes. ++(Choisir un problème dans la liste ci-dessous) ++&Afficher le code source du cadre ++Authentification du client WWW TLS ++Les cookies de plusieurs sites sont autorisés. ++Impossible d'afficher la page de la barre latérale "". ++Vous avez acheté de données le . ++Enregistrer le mot de passe ++Configurer... ++Mode de saisie du pinyin ++Intervertir les touches Ctrl et Alt de gauche ++Confirmer le mot de passe multiterme ++Activer ++Ajouter... ++Voulez-vous que Google Chrome enregistre ces informations de carte de paiement pour le remplissage de formulaires Web ? ++Continuer à bloquer les fenêtres pop-up ++Échec de la vérification DHCP ++Choisir un autre dossier... ++Le profil semble être utilisé par le processus sur l'hôte . Si vous êtes certain qu'aucun autre processus n'utilise ce profil, supprimez le fichier et relancez . ++Chinois traditionnel ++Effacer les données de navigation... ++Ré&activer le son ++Aucun réseau trouvé. ++&Ouvrir le fichier audio dans un nouvel onglet ++&Méthodes d'entrée ++Onglets ou fenêtres ++Toutefois, cette page inclut d'autres ressources qui ne sont pas sécurisées. Ces ressources peuvent être consultées par des tiers pendant leur transfert, et modifiées par un pirate informatique dans le but de changer le comportement de cette page. ++Automatique ++&Extensions ++Roumain ++Paramètres du réseau... ++Changer... ++Clé privée ++Format : ++Se connecter ++ : ++Vous avez tenté de contacter , mais le certificat présenté par le serveur est incorrect. ++Nouvelle fenêtre de nav&igation privée ++La page à l'adresse indique : ++Le serveur associé à n'a pas répondu à temps. Cela peut être dû à une surcharge. ++L2TP/IPSec + Clé pré-partagée ++XSS Auditor ++Durée de validité ++WebGL ++Mot de passe multiterme erroné ++Corriger automatiquement la saisie ++Unité d'organisation ++Compte Google ++&Aide ++Utiliser un service de prédiction afin de compléter les recherches et les URL saisies dans la barre d'adresse ++Certificat du signataire de courrier électronique ++En savoir plus ++Vous avez enregistré vos imprimantes sur via le compte . ++il y a  jours ++: restantes ++Cette page est enVoulez-vous la traduire ? ++Saisie automatique des formulaires ++Clavier ukrainien ++Ouvrir tous les favoris dans une fenêtre de navigation privée ++Ctrl ++ minutes ++Le certificat de sécurité du serveur contient des erreurs ! ++avec votre compte Google ++Rechercher dans les favoris ++MSCHAPv2 ++Avertissement utilisateur ++&Options du vérificateur d'orthographe ++Échec de la connexion ++Identifiant de l'erreur ++ jours restants ++Émis par : ++Mode de saisie du thaï (clavier Kesmanee) ++Passerelle : ++Chiffrement ++Autre... ++Pas avant le ++ n'a pas pu synchroniser vos données, car la connexion avec le serveur de synchronisation n'a pas pu être établie. Nouvel essai... ++Me demander lorsqu'un site souhaite afficher des notifications sur le Bureau (recommandé) ++Source : ++Erreur de lecture du cache ++Raccourci de sélection ++Vérifier la révocation du certificat serveur ++Vous rencontrez des problèmes lors de l'installation ? ++Bêta ++Pointeur de la déclaration CPS (Certification Practice Statement) ++Le , vous avez reçu à utiliser librement. ++Nom complet ++Inscription d'entreprise ++Clavier allemand ++Impossible de lancer l'impression. ++&Lire ++Récent ++Cette page Web présente une boucle de redirection. ++Supprimer le certificat "" émis par l'autorité de certification ? ++Mots de passe enregistrés ++Moins ++Options avancées ++Vérifiez vos paramètres DNS. Contactez votre administrateur réseau si vous n'êtes pas sûr de vous. ++Une erreur inconnue s'est produite. ++Émetteur : ++Passer d'un mode de saisie à l'autre ++Organisation (O) ++PKCS #1 SHA-1 avec chiffrement RSA ++Entrez la requête de recherche ici. ++Application en mode navigation privée : ++La largeur de ponctuation initiale est Complète ++Installer  ? ++Installation d'une nouvelle version... ++Ouvrir le lien dans un nouvel ongle&t ++Pour accéder aux paramètres de sécurité, saisissez le code PIN de la carte SIM. ++Jamais ++Impossible d'accéder au réseau. ++Effacer le formulaire ++Échec de la mise à jour du système ++Saisissez le mot de passe utilisé pour chiffrer ce fichier de certificat. ++CHAP ++Enregistrer le lie&n sous... ++Effacer les données de navigation... ++Options de reconnaissance vocale ++Réseau câblé ++Nouvel ongle&t ++R&etour ++Téléchargement suspendu ++Ouvrir la page d'accueil ++Connexion ++L'installation de est terminée. ++&Outils ++Page d'accueil ++Clavier phonétique bulgare ++Cookies et données de site... ++Batterie faible ++Commentaires ++Package incorrect : "". ++ heures restantes ++Configurer les paramètres de blocage des images... ++Options ++ hours ago ++&Détails ++Masquer la barre de titre du système et utiliser les bordures ++Elle peut accéder aux éléments suivants : ++Confidentialité ++Objets : ++Paramètres d'entrée du japonais ++Sebeol-sik Final ++Veuillez vous connecter à Internet pour continuer. ++Afficher les &infos sur le cadre ++Fichier ++Cop&ier l'image ++Utiliser le même proxy pour tous les protocoles ++Masquer ++Requête de protocole externe ++Afficher ++Certains de vos certificats enregistrés identifient ces serveurs : ++Vous avez visité ce site pour la première fois le . ++Cliquer pour avancer, maintenir pour voir l'historique ++La dernière version de l'application "" requiert d'autres autorisations. Elle a donc été désactivée. ++ secondes ++Vous avez choisi d'ouvrir automatiquement certains types de fichiers après leur téléchargement. ++EAP-MD5 ++&Nouvelle fenêtre +++ ++Vous avez essayé d'accéder au site , mais le serveur a présenté un certificat signé avec un algorithme de signature faible. Il se peut que les informations d'identification fournies par le serveur aient été falsifiées. Le serveur n'est peut-être pas celui auquel vous souhaitez accéder (il peut s'agir d'une tentative de piratage). Nous nous déconseillons vivement de continuer. ++L'envoi de rapports d'erreur est désactivé. ++Clé WEP incorrecte ++Date d'expiration : ++URL de base du certificat Netscape ++Réduire... ++Rechercher dans l'historique ++Ouvrir le lien dans la fenêtre de navi&gation privée ++ secondes ++Historique avancé pour le champ polyvalent ++Active l'utilisation de graphismes 3D dans les éléments canvas via l'API WebGL. ++Occident ++État non reconnu ++ ++Impossible de vérifier si le certificat du serveur a été révoqué. ++Se connecter ++Fuseau horaire : ++Cette option est soumise à une stratégie d'entreprise. Contactez votre administrateur pour plus d'informations. ++Résultats de recherche pour "" ++Revenir à "" (redémarrage requis) ++ va exécuter les tâches suivantes : ++Ajouter la page ++Changement de mode via la touche Maj ++Options de date et d'heure... ++Nom DNS ++Build de développement ++ sur ... ++Verrouiller la carte SIM (code PIN obligatoire pour utiliser les données mobiles) ++Sélectionnez le répertoire racine de l'extension. ++Les cookies de sont autorisés uniquement pour cette session. ++Confirmer les préférences de synchronisation ++RSN ++Ajuster la conversion en fonction de l'entrée précédente ++Afficher le panneau de la &vérification orthographique ++(Revenir à la capture d'écran d'origine) ++Mettre à jour & ++SSID ++- ++Les informations de connexion au compte n'ont pas encore été saisies. ++URL de configuration automatique ++URL : ++Avancer ++ jours restants ++Vous avez choisi de ne pas synchroniser les mots de passe. Vous pouvez à tout moment modifier vos paramètres de synchronisation, si vous changez d'avis. ++Lancer ++ ++ ne parvient pas à accéder au réseau. ++ ++ Il est possible que votre pare-feu ou votre antivirus considère ++ ++ comme un intrus dans votre ordinateur et qu'il bloque ses tentatives de connexion à Internet. ++Ce certificat a été vérifié pour les utilisations suivantes : ++Petit problème ! Une erreur est survenue lors de l'inscription de ce périphérique. Veuillez réessayer ou contacter votre représentant de l'assistance technique. ++Ajouter aux favoris ++Gérer les certificats... ++Analyse du périphérique... ++PYJJ ++Web Store ++Annuler l'épinglage des onglets ++Favori ++Sélectionnez votre langue : ++Réessayer le téléchargement ++Configurer la synchronisation des mots de passe ++Nom d'utilisateur : ++Enregistrer la p&age sous... ++Vos données sur tous les sites Web ++Un problème est survenu lors de l'extraction de l'image sur l'ordinateur. ++Lancer l'application ++Dubeol-sik ++Remplacé ++Afficher les cookies et autres données de site... ++Si vous pensez avoir cerné les risques, vous pouvez . ++Apparence ++Créer des raccourci&s vers des applications... ++Exécuter le flash PPAPI dans le processus du moteur de rendu ++Définir en tant que navigateur par défaut ++Veuillez choisir un nouveau code PIN. ++ () ++Autre ++&Options ++Impossible de charger la page d'arrière-plan "". ++À quel niveau rencontrez-vous des problèmes ? (Champ obligatoire) ++Retour à la sécurité ++Eten ++Ce site répertorie tous ses certificats valides dans le système DNS. Un certificat non répertorié a cependant été utilisé par le serveur. ++Options de reconnaissance vocale ++Tout sélectionner ++Impossible de charger le fichier "" pour le script de contenu, car ce fichier n'est pas codé en UTF-8. ++&Annuler ++Désactiver temporairement la personnalisation des conversions, les suggestions basées sur l'historique et le dictionnaire utilisateur ++Les cookies de sont autorisés. ++Au fil du temps, la zone ci-dessous affichera les huit sites que vous avez le plus visités. ++Le plug-in a besoin de votre autorisation pour s'exécuter. ++Échec de création de clé privée ++Ouvrir tous les favoris dans une fenêtre de navigation privée ++Placer dans la file d'attente ++Erreur de certificat serveur inconnue ++Mode de saisie du coréen ++&Plein écran ++ ++ ++ Vous pouvez essayer de diagnostiquer le problème en procédant comme suit : ++ ++ ++Bienvenue sur votre page d'accueil ! ++Vos modifications seront prises en compte au prochain démarrage de . ++Adresse du matériel : ++Lecture seule ++Erreur d'importation du certificat serveur ++Données stockées localement ++Tous les fichiers de vont être effacés. ++Modèle du périphérique : ++Afficher dans le Finder ++Nom X.500 ++Vous devez sélectionner au moins un type de données à synchroniser. ++Tout afficher ++Ouvrir tous les favoris ++Clavier danois ++Cette fonctionnalité permet de réaliser un rendu hors écran de la texture, au lieu d'un affichage direct. ++Partiellement activé ++Votre système Sandbox est correctement configuré. ++Ne pas installer ++Activer la recherche instantanée pour accélérer la recherche et la navigation ++Utiliser par défaut ++Non essentielle ++Fenêtres pop-up ++Dernière modification : ++Désélectionné ++Sécurité ++Rechercher... ++Le script de la page utilisait trop de mémoire. Rafraîchissez la page pour réactiver le script. ++Signature du code individuel Microsoft ++Mozilla Firefox ++Page Web inaccessible ++Recadrer l'image ++Si vous fermez maintenant, le téléchargement sera annulé. ++Coller ++Retour ++Impossible de graver l'image. ++Mode de saisie du Chewing ++Province ++JavaScript a été bloqué sur cette page. ++Remarque : Lorsque vous cliquez sur "Envoyer", Google Chrome OS ++ joint à votre envoi un journal des événements système de ++ votre périphérique. Ces informations nous permettent de diagnostiquer les ++ problèmes, de comprendre comment vous interagissez avec votre ++ périphérique et d'améliorer les performances de ce dernier. Les ++ informations personnelles fournies sciemment dans vos commentaires ou ++ involontairement dans les journaux système et la capture d'écran sont ++ protégées conformément à nos Règles de confidentialité. ++ Si vous ne souhaitez pas envoyer de journaux système, décochez la case ++ "Inclure les informations système". ++Interdire à tous les sites de stocker des données ++Trier par nom ++Afficher un aperçu des onglets... ++Annuler l'importation ++Ce serveur envoie des données que ne comprend pas. Veuillez signaler un bug et inclure la liste des raw. ++Calcul de la durée restante ++Mode de saisie Google du japonais (pour clavier américain) ++Envoi de la requête... ++Parlez maintenant ++Impossible d'installer le package : "" ++Modèle : ++Bloquer tous les cookies tiers ++Remplacer par ++Espace ++Arrêt du fonctionnement ++Préférences ++Nom inconnu ++Nom ++Choisir un nouveau code PIN ++ [] ++Erreur d'exportation de fichier PKCS #12 ++Le répertoire racine de l'extension doit être indiqué. ++Miniature supprimée ++Tout développer... ++Aie aie aie ++Choisir les expressions en arrière-plan, sans déplacer le pointeur ++Plu&s petit ++Afficher le clavier en superposition ++C&opier l'URL de l'image ++OK ++Aucun réseau détecté ++Charger l'extension non empaquetée... ++page ++Active l'interface utilisateur et le code de support pour le processus du service de communication à distance, de même que le plug-in client. Avertissement : ce service n'est actuellement disponible que pour les tests de développeurs. Si vous ne faites pas partie de l'équipe de développement et ne figurez pas sur la liste blanche, aucun élément de l'interface utilisateur activée ne fonctionnera. ++Clavier turc ++Modifier le favori ++Couleur ++Personnaliser les paramètres de synchronisation... ++Activation de votre service Internet mobile ++ ++Ouvrir dans un onglet standard ++ - ++Portrait ++ days ago ++Active un service en arrière-plan qui connecte le service aux éventuelles imprimantes installées sur cet ordinateur. Une fois ce labo activé, vous pouvez lancer en vous connectant à votre compte Google via Options/Préférences dans la section Options avancées. ++Outils de &développement ++Le répertoire racine de l'extension est incorrect. ++ID de clé de l'objet du certificat ++Téléchargements ++Le stockage du certificat client généré par a réussi. ++Sélectionnée ++Suspendre ++Taille sur le disque : ++ID du processus ++Réduire ++Expire le ++Votre administrateur a désactivé l'accès aux fichiers locaux sur votre ordinateur. ++Erreur de connexion SSL ++Envoyer ++Virgule ++&Pause ++Parcourir... ++Mode de saisie Google du japonais (pour clavier Dvorak américain) ++Police à largeur fixe ++Stockage de session ++Page en arrière-plan : ++Le serveur a renvoyé un certificat client incorrect. Erreur  () ++Signature de document Microsoft ++Bloqué ++Gérer les paramètres d'impression... ++Cette page Web a désactivé la saisie automatique dans ce formulaire. ++Clavier hongrois ++Les versions en développement permettent de tester de nouvelles idées, mais elles peuvent s'avérer très instables. Nous vous prions d'agir avec précaution. ++Ajouter un dossier... ++Mode de saisie du japonais (pour clavier Dvorak américain) ++Signaler un bug ++&Toujours ouvrir les fichiers de ce type ++Disque optique ++Nom commun ++Très grande ++Modification terminée ++Objet ++Opérateur : ++Algorithme de signature du certificat ++Cette fonctionnalité permet d'afficher un onglet d'aperçu avant de lancer une impression. ++Autre nom de l'objet du certificat ++Activer la saisie automatique pour remplir les formulaires Web d'un simple clic ++Le site Web à l'adresse a été signalé comme étant un site de phishing. Ces sites tentent d'amener les internautes à divulguer leurs informations personnelles en se faisant passer pour des institutions de confiance, telles que des banques. ++Rechercher directement sur ++Connectez-vous à pour exporter le certificat client. ++Créer un compte Google maintenant ++État Sandbox ++Retirer de la liste ++rapide ++&Effacer les données de navigation… ++Vérification des mises à jour... ++Télécharger les mises à jour de sécurité essentielles ++Package incorrect. Détails : "". ++Continuer à bloquer les cookies ++Ligne de commande ++Coller l'URL et y a&ccéder ++Désactiver ++Build officiel ++Se connecter à un réseau Wi-Fi ++Périphérique inconnu ++Supprimer les cookies et autres données de site ++URL saisies ++Utiliser les touches , et . pour paginer une liste d'entrées ++Vider la mémoire ++Supprimer les éléments sélectionnés ++Toujours ++de moins d'une heure ++Aucun réseau n'est disponible. ++Supprimer les cookies et autres données de site et de plug-in ++Intervertir les touches Rechercher et Ctrl gauche ++Faites glisser trois doigts sur la surface de votre trackpad pour afficher un aperçu de tous vos onglets. Cliquez sur une vignette pour la sélectionner. Idéal en mode plein écran. ++Nouveau ! Configurer la synchronisation des mots de passe ++Échec de la tentative de connexion au serveur ++Désactiver les notifications de ++Les fichiers suivants ont été créés : ++ ++Extension : ++Fichier de clé : ++ ++Conservez votre fichier de clé en lieu sûr. Vous en aurez besoin lors de la création de nouvelles versions de l'extension. ++&Oui ++Ouvrir les fichiers ++Clavier suédois ++Mémoire JavaScript ++Quitter le mode plein écran ++Hiérarchie des certificats ++Afficher l'onglet existant si l'URL associée est demandée dans un autre ++&Afficher ++Vos données personnelles sur , et sur  autres sites Web ++SMS de ++Afficher la s&ource ++Zoom arrière ++C&opier l'URL du fichier audio ++Importer et associer au périphérique... ++() () ++Plug-ins (par ex. Adobe Flash Player, QuickTime, etc.) ++Empaqueter l'extension... ++Vérifier l'orthographe lors de la frappe ++Échec de la traduction en raison d'un problème de connexion réseau ++Code PIN incorrect. Veuillez réessayer. Nombre de tentatives restantes : ++Vous pouvez effectuer une recherche directement à partir du champ ci-dessus. ++Ajouter les expressions au premier plan ++Lorem ipsum dolor sit amet, consectetur adipiscing elit. ++Opérateur ++Confirmer l'installation ++(Mot clé : ) ++Sensibilité : ++ +diff --git a/tools/grit/grit/testdata/generated_resources_iw.xtb b/tools/grit/grit/testdata/generated_resources_iw.xtb +new file mode 100644 +index 0000000000..86b55334c0 +--- /dev/null ++++ b/tools/grit/grit/testdata/generated_resources_iw.xtb +@@ -0,0 +1,4 @@ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/generated_resources_no.xtb b/tools/grit/grit/testdata/generated_resources_no.xtb +new file mode 100644 +index 0000000000..913638ba4e +--- /dev/null ++++ b/tools/grit/grit/testdata/generated_resources_no.xtb +@@ -0,0 +1,4 @@ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/grit_part.grdp b/tools/grit/grit/testdata/grit_part.grdp +new file mode 100644 +index 0000000000..c8e9d92692 +--- /dev/null ++++ b/tools/grit/grit/testdata/grit_part.grdp +@@ -0,0 +1,5 @@ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/header.html b/tools/grit/grit/testdata/header.html +new file mode 100644 +index 0000000000..8e9d10ec50 +--- /dev/null ++++ b/tools/grit/grit/testdata/header.html +@@ -0,0 +1,39 @@ ++ ++[$~TITLE~$] ++ ++ ++ ++ ++[EXTRA_META] ++ ++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/homepage.html b/tools/grit/grit/testdata/homepage.html +new file mode 100644 +index 0000000000..cce4f2cf35 +--- /dev/null ++++ b/tools/grit/grit/testdata/homepage.html +@@ -0,0 +1,37 @@ ++ ++Google Desktop Search ++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++
Google Desktop Search

++
++ ++ ++ ++
++[$~LINKS~$] ++
++ ++ ++ ++ ++ ++
 
  Desktop Preferences
++

Search your own computer.

++[$~MESSAGE~$]
++
[$~SETHOMEPAGE~$][$~BOTTOMLINE~$]

++

©2005 Google - Searching [NUM_ITEMS] items

+\ No newline at end of file +diff --git a/tools/grit/grit/testdata/hover.html b/tools/grit/grit/testdata/hover.html +new file mode 100644 +index 0000000000..b8f9ce0200 +--- /dev/null ++++ b/tools/grit/grit/testdata/hover.html +@@ -0,0 +1,177 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++Sidebar ++Minibar ++Close ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
  
++
++ ++ ++
++ ++
++
++ ++ ++ +diff --git a/tools/grit/grit/testdata/include_test.html b/tools/grit/grit/testdata/include_test.html +new file mode 100644 +index 0000000000..e08f2e2e8a +--- /dev/null ++++ b/tools/grit/grit/testdata/include_test.html +@@ -0,0 +1,31 @@ ++ ++ ++should be kept ++ ++in the middle... ++ ++should be removed ++ ++ ++ ++should be removed ++ ++ should be removed because outer expr is False ++ ++should be removed ++ ++ ++ ++ ++ ++ nested true should be kept ++ ++ ++ should be removed ++ ++ ++ ++ silbing true should be kept ++ ++ ++at the end... +diff --git a/tools/grit/grit/testdata/included_sample.html b/tools/grit/grit/testdata/included_sample.html +new file mode 100644 +index 0000000000..7150ffcbea +--- /dev/null ++++ b/tools/grit/grit/testdata/included_sample.html +@@ -0,0 +1 @@ ++Hello Include! +diff --git a/tools/grit/grit/testdata/indexing_speed.html b/tools/grit/grit/testdata/indexing_speed.html +new file mode 100644 +index 0000000000..db1787b0e2 +--- /dev/null ++++ b/tools/grit/grit/testdata/indexing_speed.html +@@ -0,0 +1,58 @@ ++ ++Google Desktop Search Index Speed ++ ++ ++ ++ ++ ++ ++ ++ ++
++ Go to Google Desktop Search  ++ ++ ++ ++ ++
++ ++ ++ ++ ++
 Index SpeedIndex Speed ++ Help | About Google Desktop Search
++ ++

++To make your emails, files, and previously viewed web pages searchable, Google Desktop Search ++needs to index them. This indexing process is currently occuring in the background ++and your computer performance is minimally impacted. ++

++You have the option of speeding up this process. ++

Warning: Speeding up indexing will cause your computer ++to become unusable for many minutes, depending on how many items need to be indexed. FAST INDEXING IS NOT ++RECOMMENDED. ++
 
++

++ ++
++

++ ++
++
++ ++

 
++ ++ ++ ++
++ ++ ++ ++ ++
Google Desktop Search Home - Status - About Google Desktop Search - [$~BUILDNUMBER~$] - ©2005 Google

++ ++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/install_prefs.html b/tools/grit/grit/testdata/install_prefs.html +new file mode 100644 +index 0000000000..eca0b56de5 +--- /dev/null ++++ b/tools/grit/grit/testdata/install_prefs.html +@@ -0,0 +1,92 @@ ++ ++Google Desktop Search: Initial Preferences ++ ++ ++ ++ ++ ++ ++ ++

++ ++
++
To continue, please set these initial preferences:

++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
 
 
  ++
++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++ ++
Deskbar
++ ++ ++
++
  ++
You can change these and other preferences at any time.
++


++

++
++[SCRIPT] ++ ++ ++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/install_prefs2.html b/tools/grit/grit/testdata/install_prefs2.html +new file mode 100644 +index 0000000000..18380397c2 +--- /dev/null ++++ b/tools/grit/grit/testdata/install_prefs2.html +@@ -0,0 +1,52 @@ ++ ++Indexing has Started ++ ++ ++ ++ ++ ++ ++ ++
++

++
++
++One-time indexing has started.

++An index is being prepared on your computer to allow you ++to search your information as fast as you can search the web.

++
  • This is a one-time process that may take several hours. ++
  • You may continue to use your computer as usual and it is safe to shut down your computer. ++
  • Indexing will be performed only when your computer is idle. ++ ++ ++


    ++ ++

  • ++ ++
    ++ ++[SCRIPT] ++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/klonk-alternate-skeleton.rc b/tools/grit/grit/testdata/klonk-alternate-skeleton.rc +new file mode 100644 +index 0000000000000000000000000000000000000000..5f2c82a55469ddaab246c095826ad9e6743c0015 +GIT binary patch +literal 1088 +zcmbW0Pfr3t48`AhKZV)z#sGrI5!gjnU?DC>IT2z!82=r_L=!)}zjnmk5b$6oGo9&7 +z+t=4lu9UG-Ujxl_t%b{59ih$9PSBn!lW7`iGrKMm&Q10vTRK5!yRJHlRN`fcWril@ +zv|?uHM))d_NBa7`nW9TQ&PZ3tsax6ojav@U&9TYdHduz6k{G4GFTfpX_hk&`!z0F` +z!gJ>6WBh&UO&i_oS+VOvUfcD9JR=y&;3OxP2%KT$#JB9W=UtgQpDT@>(E^#^A;oG% +z4omjIK7rLXcRgmyS+%u_Gl2`MhOxMB{GGM&5o6cXFE~=G +z`!#F5=z%_bq95y7+aIx?IdcSN`A)xX^vZjCS7lnS#=iZ)E7W%eX8!kr-#RDO36^!o +Qqn&wY8qX0d7T}2V4SbP+*8l(j + +literal 0 +HcmV?d00001 + +diff --git a/tools/grit/grit/testdata/klonk.ico b/tools/grit/grit/testdata/klonk.ico +new file mode 100644 +index 0000000000000000000000000000000000000000..d371b214dc366249870efccc5da278d023aa91f1 +GIT binary patch +literal 766 +zcmeH_F%H5o5CqSFL>Ve71Sxq1;TtsMEB*!Fv6LbmDQFSUL1mXjO7OC0gpl|G?B1ML +zXS=a1V(2`di0U>FnQ~o{oUDnF5j(}bxAgSuhE8lMu~rkI8Ju%mb%Im^Xd<+ZwEgwd +zFTg+WQOj5lfvO*4mbEA^bCj9KHh65vjx^zvsKW{eA8|Ah`w&r;%!`QgmEiG3hXCcC +L+@V2V6oA7MJIRBx + +literal 0 +HcmV?d00001 + +diff --git a/tools/grit/grit/testdata/klonk.rc b/tools/grit/grit/testdata/klonk.rc +new file mode 100644 +index 0000000000000000000000000000000000000000..35652c4e6dd7cf7b7f62f637e191acf66f487235 +GIT binary patch +literal 9824 +zcmeI2+j1L48poSUd1!LS!j6*Z-q>7MTIeClrf{=b{yW=KLKoQA`29(tkA +z?@<`g*P*W;F2X@LqqP?P!IgxQa2&e)&gmcUJfiQMr{-PocF21|OVCckGsY~31#sNt +zeuJJaU(OhLWaHAYxy#{kNExfq8uQ5J2xc`jLo2kyURV$HuoL#fZm7|_&ii)Q3SZFE +z;@$|W^lb4S@e23#yIdxsED4)%Ix5vi$fg&b@^yerB!M>k-sfJ2-!(XtBx>~E;y0>; +zywqpO@eUBz4c2yv49m3k+_Z88eb3Rg>+A-4?GCk8rmyLEuD7;k@iyBQuQz|u4r}P| +z1pk!hKgO!w#>STMq~-8ViH-G#etL?RCgF{OzaBBS8aA-k=%+1wau1JP!(#WbwJk2e +z{FW=3II|6mUA$wTS=-Ei$KrzUMVn6ea?kwXHeRp*%qrtH8Cm5n-|(IYVUuHA@wRN;~7h6y+xyz_&R~;+XxM^eZ-_q~|%%b86_{3Asa-8FBk+Z7c-kJgN>UjHR +zv*J6C_vNv`hUxGkXMvL0T0vKhVQf$p6QjfeUR}fgl_wW2W!gk%O?IOa`tbcYLDwE{AY?>BR88vkIj3pcp9ftwy~b;A8i-;T|_p=$nY5yWU!`jTE^ib +ze*F+mE-Vf$>e;=5g*fg0^w_NUeElxZA2EAWiGRui^1Zl<=<)P1 +zF&Y;=yo$%KVIA>VGwa=@)kgQbrt31jq~WuvvL2VO`$zNqGSmHCaU;Y2q0yQ$JF7mTwL~ub{sOMb^Vh8GFZ(K1F-x>#wroJR +z&tF1@??TN-{BD^HbgJ;mLeTx&a +ztSZO1p-!t5NvMLINn_JEi1N%h$mrKfeZ%Sxtv*(Sq%E`|5` +zMQa!2rJ*fu!l%|$%^a7pE^XVFE$AM-((pNcct~BK8YqR1Sd~Aqmi*&@D)rQ&bN`YW +zMPvC%+;<0?G_uSf2bldXz_x`Rp$tXUa07m0#5g^O>n*TJE4PW#|}5_jztxOjO*+fAM}< +zk=Lii5sD#879SKTSIp++>5AlgXumxIv246U-XKqCe;}^ATDIP+P{%8`Yynw2Uilpc +z$xha}X;{ahB+#YVajq(xJ|2|kCBqoURxZc-PCWGR&NeH+c%h>-Yw>z7_{+>=5WWql;yg~F}V-&+XR>jna$uG|ylUKW)Rw*m^ +z_oOjp@vHny>%lMrW)jt@&DG$}J`tOC!twxncz`|R{U9wplS^%1SD7h)zLPS$9KxSJ +z^(luqF00#DmestFZxDq%2fL5@KE>#HI|)#R(g69An@YFD|(_t^K?Y(=LYvGR$s)LKbvaYc(JPp$Xb2G?a>eC9KE-cEhZ +zHSZ3+_C$Rze-w`BSsn7ZgI%TJO=9FfdDBy)V;pqaYpnOHjNdZ)cZhIWOV;71NPE_b +z5ZwYd@EV=tI))^?mN>3>KBO~=3-s|NvQu_bO!m`Xy&s`1RS8A9bec9lO`@(ym$)sX +zMVVq?wjta)kvTJp%Bk>bSh}4@HcmwuW}T<$ta~!gT03ja*d|hI1w9*Uk>}TwPvL12 +z=Q{J$UgQ8RXmu+(2GDd)J#{>6mrEh;W{57|8=6JgB)U>?#`vQXEaBEZgsP}6H0c~I +zlTn_wQLB~3>U1IQ2y}Rh=cM|##66Rnd!p7F(K=LbM6B`LtO3?OS3Ko>03~gD6g5tu +zOSRooa>4*SqvO;gSO;d)IuFc4e&rSY3#4arR~e}tmqXie5w!0rzg2#y{KWm2%CD85 +zD?e8LTlv1?UR>st9pKlDtGM^mfuA&df=7MIT`QQ#k8mnxoriygx5#|&^UZ&6F?Nx! +z2jMH^+zTJm>H?vU#6L!6XLz9~{RHheL_xo4SVUcx*(c|e8ZfVRzJC37^PM7DoUXW9 +zRu0v_b;|ztF`73W!u5N4HWX!l^ZH1;i+3m{&0Ya4gg*c` +C>9bG( + +literal 0 +HcmV?d00001 + +diff --git a/tools/grit/grit/testdata/ko_oem_enable_bug.html b/tools/grit/grit/testdata/ko_oem_enable_bug.html +new file mode 100644 +index 0000000000..f2c199cc15 +--- /dev/null ++++ b/tools/grit/grit/testdata/ko_oem_enable_bug.html +@@ -0,0 +1 @@ ++아웃룩 +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/ko_oem_non_admin_bug.html b/tools/grit/grit/testdata/ko_oem_non_admin_bug.html +new file mode 100644 +index 0000000000..b9e8a1f288 +--- /dev/null ++++ b/tools/grit/grit/testdata/ko_oem_non_admin_bug.html +@@ -0,0 +1 @@ ++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/mini.html b/tools/grit/grit/testdata/mini.html +new file mode 100644 +index 0000000000..8ac0a231a0 +--- /dev/null ++++ b/tools/grit/grit/testdata/mini.html +@@ -0,0 +1,36 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++ ++ ++ ++ ++ ++ ++ ++
      
    ++
    ++
    +diff --git a/tools/grit/grit/testdata/oem_enable.html b/tools/grit/grit/testdata/oem_enable.html +new file mode 100644 +index 0000000000..db6b85eca6 +--- /dev/null ++++ b/tools/grit/grit/testdata/oem_enable.html +@@ -0,0 +1,106 @@ ++ ++Google Desktop Search Download ++ ++ ++ ++ ++ ++
    ++ ++ ++ ++ ++ ++
    ++
    Google Desktop Search
                Search your own ++computer.

    ++ ++ ++ ++ ++ ++
    ++
  • Find your email, files, web history and chats instantly ++
  • View web pages you've seen, even when you're not online ++
  • Search as easily as you do on Google ++

    Google Desktop Search finds:

    ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    Outlook  Email from Outlook, Outlook Express, & ++ Thunderbird
    Internet Explorer  Web history ++ from IE/Firefox/Mozilla/Netscape
    Text  Files in Word, ++ Excel, Powerpoint, PDF, & media formats
    AOL IM  Chats from AOL ++ Instant Messenger
     
     About Desktop ++ Search   Screenshots   ++ Help   Contact ++ Us
  •     ++ ++ ++ ++

    ++
    By using, you agree to our
    Terms & ++ Conditions
    and Privacy ++ Policy
    ++

    ++
    ++

    ++

    * Automatically starts when you turn on ++ your computer
    ++

    ++

    ++
    ©2005 Google ++

    +diff --git a/tools/grit/grit/testdata/oem_non_admin.html b/tools/grit/grit/testdata/oem_non_admin.html +new file mode 100644 +index 0000000000..8b7ca13e21 +--- /dev/null ++++ b/tools/grit/grit/testdata/oem_non_admin.html +@@ -0,0 +1,39 @@ ++ ++Google Desktop Search Preferences ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++
    ++


    We're sorry, but you need administrator access to ++enable Desktop Search.

    ++

    To install or run Google Desktop Search you need administrator access on this ++computer. Please try installing again once you have administrator ++access.

    ++


    ++
    +diff --git a/tools/grit/grit/testdata/onebox.html b/tools/grit/grit/testdata/onebox.html +new file mode 100644 +index 0000000000..c24ff043a5 +--- /dev/null ++++ b/tools/grit/grit/testdata/onebox.html +@@ -0,0 +1,21 @@ ++Google Desktop Search Results ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/oneclick.html b/tools/grit/grit/testdata/oneclick.html +new file mode 100644 +index 0000000000..32dc6459dd +--- /dev/null ++++ b/tools/grit/grit/testdata/oneclick.html +@@ -0,0 +1,34 @@ ++[HEADER] ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ [EMAIL_TOP_CHROME] ++ ++

    ++ ++ [EMAIL] ++
    ++

    ++ [FREQ_TOP_CHROME] ++

    ++ ++ [$~FREQ~$] ++
    ++

    ++ [RECENT_TOP_CHROME] ++ ++ [$~RECENT~$] ++
    ++

    ++

    ++ ++ ++[FOOTER] +diff --git a/tools/grit/grit/testdata/password.html b/tools/grit/grit/testdata/password.html +new file mode 100644 +index 0000000000..16007a1ac0 +--- /dev/null ++++ b/tools/grit/grit/testdata/password.html +@@ -0,0 +1,37 @@ ++ ++Password Required ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++
    Google Desktop Search

    ++
    ++ ++ ++
    ++ ++ ++ ++
    Password required:   ++ ++   ++
    ++ ++
    ++
    [$~BOTTOMLINE~$]

    ++

    ©2005 Google

    +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/preferences.html b/tools/grit/grit/testdata/preferences.html +new file mode 100644 +index 0000000000..b37412436b +--- /dev/null ++++ b/tools/grit/grit/testdata/preferences.html +@@ -0,0 +1,234 @@ ++ ++Google Desktop Search Preferences ++ ++ ++ ++ ++ ++
    ++ ++ ++ ++ ++
    ++Go to Google Desktop Search  ++ ++ ++ ++ ++
    Preferences ++Preferences Help ++
    ++ ++
    ++ ++ ++ ++ ++
    ++Save your preferences when finished.
    ++ ++[STATUS-MESSAGE] ++ ++ ++
    Preferences (changes apply to Google Desktop Search application)
    ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    Search types
    Index the following items so that you can ++search for them:
     
    ++
    ++ ++ ++ ++ ++ ++
    ++
    ++
    ++ ++ ++
    ++ ++ ++
    ++ ++
    ++ ++
    ++
    ++ ++
    ++ ++
    ++

    ++ ++
    ++
    ++
    Plug-ins
    Index these additional items:

    ++[ADDIN-DO] ++[ADDIN-OPTIONS]

    ++To install plug-ins to index other items, visit the ++Plug-ins Download page.
    ++
    Don't search these items
    ++
    ++c:\Documents and Settings\username\Private Stuff
    ++http://www.domain.com/
    ++
     
    ++
    ++
    Search Box Display ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++ ++
    Deskbar
    ++ ++ ++
    ++ ++ ++ ++
    ++ ++
    Number of Results ++
    Google integration ++ ++ ++ ++
    ++ Your personal results are private from Google. ++
    ++
    Help us improve ++ ++
    ++ ++ ++ ++ ++
    Save your preferences ++when finished.
    ++ ++

    [$~BOTTOMLINE~$]
    ++
    ©2005 Google
    ++
    +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/preprocess_test.html b/tools/grit/grit/testdata/preprocess_test.html +new file mode 100644 +index 0000000000..13ece9a9f6 +--- /dev/null ++++ b/tools/grit/grit/testdata/preprocess_test.html +@@ -0,0 +1,7 @@ ++ ++should be kept ++ ++in the middle... ++ ++should be removed ++ +diff --git a/tools/grit/grit/testdata/privacy.html b/tools/grit/grit/testdata/privacy.html +new file mode 100644 +index 0000000000..1d45f4a539 +--- /dev/null ++++ b/tools/grit/grit/testdata/privacy.html +@@ -0,0 +1,35 @@ ++[!] ++title Privacy and Google Desktop Search ++template ++privacy_bottomline ++hp_image ++ ++ ++ ++
    ++

    Privacy and Google Desktop Search

    ++ ++

    Google is committed to making search on your desktop as easy ++as searching the web. We recognize that privacy is an important issue, ++so we designed and built Google Desktop Search with respect for your privacy. ++

    ++So that you can easily search your computer, the Google Desktop Search application indexes ++and stores versions of your files and other computer activity, ++such as email, chats, and web history. These versions may also be mixed ++with your Web search results to produce ++results pages for you that integrate relevant content from your computer and ++information from the Web. ++

    ++Your computer's content is not made accessible to Google or anyone else without your explicit permission. ++ ++

    You can read the ++Privacy Policy ++and Privacy FAQ online. ++ ++

    ++ ++

    ++ ++
    ++[$~PRIVACY_BOTTOMLINE~$] - ©2005 Google ++
    +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/quit_apps.html b/tools/grit/grit/testdata/quit_apps.html +new file mode 100644 +index 0000000000..a501b0e2bf +--- /dev/null ++++ b/tools/grit/grit/testdata/quit_apps.html +@@ -0,0 +1,49 @@ ++ ++Google Desktop Search Preferences ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++
    ++


    To start using Google Desktop Search, we may need to close the following programs if they are running:

    ++

    You can start these programs once Google Desktop Search is running.

    ++ ++
  • AOL Instant Messenger ++
  • Firefox ++
  • Internet Explorer ++
  • Microsoft Excel ++
  • Microsoft Outlook ++
  • Microsoft Word ++
  • Mozilla ++
  • Mozilla Thunderbird ++
  • Netscape ++
  • Opera ++
  • Other web browsers ++ ++

    This will take only a few seconds to complete.

  • ++

    ++

    ++
    +diff --git a/tools/grit/grit/testdata/recrawl.html b/tools/grit/grit/testdata/recrawl.html +new file mode 100644 +index 0000000000..0401e7c2b0 +--- /dev/null ++++ b/tools/grit/grit/testdata/recrawl.html +@@ -0,0 +1,30 @@ ++ ++Refresh index ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++ ++ ++ ++
    Google Desktop Search ++
    ++
    ++
    Google Desktop Search is now recrawling your drive to index new files.
    ++
    Note that new files are indexed automatically, and this step is generally not needed.
    ++
    Click here to continue.
    ++ ++
    ++[$~BOTTOMLINE~$] ++

    ©2005 Google

    ++
    ++ ++ +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/resource_ids b/tools/grit/grit/testdata/resource_ids +new file mode 100644 +index 0000000000..d5d440d57f +--- /dev/null ++++ b/tools/grit/grit/testdata/resource_ids +@@ -0,0 +1,13 @@ ++{ ++ "SRCDIR": ".", ++ "test.grd": { ++ "messages": [100, 10000], ++ }, ++ "substitute_no_ids.grd": { ++ "messages": [10000, 20000], ++ }, ++ "<(FOO)/file.grd": { ++ }, ++ "<(SHARED_INTERMEDIATE_DIR)/devtools/devtools.grd": { ++ }, ++} +diff --git a/tools/grit/grit/testdata/script.html b/tools/grit/grit/testdata/script.html +new file mode 100644 +index 0000000000..f177d9c30e +--- /dev/null ++++ b/tools/grit/grit/testdata/script.html +@@ -0,0 +1,38 @@ ++ +diff --git a/tools/grit/grit/testdata/searchbox.html b/tools/grit/grit/testdata/searchbox.html +new file mode 100644 +index 0000000000..9eccba99a5 +--- /dev/null ++++ b/tools/grit/grit/testdata/searchbox.html +@@ -0,0 +1,22 @@ ++ ++ ++ ++ ++ ++
    Go to Google Desktop Search   ++ ++ ++ ++ ++
    ++ ++ ++
    ++[$~LINKS~$] ++
    ++
    ++[$~FLAGS~$]
      Desktop Preferences
      [DELETE_NAME]
    ++ ++ ++
     
    ++
    +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/sidebar_h.html b/tools/grit/grit/testdata/sidebar_h.html +new file mode 100644 +index 0000000000..e103e8f8db +--- /dev/null ++++ b/tools/grit/grit/testdata/sidebar_h.html +@@ -0,0 +1,82 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++
    ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
     Google Desktop Search
    ++
    ++ ++
    ++ ++[HEADER_SECTION1] ++[CONTENT_INBOX] ++ ++ ++ ++[HEADER_SECTION2] ++[CONTENT_HIST] ++ ++ ++ ++[CONTENT_NEWS] ++[CONTENT_OTHER] ++ ++ ++ ++ ++ ++
    ++ ++ ++ ++[SCRIPT] ++ +diff --git a/tools/grit/grit/testdata/sidebar_v.html b/tools/grit/grit/testdata/sidebar_v.html +new file mode 100644 +index 0000000000..e040d8ec59 +--- /dev/null ++++ b/tools/grit/grit/testdata/sidebar_v.html +@@ -0,0 +1,267 @@ ++ ++Google Desktop Search Sidebar ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++ ++ ++ ++
    ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++
    ++ ++ ++ ++ ++ ++ ++
    Google Desktop Search  Web 
    ++
    ++ ++

    ++
    ++
     News
    ++
    ++ ++ ++[CONTENT_NEWS] ++

    ++ ++ ++
    ++
     Email
    ++
    ++ ++ ++[CONTENT_INBOX] ++

    ++ ++ ++
    ++
     Related History
    ++
    ++ ++ ++[CONTENT_HIST] ++

    ++ ++ ++ ++
    ++
     Recent
    ++
    ++ ++ ++[CONTENT_RECENT] ++

    ++ ++ ++ ++
    ++
     Frequently Visited
    ++
    ++ ++ ++[CONTENT_POPULAR] ++

    ++ ++ ++ ++
    ++
     Implicit Query Debug
    ++
    ++ ++ ++[CONTENT_QUIB_DEBUG] ++ ++ ++ ++ ++[CONTENT_OTHER] ++ ++[SCRIPT] ++ ++ +diff --git a/tools/grit/grit/testdata/simple-input.xml b/tools/grit/grit/testdata/simple-input.xml +new file mode 100644 +index 0000000000..92827fa4b5 +--- /dev/null ++++ b/tools/grit/grit/testdata/simple-input.xml +@@ -0,0 +1,52 @@ ++ ++ ++ ++ ++ Hello earthlings! ++ ++ ++ ++ ++ ++ ++ ++ ++ Go! ++ ++ Hello %sJoi, how are you doing today? ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/simple.html b/tools/grit/grit/testdata/simple.html +new file mode 100644 +index 0000000000..4392d23e98 +--- /dev/null ++++ b/tools/grit/grit/testdata/simple.html +@@ -0,0 +1,3 @@ ++

    ++ Hello! ++

    +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/source.rc b/tools/grit/grit/testdata/source.rc +new file mode 100644 +index 0000000000..fbc72284e9 +--- /dev/null ++++ b/tools/grit/grit/testdata/source.rc +@@ -0,0 +1,57 @@ ++IDC_KLONKMENU MENU ++BEGIN ++ POPUP "&File" ++ BEGIN ++ MENUITEM "E&xit", IDM_EXIT ++ MENUITEM "This be ""Klonk"" me like", ID_FILE_THISBE ++ POPUP "gonk" ++ BEGIN ++ MENUITEM "Klonk && is [good]", ID_GONK_KLONKIS ++ END ++ END ++ POPUP "&Help" ++ BEGIN ++ MENUITEM "&About ...", IDM_ABOUT ++ END ++END ++ ++IDD_ABOUTBOX DIALOGEX 22, 17, 230, 75 ++STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU ++CAPTION "About" ++FONT 8, "System", 0, 0, 0x0 ++BEGIN ++ ICON IDI_KLONK,IDC_MYICON,14,9,20,20 ++ LTEXT "klonk Version ""yibbee"" 1.0",IDC_STATIC,49,10,119,8, ++ SS_NOPREFIX ++ LTEXT "Copyright (C) 2005",IDC_STATIC,49,20,119,8 ++ DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP ++ CONTROL "Jack ""Black"" Daniels",IDC_RADIO1,"Button", ++ BS_AUTORADIOBUTTON,46,51,84,10 ++END ++ ++IDD_DIFFERENT_LENGTH_IN_TRANSL DIALOGEX 22, 17, 230, 75 ++STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU ++CAPTION "Bingobobbi" ++FONT 8, "System", 0, 0, 0x0 ++BEGIN ++ LTEXT "Howdie dodie!",IDC_STATIC,49,10,119,8,SS_NOPREFIX ++ LTEXT "Yo froodie!",IDC_STATIC,49,20,119,8 ++END ++ ++STRINGTABLE ++BEGIN ++ IDS_SIMPLE "One" ++ IDS_PLACEHOLDER "%s birds" ++ IDS_PLACEHOLDERS "%d of %d" ++ IDS_REORDERED_PLACEHOLDERS "$1 of $2" ++ // Won't be in translations list because it has changed ++ IDS_CHANGED "This was the old version" ++ IDS_TWIN_1 "Hello" ++ IDS_TWIN_2 "Hello" ++ IDS_NOT_TRANSLATEABLE ":" ++ IDS_LONGER_TRANSLATED "Removed document $1" ++ // Won't appear in the list of translations because it's not in the .grd file ++ IDS_NO_LONGER_USED "Not used" ++ IDS_DIFFERENT_TWIN_1 "Howdie" ++ IDS_DIFFERENT_TWIN_2 "Howdie" ++END +diff --git a/tools/grit/grit/testdata/special_100_percent/a.png b/tools/grit/grit/testdata/special_100_percent/a.png +new file mode 100644 +index 0000000000000000000000000000000000000000..5d5089038ca71172e95db9e7aae1e1fa5cebd505 +GIT binary patch +literal 159 +zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>0wld=oSO}#(mY)pLnNjq|2Y3)zGGzYPN&L+ +zMSC}CcCfp=Dtxv4%6W%G#Q=|R|L;6pCCLUWO)Z<5eoL%TkDTw=s4X!^d(Qa<2khAN +zZPy!XToBAic1Ss}vcWiD27B3&`Zj^H6CO>7R1{ToQ;=ggdEYbV=IISvfHpFCy85}S +Ib4q9e0O9jEh5!Hn + +literal 0 +HcmV?d00001 + +diff --git a/tools/grit/grit/testdata/status.html b/tools/grit/grit/testdata/status.html +new file mode 100644 +index 0000000000..6b997b9369 +--- /dev/null ++++ b/tools/grit/grit/testdata/status.html +@@ -0,0 +1,44 @@ ++[HEADER] ++ ++ ++
    ++ ++ ++
     Desktop Search Status
    ++
    ++
    ++[$~MESSAGE~$] ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
     Number of itemsTime of newest item
      Total searchable items[TOTAL_COUNT][TOTAL_TIME]
           Emails[EMAIL_COUNT][EMAIL_TIME]
           Chats[IM_COUNT][IM_TIME]
           Web history[WEB_COUNT][WEB_TIME]
           Files[FILE_COUNT][FILE_TIME]
    ++
    ++[FOOTER] +\ No newline at end of file +diff --git a/tools/grit/grit/testdata/structure_variables.html b/tools/grit/grit/testdata/structure_variables.html +new file mode 100644 +index 0000000000..2a15de8072 +--- /dev/null ++++ b/tools/grit/grit/testdata/structure_variables.html +@@ -0,0 +1,4 @@ ++

    [GREETING]!

    ++Some cool things are [THINGS]. ++Did you know that [EQUATION]? ++ +diff --git a/tools/grit/grit/testdata/substitute.grd b/tools/grit/grit/testdata/substitute.grd +new file mode 100644 +index 0000000000..95dcc56e1d +--- /dev/null ++++ b/tools/grit/grit/testdata/substitute.grd +@@ -0,0 +1,31 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Copyright 2008 Google Inc. All Rights Reserved. ++ ++ ++ Google Desktop News gadget ++[IDS_COPYRIGHT_GOOGLE_LONG] ++View news that is personalized based on the articles you read. ++ ++For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/substitute.xmb b/tools/grit/grit/testdata/substitute.xmb +new file mode 100644 +index 0000000000..e592069c8b +--- /dev/null ++++ b/tools/grit/grit/testdata/substitute.xmb +@@ -0,0 +1,10 @@ ++ ++ ++ ++© 2008 Google Inc. Med ensamrätt. ++Google Desktop News gadget ++ ++Se nyheter som är anpassade till dig, baserat på de artiklar du läser. ++ ++Om du t.ex. läser massor av sportnyheter kommer du att se fler sportartiklar. Om du inte läser tekniknyheter lika ofta ser du färre av dessa artiklar. ++ +diff --git a/tools/grit/grit/testdata/substitute_no_ids.grd b/tools/grit/grit/testdata/substitute_no_ids.grd +new file mode 100644 +index 0000000000..d569d1cacd +--- /dev/null ++++ b/tools/grit/grit/testdata/substitute_no_ids.grd +@@ -0,0 +1,31 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Copyright 2008 Google Inc. All Rights Reserved. ++ ++ ++ Google Desktop News gadget ++[IDS_COPYRIGHT_GOOGLE_LONG] ++View news that is personalized based on the articles you read. ++ ++For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/substitute_tmpl.grd b/tools/grit/grit/testdata/substitute_tmpl.grd +new file mode 100644 +index 0000000000..be7b601707 +--- /dev/null ++++ b/tools/grit/grit/testdata/substitute_tmpl.grd +@@ -0,0 +1,31 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Copyright 2008 Google Inc. All Rights Reserved. ++ ++ ++ Google Desktop News gadget ++[IDS_COPYRIGHT_GOOGLE_LONG] ++View news that is personalized based on the articles you read. ++ ++For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/test_css.css b/tools/grit/grit/testdata/test_css.css +new file mode 100644 +index 0000000000..55d5dd1770 +--- /dev/null ++++ b/tools/grit/grit/testdata/test_css.css +@@ -0,0 +1 @@ ++This is a test! +diff --git a/tools/grit/grit/testdata/test_html.html b/tools/grit/grit/testdata/test_html.html +new file mode 100644 +index 0000000000..55d5dd1770 +--- /dev/null ++++ b/tools/grit/grit/testdata/test_html.html +@@ -0,0 +1 @@ ++This is a test! +diff --git a/tools/grit/grit/testdata/test_js.js b/tools/grit/grit/testdata/test_js.js +new file mode 100644 +index 0000000000..55d5dd1770 +--- /dev/null ++++ b/tools/grit/grit/testdata/test_js.js +@@ -0,0 +1 @@ ++This is a test! +diff --git a/tools/grit/grit/testdata/test_svg.svg b/tools/grit/grit/testdata/test_svg.svg +new file mode 100644 +index 0000000000..55d5dd1770 +--- /dev/null ++++ b/tools/grit/grit/testdata/test_svg.svg +@@ -0,0 +1 @@ ++This is a test! +diff --git a/tools/grit/grit/testdata/test_text.txt b/tools/grit/grit/testdata/test_text.txt +new file mode 100644 +index 0000000000..55d5dd1770 +--- /dev/null ++++ b/tools/grit/grit/testdata/test_text.txt +@@ -0,0 +1 @@ ++This is a test! +diff --git a/tools/grit/grit/testdata/time_related.html b/tools/grit/grit/testdata/time_related.html +new file mode 100644 +index 0000000000..ee64b1665e +--- /dev/null ++++ b/tools/grit/grit/testdata/time_related.html +@@ -0,0 +1,11 @@ ++[HEADER] ++[CHROME] ++[NAV_PRE_POST] ++[$~MESSAGE~$]
    ++ ++[CONTENTS] ++

    ++ ++[NAV_PRE_POST] ++[FOOTER] ++ +diff --git a/tools/grit/grit/testdata/toolbar_about.html b/tools/grit/grit/testdata/toolbar_about.html +new file mode 100644 +index 0000000000..bb4b0eb355 +--- /dev/null ++++ b/tools/grit/grit/testdata/toolbar_about.html +@@ -0,0 +1,138 @@ ++ ++ ++ ++About Google Toolbar ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
    ++ ++ ++ ++ ++ ++ ++
    ++
    Google Toolbar
    ++
    ++
    ++ ++ ++
    ++
    ++ ++
    ++
    ++
    ++ ++ ++ De parvis grandis acervus erit ++ ++ ++
    ++ ++ © 2006 Google ++ ++ ++
    ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/tools/grit/resource_ids b/tools/grit/grit/testdata/tools/grit/resource_ids +new file mode 100644 +index 0000000000..8a2b608df1 +--- /dev/null ++++ b/tools/grit/grit/testdata/tools/grit/resource_ids +@@ -0,0 +1,176 @@ ++# Copyright (c) 2011 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++# ++# This file is used to assign starting resource ids for resources and strings ++# used by Chromium. This is done to ensure that resource ids are unique ++# across all the grd files. If you are adding a new grd file, please add ++# a new entry to this file. ++# ++# The first entry in the file, SRCDIR, is special: It is a relative path from ++# this file to the base of your checkout. ++# ++# http://msdn.microsoft.com/en-us/library/t2zechd4(VS.71).aspx says that the ++# range for IDR_ is 1 to 28,671 and the range for IDS_ is 1 to 32,767 and ++# common convention starts practical use of IDs at 100 or 101. ++{ ++ "SRCDIR": "../..", ++ ++ "chrome/browser/browser_resources.grd": { ++ "includes": [500], ++ }, ++ "chrome/browser/resources/component_extension_resources.grd": { ++ "includes": [1000], ++ }, ++ "chrome/browser/resources/net_internals_resources.grd": { ++ "includes": [1500], ++ }, ++ "chrome/browser/resources/shared_resources.grd": { ++ "includes": [2000], ++ }, ++ "chrome/common/common_resources.grd": { ++ "includes": [2500], ++ }, ++ "chrome/default_plugin/default_plugin_resources.grd": { ++ "includes": [3000], ++ }, ++ "chrome/renderer/renderer_resources.grd": { ++ "includes": [3500], ++ }, ++ "net/base/net_resources.grd": { ++ "includes": [4000], ++ }, ++ "webkit/glue/webkit_resources.grd": { ++ "includes": [4500], ++ }, ++ "webkit/tools/test_shell/test_shell_resources.grd": { ++ "includes": [5000], ++ }, ++ "ui/resources/ui_resources.grd": { ++ "includes": [5500], ++ }, ++ "chrome/app/theme/theme_resources.grd": { ++ "includes": [6000], ++ }, ++ "chrome_frame/resources/chrome_frame_resources.grd": { ++ "includes": [6500], ++ }, ++ # WebKit.grd can be in two different places depending on whether we are ++ # in a chromium checkout or a webkit-only checkout. ++ "third_party/WebKit/Source/WebKit/chromium/WebKit.grd": { ++ "includes": [7000], ++ }, ++ "WebKit.grd": { ++ "includes": [7000], ++ }, ++ ++ "ui/base/strings/app_locale_settings.grd": { ++ "META": {"join": 2}, ++ "messages": [7500], ++ }, ++ "chrome/app/resources/locale_settings.grd": { ++ "includes": [8000], ++ "messages": [8500], ++ }, ++ # These each start with the same resource id because we only use one ++ # file for each build (cros, linux, mac, or win). ++ "chrome/app/resources/locale_settings_cros.grd": { ++ "messages": [9000], ++ }, ++ "chrome/app/resources/locale_settings_linux.grd": { ++ "messages": [9000], ++ }, ++ "chrome/app/resources/locale_settings_mac.grd": { ++ "messages": [9000], ++ }, ++ "chrome/app/resources/locale_settings_win.grd": { ++ "messages": [9000], ++ }, ++ ++ "ui/base/strings/ui_strings.grd": { ++ "META": {"join": 4}, ++ "messages": [9500], ++ }, ++ # Chromium strings and Google Chrome strings must start at the same id. ++ # We only use one file depending on whether we're building Chromium or ++ # Google Chrome. ++ "chrome/app/chromium_strings.grd": { ++ "messages": [10000], ++ }, ++ "chrome/app/google_chrome_strings.grd": { ++ "messages": [10000], ++ }, ++ # Leave lots of space for generated_resources since it has most of our ++ # strings. ++ "chrome/app/generated_resources.grd": { ++ "META": {"join": 2}, ++ "structures": [10500], ++ "messages": [11000], ++ }, ++ # The chrome frame dialogs are also in generated_resources.grd so they ++ # get included by the translation console. We make sure that the ids ++ # for structures here are the same as for generated_resources.grd. ++ "chrome_frame/resources/chrome_frame_dialogs.grd": { ++ "structures": [10500], ++ "includes": [10750], ++ }, ++ "webkit/glue/inspector_strings.grd": { ++ "messages": [16000], ++ }, ++ "webkit/glue/webkit_strings.grd": { ++ "messages": [16500], ++ }, ++ ++ "chrome_frame/resources/chrome_frame_resources.grd": { ++ "includes": [17500], ++ "structures": [18000], ++ }, ++ ++ "ui/gfx/gfx_resources.grd": { ++ "includes": [18500], ++ }, ++ ++ "chrome/app/policy/policy_templates.grd": { ++ "structures": [19000], ++ "messages": [19010], ++ }, ++ ++ "chrome/browser/autofill/autofill_resources.grd": { ++ "messages": [19500], ++ }, ++ "chrome/browser/resources/sync_internals_resources.grd": { ++ "includes": [20000], ++ }, ++ # This file is generated during the build. ++ "<(SHARED_INTERMEDIATE_DIR)/devtools/devtools_resources.grd": { ++ "includes": [20500], ++ }, ++ # All standard and large theme resources should have the same IDs. ++ "chrome/app/theme/theme_resources_standard.grd": { ++ "includes": [21000], ++ }, ++ "chrome/app/theme/theme_resources_large.grd": { ++ "includes": [21000], ++ }, ++ # This file is generated during the build. ++ "chrome/browser/debugger/frontend/devtools_frontend_resources.grd": { ++ "META": {"join": 2}, ++ "includes": [21500], ++ }, ++ "cloud_print/virtual_driver/win/install/virtual_driver_setup_resources.grd": { ++ "messages": [22500], ++ }, ++ "chrome/browser/resources/quota_internals_resources.grd": { ++ "includes": [23000], ++ }, ++ "chrome/browser/resources/workers_resources.grd": { ++ "includes": [23500], ++ }, ++ # All standard and large theme resources should have the same IDs. ++ "ui/resources/ui_resources_standard.grd": { ++ "includes": [24000], ++ }, ++ "ui/resources/ui_resources_large.grd": { ++ "includes": [24000], ++ }, ++} +diff --git a/tools/grit/grit/testdata/transl.rc b/tools/grit/grit/testdata/transl.rc +new file mode 100644 +index 0000000000..2f2595db3f +--- /dev/null ++++ b/tools/grit/grit/testdata/transl.rc +@@ -0,0 +1,56 @@ ++IDC_KLONKMENU MENU ++BEGIN ++ POPUP "&Skra" ++ BEGIN ++ MENUITEM "&Haetta", IDM_EXIT ++ MENUITEM "Thetta er ""Klonk"" sem eg fyla", ID_FILE_THISBE ++ POPUP "gonkurinn" ++ BEGIN ++ MENUITEM "Klonk && er [good]", ID_GONK_KLONKIS ++ END ++ END ++ POPUP "&Hjalp" ++ BEGIN ++ MENUITEM "&Um...", IDM_ABOUT ++ END ++END ++ ++IDD_ABOUTBOX DIALOGEX 22, 17, 230, 75 ++STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU ++CAPTION "Um Klonk" ++FONT 8, "System", 0, 0, 0x0 ++BEGIN ++ ICON IDI_KLONK,IDC_MYICON,14,9,20,20 ++ LTEXT "klonk utgafa ""jibbi"" 1.0",IDC_STATIC,49,10,119,8, ++ SS_NOPREFIX ++ LTEXT "Hofundarrettur (C) 2005",IDC_STATIC,49,20,119,8 ++ DEFPUSHBUTTON "I lagi",IDOK,195,6,30,11,WS_GROUP ++ CONTROL "Jack ""Black"" Daniels",IDC_RADIO1,"Button", ++ BS_AUTORADIOBUTTON,46,51,84,10 ++END ++ ++IDD_DIFFERENT_LENGTH_IN_TRANSL DIALOGEX 22, 17, 230, 75 ++STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU ++CAPTION "Bingobobbi" ++FONT 8, "System", 0, 0, 0x0 ++BEGIN ++ LTEXT "Howdie dodie!",IDC_STATIC,49,10,119,8,SS_NOPREFIX ++END ++ ++STRINGTABLE ++BEGIN ++ IDS_SIMPLE "Ein" ++ IDS_PLACEHOLDER "%s Vogeln" ++ IDS_PLACEHOLDERS "%d von %d" ++ // Shouldn't be part of translations list because the translation is ++ // reordered so placeholder fixup fails ++ IDS_REORDERED_PLACEHOLDERS "$2 auf $1" ++ IDS_CHANGED "Dass war die alte Version" ++ IDS_TWIN_1 "Hallo" ++ IDS_TWIN_2 "Hallo" ++ IDS_NOT_TRANSLATEABLE ":" ++ IDS_LONGER_TRANSLATED "Dokument $1 ist entfernt worden" ++ IDS_NO_LONGER_USED "Nicht verwendet" ++ IDS_DIFFERENT_TWIN_1 "Howdie" ++ IDS_DIFFERENT_TWIN_2 "Hallo sagt man" ++END +diff --git a/tools/grit/grit/testdata/versions.html b/tools/grit/grit/testdata/versions.html +new file mode 100644 +index 0000000000..d1f40d8d72 +--- /dev/null ++++ b/tools/grit/grit/testdata/versions.html +@@ -0,0 +1,7 @@ ++[HEADER] ++ ++[TOP_CHROME] ++[CONTENTS] ++ ++[NEXT_PREV] ++[FOOTER] +diff --git a/tools/grit/grit/testdata/whitelist.txt b/tools/grit/grit/testdata/whitelist.txt +new file mode 100644 +index 0000000000..5b3aca40b5 +--- /dev/null ++++ b/tools/grit/grit/testdata/whitelist.txt +@@ -0,0 +1,4 @@ ++IDS_MESSAGE_WHITELISTED ++IDR_STRUCTURE_WHITELISTED ++IDR_STRUCTURE_IN_TRUE_IF_WHITELISTED ++IDR_INCLUDE_WHITELISTED +diff --git a/tools/grit/grit/testdata/whitelist_resources.grd b/tools/grit/grit/testdata/whitelist_resources.grd +new file mode 100644 +index 0000000000..9925688ff5 +--- /dev/null ++++ b/tools/grit/grit/testdata/whitelist_resources.grd +@@ -0,0 +1,54 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tools/grit/grit/testdata/whitelist_strings.grd b/tools/grit/grit/testdata/whitelist_strings.grd +new file mode 100644 +index 0000000000..df80f5fd32 +--- /dev/null ++++ b/tools/grit/grit/testdata/whitelist_strings.grd +@@ -0,0 +1,23 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ Whitelisted. ++ ++ ++ Not whitelisted. ++ ++ ++ ++ +diff --git a/tools/grit/grit/tool/__init__.py b/tools/grit/grit/tool/__init__.py +new file mode 100644 +index 0000000000..cc455b36e7 +--- /dev/null ++++ b/tools/grit/grit/tool/__init__.py +@@ -0,0 +1,8 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Package grit.tool ++''' ++ ++pass +diff --git a/tools/grit/grit/tool/android2grd.py b/tools/grit/grit/tool/android2grd.py +new file mode 100644 +index 0000000000..005297bafe +--- /dev/null ++++ b/tools/grit/grit/tool/android2grd.py +@@ -0,0 +1,484 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""The 'grit android2grd' tool.""" ++ ++from __future__ import print_function ++ ++import getopt ++import os.path ++import sys ++from xml.dom import Node ++import xml.dom.minidom ++ ++import six ++from six import StringIO ++ ++import grit.node.empty ++from grit.node import node_io ++from grit.node import message ++ ++from grit.tool import interface ++ ++from grit import grd_reader ++from grit import lazy_re ++from grit import tclib ++ ++ ++# The name of a string in strings.xml ++_STRING_NAME = lazy_re.compile(r'[a-z0-9_]+\Z') ++ ++# A string's character limit in strings.xml ++_CHAR_LIMIT = lazy_re.compile(r'\[CHAR-LIMIT=(\d+)\]') ++ ++# Finds String.Format() style format specifiers such as "%-5.2f". ++_FORMAT_SPECIFIER = lazy_re.compile( ++ r'%' ++ r'([1-9][0-9]*\$|<)?' # argument_index ++ r'([-#+ 0,(]*)' # flags ++ r'([0-9]+)?' # width ++ r'(\.[0-9]+)?' # precision ++ r'([bBhHsScCdoxXeEfgGaAtT%n])') # conversion ++ ++ ++class Android2Grd(interface.Tool): ++ """Tool for converting Android string.xml files into chrome Grd files. ++ ++Usage: grit [global options] android2grd [OPTIONS] STRINGS_XML ++ ++The Android2Grd tool will convert an Android strings.xml file (whose path is ++specified by STRINGS_XML) and create a chrome style grd file containing the ++relevant information. ++ ++Because grd documents are much richer than strings.xml documents we supplement ++the information required by grds using OPTIONS with sensible defaults. ++ ++OPTIONS may be any of the following: ++ ++ --name FILENAME Specify the base FILENAME. This should be without ++ any file type suffix. By default ++ "chrome_android_strings" will be used. ++ ++ --languages LANGUAGES Comma separated list of ISO language codes (e.g. ++ en-US, en-GB, ru, zh-CN). These codes will be used ++ to determine the names of resource and translations ++ files that will be declared by the output grd file. ++ ++ --grd-dir GRD_DIR Specify where the resultant grd file ++ (FILENAME.grd) should be output. By default this ++ will be the present working directory. ++ ++ --header-dir HEADER_DIR Specify the location of the directory where grit ++ generated C++ headers (whose name will be ++ FILENAME.h) will be placed. Use an empty string to ++ disable rc generation. Default: empty. ++ ++ --rc-dir RC_DIR Specify the directory where resource files will ++ be located relative to grit build's output ++ directory. Use an empty string to disable rc ++ generation. Default: empty. ++ ++ --xml-dir XML_DIR Specify where to place localized strings.xml files ++ relative to grit build's output directory. For each ++ language xx a values-xx/strings.xml file will be ++ generated. Use an empty string to disable ++ strings.xml generation. Default: '.'. ++ ++ --xtb-dir XTB_DIR Specify where the xtb files containing translations ++ will be located relative to the grd file. Default: ++ '.'. ++""" ++ ++ _NAME_FLAG = 'name' ++ _LANGUAGES_FLAG = 'languages' ++ _GRD_DIR_FLAG = 'grd-dir' ++ _RC_DIR_FLAG = 'rc-dir' ++ _HEADER_DIR_FLAG = 'header-dir' ++ _XTB_DIR_FLAG = 'xtb-dir' ++ _XML_DIR_FLAG = 'xml-dir' ++ ++ def __init__(self): ++ self.name = 'chrome_android_strings' ++ self.languages = [] ++ self.grd_dir = '.' ++ self.rc_dir = None ++ self.xtb_dir = '.' ++ self.xml_res_dir = '.' ++ self.header_dir = None ++ ++ def ShortDescription(self): ++ """Returns a short description of the Android2Grd tool. ++ ++ Overridden from grit.interface.Tool ++ ++ Returns: ++ A string containing a short description of the android2grd tool. ++ """ ++ return 'Converts Android string.xml files into Chrome grd files.' ++ ++ def ParseOptions(self, args): ++ """Set this objects and return all non-option arguments.""" ++ flags = [ ++ Android2Grd._NAME_FLAG, ++ Android2Grd._LANGUAGES_FLAG, ++ Android2Grd._GRD_DIR_FLAG, ++ Android2Grd._RC_DIR_FLAG, ++ Android2Grd._HEADER_DIR_FLAG, ++ Android2Grd._XTB_DIR_FLAG, ++ Android2Grd._XML_DIR_FLAG, ] ++ (opts, args) = getopt.getopt( ++ args, None, ['%s=' % o for o in flags] + ['help']) ++ ++ for key, val in opts: ++ # Get rid of the preceding hypens. ++ k = key[2:] ++ if k == Android2Grd._NAME_FLAG: ++ self.name = val ++ elif k == Android2Grd._LANGUAGES_FLAG: ++ self.languages = val.split(',') ++ elif k == Android2Grd._GRD_DIR_FLAG: ++ self.grd_dir = val ++ elif k == Android2Grd._RC_DIR_FLAG: ++ self.rc_dir = val ++ elif k == Android2Grd._HEADER_DIR_FLAG: ++ self.header_dir = val ++ elif k == Android2Grd._XTB_DIR_FLAG: ++ self.xtb_dir = val ++ elif k == Android2Grd._XML_DIR_FLAG: ++ self.xml_res_dir = val ++ elif k == 'help': ++ self.ShowUsage() ++ sys.exit(0) ++ return args ++ ++ def Run(self, opts, args): ++ """Runs the Android2Grd tool. ++ ++ Inherited from grit.interface.Tool. ++ ++ Args: ++ opts: List of string arguments that should be parsed. ++ args: String containing the path of the strings.xml file to be converted. ++ """ ++ args = self.ParseOptions(args) ++ if len(args) != 1: ++ print('Tool requires one argument, the path to the Android ' ++ 'strings.xml resource file to be converted.') ++ return 2 ++ self.SetOptions(opts) ++ ++ android_path = args[0] ++ ++ # Read and parse the Android strings.xml file. ++ with open(android_path) as android_file: ++ android_dom = xml.dom.minidom.parse(android_file) ++ ++ # Do the hard work -- convert the Android dom to grd file contents. ++ grd_dom = self.AndroidDomToGrdDom(android_dom) ++ grd_string = six.text_type(grd_dom) ++ ++ # Write the grd string to a file in grd_dir. ++ grd_filename = self.name + '.grd' ++ grd_path = os.path.join(self.grd_dir, grd_filename) ++ with open(grd_path, 'w') as grd_file: ++ grd_file.write(grd_string) ++ ++ def AndroidDomToGrdDom(self, android_dom): ++ """Converts a strings.xml DOM into a DOM representing the contents of ++ a grd file. ++ ++ Args: ++ android_dom: A xml.dom.Document containing the contents of the Android ++ string.xml document. ++ Returns: ++ The DOM for the grd xml document produced by converting the Android DOM. ++ """ ++ ++ # Start with a basic skeleton for the .grd file. ++ root = grd_reader.Parse(StringIO( ++ ''' ++ ++ ++ ++ ++ ++ ++ '''), dir='.') ++ outputs = root.children[0] ++ translations = root.children[1] ++ messages = root.children[2].children[0] ++ assert (isinstance(messages, grit.node.empty.MessagesNode) and ++ isinstance(translations, grit.node.empty.TranslationsNode) and ++ isinstance(outputs, grit.node.empty.OutputsNode)) ++ ++ if self.header_dir: ++ cpp_header = self.__CreateCppHeaderOutputNode(outputs, self.header_dir) ++ for lang in self.languages: ++ # Create an output element for each language. ++ if self.rc_dir: ++ self.__CreateRcOutputNode(outputs, lang, self.rc_dir) ++ if self.xml_res_dir: ++ self.__CreateAndroidXmlOutputNode(outputs, lang, self.xml_res_dir) ++ if lang != 'en': ++ self.__CreateFileNode(translations, lang) ++ # Convert all the strings.xml strings into grd messages. ++ self.__CreateMessageNodes(messages, android_dom.documentElement) ++ ++ return root ++ ++ def __CreateMessageNodes(self, messages, resources): ++ """Creates the elements and adds them as children of . ++ ++ Args: ++ messages: the element in the strings.xml dom. ++ resources: the element in the grd dom. ++ """ ++ # elements contain the definition of the resource. ++ # The description of a element is contained within the comment ++ # node element immediately preceeding the string element in question. ++ description = '' ++ for child in resources.childNodes: ++ if child.nodeType == Node.COMMENT_NODE: ++ # Remove leading/trailing whitespace; collapse consecutive whitespaces. ++ description = ' '.join(child.data.split()) ++ elif child.nodeType == Node.ELEMENT_NODE: ++ if child.tagName != 'string': ++ print('Warning: ignoring unknown tag <%s>' % child.tagName) ++ else: ++ translatable = self.IsTranslatable(child) ++ raw_name = child.getAttribute('name') ++ if not _STRING_NAME.match(raw_name): ++ print('Error: illegal string name: %s' % raw_name) ++ grd_name = 'IDS_' + raw_name.upper() ++ # Transform the node contents into a tclib.Message, taking ++ # care to handle whitespace transformations and escaped characters, ++ # and coverting placeholders into placeholders. ++ msg = self.CreateTclibMessage(child) ++ msg_node = self.__CreateMessageNode(messages, grd_name, description, ++ msg, translatable) ++ messages.AddChild(msg_node) ++ # Reset the description once a message has been parsed. ++ description = '' ++ ++ def CreateTclibMessage(self, android_string): ++ """Transforms a element from strings.xml into a tclib.Message. ++ ++ Interprets whitespace, quotes, and escaped characters in the android_string ++ according to Android's formatting and styling rules for strings. Also ++ converts placeholders into placeholders, e.g.: ++ ++ %s ++ becomes ++ google.com%s ++ ++ Returns: ++ The tclib.Message. ++ """ ++ msg = tclib.Message() ++ current_text = '' # Accumulated text that hasn't yet been added to msg. ++ nodes = android_string.childNodes ++ ++ for i, node in enumerate(nodes): ++ # Handle text nodes. ++ if node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): ++ current_text += node.data ++ ++ # Handle and other tags. ++ elif node.nodeType == Node.ELEMENT_NODE: ++ if node.tagName == 'xliff:g': ++ assert node.hasAttribute('id'), 'missing id: ' + node.data() ++ placeholder_id = node.getAttribute('id') ++ placeholder_text = self.__FormatPlaceholderText(node) ++ placeholder_example = node.getAttribute('example') ++ if not placeholder_example: ++ print('Info: placeholder does not contain an example: %s' % ++ node.toxml()) ++ placeholder_example = placeholder_id.upper() ++ msg.AppendPlaceholder(tclib.Placeholder(placeholder_id, ++ placeholder_text, placeholder_example)) ++ else: ++ print('Warning: removing tag <%s> which must be inside a ' ++ 'placeholder: %s' % (node.tagName, node.toxml())) ++ msg.AppendText(self.__FormatPlaceholderText(node)) ++ ++ # Handle other nodes. ++ elif node.nodeType != Node.COMMENT_NODE: ++ assert False, 'Unknown node type: %s' % node.nodeType ++ ++ is_last_node = (i == len(nodes) - 1) ++ if (current_text and ++ (is_last_node or nodes[i + 1].nodeType == Node.ELEMENT_NODE)): ++ # For messages containing just text and comments (no xml tags) Android ++ # strips leading and trailing whitespace. We mimic that behavior. ++ if not msg.GetContent() and is_last_node: ++ current_text = current_text.strip() ++ msg.AppendText(self.__FormatAndroidString(current_text)) ++ current_text = '' ++ ++ return msg ++ ++ def __FormatAndroidString(self, android_string, inside_placeholder=False): ++ r"""Returns android_string formatted for a .grd file. ++ ++ * Collapses consecutive whitespaces, except when inside double-quotes. ++ * Replaces \\, \n, \t, \", \' with \, newline, tab, ", '. ++ """ ++ backslash_map = {'\\' : '\\', 'n' : '\n', 't' : '\t', '"' : '"', "'" : "'"} ++ is_quoted_section = False # True when we're inside double quotes. ++ is_backslash_sequence = False # True after seeing an unescaped backslash. ++ prev_char = '' ++ output = [] ++ for c in android_string: ++ if is_backslash_sequence: ++ # Unescape \\, \n, \t, \", and \'. ++ assert c in backslash_map, 'Illegal escape sequence: \\%s' % c ++ output.append(backslash_map[c]) ++ is_backslash_sequence = False ++ elif c == '\\': ++ is_backslash_sequence = True ++ elif c.isspace() and not is_quoted_section: ++ # Turn whitespace into ' ' and collapse consecutive whitespaces. ++ if not prev_char.isspace(): ++ output.append(' ') ++ elif c == '"': ++ is_quoted_section = not is_quoted_section ++ else: ++ output.append(c) ++ prev_char = c ++ output = ''.join(output) ++ ++ if is_quoted_section: ++ print('Warning: unbalanced quotes in string: %s' % android_string) ++ ++ if is_backslash_sequence: ++ print('Warning: trailing backslash in string: %s' % android_string) ++ ++ # Check for format specifiers outside of placeholder tags. ++ if not inside_placeholder: ++ format_specifier = _FORMAT_SPECIFIER.search(output) ++ if format_specifier: ++ print('Warning: format specifiers are not inside a placeholder ' ++ ' tag: %s' % output) ++ ++ return output ++ ++ def __FormatPlaceholderText(self, placeholder_node): ++ """Returns the text inside of an placeholder node.""" ++ text = [] ++ for childNode in placeholder_node.childNodes: ++ if childNode.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): ++ text.append(childNode.data) ++ elif childNode.nodeType != Node.COMMENT_NODE: ++ assert False, 'Unknown node type in ' + placeholder_node.toxml() ++ return self.__FormatAndroidString(''.join(text), inside_placeholder=True) ++ ++ def __CreateMessageNode(self, messages_node, grd_name, description, msg, ++ translatable): ++ """Creates and initializes a element. ++ ++ Message elements correspond to Android elements in that they ++ declare a string resource along with a programmatic id. ++ """ ++ if not description: ++ print('Warning: no description for %s' % grd_name) ++ # Check that we actually fit within the character limit we've specified. ++ match = _CHAR_LIMIT.search(description) ++ if match: ++ char_limit = int(match.group(1)) ++ msg_content = msg.GetRealContent() ++ if len(msg_content) > char_limit: ++ print('Warning: char-limit for %s is %d, but length is %d: %s' % ++ (grd_name, char_limit, len(msg_content), msg_content)) ++ return message.MessageNode.Construct(parent=messages_node, ++ name=grd_name, ++ message=msg, ++ desc=description, ++ translateable=translatable) ++ ++ def __CreateFileNode(self, translations_node, lang): ++ """Creates and initializes the elements. ++ ++ File elements provide information on the location of translation files ++ (xtbs) ++ """ ++ xtb_file = os.path.normpath(os.path.join( ++ self.xtb_dir, '%s_%s.xtb' % (self.name, lang))) ++ fnode = node_io.FileNode() ++ fnode.StartParsing(u'file', translations_node) ++ fnode.HandleAttribute('path', xtb_file) ++ fnode.HandleAttribute('lang', lang) ++ fnode.EndParsing() ++ translations_node.AddChild(fnode) ++ return fnode ++ ++ def __CreateCppHeaderOutputNode(self, outputs_node, header_dir): ++ """Creates the element corresponding to the generated c header.""" ++ header_file_name = os.path.join(header_dir, self.name + '.h') ++ header_node = node_io.OutputNode() ++ header_node.StartParsing(u'output', outputs_node) ++ header_node.HandleAttribute('filename', header_file_name) ++ header_node.HandleAttribute('type', 'rc_header') ++ emit_node = node_io.EmitNode() ++ emit_node.StartParsing(u'emit', header_node) ++ emit_node.HandleAttribute('emit_type', 'prepend') ++ emit_node.EndParsing() ++ header_node.AddChild(emit_node) ++ header_node.EndParsing() ++ outputs_node.AddChild(header_node) ++ return header_node ++ ++ def __CreateRcOutputNode(self, outputs_node, lang, rc_dir): ++ """Creates the element corresponding to various rc file output.""" ++ rc_file_name = self.name + '_' + lang + ".rc" ++ rc_path = os.path.join(rc_dir, rc_file_name) ++ node = node_io.OutputNode() ++ node.StartParsing(u'output', outputs_node) ++ node.HandleAttribute('filename', rc_path) ++ node.HandleAttribute('lang', lang) ++ node.HandleAttribute('type', 'rc_all') ++ node.EndParsing() ++ outputs_node.AddChild(node) ++ return node ++ ++ def __CreateAndroidXmlOutputNode(self, outputs_node, locale, xml_res_dir): ++ """Creates the element corresponding to various rc file output.""" ++ # Need to check to see if the locale has a region, e.g. the GB in en-GB. ++ # When a locale has a region Android expects the region to be prefixed ++ # with an 'r'. For example for en-GB Android expects a values-en-rGB ++ # directory. Also, Android expects nb, tl, in, iw, ji as the language ++ # codes for Norwegian, Tagalog/Filipino, Indonesian, Hebrew, and Yiddish: ++ # http://developer.android.com/reference/java/util/Locale.html ++ if locale == 'es-419': ++ android_locale = 'es-rUS' ++ else: ++ android_lang, dash, region = locale.partition('-') ++ lang_map = {'no': 'nb', 'fil': 'tl', 'id': 'in', 'he': 'iw', 'yi': 'ji'} ++ android_lang = lang_map.get(android_lang, android_lang) ++ android_locale = android_lang + ('-r' + region if region else '') ++ values = 'values-' + android_locale if android_locale != 'en' else 'values' ++ xml_path = os.path.normpath(os.path.join( ++ xml_res_dir, values, 'strings.xml')) ++ ++ node = node_io.OutputNode() ++ node.StartParsing(u'output', outputs_node) ++ node.HandleAttribute('filename', xml_path) ++ node.HandleAttribute('lang', locale) ++ node.HandleAttribute('type', 'android') ++ node.EndParsing() ++ outputs_node.AddChild(node) ++ return node ++ ++ def IsTranslatable(self, android_string): ++ """Determines if a element is a candidate for translation. ++ ++ A element is by default translatable unless otherwise marked. ++ """ ++ if android_string.hasAttribute('translatable'): ++ value = android_string.getAttribute('translatable').lower() ++ if value not in ('true', 'false'): ++ print('Warning: translatable attribute has invalid value: %s' % value) ++ return value == 'true' ++ else: ++ return True +diff --git a/tools/grit/grit/tool/android2grd_unittest.py b/tools/grit/grit/tool/android2grd_unittest.py +new file mode 100644 +index 0000000000..a6934a707c +--- /dev/null ++++ b/tools/grit/grit/tool/android2grd_unittest.py +@@ -0,0 +1,181 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.tool.android2grd''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++import xml.dom.minidom ++ ++from grit import util ++from grit.node import empty ++from grit.node import message ++from grit.node import misc ++from grit.node import node_io ++from grit.tool import android2grd ++ ++ ++class Android2GrdUnittest(unittest.TestCase): ++ ++ def __Parse(self, xml_string): ++ return xml.dom.minidom.parseString(xml_string).childNodes[0] ++ ++ def testCreateTclibMessage(self): ++ tool = android2grd.Android2Grd() ++ msg = tool.CreateTclibMessage(self.__Parse(r''' ++ A simple string''')) ++ self.assertEqual(msg.GetRealContent(), 'A simple string') ++ msg = tool.CreateTclibMessage(self.__Parse(r''' ++ ++ Strip leading/trailing whitespace ++ ''')) ++ self.assertEqual(msg.GetRealContent(), 'Strip leading/trailing whitespace') ++ msg = tool.CreateTclibMessage(self.__Parse(r''' ++ Fold multiple spaces''')) ++ self.assertEqual(msg.GetRealContent(), 'Fold multiple spaces') ++ msg = tool.CreateTclibMessage(self.__Parse(r''' ++ Retain \n escaped\t spaces''')) ++ self.assertEqual(msg.GetRealContent(), 'Retain \n escaped\t spaces') ++ msg = tool.CreateTclibMessage(self.__Parse(r''' ++ " Quotes preserve ++ whitespace" but only for "enclosed elements " ++ ''')) ++ self.assertEqual(msg.GetRealContent(), ''' Quotes preserve ++ whitespace but only for enclosed elements ''') ++ msg = tool.CreateTclibMessage(self.__Parse( ++ r'''Escaped characters: \"\'\\\t\n''' ++ '')) ++ self.assertEqual(msg.GetRealContent(), '''Escaped characters: "'\\\t\n''') ++ msg = tool.CreateTclibMessage(self.__Parse( ++ '' ++ 'Open %s?' ++ '')) ++ self.assertEqual(msg.GetRealContent(), 'Open %s?') ++ self.assertEqual(len(msg.GetPlaceholders()), 1) ++ self.assertEqual(msg.GetPlaceholders()[0].presentation, 'FILENAME') ++ self.assertEqual(msg.GetPlaceholders()[0].original, '%s') ++ self.assertEqual(msg.GetPlaceholders()[0].example, 'internet.html') ++ msg = tool.CreateTclibMessage(self.__Parse(r''' ++ Contains a comment ++ ''')) ++ self.assertEqual(msg.GetRealContent(), 'Contains a comment') ++ ++ def testIsTranslatable(self): ++ tool = android2grd.Android2Grd() ++ string_el = self.__Parse('Hi') ++ self.assertTrue(tool.IsTranslatable(string_el)) ++ string_el = self.__Parse( ++ 'Hi') ++ self.assertTrue(tool.IsTranslatable(string_el)) ++ string_el = self.__Parse( ++ 'Hi') ++ self.assertFalse(tool.IsTranslatable(string_el)) ++ ++ def __ParseAndroidXml(self, options = []): ++ tool = android2grd.Android2Grd() ++ ++ tool.ParseOptions(options) ++ ++ android_path = util.PathFromRoot('grit/testdata/android.xml') ++ with open(android_path) as android_file: ++ android_dom = xml.dom.minidom.parse(android_file) ++ ++ grd = tool.AndroidDomToGrdDom(android_dom) ++ self.assertTrue(isinstance(grd, misc.GritNode)) ++ ++ return grd ++ ++ def testAndroidDomToGrdDom(self): ++ grd = self.__ParseAndroidXml(['--languages', 'en-US,en-GB,ru']) ++ ++ # Check that the structure of the GritNode is as expected. ++ messages = grd.GetChildrenOfType(message.MessageNode) ++ translations = grd.GetChildrenOfType(empty.TranslationsNode) ++ files = grd.GetChildrenOfType(node_io.FileNode) ++ ++ self.assertEqual(len(translations), 1) ++ self.assertEqual(len(files), 3) ++ self.assertEqual(len(messages), 5) ++ ++ # Check that a message node is constructed correctly. ++ msg = [x for x in messages if x.GetTextualIds()[0] == 'IDS_PLACEHOLDERS'] ++ self.assertTrue(msg) ++ msg = msg[0] ++ ++ self.assertTrue(msg.IsTranslateable()) ++ self.assertEqual(msg.attrs["desc"], "A string with placeholder.") ++ ++ def testTranslatableAttribute(self): ++ grd = self.__ParseAndroidXml([]) ++ messages = grd.GetChildrenOfType(message.MessageNode) ++ msgs = [x for x in messages if x.GetTextualIds()[0] == 'IDS_CONSTANT'] ++ self.assertTrue(msgs) ++ self.assertFalse(msgs[0].IsTranslateable()) ++ ++ def testTranslations(self): ++ grd = self.__ParseAndroidXml(['--languages', 'en-US,en-GB,ru,id']) ++ ++ files = grd.GetChildrenOfType(node_io.FileNode) ++ us_file = [x for x in files if x.attrs['lang'] == 'en-US'] ++ self.assertTrue(us_file) ++ self.assertEqual(us_file[0].GetInputPath(), ++ 'chrome_android_strings_en-US.xtb') ++ ++ id_file = [x for x in files if x.attrs['lang'] == 'id'] ++ self.assertTrue(id_file) ++ self.assertEqual(id_file[0].GetInputPath(), ++ 'chrome_android_strings_id.xtb') ++ ++ def testOutputs(self): ++ grd = self.__ParseAndroidXml(['--languages', 'en-US,ru,id', ++ '--rc-dir', 'rc/dir', ++ '--header-dir', 'header/dir', ++ '--xtb-dir', 'xtb/dir', ++ '--xml-dir', 'xml/dir']) ++ ++ outputs = grd.GetChildrenOfType(node_io.OutputNode) ++ self.assertEqual(len(outputs), 7) ++ ++ header_outputs = [x for x in outputs if x.GetType() == 'rc_header'] ++ rc_outputs = [x for x in outputs if x.GetType() == 'rc_all'] ++ xml_outputs = [x for x in outputs if x.GetType() == 'android'] ++ ++ self.assertEqual(len(header_outputs), 1) ++ self.assertEqual(len(rc_outputs), 3) ++ self.assertEqual(len(xml_outputs), 3) ++ ++ # The header node should have an "" child and the proper filename. ++ self.assertTrue(header_outputs[0].GetChildrenOfType(node_io.EmitNode)) ++ self.assertEqual(util.normpath(header_outputs[0].GetFilename()), ++ util.normpath('header/dir/chrome_android_strings.h')) ++ ++ id_rc = [x for x in rc_outputs if x.GetLanguage() == 'id'] ++ id_xml = [x for x in xml_outputs if x.GetLanguage() == 'id'] ++ self.assertTrue(id_rc) ++ self.assertTrue(id_xml) ++ self.assertEqual(util.normpath(id_rc[0].GetFilename()), ++ util.normpath('rc/dir/chrome_android_strings_id.rc')) ++ self.assertEqual(util.normpath(id_xml[0].GetFilename()), ++ util.normpath('xml/dir/values-in/strings.xml')) ++ ++ us_rc = [x for x in rc_outputs if x.GetLanguage() == 'en-US'] ++ us_xml = [x for x in xml_outputs if x.GetLanguage() == 'en-US'] ++ self.assertTrue(us_rc) ++ self.assertTrue(us_xml) ++ self.assertEqual(util.normpath(us_rc[0].GetFilename()), ++ util.normpath('rc/dir/chrome_android_strings_en-US.rc')) ++ self.assertEqual(util.normpath(us_xml[0].GetFilename()), ++ util.normpath('xml/dir/values-en-rUS/strings.xml')) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/tool/build.py b/tools/grit/grit/tool/build.py +new file mode 100644 +index 0000000000..204592bf0d +--- /dev/null ++++ b/tools/grit/grit/tool/build.py +@@ -0,0 +1,556 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''The 'grit build' tool. ++''' ++ ++from __future__ import print_function ++ ++import codecs ++import filecmp ++import getopt ++import gzip ++import os ++import shutil ++import sys ++ ++import six ++ ++from grit import grd_reader ++from grit import shortcuts ++from grit import util ++from grit.format import minifier ++from grit.node import brotli_util ++from grit.node import include ++from grit.node import message ++from grit.node import structure ++from grit.tool import interface ++ ++ ++# It would be cleaner to have each module register itself, but that would ++# require importing all of them on every run of GRIT. ++'''Map from node types to modules under grit.format.''' ++_format_modules = { ++ 'android': 'android_xml', ++ 'c_format': 'c_format', ++ 'chrome_messages_json': 'chrome_messages_json', ++ 'chrome_messages_json_gzip': 'chrome_messages_json', ++ 'data_package': 'data_pack', ++ 'policy_templates': 'policy_templates_json', ++ 'rc_all': 'rc', ++ 'rc_header': 'rc_header', ++ 'rc_nontranslateable': 'rc', ++ 'rc_translateable': 'rc', ++ 'resource_file_map_source': 'resource_map', ++ 'resource_map_header': 'resource_map', ++ 'resource_map_source': 'resource_map', ++} ++ ++def GetFormatter(type): ++ modulename = 'grit.format.' + _format_modules[type] ++ __import__(modulename) ++ module = sys.modules[modulename] ++ try: ++ return module.Format ++ except AttributeError: ++ return module.GetFormatter(type) ++ ++ ++class RcBuilder(interface.Tool): ++ '''A tool that builds RC files and resource header files for compilation. ++ ++Usage: grit build [-o OUTPUTDIR] [-D NAME[=VAL]]* ++ ++All output options for this tool are specified in the input file (see ++'grit help' for details on how to specify the input file - it is a global ++option). ++ ++Options: ++ ++ -a FILE Assert that the given file is an output. There can be ++ multiple "-a" flags listed for multiple outputs. If a "-a" ++ or "--assert-file-list" argument is present, then the list ++ of asserted files must match the output files or the tool ++ will fail. The use-case is for the build system to maintain ++ separate lists of output files and to catch errors if the ++ build system's list and the grit list are out-of-sync. ++ ++ --assert-file-list Provide a file listing multiple asserted output files. ++ There is one file name per line. This acts like specifying ++ each file with "-a" on the command line, but without the ++ possibility of running into OS line-length limits for very ++ long lists. ++ ++ -o OUTPUTDIR Specify what directory output paths are relative to. ++ Defaults to the current directory. ++ ++ -p FILE Specify a file containing a pre-determined mapping from ++ resource names to resource ids which will be used to assign ++ resource ids to those resources. Resources not found in this ++ file will be assigned ids normally. The motivation is to run ++ your app's startup and have it dump the resources it loads, ++ and then pass these via this flag. This will pack startup ++ resources together, thus reducing paging while all other ++ resources are unperturbed. The file should have the format: ++ RESOURCE_ONE_NAME 123 ++ RESOURCE_TWO_NAME 124 ++ ++ -D NAME[=VAL] Specify a C-preprocessor-like define NAME with optional ++ value VAL (defaults to 1) which will be used to control ++ conditional inclusion of resources. ++ ++ -E NAME=VALUE Set environment variable NAME to VALUE (within grit). ++ ++ -f FIRSTIDSFILE Path to a python file that specifies the first id of ++ value to use for resources. A non-empty value here will ++ override the value specified in the node's ++ first_ids_file. ++ ++ -w WHITELISTFILE Path to a file containing the string names of the ++ resources to include. Anything not listed is dropped. ++ ++ -t PLATFORM Specifies the platform the build is targeting; defaults ++ to the value of sys.platform. The value provided via this ++ flag should match what sys.platform would report for your ++ target platform; see grit.node.base.EvaluateCondition. ++ ++ --whitelist-support ++ Generate code to support extracting a resource whitelist ++ from executables. ++ ++ --write-only-new flag ++ If flag is non-0, write output files to a temporary file ++ first, and copy it to the real output only if the new file ++ is different from the old file. This allows some build ++ systems to realize that dependent build steps might be ++ unnecessary, at the cost of comparing the output data at ++ grit time. ++ ++ --depend-on-stamp ++ If specified along with --depfile and --depdir, the depfile ++ generated will depend on a stampfile instead of the first ++ output in the input .grd file. ++ ++ --js-minifier A command to run the Javascript minifier. If not set then ++ Javascript won't be minified. The command should read the ++ original Javascript from standard input, and output the ++ minified Javascript to standard output. A non-zero exit ++ status will be taken as indicating failure. ++ ++ --css-minifier A command to run the CSS minifier. If not set then CSS won't ++ be minified. The command should read the original CSS from ++ standard input, and output the minified CSS to standard ++ output. A non-zero exit status will be taken as indicating ++ failure. ++ ++ --brotli The full path to the brotli executable generated by ++ third_party/brotli/BUILD.gn, required if any entries use ++ compress="brotli". ++ ++Conditional inclusion of resources only affects the output of files which ++control which resources get linked into a binary, e.g. it affects .rc files ++meant for compilation but it does not affect resource header files (that define ++IDs). This helps ensure that values of IDs stay the same, that all messages ++are exported to translation interchange files (e.g. XMB files), etc. ++''' ++ ++ def ShortDescription(self): ++ return 'A tool that builds RC files for compilation.' ++ ++ def Run(self, opts, args): ++ brotli_util.SetBrotliCommand(None) ++ os.environ['cwd'] = os.getcwd() ++ self.output_directory = '.' ++ first_ids_file = None ++ predetermined_ids_file = None ++ whitelist_filenames = [] ++ assert_output_files = [] ++ target_platform = None ++ depfile = None ++ depdir = None ++ whitelist_support = False ++ write_only_new = False ++ depend_on_stamp = False ++ js_minifier = None ++ css_minifier = None ++ replace_ellipsis = True ++ (own_opts, args) = getopt.getopt( ++ args, 'a:p:o:D:E:f:w:t:', ++ ('depdir=', 'depfile=', 'assert-file-list=', 'help', ++ 'output-all-resource-defines', 'no-output-all-resource-defines', ++ 'no-replace-ellipsis', 'depend-on-stamp', 'js-minifier=', ++ 'css-minifier=', 'write-only-new=', 'whitelist-support', 'brotli=')) ++ for (key, val) in own_opts: ++ if key == '-a': ++ assert_output_files.append(val) ++ elif key == '--assert-file-list': ++ with open(val) as f: ++ assert_output_files += f.read().splitlines() ++ elif key == '-o': ++ self.output_directory = val ++ elif key == '-D': ++ name, val = util.ParseDefine(val) ++ self.defines[name] = val ++ elif key == '-E': ++ (env_name, env_value) = val.split('=', 1) ++ os.environ[env_name] = env_value ++ elif key == '-f': ++ # TODO(joi@chromium.org): Remove this override once change ++ # lands in WebKit.grd to specify the first_ids_file in the ++ # .grd itself. ++ first_ids_file = val ++ elif key == '-w': ++ whitelist_filenames.append(val) ++ elif key == '--no-replace-ellipsis': ++ replace_ellipsis = False ++ elif key == '-p': ++ predetermined_ids_file = val ++ elif key == '-t': ++ target_platform = val ++ elif key == '--depdir': ++ depdir = val ++ elif key == '--depfile': ++ depfile = val ++ elif key == '--write-only-new': ++ write_only_new = val != '0' ++ elif key == '--depend-on-stamp': ++ depend_on_stamp = True ++ elif key == '--js-minifier': ++ js_minifier = val ++ elif key == '--css-minifier': ++ css_minifier = val ++ elif key == '--whitelist-support': ++ whitelist_support = True ++ elif key == '--brotli': ++ brotli_util.SetBrotliCommand([os.path.abspath(val)]) ++ elif key == '--help': ++ self.ShowUsage() ++ sys.exit(0) ++ ++ if len(args): ++ print('This tool takes no tool-specific arguments.') ++ return 2 ++ self.SetOptions(opts) ++ self.VerboseOut('Output directory: %s (absolute path: %s)\n' % ++ (self.output_directory, ++ os.path.abspath(self.output_directory))) ++ ++ if whitelist_filenames: ++ self.whitelist_names = set() ++ for whitelist_filename in whitelist_filenames: ++ self.VerboseOut('Using whitelist: %s\n' % whitelist_filename); ++ whitelist_contents = util.ReadFile(whitelist_filename, 'utf-8') ++ self.whitelist_names.update(whitelist_contents.strip().split('\n')) ++ ++ if js_minifier: ++ minifier.SetJsMinifier(js_minifier) ++ ++ if css_minifier: ++ minifier.SetCssMinifier(css_minifier) ++ ++ self.write_only_new = write_only_new ++ ++ self.res = grd_reader.Parse(opts.input, ++ debug=opts.extra_verbose, ++ first_ids_file=first_ids_file, ++ predetermined_ids_file=predetermined_ids_file, ++ defines=self.defines, ++ target_platform=target_platform) ++ ++ # Set an output context so that conditionals can use defines during the ++ # gathering stage; we use a dummy language here since we are not outputting ++ # a specific language. ++ self.res.SetOutputLanguage('en') ++ self.res.SetWhitelistSupportEnabled(whitelist_support) ++ self.res.RunGatherers() ++ ++ # Replace ... with the single-character version. http://crbug.com/621772 ++ if replace_ellipsis: ++ for node in self.res: ++ if isinstance(node, message.MessageNode): ++ node.SetReplaceEllipsis(True) ++ ++ self.Process() ++ ++ if assert_output_files: ++ if not self.CheckAssertedOutputFiles(assert_output_files): ++ return 2 ++ ++ if depfile and depdir: ++ self.GenerateDepfile(depfile, depdir, first_ids_file, depend_on_stamp) ++ ++ return 0 ++ ++ def __init__(self, defines=None): ++ # Default file-creation function is codecs.open(). Only done to allow ++ # overriding by unit test. ++ self.fo_create = codecs.open ++ ++ # key/value pairs of C-preprocessor like defines that are used for ++ # conditional output of resources ++ self.defines = defines or {} ++ ++ # self.res is a fully-populated resource tree if Run() ++ # has been called, otherwise None. ++ self.res = None ++ ++ # The set of names that are whitelisted to actually be included in the ++ # output. ++ self.whitelist_names = None ++ ++ # Whether to compare outputs to their old contents before writing. ++ self.write_only_new = False ++ ++ @staticmethod ++ def AddWhitelistTags(start_node, whitelist_names): ++ # Walk the tree of nodes added attributes for the nodes that shouldn't ++ # be written into the target files (skip markers). ++ for node in start_node: ++ # Same trick data_pack.py uses to see what nodes actually result in ++ # real items. ++ if (isinstance(node, include.IncludeNode) or ++ isinstance(node, message.MessageNode) or ++ isinstance(node, structure.StructureNode)): ++ text_ids = node.GetTextualIds() ++ # Mark the item to be skipped if it wasn't in the whitelist. ++ if text_ids and text_ids[0] not in whitelist_names: ++ node.SetWhitelistMarkedAsSkip(True) ++ ++ @staticmethod ++ def ProcessNode(node, output_node, outfile): ++ '''Processes a node in-order, calling its formatter before and after ++ recursing to its children. ++ ++ Args: ++ node: grit.node.base.Node subclass ++ output_node: grit.node.io.OutputNode ++ outfile: open filehandle ++ ''' ++ base_dir = util.dirname(output_node.GetOutputFilename()) ++ ++ formatter = GetFormatter(output_node.GetType()) ++ formatted = formatter(node, output_node.GetLanguage(), output_dir=base_dir) ++ # NB: Formatters may be generators or return lists. The writelines API ++ # accepts iterables as a shortcut to calling write directly. That means ++ # you can pass strings (iteration yields characters), but not bytes (as ++ # iteration yields integers). Python 2 worked due to its quirks with ++ # bytes/string implementation, but Python 3 fails. It's also a bit more ++ # inefficient to call write once per character/byte. Handle all of this ++ # ourselves by calling write directly on strings/bytes before falling back ++ # to writelines. ++ if isinstance(formatted, (six.string_types, six.binary_type)): ++ outfile.write(formatted) ++ else: ++ outfile.writelines(formatted) ++ if output_node.GetType() == 'data_package': ++ with open(output_node.GetOutputFilename() + '.info', 'w') as infofile: ++ if node.info: ++ # We terminate with a newline so that when these files are ++ # concatenated later we consistently terminate with a newline so ++ # consumers can account for terminating newlines. ++ infofile.writelines(['\n'.join(node.info), '\n']) ++ ++ @staticmethod ++ def _EncodingForOutputType(output_type): ++ # Microsoft's RC compiler can only deal with single-byte or double-byte ++ # files (no UTF-8), so we make all RC files UTF-16 to support all ++ # character sets. ++ if output_type in ('rc_header', 'resource_file_map_source', ++ 'resource_map_header', 'resource_map_source'): ++ return 'cp1252' ++ if output_type in ('android', 'c_format', 'plist', 'plist_strings', 'doc', ++ 'json', 'android_policy', 'chrome_messages_json', ++ 'chrome_messages_json_gzip', 'policy_templates'): ++ return 'utf_8' ++ # TODO(gfeher) modify here to set utf-8 encoding for admx/adml ++ return 'utf_16' ++ ++ def Process(self): ++ for output in self.res.GetOutputFiles(): ++ output.output_filename = os.path.abspath(os.path.join( ++ self.output_directory, output.GetOutputFilename())) ++ ++ # If there are whitelisted names, tag the tree once up front, this way ++ # while looping through the actual output, it is just an attribute check. ++ if self.whitelist_names: ++ self.AddWhitelistTags(self.res, self.whitelist_names) ++ ++ for output in self.res.GetOutputFiles(): ++ self.VerboseOut('Creating %s...' % output.GetOutputFilename()) ++ ++ # Set the context, for conditional inclusion of resources ++ self.res.SetOutputLanguage(output.GetLanguage()) ++ self.res.SetOutputContext(output.GetContext()) ++ self.res.SetFallbackToDefaultLayout(output.GetFallbackToDefaultLayout()) ++ self.res.SetDefines(self.defines) ++ ++ # Assign IDs only once to ensure that all outputs use the same IDs. ++ if self.res.GetIdMap() is None: ++ self.res.InitializeIds() ++ ++ # Make the output directory if it doesn't exist. ++ self.MakeDirectoriesTo(output.GetOutputFilename()) ++ ++ # Write the results to a temporary file and only overwrite the original ++ # if the file changed. This avoids unnecessary rebuilds. ++ out_filename = output.GetOutputFilename() ++ tmp_filename = out_filename + '.tmp' ++ tmpfile = self.fo_create(tmp_filename, 'wb') ++ ++ output_type = output.GetType() ++ if output_type != 'data_package': ++ encoding = self._EncodingForOutputType(output_type) ++ tmpfile = util.WrapOutputStream(tmpfile, encoding) ++ ++ # Iterate in-order through entire resource tree, calling formatters on ++ # the entry into a node and on exit out of it. ++ with tmpfile: ++ self.ProcessNode(self.res, output, tmpfile) ++ ++ if output_type == 'chrome_messages_json_gzip': ++ gz_filename = tmp_filename + '.gz' ++ with open(tmp_filename, 'rb') as tmpfile, open(gz_filename, 'wb') as f: ++ with gzip.GzipFile(filename='', mode='wb', fileobj=f, mtime=0) as fgz: ++ shutil.copyfileobj(tmpfile, fgz) ++ os.remove(tmp_filename) ++ tmp_filename = gz_filename ++ ++ # Now copy from the temp file back to the real output, but on Windows, ++ # only if the real output doesn't exist or the contents of the file ++ # changed. This prevents identical headers from being written and .cc ++ # files from recompiling (which is painful on Windows). ++ if not os.path.exists(out_filename): ++ os.rename(tmp_filename, out_filename) ++ else: ++ # CHROMIUM SPECIFIC CHANGE. ++ # This clashes with gyp + vstudio, which expect the output timestamp ++ # to change on a rebuild, even if nothing has changed, so only do ++ # it when opted in. ++ if not self.write_only_new: ++ write_file = True ++ else: ++ files_match = filecmp.cmp(out_filename, tmp_filename) ++ write_file = not files_match ++ if write_file: ++ shutil.copy2(tmp_filename, out_filename) ++ os.remove(tmp_filename) ++ ++ self.VerboseOut(' done.\n') ++ ++ # Print warnings if there are any duplicate shortcuts. ++ warnings = shortcuts.GenerateDuplicateShortcutsWarnings( ++ self.res.UberClique(), self.res.GetTcProject()) ++ if warnings: ++ print('\n'.join(warnings)) ++ ++ # Print out any fallback warnings, and missing translation errors, and ++ # exit with an error code if there are missing translations in a non-pseudo ++ # and non-official build. ++ warnings = (self.res.UberClique().MissingTranslationsReport(). ++ encode('ascii', 'replace')) ++ if warnings: ++ self.VerboseOut(warnings) ++ if self.res.UberClique().HasMissingTranslations(): ++ print(self.res.UberClique().missing_translations_) ++ sys.exit(-1) ++ ++ ++ def CheckAssertedOutputFiles(self, assert_output_files): ++ '''Checks that the asserted output files are specified in the given list. ++ ++ Returns true if the asserted files are present. If they are not, returns ++ False and prints the failure. ++ ''' ++ # Compare the absolute path names, sorted. ++ asserted = sorted([os.path.abspath(i) for i in assert_output_files]) ++ actual = sorted([ ++ os.path.abspath(os.path.join(self.output_directory, ++ i.GetOutputFilename())) ++ for i in self.res.GetOutputFiles()]) ++ ++ if asserted != actual: ++ missing = list(set(asserted) - set(actual)) ++ extra = list(set(actual) - set(asserted)) ++ error = '''Asserted file list does not match. ++ ++Expected output files: ++%s ++Actual output files: ++%s ++Missing output files: ++%s ++Extra output files: ++%s ++''' ++ print(error % ('\n'.join(asserted), '\n'.join(actual), '\n'.join(missing), ++ ' \n'.join(extra))) ++ return False ++ return True ++ ++ ++ def GenerateDepfile(self, depfile, depdir, first_ids_file, depend_on_stamp): ++ '''Generate a depfile that contains the imlicit dependencies of the input ++ grd. The depfile will be in the same format as a makefile, and will contain ++ references to files relative to |depdir|. It will be put in |depfile|. ++ ++ For example, supposing we have three files in a directory src/ ++ ++ src/ ++ blah.grd <- depends on input{1,2}.xtb ++ input1.xtb ++ input2.xtb ++ ++ and we run ++ ++ grit -i blah.grd -o ../out/gen \ ++ --depdir ../out \ ++ --depfile ../out/gen/blah.rd.d ++ ++ from the directory src/ we will generate a depfile ../out/gen/blah.grd.d ++ that has the contents ++ ++ gen/blah.h: ../src/input1.xtb ../src/input2.xtb ++ ++ Where "gen/blah.h" is the first output (Ninja expects the .d file to list ++ the first output in cases where there is more than one). If the flag ++ --depend-on-stamp is specified, "gen/blah.rd.d.stamp" will be used that is ++ 'touched' whenever a new depfile is generated. ++ ++ Note that all paths in the depfile are relative to ../out, the depdir. ++ ''' ++ depfile = os.path.abspath(depfile) ++ depdir = os.path.abspath(depdir) ++ infiles = self.res.GetInputFiles() ++ ++ # We want to trigger a rebuild if the first ids change. ++ if first_ids_file is not None: ++ infiles.append(first_ids_file) ++ ++ if (depend_on_stamp): ++ output_file = depfile + ".stamp" ++ # Touch the stamp file before generating the depfile. ++ with open(output_file, 'a'): ++ os.utime(output_file, None) ++ else: ++ # Get the first output file relative to the depdir. ++ outputs = self.res.GetOutputFiles() ++ output_file = os.path.join(self.output_directory, ++ outputs[0].GetOutputFilename()) ++ ++ output_file = os.path.relpath(output_file, depdir) ++ # The path prefix to prepend to dependencies in the depfile. ++ prefix = os.path.relpath(os.getcwd(), depdir) ++ deps_text = ' '.join([os.path.join(prefix, i) for i in infiles]) ++ ++ depfile_contents = output_file + ': ' + deps_text ++ self.MakeDirectoriesTo(depfile) ++ outfile = self.fo_create(depfile, 'w', encoding='utf-8') ++ outfile.write(depfile_contents) ++ ++ @staticmethod ++ def MakeDirectoriesTo(file): ++ '''Creates directories necessary to contain |file|.''' ++ dir = os.path.split(file)[0] ++ if not os.path.exists(dir): ++ os.makedirs(dir) +diff --git a/tools/grit/grit/tool/build_unittest.py b/tools/grit/grit/tool/build_unittest.py +new file mode 100644 +index 0000000000..c4a2f2752b +--- /dev/null ++++ b/tools/grit/grit/tool/build_unittest.py +@@ -0,0 +1,341 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for the 'grit build' tool. ++''' ++ ++from __future__ import print_function ++ ++import codecs ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++from grit import util ++from grit.tool import build ++ ++ ++class BuildUnittest(unittest.TestCase): ++ ++ # IDs should not change based on whitelisting. ++ # Android WebView currently relies on this. ++ EXPECTED_ID_MAP = { ++ 'IDS_MESSAGE_WHITELISTED': 6889, ++ 'IDR_STRUCTURE_WHITELISTED': 11546, ++ 'IDR_STRUCTURE_IN_TRUE_IF_WHITELISTED': 11548, ++ 'IDR_INCLUDE_WHITELISTED': 15601, ++ } ++ ++ def testFindTranslationsWithSubstitutions(self): ++ # This is a regression test; we had a bug where GRIT would fail to find ++ # messages with substitutions e.g. "Hello [IDS_USER]" where IDS_USER is ++ # another . ++ output_dir = util.TempDir({}) ++ builder = build.RcBuilder() ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/substitute.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ builder.Run(DummyOpts(), ['-o', output_dir.GetPath()]) ++ output_dir.CleanUp() ++ ++ def testGenerateDepFile(self): ++ output_dir = util.TempDir({}) ++ builder = build.RcBuilder() ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/depfile.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ expected_dep_file = output_dir.GetPath('substitute.grd.d') ++ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), ++ '--depdir', output_dir.GetPath(), ++ '--depfile', expected_dep_file]) ++ ++ self.failUnless(os.path.isfile(expected_dep_file)) ++ with open(expected_dep_file) as f: ++ line = f.readline() ++ (dep_output_file, deps_string) = line.split(': ') ++ deps = deps_string.split(' ') ++ ++ self.failUnlessEqual("default_100_percent.pak", dep_output_file) ++ self.failUnlessEqual(deps, [ ++ util.PathFromRoot('grit/testdata/default_100_percent/a.png'), ++ util.PathFromRoot('grit/testdata/grit_part.grdp'), ++ util.PathFromRoot('grit/testdata/special_100_percent/a.png'), ++ ]) ++ output_dir.CleanUp() ++ ++ def testGenerateDepFileWithResourceIds(self): ++ output_dir = util.TempDir({}) ++ builder = build.RcBuilder() ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/substitute_no_ids.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ expected_dep_file = output_dir.GetPath('substitute_no_ids.grd.d') ++ builder.Run(DummyOpts(), ++ ['-f', util.PathFromRoot('grit/testdata/resource_ids'), ++ '-o', output_dir.GetPath(), ++ '--depdir', output_dir.GetPath(), ++ '--depfile', expected_dep_file]) ++ ++ self.failUnless(os.path.isfile(expected_dep_file)) ++ with open(expected_dep_file) as f: ++ line = f.readline() ++ (dep_output_file, deps_string) = line.split(': ') ++ deps = deps_string.split(' ') ++ ++ self.failUnlessEqual("resource.h", dep_output_file) ++ self.failUnlessEqual(2, len(deps)) ++ self.failUnlessEqual(deps[0], ++ util.PathFromRoot('grit/testdata/substitute.xmb')) ++ self.failUnlessEqual(deps[1], ++ util.PathFromRoot('grit/testdata/resource_ids')) ++ output_dir.CleanUp() ++ ++ def testAssertOutputs(self): ++ output_dir = util.TempDir({}) ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/substitute.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ ++ # Incomplete output file list should fail. ++ builder_fail = build.RcBuilder() ++ self.failUnlessEqual(2, ++ builder_fail.Run(DummyOpts(), [ ++ '-o', output_dir.GetPath(), ++ '-a', os.path.abspath( ++ output_dir.GetPath('en_generated_resources.rc'))])) ++ ++ # Complete output file list should succeed. ++ builder_ok = build.RcBuilder() ++ self.failUnlessEqual(0, ++ builder_ok.Run(DummyOpts(), [ ++ '-o', output_dir.GetPath(), ++ '-a', os.path.abspath( ++ output_dir.GetPath('en_generated_resources.rc')), ++ '-a', os.path.abspath( ++ output_dir.GetPath('sv_generated_resources.rc')), ++ '-a', os.path.abspath(output_dir.GetPath('resource.h'))])) ++ output_dir.CleanUp() ++ ++ def testAssertTemplateOutputs(self): ++ output_dir = util.TempDir({}) ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/substitute_tmpl.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ ++ # Incomplete output file list should fail. ++ builder_fail = build.RcBuilder() ++ self.failUnlessEqual(2, ++ builder_fail.Run(DummyOpts(), [ ++ '-o', output_dir.GetPath(), ++ '-E', 'name=foo', ++ '-a', os.path.abspath(output_dir.GetPath('en_foo_resources.rc'))])) ++ ++ # Complete output file list should succeed. ++ builder_ok = build.RcBuilder() ++ self.failUnlessEqual(0, ++ builder_ok.Run(DummyOpts(), [ ++ '-o', output_dir.GetPath(), ++ '-E', 'name=foo', ++ '-a', os.path.abspath(output_dir.GetPath('en_foo_resources.rc')), ++ '-a', os.path.abspath(output_dir.GetPath('sv_foo_resources.rc')), ++ '-a', os.path.abspath(output_dir.GetPath('resource.h'))])) ++ output_dir.CleanUp() ++ ++ def _verifyWhitelistedOutput(self, ++ filename, ++ whitelisted_ids, ++ non_whitelisted_ids, ++ encoding='utf8'): ++ self.failUnless(os.path.exists(filename)) ++ whitelisted_ids_found = [] ++ non_whitelisted_ids_found = [] ++ with codecs.open(filename, encoding=encoding) as f: ++ for line in f.readlines(): ++ for whitelisted_id in whitelisted_ids: ++ if whitelisted_id in line: ++ whitelisted_ids_found.append(whitelisted_id) ++ if filename.endswith('.h'): ++ numeric_id = int(line.split()[2]) ++ expected_numeric_id = self.EXPECTED_ID_MAP.get(whitelisted_id) ++ self.assertEqual( ++ expected_numeric_id, numeric_id, ++ 'Numeric ID for {} was {} should be {}'.format( ++ whitelisted_id, numeric_id, expected_numeric_id)) ++ for non_whitelisted_id in non_whitelisted_ids: ++ if non_whitelisted_id in line: ++ non_whitelisted_ids_found.append(non_whitelisted_id) ++ self.longMessage = True ++ self.assertEqual(whitelisted_ids, ++ whitelisted_ids_found, ++ '\nin file {}'.format(os.path.basename(filename))) ++ non_whitelisted_msg = ('Non-Whitelisted IDs {} found in {}' ++ .format(non_whitelisted_ids_found, os.path.basename(filename))) ++ self.assertFalse(non_whitelisted_ids_found, non_whitelisted_msg) ++ ++ def testWhitelistStrings(self): ++ output_dir = util.TempDir({}) ++ builder = build.RcBuilder() ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/whitelist_strings.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ whitelist_file = util.PathFromRoot('grit/testdata/whitelist.txt') ++ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), ++ '-w', whitelist_file]) ++ header = output_dir.GetPath('whitelist_test_resources.h') ++ rc = output_dir.GetPath('en_whitelist_test_strings.rc') ++ ++ whitelisted_ids = ['IDS_MESSAGE_WHITELISTED'] ++ non_whitelisted_ids = ['IDS_MESSAGE_NOT_WHITELISTED'] ++ self._verifyWhitelistedOutput( ++ header, ++ whitelisted_ids, ++ non_whitelisted_ids, ++ ) ++ self._verifyWhitelistedOutput( ++ rc, ++ whitelisted_ids, ++ non_whitelisted_ids, ++ encoding='utf16' ++ ) ++ output_dir.CleanUp() ++ ++ def testWhitelistResources(self): ++ output_dir = util.TempDir({}) ++ builder = build.RcBuilder() ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/whitelist_resources.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ whitelist_file = util.PathFromRoot('grit/testdata/whitelist.txt') ++ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), ++ '-w', whitelist_file]) ++ header = output_dir.GetPath('whitelist_test_resources.h') ++ map_cc = output_dir.GetPath('whitelist_test_resources_map.cc') ++ map_h = output_dir.GetPath('whitelist_test_resources_map.h') ++ pak = output_dir.GetPath('whitelist_test_resources.pak') ++ ++ # Ensure the resource map header and .pak files exist, but don't verify ++ # their content. ++ self.failUnless(os.path.exists(map_h)) ++ self.failUnless(os.path.exists(pak)) ++ ++ whitelisted_ids = [ ++ 'IDR_STRUCTURE_WHITELISTED', ++ 'IDR_STRUCTURE_IN_TRUE_IF_WHITELISTED', ++ 'IDR_INCLUDE_WHITELISTED', ++ ] ++ non_whitelisted_ids = [ ++ 'IDR_STRUCTURE_NOT_WHITELISTED', ++ 'IDR_STRUCTURE_IN_TRUE_IF_NOT_WHITELISTED', ++ 'IDR_STRUCTURE_IN_FALSE_IF_WHITELISTED', ++ 'IDR_STRUCTURE_IN_FALSE_IF_NOT_WHITELISTED', ++ 'IDR_INCLUDE_NOT_WHITELISTED', ++ ] ++ for output_file in (header, map_cc): ++ self._verifyWhitelistedOutput( ++ output_file, ++ whitelisted_ids, ++ non_whitelisted_ids, ++ ) ++ output_dir.CleanUp() ++ ++ def testWriteOnlyNew(self): ++ output_dir = util.TempDir({}) ++ builder = build.RcBuilder() ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/substitute.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ UNCHANGED = 10 ++ header = output_dir.GetPath('resource.h') ++ ++ builder.Run(DummyOpts(), ['-o', output_dir.GetPath()]) ++ self.failUnless(os.path.exists(header)) ++ first_mtime = os.stat(header).st_mtime ++ ++ os.utime(header, (UNCHANGED, UNCHANGED)) ++ builder.Run(DummyOpts(), ++ ['-o', output_dir.GetPath(), '--write-only-new', '0']) ++ self.failUnless(os.path.exists(header)) ++ second_mtime = os.stat(header).st_mtime ++ ++ os.utime(header, (UNCHANGED, UNCHANGED)) ++ builder.Run(DummyOpts(), ++ ['-o', output_dir.GetPath(), '--write-only-new', '1']) ++ self.failUnless(os.path.exists(header)) ++ third_mtime = os.stat(header).st_mtime ++ ++ self.assertTrue(abs(second_mtime - UNCHANGED) > 5) ++ self.assertTrue(abs(third_mtime - UNCHANGED) < 5) ++ output_dir.CleanUp() ++ ++ def testGenerateDepFileWithDependOnStamp(self): ++ output_dir = util.TempDir({}) ++ builder = build.RcBuilder() ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = util.PathFromRoot('grit/testdata/substitute.grd') ++ self.verbose = False ++ self.extra_verbose = False ++ expected_dep_file_name = 'substitute.grd.d' ++ expected_stamp_file_name = expected_dep_file_name + '.stamp' ++ expected_dep_file = output_dir.GetPath(expected_dep_file_name) ++ expected_stamp_file = output_dir.GetPath(expected_stamp_file_name) ++ if os.path.isfile(expected_stamp_file): ++ os.remove(expected_stamp_file) ++ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), ++ '--depdir', output_dir.GetPath(), ++ '--depfile', expected_dep_file, ++ '--depend-on-stamp']) ++ self.failUnless(os.path.isfile(expected_stamp_file)) ++ first_mtime = os.stat(expected_stamp_file).st_mtime ++ ++ # Reset mtime to very old. ++ OLDTIME = 10 ++ os.utime(expected_stamp_file, (OLDTIME, OLDTIME)) ++ ++ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), ++ '--depdir', output_dir.GetPath(), ++ '--depfile', expected_dep_file, ++ '--depend-on-stamp']) ++ self.failUnless(os.path.isfile(expected_stamp_file)) ++ second_mtime = os.stat(expected_stamp_file).st_mtime ++ ++ # Some OS have a 2s stat resolution window, so can't do a direct comparison. ++ self.assertTrue((second_mtime - OLDTIME) > 5) ++ self.assertTrue(abs(second_mtime - first_mtime) < 5) ++ ++ self.failUnless(os.path.isfile(expected_dep_file)) ++ with open(expected_dep_file) as f: ++ line = f.readline() ++ (dep_output_file, deps_string) = line.split(': ') ++ deps = deps_string.split(' ') ++ ++ self.failUnlessEqual(expected_stamp_file_name, dep_output_file) ++ self.failUnlessEqual(deps, [ ++ util.PathFromRoot('grit/testdata/substitute.xmb'), ++ ]) ++ output_dir.CleanUp() ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/tool/buildinfo.py b/tools/grit/grit/tool/buildinfo.py +new file mode 100644 +index 0000000000..7f8d1a3b04 +--- /dev/null ++++ b/tools/grit/grit/tool/buildinfo.py +@@ -0,0 +1,78 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Output the list of files to be generated by GRIT from an input. ++""" ++ ++from __future__ import print_function ++ ++import getopt ++import os ++import sys ++ ++from grit import grd_reader ++from grit.node import structure ++from grit.tool import interface ++ ++class DetermineBuildInfo(interface.Tool): ++ """Determine what files will be read and output by GRIT. ++Outputs the list of generated files and inputs used to stdout. ++ ++Usage: grit buildinfo [-o DIR] ++ ++The output directory is used for display only. ++""" ++ ++ def __init__(self): ++ pass ++ ++ def ShortDescription(self): ++ """Describes this tool for the usage message.""" ++ return ('Determine what files will be needed and\n' ++ 'output by GRIT with a given input.') ++ ++ def Run(self, opts, args): ++ """Main method for the buildinfo tool.""" ++ self.output_directory = '.' ++ (own_opts, args) = getopt.getopt(args, 'o:', ('help',)) ++ for (key, val) in own_opts: ++ if key == '-o': ++ self.output_directory = val ++ elif key == '--help': ++ self.ShowUsage() ++ sys.exit(0) ++ if len(args) > 0: ++ print('This tool takes exactly one argument: the output directory via -o') ++ return 2 ++ self.SetOptions(opts) ++ ++ res_tree = grd_reader.Parse(opts.input, debug=opts.extra_verbose) ++ ++ langs = {} ++ for output in res_tree.GetOutputFiles(): ++ if output.attrs['lang']: ++ langs[output.attrs['lang']] = os.path.dirname(output.GetFilename()) ++ ++ for lang, dirname in langs.items(): ++ old_output_language = res_tree.output_language ++ res_tree.SetOutputLanguage(lang) ++ for node in res_tree.ActiveDescendants(): ++ with node: ++ if (isinstance(node, structure.StructureNode) and ++ node.HasFileForLanguage()): ++ path = node.FileForLanguage(lang, dirname, create_file=False, ++ return_if_not_generated=False) ++ if path: ++ path = os.path.join(self.output_directory, path) ++ path = os.path.normpath(path) ++ print('%s|%s' % ('rc_all', path)) ++ res_tree.SetOutputLanguage(old_output_language) ++ ++ for output in res_tree.GetOutputFiles(): ++ path = os.path.join(self.output_directory, output.GetFilename()) ++ path = os.path.normpath(path) ++ print('%s|%s' % (output.GetType(), path)) ++ ++ for infile in res_tree.GetInputFiles(): ++ print('input|%s' % os.path.normpath(infile)) +diff --git a/tools/grit/grit/tool/buildinfo_unittest.py b/tools/grit/grit/tool/buildinfo_unittest.py +new file mode 100644 +index 0000000000..24e9ddf8d8 +--- /dev/null ++++ b/tools/grit/grit/tool/buildinfo_unittest.py +@@ -0,0 +1,90 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""Unit tests for the 'grit buildinfo' tool. ++""" ++ ++from __future__ import print_function ++ ++import os ++import sys ++import unittest ++ ++# This is needed to find some of the imports below. ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++from six import StringIO ++ ++# pylint: disable-msg=C6204 ++from grit.tool import buildinfo ++ ++ ++class BuildInfoUnittest(unittest.TestCase): ++ def setUp(self): ++ self.old_cwd = os.getcwd() ++ # Change CWD to make tests work independently of callers CWD. ++ os.chdir(os.path.dirname(__file__)) ++ os.chdir('..') ++ self.buf = StringIO() ++ self.old_stdout = sys.stdout ++ sys.stdout = self.buf ++ ++ def tearDown(self): ++ sys.stdout = self.old_stdout ++ os.chdir(self.old_cwd) ++ ++ def testBuildOutput(self): ++ """Find all of the inputs and outputs for a GRD file.""" ++ info_object = buildinfo.DetermineBuildInfo() ++ ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = '../grit/testdata/buildinfo.grd' ++ self.print_header = False ++ self.verbose = False ++ self.extra_verbose = False ++ info_object.Run(DummyOpts(), []) ++ output = self.buf.getvalue().replace('\\', '/') ++ self.failUnless(output.count(r'rc_all|sv_sidebar_loading.html')) ++ self.failUnless(output.count(r'rc_header|resource.h')) ++ self.failUnless(output.count(r'rc_all|en_generated_resources.rc')) ++ self.failUnless(output.count(r'rc_all|sv_generated_resources.rc')) ++ self.failUnless(output.count(r'input|../grit/testdata/substitute.xmb')) ++ self.failUnless(output.count(r'input|../grit/testdata/pr.bmp')) ++ self.failUnless(output.count(r'input|../grit/testdata/pr2.bmp')) ++ self.failUnless( ++ output.count(r'input|../grit/testdata/sidebar_loading.html')) ++ self.failUnless(output.count(r'input|../grit/testdata/transl.rc')) ++ self.failUnless(output.count(r'input|../grit/testdata/transl1.rc')) ++ ++ def testBuildOutputWithDir(self): ++ """Find all the inputs and outputs for a GRD file with an output dir.""" ++ info_object = buildinfo.DetermineBuildInfo() ++ ++ class DummyOpts(object): ++ def __init__(self): ++ self.input = '../grit/testdata/buildinfo.grd' ++ self.print_header = False ++ self.verbose = False ++ self.extra_verbose = False ++ info_object.Run(DummyOpts(), ['-o', '../grit/testdata']) ++ output = self.buf.getvalue().replace('\\', '/') ++ self.failUnless( ++ output.count(r'rc_all|../grit/testdata/sv_sidebar_loading.html')) ++ self.failUnless(output.count(r'rc_header|../grit/testdata/resource.h')) ++ self.failUnless( ++ output.count(r'rc_all|../grit/testdata/en_generated_resources.rc')) ++ self.failUnless( ++ output.count(r'rc_all|../grit/testdata/sv_generated_resources.rc')) ++ self.failUnless(output.count(r'input|../grit/testdata/substitute.xmb')) ++ self.failUnlessEqual(0, ++ output.count(r'rc_all|../grit/testdata/sv_welcome_toast.html')) ++ self.failUnless( ++ output.count(r'rc_all|../grit/testdata/en_welcome_toast.html')) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/tool/count.py b/tools/grit/grit/tool/count.py +new file mode 100644 +index 0000000000..ab37f2ddb3 +--- /dev/null ++++ b/tools/grit/grit/tool/count.py +@@ -0,0 +1,52 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Count number of occurrences of a given message ID.''' ++ ++from __future__ import print_function ++ ++import getopt ++import sys ++ ++from grit import grd_reader ++from grit.tool import interface ++ ++ ++class CountMessage(interface.Tool): ++ '''Count the number of times a given message ID is used.''' ++ ++ def __init__(self): ++ pass ++ ++ def ShortDescription(self): ++ return 'Count the number of times a given message ID is used.' ++ ++ def ParseOptions(self, args): ++ """Set this objects and return all non-option arguments.""" ++ own_opts, args = getopt.getopt(args, '', ('help',)) ++ for key, val in own_opts: ++ if key == '--help': ++ self.ShowUsage() ++ sys.exit(0) ++ return args ++ ++ def Run(self, opts, args): ++ args = self.ParseOptions(args) ++ if len(args) != 1: ++ print('This tool takes a single tool-specific argument, the message ' ++ 'ID to count.') ++ return 2 ++ self.SetOptions(opts) ++ ++ id = args[0] ++ res_tree = grd_reader.Parse(opts.input, debug=opts.extra_verbose) ++ res_tree.OnlyTheseTranslations([]) ++ res_tree.RunGatherers() ++ ++ count = 0 ++ for c in res_tree.UberClique().AllCliques(): ++ if c.GetId() == id: ++ count += 1 ++ ++ print("There are %d occurrences of message %s." % (count, id)) +diff --git a/tools/grit/grit/tool/diff_structures.py b/tools/grit/grit/tool/diff_structures.py +new file mode 100644 +index 0000000000..d69e009b58 +--- /dev/null ++++ b/tools/grit/grit/tool/diff_structures.py +@@ -0,0 +1,119 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''The 'grit sdiff' tool. ++''' ++ ++from __future__ import print_function ++ ++import os ++import getopt ++import sys ++import tempfile ++ ++from grit.node import structure ++from grit.tool import interface ++ ++from grit import constants ++from grit import util ++ ++# Builds the description for the tool (used as the __doc__ ++# for the DiffStructures class). ++_class_doc = """\ ++Allows you to view the differences in the structure of two files, ++disregarding their translateable content. Translateable portions of ++each file are changed to the string "TTTTTT" before invoking the diff program ++specified by the P4DIFF environment variable. ++ ++Usage: grit sdiff [-t TYPE] [-s SECTION] [-e ENCODING] LEFT RIGHT ++ ++LEFT and RIGHT are the files you want to diff. SECTION is required ++for structure types like 'dialog' to identify the part of the file to look at. ++ENCODING indicates the encoding of the left and right files (default 'cp1252'). ++TYPE can be one of the following, defaults to 'tr_html': ++""" ++for gatherer in structure._GATHERERS: ++ _class_doc += " - %s\n" % gatherer ++ ++ ++class DiffStructures(interface.Tool): ++ __doc__ = _class_doc ++ ++ def __init__(self): ++ self.section = None ++ self.left_encoding = 'cp1252' ++ self.right_encoding = 'cp1252' ++ self.structure_type = 'tr_html' ++ ++ def ShortDescription(self): ++ return 'View differences without regard for translateable portions.' ++ ++ def Run(self, global_opts, args): ++ (opts, args) = getopt.getopt(args, 's:e:t:', ++ ('help', 'left_encoding=', 'right_encoding=')) ++ for key, val in opts: ++ if key == '-s': ++ self.section = val ++ elif key == '-e': ++ self.left_encoding = val ++ self.right_encoding = val ++ elif key == '-t': ++ self.structure_type = val ++ elif key == '--left_encoding': ++ self.left_encoding = val ++ elif key == '--right_encoding': ++ self.right_encoding == val ++ elif key == '--help': ++ self.ShowUsage() ++ sys.exit(0) ++ ++ if len(args) != 2: ++ print("Incorrect usage - 'grit help sdiff' for usage details.") ++ return 2 ++ ++ if 'P4DIFF' not in os.environ: ++ print("Environment variable P4DIFF not set; defaulting to 'windiff'.") ++ diff_program = 'windiff' ++ else: ++ diff_program = os.environ['P4DIFF'] ++ ++ left_trans = self.MakeStaticTranslation(args[0], self.left_encoding) ++ try: ++ try: ++ right_trans = self.MakeStaticTranslation(args[1], self.right_encoding) ++ ++ os.system('%s %s %s' % (diff_program, left_trans, right_trans)) ++ finally: ++ os.unlink(right_trans) ++ finally: ++ os.unlink(left_trans) ++ ++ def MakeStaticTranslation(self, original_filename, encoding): ++ """Given the name of the structure type (self.structure_type), the filename ++ of the file holding the original structure, and optionally the "section" key ++ identifying the part of the file to look at (self.section), creates a ++ temporary file holding a "static" translation of the original structure ++ (i.e. one where all translateable parts have been replaced with "TTTTTT") ++ and returns the temporary file name. It is the caller's responsibility to ++ delete the file when finished. ++ ++ Args: ++ original_filename: 'c:\\bingo\\bla.rc' ++ ++ Return: ++ 'c:\\temp\\werlkjsdf334.tmp' ++ """ ++ original = structure._GATHERERS[self.structure_type](original_filename, ++ extkey=self.section, ++ encoding=encoding) ++ original.Parse() ++ translated = original.Translate(constants.CONSTANT_LANGUAGE, False) ++ ++ fname = tempfile.mktemp() ++ with util.WrapOutputStream(open(fname, 'wb')) as writer: ++ writer.write("Original filename: %s\n=============\n\n" ++ % original_filename) ++ writer.write(translated) # write in UTF-8 ++ ++ return fname +diff --git a/tools/grit/grit/tool/diff_structures_unittest.py b/tools/grit/grit/tool/diff_structures_unittest.py +new file mode 100644 +index 0000000000..a6d7585761 +--- /dev/null ++++ b/tools/grit/grit/tool/diff_structures_unittest.py +@@ -0,0 +1,46 @@ ++#!/usr/bin/env python ++# Copyright 2020 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for the 'grit newgrd' tool.''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++from grit.tool import diff_structures ++ ++ ++class DummyOpts(object): ++ """Options needed by NewGrd.""" ++ ++ ++class DiffStructuresUnittest(unittest.TestCase): ++ ++ def testMissingFiles(self): ++ """Verify failure w/out file inputs.""" ++ tool = diff_structures.DiffStructures() ++ ret = tool.Run(DummyOpts(), []) ++ self.assertIsNotNone(ret) ++ self.assertGreater(ret, 0) ++ ++ ret = tool.Run(DummyOpts(), ['left']) ++ self.assertIsNotNone(ret) ++ self.assertGreater(ret, 0) ++ ++ def testTooManyArgs(self): ++ """Verify failure w/too many inputs.""" ++ tool = diff_structures.DiffStructures() ++ ret = tool.Run(DummyOpts(), ['a', 'b', 'c']) ++ self.assertIsNotNone(ret) ++ self.assertGreater(ret, 0) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/tool/interface.py b/tools/grit/grit/tool/interface.py +new file mode 100644 +index 0000000000..e923205223 +--- /dev/null ++++ b/tools/grit/grit/tool/interface.py +@@ -0,0 +1,62 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Base class and interface for tools. ++''' ++ ++from __future__ import print_function ++ ++class Tool(object): ++ '''Base class for all tools. Tools should use their docstring (i.e. the ++ class-level docstring) for the help they want to have printed when they ++ are invoked.''' ++ ++ # ++ # Interface (abstract methods) ++ # ++ ++ def ShortDescription(self): ++ '''Returns a short description of the functionality of the tool.''' ++ raise NotImplementedError() ++ ++ def Run(self, global_options, my_arguments): ++ '''Runs the tool. ++ ++ Args: ++ global_options: object grit_runner.Options ++ my_arguments: [arg1 arg2 ...] ++ ++ Return: ++ 0 for success, non-0 for error ++ ''' ++ raise NotImplementedError() ++ ++ # ++ # Base class implementation ++ # ++ ++ def __init__(self): ++ self.o = None ++ ++ def ShowUsage(self): ++ '''Show usage text for this tool.''' ++ print(self.__doc__) ++ ++ def SetOptions(self, opts): ++ self.o = opts ++ ++ def Out(self, text): ++ '''Always writes out 'text'.''' ++ self.o.output_stream.write(text) ++ ++ def VerboseOut(self, text): ++ '''Writes out 'text' if the verbose option is on.''' ++ if self.o.verbose: ++ self.o.output_stream.write(text) ++ ++ def ExtraVerboseOut(self, text): ++ '''Writes out 'text' if the extra-verbose option is on. ++ ''' ++ if self.o.extra_verbose: ++ self.o.output_stream.write(text) +diff --git a/tools/grit/grit/tool/menu_from_parts.py b/tools/grit/grit/tool/menu_from_parts.py +new file mode 100644 +index 0000000000..fcec26c5b1 +--- /dev/null ++++ b/tools/grit/grit/tool/menu_from_parts.py +@@ -0,0 +1,79 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''The 'grit menufromparts' tool.''' ++ ++from __future__ import print_function ++ ++import six ++ ++from grit import grd_reader ++from grit import util ++from grit import xtb_reader ++from grit.tool import interface ++from grit.tool import transl2tc ++ ++import grit.extern.tclib ++ ++ ++class MenuTranslationsFromParts(interface.Tool): ++ '''One-off tool to generate translated menu messages (where each menu is kept ++in a single message) based on existing translations of the individual menu ++items. Was needed when changing menus from being one message per menu item ++to being one message for the whole menu.''' ++ ++ def ShortDescription(self): ++ return ('Create translations of whole menus from existing translations of ' ++ 'menu items.') ++ ++ def Run(self, globopt, args): ++ self.SetOptions(globopt) ++ assert len(args) == 2, "Need exactly two arguments, the XTB file and the output file" ++ ++ xtb_file = args[0] ++ output_file = args[1] ++ ++ grd = grd_reader.Parse(self.o.input, debug=self.o.extra_verbose) ++ grd.OnlyTheseTranslations([]) # don't load translations ++ grd.RunGatherers() ++ ++ xtb = {} ++ def Callback(msg_id, parts): ++ msg = [] ++ for part in parts: ++ if part[0]: ++ msg = [] ++ break # it had a placeholder so ignore it ++ else: ++ msg.append(part[1]) ++ if len(msg): ++ xtb[msg_id] = ''.join(msg) ++ with open(xtb_file, 'rb') as f: ++ xtb_reader.Parse(f, Callback) ++ ++ translations = [] # list of translations as per transl2tc.WriteTranslations ++ for node in grd: ++ if node.name == 'structure' and node.attrs['type'] == 'menu': ++ assert len(node.GetCliques()) == 1 ++ message = node.GetCliques()[0].GetMessage() ++ translation = [] ++ ++ contents = message.GetContent() ++ for part in contents: ++ if isinstance(part, six.string_types): ++ id = grit.extern.tclib.GenerateMessageId(part) ++ if id not in xtb: ++ print("WARNING didn't find all translations for menu %s" % ++ (node.attrs['name'],)) ++ translation = [] ++ break ++ translation.append(xtb[id]) ++ else: ++ translation.append(part.GetPresentation()) ++ ++ if len(translation): ++ translations.append([message.GetId(), ''.join(translation)]) ++ ++ with util.WrapOutputStream(open(output_file, 'wb')) as f: ++ transl2tc.TranslationToTc.WriteTranslations(f, translations) +diff --git a/tools/grit/grit/tool/newgrd.py b/tools/grit/grit/tool/newgrd.py +new file mode 100644 +index 0000000000..66a18e9c04 +--- /dev/null ++++ b/tools/grit/grit/tool/newgrd.py +@@ -0,0 +1,85 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Tool to create a new, empty .grd file with all the basic sections. ++''' ++ ++from __future__ import print_function ++ ++import getopt ++import sys ++ ++from grit.tool import interface ++from grit import constants ++from grit import util ++ ++# The contents of the new .grd file ++_FILE_CONTENTS = '''\ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++''' % constants.ENCODING_CHECK ++ ++ ++class NewGrd(interface.Tool): ++ '''Usage: grit newgrd OUTPUT_FILE ++ ++Creates a new, empty .grd file OUTPUT_FILE with comments about what to put ++where in the file.''' ++ ++ def ShortDescription(self): ++ return 'Create a new empty .grd file.' ++ ++ def ParseOptions(self, args): ++ """Set this objects and return all non-option arguments.""" ++ own_opts, args = getopt.getopt(args, '', ('help',)) ++ for key, val in own_opts: ++ if key == '--help': ++ self.ShowUsage() ++ sys.exit(0) ++ return args ++ ++ def Run(self, opts, args): ++ args = self.ParseOptions(args) ++ if len(args) != 1: ++ print('This tool requires exactly one argument, the name of the output ' ++ 'file.') ++ return 2 ++ filename = args[0] ++ with util.WrapOutputStream(open(filename, 'wb'), 'utf-8') as out: ++ out.write(_FILE_CONTENTS) ++ print("Wrote file %s" % filename) +diff --git a/tools/grit/grit/tool/newgrd_unittest.py b/tools/grit/grit/tool/newgrd_unittest.py +new file mode 100644 +index 0000000000..f7c8831df5 +--- /dev/null ++++ b/tools/grit/grit/tool/newgrd_unittest.py +@@ -0,0 +1,51 @@ ++#!/usr/bin/env python ++# Copyright 2020 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for the 'grit newgrd' tool.''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++from grit import util ++from grit.tool import newgrd ++ ++ ++class DummyOpts(object): ++ """Options needed by NewGrd.""" ++ ++ ++class NewgrdUnittest(unittest.TestCase): ++ ++ def testNewFile(self): ++ """Create a new file.""" ++ tool = newgrd.NewGrd() ++ with util.TempDir({}) as output_dir: ++ output_file = os.path.join(output_dir.GetPath(), 'new.grd') ++ self.assertIsNone(tool.Run(DummyOpts(), [output_file])) ++ self.assertTrue(os.path.exists(output_file)) ++ ++ def testMissingFile(self): ++ """Verify failure w/out file output.""" ++ tool = newgrd.NewGrd() ++ ret = tool.Run(DummyOpts(), []) ++ self.assertIsNotNone(ret) ++ self.assertGreater(ret, 0) ++ ++ def testTooManyArgs(self): ++ """Verify failure w/too many outputs.""" ++ tool = newgrd.NewGrd() ++ ret = tool.Run(DummyOpts(), ['a', 'b']) ++ self.assertIsNotNone(ret) ++ self.assertGreater(ret, 0) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/tool/postprocess_interface.py b/tools/grit/grit/tool/postprocess_interface.py +new file mode 100644 +index 0000000000..4bb8c5871f +--- /dev/null ++++ b/tools/grit/grit/tool/postprocess_interface.py +@@ -0,0 +1,29 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++''' Base class for postprocessing of RC files. ++''' ++ ++from __future__ import print_function ++ ++class PostProcessor(object): ++ ''' Base class for postprocessing of the RC file data before being ++ output through the RC2GRD tool. You should implement this class if ++ you want GRIT to do specific things to the RC files after it has ++ converted the data into GRD format, i.e. change the content of the ++ RC file, and put it into a P4 changelist, etc.''' ++ ++ ++ def Process(self, rctext, rcpath, grdnode): ++ ''' Processes the data in rctext and grdnode. ++ Args: ++ rctext: string containing the contents of the RC file being processed. ++ rcpath: the path used to access the file. ++ grdtext: the root node of the grd xml data generated by ++ the rc2grd tool. ++ ++ Return: ++ The root node of the processed GRD tree. ++ ''' ++ raise NotImplementedError() +diff --git a/tools/grit/grit/tool/postprocess_unittest.py b/tools/grit/grit/tool/postprocess_unittest.py +new file mode 100644 +index 0000000000..77fe228bbe +--- /dev/null ++++ b/tools/grit/grit/tool/postprocess_unittest.py +@@ -0,0 +1,64 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit test that checks postprocessing of files. ++ Tests postprocessing by having the postprocessor ++ modify the grd data tree, changing the message name attributes. ++''' ++ ++from __future__ import print_function ++ ++import os ++import re ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++import grit.tool.postprocess_interface ++from grit.tool import rc2grd ++ ++ ++class PostProcessingUnittest(unittest.TestCase): ++ ++ def testPostProcessing(self): ++ rctext = '''STRINGTABLE ++BEGIN ++ DUMMY_STRING_1 "String 1" ++ // Some random description ++ DUMMY_STRING_2 "This text was added during preprocessing" ++END ++ ''' ++ tool = rc2grd.Rc2Grd() ++ class DummyOpts(object): ++ verbose = False ++ extra_verbose = False ++ tool.o = DummyOpts() ++ tool.post_process = 'grit.tool.postprocess_unittest.DummyPostProcessor' ++ result = tool.Process(rctext, '.\resource.rc') ++ ++ self.failUnless( ++ result.children[2].children[2].children[0].attrs['name'] == 'SMART_STRING_1') ++ self.failUnless( ++ result.children[2].children[2].children[1].attrs['name'] == 'SMART_STRING_2') ++ ++class DummyPostProcessor(grit.tool.postprocess_interface.PostProcessor): ++ ''' ++ Post processing replaces all message name attributes containing "DUMMY" to ++ "SMART". ++ ''' ++ def Process(self, rctext, rcpath, grdnode): ++ smarter = re.compile(r'(DUMMY)(.*)') ++ messages = grdnode.children[2].children[2] ++ for node in messages.children: ++ name_attr = node.attrs['name'] ++ m = smarter.search(name_attr) ++ if m: ++ node.attrs['name'] = 'SMART' + m.group(2) ++ return grdnode ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/tool/preprocess_interface.py b/tools/grit/grit/tool/preprocess_interface.py +new file mode 100644 +index 0000000000..67974e704e +--- /dev/null ++++ b/tools/grit/grit/tool/preprocess_interface.py +@@ -0,0 +1,25 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++''' Base class for preprocessing of RC files. ++''' ++ ++from __future__ import print_function ++ ++class PreProcessor(object): ++ ''' Base class for preprocessing of the RC file data before being ++ output through the RC2GRD tool. You should implement this class if ++ you have specific constructs in your RC files that GRIT cannot handle.''' ++ ++ ++ def Process(self, rctext, rcpath): ++ ''' Processes the data in rctext. ++ Args: ++ rctext: string containing the contents of the RC file being processed ++ rcpath: the path used to access the file. ++ ++ Return: ++ The processed text. ++ ''' ++ raise NotImplementedError() +diff --git a/tools/grit/grit/tool/preprocess_unittest.py b/tools/grit/grit/tool/preprocess_unittest.py +new file mode 100644 +index 0000000000..40b95cd6f8 +--- /dev/null ++++ b/tools/grit/grit/tool/preprocess_unittest.py +@@ -0,0 +1,50 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit test that checks preprocessing of files. ++ Tests preprocessing by adding having the preprocessor ++ provide the actual rctext data. ++''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import unittest ++ ++import grit.tool.preprocess_interface ++from grit.tool import rc2grd ++ ++ ++class PreProcessingUnittest(unittest.TestCase): ++ ++ def testPreProcessing(self): ++ tool = rc2grd.Rc2Grd() ++ class DummyOpts(object): ++ verbose = False ++ extra_verbose = False ++ tool.o = DummyOpts() ++ tool.pre_process = 'grit.tool.preprocess_unittest.DummyPreProcessor' ++ result = tool.Process('', '.\resource.rc') ++ ++ self.failUnless( ++ result.children[2].children[2].children[0].attrs['name'] == 'DUMMY_STRING_1') ++ ++class DummyPreProcessor(grit.tool.preprocess_interface.PreProcessor): ++ def Process(self, rctext, rcpath): ++ rctext = '''STRINGTABLE ++BEGIN ++ DUMMY_STRING_1 "String 1" ++ // Some random description ++ DUMMY_STRING_2 "This text was added during preprocessing" ++END ++ ''' ++ return rctext ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/tools/grit/grit/tool/rc2grd.py b/tools/grit/grit/tool/rc2grd.py +new file mode 100644 +index 0000000000..3195b39000 +--- /dev/null ++++ b/tools/grit/grit/tool/rc2grd.py +@@ -0,0 +1,418 @@ ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''The 'grit rc2grd' tool.''' ++ ++from __future__ import print_function ++ ++import os.path ++import getopt ++import re ++import sys ++ ++import six ++from six import StringIO ++ ++import grit.node.empty ++from grit.node import include ++from grit.node import structure ++from grit.node import message ++ ++from grit.gather import rc ++from grit.gather import tr_html ++ ++from grit.tool import interface ++from grit.tool import postprocess_interface ++from grit.tool import preprocess_interface ++ ++from grit import grd_reader ++from grit import lazy_re ++from grit import tclib ++from grit import util ++ ++ ++# Matches files referenced from an .rc file ++_FILE_REF = lazy_re.compile(r''' ++ ^(?P[A-Z_0-9.]+)[ \t]+ ++ (?P[A-Z_0-9]+)[ \t]+ ++ "(?P.*?([^"]|""))"[ \t]*$''', re.VERBOSE | re.MULTILINE) ++ ++ ++# Matches a dialog section ++_DIALOG = lazy_re.compile( ++ r'^(?P[A-Z0-9_]+)\s+DIALOG(EX)?\s.+?^BEGIN\s*$.+?^END\s*$', ++ re.MULTILINE | re.DOTALL) ++ ++ ++# Matches a menu section ++_MENU = lazy_re.compile(r'^(?P[A-Z0-9_]+)\s+MENU.+?^BEGIN\s*$.+?^END\s*$', ++ re.MULTILINE | re.DOTALL) ++ ++ ++# Matches a versioninfo section ++_VERSIONINFO = lazy_re.compile( ++ r'^(?P[A-Z0-9_]+)\s+VERSIONINFO\s.+?^BEGIN\s*$.+?^END\s*$', ++ re.MULTILINE | re.DOTALL) ++ ++ ++# Matches a stringtable ++_STRING_TABLE = lazy_re.compile( ++ (r'^STRINGTABLE(\s+(PRELOAD|DISCARDABLE|CHARACTERISTICS.+|LANGUAGE.+|' ++ r'VERSION.+))*\s*\nBEGIN\s*$(?P.+?)^END\s*$'), ++ re.MULTILINE | re.DOTALL) ++ ++ ++# Matches each message inside a stringtable, breaking it up into comments, ++# the ID of the message, and the (RC-escaped) message text. ++_MESSAGE = lazy_re.compile(r''' ++ (?P(^\s+//.+?)*) # 0 or more lines of comments preceding the message ++ ^\s* ++ (?P[A-Za-z0-9_]+) # id ++ \s+ ++ "(?P.*?([^"]|""))"([^"]|$) # The message itself ++ ''', re.MULTILINE | re.DOTALL | re.VERBOSE) ++ ++ ++# Matches each line of comment text in a multi-line comment. ++_COMMENT_TEXT = lazy_re.compile(r'^\s*//\s*(?P.+?)$', re.MULTILINE) ++ ++ ++# Matches a string that is empty or all whitespace ++_WHITESPACE_ONLY = lazy_re.compile(r'\A\s*\Z', re.MULTILINE) ++ ++ ++# Finds printf and FormatMessage style format specifiers ++# Uses non-capturing groups except for the outermost group, so the output of ++# re.split() should include both the normal text and what we intend to ++# replace with placeholders. ++# TODO(joi) Check documentation for printf (and Windows variants) and FormatMessage ++_FORMAT_SPECIFIER = lazy_re.compile( ++ r'(%[-# +]?(?:[0-9]*|\*)(?:\.(?:[0-9]+|\*))?(?:h|l|L)?' # printf up to last char ++ r'(?:d|i|o|u|x|X|e|E|f|F|g|G|c|r|s|ls|ws)' # printf last char ++ r'|\$[1-9][0-9]*)') # FormatMessage ++ ++ ++class Rc2Grd(interface.Tool): ++ '''A tool for converting .rc files to .grd files. This tool is only for ++converting the source (nontranslated) .rc file to a .grd file. For importing ++existing translations, use the rc2xtb tool. ++ ++Usage: grit [global options] rc2grd [OPTIONS] RCFILE ++ ++The tool takes a single argument, which is the path to the .rc file to convert. ++It outputs a .grd file with the same name in the same directory as the .rc file. ++The .grd file may have one or more TODO comments for things that have to be ++cleaned up manually. ++ ++OPTIONS may be any of the following: ++ ++ -e ENCODING Specify the ENCODING of the .rc file. Default is 'cp1252'. ++ ++ -h TYPE Specify the TYPE attribute for HTML structures. ++ Default is 'tr_html'. ++ ++ -u ENCODING Specify the ENCODING of HTML files. Default is 'utf-8'. ++ ++ -n MATCH Specify the regular expression to match in comments that will ++ indicate that the resource the comment belongs to is not ++ translateable. Default is 'Not locali(s|z)able'. ++ ++ -r GRDFILE Specify that GRDFILE should be used as a "role model" for ++ any placeholders that otherwise would have had TODO names. ++ This attempts to find an identical message in the GRDFILE ++ and uses that instead of the automatically placeholderized ++ message. ++ ++ --pre CLASS Specify an optional, fully qualified classname, which ++ has to be a subclass of grit.tool.PreProcessor, to ++ run on the text of the RC file before conversion occurs. ++ This can be used to support constructs in the RC files ++ that GRIT cannot handle on its own. ++ ++ --post CLASS Specify an optional, fully qualified classname, which ++ has to be a subclass of grit.tool.PostProcessor, to ++ run on the text of the converted RC file. ++ This can be used to alter the content of the RC file ++ based on the conversion that occured. ++ ++For menus, dialogs and version info, the .grd file will refer to the original ++.rc file. Once conversion is complete, you can strip the original .rc file ++of its string table and all comments as these will be available in the .grd ++file. ++ ++Note that this tool WILL NOT obey C preprocessor rules, so even if something ++is #if 0-ed out it will still be included in the output of this tool ++Therefore, if your .rc file contains sections like this, you should run the ++C preprocessor on the .rc file or manually edit it before using this tool. ++''' ++ ++ def ShortDescription(self): ++ return 'A tool for converting .rc source files to .grd files.' ++ ++ def __init__(self): ++ self.input_encoding = 'cp1252' ++ self.html_type = 'tr_html' ++ self.html_encoding = 'utf-8' ++ self.not_localizable_re = re.compile('Not locali(s|z)able') ++ self.role_model = None ++ self.pre_process = None ++ self.post_process = None ++ ++ def ParseOptions(self, args, help_func=None): ++ '''Given a list of arguments, set this object's options and return ++ all non-option arguments. ++ ''' ++ (own_opts, args) = getopt.getopt(args, 'e:h:u:n:r', ++ ('help', 'pre=', 'post=')) ++ for (key, val) in own_opts: ++ if key == '-e': ++ self.input_encoding = val ++ elif key == '-h': ++ self.html_type = val ++ elif key == '-u': ++ self.html_encoding = val ++ elif key == '-n': ++ self.not_localizable_re = re.compile(val) ++ elif key == '-r': ++ self.role_model = grd_reader.Parse(val) ++ elif key == '--pre': ++ self.pre_process = val ++ elif key == '--post': ++ self.post_process = val ++ elif key == '--help': ++ if help_func is None: ++ self.ShowUsage() ++ else: ++ help_func() ++ sys.exit(0) ++ return args ++ ++ def Run(self, opts, args): ++ args = self.ParseOptions(args) ++ if len(args) != 1: ++ print('This tool takes a single tool-specific argument, the path to the\n' ++ '.rc file to process.') ++ return 2 ++ self.SetOptions(opts) ++ ++ path = args[0] ++ out_path = os.path.join(util.dirname(path), ++ os.path.splitext(os.path.basename(path))[0] + '.grd') ++ ++ rctext = util.ReadFile(path, self.input_encoding) ++ grd_text = six.text_type(self.Process(rctext, path)) ++ with util.WrapOutputStream(open(out_path, 'wb'), 'utf-8') as outfile: ++ outfile.write(grd_text) ++ ++ print('Wrote output file %s.\nPlease check for TODO items in the file.' % ++ (out_path,)) ++ ++ ++ def Process(self, rctext, rc_path): ++ '''Processes 'rctext' and returns a resource tree corresponding to it. ++ ++ Args: ++ rctext: complete text of the rc file ++ rc_path: 'resource\resource.rc' ++ ++ Return: ++ grit.node.base.Node subclass ++ ''' ++ ++ if self.pre_process: ++ preprocess_class = util.NewClassInstance(self.pre_process, ++ preprocess_interface.PreProcessor) ++ if preprocess_class: ++ rctext = preprocess_class.Process(rctext, rc_path) ++ else: ++ self.Out( ++ 'PreProcessing class could not be found. Skipping preprocessing.\n') ++ ++ # Start with a basic skeleton for the .grd file ++ root = grd_reader.Parse(StringIO( ++ ''' ++ ++ ++ ++ ++ ++ ++ ++ ++ '''), util.dirname(rc_path)) ++ includes = root.children[2].children[0] ++ structures = root.children[2].children[1] ++ messages = root.children[2].children[2] ++ assert (isinstance(includes, grit.node.empty.IncludesNode) and ++ isinstance(structures, grit.node.empty.StructuresNode) and ++ isinstance(messages, grit.node.empty.MessagesNode)) ++ ++ self.AddIncludes(rctext, includes) ++ self.AddStructures(rctext, structures, os.path.basename(rc_path)) ++ self.AddMessages(rctext, messages) ++ ++ self.VerboseOut('Validating that all IDs are unique...\n') ++ root.ValidateUniqueIds() ++ self.ExtraVerboseOut('Done validating that all IDs are unique.\n') ++ ++ if self.post_process: ++ postprocess_class = util.NewClassInstance(self.post_process, ++ postprocess_interface.PostProcessor) ++ if postprocess_class: ++ root = postprocess_class.Process(rctext, rc_path, root) ++ else: ++ self.Out( ++ 'PostProcessing class could not be found. Skipping postprocessing.\n') ++ ++ return root ++ ++ ++ def IsHtml(self, res_type, fname): ++ '''Check whether both the type and file extension indicate HTML''' ++ fext = fname.split('.')[-1].lower() ++ return res_type == 'HTML' and fext in ('htm', 'html') ++ ++ ++ def AddIncludes(self, rctext, node): ++ '''Scans 'rctext' for included resources (e.g. BITMAP, ICON) and ++ adds each included resource as an child node of 'node'.''' ++ for m in _FILE_REF.finditer(rctext): ++ id = m.group('id') ++ res_type = m.group('type').upper() ++ fname = rc.Section.UnEscape(m.group('file')) ++ assert fname.find('\n') == -1 ++ if not self.IsHtml(res_type, fname): ++ self.VerboseOut('Processing %s with ID %s (filename: %s)\n' % ++ (res_type, id, fname)) ++ node.AddChild(include.IncludeNode.Construct(node, id, res_type, fname)) ++ ++ ++ def AddStructures(self, rctext, node, rc_filename): ++ '''Scans 'rctext' for structured resources (e.g. menus, dialogs, version ++ information resources and HTML templates) and adds each as a ++ child of 'node'.''' ++ # First add HTML includes ++ for m in _FILE_REF.finditer(rctext): ++ id = m.group('id') ++ res_type = m.group('type').upper() ++ fname = rc.Section.UnEscape(m.group('file')) ++ if self.IsHtml(type, fname): ++ node.AddChild(structure.StructureNode.Construct( ++ node, id, self.html_type, fname, self.html_encoding)) ++ ++ # Then add all RC includes ++ def AddStructure(res_type, id): ++ self.VerboseOut('Processing %s with ID %s\n' % (res_type, id)) ++ node.AddChild(structure.StructureNode.Construct(node, id, res_type, ++ rc_filename, ++ encoding=self.input_encoding)) ++ for m in _MENU.finditer(rctext): ++ AddStructure('menu', m.group('id')) ++ for m in _DIALOG.finditer(rctext): ++ AddStructure('dialog', m.group('id')) ++ for m in _VERSIONINFO.finditer(rctext): ++ AddStructure('version', m.group('id')) ++ ++ ++ def AddMessages(self, rctext, node): ++ '''Scans 'rctext' for all messages in string tables, preprocesses them as ++ much as possible for placeholders (e.g. messages containing $1, $2 or %s, %d ++ type format specifiers get those specifiers replaced with placeholders, and ++ HTML-formatted messages get run through the HTML-placeholderizer). Adds ++ each message as a node child of 'node'.''' ++ for tm in _STRING_TABLE.finditer(rctext): ++ table = tm.group('body') ++ for mm in _MESSAGE.finditer(table): ++ comment_block = mm.group('comment') ++ comment_text = [] ++ for cm in _COMMENT_TEXT.finditer(comment_block): ++ comment_text.append(cm.group('text')) ++ comment_text = ' '.join(comment_text) ++ ++ id = mm.group('id') ++ text = rc.Section.UnEscape(mm.group('text')) ++ ++ self.VerboseOut('Processing message %s (text: "%s")\n' % (id, text)) ++ ++ msg_obj = self.Placeholderize(text) ++ ++ # Messages that contain only placeholders do not need translation. ++ is_translateable = False ++ for item in msg_obj.GetContent(): ++ if isinstance(item, six.string_types): ++ if not _WHITESPACE_ONLY.match(item): ++ is_translateable = True ++ ++ if self.not_localizable_re.search(comment_text): ++ is_translateable = False ++ ++ message_meaning = '' ++ internal_comment = '' ++ ++ # If we have a "role model" (existing GRD file) and this node exists ++ # in the role model, use the description, meaning and translateable ++ # attributes from the role model. ++ if self.role_model: ++ role_node = self.role_model.GetNodeById(id) ++ if role_node: ++ is_translateable = role_node.IsTranslateable() ++ message_meaning = role_node.attrs['meaning'] ++ comment_text = role_node.attrs['desc'] ++ internal_comment = role_node.attrs['internal_comment'] ++ ++ # For nontranslateable messages, we don't want the complexity of ++ # placeholderizing everything. ++ if not is_translateable: ++ msg_obj = tclib.Message(text=text) ++ ++ msg_node = message.MessageNode.Construct(node, msg_obj, id, ++ desc=comment_text, ++ translateable=is_translateable, ++ meaning=message_meaning) ++ msg_node.attrs['internal_comment'] = internal_comment ++ ++ node.AddChild(msg_node) ++ self.ExtraVerboseOut('Done processing message %s\n' % id) ++ ++ ++ def Placeholderize(self, text): ++ '''Creates a tclib.Message object from 'text', attempting to recognize ++ a few different formats of text that can be automatically placeholderized ++ (HTML code, printf-style format strings, and FormatMessage-style format ++ strings). ++ ''' ++ ++ try: ++ # First try HTML placeholderizing. ++ # TODO(joi) Allow use of non-TotalRecall flavors of HTML placeholderizing ++ msg = tr_html.HtmlToMessage(text, True) ++ for item in msg.GetContent(): ++ if not isinstance(item, six.string_types): ++ return msg # Contained at least one placeholder, so we're done ++ ++ # HTML placeholderization didn't do anything, so try to find printf or ++ # FormatMessage format specifiers and change them into placeholders. ++ msg = tclib.Message() ++ parts = _FORMAT_SPECIFIER.split(text) ++ todo_counter = 1 # We make placeholder IDs 'TODO_0001' etc. ++ for part in parts: ++ if _FORMAT_SPECIFIER.match(part): ++ msg.AppendPlaceholder(tclib.Placeholder( ++ 'TODO_%04d' % todo_counter, part, 'TODO')) ++ todo_counter += 1 ++ elif part != '': ++ msg.AppendText(part) ++ ++ if self.role_model and len(parts) > 1: # there are TODO placeholders ++ role_model_msg = self.role_model.UberClique().BestCliqueByOriginalText( ++ msg.GetRealContent(), '') ++ if role_model_msg: ++ # replace wholesale to get placeholder names and examples ++ msg = role_model_msg ++ ++ return msg ++ except: ++ print('Exception processing message with text "%s"' % text) ++ raise +diff --git a/tools/grit/grit/tool/rc2grd_unittest.py b/tools/grit/grit/tool/rc2grd_unittest.py +new file mode 100644 +index 0000000000..6d53794c27 +--- /dev/null ++++ b/tools/grit/grit/tool/rc2grd_unittest.py +@@ -0,0 +1,163 @@ ++#!/usr/bin/env python ++# Copyright (c) 2012 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++'''Unit tests for grit.tool.rc2grd''' ++ ++from __future__ import print_function ++ ++import os ++import sys ++if __name__ == '__main__': ++ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) ++ ++import re ++import unittest ++ ++from six import StringIO ++ ++from grit import grd_reader ++from grit import util ++from grit.node import base ++from grit.tool import rc2grd ++ ++ ++class Rc2GrdUnittest(unittest.TestCase): ++ def testPlaceholderize(self): ++ tool = rc2grd.Rc2Grd() ++ original = "Hello %s, how are you? I'm $1 years old!" ++ msg = tool.Placeholderize(original) ++ self.failUnless(msg.GetPresentableContent() == "Hello TODO_0001, how are you? I'm TODO_0002 years old!") ++ self.failUnless(msg.GetRealContent() == original) ++ ++ def testHtmlPlaceholderize(self): ++ tool = rc2grd.Rc2Grd() ++ original = "Hello [USERNAME], how are you? I'm [AGE] years old!" ++ msg = tool.Placeholderize(original) ++ self.failUnless(msg.GetPresentableContent() == ++ "Hello BEGIN_BOLDX_USERNAME_XEND_BOLD, how are you? I'm X_AGE_X years old!") ++ self.failUnless(msg.GetRealContent() == original) ++ ++ def testMenuWithoutWhitespaceRegression(self): ++ # There was a problem in the original regular expression for parsing out ++ # menu sections, that would parse the following block of text as a single ++ # menu instead of two. ++ two_menus = ''' ++// Hyper context menus ++IDR_HYPERMENU_FOLDER MENU ++BEGIN ++ POPUP "HyperFolder" ++ BEGIN ++ MENUITEM "Open Containing Folder", IDM_OPENFOLDER ++ END ++END ++ ++IDR_HYPERMENU_FILE MENU ++BEGIN ++ POPUP "HyperFile" ++ BEGIN ++ MENUITEM "Open Folder", IDM_OPENFOLDER ++ END ++END ++ ++''' ++ self.failUnless(len(rc2grd._MENU.findall(two_menus)) == 2) ++ ++ def testRegressionScriptWithTranslateable(self): ++ tool = rc2grd.Rc2Grd() ++ ++ # test rig ++ class DummyNode(base.Node): ++ def AddChild(self, item): ++ self.node = item ++ verbose = False ++ extra_verbose = False ++ tool.not_localizable_re = re.compile('') ++ tool.o = DummyNode() ++ ++ rc_text = '''STRINGTABLE\nBEGIN\nID_BINGO ""\nEND\n''' ++ tool.AddMessages(rc_text, tool.o) ++ self.failUnless(tool.o.node.GetCdata().find('Set As Homepage') != -1) ++ ++ # TODO(joi) Improve the HTML parser to support translateables inside ++ # ', -+ strip_whitespace=True) -+ -+ def InlineCSSText(text, css_filepath): -+ """Helper function that inlines external resources in CSS text""" -+ filepath = os.path.dirname(css_filepath) -+ # Allow custom modifications before inlining images. -+ if rewrite_function: -+ text = rewrite_function(filepath, text, distribution) -+ text = InlineCSSImages(text, filepath) -+ return InlineCSSImports(text, filepath) -+ -+ def InlineCSSFile(src_match, pattern, base_path=input_filepath): -+ """Helper function to inline external CSS files. -+ -+ Args: -+ src_match: A regular expression match with a named group named "filename". -+ pattern: The pattern to replace with the contents of the CSS file. -+ base_path: The base path to use for resolving the CSS file. -+ -+ Returns: -+ The text that should replace the reference to the CSS file. -+ """ -+ filepath = GetFilepath(src_match, base_path) -+ if filepath is None: -+ return src_match.group(0) -+ -+ # Even if names_only is set, the CSS file needs to be opened, because it -+ # can link to images that need to be added to the file set. -+ inlined_files.add(filepath) -+ -+ # Inline stylesheets included in this css file. -+ text = _INCLUDE_RE.sub(InlineIncludeFiles, util.ReadFile(filepath, 'utf-8')) -+ # When resolving CSS files we need to pass in the path so that relative URLs -+ # can be resolved. -+ -+ return pattern % InlineCSSText(text, filepath) -+ -+ def GetUrlRegexString(postfix=''): -+ """Helper function that returns a string for a regex that matches url('') -+ but not url([[ ]]) or url({{ }}). Appends |postfix| to group names. -+ """ -+ url_re = (r'url\((?!\[\[|{{)(?P"|\'|)(?P[^"\'()]*)' -+ r'(?P=q%s)\)') -+ return url_re % (postfix, postfix, postfix) -+ -+ def InlineCSSImages(text, filepath=input_filepath): -+ """Helper function that inlines external images in CSS backgrounds.""" -+ # Replace contents of url() for css attributes: content, background, -+ # or *-image. -+ property_re = r'(content|background|[\w-]*-image):[^;]*' -+ # Replace group names to prevent duplicates when forming value_re. -+ image_set_value_re = (r'image-set\(([ ]*' + GetUrlRegexString('2') + -+ r'[ ]*[0-9.]*x[ ]*(,[ ]*)?)+\)') -+ value_re = '(%s|%s)' % (GetUrlRegexString(), image_set_value_re) -+ css_re = property_re + value_re -+ return re.sub(css_re, lambda m: InlineCSSUrls(m, filepath), text) -+ -+ def InlineCSSUrls(src_match, filepath=input_filepath): -+ """Helper function that inlines each url on a CSS image rule match.""" -+ # Replace contents of url() references in matches. -+ return re.sub(GetUrlRegexString(), -+ lambda m: SrcReplace(m, filepath), -+ src_match.group(0)) -+ -+ def InlineCSSImports(text, filepath=input_filepath): -+ """Helper function that inlines CSS files included via the @import -+ directive. -+ """ -+ return re.sub(r'@import\s+' + GetUrlRegexString() + r';', -+ lambda m: InlineCSSFile(m, '%s', filepath), -+ text) -+ -+ -+ flat_text = util.ReadFile(input_filename, 'utf-8') -+ -+ # Check conditional elements, remove unsatisfied ones from the file. We do -+ # this twice. The first pass is so that we don't even bother calling -+ # InlineScript, InlineCSSFile and InlineIncludeFiles on text we're eventually -+ # going to throw out anyway. -+ flat_text = CheckConditionalElements(flat_text) -+ -+ flat_text = _INCLUDE_RE.sub(InlineIncludeFiles, flat_text) -+ -+ if not preprocess_only: -+ if strip_whitespace: -+ flat_text = minifier.Minify(flat_text.encode('utf-8'), -+ input_filename).decode('utf-8') -+ -+ if not allow_external_script: -+ # We need to inline css and js before we inline images so that image -+ # references gets inlined in the css and js -+ flat_text = re.sub(r'', -+ InlineScript, -+ flat_text) -+ -+ flat_text = _STYLESHEET_RE.sub( -+ lambda m: InlineCSSFile(m, ''), -+ flat_text) -+ -+ # Check conditional elements, second pass. This catches conditionals in any -+ # of the text we just inlined. -+ flat_text = CheckConditionalElements(flat_text) -+ -+ # Allow custom modifications before inlining images. -+ if rewrite_function: -+ flat_text = rewrite_function(input_filepath, flat_text, distribution) -+ -+ if not preprocess_only: -+ flat_text = _SRC_RE.sub(SrcReplace, flat_text) -+ flat_text = _SRCSET_RE.sub(SrcsetReplace, flat_text) -+ -+ # TODO(arv): Only do this inside -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(util.normpath(filename))) -+ -+ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ -+ tmp_dir.CleanUp() -+ -+ def testInlineIgnoresPolymerBindings(self): -+ '''Tests that polymer bindings are ignored when inlining. -+ ''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+
    -+
    -+
    -+ -+ -+ ''', -+ -+ 'test.css': ''' -+ .image { -+ background: url('test.png'); -+ background-image: url([[ignoreMe]]); -+ background-image: image-set(url({{alsoMe}}), 1x); -+ background-image: image-set( -+ url({{ignore}}) 1x, -+ url('test.png') 2x); -+ } -+ ''', -+ -+ 'test.png': 'PNG DATA' -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+
    -+
    -+
    -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(util.normpath(filename))) -+ -+ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ -+ tmp_dir.CleanUp() -+ -+ def testInlineCSSWithIncludeDirective(self): -+ '''Tests that include directive in external css files also inlined''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ ''', -+ -+ 'foo.css': '''''', -+ -+ 'style.css': ''' -+ -+ blink { -+ display: none; -+ } -+ ''', -+ 'style2.css': '''h1 {}''', -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testCssIncludedFileNames(self): -+ '''Tests that all included files from css are returned''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ ''', -+ -+ 'test.css': ''' -+ -+ ''', -+ -+ 'test2.css': ''' -+ -+ .image { -+ background: url('test.png'); -+ } -+ ''', -+ -+ 'test3.css': '''h1 {}''', -+ -+ 'test.png': 'PNG DATA' -+ } -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ resources = html_inline.GetResourceFilenames(tmp_dir.GetPath('index.html'), -+ None) -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ tmp_dir.CleanUp() -+ -+ def testInlineCSSLinks(self): -+ '''Tests that only CSS files referenced via relative URLs are inlined.''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ ''', -+ -+ 'foo.css': ''' -+ @import url(chrome://resources/blurp.css); -+ blink { -+ display: none; -+ } -+ ''', -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testFilenameVariableExpansion(self): -+ '''Tests that variables are expanded in filenames before inlining.''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ ''', -+ 'style1.css': '''h1 {}''', -+ 'tmpl1.html': '''

    ''', -+ 'script1.js': '''console.log('hello');''', -+ 'img1.png': '''abc''', -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+

    -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ def replacer(var, repl): -+ return lambda filename: filename.replace('[%s]' % var, repl) -+ -+ # Test normal inlining. -+ result = html_inline.DoInline( -+ tmp_dir.GetPath('index.html'), -+ None, -+ filename_expansion_function=replacer('WHICH', '1')) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ -+ # Test names-only inlining. -+ result = html_inline.DoInline( -+ tmp_dir.GetPath('index.html'), -+ None, -+ names_only=True, -+ filename_expansion_function=replacer('WHICH', '1')) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ tmp_dir.CleanUp() -+ -+ def testWithCloseTags(self): -+ '''Tests that close tags are removed.''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''', -+ 'style1.css': '''h1 {}''', -+ 'style2.css': '''h2 {}''', -+ 'tmpl1.html': '''

    ''', -+ 'tmpl2.html': '''

    ''', -+ 'script1.js': '''console.log('hello');''', -+ 'img1.png': '''abc''', -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+ -+ -+

    -+

    -+

    -+ -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ # Test normal inlining. -+ result = html_inline.DoInline( -+ tmp_dir.GetPath('index.html'), -+ None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testCommentedJsInclude(self): -+ '''Tests that works inside a comment.''' -+ -+ files = { -+ 'include.js': '// ', -+ 'other.js': '// Copyright somebody\nalert(1);', -+ } -+ -+ expected_inlined = '// Copyright somebody\nalert(1);' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ result = html_inline.DoInline(tmp_dir.GetPath('include.js'), None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('include.js')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testCommentedJsIf(self): -+ '''Tests that works inside a comment.''' -+ -+ files = { -+ 'if.js': ''' -+ // -+ yep(); -+ // -+ -+ // -+ nope(); -+ // -+ ''', -+ } -+ -+ expected_inlined = ''' -+ // -+ yep(); -+ // -+ -+ // -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ class FakeGrdNode(object): -+ def EvaluateCondition(self, cond): -+ return eval(cond) -+ -+ result = html_inline.DoInline(tmp_dir.GetPath('if.js'), FakeGrdNode()) -+ resources = result.inlined_files -+ -+ resources.add(tmp_dir.GetPath('if.js')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testImgSrcset(self): -+ '''Tests that img srcset="" attributes are converted.''' -+ -+ # Note that there is no space before "img10.png" and that -+ # "img11.png" has no descriptor. -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''', -+ 'img1.png': '''a1''', -+ 'img2.png': '''a2''', -+ 'img3.png': '''a3''', -+ 'img4.png': '''a4''', -+ 'img5.png': '''a5''', -+ 'img6.png': '''a6''', -+ 'img7.png': '''a7''', -+ 'img8.png': '''a8''', -+ 'img9.png': '''a9''', -+ 'img10.png': '''a10''', -+ 'img11.png': '''a11''', -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ # Test normal inlining. -+ result = html_inline.DoInline( -+ tmp_dir.GetPath('index.html'), -+ None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testImgSrcsetIgnoresI18n(self): -+ '''Tests that $i18n{...} strings are ignored when inlining. -+ ''' -+ -+ src_html = ''' -+ -+ -+ -+ -+ -+ -+ ''' -+ -+ files = { -+ 'index.html': src_html, -+ } -+ -+ expected_inlined = src_html -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(util.normpath(filename))) -+ -+ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testSourceSrcset(self): -+ '''Tests that source srcset="" attributes are converted.''' -+ -+ # Note that there is no space before "img10.png" and that -+ # "img11.png" has no descriptor. -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ -+ ''', -+ 'img1.png': '''a1''', -+ 'img2.png': '''a2''', -+ 'img3.png': '''a3''', -+ 'img4.png': '''a4''', -+ 'img5.png': '''a5''', -+ 'img6.png': '''a6''', -+ 'img7.png': '''a7''', -+ 'img8.png': '''a8''', -+ 'img9.png': '''a9''', -+ 'img10.png': '''a10''', -+ 'img11.png': '''a11''', -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+ -+ -+ ''' -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ # Test normal inlining. -+ result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ self.failUnlessEqual(expected_inlined, -+ util.FixLineEnd(result.inlined_data, '\n')) -+ tmp_dir.CleanUp() -+ -+ def testConditionalInclude(self): -+ '''Tests that output and dependency generation includes only files not'''\ -+ ''' blocked by macros.''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''', -+ 'img1.png': '''a1''', -+ 'img2.png': '''a2''', -+ 'img3.png': '''a3''', -+ 'img4.png': '''a4''', -+ 'img5.png': '''a5''', -+ 'img6.png': '''a6''', -+ 'img7.png': '''a7''', -+ 'img8.png': '''a8''', -+ 'img9.png': '''a9''', -+ 'img10.png': '''a10''', -+ } -+ -+ expected_inlined = ''' -+ -+ -+ -+ -+ -+ ''' -+ -+ expected_files = [ -+ 'index.html', -+ 'img1.png', -+ 'img2.png', -+ 'img3.png', -+ 'img7.png', -+ 'img8.png', -+ 'img9.png', -+ 'img10.png' -+ ] -+ -+ source_resources = set() -+ tmp_dir = util.TempDir(files) -+ for filename in expected_files: -+ source_resources.add(tmp_dir.GetPath(filename)) -+ -+ class FakeGrdNode(object): -+ def EvaluateCondition(self, cond): -+ return eval(cond) -+ -+ # Test normal inlining. -+ result = html_inline.DoInline( -+ tmp_dir.GetPath('index.html'), -+ FakeGrdNode()) -+ resources = result.inlined_files -+ resources.add(tmp_dir.GetPath('index.html')) -+ self.failUnlessEqual(resources, source_resources) -+ -+ # ignore whitespace -+ expected_inlined = re.sub(r'\s+', ' ', expected_inlined) -+ actually_inlined = re.sub(r'\s+', ' ', -+ util.FixLineEnd(result.inlined_data, '\n')) -+ self.failUnlessEqual(expected_inlined, actually_inlined); -+ tmp_dir.CleanUp() -+ -+ def testPreprocessOnlyEvaluatesIncludeAndIf(self): -+ '''Tests that preprocess_only=true evaluates and only. ''' -+ -+ files = { -+ 'index.html': ''' -+ -+ -+ -+ -+ -+
    -+ -+
    -+ -+
    -+ -+ -+
    -+ -+
    -+    -+
    -+ -+
    -+
    -+ ''')) -+ html.Parse() -+ trans = html.Translate('en') -+ if (html.GetText() != trans): -+ self.fail() -+ -+ -+ def testHtmlToMessageWithBlockTags(self): -+ msg = tr_html.HtmlToMessage( -+ 'Hello

    Howdiebingo', True) -+ result = msg.GetPresentableContent() -+ self.failUnless( -+ result == 'HelloBEGIN_PARAGRAPHHowdieBEGIN_BLOCKbingoEND_BLOCK') -+ -+ msg = tr_html.HtmlToMessage( -+ 'Hello

    Howdie', True) -+ result = msg.GetPresentableContent() -+ self.failUnless( -+ result == 'HelloBEGIN_PARAGRAPHHowdieBEGIN_BLOCKbingoEND_BLOCK') -+ -+ -+ def testHtmlToMessageRegressions(self): -+ msg = tr_html.HtmlToMessage(' - ', True) -+ result = msg.GetPresentableContent() -+ self.failUnless(result == ' - ') -+ -+ -+ def testEscapeUnescaped(self): -+ text = '©  & "<hello>"' -+ unescaped = util.UnescapeHtml(text) -+ self.failUnless(unescaped == u'\u00a9\u00a0 & ""') -+ escaped_unescaped = util.EscapeHtml(unescaped, True) -+ self.failUnless(escaped_unescaped == -+ u'\u00a9\u00a0 & "<hello>"') -+ -+ def testRegressionCjkHtmlFile(self): -+ # TODO(joi) Fix this problem where unquoted attributes that -+ # have a value that is CJK characters causes the regular expression -+ # match never to return. (culprit is the _ELEMENT regexp( -+ if False: -+ html = self.HtmlFromFileWithManualCheck(util.PathFromRoot( -+ r'grit/testdata/ko_oem_enable_bug.html')) -+ self.failUnless(True) -+ -+ def testRegressionCpuHang(self): -+ # If this regression occurs, the unit test will never return -+ html = tr_html.TrHtml(StringIO( -+ '''''')) -+ html.Parse() -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/gather/txt.py b/tools/grit/grit/gather/txt.py -new file mode 100644 -index 0000000000..e5c10abc28 ---- /dev/null -+++ b/tools/grit/grit/gather/txt.py -@@ -0,0 +1,38 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Supports making amessage from a text file. -+''' -+ -+from __future__ import print_function -+ -+from grit.gather import interface -+from grit import tclib -+ -+ -+class TxtFile(interface.GathererBase): -+ '''A text file gatherer. Very simple, all text from the file becomes a -+ single clique. -+ ''' -+ -+ def Parse(self): -+ self.text_ = self._LoadInputFile() -+ self.clique_ = self.uberclique.MakeClique(tclib.Message(text=self.text_)) -+ -+ def GetText(self): -+ '''Returns the text of what is being gathered.''' -+ return self.text_ -+ -+ def GetTextualIds(self): -+ return [self.extkey] -+ -+ def GetCliques(self): -+ '''Returns the MessageClique objects for all translateable portions.''' -+ return [self.clique_] -+ -+ def Translate(self, lang, pseudo_if_not_available=True, -+ skeleton_gatherer=None, fallback_to_english=False): -+ return self.clique_.MessageForLanguage(lang, -+ pseudo_if_not_available, -+ fallback_to_english).GetRealContent() -diff --git a/tools/grit/grit/gather/txt_unittest.py b/tools/grit/grit/gather/txt_unittest.py -new file mode 100644 -index 0000000000..abb9ed98d7 ---- /dev/null -+++ b/tools/grit/grit/gather/txt_unittest.py -@@ -0,0 +1,35 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for TxtFile gatherer''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+ -+import unittest -+ -+from six import StringIO -+ -+from grit.gather import txt -+ -+ -+class TxtUnittest(unittest.TestCase): -+ def testGather(self): -+ input = StringIO('Hello there\nHow are you?') -+ gatherer = txt.TxtFile(input) -+ gatherer.Parse() -+ self.failUnless(gatherer.GetText() == input.getvalue()) -+ self.failUnless(len(gatherer.GetCliques()) == 1) -+ self.failUnless(gatherer.GetCliques()[0].GetMessage().GetRealContent() == -+ input.getvalue()) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/grd_reader.py b/tools/grit/grit/grd_reader.py -new file mode 100644 -index 0000000000..b7bb782977 ---- /dev/null -+++ b/tools/grit/grit/grd_reader.py -@@ -0,0 +1,238 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Class for reading GRD files into memory, without processing them. -+''' -+ -+from __future__ import print_function -+ -+import os.path -+import sys -+import xml.sax -+import xml.sax.handler -+ -+import six -+ -+from grit import exception -+from grit import util -+from grit.node import mapping -+from grit.node import misc -+ -+ -+class StopParsingException(Exception): -+ '''An exception used to stop parsing.''' -+ pass -+ -+ -+class GrdContentHandler(xml.sax.handler.ContentHandler): -+ def __init__(self, stop_after, debug, dir, defines, tags_to_ignore, -+ target_platform, source): -+ # Invariant of data: -+ # 'root' is the root of the parse tree being created, or None if we haven't -+ # parsed out any elements. -+ # 'stack' is the a stack of elements that we push new nodes onto and -+ # pop from when they finish parsing, or [] if we are not currently parsing. -+ # 'stack[-1]' is the top of the stack. -+ self.root = None -+ self.stack = [] -+ self.stop_after = stop_after -+ self.debug = debug -+ self.dir = dir -+ self.defines = defines -+ self.tags_to_ignore = tags_to_ignore or set() -+ self.ignore_depth = 0 -+ self.target_platform = target_platform -+ self.source = source -+ -+ def startElement(self, name, attrs): -+ if self.ignore_depth or name in self.tags_to_ignore: -+ if self.debug and self.ignore_depth == 0: -+ print("Ignoring element %s and its children" % name) -+ self.ignore_depth += 1 -+ return -+ -+ if self.debug: -+ attr_list = ' '.join('%s="%s"' % kv for kv in attrs.items()) -+ print("Starting parsing of element %s with attributes %r" % -+ (name, attr_list or '(none)')) -+ -+ typeattr = attrs.get('type') -+ node = mapping.ElementToClass(name, typeattr)() -+ node.source = self.source -+ -+ if self.stack: -+ self.stack[-1].AddChild(node) -+ node.StartParsing(name, self.stack[-1]) -+ else: -+ assert self.root is None -+ self.root = node -+ if isinstance(self.root, misc.GritNode): -+ if self.target_platform: -+ self.root.SetTargetPlatform(self.target_platform) -+ node.StartParsing(name, None) -+ if self.defines: -+ node.SetDefines(self.defines) -+ self.stack.append(node) -+ -+ for attr, attrval in attrs.items(): -+ node.HandleAttribute(attr, attrval) -+ -+ def endElement(self, name): -+ if self.ignore_depth: -+ self.ignore_depth -= 1 -+ return -+ -+ if name == 'part': -+ partnode = self.stack[-1] -+ partnode.started_inclusion = True -+ # Add the contents of the sub-grd file as children of the node. -+ partname = os.path.join(self.dir, partnode.GetInputPath()) -+ # Check the GRDP file exists. -+ if not os.path.exists(partname): -+ raise exception.FileNotFound(partname) -+ # Exceptions propagate to the handler in grd_reader.Parse(). -+ oldsource = self.source -+ try: -+ self.source = partname -+ xml.sax.parse(partname, GrdPartContentHandler(self)) -+ finally: -+ self.source = oldsource -+ -+ if self.debug: -+ print("End parsing of element %s" % name) -+ self.stack.pop().EndParsing() -+ -+ if name == self.stop_after: -+ raise StopParsingException() -+ -+ def characters(self, content): -+ if self.ignore_depth == 0: -+ if self.stack[-1]: -+ self.stack[-1].AppendContent(content) -+ -+ def ignorableWhitespace(self, whitespace): -+ # TODO(joi): This is not supported by expat. Should use a different XML -+ # parser? -+ pass -+ -+ -+class GrdPartContentHandler(xml.sax.handler.ContentHandler): -+ def __init__(self, parent): -+ self.parent = parent -+ self.depth = 0 -+ -+ def startElement(self, name, attrs): -+ if self.depth: -+ self.parent.startElement(name, attrs) -+ else: -+ if name != 'grit-part': -+ raise exception.MissingElement("root tag must be ") -+ if attrs: -+ raise exception.UnexpectedAttribute( -+ " tag must not have attributes") -+ self.depth += 1 -+ -+ def endElement(self, name): -+ self.depth -= 1 -+ if self.depth: -+ self.parent.endElement(name) -+ -+ def characters(self, content): -+ self.parent.characters(content) -+ -+ def ignorableWhitespace(self, whitespace): -+ self.parent.ignorableWhitespace(whitespace) -+ -+ -+def Parse(filename_or_stream, dir=None, stop_after=None, first_ids_file=None, -+ debug=False, defines=None, tags_to_ignore=None, target_platform=None, -+ predetermined_ids_file=None): -+ '''Parses a GRD file into a tree of nodes (from grit.node). -+ -+ If filename_or_stream is a stream, 'dir' should point to the directory -+ notionally containing the stream (this feature is only used in unit tests). -+ -+ If 'stop_after' is provided, the parsing will stop once the first node -+ with this name has been fully parsed (including all its contents). -+ -+ If 'debug' is true, lots of information about the parsing events will be -+ printed out during parsing of the file. -+ -+ If 'first_ids_file' is non-empty, it is used to override the setting for the -+ first_ids_file attribute of the root node. Note that the first_ids_file -+ parameter should be relative to the cwd, even though the first_ids_file -+ attribute of the node is relative to the grd file. -+ -+ If 'target_platform' is set, this is used to determine the target -+ platform of builds, instead of using |sys.platform|. -+ -+ Args: -+ filename_or_stream: './bla.xml' -+ dir: None (if filename_or_stream is a filename) or '.' -+ stop_after: 'inputs' -+ first_ids_file: 'GRIT_DIR/../gritsettings/resource_ids' -+ debug: False -+ defines: dictionary of defines, like {'chromeos': '1'} -+ target_platform: None or the value that would be returned by sys.platform -+ on your target platform. -+ predetermined_ids_file: File path to a file containing a pre-determined -+ mapping from resource names to resource ids which will be used to assign -+ resource ids to those resources. -+ -+ Return: -+ Subclass of grit.node.base.Node -+ -+ Throws: -+ grit.exception.Parsing -+ ''' -+ -+ if isinstance(filename_or_stream, six.string_types): -+ source = filename_or_stream -+ if dir is None: -+ dir = util.dirname(filename_or_stream) -+ else: -+ source = None -+ -+ handler = GrdContentHandler(stop_after=stop_after, debug=debug, dir=dir, -+ defines=defines, tags_to_ignore=tags_to_ignore, -+ target_platform=target_platform, source=source) -+ try: -+ xml.sax.parse(filename_or_stream, handler) -+ except StopParsingException: -+ assert stop_after -+ pass -+ except: -+ if not debug: -+ print("parse exception: run GRIT with the -x flag to debug .grd problems") -+ raise -+ -+ if handler.root.name != 'grit': -+ raise exception.MissingElement("root tag must be ") -+ -+ if hasattr(handler.root, 'SetOwnDir'): -+ # Fix up the base_dir so it is relative to the input file. -+ assert dir is not None -+ handler.root.SetOwnDir(dir) -+ -+ if isinstance(handler.root, misc.GritNode): -+ handler.root.SetPredeterminedIdsFile(predetermined_ids_file) -+ if first_ids_file: -+ # Make the path to the first_ids_file relative to the grd file, -+ # unless it begins with GRIT_DIR. -+ GRIT_DIR_PREFIX = 'GRIT_DIR' -+ if not (first_ids_file.startswith(GRIT_DIR_PREFIX) -+ and first_ids_file[len(GRIT_DIR_PREFIX)] in ['/', '\\']): -+ rel_dir = os.path.relpath(os.getcwd(), dir) -+ first_ids_file = util.normpath(os.path.join(rel_dir, first_ids_file)) -+ handler.root.attrs['first_ids_file'] = first_ids_file -+ # Assign first ids to the nodes that don't have them. -+ handler.root.AssignFirstIds(filename_or_stream, defines) -+ -+ return handler.root -+ -+ -+if __name__ == '__main__': -+ util.ChangeStdoutEncoding() -+ print(six.text_type(Parse(sys.argv[1]))) -diff --git a/tools/grit/grit/grd_reader_unittest.py b/tools/grit/grit/grd_reader_unittest.py -new file mode 100644 -index 0000000000..920a92f9c0 ---- /dev/null -+++ b/tools/grit/grit/grd_reader_unittest.py -@@ -0,0 +1,346 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grd_reader package''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -+ -+import unittest -+ -+import six -+from six import StringIO -+ -+from grit import exception -+from grit import grd_reader -+from grit import util -+from grit.node import empty -+from grit.node import message -+ -+ -+class GrdReaderUnittest(unittest.TestCase): -+ def testParsingAndXmlOutput(self): -+ input = u''' -+ -+ -+ -+ -+ -+ -+ -+ -+ Hello %sJoi, how are you doing today? -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+''' -+ pseudo_file = StringIO(input) -+ tree = grd_reader.Parse(pseudo_file, '.') -+ output = six.text_type(tree) -+ expected_output = input.replace(u' base_dir="."', u'') -+ self.assertEqual(expected_output, output) -+ self.failUnless(tree.GetNodeById('IDS_GREETING')) -+ -+ -+ def testStopAfter(self): -+ input = u''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+''' -+ pseudo_file = StringIO(input) -+ tree = grd_reader.Parse(pseudo_file, '.', stop_after='outputs') -+ # only an child -+ self.failUnless(len(tree.children) == 1) -+ self.failUnless(tree.children[0].name == 'outputs') -+ -+ def testLongLinesWithComments(self): -+ input = u''' -+ -+ -+ -+ -+ This is a very long line with no linebreaks yes yes it stretches on and on and on! -+ -+ -+ -+''' -+ pseudo_file = StringIO(input) -+ tree = grd_reader.Parse(pseudo_file, '.') -+ -+ greeting = tree.GetNodeById('IDS_GREETING') -+ self.failUnless(greeting.GetCliques()[0].GetMessage().GetRealContent() == -+ 'This is a very long line with no linebreaks yes yes it ' -+ 'stretches on and on and on!') -+ -+ def doTestAssignFirstIds(self, first_ids_path): -+ input = u''' -+ -+ -+ -+ -+ test -+ -+ -+ -+''' % first_ids_path -+ pseudo_file = StringIO(input) -+ grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), -+ '..') -+ fake_input_path = os.path.join( -+ grit_root_dir, "grit/testdata/chrome/app/generated_resources.grd") -+ root = grd_reader.Parse(pseudo_file, os.path.split(fake_input_path)[0]) -+ root.AssignFirstIds(fake_input_path, {}) -+ messages_node = root.children[0].children[0] -+ self.failUnless(isinstance(messages_node, empty.MessagesNode)) -+ self.failUnless(messages_node.attrs["first_id"] != -+ empty.MessagesNode().DefaultAttributes()["first_id"]) -+ -+ def testAssignFirstIds(self): -+ self.doTestAssignFirstIds("../../tools/grit/resource_ids") -+ -+ def testAssignFirstIdsUseGritDir(self): -+ self.doTestAssignFirstIds("GRIT_DIR/grit/testdata/tools/grit/resource_ids") -+ -+ def testAssignFirstIdsMultipleMessages(self): -+ """If there are multiple messages sections, the resource_ids file -+ needs to list multiple first_id values.""" -+ input = u''' -+ -+ -+ -+ -+ test -+ -+ -+ -+ -+ test2 -+ -+ -+ -+''' -+ pseudo_file = StringIO(input) -+ grit_root_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), -+ '..') -+ fake_input_path = os.path.join(grit_root_dir, "grit/testdata/test.grd") -+ -+ root = grd_reader.Parse(pseudo_file, os.path.split(fake_input_path)[0]) -+ root.AssignFirstIds(fake_input_path, {}) -+ messages_node = root.children[0].children[0] -+ self.assertTrue(isinstance(messages_node, empty.MessagesNode)) -+ self.assertEqual('100', messages_node.attrs["first_id"]) -+ messages_node = root.children[0].children[1] -+ self.assertTrue(isinstance(messages_node, empty.MessagesNode)) -+ self.assertEqual('10000', messages_node.attrs["first_id"]) -+ -+ def testUseNameForIdAndPpIfdef(self): -+ input = u''' -+ -+ -+ -+ -+ -+ Hello! -+ -+ -+ -+ -+''' -+ pseudo_file = StringIO(input) -+ root = grd_reader.Parse(pseudo_file, '.', defines={'hello': '1'}) -+ -+ # Check if the ID is set to the name. In the past, there was a bug -+ # that caused the ID to be a generated number. -+ hello = root.GetNodeById('IDS_HELLO') -+ self.failUnless(hello.GetCliques()[0].GetId() == 'IDS_HELLO') -+ -+ def testUseNameForIdWithIfElse(self): -+ input = u''' -+ -+ -+ -+ -+ -+ -+ Hello! -+ -+ -+ -+ -+ Yellow! -+ -+ -+ -+ -+ -+''' -+ pseudo_file = StringIO(input) -+ root = grd_reader.Parse(pseudo_file, '.', defines={'hello': '1'}) -+ -+ # Check if the ID is set to the name. In the past, there was a bug -+ # that caused the ID to be a generated number. -+ hello = root.GetNodeById('IDS_HELLO') -+ self.failUnless(hello.GetCliques()[0].GetId() == 'IDS_HELLO') -+ -+ def testPartInclusionAndCorrectSource(self): -+ arbitrary_path_grd = u'''\ -+ -+ test5 -+ ''' -+ tmp_dir = util.TempDir({'arbitrary_path.grp': arbitrary_path_grd}) -+ arbitrary_path_grd_file = tmp_dir.GetPath('arbitrary_path.grp') -+ top_grd = u'''\ -+ -+ -+ -+ -+ test -+ -+ -+ -+ -+ -+ ''' % arbitrary_path_grd_file -+ sub_grd = u'''\ -+ -+ test2 -+ -+ test3 -+ ''' -+ subsub_grd = u'''\ -+ -+ test4 -+ ''' -+ expected_output = u'''\ -+ -+ -+ -+ -+ test -+ -+ -+ -+ test2 -+ -+ -+ -+ test4 -+ -+ -+ -+ test3 -+ -+ -+ -+ -+ test5 -+ -+ -+ -+ -+ ''' % arbitrary_path_grd_file -+ -+ with util.TempDir({'sub.grp': sub_grd, -+ 'subsub.grp': subsub_grd}) as tmp_sub_dir: -+ output = grd_reader.Parse(StringIO(top_grd), -+ tmp_sub_dir.GetPath()) -+ correct_sources = { -+ 'IDS_TEST': None, -+ 'IDS_TEST2': tmp_sub_dir.GetPath('sub.grp'), -+ 'IDS_TEST3': tmp_sub_dir.GetPath('sub.grp'), -+ 'IDS_TEST4': tmp_sub_dir.GetPath('subsub.grp'), -+ 'IDS_TEST5': arbitrary_path_grd_file, -+ } -+ -+ for node in output.ActiveDescendants(): -+ with node: -+ if isinstance(node, message.MessageNode): -+ self.assertEqual(correct_sources[node.attrs.get('name')], node.source) -+ self.assertEqual(expected_output.split(), output.FormatXml().split()) -+ tmp_dir.CleanUp() -+ -+ def testPartInclusionFailure(self): -+ template = u''' -+ -+ -+ %s -+ -+ ''' -+ -+ part_failures = [ -+ (exception.UnexpectedContent, u'fnord'), -+ (exception.UnexpectedChild, -+ u''), -+ (exception.FileNotFound, u''), -+ ] -+ for raises, data in part_failures: -+ data = StringIO(template % data) -+ self.assertRaises(raises, grd_reader.Parse, data, '.') -+ -+ gritpart_failures = [ -+ (exception.UnexpectedAttribute, u''), -+ (exception.MissingElement, u''), -+ ] -+ for raises, data in gritpart_failures: -+ top_grd = StringIO(template % u'') -+ with util.TempDir({'bad.grp': data}) as temp_dir: -+ self.assertRaises(raises, grd_reader.Parse, top_grd, temp_dir.GetPath()) -+ -+ def testEarlyEnoughPlatformSpecification(self): -+ # This is a regression test for issue -+ # https://code.google.com/p/grit-i18n/issues/detail?id=23 -+ grd_text = u''' -+ -+ -+ -+ -+ foo -+ -+ -+ -+ boo -+ -+ -+ -+ ''' % sys.platform -+ with util.TempDir({}) as temp_dir: -+ grd_reader.Parse(StringIO(grd_text), temp_dir.GetPath(), -+ target_platform='android') -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/grit-todo.xml b/tools/grit/grit/grit-todo.xml -new file mode 100644 -index 0000000000..b8c20fdfad ---- /dev/null -+++ b/tools/grit/grit/grit-todo.xml -@@ -0,0 +1,62 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/grit_runner.py b/tools/grit/grit/grit_runner.py -new file mode 100644 -index 0000000000..26aa0d58c4 ---- /dev/null -+++ b/tools/grit/grit/grit_runner.py -@@ -0,0 +1,334 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""Command processor for GRIT. This is the script you invoke to run the various -+GRIT tools. -+""" -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -+ -+import getopt -+ -+from grit import util -+ -+import grit.extern.FP -+ -+# Tool info factories; these import only within each factory to avoid -+# importing most of the GRIT code until required. -+def ToolFactoryBuild(): -+ import grit.tool.build -+ return grit.tool.build.RcBuilder() -+ -+def ToolFactoryBuildInfo(): -+ import grit.tool.buildinfo -+ return grit.tool.buildinfo.DetermineBuildInfo() -+ -+def ToolFactoryCount(): -+ import grit.tool.count -+ return grit.tool.count.CountMessage() -+ -+def ToolFactoryDiffStructures(): -+ import grit.tool.diff_structures -+ return grit.tool.diff_structures.DiffStructures() -+ -+def ToolFactoryMenuTranslationsFromParts(): -+ import grit.tool.menu_from_parts -+ return grit.tool.menu_from_parts.MenuTranslationsFromParts() -+ -+def ToolFactoryNewGrd(): -+ import grit.tool.newgrd -+ return grit.tool.newgrd.NewGrd() -+ -+def ToolFactoryResizeDialog(): -+ import grit.tool.resize -+ return grit.tool.resize.ResizeDialog() -+ -+def ToolFactoryRc2Grd(): -+ import grit.tool.rc2grd -+ return grit.tool.rc2grd.Rc2Grd() -+ -+def ToolFactoryTest(): -+ import grit.tool.test -+ return grit.tool.test.TestTool() -+ -+def ToolFactoryTranslationToTc(): -+ import grit.tool.transl2tc -+ return grit.tool.transl2tc.TranslationToTc() -+ -+def ToolFactoryUnit(): -+ import grit.tool.unit -+ return grit.tool.unit.UnitTestTool() -+ -+ -+def ToolFactoryUpdateResourceIds(): -+ import grit.tool.update_resource_ids -+ return grit.tool.update_resource_ids.UpdateResourceIds() -+ -+ -+def ToolFactoryXmb(): -+ import grit.tool.xmb -+ return grit.tool.xmb.OutputXmb() -+ -+def ToolAndroid2Grd(): -+ import grit.tool.android2grd -+ return grit.tool.android2grd.Android2Grd() -+ -+# Keys for the following map -+_FACTORY = 1 -+_REQUIRES_INPUT = 2 -+_HIDDEN = 3 # optional key - presence indicates tool is hidden -+ -+# Maps tool names to the tool's module. Done as a list of (key, value) tuples -+# instead of a map to preserve ordering. -+_TOOLS = [ -+ ['android2grd', { -+ _FACTORY: ToolAndroid2Grd, -+ _REQUIRES_INPUT: False -+ }], -+ ['build', { -+ _FACTORY: ToolFactoryBuild, -+ _REQUIRES_INPUT: True -+ }], -+ ['buildinfo', { -+ _FACTORY: ToolFactoryBuildInfo, -+ _REQUIRES_INPUT: True -+ }], -+ ['count', { -+ _FACTORY: ToolFactoryCount, -+ _REQUIRES_INPUT: True -+ }], -+ [ -+ 'menufromparts', -+ { -+ _FACTORY: ToolFactoryMenuTranslationsFromParts, -+ _REQUIRES_INPUT: True, -+ _HIDDEN: True -+ } -+ ], -+ ['newgrd', { -+ _FACTORY: ToolFactoryNewGrd, -+ _REQUIRES_INPUT: False -+ }], -+ ['rc2grd', { -+ _FACTORY: ToolFactoryRc2Grd, -+ _REQUIRES_INPUT: False -+ }], -+ ['resize', { -+ _FACTORY: ToolFactoryResizeDialog, -+ _REQUIRES_INPUT: True -+ }], -+ ['sdiff', { -+ _FACTORY: ToolFactoryDiffStructures, -+ _REQUIRES_INPUT: False -+ }], -+ ['test', { -+ _FACTORY: ToolFactoryTest, -+ _REQUIRES_INPUT: True, -+ _HIDDEN: True -+ }], -+ [ -+ 'transl2tc', -+ { -+ _FACTORY: ToolFactoryTranslationToTc, -+ _REQUIRES_INPUT: False -+ } -+ ], -+ ['unit', { -+ _FACTORY: ToolFactoryUnit, -+ _REQUIRES_INPUT: False -+ }], -+ [ -+ 'update_resource_ids', -+ { -+ _FACTORY: ToolFactoryUpdateResourceIds, -+ _REQUIRES_INPUT: False -+ } -+ ], -+ ['xmb', { -+ _FACTORY: ToolFactoryXmb, -+ _REQUIRES_INPUT: True -+ }], -+] -+ -+ -+def PrintUsage(): -+ tool_list = '' -+ for (tool, info) in _TOOLS: -+ if not _HIDDEN in info: -+ tool_list += ' %-12s %s\n' % ( -+ tool, info[_FACTORY]().ShortDescription()) -+ -+ print("""GRIT - the Google Resource and Internationalization Tool -+ -+Usage: grit [GLOBALOPTIONS] TOOL [args to tool] -+ -+Global options: -+ -+ -i INPUT Specifies the INPUT file to use (a .grd file). If this is not -+ specified, GRIT will look for the environment variable GRIT_INPUT. -+ If it is not present either, GRIT will try to find an input file -+ named 'resource.grd' in the current working directory. -+ -+ -h MODULE Causes GRIT to use MODULE.UnsignedFingerPrint instead of -+ grit.extern.FP.UnsignedFingerprint. MODULE must be -+ available somewhere in the PYTHONPATH search path. -+ -+ -v Print more verbose runtime information. -+ -+ -x Print extremely verbose runtime information. Implies -v -+ -+ -p FNAME Specifies that GRIT should profile its execution and output the -+ results to the file FNAME. -+ -+Tools: -+ -+ TOOL can be one of the following: -+%s -+ For more information on how to use a particular tool, and the specific -+ arguments you can send to that tool, execute 'grit help TOOL' -+""" % (tool_list)) -+ -+ -+class Options(object): -+ """Option storage and parsing.""" -+ -+ def __init__(self): -+ self.hash = None -+ self.input = None -+ self.verbose = False -+ self.extra_verbose = False -+ self.output_stream = sys.stdout -+ self.profile_dest = None -+ -+ def ReadOptions(self, args): -+ """Reads options from the start of args and returns the remainder.""" -+ (opts, args) = getopt.getopt(args, 'vxi:p:h:', ('help',)) -+ for (key, val) in opts: -+ if key == '-h': self.hash = val -+ elif key == '-i': self.input = val -+ elif key == '-v': -+ self.verbose = True -+ util.verbose = True -+ elif key == '-x': -+ self.verbose = True -+ util.verbose = True -+ self.extra_verbose = True -+ util.extra_verbose = True -+ elif key == '-p': self.profile_dest = val -+ elif key == '--help': -+ PrintUsage() -+ sys.exit(0) -+ -+ if not self.input: -+ if 'GRIT_INPUT' in os.environ: -+ self.input = os.environ['GRIT_INPUT'] -+ else: -+ self.input = 'resource.grd' -+ -+ return args -+ -+ def __repr__(self): -+ return '(verbose: %d, input: %s)' % ( -+ self.verbose, self.input) -+ -+ -+def _GetToolInfo(tool): -+ """Returns the info map for the tool named 'tool' or None if there is no -+ such tool.""" -+ matches = [t for t in _TOOLS if t[0] == tool] -+ if not matches: -+ return None -+ else: -+ return matches[0][1] -+ -+ -+def Main(args=None): -+ """Parses arguments and does the appropriate thing.""" -+ util.ChangeStdoutEncoding() -+ -+ # Support for setuptools console wrappers. -+ if args is None: -+ args = sys.argv[1:] -+ -+ options = Options() -+ try: -+ args = options.ReadOptions(args) # args may be shorter after this -+ except getopt.GetoptError as e: -+ print("grit:", str(e)) -+ print("Try running 'grit help' for valid options.") -+ return 1 -+ if not args: -+ print("No tool provided. Try running 'grit help' for a list of tools.") -+ return 2 -+ -+ tool = args[0] -+ if tool == 'help': -+ if len(args) == 1: -+ PrintUsage() -+ return 0 -+ else: -+ tool = args[1] -+ if not _GetToolInfo(tool): -+ print("No such tool. Try running 'grit help' for a list of tools.") -+ return 2 -+ -+ print("Help for 'grit %s' (for general help, run 'grit help'):\n" % -+ (tool,)) -+ _GetToolInfo(tool)[_FACTORY]().ShowUsage() -+ return 0 -+ if not _GetToolInfo(tool): -+ print("No such tool. Try running 'grit help' for a list of tools.") -+ return 2 -+ -+ try: -+ if _GetToolInfo(tool)[_REQUIRES_INPUT]: -+ os.stat(options.input) -+ except OSError: -+ print('Input file %s not found.\n' -+ 'To specify a different input file:\n' -+ ' 1. Use the GRIT_INPUT environment variable.\n' -+ ' 2. Use the -i command-line option. This overrides ' -+ 'GRIT_INPUT.\n' -+ ' 3. Specify neither GRIT_INPUT or -i and GRIT will try to load ' -+ "'resource.grd'\n" -+ ' from the current directory.' % options.input) -+ return 2 -+ -+ if options.hash: -+ grit.extern.FP.UseUnsignedFingerPrintFromModule(options.hash) -+ -+ try: -+ toolobject = _GetToolInfo(tool)[_FACTORY]() -+ if options.profile_dest: -+ import hotshot -+ prof = hotshot.Profile(options.profile_dest) -+ return prof.runcall(toolobject.Run, options, args[1:]) -+ else: -+ return toolobject.Run(options, args[1:]) -+ except getopt.GetoptError as e: -+ print("grit: %s: %s" % (tool, str(e))) -+ print("Try running 'grit help %s' for valid options." % (tool,)) -+ return 1 -+ -+ -+if __name__ == '__main__': -+ sys.path.append( -+ os.path.join( -+ os.path.dirname( -+ os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), -+ 'diagnosis')) -+ try: -+ import crbug_1001171 -+ with crbug_1001171.DumpStateOnLookupError(): -+ sys.exit(Main(sys.argv[1:])) -+ except ImportError: -+ pass -+ -+ sys.exit(Main(sys.argv[1:])) -diff --git a/tools/grit/grit/grit_runner_unittest.py b/tools/grit/grit/grit_runner_unittest.py -new file mode 100644 -index 0000000000..1487001d81 ---- /dev/null -+++ b/tools/grit/grit/grit_runner_unittest.py -@@ -0,0 +1,42 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.py''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -+ -+import unittest -+ -+from six import StringIO -+ -+from grit import util -+import grit.grit_runner -+ -+class OptionArgsUnittest(unittest.TestCase): -+ def setUp(self): -+ self.buf = StringIO() -+ self.old_stdout = sys.stdout -+ sys.stdout = self.buf -+ -+ def tearDown(self): -+ sys.stdout = self.old_stdout -+ -+ def testSimple(self): -+ grit.grit_runner.Main(['-i', -+ util.PathFromRoot('grit/testdata/simple-input.xml'), -+ 'test', 'bla', 'voff', 'ga']) -+ output = self.buf.getvalue() -+ self.failUnless(output.count("'test'") == 0) # tool name doesn't occur -+ self.failUnless(output.count('bla')) -+ self.failUnless(output.count('simple-input.xml')) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/lazy_re.py b/tools/grit/grit/lazy_re.py -new file mode 100644 -index 0000000000..5c461e87e7 ---- /dev/null -+++ b/tools/grit/grit/lazy_re.py -@@ -0,0 +1,46 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''In GRIT, we used to compile a lot of regular expressions at parse -+time. Since many of them never get used, we use lazy_re to compile -+them on demand the first time they are used, thus speeding up startup -+time in some cases. -+''' -+ -+from __future__ import print_function -+ -+import re -+ -+ -+class LazyRegexObject(object): -+ '''This object creates a RegexObject with the arguments passed in -+ its constructor, the first time any attribute except the several on -+ the class itself is accessed. This accomplishes lazy compilation of -+ the regular expression while maintaining a nearly-identical -+ interface. -+ ''' -+ -+ def __init__(self, *args, **kwargs): -+ self._stash_args = args -+ self._stash_kwargs = kwargs -+ self._lazy_re = None -+ -+ def _LazyInit(self): -+ if not self._lazy_re: -+ self._lazy_re = re.compile(*self._stash_args, **self._stash_kwargs) -+ -+ def __getattribute__(self, name): -+ if name in ('_LazyInit', '_lazy_re', '_stash_args', '_stash_kwargs'): -+ return object.__getattribute__(self, name) -+ else: -+ self._LazyInit() -+ return getattr(self._lazy_re, name) -+ -+ -+def compile(*args, **kwargs): -+ '''Creates a LazyRegexObject that, when invoked on, will compile a -+ re.RegexObject (via re.compile) with the same arguments passed to -+ this function, and delegate almost all of its methods to it. -+ ''' -+ return LazyRegexObject(*args, **kwargs) -diff --git a/tools/grit/grit/lazy_re_unittest.py b/tools/grit/grit/lazy_re_unittest.py -new file mode 100644 -index 0000000000..8488b454ee ---- /dev/null -+++ b/tools/grit/grit/lazy_re_unittest.py -@@ -0,0 +1,40 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit test for lazy_re. -+''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -+ -+import re -+import unittest -+ -+from grit import lazy_re -+ -+ -+class LazyReUnittest(unittest.TestCase): -+ -+ def testCreatedOnlyOnDemand(self): -+ rex = lazy_re.compile('bingo') -+ self.assertEqual(None, rex._lazy_re) -+ self.assertTrue(rex.match('bingo')) -+ self.assertNotEqual(None, rex._lazy_re) -+ -+ def testJustKwargsWork(self): -+ rex = lazy_re.compile(flags=re.I, pattern='BiNgO') -+ self.assertTrue(rex.match('bingo')) -+ -+ def testPositionalAndKwargsWork(self): -+ rex = lazy_re.compile('BiNgO', flags=re.I) -+ self.assertTrue(rex.match('bingo')) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/__init__.py b/tools/grit/grit/node/__init__.py -new file mode 100644 -index 0000000000..2fc0d3360c ---- /dev/null -+++ b/tools/grit/grit/node/__init__.py -@@ -0,0 +1,8 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Package 'grit.node' -+''' -+ -+pass -diff --git a/tools/grit/grit/node/base.py b/tools/grit/grit/node/base.py -new file mode 100644 -index 0000000000..40859d301d ---- /dev/null -+++ b/tools/grit/grit/node/base.py -@@ -0,0 +1,670 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Base types for nodes in a GRIT resource tree. -+''' -+ -+from __future__ import print_function -+ -+import ast -+import os -+import struct -+import sys -+from xml.sax import saxutils -+ -+import six -+ -+from grit import constants -+from grit import clique -+from grit import exception -+from grit import util -+from grit.node import brotli_util -+import grit.format.gzip_string -+ -+ -+class Node(object): -+ '''An item in the tree that has children.''' -+ -+ # Valid content types that can be returned by _ContentType() -+ _CONTENT_TYPE_NONE = 0 # No CDATA content but may have children -+ _CONTENT_TYPE_CDATA = 1 # Only CDATA, no children. -+ _CONTENT_TYPE_MIXED = 2 # CDATA and children, possibly intermingled -+ -+ # Types of files to be compressed by default. -+ _COMPRESS_BY_DEFAULT_EXTENSIONS = ('.js', '.html', '.css', '.svg') -+ -+ # Default nodes to not whitelist skipped -+ _whitelist_marked_as_skip = False -+ -+ # A class-static cache to speed up EvaluateExpression(). -+ # Keys are expressions (e.g. 'is_ios and lang == "fr"'). Values are tuples -+ # (code, variables_in_expr) where code is the compiled expression and can be -+ # directly eval'd, and variables_in_expr is the list of variable and method -+ # names used in the expression (e.g. ['is_ios', 'lang']). -+ eval_expr_cache = {} -+ -+ def __init__(self): -+ self.children = [] # A list of child elements -+ self.mixed_content = [] # A list of u'' and/or child elements (this -+ # duplicates 'children' but -+ # is needed to preserve markup-type content). -+ self.name = u'' # The name of this element -+ self.attrs = {} # The set of attributes (keys to values) -+ self.parent = None # Our parent unless we are the root element. -+ self.uberclique = None # Allows overriding uberclique for parts of tree -+ self.source = None # File that this node was parsed from -+ -+ # This context handler allows you to write "with node:" and get a -+ # line identifying the offending node if an exception escapes from the body -+ # of the with statement. -+ def __enter__(self): -+ return self -+ -+ def __exit__(self, exc_type, exc_value, traceback): -+ if exc_type is not None: -+ print(u'Error processing node %s: %s' % (six.text_type(self), exc_value)) -+ -+ def __iter__(self): -+ '''A preorder iteration through the tree that this node is the root of.''' -+ return self.Preorder() -+ -+ def Preorder(self): -+ '''Generator that generates first this node, then the same generator for -+ any child nodes.''' -+ yield self -+ for child in self.children: -+ for iterchild in child.Preorder(): -+ yield iterchild -+ -+ def ActiveChildren(self): -+ '''Returns the children of this node that should be included in the current -+ configuration. Overridden by .''' -+ return [node for node in self.children if not node.WhitelistMarkedAsSkip()] -+ -+ def ActiveDescendants(self): -+ '''Yields the current node and all descendants that should be included in -+ the current configuration, in preorder.''' -+ yield self -+ for child in self.ActiveChildren(): -+ for descendant in child.ActiveDescendants(): -+ yield descendant -+ -+ def GetRoot(self): -+ '''Returns the root Node in the tree this Node belongs to.''' -+ curr = self -+ while curr.parent: -+ curr = curr.parent -+ return curr -+ -+ # TODO(joi) Use this (currently untested) optimization?: -+ #if hasattr(self, '_root'): -+ # return self._root -+ #curr = self -+ #while curr.parent and not hasattr(curr, '_root'): -+ # curr = curr.parent -+ #if curr.parent: -+ # self._root = curr._root -+ #else: -+ # self._root = curr -+ #return self._root -+ -+ def StartParsing(self, name, parent): -+ '''Called at the start of parsing. -+ -+ Args: -+ name: u'elementname' -+ parent: grit.node.base.Node or subclass or None -+ ''' -+ assert isinstance(name, six.string_types) -+ assert not parent or isinstance(parent, Node) -+ self.name = name -+ self.parent = parent -+ -+ def AddChild(self, child): -+ '''Adds a child to the list of children of this node, if it is a valid -+ child for the node.''' -+ assert isinstance(child, Node) -+ if (not self._IsValidChild(child) or -+ self._ContentType() == self._CONTENT_TYPE_CDATA): -+ explanation = 'invalid child %s for parent %s' % (str(child), self.name) -+ raise exception.UnexpectedChild(explanation) -+ self.children.append(child) -+ self.mixed_content.append(child) -+ -+ def RemoveChild(self, child_id): -+ '''Removes the first node that has a "name" attribute which -+ matches "child_id" in the list of immediate children of -+ this node. -+ -+ Args: -+ child_id: String identifying the child to be removed -+ ''' -+ index = 0 -+ # Safe not to copy since we only remove the first element found -+ for child in self.children: -+ name_attr = child.attrs['name'] -+ if name_attr == child_id: -+ self.children.pop(index) -+ self.mixed_content.pop(index) -+ break -+ index += 1 -+ -+ def AppendContent(self, content): -+ '''Appends a chunk of text as content of this node. -+ -+ Args: -+ content: u'hello' -+ -+ Return: -+ None -+ ''' -+ assert isinstance(content, six.string_types) -+ if self._ContentType() != self._CONTENT_TYPE_NONE: -+ self.mixed_content.append(content) -+ elif content.strip() != '': -+ raise exception.UnexpectedContent() -+ -+ def HandleAttribute(self, attrib, value): -+ '''Informs the node of an attribute that was parsed out of the GRD file -+ for it. -+ -+ Args: -+ attrib: 'name' -+ value: 'fooblat' -+ -+ Return: -+ None -+ ''' -+ assert isinstance(attrib, six.string_types) -+ assert isinstance(value, six.string_types) -+ if self._IsValidAttribute(attrib, value): -+ self.attrs[attrib] = value -+ else: -+ raise exception.UnexpectedAttribute(attrib) -+ -+ def EndParsing(self): -+ '''Called at the end of parsing.''' -+ -+ # TODO(joi) Rewrite this, it's extremely ugly! -+ if len(self.mixed_content): -+ if isinstance(self.mixed_content[0], six.string_types): -+ # Remove leading and trailing chunks of pure whitespace. -+ while (len(self.mixed_content) and -+ isinstance(self.mixed_content[0], six.string_types) and -+ self.mixed_content[0].strip() == ''): -+ self.mixed_content = self.mixed_content[1:] -+ # Strip leading and trailing whitespace from mixed content chunks -+ # at front and back. -+ if (len(self.mixed_content) and -+ isinstance(self.mixed_content[0], six.string_types)): -+ self.mixed_content[0] = self.mixed_content[0].lstrip() -+ # Remove leading and trailing ''' (used to demarcate whitespace) -+ if (len(self.mixed_content) and -+ isinstance(self.mixed_content[0], six.string_types)): -+ if self.mixed_content[0].startswith("'''"): -+ self.mixed_content[0] = self.mixed_content[0][3:] -+ if len(self.mixed_content): -+ if isinstance(self.mixed_content[-1], six.string_types): -+ # Same stuff all over again for the tail end. -+ while (len(self.mixed_content) and -+ isinstance(self.mixed_content[-1], six.string_types) and -+ self.mixed_content[-1].strip() == ''): -+ self.mixed_content = self.mixed_content[:-1] -+ if (len(self.mixed_content) and -+ isinstance(self.mixed_content[-1], six.string_types)): -+ self.mixed_content[-1] = self.mixed_content[-1].rstrip() -+ if (len(self.mixed_content) and -+ isinstance(self.mixed_content[-1], six.string_types)): -+ if self.mixed_content[-1].endswith("'''"): -+ self.mixed_content[-1] = self.mixed_content[-1][:-3] -+ -+ # Check that all mandatory attributes are there. -+ for node_mandatt in self.MandatoryAttributes(): -+ mandatt_list = [] -+ if node_mandatt.find('|') >= 0: -+ mandatt_list = node_mandatt.split('|') -+ else: -+ mandatt_list.append(node_mandatt) -+ -+ mandatt_option_found = False -+ for mandatt in mandatt_list: -+ assert mandatt not in self.DefaultAttributes() -+ if mandatt in self.attrs: -+ if not mandatt_option_found: -+ mandatt_option_found = True -+ else: -+ raise exception.MutuallyExclusiveMandatoryAttribute(mandatt) -+ -+ if not mandatt_option_found: -+ raise exception.MissingMandatoryAttribute(mandatt) -+ -+ # Add default attributes if not specified in input file. -+ for defattr in self.DefaultAttributes(): -+ if not defattr in self.attrs: -+ self.attrs[defattr] = self.DefaultAttributes()[defattr] -+ -+ def GetCdata(self): -+ '''Returns all CDATA of this element, concatenated into a single -+ string. Note that this ignores any elements embedded in CDATA.''' -+ return ''.join([c for c in self.mixed_content -+ if isinstance(c, six.string_types)]) -+ -+ def __str__(self): -+ '''Returns this node and all nodes below it as an XML document in a Unicode -+ string.''' -+ header = u'\n' -+ return header + self.FormatXml() -+ -+ # Some Python 2 glue. -+ __unicode__ = __str__ -+ -+ def FormatXml(self, indent = u'', one_line = False): -+ '''Returns this node and all nodes below it as an XML -+ element in a Unicode string. This differs from __unicode__ in that it does -+ not include the stuff at the top of the string. If one_line is true, -+ children and CDATA are layed out in a way that preserves internal -+ whitespace. -+ ''' -+ assert isinstance(indent, six.string_types) -+ -+ content_one_line = (one_line or -+ self._ContentType() == self._CONTENT_TYPE_MIXED) -+ inside_content = self.ContentsAsXml(indent, content_one_line) -+ -+ # Then the attributes for this node. -+ attribs = u'' -+ default_attribs = self.DefaultAttributes() -+ for attrib, value in sorted(self.attrs.items()): -+ # Only print an attribute if it is other than the default value. -+ if attrib not in default_attribs or value != default_attribs[attrib]: -+ attribs += u' %s=%s' % (attrib, saxutils.quoteattr(value)) -+ -+ # Finally build the XML for our node and return it -+ if len(inside_content) > 0: -+ if one_line: -+ return u'<%s%s>%s' % (self.name, attribs, inside_content, -+ self.name) -+ elif content_one_line: -+ return u'%s<%s%s>\n%s %s\n%s' % ( -+ indent, self.name, attribs, -+ indent, inside_content, -+ indent, self.name) -+ else: -+ return u'%s<%s%s>\n%s\n%s' % ( -+ indent, self.name, attribs, -+ inside_content, -+ indent, self.name) -+ else: -+ return u'%s<%s%s />' % (indent, self.name, attribs) -+ -+ def ContentsAsXml(self, indent, one_line): -+ '''Returns the contents of this node (CDATA and child elements) in XML -+ format. If 'one_line' is true, the content will be laid out on one line.''' -+ assert isinstance(indent, six.string_types) -+ -+ # Build the contents of the element. -+ inside_parts = [] -+ last_item = None -+ for mixed_item in self.mixed_content: -+ if isinstance(mixed_item, Node): -+ inside_parts.append(mixed_item.FormatXml(indent + u' ', one_line)) -+ if not one_line: -+ inside_parts.append(u'\n') -+ else: -+ message = mixed_item -+ # If this is the first item and it starts with whitespace, we add -+ # the ''' delimiter. -+ if not last_item and message.lstrip() != message: -+ message = u"'''" + message -+ inside_parts.append(util.EncodeCdata(message)) -+ last_item = mixed_item -+ -+ # If there are only child nodes and no cdata, there will be a spurious -+ # trailing \n -+ if len(inside_parts) and inside_parts[-1] == '\n': -+ inside_parts = inside_parts[:-1] -+ -+ # If the last item is a string (not a node) and ends with whitespace, -+ # we need to add the ''' delimiter. -+ if (isinstance(last_item, six.string_types) and -+ last_item.rstrip() != last_item): -+ inside_parts[-1] = inside_parts[-1] + u"'''" -+ -+ return u''.join(inside_parts) -+ -+ def SubstituteMessages(self, substituter): -+ '''Applies substitutions to all messages in the tree. -+ -+ Called as a final step of RunGatherers. -+ -+ Args: -+ substituter: a grit.util.Substituter object. -+ ''' -+ for child in self.children: -+ child.SubstituteMessages(substituter) -+ -+ def _IsValidChild(self, child): -+ '''Returns true if 'child' is a valid child of this node. -+ Overridden by subclasses.''' -+ return False -+ -+ def _IsValidAttribute(self, name, value): -+ '''Returns true if 'name' is the name of a valid attribute of this element -+ and 'value' is a valid value for that attribute. Overriden by -+ subclasses unless they have only mandatory attributes.''' -+ return (name in self.MandatoryAttributes() or -+ name in self.DefaultAttributes()) -+ -+ def _ContentType(self): -+ '''Returns the type of content this element can have. Overridden by -+ subclasses. The content type can be one of the _CONTENT_TYPE_XXX constants -+ above.''' -+ return self._CONTENT_TYPE_NONE -+ -+ def MandatoryAttributes(self): -+ '''Returns a list of attribute names that are mandatory (non-optional) -+ on the current element. One can specify a list of -+ "mutually exclusive mandatory" attributes by specifying them as one -+ element in the list, separated by a "|" character. -+ ''' -+ return [] -+ -+ def DefaultAttributes(self): -+ '''Returns a dictionary of attribute names that have defaults, mapped to -+ the default value. Overridden by subclasses.''' -+ return {} -+ -+ def GetCliques(self): -+ '''Returns all MessageClique objects belonging to this node. Overridden -+ by subclasses. -+ -+ Return: -+ [clique1, clique2] or [] -+ ''' -+ return [] -+ -+ def ToRealPath(self, path_from_basedir): -+ '''Returns a real path (which can be absolute or relative to the current -+ working directory), given a path that is relative to the base directory -+ set for the GRIT input file. -+ -+ Args: -+ path_from_basedir: '..' -+ -+ Return: -+ 'resource' -+ ''' -+ return util.normpath(os.path.join(self.GetRoot().GetBaseDir(), -+ os.path.expandvars(path_from_basedir))) -+ -+ def GetInputPath(self): -+ '''Returns a path, relative to the base directory set for the grd file, -+ that points to the file the node refers to. -+ ''' -+ # This implementation works for most nodes that have an input file. -+ return self.attrs['file'] -+ -+ def UberClique(self): -+ '''Returns the uberclique that should be used for messages originating in -+ a given node. If the node itself has its uberclique set, that is what we -+ use, otherwise we search upwards until we find one. If we do not find one -+ even at the root node, we set the root node's uberclique to a new -+ uberclique instance. -+ ''' -+ node = self -+ while not node.uberclique and node.parent: -+ node = node.parent -+ if not node.uberclique: -+ node.uberclique = clique.UberClique() -+ return node.uberclique -+ -+ def IsTranslateable(self): -+ '''Returns false if the node has contents that should not be translated, -+ otherwise returns false (even if the node has no contents). -+ ''' -+ if not 'translateable' in self.attrs: -+ return True -+ else: -+ return self.attrs['translateable'] == 'true' -+ -+ def IsAccessibilityWithNoUI(self): -+ '''Returns true if the node is marked as an accessibility label and the -+ message isn't shown in the UI. Otherwise returns false. This label is -+ used to determine if the text requires screenshots.''' -+ if not 'is_accessibility_with_no_ui' in self.attrs: -+ return False -+ else: -+ return self.attrs['is_accessibility_with_no_ui'] == 'true' -+ -+ def GetNodeById(self, id): -+ '''Returns the node in the subtree parented by this node that has a 'name' -+ attribute matching 'id'. Returns None if no such node is found. -+ ''' -+ for node in self: -+ if 'name' in node.attrs and node.attrs['name'] == id: -+ return node -+ return None -+ -+ def GetChildrenOfType(self, type): -+ '''Returns a list of all subnodes (recursing to all leaves) of this node -+ that are of the indicated type (or tuple of types). -+ -+ Args: -+ type: A type you could use with isinstance(). -+ -+ Return: -+ A list, possibly empty. -+ ''' -+ return [child for child in self if isinstance(child, type)] -+ -+ def GetTextualIds(self): -+ '''Returns a list of the textual ids of this node. -+ ''' -+ if 'name' in self.attrs: -+ return [self.attrs['name']] -+ return [] -+ -+ @classmethod -+ def EvaluateExpression(cls, expr, defs, target_platform, extra_variables={}): -+ '''Worker for EvaluateCondition (below) and conditions in XTB files.''' -+ if expr in cls.eval_expr_cache: -+ code, variables_in_expr = cls.eval_expr_cache[expr] -+ else: -+ # Get a list of all variable and method names used in the expression. -+ syntax_tree = ast.parse(expr, mode='eval') -+ variables_in_expr = [node.id for node in ast.walk(syntax_tree) if -+ isinstance(node, ast.Name) and node.id not in ('True', 'False')] -+ code = compile(syntax_tree, filename='', mode='eval') -+ cls.eval_expr_cache[expr] = code, variables_in_expr -+ -+ # Set values only for variables that are needed to eval the expression. -+ variable_map = {} -+ for name in variables_in_expr: -+ if name == 'os': -+ value = target_platform -+ elif name == 'defs': -+ value = defs -+ -+ elif name == 'is_linux': -+ value = target_platform.startswith('linux') -+ elif name == 'is_macosx': -+ value = target_platform == 'darwin' -+ elif name == 'is_win': -+ value = target_platform in ('cygwin', 'win32') -+ elif name == 'is_android': -+ value = target_platform == 'android' -+ elif name == 'is_ios': -+ value = target_platform == 'ios' -+ elif name == 'is_bsd': -+ value = 'bsd' in target_platform -+ elif name == 'is_posix': -+ value = (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5', -+ 'android', 'ios') -+ or 'bsd' in target_platform) -+ -+ elif name == 'pp_ifdef': -+ def pp_ifdef(symbol): -+ return symbol in defs -+ value = pp_ifdef -+ elif name == 'pp_if': -+ def pp_if(symbol): -+ return defs.get(symbol, False) -+ value = pp_if -+ -+ elif name in defs: -+ value = defs[name] -+ elif name in extra_variables: -+ value = extra_variables[name] -+ else: -+ # Undefined variables default to False. -+ value = False -+ -+ variable_map[name] = value -+ -+ eval_result = eval(code, {}, variable_map) -+ assert isinstance(eval_result, bool) -+ return eval_result -+ -+ def EvaluateCondition(self, expr): -+ '''Returns true if and only if the Python expression 'expr' evaluates -+ to true. -+ -+ The expression is given a few local variables: -+ - 'lang' is the language currently being output -+ (the 'lang' attribute of the element). -+ - 'context' is the current output context -+ (the 'context' attribute of the element). -+ - 'defs' is a map of C preprocessor-style symbol names to their values. -+ - 'os' is the current platform (likely 'linux2', 'win32' or 'darwin'). -+ - 'pp_ifdef(symbol)' is a shorthand for "symbol in defs". -+ - 'pp_if(symbol)' is a shorthand for "symbol in defs and defs[symbol]". -+ - 'is_linux', 'is_macosx', 'is_win', 'is_posix' are true if 'os' -+ matches the given platform. -+ ''' -+ root = self.GetRoot() -+ lang = getattr(root, 'output_language', '') -+ context = getattr(root, 'output_context', '') -+ defs = getattr(root, 'defines', {}) -+ target_platform = getattr(root, 'target_platform', '') -+ extra_variables = { -+ 'lang': lang, -+ 'context': context, -+ } -+ return Node.EvaluateExpression( -+ expr, defs, target_platform, extra_variables) -+ -+ def OnlyTheseTranslations(self, languages): -+ '''Turns off loading of translations for languages not in the provided list. -+ -+ Attrs: -+ languages: ['fr', 'zh_cn'] -+ ''' -+ for node in self: -+ if (hasattr(node, 'IsTranslation') and -+ node.IsTranslation() and -+ node.GetLang() not in languages): -+ node.DisableLoading() -+ -+ def FindBooleanAttribute(self, attr, default, skip_self): -+ '''Searches all ancestors of the current node for the nearest enclosing -+ definition of the given boolean attribute. -+ -+ Args: -+ attr: 'fallback_to_english' -+ default: What to return if no node defines the attribute. -+ skip_self: Don't check the current node, only its parents. -+ ''' -+ p = self.parent if skip_self else self -+ while p: -+ value = p.attrs.get(attr, 'default').lower() -+ if value != 'default': -+ return (value == 'true') -+ p = p.parent -+ return default -+ -+ def PseudoIsAllowed(self): -+ '''Returns true if this node is allowed to use pseudo-translations. This -+ is true by default, unless this node is within a node that has -+ the allow_pseudo attribute set to false. -+ ''' -+ return self.FindBooleanAttribute('allow_pseudo', -+ default=True, skip_self=True) -+ -+ def ShouldFallbackToEnglish(self): -+ '''Returns true iff this node should fall back to English when -+ pseudotranslations are disabled and no translation is available for a -+ given message. -+ ''' -+ return self.FindBooleanAttribute('fallback_to_english', -+ default=False, skip_self=True) -+ -+ def WhitelistMarkedAsSkip(self): -+ '''Returns true if the node is marked to be skipped in the output by a -+ whitelist. -+ ''' -+ return self._whitelist_marked_as_skip -+ -+ def SetWhitelistMarkedAsSkip(self, mark_skipped): -+ '''Sets WhitelistMarkedAsSkip. -+ ''' -+ self._whitelist_marked_as_skip = mark_skipped -+ -+ def ExpandVariables(self): -+ '''Whether we need to expand variables on a given node.''' -+ return False -+ -+ def IsResourceMapSource(self): -+ '''Whether this node is a resource map source.''' -+ return False -+ -+ def CompressDataIfNeeded(self, data): -+ '''Compress data using the format specified in the compress attribute. -+ -+ Args: -+ data: The data to compressed. -+ Returns: -+ The data in gzipped or brotli compressed format. If the format is -+ unspecified then this returns the data uncompressed. -+ ''' -+ -+ compress = self.attrs.get('compress') -+ -+ # Compress JS, HTML, CSS and SVG files by default (gzip), unless |compress| -+ # is explicitly specified. -+ compress_by_default = (compress == 'default' -+ and self.attrs.get('file').endswith( -+ self._COMPRESS_BY_DEFAULT_EXTENSIONS)) -+ -+ if compress == 'gzip' or compress_by_default: -+ # We only use rsyncable compression on Linux. -+ # We exclude ChromeOS since ChromeOS bots are Linux based but do not have -+ # the --rsyncable option built in for gzip. See crbug.com/617950. -+ if sys.platform == 'linux2' and 'chromeos' not in self.GetRoot().defines: -+ return grit.format.gzip_string.GzipStringRsyncable(data) -+ return grit.format.gzip_string.GzipString(data) -+ -+ if compress == 'brotli': -+ # The length of the uncompressed data as 8 bytes little-endian. -+ size_bytes = struct.pack(" ') -+ -+ ph = message.PhNode() -+ ph.StartParsing(u'ph', None) -+ ph.HandleAttribute(u'name', u'USERNAME') -+ ph.AppendContent(u'$1') -+ ex = message.ExNode() -+ ex.StartParsing(u'ex', None) -+ ex.AppendContent(u'Joi') -+ ex.EndParsing() -+ ph.AddChild(ex) -+ ph.EndParsing() -+ -+ node.AddChild(ph) -+ node.EndParsing() -+ -+ non_indented_xml = node.FormatXml() -+ self.failUnless(non_indented_xml == u'\n Hello ' -+ u'<young> $1Joi' -+ u'\n') -+ -+ indented_xml = node.FormatXml(u' ') -+ self.failUnless(indented_xml == u' \n Hello ' -+ u'<young> $1Joi' -+ u'\n ') -+ -+ def testXmlFormatMixedContentWithLeadingWhitespace(self): -+ # Again test using the Message node type, because it is the only mixed -+ # content node. -+ node = message.MessageNode() -+ node.StartParsing(u'message', None) -+ node.HandleAttribute(u'name', u'name') -+ node.AppendContent(u"''' Hello ") -+ -+ ph = message.PhNode() -+ ph.StartParsing(u'ph', None) -+ ph.HandleAttribute(u'name', u'USERNAME') -+ ph.AppendContent(u'$1') -+ ex = message.ExNode() -+ ex.StartParsing(u'ex', None) -+ ex.AppendContent(u'Joi') -+ ex.EndParsing() -+ ph.AddChild(ex) -+ ph.EndParsing() -+ -+ node.AddChild(ph) -+ node.AppendContent(u" yessiree '''") -+ node.EndParsing() -+ -+ non_indented_xml = node.FormatXml() -+ self.failUnless(non_indented_xml == -+ u"\n ''' Hello" -+ u' <young> $1Joi' -+ u" yessiree '''\n") -+ -+ indented_xml = node.FormatXml(u' ') -+ self.failUnless(indented_xml == -+ u" \n ''' Hello" -+ u' <young> $1Joi' -+ u" yessiree '''\n ") -+ -+ self.failUnless(node.GetNodeById('name')) -+ -+ def testXmlFormatContentWithEntities(self): -+ '''Tests a bug where   would not be escaped correctly.''' -+ from grit import tclib -+ msg_node = message.MessageNode.Construct(None, tclib.Message( -+ text = 'BEGIN_BOLDHelloWHITESPACEthere!END_BOLD Bingo!', -+ placeholders = [ -+ tclib.Placeholder('BEGIN_BOLD', '', 'bla'), -+ tclib.Placeholder('WHITESPACE', ' ', 'bla'), -+ tclib.Placeholder('END_BOLD', '', 'bla')]), -+ 'BINGOBONGO') -+ xml = msg_node.FormatXml() -+ self.failUnless(xml.find(' ') == -1, 'should have no entities') -+ -+ def testIter(self): -+ # First build a little tree of message and ph nodes. -+ node = message.MessageNode() -+ node.StartParsing(u'message', None) -+ node.HandleAttribute(u'name', u'bla') -+ node.AppendContent(u" ''' two spaces ") -+ node.AppendContent(u' space before and after ') -+ ph = message.PhNode() -+ ph.StartParsing(u'ph', None) -+ ph.AddChild(message.ExNode()) -+ ph.HandleAttribute(u'name', u'BINGO') -+ ph.AppendContent(u'bongo') -+ node.AddChild(ph) -+ node.AddChild(message.PhNode()) -+ node.AppendContent(u" space before two after '''") -+ -+ order = [message.MessageNode, message.PhNode, message.ExNode, message.PhNode] -+ for n in node: -+ self.failUnless(type(n) == order[0]) -+ order = order[1:] -+ self.failUnless(len(order) == 0) -+ -+ def testGetChildrenOfType(self): -+ xml = ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Hello! -+ -+ -+ ''' -+ grd = grd_reader.Parse(StringIO(xml), -+ util.PathFromRoot('grit/test/data')) -+ from grit.node import node_io -+ output_nodes = grd.GetChildrenOfType(node_io.OutputNode) -+ self.failUnlessEqual(len(output_nodes), 3) -+ self.failUnlessEqual(output_nodes[2].attrs['filename'], -+ 'de/generated_resources.rc') -+ -+ def testEvaluateExpression(self): -+ def AssertExpr(expected_value, expr, defs, target_platform, -+ extra_variables): -+ self.failUnlessEqual(expected_value, base.Node.EvaluateExpression( -+ expr, defs, target_platform, extra_variables)) -+ -+ AssertExpr(True, "True", {}, 'linux', {}) -+ AssertExpr(False, "False", {}, 'linux', {}) -+ AssertExpr(True, "True or False", {}, 'linux', {}) -+ AssertExpr(False, "True and False", {}, 'linux', {}) -+ AssertExpr(True, "os == 'linux'", {}, 'linux', {}) -+ AssertExpr(False, "os == 'linux'", {}, 'ios', {}) -+ AssertExpr(True, "'foo' in defs", {'foo': 'bar'}, 'ios', {}) -+ AssertExpr(False, "'foo' in defs", {'baz': 'bar'}, 'ios', {}) -+ AssertExpr(False, "'foo' in defs", {}, 'ios', {}) -+ AssertExpr(True, "is_linux", {}, 'linux2', {}) -+ AssertExpr(False, "is_linux", {}, 'win32', {}) -+ AssertExpr(True, "is_macosx", {}, 'darwin', {}) -+ AssertExpr(False, "is_macosx", {}, 'ios', {}) -+ AssertExpr(True, "is_win", {}, 'win32', {}) -+ AssertExpr(False, "is_win", {}, 'darwin', {}) -+ AssertExpr(True, "is_android", {}, 'android', {}) -+ AssertExpr(False, "is_android", {}, 'linux3', {}) -+ AssertExpr(True, "is_ios", {}, 'ios', {}) -+ AssertExpr(False, "is_ios", {}, 'darwin', {}) -+ AssertExpr(True, "is_posix", {}, 'linux2', {}) -+ AssertExpr(True, "is_posix", {}, 'darwin', {}) -+ AssertExpr(True, "is_posix", {}, 'android', {}) -+ AssertExpr(True, "is_posix", {}, 'ios', {}) -+ AssertExpr(True, "is_posix", {}, 'freebsd7', {}) -+ AssertExpr(False, "is_posix", {}, 'win32', {}) -+ AssertExpr(True, "pp_ifdef('foo')", {'foo': True}, 'win32', {}) -+ AssertExpr(True, "pp_ifdef('foo')", {'foo': False}, 'win32', {}) -+ AssertExpr(False, "pp_ifdef('foo')", {'bar': True}, 'win32', {}) -+ AssertExpr(True, "pp_if('foo')", {'foo': True}, 'win32', {}) -+ AssertExpr(False, "pp_if('foo')", {'foo': False}, 'win32', {}) -+ AssertExpr(False, "pp_if('foo')", {'bar': True}, 'win32', {}) -+ AssertExpr(True, "foo", {'foo': True}, 'win32', {}) -+ AssertExpr(False, "foo", {'foo': False}, 'win32', {}) -+ AssertExpr(False, "foo", {'bar': True}, 'win32', {}) -+ AssertExpr(True, "foo == 'baz'", {'foo': 'baz'}, 'win32', {}) -+ AssertExpr(False, "foo == 'baz'", {'foo': True}, 'win32', {}) -+ AssertExpr(False, "foo == 'baz'", {}, 'win32', {}) -+ AssertExpr(True, "lang == 'de'", {}, 'win32', {'lang': 'de'}) -+ AssertExpr(False, "lang == 'de'", {}, 'win32', {'lang': 'fr'}) -+ AssertExpr(False, "lang == 'de'", {}, 'win32', {}) -+ -+ # Test a couple more complex expressions for good measure. -+ AssertExpr(True, "is_ios and (lang in ['de', 'fr'] or foo)", -+ {'foo': 'bar'}, 'ios', {'lang': 'fr', 'context': 'today'}) -+ AssertExpr(False, "is_ios and (lang in ['de', 'fr'] or foo)", -+ {'foo': False}, 'linux2', {'lang': 'fr', 'context': 'today'}) -+ AssertExpr(False, "is_ios and (lang in ['de', 'fr'] or foo)", -+ {'baz': 'bar'}, 'ios', {'lang': 'he', 'context': 'today'}) -+ AssertExpr(True, "foo == 'bar' or not baz", -+ {'foo': 'bar', 'fun': True}, 'ios', {'lang': 'en'}) -+ AssertExpr(True, "foo == 'bar' or not baz", -+ {}, 'ios', {'lang': 'en', 'context': 'java'}) -+ AssertExpr(False, "foo == 'bar' or not baz", -+ {'foo': 'ruz', 'baz': True}, 'ios', {'lang': 'en'}) -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/brotli_util.py b/tools/grit/grit/node/brotli_util.py -new file mode 100644 -index 0000000000..77f70e49d5 ---- /dev/null -+++ b/tools/grit/grit/node/brotli_util.py -@@ -0,0 +1,29 @@ -+# Copyright 2019 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""Framework for compressing resources using Brotli.""" -+ -+import subprocess -+ -+__brotli_executable = None -+ -+ -+def SetBrotliCommand(brotli): -+ # brotli is a list. In production it contains the path to the Brotli executable. -+ # During testing it contains [python, mock_brotli.py] for testing on Windows. -+ global __brotli_executable -+ __brotli_executable = brotli -+ -+ -+def BrotliCompress(data): -+ if not __brotli_executable: -+ raise Exception('Add "use_brotli = true" to you GN grit(...) target ' + -+ 'if you want to use brotli.') -+ compress = subprocess.Popen(__brotli_executable + ['-', '-f'], -+ stdin=subprocess.PIPE, stdout=subprocess.PIPE) -+ return compress.communicate(data)[0] -+ -+def IsInitialized(): -+ global __brotli_executable -+ return __brotli_executable is not None -diff --git a/tools/grit/grit/node/custom/__init__.py b/tools/grit/grit/node/custom/__init__.py -new file mode 100644 -index 0000000000..e179cf7730 ---- /dev/null -+++ b/tools/grit/grit/node/custom/__init__.py -@@ -0,0 +1,8 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Package 'grit.node.custom' -+''' -+ -+pass -diff --git a/tools/grit/grit/node/custom/filename.py b/tools/grit/grit/node/custom/filename.py -new file mode 100644 -index 0000000000..55a27e58c1 ---- /dev/null -+++ b/tools/grit/grit/node/custom/filename.py -@@ -0,0 +1,29 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''A CustomType for filenames.''' -+ -+from __future__ import print_function -+ -+from grit import clique -+from grit import lazy_re -+ -+ -+class WindowsFilename(clique.CustomType): -+ '''Validates that messages can be used as Windows filenames, and strips -+ illegal characters out of translations. -+ ''' -+ -+ BANNED = lazy_re.compile(r'\+|:|\/|\\\\|\*|\?|\"|\<|\>|\|') -+ -+ def Validate(self, message): -+ return not self.BANNED.search(message.GetPresentableContent()) -+ -+ def ValidateAndModify(self, lang, translation): -+ is_ok = self.Validate(translation) -+ self.ModifyEachTextPart(lang, translation) -+ return is_ok -+ -+ def ModifyTextPart(self, lang, text): -+ return self.BANNED.sub(' ', text) -diff --git a/tools/grit/grit/node/custom/filename_unittest.py b/tools/grit/grit/node/custom/filename_unittest.py -new file mode 100644 -index 0000000000..8e2a6dd64a ---- /dev/null -+++ b/tools/grit/grit/node/custom/filename_unittest.py -@@ -0,0 +1,34 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.node.custom.filename''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../../..')) -+ -+import unittest -+from grit.node.custom import filename -+from grit import clique -+from grit import tclib -+ -+ -+class WindowsFilenameUnittest(unittest.TestCase): -+ -+ def testValidate(self): -+ factory = clique.UberClique() -+ msg = tclib.Message(text='Bingo bongo') -+ c = factory.MakeClique(msg) -+ c.SetCustomType(filename.WindowsFilename()) -+ translation = tclib.Translation(id=msg.GetId(), text='Bilingo bolongo:') -+ c.AddTranslation(translation, 'fr') -+ self.failUnless(c.MessageForLanguage('fr').GetRealContent() == 'Bilingo bolongo ') -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/empty.py b/tools/grit/grit/node/empty.py -new file mode 100644 -index 0000000000..e19d2c4ddb ---- /dev/null -+++ b/tools/grit/grit/node/empty.py -@@ -0,0 +1,64 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Container nodes that don't have any logic. -+''' -+ -+from __future__ import print_function -+ -+from grit.node import base -+from grit.node import include -+from grit.node import message -+from grit.node import misc -+from grit.node import node_io -+from grit.node import structure -+ -+ -+class GroupingNode(base.Node): -+ '''Base class for all the grouping elements (, , -+ and ).''' -+ def DefaultAttributes(self): -+ return { -+ 'first_id' : '', -+ 'comment' : '', -+ 'fallback_to_english' : 'false', -+ 'fallback_to_low_resolution' : 'false', -+ } -+ -+ -+class IncludesNode(GroupingNode): -+ '''The element.''' -+ def _IsValidChild(self, child): -+ return isinstance(child, (include.IncludeNode, misc.IfNode, misc.PartNode)) -+ -+ -+class MessagesNode(GroupingNode): -+ '''The element.''' -+ def _IsValidChild(self, child): -+ return isinstance(child, (message.MessageNode, misc.IfNode, misc.PartNode)) -+ -+ -+class StructuresNode(GroupingNode): -+ '''The element.''' -+ def _IsValidChild(self, child): -+ return isinstance(child, (structure.StructureNode, -+ misc.IfNode, misc.PartNode)) -+ -+ -+class TranslationsNode(base.Node): -+ '''The element.''' -+ def _IsValidChild(self, child): -+ return isinstance(child, (node_io.FileNode, misc.IfNode, misc.PartNode)) -+ -+ -+class OutputsNode(base.Node): -+ '''The element.''' -+ def _IsValidChild(self, child): -+ return isinstance(child, (node_io.OutputNode, misc.IfNode, misc.PartNode)) -+ -+ -+class IdentifiersNode(GroupingNode): -+ '''The element.''' -+ def _IsValidChild(self, child): -+ return isinstance(child, misc.IdentifierNode) -diff --git a/tools/grit/grit/node/include.py b/tools/grit/grit/node/include.py -new file mode 100644 -index 0000000000..b06b9889bb ---- /dev/null -+++ b/tools/grit/grit/node/include.py -@@ -0,0 +1,170 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""Handling of the element. -+""" -+ -+from __future__ import print_function -+ -+import os -+ -+from grit import util -+import grit.format.html_inline -+import grit.format.rc -+from grit.format import minifier -+from grit.node import base -+ -+class IncludeNode(base.Node): -+ """An element.""" -+ -+ def __init__(self): -+ super(IncludeNode, self).__init__() -+ -+ # Cache flattened data so that we don't flatten the same file -+ # multiple times. -+ self._flattened_data = None -+ # Also keep track of the last filename we flattened to, so we can -+ # avoid doing it more than once. -+ self._last_flat_filename = None -+ -+ def _IsValidChild(self, child): -+ return False -+ -+ def _GetFlattenedData( -+ self, allow_external_script=False, preprocess_only=False): -+ if not self._flattened_data: -+ filename = self.ToRealPath(self.GetInputPath()) -+ self._flattened_data = ( -+ grit.format.html_inline.InlineToString(filename, self, -+ preprocess_only=preprocess_only, -+ allow_external_script=allow_external_script)) -+ return self._flattened_data.encode('utf-8') -+ -+ def MandatoryAttributes(self): -+ return ['name', 'type', 'file'] -+ -+ def DefaultAttributes(self): -+ """Attributes: -+ translateable: False if the node has contents that should not be -+ translated. -+ preprocess: Takes the same code path as flattenhtml, but it -+ disables any processing/inlining outside of -+ and . -+ compress: The format to compress the data with, e.g. 'gzip' -+ or 'false' if data should not be compressed. -+ skip_minify: If true, skips minifying the node's contents. -+ skip_in_resource_map: If true, do not add to the resource map. -+ """ -+ return { -+ 'translateable': 'true', -+ 'generateid': 'true', -+ 'filenameonly': 'false', -+ 'mkoutput': 'false', -+ 'preprocess': 'false', -+ 'flattenhtml': 'false', -+ 'compress': 'default', -+ 'allowexternalscript': 'false', -+ 'relativepath': 'false', -+ 'use_base_dir': 'true', -+ 'skip_minify': 'false', -+ 'skip_in_resource_map': 'false', -+ } -+ -+ def GetInputPath(self): -+ # Do not mess with absolute paths, that would make them invalid. -+ if os.path.isabs(os.path.expandvars(self.attrs['file'])): -+ return self.attrs['file'] -+ -+ # We have no control over code that calls ToRealPath later, so convert -+ # the path to be relative against our basedir. -+ if self.attrs.get('use_base_dir', 'true') != 'true': -+ # Normalize the directory path to use the appropriate OS separator. -+ # GetBaseDir() may return paths\like\this or paths/like/this, since it is -+ # read from the base_dir attribute in the grd file. -+ norm_base_dir = util.normpath(self.GetRoot().GetBaseDir()) -+ return os.path.relpath(self.attrs['file'], norm_base_dir) -+ -+ return self.attrs['file'] -+ -+ def FileForLanguage(self, lang, output_dir): -+ """Returns the file for the specified language. This allows us to return -+ different files for different language variants of the include file. -+ """ -+ input_path = self.GetInputPath() -+ if input_path is None: -+ return None -+ -+ return self.ToRealPath(input_path) -+ -+ def GetDataPackValue(self, lang, encoding): -+ '''Returns bytes or a str represenation for a data_pack entry.''' -+ filename = self.ToRealPath(self.GetInputPath()) -+ if self.attrs['flattenhtml'] == 'true': -+ allow_external_script = self.attrs['allowexternalscript'] == 'true' -+ data = self._GetFlattenedData(allow_external_script=allow_external_script) -+ elif self.attrs['preprocess'] == 'true': -+ data = self._GetFlattenedData(preprocess_only=True) -+ else: -+ data = util.ReadFile(filename, util.BINARY) -+ -+ if self.attrs['skip_minify'] != 'true': -+ # Note that the minifier will only do anything if a minifier command -+ # has been set in the command line. -+ data = minifier.Minify(data, filename) -+ -+ # Include does not care about the encoding, because it only returns binary -+ # data. -+ return self.CompressDataIfNeeded(data) -+ -+ def Process(self, output_dir): -+ """Rewrite file references to be base64 encoded data URLs. The new file -+ will be written to output_dir and the name of the new file is returned.""" -+ filename = self.ToRealPath(self.GetInputPath()) -+ flat_filename = os.path.join(output_dir, -+ self.attrs['name'] + '_' + os.path.basename(filename)) -+ -+ if self._last_flat_filename == flat_filename: -+ return -+ -+ with open(flat_filename, 'wb') as outfile: -+ outfile.write(self._GetFlattenedData()) -+ -+ self._last_flat_filename = flat_filename -+ return os.path.basename(flat_filename) -+ -+ def GetHtmlResourceFilenames(self): -+ """Returns a set of all filenames inlined by this file.""" -+ allow_external_script = self.attrs['allowexternalscript'] == 'true' -+ return grit.format.html_inline.GetResourceFilenames( -+ self.ToRealPath(self.GetInputPath()), -+ self, -+ allow_external_script=allow_external_script) -+ -+ def IsResourceMapSource(self): -+ skip = self.attrs.get('skip_in_resource_map', 'false') == 'true' -+ return not skip -+ -+ @staticmethod -+ def Construct(parent, name, type, file, translateable=True, -+ filenameonly=False, mkoutput=False, relativepath=False): -+ """Creates a new node which is a child of 'parent', with attributes set -+ by parameters of the same name. -+ """ -+ # Convert types to appropriate strings -+ translateable = util.BoolToString(translateable) -+ filenameonly = util.BoolToString(filenameonly) -+ mkoutput = util.BoolToString(mkoutput) -+ relativepath = util.BoolToString(relativepath) -+ -+ node = IncludeNode() -+ node.StartParsing('include', parent) -+ node.HandleAttribute('name', name) -+ node.HandleAttribute('type', type) -+ node.HandleAttribute('file', file) -+ node.HandleAttribute('translateable', translateable) -+ node.HandleAttribute('filenameonly', filenameonly) -+ node.HandleAttribute('mkoutput', mkoutput) -+ node.HandleAttribute('relativepath', relativepath) -+ node.EndParsing() -+ return node -diff --git a/tools/grit/grit/node/include_unittest.py b/tools/grit/grit/node/include_unittest.py -new file mode 100644 -index 0000000000..4c658f1ffe ---- /dev/null -+++ b/tools/grit/grit/node/include_unittest.py -@@ -0,0 +1,134 @@ -+#!/usr/bin/env python -+# Copyright (c) 2013 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for include.IncludeNode''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+import unittest -+import zlib -+ -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+from grit.node import misc -+from grit.node import include -+from grit.node import empty -+from grit import util -+ -+ -+def checkIsGzipped(filename, compress_attr): -+ test_data_root = util.PathFromRoot('grit/testdata') -+ root = util.ParseGrdForUnittest( -+ ''' -+ -+ -+ ''' % (filename, compress_attr), -+ base_dir=test_data_root) -+ node, = root.GetChildrenOfType(include.IncludeNode) -+ compressed = node.GetDataPackValue(lang='en', encoding=util.BINARY) -+ -+ decompressed_data = zlib.decompress(compressed, 16 + zlib.MAX_WBITS) -+ expected = util.ReadFile(os.path.join(test_data_root, filename), util.BINARY) -+ return expected == decompressed_data -+ -+ -+class IncludeNodeUnittest(unittest.TestCase): -+ def testGetPath(self): -+ root = misc.GritNode() -+ root.StartParsing(u'grit', None) -+ root.HandleAttribute(u'latest_public_release', u'0') -+ root.HandleAttribute(u'current_release', u'1') -+ root.HandleAttribute(u'base_dir', r'..\resource') -+ release = misc.ReleaseNode() -+ release.StartParsing(u'release', root) -+ release.HandleAttribute(u'seq', u'1') -+ root.AddChild(release) -+ includes = empty.IncludesNode() -+ includes.StartParsing(u'includes', release) -+ release.AddChild(includes) -+ include_node = include.IncludeNode() -+ include_node.StartParsing(u'include', includes) -+ include_node.HandleAttribute(u'file', r'flugel\kugel.pdf') -+ includes.AddChild(include_node) -+ root.EndParsing() -+ -+ self.assertEqual(root.ToRealPath(include_node.GetInputPath()), -+ util.normpath( -+ os.path.join(r'../resource', r'flugel/kugel.pdf'))) -+ -+ def testGetPathNoBasedir(self): -+ root = misc.GritNode() -+ root.StartParsing(u'grit', None) -+ root.HandleAttribute(u'latest_public_release', u'0') -+ root.HandleAttribute(u'current_release', u'1') -+ root.HandleAttribute(u'base_dir', r'..\resource') -+ release = misc.ReleaseNode() -+ release.StartParsing(u'release', root) -+ release.HandleAttribute(u'seq', u'1') -+ root.AddChild(release) -+ includes = empty.IncludesNode() -+ includes.StartParsing(u'includes', release) -+ release.AddChild(includes) -+ include_node = include.IncludeNode() -+ include_node.StartParsing(u'include', includes) -+ include_node.HandleAttribute(u'file', r'flugel\kugel.pdf') -+ include_node.HandleAttribute(u'use_base_dir', u'false') -+ includes.AddChild(include_node) -+ root.EndParsing() -+ -+ last_dir = os.path.basename(os.getcwd()) -+ expected_path = util.normpath(os.path.join( -+ u'..', last_dir, u'flugel/kugel.pdf')) -+ self.assertEqual(root.ToRealPath(include_node.GetInputPath()), -+ expected_path) -+ -+ def testCompressGzip(self): -+ self.assertTrue(checkIsGzipped('test_text.txt', 'compress="gzip"')) -+ -+ def testCompressGzipByDefault(self): -+ self.assertTrue(checkIsGzipped('test_html.html', '')) -+ self.assertTrue(checkIsGzipped('test_js.js', '')) -+ self.assertTrue(checkIsGzipped('test_css.css', '')) -+ self.assertTrue(checkIsGzipped('test_svg.svg', '')) -+ -+ self.assertTrue(checkIsGzipped('test_html.html', 'compress="default"')) -+ self.assertTrue(checkIsGzipped('test_js.js', 'compress="default"')) -+ self.assertTrue(checkIsGzipped('test_css.css', 'compress="default"')) -+ self.assertTrue(checkIsGzipped('test_svg.svg', 'compress="default"')) -+ -+ def testSkipInResourceMap(self): -+ root = util.ParseGrdForUnittest(''' -+ -+ -+ -+ -+ ''', base_dir = util.PathFromRoot('grit/testdata')) -+ inc = root.GetChildrenOfType(include.IncludeNode) -+ self.assertTrue(inc[0].IsResourceMapSource()) -+ self.assertFalse(inc[1].IsResourceMapSource()) -+ self.assertTrue(inc[2].IsResourceMapSource()) -+ -+ def testAcceptsPreprocess(self): -+ root = util.ParseGrdForUnittest( -+ ''' -+ -+ -+ ''', -+ base_dir=util.PathFromRoot('grit/testdata')) -+ inc, = root.GetChildrenOfType(include.IncludeNode) -+ result = inc.GetDataPackValue(lang='en', encoding=util.BINARY) -+ self.assertIn(b'should be kept', result) -+ self.assertIn(b'in the middle...', result) -+ self.assertNotIn(b'should be removed', result) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/mapping.py b/tools/grit/grit/node/mapping.py -new file mode 100644 -index 0000000000..6297f0b666 ---- /dev/null -+++ b/tools/grit/grit/node/mapping.py -@@ -0,0 +1,60 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Maps each node type to an implementation class. -+When adding a new node type, you add to this mapping. -+''' -+ -+from __future__ import print_function -+ -+from grit import exception -+ -+from grit.node import empty -+from grit.node import include -+from grit.node import message -+from grit.node import misc -+from grit.node import node_io -+from grit.node import structure -+from grit.node import variant -+ -+ -+_ELEMENT_TO_CLASS = { -+ 'identifiers' : empty.IdentifiersNode, -+ 'includes' : empty.IncludesNode, -+ 'messages' : empty.MessagesNode, -+ 'outputs' : empty.OutputsNode, -+ 'structures' : empty.StructuresNode, -+ 'translations' : empty.TranslationsNode, -+ 'include' : include.IncludeNode, -+ 'emit' : node_io.EmitNode, -+ 'file' : node_io.FileNode, -+ 'output' : node_io.OutputNode, -+ 'ex' : message.ExNode, -+ 'message' : message.MessageNode, -+ 'ph' : message.PhNode, -+ 'else' : misc.ElseNode, -+ 'grit' : misc.GritNode, -+ 'identifier' : misc.IdentifierNode, -+ 'if' : misc.IfNode, -+ 'part' : misc.PartNode, -+ 'release' : misc.ReleaseNode, -+ 'then' : misc.ThenNode, -+ 'structure' : structure.StructureNode, -+ 'skeleton' : variant.SkeletonNode, -+} -+ -+ -+def ElementToClass(name, typeattr): -+ '''Maps an element to a class that handles the element. -+ -+ Args: -+ name: 'element' (the name of the element) -+ typeattr: 'type' (the value of the type attribute, if present, else None) -+ -+ Return: -+ type -+ ''' -+ if name not in _ELEMENT_TO_CLASS: -+ raise exception.UnknownElement() -+ return _ELEMENT_TO_CLASS[name] -diff --git a/tools/grit/grit/node/message.py b/tools/grit/grit/node/message.py -new file mode 100644 -index 0000000000..4fa83cf26b ---- /dev/null -+++ b/tools/grit/grit/node/message.py -@@ -0,0 +1,362 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Handling of the element. -+''' -+ -+from __future__ import print_function -+ -+import re -+ -+import six -+ -+from grit.node import base -+ -+from grit import clique -+from grit import exception -+from grit import lazy_re -+from grit import tclib -+from grit import util -+ -+ -+# Matches exactly three dots ending a line or followed by whitespace. -+_ELLIPSIS_PATTERN = lazy_re.compile(r'(?\s*)(?P.+?)(?P\s*)\Z', -+ re.DOTALL | re.MULTILINE) -+ -+# placeholder elements should contain the special character formatters -+# used to format element content. -+# Android format. -+_ANDROID_FORMAT = (r'%[1-9]+\$' -+ r'([-#+ 0,(]*)([0-9]+)?(\.[0-9]+)?' -+ r'([bBhHsScCdoxXeEfgGaAtT%n])') -+# Chrome l10n format. -+_CHROME_FORMAT = r'\$+\d' -+# Windows EWT numeric and GRIT %s %d formats. -+_OTHER_FORMAT = r'%[0-9sd]' -+ -+# Finds formatters that must be in a placeholder () element. -+_FORMATTERS = lazy_re.compile( -+ '(%s)|(%s)|(%s)' % (_ANDROID_FORMAT, _CHROME_FORMAT, _OTHER_FORMAT)) -+_BAD_PLACEHOLDER_MSG = ('ERROR: Placeholder formatter found outside of ' -+ 'tag in message "%s" in %s.') -+_INVALID_PH_CHAR_MSG = ('ERROR: Invalid format characters found in message ' -+ '"%s" tag in %s.') -+ -+# Finds HTML tag tokens. -+_HTMLTOKEN = lazy_re.compile(r'<[/]?[a-z][a-z0-9]*[^>]*>', re.I) -+ -+# Finds HTML entities. -+_HTMLENTITY = lazy_re.compile(r'&[^\s]*;') -+ -+ -+class MessageNode(base.ContentNode): -+ '''A element.''' -+ -+ # For splitting a list of things that can be separated by commas or -+ # whitespace -+ _SPLIT_RE = lazy_re.compile(r'\s*,\s*|\s+') -+ -+ def __init__(self): -+ super(MessageNode, self).__init__() -+ # Valid after EndParsing, this is the MessageClique that contains the -+ # source message and any translations of it that have been loaded. -+ self.clique = None -+ -+ # We don't send leading and trailing whitespace into the translation -+ # console, but rather tack it onto the source message and any -+ # translations when formatting them into RC files or what have you. -+ self.ws_at_start = '' # Any whitespace characters at the start of the text -+ self.ws_at_end = '' # --"-- at the end of the text -+ -+ # A list of "shortcut groups" this message is in. We check to make sure -+ # that shortcut keys (e.g. &J) within each shortcut group are unique. -+ self.shortcut_groups_ = [] -+ -+ # Formatter-specific data used to control the output of individual strings. -+ # formatter_data is a space separated list of C preprocessor-style -+ # definitions. Names without values are given the empty string value. -+ # Example: "foo=5 bar baz=100" -+ self.formatter_data = {} -+ -+ # Whether or not to convert ... -> U+2026 within Translate(). -+ self._replace_ellipsis = False -+ -+ def _IsValidChild(self, child): -+ return isinstance(child, (PhNode)) -+ -+ def _IsValidAttribute(self, name, value): -+ if name not in [ -+ 'name', 'offset', 'translateable', 'desc', 'meaning', -+ 'internal_comment', 'shortcut_groups', 'custom_type', 'validation_expr', -+ 'use_name_for_id', 'sub_variable', 'formatter_data', -+ 'is_accessibility_with_no_ui' -+ ]: -+ return False -+ if (name in ('translateable', 'sub_variable') and -+ value not in ['true', 'false']): -+ return False -+ return True -+ -+ def SetReplaceEllipsis(self, value): -+ r'''Sets whether to replace ... with \u2026. -+ ''' -+ self._replace_ellipsis = value -+ -+ def MandatoryAttributes(self): -+ return ['name|offset'] -+ -+ def DefaultAttributes(self): -+ return { -+ 'custom_type': '', -+ 'desc': '', -+ 'formatter_data': '', -+ 'internal_comment': '', -+ 'is_accessibility_with_no_ui': 'false', -+ 'meaning': '', -+ 'shortcut_groups': '', -+ 'sub_variable': 'false', -+ 'translateable': 'true', -+ 'use_name_for_id': 'false', -+ 'validation_expr': '', -+ } -+ -+ def HandleAttribute(self, attrib, value): -+ base.ContentNode.HandleAttribute(self, attrib, value) -+ if attrib != 'formatter_data': -+ return -+ -+ # Parse value, a space-separated list of defines, into a dict. -+ # Example: "foo=5 bar" -> {'foo':'5', 'bar':''} -+ for item in value.split(): -+ name, _, val = item.partition('=') -+ self.formatter_data[name] = val -+ -+ def GetTextualIds(self): -+ ''' -+ Returns the concatenation of the parent's node first_id and -+ this node's offset if it has one, otherwise just call the -+ superclass' implementation -+ ''' -+ if 'offset' not in self.attrs: -+ return super(MessageNode, self).GetTextualIds() -+ -+ # we search for the first grouping node in the parents' list -+ # to take care of the case where the first parent is an node -+ grouping_parent = self.parent -+ import grit.node.empty -+ while grouping_parent and not isinstance(grouping_parent, -+ grit.node.empty.GroupingNode): -+ grouping_parent = grouping_parent.parent -+ -+ assert 'first_id' in grouping_parent.attrs -+ return [grouping_parent.attrs['first_id'] + '_' + self.attrs['offset']] -+ -+ def IsTranslateable(self): -+ return self.attrs['translateable'] == 'true' -+ -+ def EndParsing(self): -+ super(MessageNode, self).EndParsing() -+ -+ # Make the text (including placeholder references) and list of placeholders, -+ # verify placeholder formats, then strip and store leading and trailing -+ # whitespace and create the tclib.Message() and a clique to contain it. -+ -+ text = '' -+ placeholders = [] -+ -+ for item in self.mixed_content: -+ if isinstance(item, six.string_types): -+ # Not a element: fail if any formatters are detected. -+ if _FORMATTERS.search(item): -+ print(_BAD_PLACEHOLDER_MSG % (item, self.source)) -+ raise exception.PlaceholderNotInsidePhNode -+ text += item -+ else: -+ # Extract the element components. -+ presentation = item.attrs['name'].upper() -+ text += presentation -+ ex = ' ' # example element cdata if present. -+ if len(item.children): -+ ex = item.children[0].GetCdata() -+ original = item.GetCdata() -+ -+ # Sanity check the element content. -+ cdata = original -+ # Replace all HTML tag tokens in cdata. -+ match = _HTMLTOKEN.search(cdata) -+ while match: -+ cdata = cdata.replace(match.group(0), '_') -+ match = _HTMLTOKEN.search(cdata) -+ # Replace all HTML entities in cdata. -+ match = _HTMLENTITY.search(cdata) -+ while match: -+ cdata = cdata.replace(match.group(0), '_') -+ match = _HTMLENTITY.search(cdata) -+ # Remove first matching formatter from cdata. -+ match = _FORMATTERS.search(cdata) -+ if match: -+ cdata = cdata.replace(match.group(0), '') -+ # Fail if special chars remain in cdata. -+ if re.search(r'[%\$]', cdata): -+ message_id = self.attrs['name'] + ' ' + original; -+ print(_INVALID_PH_CHAR_MSG % (message_id, self.source)) -+ raise exception.InvalidCharactersInsidePhNode -+ -+ # Otherwise, accept this placeholder. -+ placeholders.append(tclib.Placeholder(presentation, original, ex)) -+ -+ m = _WHITESPACE.match(text) -+ if m: -+ self.ws_at_start = m.group('start') -+ self.ws_at_end = m.group('end') -+ text = m.group('body') -+ -+ self.shortcut_groups_ = self._SPLIT_RE.split(self.attrs['shortcut_groups']) -+ self.shortcut_groups_ = [i for i in self.shortcut_groups_ if i != ''] -+ -+ description_or_id = self.attrs['desc'] -+ if description_or_id == '' and 'name' in self.attrs: -+ description_or_id = 'ID: %s' % self.attrs['name'] -+ -+ assigned_id = None -+ if self.attrs['use_name_for_id'] == 'true': -+ assigned_id = self.attrs['name'] -+ message = tclib.Message(text=text, placeholders=placeholders, -+ description=description_or_id, -+ meaning=self.attrs['meaning'], -+ assigned_id=assigned_id) -+ self.InstallMessage(message) -+ -+ def InstallMessage(self, message): -+ '''Sets this node's clique from a tclib.Message instance. -+ -+ Args: -+ message: A tclib.Message. -+ ''' -+ self.clique = self.UberClique().MakeClique(message, self.IsTranslateable()) -+ for group in self.shortcut_groups_: -+ self.clique.AddToShortcutGroup(group) -+ if self.attrs['custom_type'] != '': -+ self.clique.SetCustomType(util.NewClassInstance(self.attrs['custom_type'], -+ clique.CustomType)) -+ elif self.attrs['validation_expr'] != '': -+ self.clique.SetCustomType( -+ clique.OneOffCustomType(self.attrs['validation_expr'])) -+ -+ def SubstituteMessages(self, substituter): -+ '''Applies substitution to this message. -+ -+ Args: -+ substituter: a grit.util.Substituter object. -+ ''' -+ message = substituter.SubstituteMessage(self.clique.GetMessage()) -+ if message is not self.clique.GetMessage(): -+ self.InstallMessage(message) -+ -+ def GetCliques(self): -+ return [self.clique] if self.clique else [] -+ -+ def Translate(self, lang): -+ '''Returns a translated version of this message. -+ ''' -+ assert self.clique -+ msg = self.clique.MessageForLanguage(lang, -+ self.PseudoIsAllowed(), -+ self.ShouldFallbackToEnglish() -+ ).GetRealContent() -+ if self._replace_ellipsis: -+ msg = _ELLIPSIS_PATTERN.sub(_ELLIPSIS_SYMBOL, msg) -+ # Always remove all byte order marks (\uFEFF) https://crbug.com/1033305 -+ msg = msg.replace(u'\uFEFF','') -+ return msg.replace('[GRITLANGCODE]', lang) -+ -+ def NameOrOffset(self): -+ key = 'name' if 'name' in self.attrs else 'offset' -+ return self.attrs[key] -+ -+ def ExpandVariables(self): -+ '''We always expand variables on Messages.''' -+ return True -+ -+ def GetDataPackValue(self, lang, encoding): -+ '''Returns a str represenation for a data_pack entry.''' -+ message = self.ws_at_start + self.Translate(lang) + self.ws_at_end -+ return util.Encode(message, encoding) -+ -+ def IsResourceMapSource(self): -+ return True -+ -+ @staticmethod -+ def Construct(parent, message, name, desc='', meaning='', translateable=True): -+ '''Constructs a new message node that is a child of 'parent', with the -+ name, desc, meaning and translateable attributes set using the same-named -+ parameters and the text of the message and any placeholders taken from -+ 'message', which must be a tclib.Message() object.''' -+ # Convert type to appropriate string -+ translateable = 'true' if translateable else 'false' -+ -+ node = MessageNode() -+ node.StartParsing('message', parent) -+ node.HandleAttribute('name', name) -+ node.HandleAttribute('desc', desc) -+ node.HandleAttribute('meaning', meaning) -+ node.HandleAttribute('translateable', translateable) -+ -+ items = message.GetContent() -+ for ix, item in enumerate(items): -+ if isinstance(item, six.string_types): -+ # Ensure whitespace at front and back of message is correctly handled. -+ if ix == 0: -+ item = "'''" + item -+ if ix == len(items) - 1: -+ item = item + "'''" -+ -+ node.AppendContent(item) -+ else: -+ phnode = PhNode() -+ phnode.StartParsing('ph', node) -+ phnode.HandleAttribute('name', item.GetPresentation()) -+ phnode.AppendContent(item.GetOriginal()) -+ -+ if len(item.GetExample()) and item.GetExample() != ' ': -+ exnode = ExNode() -+ exnode.StartParsing('ex', phnode) -+ exnode.AppendContent(item.GetExample()) -+ exnode.EndParsing() -+ phnode.AddChild(exnode) -+ -+ phnode.EndParsing() -+ node.AddChild(phnode) -+ -+ node.EndParsing() -+ return node -+ -+ -+class PhNode(base.ContentNode): -+ '''A element.''' -+ -+ def _IsValidChild(self, child): -+ return isinstance(child, ExNode) -+ -+ def MandatoryAttributes(self): -+ return ['name'] -+ -+ def EndParsing(self): -+ super(PhNode, self).EndParsing() -+ # We only allow a single example for each placeholder -+ if len(self.children) > 1: -+ raise exception.TooManyExamples() -+ -+ def GetTextualIds(self): -+ # The 'name' attribute is not an ID. -+ return [] -+ -+ -+class ExNode(base.ContentNode): -+ '''An element.''' -+ pass -diff --git a/tools/grit/grit/node/message_unittest.py b/tools/grit/grit/node/message_unittest.py -new file mode 100644 -index 0000000000..7a4cbbedc2 ---- /dev/null -+++ b/tools/grit/grit/node/message_unittest.py -@@ -0,0 +1,380 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.node.message''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+import unittest -+ -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+from grit import exception -+from grit import tclib -+from grit import util -+from grit.node import message -+ -+class MessageUnittest(unittest.TestCase): -+ def testMessage(self): -+ root = util.ParseGrdForUnittest(''' -+ -+ -+ Hello %sJoi, how are you doing today? -+ -+ ''') -+ msg, = root.GetChildrenOfType(message.MessageNode) -+ cliques = msg.GetCliques() -+ content = cliques[0].GetMessage().GetPresentableContent() -+ self.failUnless(content == 'Hello USERNAME, how are you doing today?') -+ -+ def testMessageWithWhitespace(self): -+ root = util.ParseGrdForUnittest("""\ -+ -+ -+ ''' Hello there %s ''' -+ -+ """) -+ msg, = root.GetChildrenOfType(message.MessageNode) -+ content = msg.GetCliques()[0].GetMessage().GetPresentableContent() -+ self.failUnless(content == 'Hello there USERNAME') -+ self.failUnless(msg.ws_at_start == ' ') -+ self.failUnless(msg.ws_at_end == ' ') -+ -+ def testConstruct(self): -+ msg = tclib.Message(text=" Hello USERNAME, how are you? BINGO\t\t", -+ placeholders=[tclib.Placeholder('USERNAME', '%s', 'Joi'), -+ tclib.Placeholder('BINGO', '%d', '11')]) -+ msg_node = message.MessageNode.Construct(None, msg, 'BINGOBONGO') -+ self.failUnless(msg_node.children[0].name == 'ph') -+ self.failUnless(msg_node.children[0].children[0].name == 'ex') -+ self.failUnless(msg_node.children[0].children[0].GetCdata() == 'Joi') -+ self.failUnless(msg_node.children[1].children[0].GetCdata() == '11') -+ self.failUnless(msg_node.ws_at_start == ' ') -+ self.failUnless(msg_node.ws_at_end == '\t\t') -+ -+ def testUnicodeConstruct(self): -+ text = u'Howdie \u00fe' -+ msg = tclib.Message(text=text) -+ msg_node = message.MessageNode.Construct(None, msg, 'BINGOBONGO') -+ msg_from_node = msg_node.GetCdata() -+ self.failUnless(msg_from_node == text) -+ -+ def testFormatterData(self): -+ root = util.ParseGrdForUnittest("""\ -+ -+ -+ Text -+ -+ """) -+ msg, = root.GetChildrenOfType(message.MessageNode) -+ expected_formatter_data = { -+ 'foo': '123', -+ 'bar': '', -+ 'qux': 'low'} -+ -+ # Can't use assertDictEqual, not available in Python 2.6, so do it -+ # by hand. -+ self.failUnlessEqual(len(expected_formatter_data), -+ len(msg.formatter_data)) -+ for key in expected_formatter_data: -+ self.failUnlessEqual(expected_formatter_data[key], -+ msg.formatter_data[key]) -+ -+ def testReplaceEllipsis(self): -+ root = util.ParseGrdForUnittest(''' -+ -+ -+ A...B.... %sA... B... C... -+ -+ ''') -+ msg, = root.GetChildrenOfType(message.MessageNode) -+ msg.SetReplaceEllipsis(True) -+ content = msg.Translate('en') -+ self.failUnlessEqual(u'A...B.... %s\u2026 B\u2026 C\u2026', content) -+ -+ def testRemoveByteOrderMark(self): -+ root = util.ParseGrdForUnittest(u''' -+ -+ -+ \uFEFFThis\uFEFF i\uFEFFs OK\uFEFF -+ -+ ''') -+ msg, = root.GetChildrenOfType(message.MessageNode) -+ content = msg.Translate('en') -+ self.failUnlessEqual(u'This is OK', content) -+ -+ def testPlaceholderHasTooManyExamples(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ Hi $1JoiJoy -+ -+ """) -+ except exception.TooManyExamples: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testPlaceholderHasInvalidName(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ Hi $1 -+ -+ """) -+ except exception.InvalidPlaceholderName: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testChromeLocalizedFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing the ph node: $1 -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testAndroidStringFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing a ph node: %1$s -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testAndroidIntegerFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing a ph node: %2$d -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testAndroidIntegerWidthFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing a ph node: %2$3d -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testValidAndroidIntegerWidthFormatInPhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ %2$3d042 -+ -+ """) -+ except: -+ self.fail('Should not have gotten exception') -+ -+ def testAndroidFloatFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing a ph node: %3$4.5f -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testGritStringFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing the ph node: %s -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testGritIntegerFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing the ph node: %d -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testWindowsETWIntegerFormatIsInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ This message is missing the ph node: %1 -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testValidMultipleFormattersInsidePhNodes(self): -+ root = util.ParseGrdForUnittest("""\ -+ -+ -+ %1$d1 error, %2$d1 warning -+ -+ """) -+ msg, = root.GetChildrenOfType(message.MessageNode) -+ cliques = msg.GetCliques() -+ content = cliques[0].GetMessage().GetPresentableContent() -+ self.failUnless(content == 'ERROR_COUNT error, WARNING_COUNT warning') -+ -+ def testMultipleFormattersAreInsidePhNodes(self): -+ failed = True -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ %1$d error, %2$d warning -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ failed = False -+ if failed: -+ self.fail('Should have gotten exception') -+ return -+ -+ failed = True -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ %1$d1 error, %2$d warning -+ -+ """) -+ except exception.PlaceholderNotInsidePhNode: -+ failed = False -+ if failed: -+ self.fail('Should have gotten exception') -+ return -+ -+ failed = True -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ %1$d %2$d -+ -+ """) -+ except exception.InvalidCharactersInsidePhNode: -+ failed = False -+ if failed: -+ self.fail('Should have gotten exception') -+ return -+ -+ def testValidHTMLFormatInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ <span>$1</span>1 -+ -+ """) -+ except: -+ self.fail('Should not have gotten exception') -+ -+ def testValidHTMLWithAttributesFormatInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ <span attribute="js:$this %">$2</span>2 -+ -+ """) -+ except: -+ self.fail('Should not have gotten exception') -+ -+ def testValidHTMLEntityFormatInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ >%1$d<1 -+ -+ """) -+ except: -+ self.fail('Should not have gotten exception') -+ -+ def testValidMultipleDollarFormatInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ $$1 -+ -+ """) -+ except: -+ self.fail('Should not have gotten exception') -+ -+ def testInvalidDollarCharacterInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ %1$d $ -+ -+ """) -+ except exception.InvalidCharactersInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testInvalidPercentCharacterInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ %1$d % -+ -+ """) -+ except exception.InvalidCharactersInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ def testInvalidMixedFormatCharactersInsidePhNode(self): -+ try: -+ util.ParseGrdForUnittest("""\ -+ -+ -+ %1$2 -+ -+ """) -+ except exception.InvalidCharactersInsidePhNode: -+ return -+ self.fail('Should have gotten exception') -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/misc.py b/tools/grit/grit/node/misc.py -new file mode 100644 -index 0000000000..2d8b06d6a5 ---- /dev/null -+++ b/tools/grit/grit/node/misc.py -@@ -0,0 +1,707 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""Miscellaneous node types. -+""" -+ -+from __future__ import print_function -+ -+import os.path -+import re -+import sys -+ -+import six -+ -+from grit import constants -+from grit import exception -+from grit import util -+from grit.extern import FP -+from grit.node import base -+from grit.node import message -+from grit.node import node_io -+ -+ -+# Python 3 doesn't have long() as int() works everywhere. But we really do need -+# the long() behavior on Python 2 as our ids are much too large for int(). -+try: -+ long -+except NameError: -+ long = int -+ -+ -+# RTL languages -+# TODO(jennyz): remove this fixed set of RTL language array -+# now that generic expand_variable code exists. -+_RTL_LANGS = ( -+ 'ar', # Arabic -+ 'fa', # Farsi -+ 'iw', # Hebrew -+ 'ks', # Kashmiri -+ 'ku', # Kurdish -+ 'ps', # Pashto -+ 'ur', # Urdu -+ 'yi', # Yiddish -+) -+ -+ -+def _ReadFirstIdsFromFile(filename, defines): -+ """Read the starting resource id values from |filename|. We also -+ expand variables of the form <(FOO) based on defines passed in on -+ the command line. -+ -+ Returns a tuple, the absolute path of SRCDIR followed by the -+ first_ids dictionary. -+ """ -+ first_ids_dict = eval(util.ReadFile(filename, 'utf-8')) -+ src_root_dir = os.path.abspath(os.path.join(os.path.dirname(filename), -+ first_ids_dict['SRCDIR'])) -+ -+ def ReplaceVariable(matchobj): -+ for key, value in defines.items(): -+ if matchobj.group(1) == key: -+ return value -+ return '' -+ -+ renames = [] -+ for grd_filename in first_ids_dict: -+ new_grd_filename = re.sub(r'<\(([A-Za-z_]+)\)', ReplaceVariable, -+ grd_filename) -+ if new_grd_filename != grd_filename: -+ abs_grd_filename = os.path.abspath(new_grd_filename) -+ if abs_grd_filename[:len(src_root_dir)] != src_root_dir: -+ new_grd_filename = os.path.basename(abs_grd_filename) -+ else: -+ new_grd_filename = abs_grd_filename[len(src_root_dir) + 1:] -+ new_grd_filename = new_grd_filename.replace('\\', '/') -+ renames.append((grd_filename, new_grd_filename)) -+ -+ for grd_filename, new_grd_filename in renames: -+ first_ids_dict[new_grd_filename] = first_ids_dict[grd_filename] -+ del(first_ids_dict[grd_filename]) -+ -+ return (src_root_dir, first_ids_dict) -+ -+ -+def _ComputeIds(root, predetermined_tids): -+ """Returns a dict of textual id -> numeric id for all nodes in root. -+ -+ IDs are mostly assigned sequentially, but will vary based on: -+ * first_id node attribute (from first_ids_file) -+ * hash of textual id (if not first_id is defined) -+ * offset node attribute -+ * whether the textual id matches a system id -+ * whether the node generates its own ID via GetId() -+ -+ Args: -+ predetermined_tids: Dict of textual id -> numeric id to use in return dict. -+ """ -+ from grit.node import empty, include, misc, structure -+ -+ ids = {} # Maps numeric id to textual id -+ tids = {} # Maps textual id to numeric id -+ id_reasons = {} # Maps numeric id to text id and a human-readable explanation -+ group = None -+ last_id = None -+ predetermined_ids = {value: key -+ for key, value in predetermined_tids.items()} -+ -+ for item in root: -+ if isinstance(item, empty.GroupingNode): -+ # Note: this won't work if any GroupingNode can be contained inside -+ # another. -+ group = item -+ last_id = None -+ continue -+ -+ assert not item.GetTextualIds() or isinstance(item, -+ (include.IncludeNode, message.MessageNode, -+ misc.IdentifierNode, structure.StructureNode)) -+ -+ # Resources that use the RES protocol don't need -+ # any numerical ids generated, so we skip them altogether. -+ # This is accomplished by setting the flag 'generateid' to false -+ # in the GRD file. -+ if item.attrs.get('generateid', 'true') == 'false': -+ continue -+ -+ for tid in item.GetTextualIds(): -+ if util.SYSTEM_IDENTIFIERS.match(tid): -+ # Don't emit a new ID for predefined IDs -+ continue -+ -+ if tid in tids: -+ continue -+ -+ if predetermined_tids and tid in predetermined_tids: -+ id = predetermined_tids[tid] -+ reason = "from predetermined_tids map" -+ -+ # Some identifier nodes can provide their own id, -+ # and we use that id in the generated header in that case. -+ elif hasattr(item, 'GetId') and item.GetId(): -+ id = long(item.GetId()) -+ reason = 'returned by GetId() method' -+ -+ elif ('offset' in item.attrs and group and -+ group.attrs.get('first_id', '') != ''): -+ offset_text = item.attrs['offset'] -+ parent_text = group.attrs['first_id'] -+ -+ try: -+ offset_id = long(offset_text) -+ except ValueError: -+ offset_id = tids[offset_text] -+ -+ try: -+ parent_id = long(parent_text) -+ except ValueError: -+ parent_id = tids[parent_text] -+ -+ id = parent_id + offset_id -+ reason = 'first_id %d + offset %d' % (parent_id, offset_id) -+ -+ # We try to allocate IDs sequentially for blocks of items that might -+ # be related, for instance strings in a stringtable (as their IDs might be -+ # used e.g. as IDs for some radio buttons, in which case the IDs must -+ # be sequential). -+ # -+ # We do this by having the first item in a section store its computed ID -+ # (computed from a fingerprint) in its parent object. Subsequent children -+ # of the same parent will then try to get IDs that sequentially follow -+ # the currently stored ID (on the parent) and increment it. -+ elif last_id is None: -+ # First check if the starting ID is explicitly specified by the parent. -+ if group and group.attrs.get('first_id', '') != '': -+ id = long(group.attrs['first_id']) -+ reason = "from parent's first_id attribute" -+ else: -+ # Automatically generate the ID based on the first clique from the -+ # first child of the first child node of our parent (i.e. when we -+ # first get to this location in the code). -+ -+ # According to -+ # http://msdn.microsoft.com/en-us/library/t2zechd4(VS.71).aspx -+ # the safe usable range for resource IDs in Windows is from decimal -+ # 101 to 0x7FFF. -+ -+ id = FP.UnsignedFingerPrint(tid) -+ id = id % (0x7FFF - 101) + 101 -+ reason = 'chosen by random fingerprint -- use first_id to override' -+ -+ last_id = id -+ else: -+ id = last_id = last_id + 1 -+ reason = 'sequentially assigned' -+ -+ reason = "%s (%s)" % (tid, reason) -+ # Don't fail when 'offset' is specified, as the base and the 0th -+ # offset will have the same ID. -+ if id in id_reasons and not 'offset' in item.attrs: -+ raise exception.IdRangeOverlap('ID %d was assigned to both %s and %s.' -+ % (id, id_reasons[id], reason)) -+ -+ if id < 101: -+ print('WARNING: Numeric resource IDs should be greater than 100 to\n' -+ 'avoid conflicts with system-defined resource IDs.') -+ -+ if tid not in predetermined_tids and id in predetermined_ids: -+ raise exception.IdRangeOverlap('ID %d overlaps between %s and %s' -+ % (id, tid, predetermined_ids[tid])) -+ -+ ids[id] = tid -+ tids[tid] = id -+ id_reasons[id] = reason -+ -+ return tids -+ -+class SplicingNode(base.Node): -+ """A node whose children should be considered to be at the same level as -+ its siblings for most purposes. This includes and nodes. -+ """ -+ -+ def _IsValidChild(self, child): -+ assert self.parent, '<%s> node should never be root.' % self.name -+ if isinstance(child, SplicingNode): -+ return True # avoid O(n^2) behavior -+ return self.parent._IsValidChild(child) -+ -+ -+class IfNode(SplicingNode): -+ """A node for conditional inclusion of resources. -+ """ -+ -+ def MandatoryAttributes(self): -+ return ['expr'] -+ -+ def _IsValidChild(self, child): -+ return (isinstance(child, (ThenNode, ElseNode)) or -+ super(IfNode, self)._IsValidChild(child)) -+ -+ def EndParsing(self): -+ children = self.children -+ self.if_then_else = False -+ if any(isinstance(node, (ThenNode, ElseNode)) for node in children): -+ if (len(children) != 2 or not isinstance(children[0], ThenNode) or -+ not isinstance(children[1], ElseNode)): -+ raise exception.UnexpectedChild( -+ ' element must be ......') -+ self.if_then_else = True -+ -+ def ActiveChildren(self): -+ cond = self.EvaluateCondition(self.attrs['expr']) -+ if self.if_then_else: -+ return self.children[0 if cond else 1].ActiveChildren() -+ else: -+ # Equivalent to having all children inside with an empty -+ return super(IfNode, self).ActiveChildren() if cond else [] -+ -+ -+class ThenNode(SplicingNode): -+ """A node. Can only appear directly inside an node.""" -+ pass -+ -+ -+class ElseNode(SplicingNode): -+ """An node. Can only appear directly inside an node.""" -+ pass -+ -+ -+class PartNode(SplicingNode): -+ """A node for inclusion of sub-grd (*.grp) files. -+ """ -+ -+ def __init__(self): -+ super(PartNode, self).__init__() -+ self.started_inclusion = False -+ -+ def MandatoryAttributes(self): -+ return ['file'] -+ -+ def _IsValidChild(self, child): -+ return self.started_inclusion and super(PartNode, self)._IsValidChild(child) -+ -+ -+class ReleaseNode(base.Node): -+ """The element.""" -+ -+ def _IsValidChild(self, child): -+ from grit.node import empty -+ return isinstance(child, (empty.IncludesNode, empty.MessagesNode, -+ empty.StructuresNode, empty.IdentifiersNode)) -+ -+ def _IsValidAttribute(self, name, value): -+ return ( -+ (name == 'seq' and int(value) <= self.GetRoot().GetCurrentRelease()) or -+ name == 'allow_pseudo' -+ ) -+ -+ def MandatoryAttributes(self): -+ return ['seq'] -+ -+ def DefaultAttributes(self): -+ return { 'allow_pseudo' : 'true' } -+ -+ -+class GritNode(base.Node): -+ """The root element.""" -+ -+ def __init__(self): -+ super(GritNode, self).__init__() -+ self.output_language = '' -+ self.defines = {} -+ self.substituter = None -+ self.target_platform = sys.platform -+ self.whitelist_support = False -+ self._predetermined_ids_file = None -+ self._id_map = None # Dict of textual_id -> numeric_id. -+ -+ def _IsValidChild(self, child): -+ from grit.node import empty -+ return isinstance(child, (ReleaseNode, empty.TranslationsNode, -+ empty.OutputsNode)) -+ -+ def _IsValidAttribute(self, name, value): -+ if name not in ['base_dir', 'first_ids_file', 'source_lang_id', -+ 'latest_public_release', 'current_release', -+ 'enc_check', 'tc_project', 'grit_version', -+ 'output_all_resource_defines']: -+ return False -+ if name in ['latest_public_release', 'current_release'] and value.strip( -+ '0123456789') != '': -+ return False -+ return True -+ -+ def MandatoryAttributes(self): -+ return ['latest_public_release', 'current_release'] -+ -+ def DefaultAttributes(self): -+ return { -+ 'base_dir' : '.', -+ 'first_ids_file': '', -+ 'grit_version': 1, -+ 'source_lang_id' : 'en', -+ 'enc_check' : constants.ENCODING_CHECK, -+ 'tc_project' : 'NEED_TO_SET_tc_project_ATTRIBUTE', -+ } -+ -+ def EndParsing(self): -+ super(GritNode, self).EndParsing() -+ if (int(self.attrs['latest_public_release']) -+ > int(self.attrs['current_release'])): -+ raise exception.Parsing('latest_public_release cannot have a greater ' -+ 'value than current_release') -+ -+ self.ValidateUniqueIds() -+ -+ # Add the encoding check if it's not present (should ensure that it's always -+ # present in all .grd files generated by GRIT). If it's present, assert if -+ # it's not correct. -+ if 'enc_check' not in self.attrs or self.attrs['enc_check'] == '': -+ self.attrs['enc_check'] = constants.ENCODING_CHECK -+ else: -+ assert self.attrs['enc_check'] == constants.ENCODING_CHECK, ( -+ 'Are you sure your .grd file is in the correct encoding (UTF-8)?') -+ -+ def ValidateUniqueIds(self): -+ """Validate that 'name' attribute is unique in all nodes in this tree -+ except for nodes that are children of nodes. -+ """ -+ unique_names = {} -+ duplicate_names = [] -+ # To avoid false positives from mutually exclusive clauses, check -+ # against whatever the output condition happens to be right now. -+ # TODO(benrg): do something better. -+ for node in self.ActiveDescendants(): -+ if node.attrs.get('generateid', 'true') == 'false': -+ continue # Duplication not relevant in that case -+ -+ for node_id in node.GetTextualIds(): -+ if util.SYSTEM_IDENTIFIERS.match(node_id): -+ continue # predefined IDs are sometimes used more than once -+ -+ if node_id in unique_names and node_id not in duplicate_names: -+ duplicate_names.append(node_id) -+ unique_names[node_id] = 1 -+ -+ if len(duplicate_names): -+ raise exception.DuplicateKey(', '.join(duplicate_names)) -+ -+ -+ def GetCurrentRelease(self): -+ """Returns the current release number.""" -+ return int(self.attrs['current_release']) -+ -+ def GetLatestPublicRelease(self): -+ """Returns the latest public release number.""" -+ return int(self.attrs['latest_public_release']) -+ -+ def GetSourceLanguage(self): -+ """Returns the language code of the source language.""" -+ return self.attrs['source_lang_id'] -+ -+ def GetTcProject(self): -+ """Returns the name of this project in the TranslationConsole, or -+ 'NEED_TO_SET_tc_project_ATTRIBUTE' if it is not defined.""" -+ return self.attrs['tc_project'] -+ -+ def SetOwnDir(self, dir): -+ """Informs the 'grit' element of the directory the file it is in resides. -+ This allows it to calculate relative paths from the input file, which is -+ what we desire (rather than from the current path). -+ -+ Args: -+ dir: r'c:\bla' -+ -+ Return: -+ None -+ """ -+ assert dir -+ self.base_dir = os.path.normpath(os.path.join(dir, self.attrs['base_dir'])) -+ -+ def GetBaseDir(self): -+ """Returns the base directory, relative to the working directory. To get -+ the base directory as set in the .grd file, use GetOriginalBaseDir() -+ """ -+ if hasattr(self, 'base_dir'): -+ return self.base_dir -+ else: -+ return self.GetOriginalBaseDir() -+ -+ def GetOriginalBaseDir(self): -+ """Returns the base directory, as set in the .grd file. -+ """ -+ return self.attrs['base_dir'] -+ -+ def IsWhitelistSupportEnabled(self): -+ return self.whitelist_support -+ -+ def SetWhitelistSupportEnabled(self, whitelist_support): -+ self.whitelist_support = whitelist_support -+ -+ def GetInputFiles(self): -+ """Returns the list of files that are read to produce the output.""" -+ -+ # Importing this here avoids a circular dependency in the imports. -+ # pylint: disable-msg=C6204 -+ from grit.node import include -+ from grit.node import misc -+ from grit.node import structure -+ from grit.node import variant -+ -+ # Check if the input is required for any output configuration. -+ input_files = set() -+ # Collect even inactive PartNodes since they affect ID assignments. -+ for node in self: -+ if isinstance(node, misc.PartNode): -+ input_files.add(self.ToRealPath(node.GetInputPath())) -+ -+ old_output_language = self.output_language -+ for lang, ctx, fallback in self.GetConfigurations(): -+ self.SetOutputLanguage(lang or self.GetSourceLanguage()) -+ self.SetOutputContext(ctx) -+ self.SetFallbackToDefaultLayout(fallback) -+ -+ for node in self.ActiveDescendants(): -+ if isinstance(node, (node_io.FileNode, include.IncludeNode, -+ structure.StructureNode, variant.SkeletonNode)): -+ input_path = node.GetInputPath() -+ if input_path is not None: -+ input_files.add(self.ToRealPath(input_path)) -+ -+ # If it's a flattened node, grab inlined resources too. -+ if ((node.name == 'structure' or node.name == 'include') -+ and node.attrs['flattenhtml'] == 'true'): -+ if node.name == 'structure': -+ node.RunPreSubstitutionGatherer() -+ input_files.update(node.GetHtmlResourceFilenames()) -+ -+ self.SetOutputLanguage(old_output_language) -+ return sorted(input_files) -+ -+ def GetFirstIdsFile(self): -+ """Returns a usable path to the first_ids file, if set, otherwise -+ returns None. -+ -+ The first_ids_file attribute is by default relative to the -+ base_dir of the .grd file, but may be prefixed by GRIT_DIR/, -+ which makes it relative to the directory of grit.py -+ (e.g. GRIT_DIR/../gritsettings/resource_ids). -+ """ -+ if not self.attrs['first_ids_file']: -+ return None -+ -+ path = self.attrs['first_ids_file'] -+ GRIT_DIR_PREFIX = 'GRIT_DIR' -+ if (path.startswith(GRIT_DIR_PREFIX) -+ and path[len(GRIT_DIR_PREFIX)] in ['/', '\\']): -+ return util.PathFromRoot(path[len(GRIT_DIR_PREFIX) + 1:]) -+ else: -+ return self.ToRealPath(path) -+ -+ def GetOutputFiles(self): -+ """Returns the list of nodes that are descendants of this node's -+ child and are not enclosed by unsatisfied conditionals. -+ """ -+ for child in self.children: -+ if child.name == 'outputs': -+ return [node for node in child.ActiveDescendants() -+ if node.name == 'output'] -+ raise exception.MissingElement() -+ -+ def GetConfigurations(self): -+ """Returns the distinct (language, context, fallback_to_default_layout) -+ triples from the output nodes. -+ """ -+ return set((n.GetLanguage(), n.GetContext(), n.GetFallbackToDefaultLayout()) -+ for n in self.GetOutputFiles()) -+ -+ def GetSubstitutionMessages(self): -+ """Returns the list of nodes.""" -+ return [n for n in self.ActiveDescendants() -+ if isinstance(n, message.MessageNode) -+ and n.attrs['sub_variable'] == 'true'] -+ -+ def SetOutputLanguage(self, output_language): -+ """Set the output language. Prepares substitutions. -+ -+ The substitutions are reset every time the language is changed. -+ They include messages designated as variables, and language codes for html -+ and rc files. -+ -+ Args: -+ output_language: a two-letter language code (eg: 'en', 'ar'...) or '' -+ """ -+ if not output_language: -+ # We do not specify the output language for .grh files, -+ # so we get an empty string as the default. -+ # The value should match grit.clique.MessageClique.source_language. -+ output_language = self.GetSourceLanguage() -+ if output_language != self.output_language: -+ self.output_language = output_language -+ self.substituter = None # force recalculate -+ -+ def SetOutputContext(self, output_context): -+ self.output_context = output_context -+ self.substituter = None # force recalculate -+ -+ def SetFallbackToDefaultLayout(self, fallback_to_default_layout): -+ self.fallback_to_default_layout = fallback_to_default_layout -+ self.substituter = None # force recalculate -+ -+ def SetDefines(self, defines): -+ self.defines = defines -+ self.substituter = None # force recalculate -+ -+ def SetTargetPlatform(self, target_platform): -+ self.target_platform = target_platform -+ -+ def GetSubstituter(self): -+ if self.substituter is None: -+ self.substituter = util.Substituter() -+ self.substituter.AddMessages(self.GetSubstitutionMessages(), -+ self.output_language) -+ if self.output_language in _RTL_LANGS: -+ direction = 'dir="RTL"' -+ else: -+ direction = 'dir="LTR"' -+ self.substituter.AddSubstitutions({ -+ 'GRITLANGCODE': self.output_language, -+ 'GRITDIR': direction, -+ }) -+ from grit.format import rc # avoid circular dep -+ rc.RcSubstitutions(self.substituter, self.output_language) -+ return self.substituter -+ -+ def AssignFirstIds(self, filename_or_stream, defines): -+ """Assign first ids to each grouping node based on values from the -+ first_ids file (if specified on the node). -+ """ -+ assert self._id_map is None, 'AssignFirstIds() after InitializeIds()' -+ # If the input is a stream, then we're probably in a unit test and -+ # should skip this step. -+ if not isinstance(filename_or_stream, six.string_types): -+ return -+ -+ # Nothing to do if the first_ids_filename attribute isn't set. -+ first_ids_filename = self.GetFirstIdsFile() -+ if not first_ids_filename: -+ return -+ -+ src_root_dir, first_ids = _ReadFirstIdsFromFile(first_ids_filename, -+ defines) -+ from grit.node import empty -+ for node in self.Preorder(): -+ if isinstance(node, empty.GroupingNode): -+ abs_filename = os.path.abspath(filename_or_stream) -+ if abs_filename[:len(src_root_dir)] != src_root_dir: -+ filename = os.path.basename(filename_or_stream) -+ else: -+ filename = abs_filename[len(src_root_dir) + 1:] -+ filename = filename.replace('\\', '/') -+ -+ if node.attrs['first_id'] != '': -+ raise Exception( -+ "Don't set the first_id attribute when using the first_ids_file " -+ "attribute on the node, update %s instead." % -+ first_ids_filename) -+ -+ try: -+ id_list = first_ids[filename][node.name] -+ except KeyError as e: -+ print('-' * 78) -+ print('Resource id not set for %s (%s)!' % (filename, node.name)) -+ print('Please update %s to include an entry for %s. See the ' -+ 'comments in resource_ids for information on why you need to ' -+ 'update that file.' % (first_ids_filename, filename)) -+ print('-' * 78) -+ raise e -+ -+ try: -+ node.attrs['first_id'] = str(id_list.pop(0)) -+ except IndexError as e: -+ raise Exception('Please update %s and add a first id for %s (%s).' -+ % (first_ids_filename, filename, node.name)) -+ -+ def GetIdMap(self): -+ '''Return a dictionary mapping textual ids to numeric ids.''' -+ return self._id_map -+ -+ def SetPredeterminedIdsFile(self, predetermined_ids_file): -+ assert self._id_map is None, ( -+ 'SetPredeterminedIdsFile() after InitializeIds()') -+ self._predetermined_ids_file = predetermined_ids_file -+ -+ def InitializeIds(self): -+ '''Initializes the text ID -> numeric ID mapping.''' -+ predetermined_id_map = {} -+ if self._predetermined_ids_file: -+ with open(self._predetermined_ids_file) as f: -+ for line in f: -+ tid, nid = line.split() -+ predetermined_id_map[tid] = int(nid) -+ self._id_map = _ComputeIds(self, predetermined_id_map) -+ -+ def RunGatherers(self, debug=False): -+ '''Call RunPreSubstitutionGatherer() on every node of the tree, then apply -+ substitutions, then call RunPostSubstitutionGatherer() on every node. -+ -+ The substitutions step requires that the output language has been set. -+ Locally, get the Substitution messages and add them to the substituter. -+ Also add substitutions for language codes in the Rc. -+ -+ Args: -+ debug: will print information while running gatherers. -+ ''' -+ for node in self.ActiveDescendants(): -+ if hasattr(node, 'RunPreSubstitutionGatherer'): -+ with node: -+ node.RunPreSubstitutionGatherer(debug=debug) -+ -+ assert self.output_language -+ self.SubstituteMessages(self.GetSubstituter()) -+ -+ for node in self.ActiveDescendants(): -+ if hasattr(node, 'RunPostSubstitutionGatherer'): -+ with node: -+ node.RunPostSubstitutionGatherer(debug=debug) -+ -+ -+class IdentifierNode(base.Node): -+ """A node for specifying identifiers that should appear in the resource -+ header file, and be unique amongst all other resource identifiers, but don't -+ have any other attributes or reference any resources. -+ """ -+ -+ def MandatoryAttributes(self): -+ return ['name'] -+ -+ def DefaultAttributes(self): -+ return { 'comment' : '', 'id' : '', 'systemid': 'false' } -+ -+ def GetId(self): -+ """Returns the id of this identifier if it has one, None otherwise -+ """ -+ if 'id' in self.attrs: -+ return self.attrs['id'] -+ return None -+ -+ def EndParsing(self): -+ """Handles system identifiers.""" -+ super(IdentifierNode, self).EndParsing() -+ if self.attrs['systemid'] == 'true': -+ util.SetupSystemIdentifiers((self.attrs['name'],)) -+ -+ @staticmethod -+ def Construct(parent, name, id, comment, systemid='false'): -+ """Creates a new node which is a child of 'parent', with attributes set -+ by parameters of the same name. -+ """ -+ node = IdentifierNode() -+ node.StartParsing('identifier', parent) -+ node.HandleAttribute('name', name) -+ node.HandleAttribute('id', id) -+ node.HandleAttribute('comment', comment) -+ node.HandleAttribute('systemid', systemid) -+ node.EndParsing() -+ return node -diff --git a/tools/grit/grit/node/misc_unittest.py b/tools/grit/grit/node/misc_unittest.py -new file mode 100644 -index 0000000000..c192b096f4 ---- /dev/null -+++ b/tools/grit/grit/node/misc_unittest.py -@@ -0,0 +1,590 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for misc.GritNode''' -+ -+from __future__ import print_function -+ -+import contextlib -+import os -+import sys -+import tempfile -+import unittest -+ -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+from six import StringIO -+ -+from grit import grd_reader -+import grit.exception -+from grit import util -+from grit.format import rc -+from grit.format import rc_header -+from grit.node import misc -+ -+ -+@contextlib.contextmanager -+def _MakeTempPredeterminedIdsFile(content): -+ """Write the |content| string to a temporary file. -+ -+ The temporary file must be deleted by the caller. -+ -+ Example: -+ with _MakeTempPredeterminedIdsFile('foo') as path: -+ ... -+ os.remove(path) -+ -+ Args: -+ content: The string to write. -+ -+ Yields: -+ The name of the temporary file. -+ """ -+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as f: -+ f.write(content) -+ f.flush() -+ f.close() -+ yield f.name -+ -+ -+class GritNodeUnittest(unittest.TestCase): -+ def testUniqueNameAttribute(self): -+ try: -+ restree = grd_reader.Parse( -+ util.PathFromRoot('grit/testdata/duplicate-name-input.xml')) -+ self.fail('Expected parsing exception because of duplicate names.') -+ except grit.exception.Parsing: -+ pass # Expected case -+ -+ def testReadFirstIdsFromFile(self): -+ test_resource_ids = os.path.join(os.path.dirname(__file__), '..', -+ 'testdata', 'resource_ids') -+ base_dir = os.path.dirname(test_resource_ids) -+ -+ src_dir, id_dict = misc._ReadFirstIdsFromFile( -+ test_resource_ids, -+ { -+ 'FOO': os.path.join(base_dir, 'bar'), -+ 'SHARED_INTERMEDIATE_DIR': os.path.join(base_dir, -+ 'out/Release/obj/gen'), -+ }) -+ self.assertEqual({}, id_dict.get('bar/file.grd', None)) -+ self.assertEqual({}, -+ id_dict.get('out/Release/obj/gen/devtools/devtools.grd', None)) -+ -+ src_dir, id_dict = misc._ReadFirstIdsFromFile( -+ test_resource_ids, -+ { -+ 'SHARED_INTERMEDIATE_DIR': '/outside/src_dir', -+ }) -+ self.assertEqual({}, id_dict.get('devtools.grd', None)) -+ -+ # Verifies that GetInputFiles() returns the correct list of files -+ # corresponding to ChromeScaledImage nodes when assets are missing. -+ def testGetInputFilesChromeScaledImage(self): -+ chrome_html_path = util.PathFromRoot('grit/testdata/chrome_html.html') -+ xml = ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''' % chrome_html_path -+ -+ grd = grd_reader.Parse(StringIO(xml), -+ util.PathFromRoot('grit/testdata')) -+ expected = ['chrome_html.html', 'default_100_percent/a.png', -+ 'default_100_percent/b.png', 'included_sample.html', -+ 'special_100_percent/a.png'] -+ actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for -+ path in grd.GetInputFiles()] -+ # Convert path separator for Windows paths. -+ actual = [path.replace('\\', '/') for path in actual] -+ self.assertEquals(expected, actual) -+ -+ # Verifies that GetInputFiles() returns the correct list of files -+ # when files include other files. -+ def testGetInputFilesFromIncludes(self): -+ chrome_html_path = util.PathFromRoot('grit/testdata/chrome_html.html') -+ xml = ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''' % chrome_html_path -+ -+ grd = grd_reader.Parse(StringIO(xml), util.PathFromRoot('grit/testdata')) -+ expected = ['chrome_html.html', 'included_sample.html'] -+ actual = [os.path.relpath(path, util.PathFromRoot('grit/testdata')) for -+ path in grd.GetInputFiles()] -+ # Convert path separator for Windows paths. -+ actual = [path.replace('\\', '/') for path in actual] -+ self.assertEquals(expected, actual) -+ -+ def testNonDefaultEntry(self): -+ grd = util.ParseGrdForUnittest(''' -+ -+ bar -+ -+ bar -+ -+ ''') -+ grd.SetOutputLanguage('fr') -+ output = ''.join(rc_header.Format(grd, 'fr', '.')) -+ self.assertIn('#define IDS_A 2378\n#define IDS_B 2379', output) -+ -+ def testExplicitFirstIdOverlaps(self): -+ # second first_id will overlap preexisting range -+ self.assertRaises(grit.exception.IdRangeOverlap, -+ util.ParseGrdForUnittest, ''' -+ -+ -+ -+ -+ -+ -+ Hello %sJoi, how are you doing today? -+ -+ Frubegfrums -+ ''') -+ -+ def testImplicitOverlapsPreexisting(self): -+ # second message in will overlap preexisting range -+ self.assertRaises(grit.exception.IdRangeOverlap, -+ util.ParseGrdForUnittest, ''' -+ -+ -+ -+ -+ -+ -+ Hello %sJoi, how are you doing today? -+ -+ Frubegfrums -+ ''') -+ -+ def testPredeterminedIds(self): -+ with _MakeTempPredeterminedIdsFile('IDS_A 101\nIDS_B 102') as ids_file: -+ grd = util.ParseGrdForUnittest(''' -+ -+ -+ -+ -+ -+ Hello %sJoi, how are you doing today? -+ -+ -+ Bongo! -+ -+ ''', predetermined_ids_file=ids_file) -+ output = rc_header.FormatDefines(grd) -+ self.assertEqual(('#define IDS_B 102\n' -+ '#define IDS_GREETING 10000\n' -+ '#define IDS_A 101\n'), ''.join(output)) -+ os.remove(ids_file) -+ -+ def testPredeterminedIdsOverlap(self): -+ with _MakeTempPredeterminedIdsFile('ID_LOGO 10000') as ids_file: -+ self.assertRaises(grit.exception.IdRangeOverlap, -+ util.ParseGrdForUnittest, ''' -+ -+ -+ -+ -+ -+ Hello %sJoi, how are you doing today? -+ -+ -+ Bongo! -+ -+ ''', predetermined_ids_file=ids_file) -+ os.remove(ids_file) -+ -+ -+class IfNodeUnittest(unittest.TestCase): -+ def testIffyness(self): -+ grd = grd_reader.Parse(StringIO(''' -+ -+ -+ -+ -+ -+ Bingo! -+ -+ -+ -+ -+ Hello! -+ -+ -+ -+ -+ Good morning -+ -+ -+ -+ is_win -+ -+ -+ -+ '''), dir='.') -+ -+ messages_node = grd.children[0].children[0] -+ bingo_message = messages_node.children[0].children[0] -+ hello_message = messages_node.children[1].children[0] -+ french_message = messages_node.children[2].children[0] -+ is_win_message = messages_node.children[3].children[0] -+ -+ self.assertTrue(bingo_message.name == 'message') -+ self.assertTrue(hello_message.name == 'message') -+ self.assertTrue(french_message.name == 'message') -+ -+ grd.SetOutputLanguage('fr') -+ grd.SetDefines({'hello': '1'}) -+ active = set(grd.ActiveDescendants()) -+ self.failUnless(bingo_message not in active) -+ self.failUnless(hello_message in active) -+ self.failUnless(french_message in active) -+ -+ grd.SetOutputLanguage('en') -+ grd.SetDefines({'bingo': 1}) -+ active = set(grd.ActiveDescendants()) -+ self.failUnless(bingo_message in active) -+ self.failUnless(hello_message not in active) -+ self.failUnless(french_message not in active) -+ -+ grd.SetOutputLanguage('en') -+ grd.SetDefines({'FORCE_FRENCH': '1', 'bingo': '1'}) -+ active = set(grd.ActiveDescendants()) -+ self.failUnless(bingo_message in active) -+ self.failUnless(hello_message not in active) -+ self.failUnless(french_message in active) -+ -+ grd.SetOutputLanguage('en') -+ grd.SetDefines({}) -+ self.failUnless(grd.target_platform == sys.platform) -+ grd.SetTargetPlatform('darwin') -+ active = set(grd.ActiveDescendants()) -+ self.failUnless(is_win_message not in active) -+ grd.SetTargetPlatform('win32') -+ active = set(grd.ActiveDescendants()) -+ self.failUnless(is_win_message in active) -+ -+ def testElsiness(self): -+ grd = util.ParseGrdForUnittest(''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''') -+ included = [msg.attrs['name'] for msg in grd.ActiveDescendants() -+ if msg.name == 'message'] -+ self.assertEqual(['IDS_YES1', 'IDS_YES2', 'IDS_YES3', 'IDS_YES4'], included) -+ -+ def testIffynessWithOutputNodes(self): -+ grd = grd_reader.Parse(StringIO(''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ '''), dir='.') -+ -+ outputs_node = grd.children[0] -+ uncond1_output = outputs_node.children[0] -+ only_fr_adm_output = outputs_node.children[1].children[0] -+ only_fr_plist_output = outputs_node.children[1].children[1] -+ doc_output = outputs_node.children[2].children[0] -+ uncond2_output = outputs_node.children[0] -+ self.assertTrue(uncond1_output.name == 'output') -+ self.assertTrue(only_fr_adm_output.name == 'output') -+ self.assertTrue(only_fr_plist_output.name == 'output') -+ self.assertTrue(doc_output.name == 'output') -+ self.assertTrue(uncond2_output.name == 'output') -+ -+ grd.SetOutputLanguage('ru') -+ grd.SetDefines({'hello': '1'}) -+ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] -+ self.assertEquals( -+ outputs, -+ ['uncond1.rc', 'only_fr.adm', 'only_fr.plist', 'doc.html', -+ 'uncond2.adm', 'iftest.h']) -+ -+ grd.SetOutputLanguage('ru') -+ grd.SetDefines({'bingo': '2'}) -+ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] -+ self.assertEquals( -+ outputs, -+ ['uncond1.rc', 'doc.html', 'uncond2.adm', 'iftest.h']) -+ -+ grd.SetOutputLanguage('fr') -+ grd.SetDefines({'hello': '1'}) -+ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] -+ self.assertEquals( -+ outputs, -+ ['uncond1.rc', 'only_fr.adm', 'only_fr.plist', 'uncond2.adm', -+ 'iftest.h']) -+ -+ grd.SetOutputLanguage('en') -+ grd.SetDefines({'bingo': '1'}) -+ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] -+ self.assertEquals(outputs, ['uncond1.rc', 'uncond2.adm', 'iftest.h']) -+ -+ grd.SetOutputLanguage('fr') -+ grd.SetDefines({'bingo': '1'}) -+ outputs = [output.GetFilename() for output in grd.GetOutputFiles()] -+ self.assertNotEquals(outputs, ['uncond1.rc', 'uncond2.adm', 'iftest.h']) -+ -+ def testChildrenAccepted(self): -+ grd_reader.Parse(StringIO(r''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Bingo! -+ -+ -+ -+ Bingo! -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ '''), dir='.') -+ -+ def testIfBadChildrenNesting(self): -+ # includes -+ xml = StringIO(r''' -+ -+ -+ -+ -+ -+ -+ -+ -+ ''') -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ # messages -+ xml = StringIO(r''' -+ -+ -+ -+ -+ -+ -+ -+ -+ ''') -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ # structures -+ xml = StringIO(''' -+ -+ -+ -+ -+ Bingo! -+ -+ -+ -+ ''') -+ # translations -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ xml = StringIO(''' -+ -+ -+ -+ Bingo! -+ -+ -+ ''') -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ # same with nesting -+ xml = StringIO(r''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''') -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ xml = StringIO(r''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ''') -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ xml = StringIO(''' -+ -+ -+ -+ -+ -+ Bingo! -+ -+ -+ -+ -+ ''') -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ xml = StringIO(''' -+ -+ -+ -+ -+ Bingo! -+ -+ -+ -+ ''') -+ self.assertRaises(grit.exception.UnexpectedChild, grd_reader.Parse, xml) -+ -+ -+class ReleaseNodeUnittest(unittest.TestCase): -+ def testPseudoControl(self): -+ grd = grd_reader.Parse(StringIO(''' -+ -+ -+ -+ -+ Hello -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Bingo -+ -+ -+ -+ -+ -+ -+ '''), util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ -+ hello = grd.GetNodeById('IDS_HELLO') -+ aboutbox = grd.GetNodeById('IDD_ABOUTBOX') -+ bingo = grd.GetNodeById('IDS_BINGO') -+ menu = grd.GetNodeById('IDC_KLONKMENU') -+ -+ for node in [hello, aboutbox]: -+ self.failUnless(not node.PseudoIsAllowed()) -+ -+ for node in [bingo, menu]: -+ self.failUnless(node.PseudoIsAllowed()) -+ -+ # TODO(benrg): There was a test here that formatting hello and aboutbox with -+ # a pseudo language should fail, but they do not fail and the test was -+ # broken and failed to catch it. Fix this. -+ -+ # Should not raise an exception since pseudo is allowed -+ rc.FormatMessage(bingo, 'xyz-pseudo') -+ rc.FormatStructure(menu, 'xyz-pseudo', '.') -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/mock_brotli.py b/tools/grit/grit/node/mock_brotli.py -new file mode 100644 -index 0000000000..14237aab20 ---- /dev/null -+++ b/tools/grit/grit/node/mock_brotli.py -@@ -0,0 +1,10 @@ -+#!/usr/bin/env python -+# Copyright 2019 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""Mock Brotli Executable for testing purposes.""" -+ -+import sys -+ -+sys.stdout.write('This has been mock compressed!') -diff --git a/tools/grit/grit/node/node_io.py b/tools/grit/grit/node/node_io.py -new file mode 100644 -index 0000000000..ccbc2c0647 ---- /dev/null -+++ b/tools/grit/grit/node/node_io.py -@@ -0,0 +1,117 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''The and elements. -+''' -+ -+from __future__ import print_function -+ -+import os -+ -+from grit import xtb_reader -+from grit.node import base -+ -+ -+class FileNode(base.Node): -+ '''A element.''' -+ -+ def __init__(self): -+ super(FileNode, self).__init__() -+ self.re = None -+ self.should_load_ = True -+ -+ def IsTranslation(self): -+ return True -+ -+ def GetLang(self): -+ return self.attrs['lang'] -+ -+ def DisableLoading(self): -+ self.should_load_ = False -+ -+ def MandatoryAttributes(self): -+ return ['path', 'lang'] -+ -+ def RunPostSubstitutionGatherer(self, debug=False): -+ if not self.should_load_: -+ return -+ -+ root = self.GetRoot() -+ defs = getattr(root, 'defines', {}) -+ target_platform = getattr(root, 'target_platform', '') -+ -+ xtb_file = open(self.ToRealPath(self.GetInputPath()), 'rb') -+ try: -+ lang = xtb_reader.Parse(xtb_file, -+ self.UberClique().GenerateXtbParserCallback( -+ self.attrs['lang'], debug=debug), -+ defs=defs, -+ target_platform=target_platform) -+ except: -+ print("Exception during parsing of %s" % self.GetInputPath()) -+ raise -+ # Translation console uses non-standard language codes 'iw' and 'no' for -+ # Hebrew and Norwegian Bokmal instead of 'he' and 'nb' used in Chrome. -+ # Note that some Chrome's .grd still use 'no' instead of 'nb', but 'nb' is -+ # always used for generated .pak files. -+ ALTERNATIVE_LANG_CODE_MAP = { 'he': 'iw', 'nb': 'no' } -+ assert (lang == self.attrs['lang'] or -+ lang == ALTERNATIVE_LANG_CODE_MAP[self.attrs['lang']]), ( -+ 'The XTB file you reference must contain messages in the language ' -+ 'specified\nby the \'lang\' attribute.') -+ -+ def GetInputPath(self): -+ return os.path.expandvars(self.attrs['path']) -+ -+ -+class OutputNode(base.Node): -+ '''An element.''' -+ -+ def MandatoryAttributes(self): -+ return ['filename', 'type'] -+ -+ def DefaultAttributes(self): -+ return { -+ 'lang' : '', # empty lang indicates all languages -+ 'language_section' : 'neutral', # defines a language neutral section -+ 'context' : '', -+ 'fallback_to_default_layout' : 'true', -+ } -+ -+ def GetType(self): -+ return self.attrs['type'] -+ -+ def GetLanguage(self): -+ '''Returns the language ID, default 'en'.''' -+ return self.attrs['lang'] -+ -+ def GetContext(self): -+ return self.attrs['context'] -+ -+ def GetFilename(self): -+ return self.attrs['filename'] -+ -+ def GetOutputFilename(self): -+ path = None -+ if hasattr(self, 'output_filename'): -+ path = self.output_filename -+ else: -+ path = self.attrs['filename'] -+ return os.path.expandvars(path) -+ -+ def GetFallbackToDefaultLayout(self): -+ return self.attrs['fallback_to_default_layout'].lower() == 'true' -+ -+ def _IsValidChild(self, child): -+ return isinstance(child, EmitNode) -+ -+class EmitNode(base.ContentNode): -+ ''' An element.''' -+ -+ def DefaultAttributes(self): -+ return { 'emit_type' : 'prepend'} -+ -+ def GetEmitType(self): -+ '''Returns the emit_type for this node. Default is 'append'.''' -+ return self.attrs['emit_type'] -diff --git a/tools/grit/grit/node/node_io_unittest.py b/tools/grit/grit/node/node_io_unittest.py -new file mode 100644 -index 0000000000..1f45e51af8 ---- /dev/null -+++ b/tools/grit/grit/node/node_io_unittest.py -@@ -0,0 +1,182 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for node_io.FileNode''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+import unittest -+ -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+from six import StringIO -+ -+from grit.node import misc -+from grit.node import node_io -+from grit.node import empty -+from grit import grd_reader -+from grit import util -+ -+ -+def _GetAllCliques(root_node): -+ """Return all cliques in the |root_node| tree.""" -+ ret = [] -+ for node in root_node: -+ ret.extend(node.GetCliques()) -+ return ret -+ -+ -+class FileNodeUnittest(unittest.TestCase): -+ def testGetPath(self): -+ root = misc.GritNode() -+ root.StartParsing(u'grit', None) -+ root.HandleAttribute(u'latest_public_release', u'0') -+ root.HandleAttribute(u'current_release', u'1') -+ root.HandleAttribute(u'base_dir', r'..\resource') -+ translations = empty.TranslationsNode() -+ translations.StartParsing(u'translations', root) -+ root.AddChild(translations) -+ file_node = node_io.FileNode() -+ file_node.StartParsing(u'file', translations) -+ file_node.HandleAttribute(u'path', r'flugel\kugel.pdf') -+ translations.AddChild(file_node) -+ root.EndParsing() -+ -+ self.failUnless(root.ToRealPath(file_node.GetInputPath()) == -+ util.normpath( -+ os.path.join(r'../resource', r'flugel/kugel.pdf'))) -+ -+ def VerifyCliquesContainEnglishAndFrenchAndNothingElse(self, cliques): -+ self.assertEqual(2, len(cliques)) -+ for clique in cliques: -+ self.assertEqual({'en', 'fr'}, set(clique.clique.keys())) -+ -+ def testLoadTranslations(self): -+ xml = ''' -+ -+ -+ -+ -+ -+ -+ Hello! -+ Hello %sJoi -+ -+ -+ ''' -+ grd = grd_reader.Parse(StringIO(xml), -+ util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ self.VerifyCliquesContainEnglishAndFrenchAndNothingElse(_GetAllCliques(grd)) -+ -+ def testIffyness(self): -+ grd = grd_reader.Parse(StringIO(''' -+ -+ -+ -+ -+ -+ -+ -+ -+ Hello! -+ Hello %sJoi -+ -+ -+ '''), util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ cliques = _GetAllCliques(grd) -+ self.assertEqual(2, len(cliques)) -+ for clique in cliques: -+ self.assertEqual({'en'}, set(clique.clique.keys())) -+ -+ grd.SetOutputLanguage('fr') -+ grd.RunGatherers() -+ self.VerifyCliquesContainEnglishAndFrenchAndNothingElse(_GetAllCliques(grd)) -+ -+ def testConditionalLoadTranslations(self): -+ xml = ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Hello! -+ Hello %s -+ Joi -+ -+ -+ ''' -+ grd = grd_reader.Parse(StringIO(xml), -+ util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ self.VerifyCliquesContainEnglishAndFrenchAndNothingElse(_GetAllCliques(grd)) -+ -+ def testConditionalOutput(self): -+ xml = ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Hello! -+ -+ -+ ''' -+ grd = grd_reader.Parse(StringIO(xml), -+ util.PathFromRoot('grit/test/data'), -+ defines={}) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ outputs = grd.GetChildrenOfType(node_io.OutputNode) -+ active = set(grd.ActiveDescendants()) -+ self.failUnless(outputs[0] in active) -+ self.failUnless(outputs[0].GetType() == 'rc_header') -+ self.failUnless(outputs[1] in active) -+ self.failUnless(outputs[1].GetType() == 'rc_all') -+ self.failUnless(outputs[2] not in active) -+ self.failUnless(outputs[2].GetType() == 'rc_all') -+ -+ # Verify that 'iw' and 'no' language codes in xtb files are mapped to 'he' and -+ # 'nb'. -+ def testLangCodeMapping(self): -+ grd = grd_reader.Parse(StringIO(''' -+ -+ -+ -+ -+ -+ -+ -+ -+ '''), util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ self.assertEqual([], _GetAllCliques(grd)) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/structure.py b/tools/grit/grit/node/structure.py -new file mode 100644 -index 0000000000..ec170faebb ---- /dev/null -+++ b/tools/grit/grit/node/structure.py -@@ -0,0 +1,375 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''The element. -+''' -+ -+from __future__ import print_function -+ -+import os -+import platform -+import re -+ -+from grit import exception -+from grit import util -+from grit.node import base -+from grit.node import variant -+ -+import grit.gather.admin_template -+import grit.gather.chrome_html -+import grit.gather.chrome_scaled_image -+import grit.gather.policy_json -+import grit.gather.rc -+import grit.gather.tr_html -+import grit.gather.txt -+ -+import grit.format.rc -+ -+# Type of the gatherer to use for each type attribute -+_GATHERERS = { -+ 'accelerators' : grit.gather.rc.Accelerators, -+ 'admin_template' : grit.gather.admin_template.AdmGatherer, -+ 'chrome_html' : grit.gather.chrome_html.ChromeHtml, -+ 'chrome_scaled_image' : grit.gather.chrome_scaled_image.ChromeScaledImage, -+ 'dialog' : grit.gather.rc.Dialog, -+ 'menu' : grit.gather.rc.Menu, -+ 'rcdata' : grit.gather.rc.RCData, -+ 'tr_html' : grit.gather.tr_html.TrHtml, -+ 'txt' : grit.gather.txt.TxtFile, -+ 'version' : grit.gather.rc.Version, -+ 'policy_template_metafile' : grit.gather.policy_json.PolicyJson, -+} -+ -+ -+# TODO(joi) Print a warning if the 'variant_of_revision' attribute indicates -+# that a skeleton variant is older than the original file. -+ -+ -+class StructureNode(base.Node): -+ '''A element.''' -+ -+ # Regular expression for a local variable definition. Each definition -+ # is of the form NAME=VALUE, where NAME cannot contain '=' or ',' and -+ # VALUE must escape all commas: ',' -> ',,'. Each variable definition -+ # should be separated by a comma with no extra whitespace. -+ # Example: THING1=foo,THING2=bar -+ variable_pattern = re.compile(r'([^,=\s]+)=((?:,,|[^,])*)') -+ -+ def __init__(self): -+ super(StructureNode, self).__init__() -+ -+ # Keep track of the last filename we flattened to, so we can -+ # avoid doing it more than once. -+ self._last_flat_filename = None -+ -+ # See _Substitute; this substituter is used for local variables and -+ # the root substituter is used for global variables. -+ self.substituter = None -+ -+ def _IsValidChild(self, child): -+ return isinstance(child, variant.SkeletonNode) -+ -+ def _ParseVariables(self, variables): -+ '''Parse a variable string into a dictionary.''' -+ matches = StructureNode.variable_pattern.findall(variables) -+ return dict((name, value.replace(',,', ',')) for name, value in matches) -+ -+ def EndParsing(self): -+ super(StructureNode, self).EndParsing() -+ -+ # Now that we have attributes and children, instantiate the gatherers. -+ gathertype = _GATHERERS[self.attrs['type']] -+ -+ self.gatherer = gathertype(self.attrs['file'], -+ self.attrs['name'], -+ self.attrs['encoding']) -+ self.gatherer.SetGrdNode(self) -+ self.gatherer.SetUberClique(self.UberClique()) -+ if hasattr(self.GetRoot(), 'defines'): -+ self.gatherer.SetDefines(self.GetRoot().defines) -+ self.gatherer.SetAttributes(self.attrs) -+ if self.ExpandVariables(): -+ self.gatherer.SetFilenameExpansionFunction(self._Substitute) -+ -+ # Parse local variables and instantiate the substituter. -+ if self.attrs['variables']: -+ variables = self.attrs['variables'] -+ self.substituter = util.Substituter() -+ self.substituter.AddSubstitutions(self._ParseVariables(variables)) -+ -+ self.skeletons = {} # Maps expressions to skeleton gatherers -+ for child in self.children: -+ assert isinstance(child, variant.SkeletonNode) -+ skel = gathertype(child.attrs['file'], -+ self.attrs['name'], -+ child.GetEncodingToUse(), -+ is_skeleton=True) -+ skel.SetGrdNode(self) # TODO(benrg): Or child? Only used for ToRealPath -+ skel.SetUberClique(self.UberClique()) -+ if hasattr(self.GetRoot(), 'defines'): -+ skel.SetDefines(self.GetRoot().defines) -+ if self.ExpandVariables(): -+ skel.SetFilenameExpansionFunction(self._Substitute) -+ self.skeletons[child.attrs['expr']] = skel -+ -+ def MandatoryAttributes(self): -+ return ['type', 'name', 'file'] -+ -+ def DefaultAttributes(self): -+ return { -+ 'encoding': 'cp1252', -+ 'exclude_from_rc': 'false', -+ 'line_end': 'unix', -+ 'output_encoding': 'utf-8', -+ 'generateid': 'true', -+ 'expand_variables': 'false', -+ 'output_filename': '', -+ 'fold_whitespace': 'false', -+ # Run an arbitrary command after translation is complete -+ # so that it doesn't interfere with what's in translation -+ # console. -+ 'run_command': '', -+ # Leave empty to run on all platforms, comma-separated -+ # for one or more specific platforms. Values must match -+ # output of platform.system(). -+ 'run_command_on_platforms': '', -+ 'allowexternalscript': 'false', -+ # preprocess takes the same code path as flattenhtml, but it -+ # disables any processing/inlining outside of and . -+ 'preprocess': 'false', -+ 'flattenhtml': 'false', -+ 'fallback_to_low_resolution': 'default', -+ 'variables': '', -+ 'compress': 'default', -+ 'use_base_dir': 'true', -+ } -+ -+ def IsExcludedFromRc(self): -+ return self.attrs['exclude_from_rc'] == 'true' -+ -+ def Process(self, output_dir): -+ """Writes the processed data to output_dir. In the case of a chrome_html -+ structure this will add references to other scale factors. If flattening -+ this will also write file references to be base64 encoded data URLs. The -+ name of the new file is returned.""" -+ filename = self.ToRealPath(self.GetInputPath()) -+ flat_filename = os.path.join(output_dir, -+ self.attrs['name'] + '_' + os.path.basename(filename)) -+ -+ if self._last_flat_filename == flat_filename: -+ return -+ -+ with open(flat_filename, 'wb') as outfile: -+ if self.ExpandVariables(): -+ text = self.gatherer.GetText() -+ file_contents = self._Substitute(text) -+ else: -+ file_contents = self.gatherer.GetData('', 'utf-8') -+ outfile.write(file_contents.encode('utf-8')) -+ -+ self._last_flat_filename = flat_filename -+ return os.path.basename(flat_filename) -+ -+ def GetLineEnd(self): -+ '''Returns the end-of-line character or characters for files output because -+ of this node ('\r\n', '\n', or '\r' depending on the 'line_end' attribute). -+ ''' -+ if self.attrs['line_end'] == 'unix': -+ return '\n' -+ elif self.attrs['line_end'] == 'windows': -+ return '\r\n' -+ elif self.attrs['line_end'] == 'mac': -+ return '\r' -+ else: -+ raise exception.UnexpectedAttribute( -+ "Attribute 'line_end' must be one of 'unix' (default), 'windows' or " -+ "'mac'") -+ -+ def GetCliques(self): -+ return self.gatherer.GetCliques() -+ -+ def GetDataPackValue(self, lang, encoding): -+ """Returns a bytes representation for a data_pack entry.""" -+ if self.ExpandVariables(): -+ text = self.gatherer.GetText() -+ data = util.Encode(self._Substitute(text), encoding) -+ else: -+ data = self.gatherer.GetData(lang, encoding) -+ if encoding != util.BINARY: -+ data = data.encode(encoding) -+ return self.CompressDataIfNeeded(data) -+ -+ def GetHtmlResourceFilenames(self): -+ """Returns a set of all filenames inlined by this node.""" -+ return self.gatherer.GetHtmlResourceFilenames() -+ -+ def GetInputPath(self): -+ path = self.gatherer.GetInputPath() -+ if path is None: -+ return path -+ -+ # Do not mess with absolute paths, that would make them invalid. -+ if os.path.isabs(os.path.expandvars(path)): -+ return path -+ -+ # We have no control over code that calls ToRealPath later, so convert -+ # the path to be relative against our basedir. -+ if self.attrs.get('use_base_dir', 'true') != 'true': -+ # Normalize the directory path to use the appropriate OS separator. -+ # GetBaseDir() may return paths\like\this or paths/like/this, since it is -+ # read from the base_dir attribute in the grd file. -+ norm_base_dir = util.normpath(self.GetRoot().GetBaseDir()) -+ return os.path.relpath(path, norm_base_dir) -+ -+ return path -+ -+ def GetTextualIds(self): -+ if not hasattr(self, 'gatherer'): -+ # This case is needed because this method is called by -+ # GritNode.ValidateUniqueIds before RunGatherers has been called. -+ # TODO(benrg): Fix this? -+ return [self.attrs['name']] -+ return self.gatherer.GetTextualIds() -+ -+ def RunPreSubstitutionGatherer(self, debug=False): -+ if debug: -+ print('Running gatherer %s for file %s' % -+ (type(self.gatherer), self.GetInputPath())) -+ -+ # Note: Parse() is idempotent, therefore this method is also. -+ self.gatherer.Parse() -+ for skel in self.skeletons.values(): -+ skel.Parse() -+ -+ def GetSkeletonGatherer(self): -+ '''Returns the gatherer for the alternate skeleton that should be used, -+ based on the expressions for selecting skeletons, or None if the skeleton -+ from the English version of the structure should be used. -+ ''' -+ for expr in self.skeletons: -+ if self.EvaluateCondition(expr): -+ return self.skeletons[expr] -+ return None -+ -+ def HasFileForLanguage(self): -+ return self.attrs['type'] in ['tr_html', 'admin_template', 'txt', -+ 'chrome_scaled_image', -+ 'chrome_html'] -+ -+ def ExpandVariables(self): -+ '''Variable expansion on structures is controlled by an XML attribute. -+ -+ However, old files assume that expansion is always on for Rc files. -+ -+ Returns: -+ A boolean. -+ ''' -+ attrs = self.GetRoot().attrs -+ if 'grit_version' in attrs and attrs['grit_version'] > 1: -+ return self.attrs['expand_variables'] == 'true' -+ else: -+ return (self.attrs['expand_variables'] == 'true' or -+ self.attrs['file'].lower().endswith('.rc')) -+ -+ def _Substitute(self, text): -+ '''Perform local and global variable substitution.''' -+ if self.substituter: -+ text = self.substituter.Substitute(text) -+ return self.GetRoot().GetSubstituter().Substitute(text) -+ -+ def RunCommandOnCurrentPlatform(self): -+ if self.attrs['run_command_on_platforms'] == '': -+ return True -+ else: -+ target_platforms = self.attrs['run_command_on_platforms'].split(',') -+ return platform.system() in target_platforms -+ -+ def FileForLanguage(self, lang, output_dir, create_file=True, -+ return_if_not_generated=True): -+ '''Returns the filename of the file associated with this structure, -+ for the specified language. -+ -+ Args: -+ lang: 'fr' -+ output_dir: 'c:\temp' -+ create_file: True -+ ''' -+ assert self.HasFileForLanguage() -+ # If the source language is requested, and no extra changes are requested, -+ # use the existing file. -+ if ((not lang or lang == self.GetRoot().GetSourceLanguage()) and -+ self.attrs['expand_variables'] != 'true' and -+ (not self.attrs['run_command'] or -+ not self.RunCommandOnCurrentPlatform())): -+ if return_if_not_generated: -+ input_path = self.GetInputPath() -+ if input_path is None: -+ return None -+ return self.ToRealPath(input_path) -+ else: -+ return None -+ -+ if self.attrs['output_filename'] != '': -+ filename = self.attrs['output_filename'] -+ else: -+ filename = os.path.basename(self.attrs['file']) -+ assert len(filename) -+ filename = '%s_%s' % (lang, filename) -+ filename = os.path.join(output_dir, filename) -+ -+ # Only create the output if it was requested by the call. -+ if create_file: -+ text = self.gatherer.Translate( -+ lang, -+ pseudo_if_not_available=self.PseudoIsAllowed(), -+ fallback_to_english=self.ShouldFallbackToEnglish(), -+ skeleton_gatherer=self.GetSkeletonGatherer()) -+ -+ file_contents = util.FixLineEnd(text, self.GetLineEnd()) -+ if self.ExpandVariables(): -+ # Note that we reapply substitution a second time here. -+ # This is because a) we need to look inside placeholders -+ # b) the substitution values are language-dependent -+ file_contents = self._Substitute(file_contents) -+ -+ with open(filename, 'wb') as file_object: -+ output_stream = util.WrapOutputStream(file_object, -+ self.attrs['output_encoding']) -+ output_stream.write(file_contents) -+ -+ if self.attrs['run_command'] and self.RunCommandOnCurrentPlatform(): -+ # Run arbitrary commands after translation is complete so that it -+ # doesn't interfere with what's in translation console. -+ command = self.attrs['run_command'] % {'filename': filename} -+ result = os.system(command) -+ assert result == 0, '"%s" failed.' % command -+ -+ return filename -+ -+ def IsResourceMapSource(self): -+ return True -+ -+ @staticmethod -+ def Construct(parent, name, type, file, encoding='cp1252'): -+ '''Creates a new node which is a child of 'parent', with attributes set -+ by parameters of the same name. -+ ''' -+ node = StructureNode() -+ node.StartParsing('structure', parent) -+ node.HandleAttribute('name', name) -+ node.HandleAttribute('type', type) -+ node.HandleAttribute('file', file) -+ node.HandleAttribute('encoding', encoding) -+ node.EndParsing() -+ return node -+ -+ def SubstituteMessages(self, substituter): -+ '''Propagates substitution to gatherer. -+ -+ Args: -+ substituter: a grit.util.Substituter object. -+ ''' -+ assert hasattr(self, 'gatherer') -+ if self.ExpandVariables(): -+ self.gatherer.SubstituteMessages(substituter) -diff --git a/tools/grit/grit/node/structure_unittest.py b/tools/grit/grit/node/structure_unittest.py -new file mode 100644 -index 0000000000..0e66dce37a ---- /dev/null -+++ b/tools/grit/grit/node/structure_unittest.py -@@ -0,0 +1,178 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for nodes. -+''' -+ -+from __future__ import print_function -+ -+import os -+import os.path -+import sys -+import zlib -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import platform -+import tempfile -+import unittest -+import struct -+ -+from grit import constants -+from grit import util -+from grit.node import brotli_util -+from grit.node import structure -+from grit.format import rc -+ -+ -+def checkIsGzipped(filename, compress_attr): -+ test_data_root = util.PathFromRoot('grit/testdata') -+ root = util.ParseGrdForUnittest( -+ ''' -+ -+ -+ ''' % (filename, compress_attr), -+ base_dir=test_data_root) -+ node, = root.GetChildrenOfType(structure.StructureNode) -+ node.RunPreSubstitutionGatherer() -+ compressed = node.GetDataPackValue(lang='en', encoding=util.BINARY) -+ -+ decompressed_data = zlib.decompress(compressed, 16 + zlib.MAX_WBITS) -+ expected = util.ReadFile(os.path.join(test_data_root, filename), util.BINARY) -+ return expected == decompressed_data -+ -+ -+class StructureUnittest(unittest.TestCase): -+ def testSkeleton(self): -+ grd = util.ParseGrdForUnittest(''' -+ -+ -+ -+ -+ ''', base_dir=util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('fr') -+ grd.RunGatherers() -+ transl = ''.join(rc.Format(grd, 'fr', '.')) -+ self.failUnless(transl.count('040704') and transl.count('110978')) -+ self.failUnless(transl.count('2005",IDC_STATIC')) -+ -+ def testRunCommandOnCurrentPlatform(self): -+ node = structure.StructureNode() -+ node.attrs = node.DefaultAttributes() -+ self.failUnless(node.RunCommandOnCurrentPlatform()) -+ node.attrs['run_command_on_platforms'] = 'Nosuch' -+ self.failIf(node.RunCommandOnCurrentPlatform()) -+ node.attrs['run_command_on_platforms'] = ( -+ 'Nosuch,%s,Othernot' % platform.system()) -+ self.failUnless(node.RunCommandOnCurrentPlatform()) -+ -+ def testVariables(self): -+ grd = util.ParseGrdForUnittest(''' -+ -+ -+ ''', base_dir=util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ node, = grd.GetChildrenOfType(structure.StructureNode) -+ filename = node.Process(tempfile.gettempdir()) -+ filepath = os.path.join(tempfile.gettempdir(), filename) -+ with open(filepath) as f: -+ result = f.read() -+ self.failUnlessEqual(('

    Hello!

    \n' -+ 'Some cool things are foo, bar, baz.\n' -+ 'Did you know that 2+2==4?\n' -+ '

    \n' -+ ' Hello!\n' -+ '

    \n'), result) -+ os.remove(filepath) -+ -+ def testGetPath(self): -+ base_dir = util.PathFromRoot('grit/testdata') -+ grd = util.ParseGrdForUnittest(''' -+ -+ -+ ''', base_dir) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ node, = grd.GetChildrenOfType(structure.StructureNode) -+ self.assertEqual(grd.ToRealPath(node.GetInputPath()), -+ os.path.abspath(os.path.join( -+ base_dir, r'structure_variables.html'))) -+ -+ def testGetPathNoBasedir(self): -+ base_dir = util.PathFromRoot('grit/testdata') -+ abs_path = os.path.join(base_dir, r'structure_variables.html') -+ rel_path = os.path.relpath(abs_path, os.getcwd()) -+ grd = util.ParseGrdForUnittest(''' -+ -+ -+ ''', util.PathFromRoot('grit/testdata')) -+ grd.SetOutputLanguage('en') -+ grd.RunGatherers() -+ node, = grd.GetChildrenOfType(structure.StructureNode) -+ self.assertEqual(grd.ToRealPath(node.GetInputPath()), -+ os.path.abspath(os.path.join( -+ base_dir, r'structure_variables.html'))) -+ -+ def testCompressGzip(self): -+ self.assertTrue(checkIsGzipped('test_text.txt', 'compress="gzip"')) -+ -+ def testCompressGzipByDefault(self): -+ self.assertTrue(checkIsGzipped('test_html.html', '')) -+ self.assertTrue(checkIsGzipped('test_js.js', '')) -+ self.assertTrue(checkIsGzipped('test_css.css', '')) -+ self.assertTrue(checkIsGzipped('test_svg.svg', '')) -+ -+ self.assertTrue(checkIsGzipped('test_html.html', 'compress="default"')) -+ self.assertTrue(checkIsGzipped('test_js.js', 'compress="default"')) -+ self.assertTrue(checkIsGzipped('test_css.css', 'compress="default"')) -+ self.assertTrue(checkIsGzipped('test_svg.svg', 'compress="default"')) -+ -+ def testCompressBrotli(self): -+ test_data_root = util.PathFromRoot('grit/testdata') -+ root = util.ParseGrdForUnittest( -+ ''' -+ -+ -+ ''', -+ base_dir=test_data_root) -+ node, = root.GetChildrenOfType(structure.StructureNode) -+ node.RunPreSubstitutionGatherer() -+ -+ # Using the mock brotli decompression executable. -+ brotli_util.SetBrotliCommand([sys.executable, -+ os.path.join(os.path.dirname(__file__), -+ 'mock_brotli.py')]) -+ compressed = node.GetDataPackValue(lang='en', encoding=util.BINARY) -+ # Assert that the first two bytes in compressed format is BROTLI_CONST. -+ self.assertEqual(constants.BROTLI_CONST, compressed[0:2]) -+ -+ # Compare the actual size of the uncompressed test data with -+ # the size appended during compression. -+ actual_size = len(util.ReadFile( -+ os.path.join(test_data_root, 'test_text.txt'), util.BINARY)) -+ uncompress_size = struct.unpack(' -+ -+ ''', base_dir=test_data_root) -+ node, = root.GetChildrenOfType(structure.StructureNode) -+ node.RunPreSubstitutionGatherer() -+ data = node.GetDataPackValue(lang='en', encoding=util.BINARY) -+ -+ self.assertEqual(util.ReadFile( -+ os.path.join(test_data_root, 'test_text.txt'), util.BINARY), data) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/node/variant.py b/tools/grit/grit/node/variant.py -new file mode 100644 -index 0000000000..9f5845f954 ---- /dev/null -+++ b/tools/grit/grit/node/variant.py -@@ -0,0 +1,41 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''The element. -+''' -+ -+from __future__ import print_function -+ -+from grit.node import base -+ -+ -+class SkeletonNode(base.Node): -+ '''A element.''' -+ -+ # TODO(joi) Support inline skeleton variants as CDATA instead of requiring -+ # a 'file' attribute. -+ -+ def MandatoryAttributes(self): -+ return ['expr', 'variant_of_revision', 'file'] -+ -+ def DefaultAttributes(self): -+ '''If not specified, 'encoding' will actually default to the parent node's -+ encoding. -+ ''' -+ return {'encoding' : ''} -+ -+ def _ContentType(self): -+ if 'file' in self.attrs: -+ return self._CONTENT_TYPE_NONE -+ else: -+ return self._CONTENT_TYPE_CDATA -+ -+ def GetEncodingToUse(self): -+ if self.attrs['encoding'] == '': -+ return self.parent.attrs['encoding'] -+ else: -+ return self.attrs['encoding'] -+ -+ def GetInputPath(self): -+ return self.attrs['file'] -diff --git a/tools/grit/grit/pseudo.py b/tools/grit/grit/pseudo.py -new file mode 100644 -index 0000000000..b607bfc6bb ---- /dev/null -+++ b/tools/grit/grit/pseudo.py -@@ -0,0 +1,129 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Pseudotranslation support. Our pseudotranslations are based on the -+P-language, which is a simple vowel-extending language. Examples of P: -+ - "hello" becomes "hepellopo" -+ - "howdie" becomes "hopowdiepie" -+ - "because" becomes "bepecaupause" (but in our implementation we don't -+ handle the silent e at the end so it actually would return "bepecaupausepe" -+ -+The P-language has the excellent quality of increasing the length of text -+by around 30-50% which is great for pseudotranslations, to stress test any -+GUI layouts etc. -+ -+To make the pseudotranslations more obviously "not a translation" and to make -+them exercise any code that deals with encodings, we also transform all English -+vowels into equivalent vowels with diacriticals on them (rings, acutes, -+diaresis, and circumflex), and we write the "p" in the P-language as a Hebrew -+character Qof. It looks sort of like a latin character "p" but it is outside -+the latin-1 character set which will stress character encoding bugs. -+''' -+ -+from __future__ import print_function -+ -+from grit import lazy_re -+from grit import tclib -+ -+ -+# An RFC language code for the P pseudolanguage. -+PSEUDO_LANG = 'x-P-pseudo' -+ -+# Hebrew character Qof. It looks kind of like a 'p' but is outside -+# the latin-1 character set which is good for our purposes. -+# TODO(joi) For now using P instead of Qof, because of some bugs it used. Find -+# a better solution, i.e. one that introduces a non-latin1 character into the -+# pseudotranslation. -+#_QOF = u'\u05e7' -+_QOF = u'P' -+ -+# How we map each vowel. -+_VOWELS = { -+ u'a' : u'\u00e5', # a with ring -+ u'e' : u'\u00e9', # e acute -+ u'i' : u'\u00ef', # i diaresis -+ u'o' : u'\u00f4', # o circumflex -+ u'u' : u'\u00fc', # u diaresis -+ u'y' : u'\u00fd', # y acute -+ u'A' : u'\u00c5', # A with ring -+ u'E' : u'\u00c9', # E acute -+ u'I' : u'\u00cf', # I diaresis -+ u'O' : u'\u00d4', # O circumflex -+ u'U' : u'\u00dc', # U diaresis -+ u'Y' : u'\u00dd', # Y acute -+} -+_VOWELS_KEYS = set(_VOWELS.keys()) -+ -+# Matches vowels and P -+_PSUB_RE = lazy_re.compile("(%s)" % '|'.join(_VOWELS_KEYS | {'P'})) -+ -+ -+# Pseudotranslations previously created. This is important for performance -+# reasons, especially since we routinely pseudotranslate the whole project -+# several or many different times for each build. -+_existing_translations = {} -+ -+ -+def MapVowels(str, also_p = False): -+ '''Returns a copy of 'str' where characters that exist as keys in _VOWELS -+ have been replaced with the corresponding value. If also_p is true, this -+ function will also change capital P characters into a Hebrew character Qof. -+ ''' -+ def Repl(match): -+ if match.group() == 'p': -+ if also_p: -+ return _QOF -+ else: -+ return 'p' -+ else: -+ return _VOWELS[match.group()] -+ return _PSUB_RE.sub(Repl, str) -+ -+ -+def PseudoString(str): -+ '''Returns a pseudotranslation of the provided string, in our enhanced -+ P-language.''' -+ if str in _existing_translations: -+ return _existing_translations[str] -+ -+ outstr = u'' -+ ix = 0 -+ while ix < len(str): -+ if str[ix] not in _VOWELS_KEYS: -+ outstr += str[ix] -+ ix += 1 -+ else: -+ # We want to treat consecutive vowels as one composite vowel. This is not -+ # always accurate e.g. in composite words but good enough. -+ consecutive_vowels = u'' -+ while ix < len(str) and str[ix] in _VOWELS_KEYS: -+ consecutive_vowels += str[ix] -+ ix += 1 -+ changed_vowels = MapVowels(consecutive_vowels) -+ outstr += changed_vowels -+ outstr += _QOF -+ outstr += changed_vowels -+ -+ _existing_translations[str] = outstr -+ return outstr -+ -+ -+def PseudoMessage(message): -+ '''Returns a pseudotranslation of the provided message. -+ -+ Args: -+ message: tclib.Message() -+ -+ Return: -+ tclib.Translation() -+ ''' -+ transl = tclib.Translation() -+ -+ for part in message.GetContent(): -+ if isinstance(part, tclib.Placeholder): -+ transl.AppendPlaceholder(part) -+ else: -+ transl.AppendText(PseudoString(part)) -+ -+ return transl -diff --git a/tools/grit/grit/pseudo_rtl.py b/tools/grit/grit/pseudo_rtl.py -new file mode 100644 -index 0000000000..2240b571de ---- /dev/null -+++ b/tools/grit/grit/pseudo_rtl.py -@@ -0,0 +1,104 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Pseudo RTL, (aka Fake Bidi) support. It simply wraps each word with -+Unicode RTL overrides. -+More info at https://sites.google.com/a/chromium.org/dev/Home/fake-bidi -+''' -+ -+from __future__ import print_function -+ -+import re -+ -+from grit import lazy_re -+from grit import tclib -+ -+ACCENTED_STRINGS = { -+ 'a': u"\u00e5", 'e': u"\u00e9", 'i': u"\u00ee", 'o': u"\u00f6", -+ 'u': u"\u00fb", 'A': u"\u00c5", 'E': u"\u00c9", 'I': u"\u00ce", -+ 'O': u"\u00d6", 'U': u"\u00db", 'c': u"\u00e7", 'd': u"\u00f0", -+ 'n': u"\u00f1", 'p': u"\u00fe", 'y': u"\u00fd", 'C': u"\u00c7", -+ 'D': u"\u00d0", 'N': u"\u00d1", 'P': u"\u00de", 'Y': u"\u00dd", -+ 'f': u"\u0192", 's': u"\u0161", 'S': u"\u0160", 'z': u"\u017e", -+ 'Z': u"\u017d", 'g': u"\u011d", 'G': u"\u011c", 'h': u"\u0125", -+ 'H': u"\u0124", 'j': u"\u0135", 'J': u"\u0134", 'k': u"\u0137", -+ 'K': u"\u0136", 'l': u"\u013c", 'L': u"\u013b", 't': u"\u0163", -+ 'T': u"\u0162", 'w': u"\u0175", 'W': u"\u0174", -+ '$': u"\u20ac", '?': u"\u00bf", 'R': u"\u00ae", r'!': u"\u00a1", -+} -+ -+# a character set containing the keys in ACCENTED_STRINGS -+# We should not accent characters in an escape sequence such as "\n". -+# To be safe, we assume every character following a backslash is an escaped -+# character. We also need to consider the case like "\\n", which means -+# a blackslash and a character "n", we will accent the character "n". -+TO_ACCENT = lazy_re.compile( -+ r'[%s]|\\[a-z\\]' % ''.join(ACCENTED_STRINGS.keys())) -+ -+# Lex text so that we don't interfere with html tokens and entities. -+# This lexing scheme will handle all well formed tags and entities, html or -+# xhtml. It will not handle comments, CDATA sections, or the unescaping tags: -+# script, style, xmp or listing. If any of those appear in messages, -+# something is wrong. -+TOKENS = [ lazy_re.compile( -+ '^%s' % pattern, # match at the beginning of input -+ re.I | re.S # html tokens are case-insensitive -+ ) -+ for pattern in -+ ( -+ # a run of non html special characters -+ r'[^<&]+', -+ # a tag -+ (r']+|"[^\"]*"|\'[^\']*\'))?' # attribute value -+ r')*\s*/?>'), -+ # an entity -+ r'&(?:[a-z]\w+|#\d+|#x[\da-f]+);', -+ # an html special character not part of a special sequence -+ r'.' -+ ) ] -+ -+ALPHABETIC_RUN = lazy_re.compile(r'([^\W0-9_]+)') -+ -+RLO = u'\u202e' -+PDF = u'\u202c' -+ -+def PseudoRTLString(text): -+ '''Returns a fake bidirectional version of the source string. This code is -+ based on accentString above, in turn copied from Frank Tang. -+ ''' -+ parts = [] -+ while text: -+ m = None -+ for token in TOKENS: -+ m = token.search(text) -+ if m: -+ part = m.group(0) -+ text = text[len(part):] -+ if part[0] not in ('<', '&'): -+ # not a tag or entity, so accent -+ part = ALPHABETIC_RUN.sub(lambda run: RLO + run.group() + PDF, part) -+ parts.append(part) -+ break -+ return ''.join(parts) -+ -+ -+def PseudoRTLMessage(message): -+ '''Returns a pseudo-RTL (aka Fake-Bidi) translation of the provided message. -+ -+ Args: -+ message: tclib.Message() -+ -+ Return: -+ tclib.Translation() -+ ''' -+ transl = tclib.Translation() -+ for part in message.GetContent(): -+ if isinstance(part, tclib.Placeholder): -+ transl.AppendPlaceholder(part) -+ else: -+ transl.AppendText(PseudoRTLString(part)) -+ -+ return transl -diff --git a/tools/grit/grit/pseudo_unittest.py b/tools/grit/grit/pseudo_unittest.py -new file mode 100644 -index 0000000000..b1d53ff401 ---- /dev/null -+++ b/tools/grit/grit/pseudo_unittest.py -@@ -0,0 +1,55 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.pseudo''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -+ -+import unittest -+ -+from grit import pseudo -+from grit import tclib -+ -+ -+class PseudoUnittest(unittest.TestCase): -+ def testVowelMapping(self): -+ self.failUnless(pseudo.MapVowels('abebibobuby') == -+ u'\u00e5b\u00e9b\u00efb\u00f4b\u00fcb\u00fd') -+ self.failUnless(pseudo.MapVowels('ABEBIBOBUBY') == -+ u'\u00c5B\u00c9B\u00cfB\u00d4B\u00dcB\u00dd') -+ -+ def testPseudoString(self): -+ out = pseudo.PseudoString('hello') -+ self.failUnless(out == pseudo.MapVowels(u'hePelloPo', True)) -+ -+ def testConsecutiveVowels(self): -+ out = pseudo.PseudoString("beautiful weather, ain't it?") -+ self.failUnless(out == pseudo.MapVowels( -+ u"beauPeautiPifuPul weaPeathePer, aiPain't iPit?", 1)) -+ -+ def testCapitals(self): -+ out = pseudo.PseudoString("HOWDIE DOODIE, DR. JONES") -+ self.failUnless(out == pseudo.MapVowels( -+ u"HOPOWDIEPIE DOOPOODIEPIE, DR. JOPONEPES", 1)) -+ -+ def testPseudoMessage(self): -+ msg = tclib.Message(text='Hello USERNAME, how are you?', -+ placeholders=[ -+ tclib.Placeholder('USERNAME', '%s', 'Joi')]) -+ trans = pseudo.PseudoMessage(msg) -+ # TODO(joi) It would be nicer if 'you' -> 'youPou' instead of -+ # 'you' -> 'youPyou' and if we handled the silent e in 'are' -+ self.failUnless(trans.GetPresentableContent() == -+ pseudo.MapVowels( -+ u'HePelloPo USERNAME, hoPow aParePe youPyou?', 1)) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/shortcuts.py b/tools/grit/grit/shortcuts.py -new file mode 100644 -index 0000000000..0db2ce436c ---- /dev/null -+++ b/tools/grit/grit/shortcuts.py -@@ -0,0 +1,93 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Stuff to prevent conflicting shortcuts. -+''' -+ -+from __future__ import print_function -+ -+from grit import lazy_re -+ -+ -+class ShortcutGroup(object): -+ '''Manages a list of cliques that belong together in a single shortcut -+ group. Knows how to detect conflicting shortcut keys. -+ ''' -+ -+ # Matches shortcut keys, e.g. &J -+ SHORTCUT_RE = lazy_re.compile('([^&]|^)(&[A-Za-z])') -+ -+ def __init__(self, name): -+ self.name = name -+ # Map of language codes to shortcut keys used (which is a map of -+ # shortcut keys to counts). -+ self.keys_by_lang = {} -+ # List of cliques in this group -+ self.cliques = [] -+ -+ def AddClique(self, c): -+ for existing_clique in self.cliques: -+ if existing_clique.GetId() == c.GetId(): -+ # This happens e.g. when we have e.g. -+ # -+ # where only one will really be included in the output. -+ return -+ -+ self.cliques.append(c) -+ for (lang, msg) in c.clique.items(): -+ if lang not in self.keys_by_lang: -+ self.keys_by_lang[lang] = {} -+ keymap = self.keys_by_lang[lang] -+ -+ content = msg.GetRealContent() -+ keys = [groups[1] for groups in self.SHORTCUT_RE.findall(content)] -+ for key in keys: -+ key = key.upper() -+ if key in keymap: -+ keymap[key] += 1 -+ else: -+ keymap[key] = 1 -+ -+ def GenerateWarnings(self, tc_project): -+ # For any language that has more than one occurrence of any shortcut, -+ # make a list of the conflicting shortcuts. -+ problem_langs = {} -+ for (lang, keys) in self.keys_by_lang.items(): -+ for (key, count) in keys.items(): -+ if count > 1: -+ if lang not in problem_langs: -+ problem_langs[lang] = [] -+ problem_langs[lang].append(key) -+ -+ warnings = [] -+ if len(problem_langs): -+ warnings.append("WARNING - duplicate keys exist in shortcut group %s" % -+ self.name) -+ for (lang,keys) in problem_langs.items(): -+ warnings.append(" %6s duplicates: %s" % (lang, ', '.join(keys))) -+ return warnings -+ -+ -+def GenerateDuplicateShortcutsWarnings(uberclique, tc_project): -+ '''Given an UberClique and a project name, will print out helpful warnings -+ if there are conflicting shortcuts within shortcut groups in the provided -+ UberClique. -+ -+ Args: -+ uberclique: clique.UberClique() -+ tc_project: 'MyProjectNameInTheTranslationConsole' -+ -+ Returns: -+ ['warning line 1', 'warning line 2', ...] -+ ''' -+ warnings = [] -+ groups = {} -+ for c in uberclique.AllCliques(): -+ for group in c.shortcut_groups: -+ if group not in groups: -+ groups[group] = ShortcutGroup(group) -+ groups[group].AddClique(c) -+ for group in groups.values(): -+ warnings += group.GenerateWarnings(tc_project) -+ return warnings -diff --git a/tools/grit/grit/shortcuts_unittest.py b/tools/grit/grit/shortcuts_unittest.py -new file mode 100644 -index 0000000000..30e7c4f758 ---- /dev/null -+++ b/tools/grit/grit/shortcuts_unittest.py -@@ -0,0 +1,79 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.shortcuts -+''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -+ -+import unittest -+ -+from six import StringIO -+ -+from grit import shortcuts -+from grit import clique -+from grit import tclib -+from grit.gather import rc -+ -+class ShortcutsUnittest(unittest.TestCase): -+ -+ def setUp(self): -+ self.uq = clique.UberClique() -+ -+ def testFunctionality(self): -+ c = self.uq.MakeClique(tclib.Message(text="Hello &there")) -+ c.AddToShortcutGroup('group_name') -+ c = self.uq.MakeClique(tclib.Message(text="Howdie &there partner")) -+ c.AddToShortcutGroup('group_name') -+ -+ warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT') -+ self.failUnless(warnings) -+ -+ def testAmpersandEscaping(self): -+ c = self.uq.MakeClique(tclib.Message(text="Hello &there")) -+ c.AddToShortcutGroup('group_name') -+ c = self.uq.MakeClique(tclib.Message(text="S&&T are the &letters S and T")) -+ c.AddToShortcutGroup('group_name') -+ -+ warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT') -+ self.failUnless(len(warnings) == 0) -+ -+ def testDialog(self): -+ dlg = rc.Dialog(StringIO('''\ -+IDD_SIDEBAR_RSS_PANEL_PROPPAGE DIALOGEX 0, 0, 239, 221 -+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -+FONT 8, "MS Shell Dlg", 400, 0, 0x1 -+BEGIN -+ PUSHBUTTON "Add &URL",IDC_SIDEBAR_RSS_ADD_URL,182,53,57,14 -+ EDITTEXT IDC_SIDEBAR_RSS_NEW_URL,0,53,178,15,ES_AUTOHSCROLL -+ PUSHBUTTON "&Remove",IDC_SIDEBAR_RSS_REMOVE,183,200,56,14 -+ PUSHBUTTON "&Edit",IDC_SIDEBAR_RSS_EDIT,123,200,56,14 -+ CONTROL "&Automatically add commonly viewed clips", -+ IDC_SIDEBAR_RSS_AUTO_ADD,"Button",BS_AUTOCHECKBOX | -+ BS_MULTILINE | WS_TABSTOP,0,200,120,17 -+ PUSHBUTTON "",IDC_SIDEBAR_RSS_HIDDEN,179,208,6,6,NOT WS_VISIBLE -+ LTEXT "You can display clips from blogs, news sites, and other online sources.", -+ IDC_STATIC,0,0,239,10 -+ LISTBOX IDC_SIDEBAR_DISPLAYED_FEED_LIST,0,69,239,127,LBS_SORT | -+ LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | -+ LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | -+ WS_TABSTOP -+ LTEXT "Add a clip from a recently viewed website by clicking Add Recent Clips.", -+ IDC_STATIC,0,13,141,19 -+ LTEXT "Or, if you know a site supports RSS or Atom, you can enter the RSS or Atom URL below and add it to your list of Web Clips.", -+ IDC_STATIC,0,33,239,18 -+ PUSHBUTTON "Add Recent &Clips (10)...", -+ IDC_SIDEBAR_RSS_ADD_RECENT_CLIPS,146,14,93,14 -+END'''), 'IDD_SIDEBAR_RSS_PANEL_PROPPAGE') -+ dlg.SetUberClique(self.uq) -+ dlg.Parse() -+ -+ warnings = shortcuts.GenerateDuplicateShortcutsWarnings(self.uq, 'PROJECT') -+ self.failUnless(len(warnings) == 0) -+ -diff --git a/tools/grit/grit/tclib.py b/tools/grit/grit/tclib.py -new file mode 100644 -index 0000000000..27ba366924 ---- /dev/null -+++ b/tools/grit/grit/tclib.py -@@ -0,0 +1,246 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Adaptation of the extern.tclib classes for our needs. -+''' -+ -+from __future__ import print_function -+ -+import functools -+import re -+ -+import six -+ -+from grit import exception -+from grit import lazy_re -+import grit.extern.tclib -+ -+ -+# Matches whitespace sequences which can be folded into a single whitespace -+# character. This matches single characters so that non-spaces are replaced -+# with spaces. -+_FOLD_WHITESPACE = re.compile(r'\s+') -+ -+# Caches compiled regexp used to split tags in BaseMessage.__init__() -+_RE_CACHE = {} -+ -+def Identity(i): -+ return i -+ -+ -+class BaseMessage(object): -+ '''Base class with methods shared by Message and Translation. -+ ''' -+ -+ def __init__(self, text='', placeholders=[], description='', meaning=''): -+ self.parts = [] -+ self.placeholders = [] -+ self.meaning = meaning -+ self.dirty = True # True if self.id is (or might be) wrong -+ self.id = 0 -+ self.SetDescription(description) -+ -+ if text != '': -+ if not placeholders or placeholders == []: -+ self.AppendText(text) -+ else: -+ tag_map = {} -+ for placeholder in placeholders: -+ tag_map[placeholder.GetPresentation()] = [placeholder, 0] -+ # This creates a regexp like '(TAG1|TAG2|TAG3)'. -+ # The tags have to be sorted in order of decreasing length, so that -+ # longer tags are substituted before shorter tags that happen to be -+ # substrings of the longer tag. -+ # E.g. "EXAMPLE_FOO_NAME" must be matched before "EXAMPLE_FOO", -+ # otherwise "EXAMPLE_FOO" splits "EXAMPLE_FOO_NAME" too. -+ tags = sorted(tag_map.keys(), -+ key=functools.cmp_to_key( -+ lambda x, y: len(x) - len(y) or ((x > y) - (x < y))), -+ reverse=True) -+ tag_re = '(' + '|'.join(tags) + ')' -+ -+ # This caching improves the time to build -+ # chrome/app:generated_resources from 21.562s to 17.672s on Linux. -+ compiled_re = _RE_CACHE.get(tag_re, None) -+ if compiled_re is None: -+ compiled_re = re.compile(tag_re) -+ _RE_CACHE[tag_re] = compiled_re -+ -+ chunked_text = compiled_re.split(text) -+ -+ for chunk in chunked_text: -+ if chunk: # ignore empty chunk -+ if chunk in tag_map: -+ self.AppendPlaceholder(tag_map[chunk][0]) -+ tag_map[chunk][1] += 1 # increase placeholder use count -+ else: -+ self.AppendText(chunk) -+ for key in tag_map: -+ assert tag_map[key][1] != 0 -+ -+ def GetRealContent(self, escaping_function=Identity): -+ '''Returns the original content, i.e. what your application and users -+ will see. -+ -+ Specify a function to escape each translateable bit, if you like. -+ ''' -+ bits = [] -+ for item in self.parts: -+ if isinstance(item, six.string_types): -+ bits.append(escaping_function(item)) -+ else: -+ bits.append(item.GetOriginal()) -+ return ''.join(bits) -+ -+ def GetPresentableContent(self): -+ presentable_content = [] -+ for part in self.parts: -+ if isinstance(part, Placeholder): -+ presentable_content.append(part.GetPresentation()) -+ else: -+ presentable_content.append(part) -+ return ''.join(presentable_content) -+ -+ def AppendPlaceholder(self, placeholder): -+ assert isinstance(placeholder, Placeholder) -+ dup = False -+ for other in self.GetPlaceholders(): -+ if other.presentation == placeholder.presentation: -+ assert other.original == placeholder.original -+ dup = True -+ -+ if not dup: -+ self.placeholders.append(placeholder) -+ self.parts.append(placeholder) -+ self.dirty = True -+ -+ def AppendText(self, text): -+ assert isinstance(text, six.string_types) -+ assert text != '' -+ -+ self.parts.append(text) -+ self.dirty = True -+ -+ def GetContent(self): -+ '''Returns the parts of the message. You may modify parts if you wish. -+ Note that you must not call GetId() on this object until you have finished -+ modifying the contents. -+ ''' -+ self.dirty = True # user might modify content -+ return self.parts -+ -+ def GetDescription(self): -+ return self.description -+ -+ def SetDescription(self, description): -+ self.description = _FOLD_WHITESPACE.sub(' ', description) -+ -+ def GetMeaning(self): -+ return self.meaning -+ -+ def GetId(self): -+ if self.dirty: -+ self.id = self.GenerateId() -+ self.dirty = False -+ return self.id -+ -+ def GenerateId(self): -+ return grit.extern.tclib.GenerateMessageId(self.GetPresentableContent(), -+ self.meaning) -+ -+ def GetPlaceholders(self): -+ return self.placeholders -+ -+ def FillTclibBaseMessage(self, msg): -+ msg.SetDescription(self.description.encode('utf-8')) -+ -+ for part in self.parts: -+ if isinstance(part, Placeholder): -+ ph = grit.extern.tclib.Placeholder( -+ part.presentation.encode('utf-8'), -+ part.original.encode('utf-8'), -+ part.example.encode('utf-8')) -+ msg.AppendPlaceholder(ph) -+ else: -+ msg.AppendText(part.encode('utf-8')) -+ -+ -+class Message(BaseMessage): -+ '''A message.''' -+ -+ def __init__(self, text='', placeholders=[], description='', meaning='', -+ assigned_id=None): -+ super(Message, self).__init__(text, placeholders, description, meaning) -+ self.assigned_id = assigned_id -+ -+ def ToTclibMessage(self): -+ msg = grit.extern.tclib.Message('utf-8', meaning=self.meaning) -+ self.FillTclibBaseMessage(msg) -+ return msg -+ -+ def GetId(self): -+ '''Use the assigned id if we have one.''' -+ if self.assigned_id: -+ return self.assigned_id -+ -+ return super(Message, self).GetId() -+ -+ def HasAssignedId(self): -+ '''Returns True if this message has an assigned id.''' -+ return bool(self.assigned_id) -+ -+ -+class Translation(BaseMessage): -+ '''A translation.''' -+ -+ def __init__(self, text='', id='', placeholders=[], description='', meaning=''): -+ super(Translation, self).__init__(text, placeholders, description, meaning) -+ self.id = id -+ -+ def GetId(self): -+ assert id != '', "ID has not been set." -+ return self.id -+ -+ def SetId(self, id): -+ self.id = id -+ -+ def ToTclibMessage(self): -+ msg = grit.extern.tclib.Message( -+ 'utf-8', id=self.id, meaning=self.meaning) -+ self.FillTclibBaseMessage(msg) -+ return msg -+ -+ -+class Placeholder(grit.extern.tclib.Placeholder): -+ '''Modifies constructor to accept a Unicode string -+ ''' -+ -+ # Must match placeholder presentation names -+ _NAME_RE = lazy_re.compile('^[A-Za-z0-9_]+$') -+ -+ def __init__(self, presentation, original, example): -+ '''Creates a new placeholder. -+ -+ Args: -+ presentation: 'USERNAME' -+ original: '%s' -+ example: 'Joi' -+ ''' -+ assert presentation != '' -+ assert original != '' -+ assert example != '' -+ if not self._NAME_RE.match(presentation): -+ raise exception.InvalidPlaceholderName(presentation) -+ self.presentation = presentation -+ self.original = original -+ self.example = example -+ -+ def GetPresentation(self): -+ return self.presentation -+ -+ def GetOriginal(self): -+ return self.original -+ -+ def GetExample(self): -+ return self.example -diff --git a/tools/grit/grit/tclib_unittest.py b/tools/grit/grit/tclib_unittest.py -new file mode 100644 -index 0000000000..7a08654e1b ---- /dev/null -+++ b/tools/grit/grit/tclib_unittest.py -@@ -0,0 +1,180 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.tclib''' -+ -+from __future__ import print_function -+ -+import sys -+import os.path -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -+ -+import unittest -+ -+import six -+ -+from grit import tclib -+ -+from grit import exception -+import grit.extern.tclib -+ -+ -+class TclibUnittest(unittest.TestCase): -+ def testInit(self): -+ msg = tclib.Message(text=u'Hello Earthlings', -+ description='Greetings\n\t message') -+ self.failUnlessEqual(msg.GetPresentableContent(), 'Hello Earthlings') -+ self.failUnless(isinstance(msg.GetPresentableContent(), six.string_types)) -+ self.failUnlessEqual(msg.GetDescription(), 'Greetings message') -+ -+ def testGetAttr(self): -+ msg = tclib.Message() -+ msg.AppendText(u'Hello') # Tests __getattr__ -+ self.failUnless(msg.GetPresentableContent() == 'Hello') -+ self.failUnless(isinstance(msg.GetPresentableContent(), six.string_types)) -+ -+ def testAll(self): -+ text = u'Howdie USERNAME' -+ phs = [tclib.Placeholder(u'USERNAME', u'%s', 'Joi')] -+ msg = tclib.Message(text=text, placeholders=phs) -+ self.failUnless(msg.GetPresentableContent() == 'Howdie USERNAME') -+ -+ trans = tclib.Translation(text=text, placeholders=phs) -+ self.failUnless(trans.GetPresentableContent() == 'Howdie USERNAME') -+ self.failUnless(isinstance(trans.GetPresentableContent(), six.string_types)) -+ -+ def testUnicodeReturn(self): -+ text = u'\u00fe' -+ msg = tclib.Message(text=text) -+ self.failUnless(msg.GetPresentableContent() == text) -+ from_list = msg.GetContent()[0] -+ self.failUnless(from_list == text) -+ -+ def testRegressionTranslationInherited(self): -+ '''Regression tests a bug that was caused by grit.tclib.Translation -+ inheriting from the translation console's Translation object -+ instead of only owning an instance of it. -+ ''' -+ msg = tclib.Message(text=u"BLA1\r\nFrom: BLA2 \u00fe BLA3", -+ placeholders=[ -+ tclib.Placeholder('BLA1', '%s', '%s'), -+ tclib.Placeholder('BLA2', '%s', '%s'), -+ tclib.Placeholder('BLA3', '%s', '%s')]) -+ transl = tclib.Translation(text=msg.GetPresentableContent(), -+ placeholders=msg.GetPlaceholders()) -+ content = transl.GetContent() -+ self.failUnless(isinstance(content[3], six.string_types)) -+ -+ def testFingerprint(self): -+ # This has Windows line endings. That is on purpose. -+ id = grit.extern.tclib.GenerateMessageId( -+ 'Google Desktop for Enterprise\r\n' -+ 'All Rights Reserved\r\n' -+ '\r\n' -+ '---------\r\n' -+ 'Contents\r\n' -+ '---------\r\n' -+ 'This distribution contains the following files:\r\n' -+ '\r\n' -+ 'GoogleDesktopSetup.msi - Installation and setup program\r\n' -+ 'GoogleDesktop.adm - Group Policy administrative template file\r\n' -+ 'AdminGuide.pdf - Google Desktop for Enterprise administrative guide\r\n' -+ '\r\n' -+ '\r\n' -+ '--------------\r\n' -+ 'Documentation\r\n' -+ '--------------\r\n' -+ 'Full documentation and installation instructions are in the \r\n' -+ 'administrative guide, and also online at \r\n' -+ 'http://desktop.google.com/enterprise/adminguide.html.\r\n' -+ '\r\n' -+ '\r\n' -+ '------------------------\r\n' -+ 'IBM Lotus Notes Plug-In\r\n' -+ '------------------------\r\n' -+ 'The Lotus Notes plug-in is included in the release of Google \r\n' -+ 'Desktop for Enterprise. The IBM Lotus Notes Plug-in for Google \r\n' -+ 'Desktop indexes mail, calendar, task, contact and journal \r\n' -+ 'documents from Notes. Discussion documents including those from \r\n' -+ 'the discussion and team room templates can also be indexed by \r\n' -+ 'selecting an option from the preferences. Once indexed, this data\r\n' -+ 'will be returned in Google Desktop searches. The corresponding\r\n' -+ 'document can be opened in Lotus Notes from the Google Desktop \r\n' -+ 'results page.\r\n' -+ '\r\n' -+ 'Install: The plug-in will install automatically during the Google \r\n' -+ 'Desktop setup process if Lotus Notes is already installed. Lotus \r\n' -+ 'Notes must not be running in order for the install to occur. \r\n' -+ '\r\n' -+ 'Preferences: Preferences and selection of databases to index are\r\n' -+ 'set in the \'Google Desktop for Notes\' dialog reached through the \r\n' -+ '\'Actions\' menu.\r\n' -+ '\r\n' -+ 'Reindexing: Selecting \'Reindex all databases\' will index all the \r\n' -+ 'documents in each database again.\r\n' -+ '\r\n' -+ '\r\n' -+ 'Notes Plug-in Known Issues\r\n' -+ '---------------------------\r\n' -+ '\r\n' -+ 'If the \'Google Desktop for Notes\' item is not available from the \r\n' -+ 'Lotus Notes Actions menu, then installation was not successful. \r\n' -+ 'Installation consists of writing one file, notesgdsplugin.dll, to \r\n' -+ 'the Notes application directory and a setting to the notes.ini \r\n' -+ 'configuration file. The most likely cause of an unsuccessful \r\n' -+ 'installation is that the installer was not able to locate the \r\n' -+ 'notes.ini file. Installation will complete if the user closes Notes\r\n' -+ 'and manually adds the following setting to this file on a new line:\r\n' -+ 'AddinMenus=notegdsplugin.dll\r\n' -+ '\r\n' -+ 'If the notesgdsplugin.dll file is not in the application directory\r\n' -+ r'(e.g., C:\Program Files\Lotus\Notes) after Google Desktop \r\n' -+ 'installation, it is likely that Notes was not installed correctly. \r\n' -+ '\r\n' -+ 'Only local databases can be indexed. If they can be determined, \r\n' -+ 'the user\'s local mail file and address book will be included in the\r\n' -+ 'list automatically. Mail archives and other databases must be \r\n' -+ 'added with the \'Add\' button.\r\n' -+ '\r\n' -+ 'Some users may experience performance issues during the initial \r\n' -+ 'indexing of a database. The \'Perform the initial index of a \r\n' -+ 'database only when I\'m idle\' option will limit the indexing process\r\n' -+ 'to times when the user is not using the machine. If this does not \r\n' -+ 'alleviate the problem or the user would like to continually index \r\n' -+ 'but just do so more slowly or quickly, the GoogleWaitTime notes.ini\r\n' -+ 'value can be set. Increasing the GoogleWaitTime value will slow \r\n' -+ 'down the indexing process, and lowering the value will speed it up.\r\n' -+ 'A value of zero causes the fastest possible indexing. Removing the\r\n' -+ 'ini parameter altogether returns it to the default (20).\r\n' -+ '\r\n' -+ 'Crashes have been known to occur with certain types of history \r\n' -+ 'bookmarks. If the Notes client seems to crash randomly, try \r\n' -+ 'disabling the \'Index note history\' option. If it crashes before,\r\n' -+ 'you can get to the preferences, add the following line to your \r\n' -+ 'notes.ini file:\r\n' -+ 'GDSNoIndexHistory=1\r\n') -+ self.assertEqual(id, '7660964495923572726') -+ -+ def testPlaceholderNameChecking(self): -+ try: -+ ph = tclib.Placeholder('BINGO BONGO', 'bla', 'bla') -+ raise Exception("We shouldn't get here") -+ except exception.InvalidPlaceholderName: -+ pass # Expect exception to be thrown because presentation contained space -+ -+ def testTagsWithCommonSubstring(self): -+ word = 'ABCDEFGHIJ' -+ text = ' '.join([word[:i] for i in range(1, 11)]) -+ phs = [tclib.Placeholder(word[:i], str(i), str(i)) for i in range(1, 11)] -+ try: -+ msg = tclib.Message(text=text, placeholders=phs) -+ self.failUnless(msg.GetRealContent() == '1 2 3 4 5 6 7 8 9 10') -+ except: -+ self.fail('tclib.Message() should handle placeholders that are ' -+ 'substrings of each other') -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/test_suite_all.py b/tools/grit/grit/test_suite_all.py -new file mode 100644 -index 0000000000..3bfe2a79d5 ---- /dev/null -+++ b/tools/grit/grit/test_suite_all.py -@@ -0,0 +1,34 @@ -+#!/usr/bin/env python3 -+# Copyright (c) 2011 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit test suite that collects all test cases for GRIT.''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+ -+ -+CUR_DIR = os.path.dirname(os.path.realpath(__file__)) -+SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(CUR_DIR))) -+TYP_DIR = os.path.join( -+ SRC_DIR, 'third_party', 'catapult', 'third_party', 'typ') -+ -+if TYP_DIR not in sys.path: -+ sys.path.insert(0, TYP_DIR) -+ -+ -+import typ # pylint: disable=import-error,unused-import -+ -+ -+def main(args): -+ return typ.main( -+ top_level_dirs=[os.path.join(CUR_DIR, '..')], -+ skip=['grit.format.gen_predetermined_ids_unittest.*', -+ 'grit.pseudo_unittest.*'] -+ ) -+ -+if __name__ == '__main__': -+ sys.exit(main(sys.argv[1:])) -diff --git a/tools/grit/grit/testdata/GoogleDesktop.adm b/tools/grit/grit/testdata/GoogleDesktop.adm -new file mode 100644 -index 0000000000..082f56bb1a ---- /dev/null -+++ b/tools/grit/grit/testdata/GoogleDesktop.adm -@@ -0,0 +1,945 @@ -+CLASS MACHINE -+ CATEGORY !!Cat_Google -+ CATEGORY !!Cat_GoogleDesktopSearch -+ KEYNAME "Software\Policies\Google\Google Desktop" -+ -+ CATEGORY !!Cat_Preferences -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences" -+ -+ CATEGORY !!Cat_IndexAndCaptureControl -+ POLICY !!Blacklist_Email -+ EXPLAIN !!Explain_Blacklist_Email -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ VALUENAME "1" -+ END POLICY -+ -+ POLICY !!Blacklist_Gmail -+ EXPLAIN !!Explain_Blacklist_Gmail -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-pop" -+ VALUENAME "gmail" -+ END POLICY -+ -+ POLICY !!Blacklist_WebHistory -+ EXPLAIN !!Explain_Blacklist_WebHistory -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ VALUENAME "2" -+ END POLICY -+ -+ POLICY !!Blacklist_Chat -+ EXPLAIN !!Explain_Blacklist_Chat -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "3" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Text -+ EXPLAIN !!Explain_Blacklist_Text -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "4" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Media -+ EXPLAIN !!Explain_Blacklist_Media -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "5" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Contact -+ EXPLAIN !!Explain_Blacklist_Contact -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "9" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Calendar -+ EXPLAIN !!Explain_Blacklist_Calendar -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "10" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Task -+ EXPLAIN !!Explain_Blacklist_Task -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "11" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Note -+ EXPLAIN !!Explain_Blacklist_Note -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "12" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Journal -+ EXPLAIN !!Explain_Blacklist_Journal -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "13" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Word -+ EXPLAIN !!Explain_Blacklist_Word -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "DOC" -+ END POLICY -+ -+ POLICY !!Blacklist_Excel -+ EXPLAIN !!Explain_Blacklist_Excel -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "XLS" -+ END POLICY -+ -+ POLICY !!Blacklist_Powerpoint -+ EXPLAIN !!Explain_Blacklist_Powerpoint -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "PPT" -+ END POLICY -+ -+ POLICY !!Blacklist_PDF -+ EXPLAIN !!Explain_Blacklist_PDF -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "PDF" -+ END POLICY -+ -+ POLICY !!Blacklist_ZIP -+ EXPLAIN !!Explain_Blacklist_ZIP -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "ZIP" -+ END POLICY -+ -+ POLICY !!Blacklist_HTTPS -+ EXPLAIN !!Explain_Blacklist_HTTPS -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-3" -+ VALUENAME "HTTPS" -+ END POLICY -+ -+ POLICY !!Blacklist_PasswordProtectedOffice -+ EXPLAIN !!Explain_Blacklist_PasswordProtectedOffice -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-13" -+ VALUENAME "SECUREOFFICE" -+ END POLICY -+ -+ POLICY !!Blacklist_URI_Contains -+ EXPLAIN !!Explain_Blacklist_URI_Contains -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-6" -+ PART !!Blacklist_URI_Contains LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Blacklist_Extensions -+ EXPLAIN !!Explain_Blacklist_Extensions -+ PART !!Blacklist_Extensions EDITTEXT -+ VALUENAME "file_extensions_to_skip" -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Disallow_UserSearchLocations -+ EXPLAIN !!Explain_Disallow_UserSearchLocations -+ VALUENAME user_search_locations -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Search_Location_Whitelist -+ EXPLAIN !!Explain_Search_Location_Whitelist -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\policy_search_location_whitelist" -+ PART !!Search_Locations_Whitelist LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Email_Retention -+ EXPLAIN !!Explain_Email_Retention -+ PART !!Email_Retention_Edit NUMERIC -+ VALUENAME "email_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Webpage_Retention -+ EXPLAIN !!Explain_Webpage_Retention -+ PART !!Webpage_Retention_Edit NUMERIC -+ VALUENAME "webpage_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!File_Retention -+ EXPLAIN !!Explain_File_Retention -+ PART !!File_Retention_Edit NUMERIC -+ VALUENAME "file_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!IM_Retention -+ EXPLAIN !!Explain_IM_Retention -+ PART !!IM_Retention_Edit NUMERIC -+ VALUENAME "im_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Remove_Deleted_Items -+ EXPLAIN !!Explain_Remove_Deleted_Items -+ VALUENAME remove_deleted_items -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Allow_Simultaneous_Indexing -+ EXPLAIN !!Explain_Allow_Simultaneous_Indexing -+ VALUENAME simultaneous_indexing -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ END CATEGORY -+ -+ POLICY !!Pol_TurnOffAdvancedFeatures -+ EXPLAIN !!Explain_TurnOffAdvancedFeatures -+ VALUENAME error_report_on -+ VALUEON NUMERIC 0 -+ END POLICY -+ -+ POLICY !!Pol_TurnOffImproveGd -+ EXPLAIN !!Explain_TurnOffImproveGd -+ VALUENAME improve_gd -+ VALUEON NUMERIC 0 -+ VALUEOFF NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_NoPersonalizationInfo -+ EXPLAIN !!Explain_NoPersonalizationInfo -+ VALUENAME send_personalization_info -+ VALUEON NUMERIC 0 -+ VALUEOFF NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_OneBoxMode -+ EXPLAIN !!Explain_OneBoxMode -+ VALUENAME onebox_mode -+ VALUEON NUMERIC 0 -+ END POLICY -+ -+ POLICY !!Pol_EncryptIndex -+ EXPLAIN !!Explain_EncryptIndex -+ VALUENAME encrypt_index -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Hyper -+ EXPLAIN !!Explain_Hyper -+ VALUENAME hyper_off -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Display_Mode -+ EXPLAIN !!Explain_Display_Mode -+ PART !!Pol_Display_Mode DROPDOWNLIST -+ VALUENAME display_mode -+ ITEMLIST -+ NAME !!Sidebar VALUE NUMERIC 1 -+ NAME !!Deskbar VALUE NUMERIC 8 -+ NAME !!FloatingDeskbar VALUE NUMERIC 4 -+ NAME !!None VALUE NUMERIC 0 -+ END ITEMLIST -+ END PART -+ END POLICY -+ -+ END CATEGORY ; Preferences -+ -+ CATEGORY !!Cat_Enterprise -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise" -+ -+ POLICY !!Pol_Autoupdate -+ EXPLAIN !!Explain_Autoupdate -+ VALUENAME autoupdate_host -+ VALUEON "" -+ END POLICY -+ -+ POLICY !!Pol_AutoupdateAsSystem -+ EXPLAIN !!Explain_AutoupdateAsSystem -+ VALUENAME autoupdate_impersonate_user -+ VALUEON NUMERIC 0 -+ VALUEOFF NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_EnterpriseTab -+ EXPLAIN !!Explain_EnterpriseTab -+ PART !!EnterpriseTabText EDITTEXT -+ VALUENAME enterprise_tab_text -+ END PART -+ PART !!EnterpriseTabHomepage EDITTEXT -+ VALUENAME enterprise_tab_homepage -+ END PART -+ PART !!EnterpriseTabHomepageQuery CHECKBOX -+ VALUENAME enterprise_tab_homepage_query -+ END PART -+ PART !!EnterpriseTabResults EDITTEXT -+ VALUENAME enterprise_tab_results -+ END PART -+ PART !!EnterpriseTabResultsQuery CHECKBOX -+ VALUENAME enterprise_tab_results_query -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_GSAHosts -+ EXPLAIN !!Explain_GSAHosts -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\GSAHosts" -+ PART !!Pol_GSAHosts LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_PolicyUnawareClientProhibitedFlag -+ EXPLAIN !!Explain_PolicyUnawareClientProhibitedFlag -+ KEYNAME "Software\Policies\Google\Google Desktop" -+ VALUENAME PolicyUnawareClientProhibitedFlag -+ END POLICY -+ -+ POLICY !!Pol_MinimumAllowedVersion -+ EXPLAIN !!Explain_MinimumAllowedVersion -+ PART !!Pol_MinimumAllowedVersion EDITTEXT -+ VALUENAME minimum_allowed_version -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_MaximumAllowedVersion -+ EXPLAIN !!Explain_MaximumAllowedVersion -+ PART !!Pol_MaximumAllowedVersion EDITTEXT -+ VALUENAME maximum_allowed_version -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Disallow_Gadgets -+ EXPLAIN !!Explain_Disallow_Gadgets -+ VALUENAME disallow_gadgets -+ VALUEON NUMERIC 1 -+ PART !!Disallow_Only_Non_Builtin_Gadgets CHECKBOX DEFCHECKED -+ VALUENAME disallow_only_non_builtin_gadgets -+ VALUEON NUMERIC 1 -+ VALUEOFF NUMERIC 0 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Gadget_Whitelist -+ EXPLAIN !!Explain_Gadget_Whitelist -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\gadget_whitelist" -+ PART !!Pol_Gadget_Whitelist LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Gadget_Install_Confirmation_Whitelist -+ EXPLAIN !!Explain_Gadget_Install_Confirmation_Whitelist -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\install_confirmation_whitelist" -+ PART !!Pol_Gadget_Install_Confirmation_Whitelist LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Alternate_User_Data_Dir -+ EXPLAIN !!Explain_Alternate_User_Data_Dir -+ PART !!Pol_Alternate_User_Data_Dir EDITTEXT -+ VALUENAME alternate_user_data_dir -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_MaxAllowedOutlookConnections -+ EXPLAIN !!Explain_MaxAllowedOutlookConnections -+ PART !!Pol_MaxAllowedOutlookConnections NUMERIC -+ VALUENAME max_allowed_outlook_connections -+ MIN 1 MAX 65535 DEFAULT 400 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_DisallowSsdService -+ EXPLAIN !!Explain_DisallowSsdService -+ VALUENAME disallow_ssd_service -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_DisallowSsdOutbound -+ EXPLAIN !!Explain_DisallowSsdOutbound -+ VALUENAME disallow_ssd_outbound -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Disallow_Store_Gadget_Service -+ EXPLAIN !!Explain_Disallow_Store_Gadget_Service -+ VALUENAME disallow_store_gadget_service -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_MaxExchangeIndexingRate -+ EXPLAIN !!Explain_MaxExchangeIndexingRate -+ PART !!Pol_MaxExchangeIndexingRate NUMERIC -+ VALUENAME max_exchange_indexing_rate -+ MIN 1 MAX 1000 DEFAULT 60 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_EnableSafeweb -+ EXPLAIN !!Explain_Safeweb -+ VALUENAME safe_browsing -+ VALUEON NUMERIC 1 -+ VALUEOFF NUMERIC 0 -+ END POLICY -+ -+ END CATEGORY ; Enterprise -+ -+ END CATEGORY ; GoogleDesktopSearch -+ END CATEGORY ; Google -+ -+ -+CLASS USER -+ CATEGORY !!Cat_Google -+ CATEGORY !!Cat_GoogleDesktopSearch -+ KEYNAME "Software\Policies\Google\Google Desktop" -+ -+ CATEGORY !!Cat_Preferences -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences" -+ -+ CATEGORY !!Cat_IndexAndCaptureControl -+ POLICY !!Blacklist_Email -+ EXPLAIN !!Explain_Blacklist_Email -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ VALUENAME "1" -+ END POLICY -+ -+ POLICY !!Blacklist_Gmail -+ EXPLAIN !!Explain_Blacklist_Gmail -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-pop" -+ VALUENAME "gmail" -+ END POLICY -+ -+ POLICY !!Blacklist_WebHistory -+ EXPLAIN !!Explain_Blacklist_WebHistory -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ VALUENAME "2" -+ END POLICY -+ -+ POLICY !!Blacklist_Chat -+ EXPLAIN !!Explain_Blacklist_Chat -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "3" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Text -+ EXPLAIN !!Explain_Blacklist_Text -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "4" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Media -+ EXPLAIN !!Explain_Blacklist_Media -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "5" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Contact -+ EXPLAIN !!Explain_Blacklist_Contact -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "9" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Calendar -+ EXPLAIN !!Explain_Blacklist_Calendar -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "10" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Task -+ EXPLAIN !!Explain_Blacklist_Task -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "11" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Note -+ EXPLAIN !!Explain_Blacklist_Note -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "12" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Journal -+ EXPLAIN !!Explain_Blacklist_Journal -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-1" -+ ACTIONLISTON -+ VALUENAME "13" VALUE NUMERIC 1 -+ END ACTIONLISTON -+ END POLICY -+ -+ POLICY !!Blacklist_Word -+ EXPLAIN !!Explain_Blacklist_Word -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "DOC" -+ END POLICY -+ -+ POLICY !!Blacklist_Excel -+ EXPLAIN !!Explain_Blacklist_Excel -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "XLS" -+ END POLICY -+ -+ POLICY !!Blacklist_Powerpoint -+ EXPLAIN !!Explain_Blacklist_Powerpoint -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "PPT" -+ END POLICY -+ -+ POLICY !!Blacklist_PDF -+ EXPLAIN !!Explain_Blacklist_PDF -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "PDF" -+ END POLICY -+ -+ POLICY !!Blacklist_ZIP -+ EXPLAIN !!Explain_Blacklist_ZIP -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-2" -+ VALUENAME "ZIP" -+ END POLICY -+ -+ POLICY !!Blacklist_HTTPS -+ EXPLAIN !!Explain_Blacklist_HTTPS -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-3" -+ VALUENAME "HTTPS" -+ END POLICY -+ -+ POLICY !!Blacklist_PasswordProtectedOffice -+ EXPLAIN !!Explain_Blacklist_PasswordProtectedOffice -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-13" -+ VALUENAME "SECUREOFFICE" -+ END POLICY -+ -+ POLICY !!Blacklist_URI_Contains -+ EXPLAIN !!Explain_Blacklist_URI_Contains -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\blacklist-6" -+ PART !!Blacklist_URI_Contains LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Blacklist_Extensions -+ EXPLAIN !!Explain_Blacklist_Extensions -+ PART !!Blacklist_Extensions EDITTEXT -+ VALUENAME "file_extensions_to_skip" -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Disallow_UserSearchLocations -+ EXPLAIN !!Explain_Disallow_UserSearchLocations -+ VALUENAME user_search_locations -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Search_Location_Whitelist -+ EXPLAIN !!Explain_Search_Location_Whitelist -+ KEYNAME "Software\Policies\Google\Google Desktop\Preferences\policy_search_location_whitelist" -+ PART !!Search_Locations_Whitelist LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Email_Retention -+ EXPLAIN !!Explain_Email_Retention -+ PART !!Email_Retention_Edit NUMERIC -+ VALUENAME "email_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Webpage_Retention -+ EXPLAIN !!Explain_Webpage_Retention -+ PART !!Webpage_Retention_Edit NUMERIC -+ VALUENAME "webpage_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!File_Retention -+ EXPLAIN !!Explain_File_Retention -+ PART !!File_Retention_Edit NUMERIC -+ VALUENAME "file_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!IM_Retention -+ EXPLAIN !!Explain_IM_Retention -+ PART !!IM_Retention_Edit NUMERIC -+ VALUENAME "im_days_to_retain" -+ MIN 1 MAX 65535 DEFAULT 30 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Remove_Deleted_Items -+ EXPLAIN !!Explain_Remove_Deleted_Items -+ VALUENAME remove_deleted_items -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Allow_Simultaneous_Indexing -+ EXPLAIN !!Explain_Allow_Simultaneous_Indexing -+ VALUENAME simultaneous_indexing -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ END CATEGORY -+ -+ POLICY !!Pol_TurnOffAdvancedFeatures -+ EXPLAIN !!Explain_TurnOffAdvancedFeatures -+ VALUENAME error_report_on -+ VALUEON NUMERIC 0 -+ END POLICY -+ -+ POLICY !!Pol_TurnOffImproveGd -+ EXPLAIN !!Explain_TurnOffImproveGd -+ VALUENAME improve_gd -+ VALUEON NUMERIC 0 -+ VALUEOFF NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_NoPersonalizationInfo -+ EXPLAIN !!Explain_NoPersonalizationInfo -+ VALUENAME send_personalization_info -+ VALUEON NUMERIC 0 -+ VALUEOFF NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_OneBoxMode -+ EXPLAIN !!Explain_OneBoxMode -+ VALUENAME onebox_mode -+ VALUEON NUMERIC 0 -+ END POLICY -+ -+ POLICY !!Pol_EncryptIndex -+ EXPLAIN !!Explain_EncryptIndex -+ VALUENAME encrypt_index -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Hyper -+ EXPLAIN !!Explain_Hyper -+ VALUENAME hyper_off -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Display_Mode -+ EXPLAIN !!Explain_Display_Mode -+ PART !!Pol_Display_Mode DROPDOWNLIST -+ VALUENAME display_mode -+ ITEMLIST -+ NAME !!Sidebar VALUE NUMERIC 1 -+ NAME !!Deskbar VALUE NUMERIC 8 -+ NAME !!FloatingDeskbar VALUE NUMERIC 4 -+ NAME !!None VALUE NUMERIC 0 -+ END ITEMLIST -+ END PART -+ END POLICY -+ -+ END CATEGORY ; Preferences -+ -+ CATEGORY !!Cat_Enterprise -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise" -+ -+ POLICY !!Pol_Autoupdate -+ EXPLAIN !!Explain_Autoupdate -+ VALUENAME autoupdate_host -+ VALUEON "" -+ END POLICY -+ -+ POLICY !!Pol_AutoupdateAsSystem -+ EXPLAIN !!Explain_AutoupdateAsSystem -+ VALUENAME autoupdate_impersonate_user -+ VALUEON NUMERIC 0 -+ VALUEOFF NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_EnterpriseTab -+ EXPLAIN !!Explain_EnterpriseTab -+ PART !!EnterpriseTabText EDITTEXT -+ VALUENAME enterprise_tab_text -+ END PART -+ PART !!EnterpriseTabHomepage EDITTEXT -+ VALUENAME enterprise_tab_homepage -+ END PART -+ PART !!EnterpriseTabHomepageQuery CHECKBOX -+ VALUENAME enterprise_tab_homepage_query -+ END PART -+ PART !!EnterpriseTabResults EDITTEXT -+ VALUENAME enterprise_tab_results -+ END PART -+ PART !!EnterpriseTabResultsQuery CHECKBOX -+ VALUENAME enterprise_tab_results_query -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_GSAHosts -+ EXPLAIN !!Explain_GSAHosts -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\GSAHosts" -+ PART !!Pol_GSAHosts LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Disallow_Gadgets -+ EXPLAIN !!Explain_Disallow_Gadgets -+ VALUENAME disallow_gadgets -+ VALUEON NUMERIC 1 -+ PART !!Disallow_Only_Non_Builtin_Gadgets CHECKBOX DEFCHECKED -+ VALUENAME disallow_only_non_builtin_gadgets -+ VALUEON NUMERIC 1 -+ VALUEOFF NUMERIC 0 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Gadget_Whitelist -+ EXPLAIN !!Explain_Gadget_Whitelist -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\gadget_whitelist" -+ PART !!Pol_Gadget_Whitelist LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Gadget_Install_Confirmation_Whitelist -+ EXPLAIN !!Explain_Gadget_Install_Confirmation_Whitelist -+ KEYNAME "Software\Policies\Google\Google Desktop\Enterprise\install_confirmation_whitelist" -+ PART !!Pol_Gadget_Install_Confirmation_Whitelist LISTBOX -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_Alternate_User_Data_Dir -+ EXPLAIN !!Explain_Alternate_User_Data_Dir -+ PART !!Pol_Alternate_User_Data_Dir EDITTEXT -+ VALUENAME alternate_user_data_dir -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_MaxAllowedOutlookConnections -+ EXPLAIN !!Explain_MaxAllowedOutlookConnections -+ PART !!Pol_MaxAllowedOutlookConnections NUMERIC -+ VALUENAME max_allowed_outlook_connections -+ MIN 1 MAX 65535 DEFAULT 400 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_DisallowSsdService -+ EXPLAIN !!Explain_DisallowSsdService -+ VALUENAME disallow_ssd_service -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_DisallowSsdOutbound -+ EXPLAIN !!Explain_DisallowSsdOutbound -+ VALUENAME disallow_ssd_outbound -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_Disallow_Store_Gadget_Service -+ EXPLAIN !!Explain_Disallow_Store_Gadget_Service -+ VALUENAME disallow_store_gadget_service -+ VALUEON NUMERIC 1 -+ END POLICY -+ -+ POLICY !!Pol_MaxExchangeIndexingRate -+ EXPLAIN !!Explain_MaxExchangeIndexingRate -+ PART !!Pol_MaxExchangeIndexingRate NUMERIC -+ VALUENAME max_exchange_indexing_rate -+ MIN 1 MAX 1000 DEFAULT 60 SPIN 1 -+ END PART -+ END POLICY -+ -+ POLICY !!Pol_EnableSafeweb -+ EXPLAIN !!Explain_Safeweb -+ VALUENAME safe_browsing -+ VALUEON NUMERIC 1 -+ VALUEOFF NUMERIC 0 -+ END POLICY -+ -+ END CATEGORY ; Enterprise -+ -+ END CATEGORY ; GoogleDesktopSearch -+ END CATEGORY ; Google -+ -+;------------------------------------------------------------------------------ -+ -+[strings] -+Cat_Google="Google" -+Cat_GoogleDesktopSearch="Google Desktop" -+ -+;------------------------------------------------------------------------------ -+; Preferences -+;------------------------------------------------------------------------------ -+Cat_Preferences="Preferences" -+Explain_Preferences="Controls Google Desktop preferences" -+ -+Cat_IndexAndCaptureControl="Indexing and Capture Control" -+Explain_IndexAndCaptureControl="Controls what files, web pages, and other content will be indexed by Google Desktop." -+ -+Blacklist_Email="Prevent indexing of email" -+Explain_Blacklist_Email="Enabling this policy will prevent Google Desktop from indexing emails.\n\nIf this policy is not configured, the user can choose whether or not to index emails." -+Blacklist_Gmail="Prevent indexing of Gmail" -+Explain_Blacklist_Gmail="Enabling this policy prevents Google Desktop from indexing Gmail messages.\n\nThis policy is in effect only when the policy "Prevent indexing of email" is disabled. When that policy is enabled, all email indexing is disabled, including Gmail indexing.\n\nIf both this policy and "Prevent indexing of email" are disabled or not configured, a user can choose whether or not to index Gmail messages." -+Blacklist_WebHistory="Prevent indexing of web pages" -+Explain_Blacklist_WebHistory="Enabling this policy will prevent Google Desktop from indexing web pages.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index web pages." -+Blacklist_Text="Prevent indexing of text files" -+Explain_Blacklist_Text="Enabling this policy will prevent Google Desktop from indexing text files.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index text files." -+Blacklist_Media="Prevent indexing of media files" -+Explain_Blacklist_Media="Enabling this policy will prevent Google Desktop from indexing media files.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index media files." -+Blacklist_Contact="Prevent indexing of contacts" -+Explain_Blacklist_Contact="Enabling this policy will prevent Google Desktop from indexing contacts.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index contacts." -+Blacklist_Calendar="Prevent indexing of calendar entries" -+Explain_Blacklist_Calendar="Enabling this policy will prevent Google Desktop from indexing calendar entries.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index calendar entries." -+Blacklist_Task="Prevent indexing of tasks" -+Explain_Blacklist_Task="Enabling this policy will prevent Google Desktop from indexing tasks.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index tasks." -+Blacklist_Note="Prevent indexing of notes" -+Explain_Blacklist_Note="Enabling this policy will prevent Google Desktop from indexing notes.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index notes." -+Blacklist_Journal="Prevent indexing of journal entries" -+Explain_Blacklist_Journal="Enabling this policy will prevent Google Desktop from indexing journal entries.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index journal entries." -+Blacklist_Word="Prevent indexing of Word documents" -+Explain_Blacklist_Word="Enabling this policy will prevent Google Desktop from indexing Word documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index Word documents." -+Blacklist_Excel="Prevent indexing of Excel documents" -+Explain_Blacklist_Excel="Enabling this policy will prevent Google Desktop from indexing Excel documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index Excel documents." -+Blacklist_Powerpoint="Prevent indexing of PowerPoint documents" -+Explain_Blacklist_Powerpoint="Enabling this policy will prevent Google Desktop from indexing PowerPoint documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index PowerPoint documents." -+Blacklist_PDF="Prevent indexing of PDF documents" -+Explain_Blacklist_PDF="Enabling this policy will prevent Google Desktop from indexing PDF documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index PDF documents." -+Blacklist_ZIP="Prevent indexing of ZIP files" -+Explain_Blacklist_ZIP="Enabling this policy will prevent Google Desktop from indexing ZIP files.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index ZIP files." -+Blacklist_HTTPS="Prevent indexing of secure web pages" -+Explain_Blacklist_HTTPS="Enabling this policy will prevent Google Desktop from indexing secure web pages (pages with HTTPS in the URL).\n\nIf this policy is disabled or not configured, the user can choose whether or not to index secure web pages." -+Blacklist_URI_Contains="Prevent indexing of specific web sites and folders" -+Explain_Blacklist_URI_Contains="This policy allows you to prevent Google Desktop from indexing specific websites or folders. If an item's URL or path name contains any of these specified strings, it will not be indexed. These restrictions will be applied in addition to any websites or folders that the user has specified.\n\nThis policy has no effect when disabled or not configured." -+Blacklist_Chat="Prevent indexing of IM chats" -+Explain_Blacklist_Chat="Enabling this policy will prevent Google Desktop from indexing IM chat conversations.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index IM chat conversations." -+Blacklist_PasswordProtectedOffice="Prevent indexing of password-protected Office documents (Word, Excel)" -+Explain_Blacklist_PasswordProtectedOffice="Enabling this policy will prevent Google Desktop from indexing password-protected office documents.\n\nIf this policy is disabled or not configured, the user can choose whether or not to index password-protected office documents." -+Blacklist_Extensions="Prevent indexing of specific file extensions" -+Explain_Blacklist_Extensions="This policy allows you to prevent Google Desktop from indexing files with specific extensions. Enter a list of file extensions, separated by commas, that you wish to exclude from indexing.\n\nThis policy has no effect when disabled or not configured." -+Pol_Disallow_UserSearchLocations="Disallow adding search locations for indexing" -+Explain_Disallow_UserSearchLocations="Enabling this policy will prevent the user from specifying additional drives or networked folders to be indexed by Google Desktop.\n\nIf this policy is disabled or not configured, users may specify additional drives and networked folders to be indexed." -+Pol_Search_Location_Whitelist="Allow indexing of specific folders" -+Explain_Search_Location_Whitelist="This policy allows you to add additional drives and networked folders to index." -+Search_Locations_Whitelist="Search these locations" -+Email_Retention="Only retain emails that are less than x days old" -+Explain_Email_Retention="This policy allows you to configure Google Desktop to only retain emails that are less than the specified number of days old in the index. Enter the number of days to retain emails for\n\nThis policy has no effect when disabled or not configured." -+Email_Retention_Edit="Number of days to retain emails" -+Webpage_Retention="Only retain webpages that are less than x days old" -+Explain_Webpage_Retention="This policy allows you to configure Google Desktop to only retain webpages that are less than the specified number of days old in the index. Enter the number of days to retain webpages for\n\nThis policy has no effect when disabled or not configured." -+Webpage_Retention_Edit="Number of days to retain webpages" -+File_Retention="Only retain files that are less than x days old" -+Explain_File_Retention="This policy allows you to configure Google Desktop to only retain files that are less than the specified number of days old in the index. Enter the number of days to retain files for\n\nThis policy has no effect when disabled or not configured." -+File_Retention_Edit="Number of days to retain files" -+IM_Retention="Only retain IM that are less than x days old" -+Explain_IM_Retention="This policy allows you to configure Google Desktop to only retain IM that are less than the specified number of days old in the index. Enter the number of days to retain IM for\n\nThis policy has no effect when disabled or not configured." -+IM_Retention_Edit="Number of days to retain IM" -+ -+Pol_Remove_Deleted_Items="Remove deleted items from the index." -+Explain_Remove_Deleted_Items="Enabling this policy will remove all deleted items from the index and cache. Any items that are deleted will no longer be searchable." -+ -+Pol_Allow_Simultaneous_Indexing="Allow historical indexing for multiple users simultaneously." -+Explain_Allow_Simultaneous_Indexing="Enabling this policy will allow a computer to generate first-time indexes for multiple users simultaneously. \n\nIf this policy is disabled or not configured, historical indexing will happen only for the logged-in user that was connected last; historical indexing for any other logged-in user will happen the next time that other user connects." -+ -+Pol_TurnOffAdvancedFeatures="Turn off Advanced Features options" -+Explain_TurnOffAdvancedFeatures="Enabling this policy will prevent Google Desktop from sending Advanced Features data to Google (for either improvements or personalization), and users won't be able to change these options. Enabling this policy also prevents older versions of Google Desktop from sending data.\n\nIf this policy is disabled or not configured and the user has a pre-5.5 version of Google Desktop, the user can choose whether or not to enable sending data to Google. If the user has version 5.5 or later, the 'Turn off Improve Google Desktop option' and 'Do not send personalization info' policies will be used instead." -+ -+Pol_TurnOffImproveGd="Turn off Improve Google Desktop option" -+Explain_TurnOffImproveGd="Enabling this policy will prevent Google Desktop from sending improvement data, including crash reports and anonymous usage data, to Google.\n\nIf this policy is disabled, improvement data will be sent to Google and the user won't be able to change the option.\n\nIf this policy is not configured, the user can choose whether or not to enable the Improve Google Desktop option.\n\nNote that this policy applies only to version 5.5 or later and doesn't affect previous versions of Google Desktop.\n\nAlso note that this policy can be overridden by the 'Turn off Advanced Features options' policy." -+ -+Pol_NoPersonalizationInfo="Do not send personalization info" -+Explain_NoPersonalizationInfo="Enabling this policy will prevent Google Desktop from displaying personalized content, such as news that reflects the user's past interest in articles. Personalized content is derived from anonymous usage data sent to Google.\n\nIf this policy is disabled, personalized content will be displayed for all users, and users won't be able to disable this feature.\n\nIf this policy is not configured, users can choose whether or not to enable personalization in each gadget that supports this feature.\n\nNote that this policy applies only to version 5.5 or later and doesn't affect previous versions of Google Desktop.\n\nAlso note that this policy can be overridden by the 'Turn off Advanced Features options' policy." -+ -+Pol_OneBoxMode="Turn off Google Web Search Integration" -+Explain_OneBoxMode="Enabling this policy will prevent Google Desktop from displaying Desktop Search results in queries to google.com.\n\nIf this policy is disabled or not configured, the user can choose whether or not to include Desktop Search results in queries to google.com." -+ -+Pol_EncryptIndex="Encrypt index data" -+Explain_EncryptIndex="Enabling this policy will cause Google Desktop to turn on Windows file encryption for the folder containing the Google Desktop index and related user data the next time it is run.\n\nNote that Windows EFS is only available on NTFS volumes. If the user's data is stored on a FAT volume, this policy will have no effect.\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_Hyper="Turn off Quick Find" -+Explain_Hyper="Enabling this policy will cause Google Desktop to turn off Quick Find feature. Quick Find allows you to see results as you type.\n\nIf this policy is disabled or not configured, the user can choose whether or not to enable it." -+ -+Pol_Display_Mode="Choose display option" -+Explain_Display_Mode="This policy sets the Google Desktop display option: Sidebar, Deskbar, Floating Deskbar or none.\n\nNote that on 64-bit systems, a setting of Deskbar will be interpreted as Floating Deskbar.\n\nIf this policy is disabled or not configured, the user can choose a display option." -+Sidebar="Sidebar" -+Deskbar="Deskbar" -+FloatingDeskbar="Floating Deskbar" -+None="None" -+ -+;------------------------------------------------------------------------------ -+; Enterprise -+;------------------------------------------------------------------------------ -+Cat_Enterprise="Enterprise Integration" -+Explain_Enterprise="Controls features specific to Enterprise installations of Google Desktop" -+ -+Pol_Autoupdate="Block Auto-update" -+Explain_Autoupdate="Enabling this policy prevents Google Desktop from automatically checking for and installing updates from google.com.\n\nIf you enable this policy, you must distribute updates to Google Desktop using Group Policy, SMS, or a similar enterprise software distribution mechanism. You should check http://desktop.google.com/enterprise/ for updates.\n\nIf this policy is disabled or not configured, Google Desktop will periodically check for updates from desktop.google.com." -+ -+Pol_AutoupdateAsSystem="Use system proxy settings when auto-updating" -+Explain_AutoupdateAsSystem="Enabling this policy makes Google Desktop use the machine-wide proxy settings (as specified using e.g. proxycfg.exe) when performing autoupdates (if enabled).\n\nIf this policy is disabled or not configured, Google Desktop will use the logged-on user's Internet Explorer proxy settings when checking for auto-updates (if enabled)." -+ -+Pol_EnterpriseTab="Enterprise search tab" -+Explain_EnterpriseTab="This policy allows you to add a search tab for your Google Search Appliance to Google Desktop and google.com web pages.\n\nYou must provide the name of the tab, such as "Intranet", as well as URLs for the search homepage and for retrieving search results. Use [DISP_QUERY] in place of the query term for the search results URL.\n\nSee the administrator's guide for more details." -+EnterpriseTabText="Tab name" -+EnterpriseTabHomepage="Search homepage URL" -+EnterpriseTabHomepageQuery="Check if search homepage supports '&&q='" -+EnterpriseTabResults="Search results URL" -+EnterpriseTabResultsQuery="Check if search results page supports '&&q='" -+ -+Pol_GSAHosts="Google Search Appliances" -+Explain_GSAHosts="This policy allows you to list any Google Search Appliances in your intranet. When properly configured, Google Desktop will insert Google Desktop results into the results of queries on the Google Search Appliance" -+ -+Pol_PolicyUnawareClientProhibitedFlag="Prohibit Policy-Unaware versions" -+Explain_PolicyUnawareClientProhibitedFlag="Prohibits installation and execution of versions of Google Desktop that are unaware of group policy.\n\nEnabling this policy will prevent users from installing or running version 1.0 of Google Desktop.\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_MinimumAllowedVersion="Minimum allowed version" -+Explain_MinimumAllowedVersion="This policy allows you to prevent installation and/or execution of older versions of Google Desktop by specifying the minimum version you wish to allow. When enabling this policy, you should also enable the "Prohibit Policy-Unaware versions" policy to block versions of Google Desktop that did not support group policy.\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_MaximumAllowedVersion="Maximum allowed version" -+Explain_MaximumAllowedVersion="This policy allows you to prevent installation and/or execution of newer versions of Google Desktop by specifying the maximum version you wish to allow.\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_Disallow_Gadgets="Disallow gadgets and indexing plug-ins" -+Explain_Disallow_Gadgets="This policy prevents the use of all Google Desktop gadgets and indexing plug-ins. The policy applies to gadgets that are included in the Google Desktop installation package (built-in gadgets), built-in indexing plug-ins (currently only the Lotus Notes plug-in), and to gadgets or indexing plug-ins that a user might want to add later (non-built-in gadgets and indexing plug-ins).\n\nYou can prohibit use of all non-built-in gadgets and indexing plug-ins, but allow use of built-in gadgets and indexing plug-ins. To do so, enable this policy and then select the option "Disallow only non-built-in gadgets and indexing plug-ins.\n\nYou can supersede this policy to allow specified built-in and non-built-in gadgets and indexing plug-ins. To do so, enable this policy and then specify the gadgets and/or indexing plug-ins you want to allow under "Gadget and Plug-in Whitelist."" -+Disallow_Only_Non_Builtin_Gadgets="Disallow only non-built-in gadgets and indexing plug-ins" -+ -+Pol_Gadget_Whitelist="Gadget and plug-in whitelist" -+Explain_Gadget_Whitelist="This policy specifies a list of Google Desktop gadgets and indexing plug-ins that you want to allow, as exceptions to the "Disallow gadgets and indexing plug-ins" policy. This policy is valid only when the "Disallow gadgets and indexing plug-ins" policy is enabled.\n\nFor each gadget or indexing plug-in you wish to allow, add the CLSID or PROGID of the gadget or indexing plug-in (see the administrator's guide for more details).\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_Gadget_Install_Confirmation_Whitelist="Allow silent installation of gadgets" -+Explain_Gadget_Install_Confirmation_Whitelist="Enabling this policy lets you specify a list of Google Desktop gadgets or indexing plug-ins that can be installed without confirmation from the user.\n\nAdd a gadget or indexing plug-in by placing its class ID (CLSID) or program identifier (PROGID) in the list, surrounded with curly braces ({ }).\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_Alternate_User_Data_Dir="Alternate user data directory" -+Explain_Alternate_User_Data_Dir="This policy allows you to specify a directory to be used to store user data for Google Desktop (such as index data and cached documents).\n\nYou may use [USER_NAME] or [DOMAIN_NAME] in the path to specify the current user's name or domain. If [USER_NAME] is not specified, the user name will be appended at the end of the path.\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_MaxAllowedOutlookConnections="Maximum allowed Outlook connections" -+Explain_MaxAllowedOutlookConnections="This policy specifies the maximum number of open connections that Google Desktop maintains with the Exchange server. Google Desktop opens a connection for each email folder that it indexes. If insufficient connections are allowed, Google Desktop cannot index all the user email folders.\n\nThe default value is 400. Because users rarely have as many as 400 email folders, Google Desktop rarely reaches the limit.\n\nIf you set this policy's value above 400, you must also configure the number of open connections between Outlook and the Exchange server. By default, approximately 400 connections are allowed. If Google Desktop uses too many of these connections, Outlook might be unable to access email.\n\nThis policy has no effect when disabled or not configured." -+ -+Pol_DisallowSsdService="Disallow sharing and receiving of web history and documents across computers" -+Explain_DisallowSsdService="Enabling this policy will prevent Google Desktop from sharing the user's web history and document contents across the user's different Google Desktop installations, and will also prevent it from receiving such shared items from the user's other machines. To allow reception but disallow sharing, use DisallowSsdOutbound.\nThis policy has no effect when disabled or not configured." -+ -+Pol_DisallowSsdOutbound="Disallow sharing of web history and documents to user's other computers." -+Explain_DisallowSsdOutbound="Enabling this policy will prevent Google Desktop from sending the user's web history and document contents from this machine to the user's other machines. It does not prevent reception of items from the user's other machines; to disallow both, use DisallowSsdService.\nThis policy has no effect when disabled or not configured." -+ -+Pol_Disallow_Store_Gadget_Service="Disallow storage of gadget content and settings." -+Explain_Disallow_Store_Gadget_Service="Enabling this policy will prevent users from storing their gadget content and settings with Google. Users will be unable to access their gadget content and settings from other computers and all content and settings will be lost if Google Desktop is uninstalled." -+ -+Pol_MaxExchangeIndexingRate="Maximum allowed Exchange indexing rate" -+Explain_MaxExchangeIndexingRate="This policy allows you to specify the maximum number of emails that are indexed per minute. \n\nThis policy has no effect when disabled or not configured." -+ -+Pol_EnableSafeweb="Enable or disable safe browsing" -+Explain_Safeweb="Google Desktop safe browsing informs the user whenever they visit any site which is a suspected forgery site or may harm their computer. Enabling this policy turns on safe browsing; disabling the policy turns it off. \n\nIf this policy is not configured, the user can select whether to turn on safe browsing." -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/README.txt b/tools/grit/grit/testdata/README.txt -new file mode 100644 -index 0000000000..a683b3b9e3 ---- /dev/null -+++ b/tools/grit/grit/testdata/README.txt -@@ -0,0 +1,87 @@ -+Google Desktop for Enterprise -+Copyright (C) 2007 Google Inc. -+All Rights Reserved -+ -+--------- -+Contents -+--------- -+This distribution contains the following files: -+ -+GoogleDesktopSetup.msi - Installation and setup program -+GoogleDesktop.adm - Group Policy administrative template file -+AdminGuide.pdf - Google Desktop for Enterprise administrative guide -+ -+ -+-------------- -+Documentation -+-------------- -+Full documentation and installation instructions are in the -+administrative guide, and also online at -+http://desktop.google.com/enterprise/adminguide.html. -+ -+ -+------------------------ -+IBM Lotus Notes Plug-In -+------------------------ -+The Lotus Notes plug-in is included in the release of Google -+Desktop for Enterprise. The IBM Lotus Notes Plug-in for Google -+Desktop indexes mail, calendar, task, contact and journal -+documents from Notes. Discussion documents including those from -+the discussion and team room templates can also be indexed by -+selecting an option from the preferences. Once indexed, this data -+will be returned in Google Desktop searches. The corresponding -+document can be opened in Lotus Notes from the Google Desktop -+results page. -+ -+Install: The plug-in will install automatically during the Google -+Desktop setup process if Lotus Notes is already installed. Lotus -+Notes must not be running in order for the install to occur. The -+Class ID for this plug-in is {8F42BDFB-33E8-427B-AFDC-A04E046D3F07}. -+ -+Preferences: Preferences and selection of databases to index are -+set in the 'Google Desktop for Notes' dialog reached through the -+'Actions' menu. -+ -+Reindexing: Selecting 'Reindex all databases' will index all the -+documents in each database again. -+ -+ -+Notes Plug-in Known Issues -+--------------------------- -+ -+If the 'Google Desktop for Notes' item is not available from the -+Lotus Notes Actions menu, then installation was not successful. -+Installation consists of writing one file, notesgdsplugin.dll, to -+the Notes application directory and a setting to the notes.ini -+configuration file. The most likely cause of an unsuccessful -+installation is that the installer was not able to locate the -+notes.ini file. Installation will complete if the user closes Notes -+and manually adds the following setting to this file on a new line: -+AddinMenus=notesgdsplugin.dll -+ -+If the notesgdsplugin.dll file is not in the application directory -+(e.g., C:\Program Files\Lotus\Notes) after Google Desktop -+installation, it is likely that Notes was not installed correctly. -+ -+Only local databases can be indexed. If they can be determined, -+the user's local mail file and address book will be included in the -+list automatically. Mail archives and other databases must be -+added with the 'Add' button. -+ -+Some users may experience performance issues during the initial -+indexing of a database. The 'Perform the initial index of a -+database only when I'm idle' option will limit the indexing process -+to times when the user is not using the machine. If this does not -+alleviate the problem or the user would like to continually index -+but just do so more slowly or quickly, the GoogleWaitTime notes.ini -+value can be set. Increasing the GoogleWaitTime value will slow -+down the indexing process, and lowering the value will speed it up. -+A value of zero causes the fastest possible indexing. Removing the -+ini parameter altogether returns it to the default (20). -+ -+Crashes have been known to occur with certain types of history -+bookmarks. If the Notes client seems to crash randomly, try -+disabling the 'Index note history' option. If it crashes before, -+you can get to the preferences, add the following line to your -+notes.ini file: -+GDSNoIndexHistory=1 -diff --git a/tools/grit/grit/testdata/about.html b/tools/grit/grit/testdata/about.html -new file mode 100644 -index 0000000000..8e5fad7b2b ---- /dev/null -+++ b/tools/grit/grit/testdata/about.html -@@ -0,0 +1,45 @@ -+[HEADER] -+
    -+
     [TITLE]
    -+
    Google Desktop Search: Search your own computer.

    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
      Outlook Email   Netscape Mail / Thunderbird
      Outlook Express   Netscape / Firefox / Mozilla
      Word   PDF
      Excel   Music
      PowerPoint   Images
      Internet Explorer   Video
      AOL Instant Messenger   Even more with these plug-ins
      Text and others
    -+
    -+

    -+ -+ -+ -+ -+ -+
    Getting Started - Learn more about using Google Desktop Search
    Online Help - Up-to-date answers to your questions
    Privacy - A few words about privacy and Google Desktop Search
    Uninstall - How to uninstall Google Desktop Search
    Submit Feedback - Send us your comments and ideas

    Google Desktop Search [$~BUILDNUMBER~$]

    -+[FOOTER] -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/android.xml b/tools/grit/grit/testdata/android.xml -new file mode 100644 -index 0000000000..cc3b141f70 ---- /dev/null -+++ b/tools/grit/grit/testdata/android.xml -@@ -0,0 +1,24 @@ -+ -+ -+ -+ -+ -+ Open %s? -+ -+ -+ -+ A simple string. -+ -+ -+ Contains a comment. -+ -+ -+ Another simple string. -+ -+ -+ Do not translate me. -+ -diff --git a/tools/grit/grit/testdata/bad_browser.html b/tools/grit/grit/testdata/bad_browser.html -new file mode 100644 -index 0000000000..e8cf34664d ---- /dev/null -+++ b/tools/grit/grit/testdata/bad_browser.html -@@ -0,0 +1,16 @@ -+

    We're sorry, but we don't seem to be compatible.

    -+

    Our software suggests that you're using a browser incompatible with Google Desktop Search. -+ Google Desktop Search currently supports the following:

    -+ -+ -+

    You may click here to use your -+ unsupported browser, though you likely will encounter some areas that don't -+ work as expected. You need to have Javascript enabled, regardless of the -+ browser you use. -+

    We hope to expand this list in the near future and announce new -+ browsers as they become available. -diff --git a/tools/grit/grit/testdata/browser.html b/tools/grit/grit/testdata/browser.html -new file mode 100644 -index 0000000000..45d364d56f ---- /dev/null -+++ b/tools/grit/grit/testdata/browser.html -@@ -0,0 +1,42 @@ -+ -+[$~TITLE~$] -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    [$~IMAGE~$] -+   -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+
     [$~CHROME_TITLE~$]
    -+
    -+ -+ -+ -+ -+ -+
    -+ [$~BODY~$] -+
    -+[$~FOOTER~$] -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/buildinfo.grd b/tools/grit/grit/testdata/buildinfo.grd -new file mode 100644 -index 0000000000..80458a8265 ---- /dev/null -+++ b/tools/grit/grit/testdata/buildinfo.grd -@@ -0,0 +1,46 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Copyright 2008 Google Inc. All Rights Reserved. -+ -+ -+ Google Desktop News gadget -+[IDS_COPYRIGHT_GOOGLE_LONG] -+View news that is personalized based on the articles you read. -+ -+For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/cache_prefix.html b/tools/grit/grit/testdata/cache_prefix.html -new file mode 100644 -index 0000000000..b1f91dd82b ---- /dev/null -+++ b/tools/grit/grit/testdata/cache_prefix.html -@@ -0,0 +1,24 @@ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+
    This is one version of -+[URL-DISP] from your personal cache.
    -+The page may have changed since that time. Click here for the current page.
    -+Since this page is stored on your computer, publicly linking to this page will not work.[$~EXTRA~$]

    -+Google may not be affiliated with the authors of this page nor responsible for its content. This page may be protected by copyright. -+
    -+ -+ -+


    -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/cache_prefix_file.html b/tools/grit/grit/testdata/cache_prefix_file.html -new file mode 100644 -index 0000000000..f3eb8e0f11 ---- /dev/null -+++ b/tools/grit/grit/testdata/cache_prefix_file.html -@@ -0,0 +1,25 @@ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+
    This is one version of [URL-DISP] -+from your personal cache.
    -+The file may have changed since that time. Click here for the current file.
    -+Since this file is stored on your computer, publicly linking to it will not work.[$~EXTRA~$]

    -+Google may not be affiliated with the authors of this page nor responsible for its content. This page may be protected by copyright. -+
    -+
    -+ -+ -+
    -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/chat_result.html b/tools/grit/grit/testdata/chat_result.html -new file mode 100644 -index 0000000000..318078bc3d ---- /dev/null -+++ b/tools/grit/grit/testdata/chat_result.html -@@ -0,0 +1,24 @@ -+[HEADER] -+[CHROME] -+ -+ -+
    [$~STARTCHAT~$]
    -+
    -+
    -+   [$~TITLE~$] -+

    Participants: [USERNAME], [BUDDYNAME]
    -+Date: [TIME]
    -+
    -+ -+
    -+ -+ -+
    [$~STARTCHAT~$]
    -+ -+ -+[FOOTER] -diff --git a/tools/grit/grit/testdata/chrome/app/generated_resources.grd b/tools/grit/grit/testdata/chrome/app/generated_resources.grd -new file mode 100644 -index 0000000000..c2efb77fd8 ---- /dev/null -+++ b/tools/grit/grit/testdata/chrome/app/generated_resources.grd -@@ -0,0 +1,199 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ New background app installed -+ -+ -+ $1Background App will launch at system startup and continue to run in the background even once you've closed all other $2Google Chrome windows. -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/chrome_html.html b/tools/grit/grit/testdata/chrome_html.html -new file mode 100644 -index 0000000000..7f7633c5cf ---- /dev/null -+++ b/tools/grit/grit/testdata/chrome_html.html -@@ -0,0 +1,6 @@ -+ -+ -diff --git a/tools/grit/grit/testdata/default_100_percent/a.png b/tools/grit/grit/testdata/default_100_percent/a.png -new file mode 100644 -index 0000000000000000000000000000000000000000..5d5089038ca71172e95db9e7aae1e1fa5cebd505 -GIT binary patch -literal 159 -zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>0wld=oSO}#(mY)pLnNjq|2Y3)zGGzYPN&L+ -zMSC}CcCfp=Dtxv4%6W%G#Q=|R|L;6pCCLUWO)Z<5eoL%TkDTw=s4X!^d(Qa<2khAN -zZPy!XToBAic1Ss}vcWiD27B3&`Zj^H6CO>7R1{ToQ;=ggdEYbV=IISvfHpFCy85}S -Ib4q9e0O9jEh5!Hn - -literal 0 -HcmV?d00001 - -diff --git a/tools/grit/grit/testdata/default_100_percent/b.png b/tools/grit/grit/testdata/default_100_percent/b.png -new file mode 100644 -index 0000000000..6178079822 ---- /dev/null -+++ b/tools/grit/grit/testdata/default_100_percent/b.png -@@ -0,0 +1 @@ -+b -diff --git a/tools/grit/grit/testdata/del_footer.html b/tools/grit/grit/testdata/del_footer.html -new file mode 100644 -index 0000000000..4e19950bfc ---- /dev/null -+++ b/tools/grit/grit/testdata/del_footer.html -@@ -0,0 +1,8 @@ -+ -+ -+ -+
     Remove checked results and return to search.Check all - Uncheck all   -+ -+
    -+

    [$~BOTTOMLINE~$] - ©2005 Google
    -+ -diff --git a/tools/grit/grit/testdata/del_header.html b/tools/grit/grit/testdata/del_header.html -new file mode 100644 -index 0000000000..72bc6756eb ---- /dev/null -+++ b/tools/grit/grit/testdata/del_header.html -@@ -0,0 +1,60 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    Go to Google Desktop Search  -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+ -+
     Remove Specific ItemsHelp  
    -+
    -+ -+ -+ -+ -+ -+ -+
     Remove checked results and return to search.Check all - -+Uncheck all  
    -+
    -+ -+ -+ -+ -+
     Remove -+checked items from Google Desktop Search. Other copies of the same items will not be -+affected.
    -+ If you view the item again, it will be added back to Google Desktop Search.
    -+
    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/deleted.html b/tools/grit/grit/testdata/deleted.html -new file mode 100644 -index 0000000000..5ae5f355fa ---- /dev/null -+++ b/tools/grit/grit/testdata/deleted.html -@@ -0,0 +1,21 @@ -+ -+Database Deleted -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+
    Google Desktop Search -+

    -+
    The database has been deleted. Click here to continue.
    -+ -+ -+
    [$~BOTTOMLINE~$]

    -+

    ©2005 Google

    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/depfile.grd b/tools/grit/grit/testdata/depfile.grd -new file mode 100644 -index 0000000000..e2f7191218 ---- /dev/null -+++ b/tools/grit/grit/testdata/depfile.grd -@@ -0,0 +1,18 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/details.html b/tools/grit/grit/testdata/details.html -new file mode 100644 -index 0000000000..0ab0e2a90c ---- /dev/null -+++ b/tools/grit/grit/testdata/details.html -@@ -0,0 +1,10 @@ -+[!] -+title Improve Google Desktop Search by Sending Non-Personal Information -+template -+bottomline -+hp_image -+ -+

    This documentation is not yet available

    -+

    -+[$~BOTTOMLINE~$] - ©2005 Google -+
    -diff --git a/tools/grit/grit/testdata/duplicate-name-input.xml b/tools/grit/grit/testdata/duplicate-name-input.xml -new file mode 100644 -index 0000000000..cc4d1d65c5 ---- /dev/null -+++ b/tools/grit/grit/testdata/duplicate-name-input.xml -@@ -0,0 +1,26 @@ -+ -+ -+ -+ -+ -+ Hello %sJoi, how are you doing today? -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/email_result.html b/tools/grit/grit/testdata/email_result.html -new file mode 100644 -index 0000000000..8bb04b988c ---- /dev/null -+++ b/tools/grit/grit/testdata/email_result.html -@@ -0,0 +1,34 @@ -+[HEADER] -+[CHROME] -+ -+ -+
    [CONV] -+Reply | Reply to All[$~FORWARD_URL~$] | Compose[$~OUTLOOKVIEW~$] -+
    -+
    -+
    -+   [SUBJECT] -+

    [FROM-DISP] -+[TO-DISP] -+[CC-DISP] -+[BCC-DISP] -+[REPLYTO-DISP] -+[DATE-DISP] -+[VIEW-DISP] -+[$~ATTACH~$] -+

    -+

    -+ -+
    -+ -+
    [CONV] -+Reply | Reply to All[$~FORWARD_URL~$] | Compose[$~OUTLOOKVIEW~$] -+
    -+ -+ -+[FOOTER] -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/email_thread.html b/tools/grit/grit/testdata/email_thread.html -new file mode 100644 -index 0000000000..3c7279b841 ---- /dev/null -+++ b/tools/grit/grit/testdata/email_thread.html -@@ -0,0 +1,10 @@ -+[HEADER] -+[CHROME] -+
    -+   [SUBJECT]

    -+ -+[CONTENTS] -+
    -+
    -+[NEXT_PREV] -+[FOOTER] -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/error.html b/tools/grit/grit/testdata/error.html -new file mode 100644 -index 0000000000..66875a234c ---- /dev/null -+++ b/tools/grit/grit/testdata/error.html -@@ -0,0 +1,8 @@ -+[HEADER] -+[CHROME] -+
    -+
    -+[ERROR]

    -+If you think this is an error, please contact us. -+
    -+[FOOTER] -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/explicit_web.html b/tools/grit/grit/testdata/explicit_web.html -new file mode 100644 -index 0000000000..1424adc617 ---- /dev/null -+++ b/tools/grit/grit/testdata/explicit_web.html -@@ -0,0 +1,11 @@ -+[HEADER] -+ -+[WEB_TOP_CHROME] -+[$~STATUS~$] -+[$~MESSAGE~$] -+[WEB_FILES] -+
    [NEXT_PREV] -+[FOOTER] -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/footer.html b/tools/grit/grit/testdata/footer.html -new file mode 100644 -index 0000000000..3372d6afac ---- /dev/null -+++ b/tools/grit/grit/testdata/footer.html -@@ -0,0 +1,14 @@ -+


    -+
    -+ -+ -+

    -+ -+ -+ -+
    [$~BOTTOM~$]

    -+
    -+

    -+[$~BOTTOMLINE~$] - ©2005 Google
    -+[SCRIPT] -+ -diff --git a/tools/grit/grit/testdata/generated_resources_fr.xtb b/tools/grit/grit/testdata/generated_resources_fr.xtb -new file mode 100644 -index 0000000000..373c40feea ---- /dev/null -+++ b/tools/grit/grit/testdata/generated_resources_fr.xtb -@@ -0,0 +1,3079 @@ -+ -+ -+ -+Salut! -+Salut -+Supprime&r -+Activer la barre de favoris -+Déconnexion du réseau privé -+ sur  -+Déconnecter ce compte... -+&Vérifier l'orthographe dans ce champ -+Aucune donnée reçue. -+Une erreur s'est produite lors de la tentative de lecture du fichier : . -+Le mot de passe multiterme est obligatoire. -+Importer les données d'un autre navigateur... -+Saisie automatique -+API P2P -+Exécuter automatiquement (recommandé) -+Le certificat de sécurité du site a expiré ! -+Clé publique de l'objet -+Importer -+Afficher dan&s un onglet -+ID : -+Le certificat n'indique aucun mécanisme permettant de vérifier s'il a été révoqué. -+Touches de modification... -+Signé par : -+Utiliser un service Web pour résoudre les erreurs de navigation -+Guillemet -+Une nouvelle tentative de connexion avec SSL 3.0 a dû être effectuée. Cette opération indique généralement que le serveur utilise un logiciel très ancien et qu'il est susceptible de présenter d'autres problèmes de sécurité. -+Autoriser le stockage des données locales (recommandé) -+Ouvrir dans une fenêtre -+Google pense qu'un logiciel malveillant pourrait être installé sur votre ordinateur si vous continuez. Nous vous conseillons de ne pas continuer, même si vous avez déjà consulté ce site auparavant ou si vous avez confiance en celui-ci. Il se peut qu'il ait été piraté récemment. Réessayez demain ou utilisez un autre site. -+&Rechercher : -+Échec de génération de clé privée RSA aléatoire -+Certificat en attente -+Technologie réseau : -+Le certificat du serveur ne figure pas dans le DNS. -+Demander le mot de passe au retour de veille -+Désactiver la synchronisation -+Base de données indexée -+Ne pas enregistrer -+ synchronise vos données avec votre compte Google en toute sécurité. Synchronisez toutes vos données ou personnalisez les types de données synchronisées et les options de chiffrement. -+Le délai imparti à l'opération est dépassé. -+Nordique -+Créer des raccourcis vers des applications -+Pas encore chargé -+Confirmer le nouveau code PIN : -+L2TP/IPSec + Certificat utilisateur -+Préfecture -+Extraction de l'image de récupération... -+Terminé -+Il se peut que la page Web à l'adresse soit temporairement inaccessible ou qu'elle ait été déplacée de façon permanente à une autre adresse Web. -+Cache des scripts -+Barre d'outils Google -+Importés depuis Safari -+Le plug-in n'est pas autorisé. -+Vous exécutez à partir de son image disque. Si vous l'installez sur votre ordinateur, vous pourrez l'utiliser sans image disque et bénéficierez de mises à jour automatiques. -+Certificat du serveur SSL -+Z&oom arrière -+Indique si la suggestion du moteur de recherche doit être entrée immédiatement via la saisie semi-automatique lorsque la fonctionnalité Recherche instantanée est activée. -+Mise à jour du système : % téléchargés -+Les informations d'identification associées au partage de vos imprimantes via sont arrivées à expiration. Cliquez ici pour saisir à nouveau votre nom d'utilisateur et votre mot de passe. -+Erreur de définition du paramètre de confiance du certificat -+ peut maintenant synchroniser vos mots de passe. -+Sélectionnez le certificat à présenter pour l'identification : -+ a planté. Cliquez sur cette info-bulle pour actualiser l'extension. -+Compatibilité expérimentale avec des méthodes Wi-Fi Extensible Authentication Protocol supplémentaires, telles que EAP-TLS et LEAP. -+Échec de lecture de la clé privée -+Les plug-ins suivants ont été bloqués sur cette page : -+Configuration de la synchronisation -+Case d'option cochée -+Très petite -+URL de révocation de l'autorité de certification Netscape -+Style de pavé numérique -+Active les feuilles de style CSS 3D et la composition graphique haute performance des pages Web via le processeur graphique. -+&Rétablir -+Redémarrer -+La connexion n'est pas compressée. -+Fin -+&Nouvelle fenêtre -+Configuration automatique du proxy -+Afficher l'orthographe et la grammaire -+Aucune imprimante n'a été trouvée. Veuillez en installer une. -+Saisissez les caractères visibles dans l'image ci-dessous. -+Certificat d'authentification de client SSL incorrect -+Le certificat du serveur ou un certificat AC intermédiaire présenté au navigateur a été signé avec un algorithme de signature faible tel que RSA-MD2. D'après des études récentes menées par des informaticiens, les algorithmes de signature seraient plus faibles qu'on ne le pensait jusqu'alors. Aujourd'hui, ils sont très rarement utilisés par les sites Web jugés dignes de confiance. Ce certificat a peut-être été contrefait. Nous vous déconseillons vivement de continuer. -+Rechercher le précédent -+I&nspecter l'élément -+État d'itinérance : -+&Non -+Effacer les données de navigation... -+Nombre maximal de suggestions -+L'accessibilité est désactivée. -+Sélectionner par domaine -+Tout réduire... -+Ne jamais traduire les pages rédigées en -+Non confirmé -+Avant de vous connecter, démarrez une session en tant qu'invité afin d'activer le réseau . -+La gravure de l'image est terminée. -+Si vous supprimez le certificat d'une autorité de certification, votre navigateur ne fera plus confiance aux certificats émis par cette autorité de certification. -+Synchronisez toutes les données de cet ordinateur ou sélectionnez celles que vous souhaitez synchroniser. -+ hours ago -+Domaine : -+Aperçu -+Associe chaque fenêtre du navigateur à un profil et ajoute une option de sélection des profils en haut à droite. Chaque profil possède ses propres favoris, extensions, applications, etc. -+Ignorer le verrouillage des majuscules et saisir des minuscules par défaut -+Aucune parole détectée -+Changer de moteur de recherche par défaut -+Cliquer pour revenir en arrière, maintenir pour voir l'historique -+ secondes restantes -+Unicode -+Ouverture à la fin du téléchargement -+Les extensions, les applications et les thèmes peuvent endommager votre ordinateur. Voulez-vous vraiment continuer ? -+Schéma du pinyin double -+Déconnecter ce compte... -+&Fichier -+Microsoft Internet Explorer -+Aucune correspondance trouvée -+État de votre commentaire -+Mise à jour terminée. Veuillez redémarrer le système. -+Lorsque vous supprimez un certificat de serveur, vous rétablissez les contrôles de sécurité habituels du serveur et un certificat valide lui est demandé. -+Essayez d'ajouter -+ -+ aux programmes autorisés dans les paramètres de votre pare-feu ou de votre antivirus. S'il -+ est déjà autorisé, tentez de le supprimer de la liste et de l'ajouter à nouveau à -+ la liste des programmes autorisés. -+Réseaux sans fil -+Masquer -+Zoom arrière -+Méthode EAP : -+Développer -+Veuillez vous connecter -+de n'importe quand -+Désactiver la validation des formulaires interactifs HTML5 -+Le suivi de votre position géographique sur cette page a été bloqué pour les sites suivants : -+La gravure de l'image a été interrompue. -+&Afficher dans le dossier -+Continuer à bloquer JavaScript -+Enregistrer la page sous... -+Le serveur à l'adresse requiert un nom d'utilisateur et un mot de passe. -+Exceptions de géolocalisation -+13px -+Contenu : -+Le plug-in a été bloqué, car il n'est plus à jour. -+Taille ré&elle -+Échec de la connexion au serveur proxy. -+Vérification de pilote matériel Microsoft Windows -+Paysage -+Détecter automatiquement -+Page -+Nom d'utilisateur : -+Nous aider à améliorer en envoyant automatiquement les statistiques d'utilisation et les rapports d'erreur à Google -+Réseau -+Connexion en cours -+Ajouter tous les onglets aux favoris... -+Onglets ou fenêtres -+Sites récemment consultés -+Ouvrir dans une fenêtre de navigation privée -+Préférences de saisie automatique... -+Compteur d'images par seconde -+Mot de passe -+Afficher le compte -+ : -+Le suivi de votre position géographique a été bloqué pour cette page. -+Connexion à l'aide de votre compte Google -+Le mot de passe multiterme entré est incorrect. -+télécopie : # -+Le navigateur par défaut est actuellement . -+ secondes restantes -+Mot de passe précédent -+Code PIN incorrect -+Modifier l'adresse -+Zoom avant -+Micrologiciel -+Une erreur s'est produite lors de l'affichage de cette page Web. Pour continuer, actualisez cette page ou ouvrez-en une autre. -+Récupération de clé Microsoft -+recto verso -+Fichier ou répertoire introuvable -+Aucun forfait de données actif -+Tout sélectionner -+Le fichier manifeste est incorrect. -+Les pages suivantes ne répondent plus. Vous pouvez attendre qu'elles soient de nouveau accessibles ou les supprimer. -+ minutes restantes -+Le certificat du serveur n'est pas encore valide. -+Menu contenant des extensions masquées -+Enregistrer les infos -+Configuration de l'accès à distance à cet ordinateur. -+Point -+Ajouter un moteur de recherche -+Impossible d'atteindre le serveur. -+Importer mes favoris... -+Enregistrer le &cadre sous... -+Vous n'êtes pas autorisé à accéder à la page Web . Votre connexion peut être requise. -+Envoyer la capture d'écran du dernier onglet actif -+Erreur -+Utiliser le thème GTK+ -+Ouvrir une fenêtre du navigateur -+ a planté. Cliquez sur cette info-bulle pour redémarrer l'application. -+Définir comme navigateur par défaut -+Certificat de courrier électronique -+Clavier en superposition -+La connexion est compressée avec . -+Exporter mes favoris... -+Format : -+Ignorer -+Déplacer un mot -+Index de -+Mémoire -+Impossible d'utiliser cette langue pour corriger l'orthographe. -+Recherche -+Ajouter une autre carte de paiement... -+Envoyer la dernière capture d'écran enregistrée -+Ce fichier contient du code malveillant. Voulez-vous vraiment continuer ? -+Erreur de synchronisation... -+Clavier brésilien -+Utiliser TLS 1.0 -+&Signaler un problème... -+Créer des raccourci&s vers des applications... -+Le certificat "" a été émis par : -+ ne contrôlant pas la façon dont les extensions gèrent vos données personnelles, toutes les extensions sont désactivées dans les fenêtres de navigation privée. Vous pouvez les réactiver individuellement dans le gestionnaire des extensions. -+Logiciels malveillants -+Mise en page ou mise en forme de la page -+Acheter davantage... -+Traduire -+Tout -+Créé : -+Annuler l'importation -+Le mode indiqué est incorrect. -+ copié(s) sur -+L'accès à distance à cet ordinateur est activé pour . -+Options... -+Un problème est survenu lors de la création du support de récupération du système d'exploitation. Le périphérique de stockage utilisé est introuvable. -+Toujours &afficher la barre de favoris -+Erreur SSL -+Confirmer les préférences de synchronisation -+Utiliser les valeurs par défaut -+Code secret manquant -+L'accès à distance à cet ordinateur est désactivé. -+API des extensions expérimentales -+Inclure les informations système -+Date d'expiration -+Autorité de certification compromise -+À propos de la saisie automatique -+Activer la fonction "Taper pour cliquer" -+Accès à la page Web refusé -+&Gestionnaire de favoris -+Erreur serveur -+Cette carte SIM est désactivée et ne peut être utilisée. Veuillez demander à votre fournisseur de services de la remplacer. -+Outils -+Clavier néerlandais -+EAP-TTLS -+Choisissez une image à associer à votre compte. Celle-ci s'affichera sur l'écran de connexion. -+Configurer le blocage des fenêtres pop-up... -+des 4 dernières semaines -+Une situation inattendue s'est produite tandis que le serveur tentait de traiter la demande. -+Impossible d'afficher certaines parties de ce document PDF. Souhaitez-vous l'ouvrir dans Adobe Reader ? -+Proxy FTP -+Si vous utilisez la version PPAPI de Flash, exécutez-la dans chaque processus de moteur du rendu plutôt que dans un processus de plug-in dédié. -+Cela signifie que le certificat présenté à votre navigateur contient des erreurs et qu'il ne peut pas être compris. Il est possible que les informations sur l'identité du certificat ou que d'autres informations du certificat relatives à la sécurité de la connexion soient incompréhensibles. Ne poursuivez pas. -+Activer l'onglet 1 -+Communication à distance -+Importer les favoris et les paramètres... -+À propos -+Modifier le favori de cette page -+Ajouter un format d'exception -+Configurer l'accès à distance... -+Supprimer le certificat "" ? -+Cache des images -+Configuration du proxy -+En l'absence de connexion Wi-Fi, Google Chrome utilise les données 3G. -+Appuyez sur pour sélectionner le mode de saisie précédent. -+La création du support de récupération du système d'exploitation a été annulée. -+Le plug-in suivant est bloqué : -+Erreur de connexion réseau -+Mot de passe multiterme -+Internet -+Configurer les paramètres de blocage des plug-ins... -+Afficher dan&s un onglet -+Synchroniser vos mots de passe -+Le serveur proxy agit comme un intermédiaire entre votre ordinateur et les autres serveurs. Votre configuration système utilise actuellement un proxy, mais -+ -+ ne parvient pas à s'y connecter. -+Sélectionner par type d'application -+Procéder à l'i&nspection de l'élément -+Impossible de valider entièrement l'identité du serveur auquel vous êtes connecté. Le nom utilisé pour cette connexion n'est valide que sur votre réseau et aucune autorité de certification externe ne peut en vérifier la propriété. Certaines autorités de certification délivrent tout de même des certificats pour ces types de nom, par conséquent nous ne sommes pas en mesure de vérifier que vous êtes connecté au site voulu et non à un site malveillant. -+Impossible de déplacer le répertoire d'extensions dans le profil. -+Supprimer ces paramètres pour les prochaines visites -+L'accessibilité est activée. -+Appuyer sur la touche Espace pour sélectionner la suggestion -+Vos favoris -+ () -+Fermer les onglets -+Applications en arrière-plan -+Favoris -+Supprimer les données synchronisées de Google Dashboard -+Veuillez patienter pendant que installe les dernières mises à jour système. -+Utilisez les touches Maj gauche et droite pour sélectionner les 2e et 3e propositions -+WEP -+Mode Zhuyin complet. La sélection automatique de la suggestion et les options associées sont désactivées ou ignorées. -+&Paramètres linguistiques... -+CRX-less Web Apps -+Connexion au réseau -+Reliure bord long -+ utilise les paramètres proxy du système pour se connecter au réseau. -+Application : -+&Descendre -+? Toutes les données présentes sur le périphérique seront supprimées. -+Adresse IP -+Active le nouveau design de la page "Nouvel onglet" (en cours de développement). -+Échec de l'activation -+Ne pas vérifier -+Le chinois simplifié est le mode de saisie initial -+Paramètres SSL sur tout l'ordinateur : -+Votre connexion à n'est pas chiffrée. -+matériel requis -+Gérer les exceptions... -+Rechercher des mises à jour -+Utiliser un mot de passe multiterme pour chiffrer mes données de synchronisation -+Connexion en cours... -+Le serveur ne parvient pas à traiter la demande pour le moment. Ce code indique une situation temporaire. Le serveur sera de nouveau opérationnel ultérieurement. -+Historique -+Destination -+Web audio -+Cookies placés par cette page -+Accès partagé -+Afficher... -+Veuillez vous connecter à . -+Ajouter un nouvel e-mail -+Personnaliser les polices... -+Matériel : -+Erreur de connexion au réseau. -+Cette page Web est introuvable. -+En&registrer la vidéo sous... -+Le certificat du serveur n'est pas approuvé. -+Cop&ier l'image -+Sebeol-sik 390 -+ mins ago -+Autre réseau mobile... -+Erreur HTTP () : -+Signature du code -+Aide -+<sans nom> -+Version du micrologiciel : -+La page ne se charge pas -+Attention, ces fonctionnalités expérimentales peuvent mordre. -+Verrouiller l'écran ou éteindre -+La connexion est chiffrée au moyen de , avec pour l'authentification des messages et pour la méthode d'échange de clés. -+Clavier portugais -+Importation -+Connexion au réseau -+Langues -+Cette erreur peut se produire lors de la connexion à un serveur sécurisé (HTTPS). -+ Elle indique que le serveur tente d'établir une connexion sécurisée, mais -+ que celle-ci ne sera pas du tout sécurisée en raison d'une grave erreur de configuration. -+ Dans ce cas, une intervention -+ est requise sur le serveur. -+ -+ n'utilise pas de connexion non sécurisée pour protéger la confidentialité -+ de vos données. -+La synchronisation de vous permet de partager vos données (favoris, préférences) sur vos ordinateurs en toute simplicité. Pour ce faire, enregistre vos données en ligne via Google lorsque vous vous connectez à votre compte. -+Format ou mise en forme de la page -+Clavier suisse -+En&registrer l'image sous... -+Basculer en mode pleine chasse ou demi-chasse -+Sélectionner... -+Effacer les paramètres d'ouverture automatique -+Ajouter un réseau privé -+ secondes -+Ne pas envoyer de capture d'écran -+Hébreu -+Toujours afficher la barre de favoris -+Impossible de trouver le chemin d'accès absolu du répertoire à empaqueter. -+Créer un profil -+Diners Club -+Paramètres de contenu... -+Activer la recherche instantanée pour accélérer la recherche et la navigation ? -+Plus d'extensions >> -+La valeur d'entrée de la clé privée est obligatoire. -+PEAP -+Fonctionnalités de localisation expérimentales -+Ou&vrir la vidéo dans un nouvel onglet -+Toujours afficher la barre de favoris -+Reliure -+Utilisation de la clé du certificat -+Clavier belge -+ heures restantes -+Afficher toutes les images (recommandé) -+Cliquez sur -+ Démarrer, -+ puis sur -+ Exécuter. -+ Saisissez -+ et cliquez sur -+ OK. -+Nom de volume -+Reliure bord court -+ va configurer les mises à jour automatiques pour tous les utilisateurs de cet ordinateur. -+Effacer les éléments datant : -+Interdire à tous les sites d'afficher des notifications sur le Bureau -+Appuyez sur pour passer d'un mode de saisie à l'autre. -+Ajouter un nouveau fax -+Recherche de contenu en cours... -+Style d'entrée avec Espace -+Vous avez tenté d'accéder à , mais, au lieu de cela, vous communiquez actuellement avec un serveur identifié comme . Cela est peut-être dû à un défaut de configuration du serveur ou à quelque chose de plus grave. Un pirate informatique sur votre réseau cherche peut-être à vous faire visiter une version falsifiée de , donc potentiellement préjudiciable. Nous vous déconseillons vivement de continuer. -+Masquer le bouton -+Modifier l'image -+Ne pas synchroniser mes mots de passe -+JavaScript -+Activer les notifications de -+Afficher les incompatibilités -+Nouvel onglet -+Impossible de charger l'icône "" d'action de page. -+Fermer l'onglet -+Nom d'hôte du serveur : -+Ajouter une carte de paiement -+ : type de fichier inconnu -+Non défini -+Gérer les paramètres de saisie automatique... -+Respecter la &casse -+Autoriser tous les sites à exécuter JavaScript (recommandé) -+Gérer vos périphériques depuis le cloud -+Clavier catalan -+Me demander lorsqu'un site essaie de stocker des données -+Menu -+Sélectionnez le périphérique de stockage amovible à utiliser. -+La traduction a échoué, car nous n'avons pas pu déterminer la langue de la page. -+Vous pouvez créer des profils supplémentaires pour autoriser plusieurs personnes à utiliser et personnaliser Google Chrome. -+Deux-points -+Toujours traduire en -+(désactivée) -+Cela signifie que le certificat n'a pas été vérifié par un tiers reconnu par votre ordinateur. N'importe qui peut émettre un certificat en se faisant passer pour un autre site Web. Ce certificat doit donc être vérifié par un tiers approuvé. Sans cette vérification, les informations sur l'identité du certificat sont sans intérêt. Par conséquent, il nous est impossible de vérifier que vous communiquez bien avec et non avec un pirate informatique ayant émis son propre certificat en prétendant être . Nous vous déconseillons vivement de continuer. -+ requiert que vous cryptiez vos données à l'aide de votre mot de passe Google ou de votre propre mot de passe multiterme. -+ -+N'est pas une autorité de certification -+Date et heure : -+Impossible de charger "" pour le thème. -+Rechercher à nouveau -+En attente de ... -+Masquer ce plug-in -+Enregistrer &sous... -+Ajouter une langue : -+Annuler -+Ouvrir une &adresse... -+Supprimer le mot -+Vous devez saisir deux fois le même mot de passe multiterme. -+Ouvrir dans un onglet épinglé -+Page Web, tout type de contenu -+Activer -+Considérer ce certificat comme fiable pour identifier les développeurs de logiciels. -+Ajouter tous les onglets aux favoris -+Impossible de créer le dossier de favoris. -+Copier l'URL -+Si vous pensez ne pas avoir à utiliser de serveur proxy, procédez comme suit : -+ -+Définir les utilisateurs autorisés à se connecter à un périphérique et autoriser les sessions de navigation en tant qu'invité -+Sélectionnez le répertoire racine de l'extension à empaqueter. Pour mettre à jour une extension, sélectionnez également le fichier de clé privée à réutiliser. -+Pool restreint : -+&Rafraîchir cette page -+&Normal -+PKCS #1 SHA-384 avec chiffrement RSA -+Numéro de série : -+HTTPS/SSL -+Toutes les données de votre ordinateur et des sites Web que vous visitez -+Ceci est une installation secondaire de et ce dernier ne peut pas être défini comme navigateur par défaut. -+Erreur lors de la signature de l'extension -+ permet d'effectuer des recherches sur Internet à l'aide du champ polyvalent. Sélectionnez le moteur de recherche à utiliser : -+Sécurité : -+Adobe Reader n'est pas à jour -+Extensions ou applications -+Effacer les cookies et autres données de site et de plug-in lorsque je ferme le navigateur -+Téléchargement de l'image terminé. -+Favoris -+Afficher les vignettes -+Ne plus afficher ce message -+Agent de récupération de clé Microsoft -+Page de diagnostic de navigation sécurisée -+Adresse ligne 2 -+Décrivez-nous le problème recontré. (Champ obligatoire) -+Cela peut prendre quelques minutes. -+Options de base -+Niveau de zoom par défaut : -+Stockage externe -+Modifi&er les moteurs de recherche... -+Cartes de paiement -+Nom du fichier -+Arrêter la synchronisation -+Actualiser le cadre -+Connexion -+Mémoire privée -+Tout effacer -+Activer la correction orthographique automatique -+Afficher les &infos sur la page -+favoris_.html -+Autoriser uniquement les utilisateurs suivants à se connecter : -+&Muet -+Nouvel ongle&t -+Erreur de synchronisation -+Zoom -+ sur -+Type de clavier -+Délai d'expiration atteint au niveau de la passerelle ou du serveur proxy en attente d'une réponse d'un serveur en amont. -+Déplacer -+Mode de saisie du vietnamien (VIQR) -+Ajouter la page actuelle aux favoris -+<aucun cookie sélectionné> -+Le mot de passe de l'application est incorrect. -+Sélectionner "un mot à la fois" -+Tout bloquer -+Chargement en cours… -+&Rouvrir la fenêtre fermée -+Gérer les exceptions... -+URL -+Katakana demi-chasse -+Ouvrir une adresse -+Données de navigation -+Code PIN incorrect. Veuillez réessayer. -+Non -+Utiliser cette langue pour corriger l'orthographe -+Fermer les autres onglets -+Clé privée non valide. -+Une erreur réseau s'est produite pendant la communication avec le service de gestion des périphériques. -+Importer les données d'un autre navigateur... -+&Ajouter au dictionnaire -+Voulez-vous vraiment ouvrir  onglets ? -+Fabricant du périphérique : -+Afficher l'historique complet -+Illimité -+Clavier Neo2 allemand -+Liste déroulante -+Clé : -+Coller en texte brut -+Afficher les &commandes -+Cette page suit votre position géographique. -+Certificat de chiffrement de courrier électronique -+&Profilage activé -+En savoir plus sur la récupération du système -+Essentielle -+Type MIME -+Autoriser le téléchargement ? -+Clavier croate -+Interdire à tous les sites de suivre ma position géographique -+Utiliser la barre de titre du système et les bordures de la fenêtre -+En bas à gauche -+Informations sur l'erreur : -+Essayez : saisissez "orchidées", puis appuyez sur Entrée. -+Pour utiliser Chrome Web Store, vous devez être connecté à un compte Google. -+Configurer -+Petit problème... Nous n'avons pas réussi à vous authentifier. Veuillez vérifier vos identifiants de connexion puis réessayer. -+Pour gérer à distance la configuration de ce périphérique depuis le cloud, connectez-vous avec votre compte Google Apps. -+Réactiver -+Fermer la fenêtre -+Présentation -+Vous avez saisi un trop grand nombre de codes PIN incorrects. Veuillez contacter pour obtenir une nouvelle clé de déverrouillage du code PIN à 8 chiffres. -+Bloquer le contenu inapproprié -+Configuration avancée -+Utiliser SSL 3.0 -+Règles de confidentialité liées à la navigation sécurisée -+Vous devez être connecté à votre compte Google pour importer les favoris de la barre d'outils Google dans Google Chrome. Connectez-vous et relancez l'importation. -+Ouvrir le lien dans une nouvelle &fenêtre -+Les cookies de ont été bloqués. -+Copies -+&Ouvrir le fichier audio dans un nouvel onglet -+Afficher les noms d'utilisateurs et leur photo sur la page de connexion -+URL de révocation de certificat Netscape -+Ajoute des options de regroupement des onglets dans le menu contextuel des onglets. -+Clavier finnois -+Vérifiez votre connexion Internet. Redémarrez votre routeur, votre modem -+ ou tout autre périphérique réseau que vous utilisez. -+&Afficher le code source de la page -+Le serveur ne prend pas en charge la version HTTP utilisée dans la demande. -+Vos mots de passe enregistrés s'afficheront ici. -+Fermer les onglets sur la droite -+ heures -+ -+ indique qu'un produit ESET intercepte les connexions sécurisées. -+ En général, cela ne constitue pas un problème de sécurité car le -+ logiciel ESET s'exécute souvent sur le même ordinateur. Toutefois, en raison -+ de certaines incompatibilités avec les connexions sécurisées -+ , -+ vous devez configurer les produits ESET de manière à éviter ces -+ interceptions. Cliquez sur le lien En savoir plus pour obtenir des instructions. -+Les requêtes adressées au serveur ont été temporairement limitées. -+Impossible de télécharger l'image. Gravure annulée. -+Activer/désactiver le mode Hanja -+Effacer les paramètres d'ouverture automatique -+Pas après le -+Manifeste : -+Visa -+Clavier anglais canadien -+Récupération de fichier Microsoft -+En&registrer l'image sous... -+Zone -+Chemin : -+Prendre la photo -+Inactif -+Certains de vos certificats enregistrés identifient ces autorités de certification : -+Impossible d'afficher la page Web, car le serveur n'a envoyé aucune donnée. -+Considérer ce certificat comme fiable pour identifier les utilisateurs de messageries. -+Ce type de fichier peut endommager votre ordinateur. Voulez-vous vraiment télécharger  ? -+Importés depuis la barre d'outils Google -+Recherche instantanée et saisie semi-automatique -+Tout synchroniser -+Dvorak (Hsu) -+Exécuter la commande  : -+Le fichier contenait un certificat, qui n'a pas été importé : -+Vous utilisez actuellement un mot de passe multiterme. Si vous l'oubliez, vous pouvez réinitialiser la synchronisation afin de supprimer vos données des serveurs Google à l'aide de Google Dashboard. -+Impossible de détecter les modules chargés. -+Cette fonctionnalité affiche une bordure autour des couches de rendu afin de déboguer et d'étudier leur composition. -+Processus de traitement Web : -+Invité -+Nom du fichier : -+Un élément est manquant. -+Échec de la tentative de connexion au serveur. -+Des fenêtres pop-up ont été bloquées sur cette page. -+Personnaliser les langues et la saisie... -+Proxy HTTP -+Mot de passe multiterme de chiffrement -+Nouvelle fenêtre -+Certains certificats provenant de ces organisations vous identifient : -+Autoriser l'itinérance des données mobiles -+Alt -+Utiliser les pages actuelles -+Version -+En&registrer le fichier audio sous... -+Itinérance -+Romaji -+ minutes -+Synchroniser uniquement les paramètres et\ndonnées qui ont changé depuis la dernière connexion\n(requiert votre mot de passe précédent) -+Autoriser tous les sites à afficher des notifications sur le Bureau -+Ouvrir le fichier... -+Changer de fenêtre -+Chèvres téléportées -+Si vous arrêtez la synchronisation, les données stockées sur cet ordinateur et dans votre compte Google demeureront à ces deux emplacements. Toutefois, les nouvelles données ou les modifications apportées au contenu existant ne seront pas synchronisées. -+Le certificat du serveur ne correspond pas à l'URL. -+Commune -+Impossible d'activer les plug-ins désactivés par une stratégie d'entreprise. -+Ne pas afficher sur cette page -+Méthodes EAP en Wi-Fi expérimentales -+Disque dur -+Nouveau dossier -+intégration sur -+Autorité de certification de messagerie -+Cache CSS -+En haut à gauche -+Saisissez le nom du nouveau dossier. -+L'extension de renégociation SSL était introuvable lors de la négociation sécurisée. Avec certains sites, connus pour leur prise en charge de l'extension de renégociation, Google Chrome exige une négociation mieux sécurisée afin de prévenir certaines attaques. L'absence de cette extension suggère que votre connexion a été interceptée et manipulée au cours du transfert. -+Petit problème... Une erreur de communication avec le réseau est survenue lors de la tentative d'inscription de ce périphérique. Veuillez vérifier votre connexion réseau et réessayer. -+pause -+Afficher tous les téléchargements... -+Connexion à -+Impossible de résoudre l'adresse DNS du serveur. -+En attente de l'affichage du cache -+Thèmes -+Impossible de se connecter au serveur proxy. -+Ignorer la synchronisation des données chiffrées ? -+Oui -+Nombre de suggestions par page -+Modifier le code PIN -+Un problème est survenu lors de la copie de l'image de récupération sur le périphérique. -+ jours restants -+La connexion Internet a été interrompue. -+Début -+« Précédent -+C&opier l'URL de la vidéo -+Vos données sur et -+Langue -+Mappages des stratégies de certificat -+ minutes restantes -+Sélectionner la position -+Le site Web à l'adresse contient des éléments provenant de sites signalés comme étant des sites de phishing. Ces derniers incitent les internautes à divulguer leurs informations personnelles en se faisant passer pour des institutions de confiance, telles que des banques. -+ -+Hors de portée -+Effacer l'historique de navigation -+Aucune page Web trouvée à l'adresse : -+Nouveau moteur de recherche : -+Jamais pour ce site -+ jours restants -+Impossible d'accéder au réseau. -+Modifier l'adresse -+&Masquer le panneau de la vérification orthographique -+1 cookie -+Activer ces fonctionnalités... -+ secondes restantes -+Cou&per -+Fermer la barre de recherche -+Signataire de la liste de révocation de certificats -+Afficher des informations à propos du site -+UC -+Fermer les pages -+MSPY -+ () -+Très petite -+Afficher les réseaux privés dans le menu Réseau pour activer la connexion à un VPN -+Vérification de la mise à jour du système... -+L'entrée demandée est introuvable dans le cache. -+Connectez-vous à pour importer le certificat client. -+Modifier la mise en page -+Se déconnecter -+Espace insuffisant. -+Préférences synchronisées -+Imp&rimer le cadre... -+MSCHAP -+Continuer à bloquer les images -+Lorsqu'un site utilise des plug-ins : -+Échec d'exportation de la clé publique -+Choisir les éléments à synchroniser -+Paramètres de saisie du Pinyin -+Ouvrir les pages suivantes : -+Déconnexion -+Moteurs de recherche -+Erreur de suppression de certificat -+Ne rien faire -+Épingler l'onglet -+réinitialiser la synchronisation -+PKCS #1 SHA-256 avec chiffrement RSA -+Katakana -+Choisir un réseau mobile -+&Historique -+Mode développeur : -+Lien -+Système -+Sélectionnez le fichier de clé privée. -+Insérez une carte SD ou une carte mémoire USB. -+Temps restant : -+Cliquez ici pour exécuter le plug-in . -+Hanyu -+pages -+Configuration en cours -+Erreur inconnue -+ days ago -+La langue utilisée pour Google Chrome est passée de "" à "" après la synchronisation de vos paramètres. -+&Aucune suggestion orthographique -+Erreur de protocole SSL -+Mode de saisie du thaï (clavier Pattachote) -+Ce compte utilisateur n'est pas compatible avec ce service. -+ ne peut pas être exécuté en tant que root. -+C&oller -+Paramètres de contenu... -+Dimensions de l'image -+Sélectionner le fichier à enregistrer sous -+Disque Flash -+Moteur de recherche actuel : -+L'identité de situé à a été vérifiée par . -+Version de l'autorité de certification Microsoft -+Enregistrer une capture d'écran -+Page sur -+Console &JavaScript -+Réponse reçue incorrecte lors de la tentative de chargement de . -+ Cela peut être dû à une opération de maintenance ou à une configuration incorrecte sur le serveur. -+Serveur DNS : -+Pré-rendu : -+Impossible d'accéder à la bibliothèque réseau. -+Des images ont été bloquées sur cette page. -+Toujours autoriser à afficher les images -+Copier l'adr&esse du lien -+Ouvrir dans une fenêtre de navigation privée -+Mode développeur -+Chiffrement des données -+Activer la protection contre le phishing et les logiciels malveillants -+Appuyez sur pour rechercher sur -+Voulez-vous utiliser () au lieu de pour gérer les liens :// à partir de maintenant ? -+Démarrer une session en tant qu'invité -+Nombre maximal de caractères chinois dans la mémoire tampon de pré-édition, notamment les entrées de symboles Zhuyin -+Barre de menus GNOME expérimentale disponible -+Effacer l'historique des téléchargements -+Navigateur bloqué... -+Parenthèse drte -+Calcul du temps de chargement -+Ajouter une carte de paiement... -+Itinérance : -+Arrêter -+Erreur de synchronisation... -+ID de clé de l'autorité de certification -+Extensions -+Imprimez où que vous soyez. -+Un problème est survenu lors du téléchargement de l'image de récupération. -+Cloud Print Proxy -+Une erreur s'est produite lors de la configuration de la synchronisation. -+Fichiers personnalisés -+Impossible de définir le mode une fois la fenêtre créée. -+Date et heure -+Personnaliser les préférences de synchronisation -+Aucune information disponible sur le forfait -+Signaler un problème -+Importer mes favoris et paramètres -+Sélectionnez le menu clé à molette > Paramètres > Options avancées > Modifier les paramètres du proxy et vérifiez que vos paramètres sont définis sur "sans proxy" ou "direct". -+Fermer et annuler les téléchargements -+Autres moteurs de recherche -+ peut maintenant synchroniser vos mots de passe. Pour protéger vos données, vous devez confirmer les informations relatives à votre compte. -+Cette fonctionnalité active les API P2P Pepper et P2P JavaScript. L'API est en cours de développement et n'est pas encore opérationnelle. -+L'identité de ce site Web n'a pas été vérifiée. -+Sessions à l'étranger -+Cette page répertorie tous les modules chargés dans le processus principal et les modules enregistrés de manière à être chargés ultérieurement. -+Afficher les &infos sur le cadre -+Connecté -+Paramètres d'entrée en Chewing -+Conserver sur cette page -+Votre support de récupération est prêt. Vous pouvez le retirer du système. -+Copi&er l'adresse e-mail -+Interdire à tous les sites d'afficher des fenêtres pop-up (recommandé) -+Console &JavaScript -+Empêcher cette page de générer des boîtes de dialogue supplémentaires -+En haut à droite -+Entrez le mot de passe associé à votre application : -+Mode de saisie Google du japonais (pour clavier japonais) -+ est à jour () -+Le serveur a mis fin à la connexion de manière inattendue. -+Il est possible que le serveur hébergeant la page Web soit surchargé ou ait rencontré une erreur. Pour éviter de générer -+ trop de trafic et d'aggraver la situation, -+ a temporairement -+ bloqué l'acceptation des requêtes adressées au serveur. -+ -+ Si vous pensez que ce comportement n'est pas souhaitable, (par exemple, dans le cas où vous déboguez votre propre site Web), vous pouvez -+ consulter la page , -+ sur laquelle vous pourrez trouver plus d'informations ou désactiver cette fonctionnalité. -+Gestionnaire de &fichiers -+Arrêter la synchronisation du compte -+Ajouter -+Sélectionnez le fichier à ouvrir -+Aucun forfait de données -+Créer un compte Google -+Code postal -+&Gestionnaire de tâches -+Téléphone -+Sélectionner l'onglet précédent -+Sélectionner un certificat -+Mots de passe enregistrés -+Autoriser l'accès aux URL de fichier -+Modifi&er les moteurs de recherche... -+Gérer les moteurs de recherche... -+PKCS #7, chaîne de certificats -+Clé pré-partagée : -+Contrôlez et partagez l'accès à vos imprimantes depuis n'importe quel compte Google. -+Ajoute l'option "Utiliser les onglets latéraux" au menu contextuel de la barre d'onglets. Utilisez cette option pour déplacer les onglets du haut de l'écran (affichage par défaut) vers le côté. Particulièrement utile sur les grands écrans. -+S'inscrire -+, -+Saisissez un nouveau nom. -+ ne peut pas être affiché dans cette langue. -+Erreur : impossible de décoder l'extension. -+Clavier bulgare -+Accès aux informations de l'autorité -+Ajouter un réseau privé... -+C&opier l'URL du fichier audio -+Masque de sous-réseau : -+Impossible d'accéder à votre compte ? -+Utiliser les touches - et = pour paginer une liste d'entrées -+Le serveur ne prend pas en charge l'extension de renégociation TLS. -+Résolution de l'hôte... -+Récemment fermés -+Le certificat de sécurité du site a été signé avec un algorithme de signature faible. -+Votre mot de passe a été modifié -+Gérer les paramètres de saisie automatique... -+La page Web n'est pas disponible pour le moment. Cela peut être dû à une surcharge ou à une opération de maintenance. -+Éjecter -+Impossible de lancer le processus de service. -+ Mo restants -+Nouvelle fenêtre -+Sélectionnez -+ -+ Applications > Préférences système > Réseau > Avancé > Proxys -+ -+ et désélectionnez les serveurs proxy sélectionnés. -+Gravure en cours d'initialisation... -+Téléchargement de l'image de récupération... -+il y a  minutes -+Mode de saisie du chinois (cangjie) -+Comté -+Ouvrir l'adresse dans un nouvel onglet -+&Rouvrir l'onglet fermé -+Impossible d'afficher la page Web, car votre ordinateur est passé en mode -+ veille ou hibernation. Dans ce cas, les connexions réseau sont -+ coupées et les requêtes réseau échouent. L'actualisation de la page -+ devrait permettre de résoudre ce problème. -+Certificat utilisateur : -+Autoriser -+Appuyer sur Entrée pour revenir en arrière et sur la touche de menu contextuel pour afficher l'historique -+ZRM -+Cookies et autres données -+Page(s) ne répondant pas -+Paramètres d'entrée hangûl -+Configurer la synchronisation... -+Modules (). Conflits connus : , conflits probables : -+Date de renouvellement du certificat Netscape -+Ouvrir tous les favoris dans une nouvelle fenêtre -+bouton radio concernant l'étendue de pages -+Saisissez votre mot de passe -+ est conçu pour rendre l'impression plus intuitive, accessible et utile. vous permet de rendre vos imprimantes accessibles depuis n'importe quelle application Web ou mobile associée à . -+Dictionnaire de kanji unique -+Rétablir tous les onglets -+Échec de l'installation de l'extension -+En savoir plus sur la manière de se protéger des logiciels malveillants en ligne -+Toujours afficher les fenêtres pop-up de -+Authentification phase 2 : -+Aucun résultat de recherche trouvé -+Ouvrir une fois le téléchargement &terminé -+ cookies -+Mode de saisie du japonais (pour clavier américain) -+Continuer à bloquer les plug-ins -+Épingler sur la barre des tâches -+Les certificats ont une période de validité, comme tous les documents relatifs à votre identité (tel qu'un passeport). Le certificat présenté à votre navigateur n'est pas encore valide ! Lorsqu'un certificat est en dehors de sa période de validité, il n'est pas nécessaire d'assurer la maintenance de certaines informations relatives à son état (s'il a été révoqué ou s'il n'est plus approuvé). Par conséquent, il est impossible de vérifier que le certificat est fiable. Ne poursuivez pas. -+Fermer la session d'invité -+Contrôlez vos tâches d'impression et l'état de connexion de vos imprimantes en ligne. -+Désinstallation -+Empreinte SHA-1 -+Modifier le code PIN de la carte SIM -+État du réseau : -+sans limite -+(Choisir une autre capture d'écran) -+Désactivation -+Aucune erreur n'a été signalée récemment. Les erreurs n'apparaissent ici que lorsque l'envoi de rapports d'erreur est activé. -+Rouvrir les dernières pages ouvertes -+Ouvrir en mode plein écran -+Ajouter une carte de paiement -+Désactivé -+Chargement des informations sur votre forfait Internet mobile, veuillez patienter... -+Acheter un forfait de données... -+Inclure cet e-mail : -+Le titre doit comporter au moins un caractère. -+Espaces de noms réseau -+ n'a pas pu terminer l'installation, mais va poursuivre son exécution à partir de son image disque. -+Gestion des services Internet mobiles -+Utiliser les onglets latéraux -+Non -+Saisir le code PIN de la carte SIM -+&Afficher dans le Finder -+Maintenez la touche Ctrl, Alt ou Maj enfoncée<br>pour afficher le raccourci clavier qui lui est associé. -+Vraiment désolé, aucun prototype n'est disponible pour le moment. -+&Afficher dans le Finder -+Informations relatives au certificat -+/ -+La synchronisation des mots de passe requiert votre attention. -+Veuillez saisir l'ancien et le nouveau code PIN. -+Langue : -+Résultats de recherche -+Serveur SSL avec fonction d'optimisation -+Enregistrer en PDF -+Mémoire USB détectée -+M'avertir lorsque le flux de données est faible ou presque inexistant -+Saisir le mot de passe multiterme -+Clavier lituanien -+Les éléments saisis dans le champ polyvalent peuvent être enregistrés. -+Les informations de connexion à votre compte sont obsolètes. Cliquez ici pour saisir à nouveau votre mot de passe. -+Vietnamien -+feuilles de papier -+URL de mot de passe perdu Netscape -+Rouvrir l'onglet fermé -+Effacer les mots de passe enregistrés -+Créer un nouveau dossier... -+Basculer en mode ponctuation pleine chasse ou demi-chasse -+Gérer les paramètres de localisation... -+Synchronisé... -+Options de recherche par défaut -+Aucune sélection -+Mode de saisie du vietnamien (TELEX) -+ minute restante -+Le nombre maximal d'autorités de certification intermédiaires a été dépassé : -+Saisissez un mot de passe pour chiffrer ce fichier de certificat. -+Organiser -+Votre mot de passe a changé. Veuillez réessayer avec votre nouveau mot de passe. -+PKCS #1 MD5 avec chiffrement RSA -+Utiliser le thème classique -+Échap efface toute la mémoire tampon de pré-édition -+Ajouter aux favoris -+Un incident est survenu sur une partie de cette page (HTML WebWorker). Elle risque de ne pas fonctionner correctement. -+Clavier américain -+Signataire de code -+Adobe Reader n'est pas à jour et risque de ne plus être sécurisé. -+Personnaliser les paramètres de synchronisation... -+Co&ller et rechercher -+Détails du certificat sélectionné : -+Impossible de se connecter -+Activation : -+Système de révocation introuvable dans le certificat du serveur -+Numéro de série -+Afficher la page "Nouvel onglet" -+il y a  heure -+Votre ordinateur redémarrera une fois la mise à jour effectuée. -+Verr. maj. -+L'accès au répertoire de l'hôte de communication à distance a été refusé. Essayez avec un autre compte. -+Accessible aux scripts : -+Cette page place des cookies. -+Proxy -+Avec sous-menu -+Afficher dans le dossier -+il y a  minutes -+<saisir une requête> -+Appuyez sur pour envoyer des commandes à . -+Prévisualiser le rapport -+Activer le dernier onglet -+Lorsque je quitte le navigateur -+Continuer sans mettre à jour Adobe Reader (non recommandé) -+Le champ de mot clé doit être vide ou comporter un mot unique -+Déplacer le curseur automatiquement au caractère suivant -+Enregistrer -+Ouvrir le lien dans un nouvel ongle&t -+Nouvelle fenêtre de navigation privée -+Celtique -+Réinitialiser le zoom -+Prototypes -+Mémoriser mes choix pour tous les liens de ce type -+Les plug-ins de cette page ont été bloqués. -+Site -+Sélectionner -+Couper -+Restaurer toutes les miniatures supprimées -+Utiliser les onglets latéraux -+Se connecter au dispositif de sécurité -+Enregistrer le fichier -+Pages -+Options de -+Barre de lancement rapide -+Annuler -+Choisir un fichier -+&Rechercher avec -+(pas encore valide) -+Mettre à jour le plug-in... -+Police Sans-Serif -+Impossible de charger le JavaScript "" du script de contenu. -+Connexion... -+Mots de passe -+Fichiers PKCS #12 -+Options de saisie automatique de -+Fenêtre précédente -+Astuce -+ / fichiers -+Localisation utilisée, mais les paramètres régionaux par défaut (default_locale) n'ont pas été indiqués dans le manifeste. -+Si vous n'êtes pas à l'origine de cette requête, il s'agit probablement d'une attaque contre votre système. Si vous n'avez pas lancé cette requête de manière intentionnelle, cliquez sur Ne rien faire. -+Votre commentaire a bien été envoyé. -+Fonction d'optimisation internationale Netscape -+Taille de police minimale -+Suivant -+Utilitaire : -+Cette opération peut prendre une minute... -+Le format du mot de passe est incorrect. -+Chargement... -+Ajouter la page... -+Masquer ce plug-in -+&Paramètres linguistiques... -+Créer un support de récupération du système d'exploitation -+Le fichier de clé privée est incorrect. -+Valeur : -+Stable -+Grande -+Certificat serveur invalide -+Jamais enregistrés -+Cette page a été préchargée. -+Google Chrome ne peut pas afficher l'aperçu avant impression lorsque la visionneuse de documents PDF intégrée est désactivée. Pour l'afficher, veuillez accéder à chrome://plugins, activer "Chrome PDF Viewer" et réessayer. -+Nouveau ! -+Vous êtes passé en navigation privée. Les pages que vous consultez dans cette fenêtre n'apparaîtront ni dans l'historique de votre navigateur, ni dans l'historique des recherches, et ne laisseront aucune trace (comme les cookies) sur votre ordinateur une fois que vous aurez fermé la fenêtre de navigation privée. Tous les fichiers téléchargés et les favoris créés seront toutefois conservés. Passer en navigation privée n'a aucun effet sur les autres utilisateurs, serveurs ou logiciels. Méfiez-vous : Des sites Web qui collectent ou partagent des informations vous concernant Des fournisseurs d'accès Internet ou des employeurs qui conservent une trace des pages que vous visitez Des programmes indésirables qui enregistrent vos frappes en échange d'émoticônes gratuites Des personnes qui pourraient surveiller vos activités Des personnes qui se tiennent derrière vous En savoir plus sur la navigation privée -+Le certificat du serveur a été révoqué. -+&Reprendre -+Sélectionnez un réseau : -+Impossible d'extraire les fichiers de l'extension. Pour effectuer cette opération en toute sécurité, vous devez disposer d'un chemin d'accès à votre répertoire de profils ne contenant pas de lien symbolique. Aucun chemin de ce type n'existe pour votre profil. -+Effacer les données de navigation -+Si vous êtes conscient que la visite de ce site peut être préjudiciable à votre ordinateur, vous pouvez . -+Votre périphérique est inscrit pour bénéficier de la gestion d'entreprise. -+Serveur de mise à jour non disponible (erreur : ) -+Module client natif : -+Rechercher sur  : -+Style de symboles -+ hours -+Département -+Continuer à utiliser -+OK -+Essayez de désactiver les prédictions d'actions du réseau en procédant comme suit : -+ Sélectionnez le -+ -+ menu clé à molette > -+ -+ > -+ -+ -+ et désélectionnez "". -+ Si le problème n'est pas résolu, nous vous conseillons de sélectionner de nouveau -+ cette option pour améliorer les performances. -+Date -+Sélectionnez un certificat pour vous authentifier sur . -+Barre latérale -+La clé publique éphémère Diffie-Hellman associée au serveur est peu sûre. -+Rechercher dans Dictionnaire -+Sélectionnez un moteur de recherche -+Clavier russe -+Nom Microsoft principal -+Clavier polonais -+Clavier serbe -+ minute -+Erreur lors de la lecture des données du cache. -+Canary -+Commentaire du certificat Netscape -+Page suivante -+ est à jour. -+Paramètres de saisie automatique... -+Tout ramener au premier plan -+Sélectionner le dossier à ouvrir -+Activer le mode Pinyin fuzzy -+Résolution du proxy... -+Le téléchargement de l'image a été interrompu. -+Eten 26 -+URI -+Clavier Dvorak américain -+Rechercher sur le Web... -+Si vous utilisez un serveur proxy, vérifiez les paramètres associés ou demandez à votre administrateur réseau -+ si ce serveur fonctionne. -+Impossible de charger l'icône de l'extension "". -+Définir un proxy pour se connecter au réseau -+zone de texte concernant l'étendue de pages -+Activation -+Clavier Dvorak britannique -+ jours -+MS-IME -+Aucun forfait de données -+Les fenêtres pop-up suivantes ont été bloquées sur cette page : -+ heures restantes -+Impossible de charger le modèle du favori. -+Échec d'exportation de la clé privée -+Utiliser comme page d'accueil -+Compte -+Plein écran -+Autoriser tous les sites à suivre ma position géographique -+Si la restauration du système d'exploitation de votre ordinateur s'avère nécessaire, une carte SD ou une clé USB de récupération vous sera demandée. -+Les cookies suivants ont été bloqués : -+Inclure les adresses de ma fiche de Carnet d’adresses -+Le certificat de sécurité du site n'est pas approuvé ! -+Votre liste d'applications, d'extensions et de thèmes installés -+Exécuter tous les plug-ins de cette page -+Augmente la taille du texte -+Accepter et continuer » -+Fichiers -+ -+Appliquer uniquement à cette session de navigation privée -+Latin large -+Exécuter ce plug-in -+MasterCard -+Sur le Web, Tab permet de sélectionner les liens, ainsi que les champs de formulaire. -+À propos de -+Paramètres de sécurité du système -+Images -+Cyrillique -+Pas maintenant -+Attendre la fin du téléchargement -+Thème "" installé -+&Supprimer -+Menu Démarrer -+&Zoom -+Transfert en cours ( %)... -+Géré par -+&Rafraîchir -+Configuration du module de plate-forme sécurisée (TPM) en cours. Veuillez patienter, cela peut prendre quelques minutes. -+Vous avez acheté une quantité illimitée de données le . -+Confirmer avant de quitter () -+Mémoire partagée -+Rech. dans les paramètres -+mot de passe d'accès au réseau -+Activer la vérification orthographique -+Types de données -+Bloquer -+Certificat de l'autorité de certification du serveur : -+Clavier grec -+Taille réelle -+Toujours en haut -+Aucun plug-in installé. -+Alerte JavaScript -+Autoriser en mode navigation privée -+Rétablir -+, expire le : -+Confirmer la désinstallation -+Impossible de désactiver les plug-ins ayant été activés par une stratégie d'entreprise. -+Cette fonctionnalité active l'option "Lire en un clic" dans les paramètres de contenu du plug-in. -+Attendre la fin des téléchargements -+Synchronisation -+&Rouvrir l'onglet fermé -+Votre mot de passe de compte Google a changé depuis votre dernière connexion à partir de cet ordinateur. -+Le fichier contenait plusieurs certificats, aucun d'eux n'a été importé : -+Afficher le bouton -+La saisie dans le champ polyvalent d'une URL déjà ouverte dans un autre onglet entraîne l'affichage de l'onglet en question, et non l'affichage de l'URL dans l'onglet actuel. -+Configuration en cours... -+Rechercher dans les téléchargements -+Me demander lorsqu'un site tente de suivre ma position géographique (recommandé) -+La nouvelle version de "" a été désactivée, car elle nécessite davantage d'autorisations. -+Clavier phonétique russe -+American Express -+Ce serveur exige un certificat d'authentification et n'a pas accepté celui envoyé par le navigateur. -+Votre certificat a peut-être expiré ou le serveur n'a pas approuvé l'émetteur. -+Réessayez avec un autre certificat si vous en avez un. -+Sinon, vous devrez en obtenir un nouveau d'un autre émetteur. -+Lorsque vous vous connectez à un site Web sécurisé, le serveur hébergeant ce site présente à votre navigateur un "certificat" afin de vérifier l'identité du site. Ce certificat contient des informations d'identité, telles que l'adresse du site Web, laquelle est vérifiée par un tiers approuvé par votre ordinateur. En vérifiant que l'adresse du certificat correspond à l'adresse du site Web, il est possible de s'assurer que vous êtes connecté de façon sécurisée avec le site Web souhaité et non pas avec un tiers (tel qu'un pirate informatique sur votre réseau). -+À l'instant -+Votre carte SIM sera définitivement désactivée si vous ne saisissez pas correctement la clé de déverrouillage du code PIN. Nombre de tentatives restantes : -+ / octets, Interrompu -+Importés depuis Firefox -+Détection automatique -+&Aide -+Les codes PIN sont différents ! -+Contenu Web -+Vider le cache -+Rétablir le thème par défaut -+Le service de communication à distance a démarré correctement. Vous devriez maintenant pouvoir vous connecter à distance à cet ordinateur. -+Outils de développement -+Police Serif -+Copier -+Adresse e-mail ou mot de passe incorrect. Veuillez réessayer. -+Le plug-in suivant ne répond pas : souhaitez-vous interrompre ? -+Sens -+ secondes -+Clavier tchèque -+Voulez-vous que "" soit considérée comme une autorité de certification fiable ? -+Gestionnaire de sécurité natif du client -+<p>Lorsque vous exécutez dans un environnement de bureau pris en charge, les paramètres proxy du système sont utilisés. Toutefois, soit votre système n'est pas pris en charge, soit un problème est survenu lors du lancement de votre configuration système.</p> -+ -+ <p>Vous avez toujours la possibilité d'effectuer la configuration via la ligne de commande. Pour plus d'informations sur les indicateurs et les variables d'environnement, veuillez vous reporter à <code>man </code>.</p> -+La page Web à l'adresse a déclenché trop de redirections. Pour résoudre le problème, effacez les cookies de ce site ou autorisez les cookies tiers. Si le problème persiste, il peut être dû à une mauvaise configuration du serveur et n'être aucunement lié à votre ordinateur. -+SSID : -+Nom du forfait : -+Adresse X.400 -+Fermer l'onglet -+Impossible de trouver un navigateur pris en charge. -+Le compte associé à la boutique en ligne est le suivant : . L'utilisation d'un autre compte pour la synchronisation provoque des erreurs. -+Enregistrer la p&age sous... -+ importe actuellement les éléments suivants à partir de  : -+Appuyez sur Entrée pour avancer et sur la touche de menu contextuel pour afficher l'historique -+Actualiser le cadre -+Annulé -+Autorités -+Sélectionnez votre clavier : -+Signaler un problème... -+Ignorer ce réseau -+Nouveau matériel détecté -+Vous disposez de certificats qui n'appartiennent à aucune autre catégorie : -+&Profilage activé -+(Navigation privée) -+&Nouveau dossier -+Types MIME : -+Afficher les pages en arrière-plan () -+Fichiers audio -+Plug-ins -+Plus d'informations... -+Se connecter automatiquement à ce réseau -+Titulaire de la carte -+Elle peut désormais accéder à : -+Noir et blanc -+Ignorer la connexion et naviguer en tant qu'invité -+Toutefois, cette page inclut d'autres ressources qui ne sont pas sécurisées. Ces ressources peuvent être consultées par des tiers pendant leur transfert, et modifiées par un pirate informatique dans le but de changer l'aspect et le comportement de cette page. -+Accès réseau interrompu -+La dernière version de l'extension "" requiert d'autres permissions. Elle a donc été désactivée. -+Dans ce cas, le certificat du serveur ou un certificat d'autorité intermédiaire présenté à votre navigateur n'est pas valide. Cela peut signifier que le certificat est incorrect, qu'il contient des champs non valides ou qu'il n'est pas compatible. -+Veuillez saisir la clé de déverrouillage du code PIN à 8 chiffres fournie par . -+Exceptions... -+Connexion à -+Voulez-vous vraiment quitter alors qu'un téléchargement est en cours ? -+Le site Web ne parvient pas à gérer la demande associée à . -+Précédent -+&Arrêter -+Lorsque l'option permettant de bloquer l'enregistrement des cookies tiers est activée, la lecture de ces cookies est également bloquée. -+ : -+Console JavaScript -+Les sites pour lesquels vos mots de passe ne seront jamais enregistrés s'afficheront ici. -+Inconnu -+Mode de saisie du thaï (clavier TIS-820.2538) -+&Favoris -+Désinstaller -+Voulez-vous vraiment quitter alors que  téléchargements sont en cours ? -+Configurer le blocage des cookies... -+ABC -+L'application hébergée par est inaccessible, car vous êtes déconnecté du réseau. Cette page s'affichera dès que la connexion réseau sera rétablie. <br> -+Gestionnaire de favoris -+ secs ago -+Quitter le mode plein écran -+Ouvrir l'&image dans un nouvel onglet -+Favori ajouté ! -+Choisir un autre dossier... -+Kotoeri -+Hier -+Synchroniser automatiquement les éléments suivants : -+Votre ordinateur intègre un périphérique de sécurité TPM (module de plate-forme sécurisée) qui permet de mettre en œuvre plusieurs fonctionnalités de sécurité critiques dans Google Chrome OS. -+Contraintes des stratégies de certificat -+Créer un support de récupération -+Emplacement : -+Toutes les pages que vous consultez apparaîtront ici à moins que vous ne les ouvriez dans une fenêtre en navigation privée. Vous pouvez utiliser le bouton Rechercher de cette page pour rechercher dans toutes les pages de votre historique. -+Options pour les développeurs -+Cookies -+Toujours exécuter pour ce site -+Afficher le dossier -+Autres favoris -+Clavier français -+ ne parvient pas à déterminer ou à définir le navigateur par défaut. -+Sélectionner l'onglet suivant -+Voulez-vous vraiment supprimer ces pages de votre historique ? -+Déverrouiller -+ID de clé : -+Exécuter ce plug-in -+Utilisateurs -+Ajouter un moteur -+Répondeur OCSP : -+Ignorer -+Champs de certificat -+Modules () : aucun conflit détecté. -+Onglet : -+Impossible de charger la page d'options "". -+Coller en adaptant le style -+Veuillez ajouter une autre langue avant de supprimer celle-ci. -+nom du réseau -+ synchronise de manière sécurisée vos données avec votre compte Google. -+Taille -+Activer... -+Recherche -+Poursuivre quand même -+Nouveau code PIN : -+La capacité du périphérique doit être d'au moins 4 Go. -+De droite à gauche -+Activer le mode Pinyin double -+Menu contenant des favoris masqués -+Utiliser le dictionnaire système -+Vous avez choisi de chiffrer les données à l'aide de votre mot de passe Google. Vous pouvez modifier vos paramètres de synchronisation à tout moment, si vous changez d'avis. -+Personnaliser les polices... -+Enregistrement des informations de date -+&Vérifier l'orthographe du texte de ce champ -+Ceci est un modèle expérimental qui permet aux enregistrements DNS (utilisant le protocole de sécurité DNSSEC) d'autoriser ou de refuser des certificats HTTPS. Ce message s'affiche lorsque vous activez des fonctionnalités expérimentales via des options de ligne de commande. Vous pouvez supprimer ces options de ligne de commande pour ignorer cette erreur. -+ minutes restantes -+Île -+Contraintes de base du certificat -+Autres... -+Activer l'onglet 4 -+Données personnelles -+Afficher l'original -+Nom de la société -+Définir Adobe Reader comme visionneuse de documents PDF par défaut ? -+Pour gérer les extensions installées, cliquez sur Extensions dans le menu Fenêtre. -+Accédez à vos imprimantes depuis n'importe quel ordinateur ou smartphone. En savoir plus -+Me &le rappeler plus tard -+Opération réussie ! -+Carte SD détectée. -+ - Propriétaire -+Clavier japonais -+WPA -+janv.^févr.^mars^avr.^mai^juin^juil.^août^sept.^oct.^nov.^déc. -+Sélectionnez -+ -+ Applications > Préférences système > Réseau > Assistant -+ -+ pour tester votre connexion. -+&Afficher le code source de la page -+Micrologiciel : -+Créer un profil -+Date de modification -+Sandbox seccomp -+Signale&r un problème... -+Entrée de symboles simplifiée -+Chinois simplifié -+Hôte SOCKS -+Considérer ce certificat comme fiable pour identifier les sites Web. -+Exceptions de localisation -+Hiragana -+Le mot de passe TPM ci-dessous, généré de façon aléatoire, a été attribué à votre ordinateur : -+Importer mes favoris maintenant... -+ -+Avertissement : Un problème a été détecté sur cette page. -+Avec Google Chrome OS for business, vous pouvez connecter votre périphérique à Google Apps, ce qui vous permet de le rechercher et de le contrôler depuis le panneau de configuration de Google Apps. -+Ajouter tous les onglets aux favoris... -+Émis le -+Lorsque je ferme le navigateur -+Localisation -+Attendre -+Infos sur la clé publique de l'objet -+Plug-in inconnu -+Connexion en mode invité -+Toujours autoriser à paramétrer les cookies -+Résumé -+Le certificat du serveur n'est pas valide. -+Chaîne de certificats codés Base 64 ASCII -+Choisir mon propre mot de passe multiterme -+Certificat de serveur non répertorié -+Rechercher la sélection -+Activer -+L'accès à ce réseau est protégé. -+E-mail -+Erreur () : -+Signature permanente Microsoft -+Sélectionnez -+ -+ Démarrer > Panneau de configuration > Réseau et Internet > Centre Réseau et partage > Résolution des problèmes (en bas) > Connexions Internet. -+ -+Gestionnaire de &fichiers -+Service client -+Impossible de se connecter au réseau "". -+J'accepte ces termes -+Copier l'adr&esse du lien -+Veuillez démarrer en tant qu'utilisateur normal. Pour l'exécuter en tant que root, vous devez indiquer un autre répertoire de données utilisateur pour stocker les informations du profil. -+Le processus du connecteur est bloqué. Voulez-vous le redémarrer ? -+Contenu Web -+Clé compromise -+Supprimer -+Si vous fermez maintenant, ces téléchargements seront annulés. -+Dachen 26 -+Voulez-vous vraiment graver l'image sur le périphérique suivant : -+Mémoire SQLite -+/, -+ est affiché dans cette langue. -+Fenêtre pop-up bloquée -+ : -+Ouvrir tous les favoris -+Effacer les cookies et autres données de site et de plug-in lorsque je ferme le navigateur -+Page d'accueil -+Onglet -+Non configuré -+Opération réussie ! -+Relancez pour terminer la mise à jour. -+Chiffrer toutes mes données -+Veuillez patienter pendant que nous configurons votre réseau pour mobile. -+Points de distribution de listes de révocation des certificats -+Association -+Appuyez sur Maj+Alt pour changer la disposition du clavier. -+Utiliser l'horloge au format 24 heures -+ est prêt à terminer l'installation. -+Lancez votre recherche à partir d'ici -+OK, synchroniser tout -+Afin d'être correctement affichée, cette page requiert des données que vous avez précédemment entrées. Vous pouvez de nouveau transmettre ces données, mais, en procédant ainsi, vous devrez répéter chaque action que cette page a effectuée auparavant. Cliquez sur Rafraîchir pour transmettre de nouveau ces données et pour afficher cette page. -+Cela signifie que le certificat présenté à votre navigateur a été révoqué par son émetteur. L'intégrité de ce certificat a certainement été compromise, et il ne doit donc pas être approuvé. Ne poursuivez pas. -+Clavier slovaque -+Nom de partie EDI -+Vous avez déjà chiffré des données avec un mot de passe multiterme. Saisissez-le ci-dessous. -+Informations sur le site -+Créer un raccourci vers l'application... -+Authentification requise -+ n'est pas parvenu à se connecter à . Sélectionnez un autre réseau ou réessayez. -+Votre compte n'est pas compatible avec . Contactez l'administrateur de votre domaine ou utilisez un compte Google standard pour vous connecter. -+Adresse e-mail -+Client natif -+Chargé depuis : -+Active les balises canvas hautes performances dans un contexte 2D, pour effectuer le rendu via le processeur graphique. -+Cette page ena été traduite en -+Seule une personne en possession de votre mot de passe multiterme peut lire vos données chiffrées. Google ne reçoit ni n'enregistre votre mot de passe multiterme. Si vous oubliez votre mot de passe multiterme, vous devrez -+Autorité de certification SSL -+ contient un logiciel malveillant. Votre ordinateur pourrait être infecté par un virus si vous consultez ce site. -+Aucune donnée disponible. -+Im&primer... -+Description -+Voix non reconnue. -+Aucun fichier sélectionné -+Souhaitez-vous installer  ? -+Activité récente -+de la dernière semaine -+Profil -+Actualiser sans utiliser le cache -+Logiciels malveillants et sites de phishing détectés ! -+Onglet fermé ! -+il y a  jours -+Paramètres -+Ce site exige que vous vous identifiiez avec un certificat : -+Supprimer... -+&Aucune suggestion orthographique -+Clavier franco-canadien -+Clavier étendu américain -+Le serveur a mis fin à la connexion sans envoyer de données. -+Autoriser à afficher des notifications sur le Bureau ? -+Pour gérer les extensions installées, cliquez sur Extensions dans le menu Outils. -+Erreur de synchronisation, veuillez vous connecter à nouveau. -+La liste suivante fait état des éléments dangereux détectés sur la page. Cliquez sur le lien "Diagnostic" pour obtenir plus d'informations sur un élément particulier. -+Émirat -+Synchroniser tous les paramètres et toutes les données\n(peut prendre un certain temps) -+Toujours demander où enregistrer les fichiers -+Créer un raccourci -+Tous les fichiers -+Sebeol-sik No-shift -+Anglais (pleine chasse) -+2D avec canvas et accélération matérielle -+Cette fonctionnalité autorise l'installation d'applications Google Chrome déployées à partir d'un manifeste situé sur une page Web, plutôt qu'avec un fichier crx contenant le manifeste et les icônes. -+Nouvelle connexion -+GPU -+Moins de 1 Mo disponible -+Nouvelle fenêtre de navigation privée -+Europe du Sud -+Sélectionner les éléments à synchroniser -+Attributs du répertoire de l'objet du certificat -+Accédez à vos imprimantes et partagez-les en ligne via . -+&Ajouter... -+Afficher dans cette langue -+il y a  jour -+Police Sans-Serif -+Ne rien faire -+ seconde -+Configurer les mises à jour automatiques pour tous les utilisateurs -+Échec de la création du répertoire des données -+Fermer et annuler le chargement -+ -+Adresse : -+Détails -+Notification : -+Cette opération peut prendre quelques minutes. -+Géré par () -+Type de certificat Netscape -+Impossible d'afficher certaines parties de ce document PDF. Souhaitez-vous installer Adobe Reader ? -+Vos certificats -+Vos données personnelles sur , et -+URL de stratégie de l'autorité de certification Netscape -+Dernier accès : -+Synchroniser les mots de passe -+&Quitter -+&Fermer l'onglet -+, -+Le site Web à l'adresse contient des éléments provenant de sites qui semblent héberger des logiciels malveillants. Ces derniers peuvent nuire à votre ordinateur ou agir à votre insu. Le simple fait de visiter un site hébergeant ce type de logiciels peut infecter votre ordinateur. -+Total : -+Les cookies de plusieurs sites ont été autorisés pour la session uniquement. -+Nom du service : -+Imprimer une page de test -+Aperçu avant impression - -+ -+ ne peut pas à afficher la page Web, car votre ordinateur n'est pas connecté à Internet. -+Exécuter cette fois -+Chiffrement de la clé -+Échec de la vérification AAA -+Ouverture dans ... -+&Copier -+Logiciel -+Moteurs de recherche -+&Méthodes d'entrée -+Jamais enregistrés -+Impossible d'analyser le fichier. -+Subordination qualifiée Microsoft -+Bureau -+Toujours traduire en les pages en -+Thaï -+Activer l'onglet suivant -+: de chargement -+Style de mappage du clavier -+Un problème lié à votre microphone s'est produit. -+ vous permet d'accéder aux imprimantes de cet ordinateur, où que vous soyez. Connectez-vous pour l'activer. -+District -+Ethernet -+Erreur de réseau inconnue. -+Nom du certificat -+Plus d'informations -+Mise à jour du système disponible. Préparation du téléchargement… -+Galerie des thèmes Google Chrome -+Copi&er l'adresse e-mail -+Activer l'onglet 3 -+Adresses -+Plug-in : () -+Pas maintenant -+Pays -+<Ne fait pas partie du certificat> -+il y a  seconde -+Fichiers image -+Europe centrale -+Certificat client SSL -+Pour accélérer l'affichage des pages Web, -+ -+ enregistre temporairement les fichiers téléchargés sur le disque. Si -+ -+ ne s'arrête pas correctement, ces fichiers peuvent être endommagés, ce qui -+ génère cette erreur. L'actualisation de la page devrait permettre de résoudre -+ ce problème ; celui-ci ne se reproduira vraisemblablement plus si l'arrêt s'effectue -+ correctement. -+ -+ Si le problème persiste, essayez de supprimer le contenu du cache. Cette -+ erreur peut aussi indiquer que le matériel est sur le point de tomber -+ en panne. -+Thème créé par -+Données de navigation -+Ajouter cette page aux favoris -+Le serveur a refusé la connexion. -+Module ( bits) :\n\n\nExposant public ( bits) :\n -+ secondes restantes -+Vous utilisez un indicateur de ligne de commande non pris en charge : . La stabilité et la sécurité en seront affectées. -+Emplacement de téléchargement -+À propos de Google Traduction -+Les lettres ne sont pas sensibles à la casse. -+Mot clé -+Connexion -+Redémarrez pour appliquer la mise à jour. -+Sélectionner un carré dans l'image -+Bases de données Web -+Codage -+Mise en route -+Utiliser les pages actuelles -+Signaler une erreur -+Recherche de réseaux en cours -+Effacer les données de navigation -+Ouvrir le lien dans une nouvelle &fenêtre -+Nom d'utilisateur -+Clavier letton -+Forcer l'actualisation de cette page -+Disposition du clavier : -+Non utilisé -+ minutes -+Chiffrement RSA PKCS #1 -+Ce n'est probablement pas le site que vous recherchez ! -+&Général -+Configurer la synchronisation -+État de connexion : -+Ancien code PIN : -+Désactiver le contrôle des liens hypertexte -+&Modifier -+Chinois -+Navigateur par défaut -+Extension en mode navigation privée : -+Mot clé : -+Un problème est survenu lors du téléchargement de l'image de récupération. La connexion réseau a été perdue. -+Votre administrateur a désactivé certaines préférences. -+Forfait de données épuisé -+Veuillez indiquer à quel niveau vous rencontrez des problèmes avant d'envoyer vos commentaires. -+Authentification du serveur WWW TLS -+Le service de synchronisation n'est pas disponible pour votre domaine. -+Modifier les paramètres du proxy... -+Cette fonctionnalité active les API des extensions expérimentales. Notez que vous ne pouvez pas mettre en ligne des extensions qui font appel aux API expérimentales dans la galerie d'extensions. -+Un logiciel malveillant a été détecté ! -+Forfait de données presque épuisé -+des dernières 24 heures -+Une fois activée, la recherche instantanée charge la plupart des pages Web dès que vous saisissez l'URL dans le champ polyvalent, avant même que vous n'appuyiez sur Entrée. Si votre moteur de recherche par défaut est compatible, toute lettre saisie dans ce champ offre de nouveaux résultats et les prédictions intégrées vous guident dans vos recherches.\n\nChaque touche utilisée fait l'objet d'une requête, par conséquent il se peut que les éléments saisies dans le champ polyvalent soient enregistrés par votre moteur de recherche par défaut.\n -+ hours left -+poursuivre quand même -+Autorisé -+Retirer l'onglet -+Moins de -+Impossible de charger l'icône "" d'action du navigateur. -+Consulter Google Dashboard -+Plus d'informations -+Ajoutez des langues puis faites-les glisser pour les classer dans l'ordre souhaité. -+ sera lancé au démarrage du système et continuera de s'exécuter en arrière-plan, même toutes les fenêtres de sont fermées. -+Non (HttpOnly) -+Saisir votre mot de passe multiterme pour la synchronisation -+Police standard -+ (par défaut) -+Cette fonctionnalité active la prise en charge du client natif. -+La puce du module de plate-forme sécurisée (TPM) est désactivée ou inexistante. -+L'index de l'onglet indiqué est incorrect. -+Nom du serveur SSL du certificat Netscape -+Est une autorité de certification -+Wi-Fi -+Connexion à -+Confirmer le mot de passe : -+Aperçu avant impression -+Clavier italien -+Impossible d'établir une connexion sécurisée à cause de l'antivirus ESET. -+(expiré) -+Voulez-vous vraiment quitter cette page ? -+Faire défiler d'une page vers le haut -+Empreintes -+Le plus récent -+ heures -+Agrandir -+La page Web est introuvable dans le cache. Certaines ressources ne sont restituées fidèlement que si elles sont extraites du cache, notamment les pages générées à partir de données que vous avez envoyées. Cette erreur peut également être due à un cache endommagé lors d'une fermeture incorrecte. Si le problème persiste, essayez d'effacer le cache. -+Le plug-in n'est plus à jour. -+Vous avez changé de position. Souhaitez-vous utiliser  ? -+EAP-TLS -+ heures -+Rafraîchir cette page -+Non-répudiation -+Extension : -+Active l'API Web audio. -+Zone de saisie de mot de passe -+Effacer les cookies et autres données de site lorsque je quitte le navigateur -+Ajouter l'option de regroupement au menu contextuel des onglets -+Version -+Latin -+Le connecteur requiert l'installation du pack Microsoft XML Paper Specification Essentials. -+Effacer les cookies et autres données de site lorsque je ferme le navigateur -+Case décochée -+Mise en page -+Saisir un nom ou une adresse -+Choix de l'image du compte -+Me montrer -+ minutes restantes -+De : -+Ouvrir un rapport de phishing -+Page de phishing -+Inspecter le pop-up -+Importer... -+Modifier la carte de paiement -+Cette langue est utilisée pour corriger l'orthographe. -+Le type d'enregistrement indiqué est incorrect. -+Forfait de données arrivé à expiration -+Exporter mes favoris... -+Clavier britannique -+Importer des favoris... -+ -+Nom d'utilisateur ou mot de passe incorrect -+&Tout sélectionner -+Erreur inconnue liée au certificat du serveur. -+Envoyer une capture d'écran enregistrée -+Émis pour : -+Page précédente -+Hsu -+Réduire -+Navigateur par défaut -+Afficher le mot de passe -+Activer les fonctionnalités d'accessibilité -+Inclure la capture d'écran actuelle : -+ - -+(cette extension est gérée et ne peut être désinstallée ni désactivée) -+OID enregistré -+Importés depuis IE -+Fichier de clé privée (facultatif) : -+Autoriser pour la session uniquement -+ mins -+Mise à jour en cours -+Aucun microphone trouvé. -+Connexion à -+ n'est pas votre navigateur par défaut. -+Forfait -+Cette page contient des éléments des sites ci-dessous qui suivent votre position géographique : -+Plusieurs profils -+Plantages -+Par défaut -+ jours -+PKCS #1 MD4 avec chiffrement RSA -+Modifier le moteur de recherche -+ minutes -+Indiquez le mot de passe approprié ci-dessus, puis saisissez les caractères figurant dans l'image ci-dessous. -+Expiration de imminente -+Activer l'onglet précédent -+Désactiver l'accès à distance -+Afficher les incompatibilités -+Carte de débit Solo -+Actualisez cette page Web ultérieurement. -+Pour utiliser cette extension, saisissez "", TAB, puis votre commande ou votre recherche. -+ synchronisera les applications installées, afin que vous puissiez y accéder en vous connectant depuis tout navigateur . -+Langues et paramètres du correcteur orthographique... -+Erreur de sécurité -+Applications -+La ressource demandée n'existe plus et aucune adresse de transfert n'est disponible. Il semble que cet état de fait soit permanent. -+Certificat unique binaire codé DER -+&Plein écran -+Fichiers vidéo -+ indique que -+ NetNanny intercepte les connexions sécurisées. En général, cela -+ ne constitue pas un problème de sécurité, car le logiciel NetNanny s'exécute souvent -+ sur le même ordinateur. Toutefois, en raison de certaines incompatibilités avec -+ les connexions sécurisées Google Chrome, vous devez configurer NetNanny -+ de manière à éviter ces interceptions. Cliquez sur le lien En savoir plus pour obtenir des instructions. -+Vos onglets et activités de navigation -+Créer -+Turc -+Une erreur s'est produite lors de la tentative d'enregistrement du certificat client. Erreur  () -+Bienvenue dans -+Sélectionner -+Nom du modèle de certificat Microsoft -+Configuration de l'adresse IP pour -+Immortalisez votre plus beau sourire et utilisez la photo comme image de compte. -+Extension créée : -+ -+ -+Mot de passe incorrect. Veuillez réessayer. -+LEAP -+Échec de la connexion aux serveurs de reconnaissance vocale. -+Très grande -+Sélectionner le répertoire de l'extension -+&Téléchargements -+Gestionnaire des certificats -+ souhaite suivre votre position géographique -+Quitter -+ sur -+Proposer d'enregistrer les mots de passe -+Modification de l'affiliation -+par exemple : 1-5, 8, 11-13 -+(Activé par une stratégie d'entreprise) -+Qu'est-ce que c'est ? -+Les cookies de plusieurs sites ont été bloqués. -+Serveur DNS spécifié par l'utilisateur et utilisé par Google Chrome, à la place du paramètre système par défaut, pour les résolutions DNS. -+Désactivé -+Annuler -+Répertoire racine de l'extension : -+Mode de saisie du vietnamien (TCVN6064) -+Échec de l'activation -+Ajouter cette page aux favoris -+L'identité de ce site Web a été vérifiée par . -+Adresse e-mail : -+Activation... -+PAP -+Sites de phishing -+ secs ago -+Interdire à tous les sites d'exécuter JavaScript -+Vouliez-vous accéder à  ? -+La connexion avec le service de configuration a été perdue. Veuillez réinitialiser votre périphérique ou contacter votre représentant de l'assistance technique. -+Paramètres des fenêtres pop-up : -+Tout exporter... -+Barre de favoris -+Stocké dans : -+Développer... -+Gin Yieh -+Rechercher sur -+Modifier la carte de paiement -+Au démarrage -+Nous examinons actuellement le problème. -+Notifications -+Navigateur -+Case d'option décochée -+ days -+Anglais -+Modifier le nom du dossier -+Grammaire et orthographe -+Réseaux privés -+Toutes sortes de connexions -+Exceptions liées aux notifications -+Épingler les onglets -+Barre d'onglets -+Activer l'onglet 6 -+Gestionnaire de &tâches -+Paramètres de stockage d'Adobe Flash Player... -+Connexion au réseau -+Mode de saisie du vietnamien (VNI) -+L'application suivante va être lancée si vous acceptez cette requête :\n\n -+Importation... -+N° de carte -+Gérer les moteurs de recherche... -+Utiliser un moniteur externe -+Gravure de l'image en cours... -+État -+Éteindre -+Enregistrer les fichiers dans le dossier : -+Fermer les autres onglets -+Répertoire de fichiers -+Masquer les autres -+Annuler l'épinglage des onglets -+Plus -+Échec de la vérification de la révocation -+Ajouter www. et .com, puis ouvrir la page -+Pour inspecter un pop-up, cliquez avec le bouton droit sur la page ou sur l'icône d'action du navigateur, puis sélectionnez Inspecter le pop-up. -+&Répéter -+ est à présent activé. a enregistré les imprimantes installées sur cette machine en les associant à <b></b>. Vous pouvez désormais utiliser vos imprimantes depuis n'importe quelle application Web ou mobile associée à . -+Le serveur de -+ est introuvable, car la résolution DNS a échoué. DNS est le service Web qui -+ traduit les noms de site Web en adresses Internet. Cette erreur est -+ généralement due à l'absence de connexion Internet ou à une configuration -+ incorrecte du réseau. Cela peut également venir d'un serveur DNS qui ne -+ répond pas ou d'un pare-feu interdisant l'accès de -+ -+ au réseau. -+ZGPY -+Impossible de charger le fichier css "" du script de contenu. -+Créer des raccourcis vers des applications aux emplacements suivants : -+Moyenne -+Envoyé pour : -+Aider Google à détecter les logiciels malveillants en envoyant des données supplémentaires concernant les sites pour lesquels cet avertissement s'affiche. Ces données seront gérées conformément aux règles définies sur la page . -+[répertoire parent] -+Touches de sélection du clavier Hsu -+Copie de l'image de récupération... -+Tout supprimer -+Seule une personne en possession de votre mot de passe multiterme peut lire vos données chiffrées. Google ne reçoit ni n'enregistre votre mot de passe multiterme. Si vous oubliez votre mot de passe multiterme, vous devrez réinitialiser la synchronisation. -+Ouvrir dans une nouvelle fenêtre -+Dommage... Aucune extension n'est installée. :-( -+Style de ponctuation -+Historique de navigation -+Ce site tente de télécharger plusieurs fichiers. Voulez-vous autoriser le chargement ? -+Établissement de la liaison avec le service de gestion des périphériques en attente... -+ heures -+Ne pas utiliser les paramètres du proxy pour les hôtes et domaines suivants : -+&Avancer -+Impossible de charger "" pour le plug-in. -+À propos du système -+Utilisation de la clé du certificat : -+Mode de saisie du chinois (quick) -+Une erreur s'est produite lors de la tentative d'écriture du fichier : . -+Renommer -+La synchronisation requiert votre attention. -+Aujourd'hui -+Imp&rimer le cadre... -+Le site a déjà été informé qu'un logiciel malveillant a été détecté sur ses pages. Pour plus d'informations concernant les problèmes rencontrés sur , consultez notre Google. -+Adresse de serveur DNS spécifiée par l'utilisateur. -+&Rechercher... -+, -+&Afficher dans le dossier -+Non connecté à Internet. -+Sélectionnez -+ -+ Démarrer > Panneau de configuration > Connexions réseau > Assistant Nouvelle connexion -+ -+ pour tester votre connexion. -+Cette icône s'affiche lorsque l'extension peut agir sur la page active. -+Reconnexion -+Réponses OCSP de signature -+Erreur d'importation de l'autorité de certification -+Gravure de l'image terminée. -+&Historique -+Installer -+Ajouter des utilisateurs -+Enregistrer l'authentification et le mot de passe -+Clavier norvégien -+Basculer en mode chinois/anglais -+Traduction de la page en ... -+À propos de & -+ onglets -+il y a  minutes -+Qu'est-ce que c'est ? -+Tout &sélectionner -+&Ajouter au dictionnaire -+Utilisation étendue de la clé -+Le chinois est la langue de saisie initiale -+Agent utilisateur -+Émetteurs de l'autorité de certification : -+ jours -+Code source -+Redémarrer maintenant -+La largeur de caractères initiale est Complète -+Pour masquer l'accès à ce programme, vous devez le désinstaller au moyen de \n du Panneau de configuration.\n\nSouhaitez-vous exécuter  ? -+Paramètres du microphone -+Port -+&Toujours ouvrir les fichiers de ce type -+Uniquement les connexions sécurisées -+Les informations de connexion au compte sont obsolètes. -+La traduction a échoué, car la page est déjà en . -+Sandbox SUID -+(vide) -+Échec de l'authentification basée sur le certificat -+Envoyer le code source de la page actuelle -+Votre administrateur a désactivé certains paramètres. -+Coréen -+Avertissement : Il s'agit peut-être d'un site de phishing ! -+Dvorak -+Étendue de pages incorrecte -+ heures restantes -+Exceptions liées aux cookies et aux données de site -+ n'est pas accessible -+P&lus grand -+Connecté à -+Le certificat de sécurité du site a été révoqué ! -+Désactiver -+ risque de ne pas rester à jour. -+intégré sur tout autre site -+ -+ ne parvient pas à atteindre le site Web. Cela vient probablement d'un problème de réseau, -+ mais peut également être dû à un pare-feu ou à un serveur proxy mal configuré. -+À propos de la reconnaissance vocale -+Langues et paramètres du correcteur orthographique... -+ seconde restante -+Nom d'utilisateur : -+Le stockage des cookies n'est pas autorisé pour cette page. -+JavaScript -+La connexion utilise . -+Échec de l'installation -+Afficher les &infos sur la page -+Serveurs -+Système de fichiers de chiffrement Microsoft -+Un plug-in supplémentaire est requis pour afficher certains éléments sur cette page. -+Appuyez sur Ctrl+Alt+/ ou sur Échap pour masquer -+Cette fonctionnalité effectue des vérifications en arrière-plan et vous avertit en cas d'incompatibilité logicielle (modules tiers bloquant le navigateur, par exemple). -+Connexion avec -+Imprimer depuis la boîte de dialogue système… -+ heure restante -+Échec de l'initialisation de l'appareil photo -+Importés -+Type de fournisseur : -+IP restreinte : -+Refuser -+Démarrage du téléchargement en cours... -+Une nouvelle version de est disponible. -+Clavier hébreu -+Police à largeur fixe -+Safari -+Les champs obligatoires ne doivent pas rester vides. -+Ouvrir une fois le téléchargement &terminé -+Stratégies de certificat -+Pavé tactile -+Aucun -+Activer la barre d'adresse en mode recherche -+Exceptions pour JavaScript -+Ouvrir dans une nouvelle fenêtre -+Veuillez saisir le code PIN. -+Options de saisie automatique... -+Arabe -+Nouveau dossier -+E/S réseau interrompue -+Rechercher le précédent -+Ne jamais enregistrer les mots de passe -+Ouvrir dans un nouvel onglet -+Fenêtre suivante -+&Rechercher le suivant -+JCB -+Signature de liste d'approbation Microsoft -+Gérer les certificats... -+Sélectionnez le fichier de certificat. -+Fabricant : -+Bloquer le contenu inapproprié -+Le fichier contenait plusieurs certificats, dont certains n'ont pas été importés : -+Exceptions pour les images -+Autoriser tous les sites à afficher des fenêtres pop-up -+Vous devez indiquer un chemin valide comme valeur de clé privée. -+Sans mot de passe multiterme, vos mots de passe et autres données chiffrées ne seront pas synchronisés sur cet ordinateur. -+Extensions ou applications -+Ce site recommande Google Chrome Frame (déjà installé). -+Les plus visités -+Vous n'êtes pas autorisé à vous connecter. Consultez le propriétaire de cet ordinateur portable. -+Remarque : Lorsque vous cliquez sur "Envoyer", Google Chrome joint à votre -+ envoi un journal indiquant votre version de Google Chrome et celle du système -+ d'exploitation utilisé, ainsi que l'URL associée à votre rapport. Vous pouvez -+ également joindre une capture d'écran. Ces informations nous -+ permettent de diagnostiquer les problèmes et d'améliorer les performances de -+ Google Chrome. Les informations personnelles fournies sciemment dans vos -+ commentaires ou involontairement dans le journal, l'URL ou la capture -+ d'écran sont protégées conformément à nos règles de -+ confidentialité. Si vous ne souhaitez pas indiquer d'URL et/ou de capture -+ d'écran, décochez les cases "Inclure cette URL" et/ou "Inclure cette capture d'écran". Vous acceptez que Google utilise vos commentaires pour améliorer ses produits ou services. -+Vos modifications seront prises en compte au prochain démarrage de . -+Taille de police minimale -+Entrée directe -+Fermer la fenêtre -+Mode de saisie du japonais (pour clavier japonais) -+Inscription réussie -+Échec de création du fichier zip temporaire lors de la création du pack -+Modifier les paramètres de confiance : -+Votre historique de navigation -+&Masquer le panneau de la vérification orthographique -+Plug-in ne répondant pas -+IBM -+Les paramètres seront effacés lors de la prochaine actualisation. -+ introuvable -+Démarrage... -+Nouvelle fenêtre de nav&igation privée -+Ajouter une adresse postale... -+Authentification en cours... -+Ouvrir dans un nouvel onglet -+Déconnecté -+Action du navigateur -+Le mot de passe multiterme saisi ne peut pas être utilisé, car vous avez déjà chiffré des données avec un mot de passe multiterme. Entrez ci-dessous le mot de passe multiterme actuellement défini pour la synchronisation. -+Ouvrir cette page : -+Voulez-vous vraiment supprimer tous les mots de passe ? -+Sélectionner par domaine -+Ouvrir le lien dans une fenêtre en navi&gation privée -+Émetteur -+Options de saisie automatique -+Les nouveaux paramètres des cookies seront appliqués quand vous aurez actualisé la page. -+Votre connexion à est sécurisée par un chiffrement bits. -+Menu Applications -+Outi&ls -+Onglets latéraux -+Reprendre -+Zoom -+Inspecteur de DOM -+Document sans titre -+Police standard -+Activer -+Opération en cours... -+C&opier l'URL de l'image -+La saisie automatique des numéros de carte de paiement est désactivée, car la connexion utilisée par ce formulaire n'est pas sécurisée. -+Enregistrer le &cadre sous... -+Général -+Défaillance -+Demander -+Coller l'URL et y a&ccéder -+Pour plus de sécurité, va chiffrer vos mots de passe. -+Si vous avez oublié votre mot de passe multiterme, vous devrez arrêter la synchronisation via Google Dashboard. -+ sur  -+Adresse ligne 1 -+Impossible de créer le favori. -+Basculer en mode chinois simplifié/traditionnel -+Votre système Sandbox n'est pas correctement configuré. -+Sélectionnez le menu clé à molette > Préférences > Options avancées > Modifier les paramètres du proxy et vérifiez que vos paramètres sont définis sur "sans proxy" ou "direct". -+Impossible de vérifier si le certificat a été révoqué. -+Stockage des données -+/, Interrompu -+Acheter un forfait -+Installer le plug-in... -+Afficher le code source -+Fermer les onglets sur la droite -+Afficher le bouton "Accueil" -+Version  -+Parenthèse gche -+Microsoft Server Gated Cryptography -+Zoom avant -+Protection du courrier électronique -+Les cookies suivants ont été bloqués (tous les cookies tiers sont bloqués, sans exception) : -+Connectez-vous à pour importer le certificat client de -+La batterie est chargée. -+Créer un nouveau profil... -+Maintenez la touche enfoncée pour quitter. -+Masquer ce plug-in -+Ouvrir le fichier -+Conteneur de barres d'infos -+Le certificat du serveur a expiré. -+Utiliser -+Réduit la taille du texte -+Épingler l'onglet -+Mise à jour du système -+ days left -+Inclure les informations système -+Google Chrome n'avait pas suffisamment de mémoire ou le processus de la page Web a été arrêté pour une autre raison. Pour continuer, actualisez la page ou ouvrez-en une autre. -+Impossible de valider votre mot de passe sur le réseau actuel. Sélectionnez un autre réseau. -+Cette page n'est pas rédigée en  ? Signaler l'erreur -+Certificat unique codé Base 64 ASCII -+Activer le mode plein écran -+Codag&e -+ est déjà utilisé pour gérer les liens ://. -+Touches de sélection -+Clavier international américain -+Je comprends que la visite de ce site peut être préjudiciable à mon ordinateur. -+Ressource cache manquante. -+Impossible d'accéder à mon compte -+C&opier l'URL de la vidéo -+Vous préférez parcourir la galerie ? -+Impossible de vérifier le certificat du serveur. -+Outils de &développement -+Exporter... -+Paramètres de saisie automatique -+Téléchargement de l'image en cours... -+&Options du vérificateur d'orthographe -+Impossible d'ouvrir votre profil correctement.\n\nIl est possible que certaines fonctionnalités ne soient pas disponibles. Vérifiez que ce profil existe et que vous disposez d'une autorisation d'accès à son contenu en lecture et en écriture. -+Vérifier le document maintenant -+Zone de liste -+Clavier slovène -+Sens de l'écriture -+Vos données sur -+Ouvrir une fenêtre du navigateur -+Conversion de la date et de l'heure -+PKCS #1 SHA-512 avec chiffrement RSA -+Clavier coréen -+Dupliquer -+Ne pas conserver sur cette page -+Désactiver -+ATOK -+téléchargement -+E-mail : -+Ouvrir tous les favoris dans une nouvelle &fenêtre -+Rafraîchir la page actuelle -+Accessibilité -+Exceptions pour les plug-ins -+Remplissage automatique des formulaires -+Nom d'utilisateur -+Enregistrer le lie&n sous... -+Réessayer -+Personnaliser et configurer -+Préférences de saisie automatique -+Votre position géographique -+Afficher les pages en arrière-plan () -+Configurer les mises à jour automatiques -+il y a  heures -+Valeur du champ -+Les dernières versions d'Unity et GNOME (ainsi que la prochaine version d'Ubuntu, Natty Narwhal) affichent une barre de menus de type OSX sur toute la largeur supérieure de l'écran. -+Index erroné. -+Préparation du module de plate-forme sécurisée (TPM) en cours. Veuillez patienter, l'opération peut prendre quelques minutes. -+Nombre de copies incorrect -+Personnaliser -+Prédire les actions du réseau pour améliorer les performances de chargement des pages -+Données restantes : -+N'est pas une autorité de certification. -+L'URL doit être valide. -+Envoyer automatiquement les statistiques d'utilisation et les rapports d'erreur à Google -+Cette fonctionnalité active la géolocalisation dans les extensions expérimentales. Cela implique l'utilisation des API de localisation du système d'exploitation (si disponibles) et l'envoi de données sur la configuration réseau locale au service de localisation de Google afin de déterminer une position précise. -+Impossible de charger le profil. -+Toujours exécuter JavaScript sur -+Version PRL : -+Confirmer la réactivation -+Ajouter une adresse postale... -+PKCS #1 MD2 avec chiffrement RSA -+Dim.^Lun.^Mar.^Mer.^Jeu.^Ven.^Sam. -+Zone de saisie -+Trier par nom -+Fenêtre -+Nouvel onglet -+Vous tentez d'accéder au site , mais le certificat présenté par le serveur a été révoqué par son émetteur. Cela signifie que les informations d'identification présentées par le serveur ne sont pas approuvées. Vous communiquez peut-être avec un pirate informatique. Nous vous déconseillons vivement de continuer. -+Composition hors écran -+ mins left -+Technologie : -+Accédez à la page d'accueil du site : -+Configurer la communication à distance -+L'émetteur d'un certificat n'ayant pas expiré est tenu d'assurer la maintenance de ce qui s'appelle "une liste de révocation". Si un certificat est compromis, l'émetteur peut le révoquer en l'ajoutant à la liste de révocation. Ce certificat n'est alors plus approuvé par votre navigateur. Il n'est pas nécessaire d'assurer la maintenance de l'état "révoqué" des certificats expirés. Donc, bien qu'un certificat ait été qualifié de valide pour le site Web que vous visitez actuellement, il est impossible de déterminer s'il a été, depuis, compromis puis révoqué ou s'il est toujours valide. Par conséquent, il n'est pas possible de s'assurer si vous communiquez avec un site Web légitime ou si le certificat a été compromis et se trouve maintenant en la possession d'un pirate informatique avec lequel vous communiquez. Ne poursuivez pas. -+Néanmoins, si vous travaillez dans une entreprise qui génère ses propres certificats, et que vous essayez de vous connecter au site Web interne de l'entreprise avec un certificat de ce type, vous pouvez résoudre ce problème en toute sécurité. Pour ce faire, importez le certificat racine de l'entreprise en tant que "certificat racine". Par la suite, les certificats émis ou vérifiés par votre entreprise seront approuvés et vous ne verrez plus cette erreur lorsque vous tenterez de vous connecter à nouveau au site Web interne. Contactez le support informatique de votre entreprise pour savoir comment ajouter un nouveau certificat racine sur votre ordinateur. -+Définir en tant que navigateur par défaut -+Avertissement -+Préférences de recherche -+Clavier Colemak américain -+Activer la navigation en tant qu'invité -+Utiliser les paramètres par défaut -+Rétablir -+Désinstaller "" ? -+Établissement de la connexion sécurisée... -+Dossier : -+Erreur non reconnue -+Consultez les conflits connus avec des modules tiers. -+Co&ller et rechercher -+&Remonter -+Échec de la traduction en raison d'une erreur de serveur -+Version : -+Polices et codage -+ - -+Signature du code commercial Microsoft -+Sélectionnez les éléments à importer : -+De gauche à droite -+Votre connexion à est sécurisée par le biais d'un faible chiffrement. -+sans objet -+Toujours afficher la barre de favoris -+Activer l'onglet 2 -+Aperçu des onglets -+Redémarrer -+Configuration en cours... -+Une erreur s'est produite lors de la récupération des fonctions de l'imprimante . Cette imprimante n'a pas pu être enregistrée dans . -+Exceptions pour les fenêtres pop-up -+Signataire du certificat -+La page Web n'existe plus. -+Vous n'avez jamais visité ce site auparavant. -+Personnaliser... -+Fe&rmer la fenêtre -+Arrêter le chargement de cette page -+Autres favoris -+ a été mis à jour. -+Mode hors connexion -+Erreur d'importation de fichier PKCS #12 -+Algorithme de clé publique de l'objet -+Le site Web a rencontré une erreur lors de l'extraction de . -+ Cela peut être dû à une opération de maintenance ou à une configuration incorrecte. -+Échec du chargement de la page -+Mot de passe : -+Conserver en tant que moteur de recherche par défaut -+Fichier manifeste absent ou illisible -+La connexion a été réinitialisée. -+Le mot de passe choisi vous sera demandé pour restaurer le fichier. Veillez à le conserver en lieu sûr. -+La vérification de la provenance du certificat DNS est activée, ce qui peut entraîner l'envoi d'informations privées à Google. -+À propos de la reconnaissance vocale -+Aller à la sélection -+Ajouter un certificat -+Espaces de noms PID -+Préférences de saisie automatique -+Activer l'onglet 8 -+Le certificat "" représente une autorité de certification. -+Envoyer par e-mail l'emplacement de la page -+Enregistrement des informations de date Microsoft -+Validité -+&Traduire en -+Batterie :  % -+Désactivé -+Japonais -+ () -+L'application est actuellement inaccessible. -+Lecteur du certificat : -+ jour restant -+Gestionnaire de tâches -+Gérer les extensions... -+Continuer -+Synchronisation avec effectuée. Dernière synchronisation : -+Le certificat de sécurité du site n'est pas encore valide ! -+Ouverture de session par carte à puce Microsoft -+Format -+Tapez votre requête ou saisissez une URL pour commencer la navigation : c'est à vous de choisir. -+Enregistrer &sous... -+Le serveur requiert un nom d'utilisateur et un mot de passe. -+Supprimer tous les mots de passe -+Le certificat du serveur contient des erreurs. -+Recherche de réseaux Wi-Fi... -+Description : -+Séparateur -+Si vous supprimez l'un de vos propres certificats, vous ne pouvez plus l'utiliser pour vous identifier. -+Rafraîchir cette page -+État d'activation : -+Créer des raccourcis vers des applications -+Clavier franco-suisse -+GUID de domaine Microsoft -+Entrer -+Supprimer -+Échec de l'enregistrement de cet ordinateur pour l'accès à distance. -+Ouvrir l'&image dans un nouvel onglet -+Préférences... -+L'administrateur a désactivé les mises à jour. -+À propos de la version -+Veuillez nous indiquer ce qu'il se passe avant d'envoyer votre rapport. -+Connectez-vous à afin de générer une clé pour . -+Clavier roumain -+Autres -+Sécurité : -+Imprimer -+Mode de saisie standard -+Signature -+Erreur lors de la connexion -+Pour cette session uniquement -+Une erreur s'est produite. -+(Désactivé par une stratégie d'entreprise) -+Erreur lors de la tentative d'impression. Vérifiez votre imprimante et réessayez. -+Grec -+Ignorer les exceptions et bloquer l'enregistrement des cookies tiers -+Cet outil vous permet de sélectionner une capture d'écran enregistrée. Aucune capture d'écran n'est disponible pour le moment. Appuyez simultanément sur Ctrl et sur la touche "Mode Présentation" pour enregistrer une capture d'écran. Vos trois dernières captures apparaissent ici. -+Activation effectuée -+Aucun système de révocation trouvé -+Bouton -+Interrompu -+Dictionnaire de symboles -+Technologie EvDo requise -+Internet mobile -+Envoyer le commentaire -+Associé au profil Chrome . Dernière synchronisation : -+Carte de crédit (autre) -+Langues et saisie -+Utiliser la barre de titre et les bordures de fenêtre du système -+Ann&uler -+ () -+Le serveur a refusé d'exécuter la demande. -+ Ko -+ a été mis à jour vers la version . -+Navigateur de contenu -+&Rouvrir la fenêtre fermée -+Se connecter directement à Internet -+Émis pour -+Ouverture de en cours -+Cibles disponibles pour l'image -+Signaler un problème -+Taille de police : -+Aide pour la configuration de proxy -+Petite -+ hours ago -+Rester sur cette page -+Type de bug : -+Inclure cette URL : -+Cookies et données de site... -+Police Serif -+Avertissement : ne peut pas empêcher les extensions d'enregistrer votre historique de navigation. Pour désactiver cette extension en mode navigation privée, désélectionnez-la. -+ChromiumOs Image Burn -+Services -+Paramètres du proxy... -+1 onglet -+Vous naviguez en tant qu'invité. Les pages que vous consultez dans cette fenêtre n'apparaîtront pas dans l'historique de votre navigateur ni dans votre historique des recherches. Les autres traces telles que les cookies seront supprimées de l'ordinateur à la fin de votre session. En revanche, les fichiers téléchargés et les favoris créés seront conservés. -+ -+ En savoir plus sur le mode invité -+Chargement des pages impossible -+Inclure cette capture d'écran : -+Certificat -+&Effacer les données de navigation... -+Valeur de signature du certificat -+URL de renouvellement du certificat Netscape -+Afficher la s&ource -+ - , -+Reprendre -+ secs ago -+Activé -+Carte SIM désactivée -+Compatibilité avec VPN -+Développement - Instable -+Échec de création du raccourci vers l'application -+Barre de favoris -+Le serveur est en mesure de répondre à la demande. -+Modifier les paramètres du proxy... -+(non empaquetée) -+Rechercher le suivant -+Paramètres réseau -+Votre service Internet mobile est activé et prêt à l'emploi. -+Modifier la police et la langue par défaut des pages Web -+Composition graphique avec accélération matérielle -+Autre nom de l'émetteur du certificat -+ -+&Afficher le code source du cadre -+Mode de saisie du persan (clavier ISIRI 2901) -+OpenVPN -+Arrêter le processus -+Votre compte a peut-être été supprimé ou désactivé. Veuillez vous déconnecter. -+Authentification anonyme : -+Bases de données indexées -+En savoir plus sur les escroqueries par phishing -+Page à l'apparence anormale -+Adresse e-mail ou mot de passe incorrect. Essayez tout d'abord de vous connecter à un réseau. -+Périphérique -+Informations sur la connexion -+Confirmer la navigation -+Nom du point d'accès : -+Rechercher -+Au démarrage -+Paramètres... -+Lire en un clic -+Connectez-vous à pour vous authentifier auprès de avec votre certificat. -+Votre administrateur informatique a désactivé certaines options. -+Supprimer le certificat de serveur ""? -+Configurer la synchronisation... -+Valider automatiquement une chaîne -+Empreinte SHA-256 -+Retour -+Réseau domestique, sans itinérance -+ - -+Gérer les mots de passe enregistrés... -+Sélectionnez -+ -+ Menu clé à molette > Options > Options avancées > Modifier les paramètres du proxy > Paramètres réseau -+ -+ et désélectionnez l'option "Utiliser un serveur proxy pour votre réseau local". -+Ne jamais traduire ce site -+(suite) -+Trop de redirections -+Ces paramètres ne peuvent être modifiés que par le propriétaire : -+Active la protection XSS Auditor de WebKit (protection contre le Cross-site Scripting), une fonctionnalité qui vous protège de certaines attaques de sites malveillants et offre une sécurité accrue, mais qui n'est pas compatible avec tous les sites Web. -+Clavier latino-américain -+Phishing détecté ! -+Voulez-vous utiliser () pour gérer les liens :// à partir de maintenant ? -+ (Navigation privée) -+Prendre une photo -+Non merci -+Ne pas afficher les images -+Toujours autoriser ces plug-ins sur -+Sélectionner un dossier -+&Paramètres -+Informations sur l'erreur : -+Toujours autoriser les plug-ins sur -+Effacer les données de saisie automatique enregistrées -+Changer de moteur de recherche -+En attente du tunnel proxy... -+Veuillez ajouter un autre mode de saisie avant de supprimer celui-ci. -+ secondes -+Paramètres de contenu -+Impossible d'extraire les fichiers de l'extension. Pour effectuer cette opération en toute sécurité, vous devez disposer d'un chemin d'accès à votre répertoire de profils commençant par une lettre de lecteur et ne contenant ni jonction, ni point de montage, ni lien symbolique. Aucun chemin de ce type n'existe pour votre profil. -+ va être installé. -+Code postal -+En bas à droite -+&Ouvrir -+ téléchargé(s) sur -+Commentaires d'ordre général/Autres -+Ou&vrir la vidéo dans un nouvel onglet -+Identité : -+Échec de l'opération OTASP -+Action sur la page -+Modifier des éléments... -+Le répertoire d'extensions est obligatoire. -+ Mo disponibles -+Ancien -+ fournit du contenu provenant de , un site connu pour distribuer des logiciels malveillants. Votre ordinateur pourrait être infecté par un virus si vous consultez ce site. -+Ces fonctionnalités expérimentales sont susceptibles d'être modifiées, interrompues ou supprimées à tout moment. Nous ne fournissons aucune garantie quant aux effets de leur activation. Votre navigateur pourrait bien prendre feu. Trêve de plaisanterie, il est possible que votre navigateur supprime toutes vos données ou que votre sécurité et votre vie privée soient compromises de manière inattendue. Nous vous prions d'agir avec précaution. -+Configuration manuelle du proxy -+Mettre à jour Adobe Reader maintenant -+ days ago -+Désactiver les plug-ins individuels... -+Envoyer une capture d'écran de la page en cours -+Point d'exclamation -+ n'est plus à jour, car il n'a pas été relancé depuis quelque temps. La mise à jour disponible sera installée dès que vous le relancerez. -+Petit problème... Tentons de le résoudre. -+Cette fonctionnalité permet d'établir des correspondances entre les sous-chaînes et plusieurs fragments d'URL figurant dans l'historique. -+Page "Nouvel onglet" expérimentale -+Les cookies suivants étaient autorisés lorsque vous avez consulté cette page : -+votre opérateur -+Activer ces fonctionnalités... -+Quitter Firefox avant l'importation -+Ajouter un nouveau téléphone -+Proxy HTTP sécurisé -+Accès à refusé. -+Finalisation de la mise à jour du système... -+Voulez-vous continuer ? -+ Ko ( Ko effectifs) -+Autre réseau Wi-Fi... -+Choisir un autre répertoire... -+L'extension indiquée est déjà associée à une clé privée. Utilisez cette clé ou supprimez-la. -+Ajouter une adresse -+Stockage local -+Afficher tous les téléchargements -+Navigateur de contenu -+Magasin de certificats -+Émis par -+Quitter le mode plein écran () -+Le certificat du serveur a été signé avec un algorithme de signature faible. -+Ajouter un utilisateur -+Me proposer de traduire les pages qui sont écrites dans une langue que je ne sais pas lire -+Récemment fermés -+Saisir la clé de déverrouillage du code PIN -+ jours -+Rechercher du texte -+Sans-Serif -+Zoom &avant -+Confirmer le nouvel envoi du formulaire -+ heure -+Cet élément doit être installé depuis . -+Mise en veille ou reprise -+Mettre à jour maintenant -+Ajouter une page -+Chiffrer seulement -+Ne jamais intervertir les touches de modification -+Conversion des numéros spéciaux -+Relancer maintenant -+Synchronisation avec effectuée -+il y a  minute -+Édition -+Préférences synchronisées -+ hours ago -+Personnalisé -+Rechercher à partir de la barre d'adresse -+Ouvrir -+Inspecter les vues actives : -+Contraintes de nom du certificat -+Ajouter une adresse -+Mot de passe incorrect. -+Statistiques avancées -+Clavier espagnol -+Sélectionnez votre réseau -+ jour -+Le serveur de synchronisation est occupé. Veuillez réessayer ultérieurement. -+Quitter cette page -+Naviguer en tant qu'invité -+Discover -+&Toujours afficher la barre de favoris -+Options de recherche -+Taille : -+il y a  secondes -+La liste suivante fait état des éléments dangereux détectés sur la page. Cliquez sur le lien "Diagnostic" pour obtenir plus d'informations sur une ressource particulière. Si une ressource a été signalée comme site de phishing alors que vous êtes certain de sa fiabilité, cliquez sur le lien "Signaler une erreur". -+Cette page rédigée dans une langue non identifiée a été traduite en . -+Les exceptions ci-dessous s'appliquent uniquement à la session de navigation privée actuelle. -+Ne plus afficher la boîte de dialogue pour les liens de ce type -+ secondes restantes -+Insérez dans l'URL où les termes de recherche devraient apparaître. -+En&registrer la vidéo sous... -+Nom : -+Si vous rencontrez des problèmes fréquents avec ce module, vous pouvez tenter d'y remédier en suivant la procédure ci-après : -+Informations relatives au certificat -+Activer l'onglet 7 -+En savoir plus sur ce problème. -+Version du matériel : -+Le site Web à l'adresse contient des éléments provenant de sites qui semblent héberger des logiciels malveillants. Ces derniers peuvent nuire à votre ordinateur ou agir à votre insu. Le simple fait de visiter un site hébergeant ce type de logiciels peut infecter votre ordinateur. Ce site héberge également des informations provenant de sites signalés comme étant des sites de phishing. Ces derniers incitent les internautes à divulguer des informations personnelles en se faisant passer pour des institutions de confiance, telles que des banques. -+Afficher la liste -+Désactivez l'affichage des messages de confirmation et le blocage de l'envoi des formulaires. -+Ce cadre a été bloqué, car il contient des éléments non sécurisés. -+Tout -+Kana -+Gérer les mots de passe enregistrés... -+Boîte de dialogue "Effacer les données de navigation" -+Mettre à jour les extensions maintenant -+Nouvelle application en arrière-plan installée -+Envoyer une capture d'écran de la page actuelle -+L'URL indiquée est incorrecte. -+Un problème est survenu lors de l'affichage de la liste des imprimantes. Certaines de vos imprimantes ne sont peut-être pas correctement enregistrées dans . -+Actuellement connecté -+La page que vous recherchez a utilisé des informations que vous avez envoyées. Si vous revenez sur cette page, chaque action précédemment effectuée sera répétée. Souhaitez-vous continuer ? -+Cette fonctionnalité indique la vitesse d'affichage réelle d'une page, en images par seconde, lorsque l'accélération matérielle est active. -+E&xporter... -+&Ouvrir un fichier... -+Configurer le contrôle d'accès pour vos périphériques -+Ouvrir un rapport de phishing -+Activer la barre d'adresse -+ secs ago -+Cartes de paiement -+Code opérateur : -+Erreur de connexion -+Vous avez la possibilité de désactiver ces services. -+Essayer d'afficher la page malgré tout -+Impossible d'établir une connexion sécurisée avec le serveur. Le serveur a peut-être rencontré un problème ou exige un certificat d'authentification du client dont vous ne disposez pas. -+Ajouter un nouveau nom -+Obtenir d'autres thèmes -+Rétablir les valeurs par défaut -+Aucun Plug-in installé. -+Action -+Extensions de fichier -+Les plus visités -+&Gestionnaire de favoris -+Caches des applications -+Cette langue est actuellement utilisée par . -+ % -+Empaqueter l'extension -+Activer l'onglet 5 -+Sélectionner le mode de saisie précédent -+Configurer le blocage de JavaScript... -+Réseaux mémorisés -+Impossible de se connecter à Internet. -+URL incorrecte -+Informations sur la sécurité -+Impossible d'installer l'application, car elle est en conflit avec "", qui est déjà installé. -+Votre périphérique n'est pas connecté. -+Fermer -+Accord de la clé -+ mins ago -+Vous ne trouvez pas ce que vous recherchez ? -+Désactivez l'envoi des pings de contrôle des liens hypertexte. -+En&registrer le fichier audio sous... -+Accédez rapidement à vos favoris en les ajoutant à la barre de favoris. -+Vérifier la grammaire et l'orthographe -+Épingler les onglets -+Sélectionner par type d'application -+assembler -+ souhaite devenir votre moteur de recherche. -+Utiliser l'historique d'entrée -+Fermer les onglets -+Voici quelques suggestions : -+Sélectionnez un ou plusieurs fichiers -+Afficher le panneau de la &vérification orthographique -+Veuillez relancer . -+Sans titre -+Pour saisir du texte, sélectionnez une langue et consultez la liste des modes de saisie disponibles. -+Ville -+Modifier... -+Réinitialiser la synchronisation -+Inclure une capture d'écran enregistrée : -+Tout supprimer -+Passer automatiquement en demi-chasse -+&Accéder à -+La capacité de ce périphérique de stockage est de . Veuillez insérer une carte SD ou une clé USB d'au moins 4 Go. -+Rouvrir le dernier onglet fermé -+(blocage) -+Erreurs () -+Traitement de la sélection... -+Aide -+Désolé ! La visionneuse de documents PDF intégrée à Google Chrome, nécessaire à l'affichage de l'aperçu avant impression, n'est pas incluse dans Chromium. -+Impossible d'ouvrir , car vous êtes déconnecté du réseau. Cette page s'affichera dès que la connexion réseau sera rétablie. <br> -+Télécopie -+version -+La passerelle ou le serveur proxy a reçu une réponse incorrecte d'un serveur en amont. -+Nouvelle fenêtre ouverte dans la session du navigateur -+Réessayer -+ peut maintenant synchroniser vos mots de passe. Vos données seront chiffrées avec le mot de passe de votre compte Google ou le mot de passe multiterme de votre choix. -+Les paramètres réseau de votre proxy sont gérés par une extension. -+Retirer l'onglet -+Valable du au -+Case cochée -+Mode de saisie -+AVERTISSEMENT -+Clavier estonien -+Ajout de bordures aux couches de rendu composées -+Imp&rimer... -+Paramètres de saisie automatique -+Rafraîchir -+Barre d'outils -+Nom de la base de données : -+Certificat du répondeur d'état -+Utiliser le mot de passe de mon compte Google -+Vos favoris sont maintenant synchronisés avec Google Documents ! -+Pour fusionner et synchroniser vos favoris dans sur un autre ordinateur, procédez de la même manière que précédemment sur l'ordinateur voulu. -+Renommer... -+ a été désactivé. Si vous arrêtez la synchronisation des favoris, vous pouvez la réactiver sur la page des extensions, via le menu Outils. -+Affichage des pages impossible -+Utiliser par défaut -+La carte SIM est verrouillée. Veuillez saisir votre code PIN. Nombre de tentatives restantes : -+Point-virgule -+Réseau domestique requis -+PKCS #7, certificat unique -+Langues baltes -+Vous avez saisi un trop grand nombre de clés de verrouillage du code PIN incorrectes. Votre carte SIM est définitivement désactivée. -+Données de diagnostic système -+Page Web, contenu HTML uniquement -+Continuer » -+Gérez vos imprimantes. -+(Choisir un problème dans la liste ci-dessous) -+&Afficher le code source du cadre -+Authentification du client WWW TLS -+Les cookies de plusieurs sites sont autorisés. -+Impossible d'afficher la page de la barre latérale "". -+Vous avez acheté de données le . -+Enregistrer le mot de passe -+Configurer... -+Mode de saisie du pinyin -+Intervertir les touches Ctrl et Alt de gauche -+Confirmer le mot de passe multiterme -+Activer -+Ajouter... -+Voulez-vous que Google Chrome enregistre ces informations de carte de paiement pour le remplissage de formulaires Web ? -+Continuer à bloquer les fenêtres pop-up -+Échec de la vérification DHCP -+Choisir un autre dossier... -+Le profil semble être utilisé par le processus sur l'hôte . Si vous êtes certain qu'aucun autre processus n'utilise ce profil, supprimez le fichier et relancez . -+Chinois traditionnel -+Effacer les données de navigation... -+Ré&activer le son -+Aucun réseau trouvé. -+&Ouvrir le fichier audio dans un nouvel onglet -+&Méthodes d'entrée -+Onglets ou fenêtres -+Toutefois, cette page inclut d'autres ressources qui ne sont pas sécurisées. Ces ressources peuvent être consultées par des tiers pendant leur transfert, et modifiées par un pirate informatique dans le but de changer le comportement de cette page. -+Automatique -+&Extensions -+Roumain -+Paramètres du réseau... -+Changer... -+Clé privée -+Format : -+Se connecter -+ : -+Vous avez tenté de contacter , mais le certificat présenté par le serveur est incorrect. -+Nouvelle fenêtre de nav&igation privée -+La page à l'adresse indique : -+Le serveur associé à n'a pas répondu à temps. Cela peut être dû à une surcharge. -+L2TP/IPSec + Clé pré-partagée -+XSS Auditor -+Durée de validité -+WebGL -+Mot de passe multiterme erroné -+Corriger automatiquement la saisie -+Unité d'organisation -+Compte Google -+&Aide -+Utiliser un service de prédiction afin de compléter les recherches et les URL saisies dans la barre d'adresse -+Certificat du signataire de courrier électronique -+En savoir plus -+Vous avez enregistré vos imprimantes sur via le compte . -+il y a  jours -+: restantes -+Cette page est enVoulez-vous la traduire ? -+Saisie automatique des formulaires -+Clavier ukrainien -+Ouvrir tous les favoris dans une fenêtre de navigation privée -+Ctrl -+ minutes -+Le certificat de sécurité du serveur contient des erreurs ! -+avec votre compte Google -+Rechercher dans les favoris -+MSCHAPv2 -+Avertissement utilisateur -+&Options du vérificateur d'orthographe -+Échec de la connexion -+Identifiant de l'erreur -+ jours restants -+Émis par : -+Mode de saisie du thaï (clavier Kesmanee) -+Passerelle : -+Chiffrement -+Autre... -+Pas avant le -+ n'a pas pu synchroniser vos données, car la connexion avec le serveur de synchronisation n'a pas pu être établie. Nouvel essai... -+Me demander lorsqu'un site souhaite afficher des notifications sur le Bureau (recommandé) -+Source : -+Erreur de lecture du cache -+Raccourci de sélection -+Vérifier la révocation du certificat serveur -+Vous rencontrez des problèmes lors de l'installation ? -+Bêta -+Pointeur de la déclaration CPS (Certification Practice Statement) -+Le , vous avez reçu à utiliser librement. -+Nom complet -+Inscription d'entreprise -+Clavier allemand -+Impossible de lancer l'impression. -+&Lire -+Récent -+Cette page Web présente une boucle de redirection. -+Supprimer le certificat "" émis par l'autorité de certification ? -+Mots de passe enregistrés -+Moins -+Options avancées -+Vérifiez vos paramètres DNS. Contactez votre administrateur réseau si vous n'êtes pas sûr de vous. -+Une erreur inconnue s'est produite. -+Émetteur : -+Passer d'un mode de saisie à l'autre -+Organisation (O) -+PKCS #1 SHA-1 avec chiffrement RSA -+Entrez la requête de recherche ici. -+Application en mode navigation privée : -+La largeur de ponctuation initiale est Complète -+Installer  ? -+Installation d'une nouvelle version... -+Ouvrir le lien dans un nouvel ongle&t -+Pour accéder aux paramètres de sécurité, saisissez le code PIN de la carte SIM. -+Jamais -+Impossible d'accéder au réseau. -+Effacer le formulaire -+Échec de la mise à jour du système -+Saisissez le mot de passe utilisé pour chiffrer ce fichier de certificat. -+CHAP -+Enregistrer le lie&n sous... -+Effacer les données de navigation... -+Options de reconnaissance vocale -+Réseau câblé -+Nouvel ongle&t -+R&etour -+Téléchargement suspendu -+Ouvrir la page d'accueil -+Connexion -+L'installation de est terminée. -+&Outils -+Page d'accueil -+Clavier phonétique bulgare -+Cookies et données de site... -+Batterie faible -+Commentaires -+Package incorrect : "". -+ heures restantes -+Configurer les paramètres de blocage des images... -+Options -+ hours ago -+&Détails -+Masquer la barre de titre du système et utiliser les bordures -+Elle peut accéder aux éléments suivants : -+Confidentialité -+Objets : -+Paramètres d'entrée du japonais -+Sebeol-sik Final -+Veuillez vous connecter à Internet pour continuer. -+Afficher les &infos sur le cadre -+Fichier -+Cop&ier l'image -+Utiliser le même proxy pour tous les protocoles -+Masquer -+Requête de protocole externe -+Afficher -+Certains de vos certificats enregistrés identifient ces serveurs : -+Vous avez visité ce site pour la première fois le . -+Cliquer pour avancer, maintenir pour voir l'historique -+La dernière version de l'application "" requiert d'autres autorisations. Elle a donc été désactivée. -+ secondes -+Vous avez choisi d'ouvrir automatiquement certains types de fichiers après leur téléchargement. -+EAP-MD5 -+&Nouvelle fenêtre -++ -+Vous avez essayé d'accéder au site , mais le serveur a présenté un certificat signé avec un algorithme de signature faible. Il se peut que les informations d'identification fournies par le serveur aient été falsifiées. Le serveur n'est peut-être pas celui auquel vous souhaitez accéder (il peut s'agir d'une tentative de piratage). Nous nous déconseillons vivement de continuer. -+L'envoi de rapports d'erreur est désactivé. -+Clé WEP incorrecte -+Date d'expiration : -+URL de base du certificat Netscape -+Réduire... -+Rechercher dans l'historique -+Ouvrir le lien dans la fenêtre de navi&gation privée -+ secondes -+Historique avancé pour le champ polyvalent -+Active l'utilisation de graphismes 3D dans les éléments canvas via l'API WebGL. -+Occident -+État non reconnu -+ -+Impossible de vérifier si le certificat du serveur a été révoqué. -+Se connecter -+Fuseau horaire : -+Cette option est soumise à une stratégie d'entreprise. Contactez votre administrateur pour plus d'informations. -+Résultats de recherche pour "" -+Revenir à "" (redémarrage requis) -+ va exécuter les tâches suivantes : -+Ajouter la page -+Changement de mode via la touche Maj -+Options de date et d'heure... -+Nom DNS -+Build de développement -+ sur ... -+Verrouiller la carte SIM (code PIN obligatoire pour utiliser les données mobiles) -+Sélectionnez le répertoire racine de l'extension. -+Les cookies de sont autorisés uniquement pour cette session. -+Confirmer les préférences de synchronisation -+RSN -+Ajuster la conversion en fonction de l'entrée précédente -+Afficher le panneau de la &vérification orthographique -+(Revenir à la capture d'écran d'origine) -+Mettre à jour & -+SSID -+- -+Les informations de connexion au compte n'ont pas encore été saisies. -+URL de configuration automatique -+URL : -+Avancer -+ jours restants -+Vous avez choisi de ne pas synchroniser les mots de passe. Vous pouvez à tout moment modifier vos paramètres de synchronisation, si vous changez d'avis. -+Lancer -+ -+ ne parvient pas à accéder au réseau. -+ -+ Il est possible que votre pare-feu ou votre antivirus considère -+ -+ comme un intrus dans votre ordinateur et qu'il bloque ses tentatives de connexion à Internet. -+Ce certificat a été vérifié pour les utilisations suivantes : -+Petit problème ! Une erreur est survenue lors de l'inscription de ce périphérique. Veuillez réessayer ou contacter votre représentant de l'assistance technique. -+Ajouter aux favoris -+Gérer les certificats... -+Analyse du périphérique... -+PYJJ -+Web Store -+Annuler l'épinglage des onglets -+Favori -+Sélectionnez votre langue : -+Réessayer le téléchargement -+Configurer la synchronisation des mots de passe -+Nom d'utilisateur : -+Enregistrer la p&age sous... -+Vos données sur tous les sites Web -+Un problème est survenu lors de l'extraction de l'image sur l'ordinateur. -+Lancer l'application -+Dubeol-sik -+Remplacé -+Afficher les cookies et autres données de site... -+Si vous pensez avoir cerné les risques, vous pouvez . -+Apparence -+Créer des raccourci&s vers des applications... -+Exécuter le flash PPAPI dans le processus du moteur de rendu -+Définir en tant que navigateur par défaut -+Veuillez choisir un nouveau code PIN. -+ () -+Autre -+&Options -+Impossible de charger la page d'arrière-plan "". -+À quel niveau rencontrez-vous des problèmes ? (Champ obligatoire) -+Retour à la sécurité -+Eten -+Ce site répertorie tous ses certificats valides dans le système DNS. Un certificat non répertorié a cependant été utilisé par le serveur. -+Options de reconnaissance vocale -+Tout sélectionner -+Impossible de charger le fichier "" pour le script de contenu, car ce fichier n'est pas codé en UTF-8. -+&Annuler -+Désactiver temporairement la personnalisation des conversions, les suggestions basées sur l'historique et le dictionnaire utilisateur -+Les cookies de sont autorisés. -+Au fil du temps, la zone ci-dessous affichera les huit sites que vous avez le plus visités. -+Le plug-in a besoin de votre autorisation pour s'exécuter. -+Échec de création de clé privée -+Ouvrir tous les favoris dans une fenêtre de navigation privée -+Placer dans la file d'attente -+Erreur de certificat serveur inconnue -+Mode de saisie du coréen -+&Plein écran -+ -+ -+ Vous pouvez essayer de diagnostiquer le problème en procédant comme suit : -+ -+ -+Bienvenue sur votre page d'accueil ! -+Vos modifications seront prises en compte au prochain démarrage de . -+Adresse du matériel : -+Lecture seule -+Erreur d'importation du certificat serveur -+Données stockées localement -+Tous les fichiers de vont être effacés. -+Modèle du périphérique : -+Afficher dans le Finder -+Nom X.500 -+Vous devez sélectionner au moins un type de données à synchroniser. -+Tout afficher -+Ouvrir tous les favoris -+Clavier danois -+Cette fonctionnalité permet de réaliser un rendu hors écran de la texture, au lieu d'un affichage direct. -+Partiellement activé -+Votre système Sandbox est correctement configuré. -+Ne pas installer -+Activer la recherche instantanée pour accélérer la recherche et la navigation -+Utiliser par défaut -+Non essentielle -+Fenêtres pop-up -+Dernière modification : -+Désélectionné -+Sécurité -+Rechercher... -+Le script de la page utilisait trop de mémoire. Rafraîchissez la page pour réactiver le script. -+Signature du code individuel Microsoft -+Mozilla Firefox -+Page Web inaccessible -+Recadrer l'image -+Si vous fermez maintenant, le téléchargement sera annulé. -+Coller -+Retour -+Impossible de graver l'image. -+Mode de saisie du Chewing -+Province -+JavaScript a été bloqué sur cette page. -+Remarque : Lorsque vous cliquez sur "Envoyer", Google Chrome OS -+ joint à votre envoi un journal des événements système de -+ votre périphérique. Ces informations nous permettent de diagnostiquer les -+ problèmes, de comprendre comment vous interagissez avec votre -+ périphérique et d'améliorer les performances de ce dernier. Les -+ informations personnelles fournies sciemment dans vos commentaires ou -+ involontairement dans les journaux système et la capture d'écran sont -+ protégées conformément à nos Règles de confidentialité. -+ Si vous ne souhaitez pas envoyer de journaux système, décochez la case -+ "Inclure les informations système". -+Interdire à tous les sites de stocker des données -+Trier par nom -+Afficher un aperçu des onglets... -+Annuler l'importation -+Ce serveur envoie des données que ne comprend pas. Veuillez signaler un bug et inclure la liste des raw. -+Calcul de la durée restante -+Mode de saisie Google du japonais (pour clavier américain) -+Envoi de la requête... -+Parlez maintenant -+Impossible d'installer le package : "" -+Modèle : -+Bloquer tous les cookies tiers -+Remplacer par -+Espace -+Arrêt du fonctionnement -+Préférences -+Nom inconnu -+Nom -+Choisir un nouveau code PIN -+ [] -+Erreur d'exportation de fichier PKCS #12 -+Le répertoire racine de l'extension doit être indiqué. -+Miniature supprimée -+Tout développer... -+Aie aie aie -+Choisir les expressions en arrière-plan, sans déplacer le pointeur -+Plu&s petit -+Afficher le clavier en superposition -+C&opier l'URL de l'image -+OK -+Aucun réseau détecté -+Charger l'extension non empaquetée... -+page -+Active l'interface utilisateur et le code de support pour le processus du service de communication à distance, de même que le plug-in client. Avertissement : ce service n'est actuellement disponible que pour les tests de développeurs. Si vous ne faites pas partie de l'équipe de développement et ne figurez pas sur la liste blanche, aucun élément de l'interface utilisateur activée ne fonctionnera. -+Clavier turc -+Modifier le favori -+Couleur -+Personnaliser les paramètres de synchronisation... -+Activation de votre service Internet mobile -+ -+Ouvrir dans un onglet standard -+ - -+Portrait -+ days ago -+Active un service en arrière-plan qui connecte le service aux éventuelles imprimantes installées sur cet ordinateur. Une fois ce labo activé, vous pouvez lancer en vous connectant à votre compte Google via Options/Préférences dans la section Options avancées. -+Outils de &développement -+Le répertoire racine de l'extension est incorrect. -+ID de clé de l'objet du certificat -+Téléchargements -+Le stockage du certificat client généré par a réussi. -+Sélectionnée -+Suspendre -+Taille sur le disque : -+ID du processus -+Réduire -+Expire le -+Votre administrateur a désactivé l'accès aux fichiers locaux sur votre ordinateur. -+Erreur de connexion SSL -+Envoyer -+Virgule -+&Pause -+Parcourir... -+Mode de saisie Google du japonais (pour clavier Dvorak américain) -+Police à largeur fixe -+Stockage de session -+Page en arrière-plan : -+Le serveur a renvoyé un certificat client incorrect. Erreur  () -+Signature de document Microsoft -+Bloqué -+Gérer les paramètres d'impression... -+Cette page Web a désactivé la saisie automatique dans ce formulaire. -+Clavier hongrois -+Les versions en développement permettent de tester de nouvelles idées, mais elles peuvent s'avérer très instables. Nous vous prions d'agir avec précaution. -+Ajouter un dossier... -+Mode de saisie du japonais (pour clavier Dvorak américain) -+Signaler un bug -+&Toujours ouvrir les fichiers de ce type -+Disque optique -+Nom commun -+Très grande -+Modification terminée -+Objet -+Opérateur : -+Algorithme de signature du certificat -+Cette fonctionnalité permet d'afficher un onglet d'aperçu avant de lancer une impression. -+Autre nom de l'objet du certificat -+Activer la saisie automatique pour remplir les formulaires Web d'un simple clic -+Le site Web à l'adresse a été signalé comme étant un site de phishing. Ces sites tentent d'amener les internautes à divulguer leurs informations personnelles en se faisant passer pour des institutions de confiance, telles que des banques. -+Rechercher directement sur -+Connectez-vous à pour exporter le certificat client. -+Créer un compte Google maintenant -+État Sandbox -+Retirer de la liste -+rapide -+&Effacer les données de navigation… -+Vérification des mises à jour... -+Télécharger les mises à jour de sécurité essentielles -+Package incorrect. Détails : "". -+Continuer à bloquer les cookies -+Ligne de commande -+Coller l'URL et y a&ccéder -+Désactiver -+Build officiel -+Se connecter à un réseau Wi-Fi -+Périphérique inconnu -+Supprimer les cookies et autres données de site -+URL saisies -+Utiliser les touches , et . pour paginer une liste d'entrées -+Vider la mémoire -+Supprimer les éléments sélectionnés -+Toujours -+de moins d'une heure -+Aucun réseau n'est disponible. -+Supprimer les cookies et autres données de site et de plug-in -+Intervertir les touches Rechercher et Ctrl gauche -+Faites glisser trois doigts sur la surface de votre trackpad pour afficher un aperçu de tous vos onglets. Cliquez sur une vignette pour la sélectionner. Idéal en mode plein écran. -+Nouveau ! Configurer la synchronisation des mots de passe -+Échec de la tentative de connexion au serveur -+Désactiver les notifications de -+Les fichiers suivants ont été créés : -+ -+Extension : -+Fichier de clé : -+ -+Conservez votre fichier de clé en lieu sûr. Vous en aurez besoin lors de la création de nouvelles versions de l'extension. -+&Oui -+Ouvrir les fichiers -+Clavier suédois -+Mémoire JavaScript -+Quitter le mode plein écran -+Hiérarchie des certificats -+Afficher l'onglet existant si l'URL associée est demandée dans un autre -+&Afficher -+Vos données personnelles sur , et sur  autres sites Web -+SMS de -+Afficher la s&ource -+Zoom arrière -+C&opier l'URL du fichier audio -+Importer et associer au périphérique... -+() () -+Plug-ins (par ex. Adobe Flash Player, QuickTime, etc.) -+Empaqueter l'extension... -+Vérifier l'orthographe lors de la frappe -+Échec de la traduction en raison d'un problème de connexion réseau -+Code PIN incorrect. Veuillez réessayer. Nombre de tentatives restantes : -+Vous pouvez effectuer une recherche directement à partir du champ ci-dessus. -+Ajouter les expressions au premier plan -+Lorem ipsum dolor sit amet, consectetur adipiscing elit. -+Opérateur -+Confirmer l'installation -+(Mot clé : ) -+Sensibilité : -+ -diff --git a/tools/grit/grit/testdata/generated_resources_iw.xtb b/tools/grit/grit/testdata/generated_resources_iw.xtb -new file mode 100644 -index 0000000000..86b55334c0 ---- /dev/null -+++ b/tools/grit/grit/testdata/generated_resources_iw.xtb -@@ -0,0 +1,4 @@ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/generated_resources_no.xtb b/tools/grit/grit/testdata/generated_resources_no.xtb -new file mode 100644 -index 0000000000..913638ba4e ---- /dev/null -+++ b/tools/grit/grit/testdata/generated_resources_no.xtb -@@ -0,0 +1,4 @@ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/grit_part.grdp b/tools/grit/grit/testdata/grit_part.grdp -new file mode 100644 -index 0000000000..c8e9d92692 ---- /dev/null -+++ b/tools/grit/grit/testdata/grit_part.grdp -@@ -0,0 +1,5 @@ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/header.html b/tools/grit/grit/testdata/header.html -new file mode 100644 -index 0000000000..8e9d10ec50 ---- /dev/null -+++ b/tools/grit/grit/testdata/header.html -@@ -0,0 +1,39 @@ -+ -+[$~TITLE~$] -+ -+ -+ -+ -+[EXTRA_META] -+ -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/homepage.html b/tools/grit/grit/testdata/homepage.html -new file mode 100644 -index 0000000000..cce4f2cf35 ---- /dev/null -+++ b/tools/grit/grit/testdata/homepage.html -@@ -0,0 +1,37 @@ -+ -+Google Desktop Search -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+
    Google Desktop Search

    -+
    -+ -+ -+ -+
    -+[$~LINKS~$] -+
    -+ -+ -+ -+ -+ -+
     
      Desktop Preferences
    -+

    Search your own computer.

    -+[$~MESSAGE~$]
    -+
    [$~SETHOMEPAGE~$][$~BOTTOMLINE~$]

    -+

    ©2005 Google - Searching [NUM_ITEMS] items

    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/hover.html b/tools/grit/grit/testdata/hover.html -new file mode 100644 -index 0000000000..b8f9ce0200 ---- /dev/null -+++ b/tools/grit/grit/testdata/hover.html -@@ -0,0 +1,177 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+Sidebar -+Minibar -+Close -+
    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+
    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
      
    -+
    -+ -+ -+
    -+ -+
    -+
    -+ -+ -+ -diff --git a/tools/grit/grit/testdata/include_test.html b/tools/grit/grit/testdata/include_test.html -new file mode 100644 -index 0000000000..e08f2e2e8a ---- /dev/null -+++ b/tools/grit/grit/testdata/include_test.html -@@ -0,0 +1,31 @@ -+ -+ -+should be kept -+ -+in the middle... -+ -+should be removed -+ -+ -+ -+should be removed -+ -+ should be removed because outer expr is False -+ -+should be removed -+ -+ -+ -+ -+ -+ nested true should be kept -+ -+ -+ should be removed -+ -+ -+ -+ silbing true should be kept -+ -+ -+at the end... -diff --git a/tools/grit/grit/testdata/included_sample.html b/tools/grit/grit/testdata/included_sample.html -new file mode 100644 -index 0000000000..7150ffcbea ---- /dev/null -+++ b/tools/grit/grit/testdata/included_sample.html -@@ -0,0 +1 @@ -+Hello Include! -diff --git a/tools/grit/grit/testdata/indexing_speed.html b/tools/grit/grit/testdata/indexing_speed.html -new file mode 100644 -index 0000000000..db1787b0e2 ---- /dev/null -+++ b/tools/grit/grit/testdata/indexing_speed.html -@@ -0,0 +1,58 @@ -+ -+Google Desktop Search Index Speed -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ Go to Google Desktop Search  -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+
     Index SpeedIndex Speed -+ Help | About Google Desktop Search
    -+ -+

    -+To make your emails, files, and previously viewed web pages searchable, Google Desktop Search -+needs to index them. This indexing process is currently occuring in the background -+and your computer performance is minimally impacted. -+

    -+You have the option of speeding up this process. -+

    Warning: Speeding up indexing will cause your computer -+to become unusable for many minutes, depending on how many items need to be indexed. FAST INDEXING IS NOT -+RECOMMENDED. -+
     
    -+

    -+ -+
    -+

    -+ -+
    -+
    -+ -+

     
    -+ -+ -+ -+
    -+ -+ -+ -+ -+
    Google Desktop Search Home - Status - About Google Desktop Search - [$~BUILDNUMBER~$] - ©2005 Google

    -+ -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/install_prefs.html b/tools/grit/grit/testdata/install_prefs.html -new file mode 100644 -index 0000000000..eca0b56de5 ---- /dev/null -+++ b/tools/grit/grit/testdata/install_prefs.html -@@ -0,0 +1,92 @@ -+ -+Google Desktop Search: Initial Preferences -+ -+ -+ -+ -+ -+ -+ -+

    -+ -+
    -+
    To continue, please set these initial preferences:

    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
     
     
      -+
    -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+
    Deskbar
    -+ -+ -+
    -+
      -+
    You can change these and other preferences at any time.
    -+


    -+

    -+
    -+[SCRIPT] -+ -+ -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/install_prefs2.html b/tools/grit/grit/testdata/install_prefs2.html -new file mode 100644 -index 0000000000..18380397c2 ---- /dev/null -+++ b/tools/grit/grit/testdata/install_prefs2.html -@@ -0,0 +1,52 @@ -+ -+Indexing has Started -+ -+ -+ -+ -+ -+ -+ -+
    -+

    -+
    -+
    -+One-time indexing has started.

    -+An index is being prepared on your computer to allow you -+to search your information as fast as you can search the web.

    -+
  • This is a one-time process that may take several hours. -+
  • You may continue to use your computer as usual and it is safe to shut down your computer. -+
  • Indexing will be performed only when your computer is idle. -+ -+ -+


    -+ -+

  • -+ -+
    -+ -+[SCRIPT] -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/klonk-alternate-skeleton.rc b/tools/grit/grit/testdata/klonk-alternate-skeleton.rc -new file mode 100644 -index 0000000000000000000000000000000000000000..5f2c82a55469ddaab246c095826ad9e6743c0015 -GIT binary patch -literal 1088 -zcmbW0Pfr3t48`AhKZV)z#sGrI5!gjnU?DC>IT2z!82=r_L=!)}zjnmk5b$6oGo9&7 -z+t=4lu9UG-Ujxl_t%b{59ih$9PSBn!lW7`iGrKMm&Q10vTRK5!yRJHlRN`fcWril@ -zv|?uHM))d_NBa7`nW9TQ&PZ3tsax6ojav@U&9TYdHduz6k{G4GFTfpX_hk&`!z0F` -z!gJ>6WBh&UO&i_oS+VOvUfcD9JR=y&;3OxP2%KT$#JB9W=UtgQpDT@>(E^#^A;oG% -z4omjIK7rLXcRgmyS+%u_Gl2`MhOxMB{GGM&5o6cXFE~=G -z`!#F5=z%_bq95y7+aIx?IdcSN`A)xX^vZjCS7lnS#=iZ)E7W%eX8!kr-#RDO36^!o -Qqn&wY8qX0d7T}2V4SbP+*8l(j - -literal 0 -HcmV?d00001 - -diff --git a/tools/grit/grit/testdata/klonk.ico b/tools/grit/grit/testdata/klonk.ico -new file mode 100644 -index 0000000000000000000000000000000000000000..d371b214dc366249870efccc5da278d023aa91f1 -GIT binary patch -literal 766 -zcmeH_F%H5o5CqSFL>Ve71Sxq1;TtsMEB*!Fv6LbmDQFSUL1mXjO7OC0gpl|G?B1ML -zXS=a1V(2`di0U>FnQ~o{oUDnF5j(}bxAgSuhE8lMu~rkI8Ju%mb%Im^Xd<+ZwEgwd -zFTg+WQOj5lfvO*4mbEA^bCj9KHh65vjx^zvsKW{eA8|Ah`w&r;%!`QgmEiG3hXCcC -L+@V2V6oA7MJIRBx - -literal 0 -HcmV?d00001 - -diff --git a/tools/grit/grit/testdata/klonk.rc b/tools/grit/grit/testdata/klonk.rc -new file mode 100644 -index 0000000000000000000000000000000000000000..35652c4e6dd7cf7b7f62f637e191acf66f487235 -GIT binary patch -literal 9824 -zcmeI2+j1L48poSUd1!LS!j6*Z-q>7MTIeClrf{=b{yW=KLKoQA`29(tkA -z?@<`g*P*W;F2X@LqqP?P!IgxQa2&e)&gmcUJfiQMr{-PocF21|OVCckGsY~31#sNt -zeuJJaU(OhLWaHAYxy#{kNExfq8uQ5J2xc`jLo2kyURV$HuoL#fZm7|_&ii)Q3SZFE -z;@$|W^lb4S@e23#yIdxsED4)%Ix5vi$fg&b@^yerB!M>k-sfJ2-!(XtBx>~E;y0>; -zywqpO@eUBz4c2yv49m3k+_Z88eb3Rg>+A-4?GCk8rmyLEuD7;k@iyBQuQz|u4r}P| -z1pk!hKgO!w#>STMq~-8ViH-G#etL?RCgF{OzaBBS8aA-k=%+1wau1JP!(#WbwJk2e -z{FW=3II|6mUA$wTS=-Ei$KrzUMVn6ea?kwXHeRp*%qrtH8Cm5n-|(IYVUuHA@wRN;~7h6y+xyz_&R~;+XxM^eZ-_q~|%%b86_{3Asa-8FBk+Z7c-kJgN>UjHR -zv*J6C_vNv`hUxGkXMvL0T0vKhVQf$p6QjfeUR}fgl_wW2W!gk%O?IOa`tbcYLDwE{AY?>BR88vkIj3pcp9ftwy~b;A8i-;T|_p=$nY5yWU!`jTE^ib -ze*F+mE-Vf$>e;=5g*fg0^w_NUeElxZA2EAWiGRui^1Zl<=<)P1 -zF&Y;=yo$%KVIA>VGwa=@)kgQbrt31jq~WuvvL2VO`$zNqGSmHCaU;Y2q0yQ$JF7mTwL~ub{sOMb^Vh8GFZ(K1F-x>#wroJR -z&tF1@??TN-{BD^HbgJ;mLeTx&a -ztSZO1p-!t5NvMLINn_JEi1N%h$mrKfeZ%Sxtv*(Sq%E`|5` -zMQa!2rJ*fu!l%|$%^a7pE^XVFE$AM-((pNcct~BK8YqR1Sd~Aqmi*&@D)rQ&bN`YW -zMPvC%+;<0?G_uSf2bldXz_x`Rp$tXUa07m0#5g^O>n*TJE4PW#|}5_jztxOjO*+fAM}< -zk=Lii5sD#879SKTSIp++>5AlgXumxIv246U-XKqCe;}^ATDIP+P{%8`Yynw2Uilpc -z$xha}X;{ahB+#YVajq(xJ|2|kCBqoURxZc-PCWGR&NeH+c%h>-Yw>z7_{+>=5WWql;yg~F}V-&+XR>jna$uG|ylUKW)Rw*m^ -z_oOjp@vHny>%lMrW)jt@&DG$}J`tOC!twxncz`|R{U9wplS^%1SD7h)zLPS$9KxSJ -z^(luqF00#DmestFZxDq%2fL5@KE>#HI|)#R(g69An@YFD|(_t^K?Y(=LYvGR$s)LKbvaYc(JPp$Xb2G?a>eC9KE-cEhZ -zHSZ3+_C$Rze-w`BSsn7ZgI%TJO=9FfdDBy)V;pqaYpnOHjNdZ)cZhIWOV;71NPE_b -z5ZwYd@EV=tI))^?mN>3>KBO~=3-s|NvQu_bO!m`Xy&s`1RS8A9bec9lO`@(ym$)sX -zMVVq?wjta)kvTJp%Bk>bSh}4@HcmwuW}T<$ta~!gT03ja*d|hI1w9*Uk>}TwPvL12 -z=Q{J$UgQ8RXmu+(2GDd)J#{>6mrEh;W{57|8=6JgB)U>?#`vQXEaBEZgsP}6H0c~I -zlTn_wQLB~3>U1IQ2y}Rh=cM|##66Rnd!p7F(K=LbM6B`LtO3?OS3Ko>03~gD6g5tu -zOSRooa>4*SqvO;gSO;d)IuFc4e&rSY3#4arR~e}tmqXie5w!0rzg2#y{KWm2%CD85 -zD?e8LTlv1?UR>st9pKlDtGM^mfuA&df=7MIT`QQ#k8mnxoriygx5#|&^UZ&6F?Nx! -z2jMH^+zTJm>H?vU#6L!6XLz9~{RHheL_xo4SVUcx*(c|e8ZfVRzJC37^PM7DoUXW9 -zRu0v_b;|ztF`73W!u5N4HWX!l^ZH1;i+3m{&0Ya4gg*c` -C>9bG( - -literal 0 -HcmV?d00001 - -diff --git a/tools/grit/grit/testdata/ko_oem_enable_bug.html b/tools/grit/grit/testdata/ko_oem_enable_bug.html -new file mode 100644 -index 0000000000..f2c199cc15 ---- /dev/null -+++ b/tools/grit/grit/testdata/ko_oem_enable_bug.html -@@ -0,0 +1 @@ -+아웃룩 -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/ko_oem_non_admin_bug.html b/tools/grit/grit/testdata/ko_oem_non_admin_bug.html -new file mode 100644 -index 0000000000..b9e8a1f288 ---- /dev/null -+++ b/tools/grit/grit/testdata/ko_oem_non_admin_bug.html -@@ -0,0 +1 @@ -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/mini.html b/tools/grit/grit/testdata/mini.html -new file mode 100644 -index 0000000000..8ac0a231a0 ---- /dev/null -+++ b/tools/grit/grit/testdata/mini.html -@@ -0,0 +1,36 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+ -+ -+ -+ -+
      
    -+
    -+
    -diff --git a/tools/grit/grit/testdata/oem_enable.html b/tools/grit/grit/testdata/oem_enable.html -new file mode 100644 -index 0000000000..db6b85eca6 ---- /dev/null -+++ b/tools/grit/grit/testdata/oem_enable.html -@@ -0,0 +1,106 @@ -+ -+Google Desktop Search Download -+ -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+ -+
    -+
    Google Desktop Search
                Search your own -+computer.

    -+ -+ -+ -+ -+ -+
    -+
  • Find your email, files, web history and chats instantly -+
  • View web pages you've seen, even when you're not online -+
  • Search as easily as you do on Google -+

    Google Desktop Search finds:

    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    Outlook  Email from Outlook, Outlook Express, & -+ Thunderbird
    Internet Explorer  Web history -+ from IE/Firefox/Mozilla/Netscape
    Text  Files in Word, -+ Excel, Powerpoint, PDF, & media formats
    AOL IM  Chats from AOL -+ Instant Messenger
     
     About Desktop -+ Search   Screenshots   -+ Help   Contact -+ Us
  •     -+ -+ -+ -+

    -+
    By using, you agree to our
    Terms & -+ Conditions
    and Privacy -+ Policy
    -+

    -+
    -+

    -+

    * Automatically starts when you turn on -+ your computer
    -+

    -+

    -+
    ©2005 Google -+

    -diff --git a/tools/grit/grit/testdata/oem_non_admin.html b/tools/grit/grit/testdata/oem_non_admin.html -new file mode 100644 -index 0000000000..8b7ca13e21 ---- /dev/null -+++ b/tools/grit/grit/testdata/oem_non_admin.html -@@ -0,0 +1,39 @@ -+ -+Google Desktop Search Preferences -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+
    -+


    We're sorry, but you need administrator access to -+enable Desktop Search.

    -+

    To install or run Google Desktop Search you need administrator access on this -+computer. Please try installing again once you have administrator -+access.

    -+


    -+
    -diff --git a/tools/grit/grit/testdata/onebox.html b/tools/grit/grit/testdata/onebox.html -new file mode 100644 -index 0000000000..c24ff043a5 ---- /dev/null -+++ b/tools/grit/grit/testdata/onebox.html -@@ -0,0 +1,21 @@ -+Google Desktop Search Results -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/oneclick.html b/tools/grit/grit/testdata/oneclick.html -new file mode 100644 -index 0000000000..32dc6459dd ---- /dev/null -+++ b/tools/grit/grit/testdata/oneclick.html -@@ -0,0 +1,34 @@ -+[HEADER] -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ [EMAIL_TOP_CHROME] -+ -+

    -+ -+ [EMAIL] -+
    -+

    -+ [FREQ_TOP_CHROME] -+

    -+ -+ [$~FREQ~$] -+
    -+

    -+ [RECENT_TOP_CHROME] -+ -+ [$~RECENT~$] -+
    -+

    -+

    -+ -+ -+[FOOTER] -diff --git a/tools/grit/grit/testdata/password.html b/tools/grit/grit/testdata/password.html -new file mode 100644 -index 0000000000..16007a1ac0 ---- /dev/null -+++ b/tools/grit/grit/testdata/password.html -@@ -0,0 +1,37 @@ -+ -+Password Required -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+
    Google Desktop Search

    -+
    -+ -+ -+
    -+ -+ -+ -+
    Password required:   -+ -+   -+
    -+ -+
    -+
    [$~BOTTOMLINE~$]

    -+

    ©2005 Google

    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/preferences.html b/tools/grit/grit/testdata/preferences.html -new file mode 100644 -index 0000000000..b37412436b ---- /dev/null -+++ b/tools/grit/grit/testdata/preferences.html -@@ -0,0 +1,234 @@ -+ -+Google Desktop Search Preferences -+ -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+
    -+Go to Google Desktop Search  -+ -+ -+ -+ -+
    Preferences -+Preferences Help -+
    -+ -+
    -+ -+ -+ -+ -+
    -+Save your preferences when finished.
    -+ -+[STATUS-MESSAGE] -+ -+ -+
    Preferences (changes apply to Google Desktop Search application)
    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    Search types
    Index the following items so that you can -+search for them:
     
    -+
    -+ -+ -+ -+ -+ -+
    -+
    -+
    -+ -+ -+
    -+ -+ -+
    -+ -+
    -+ -+
    -+
    -+ -+
    -+ -+
    -+

    -+ -+
    -+
    -+
    Plug-ins
    Index these additional items:

    -+[ADDIN-DO] -+[ADDIN-OPTIONS]

    -+To install plug-ins to index other items, visit the -+Plug-ins Download page.
    -+
    Don't search these items
    -+
    -+c:\Documents and Settings\username\Private Stuff
    -+http://www.domain.com/
    -+
     
    -+
    -+
    Search Box Display -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+
    Deskbar
    -+ -+ -+
    -+ -+ -+ -+
    -+ -+
    Number of Results -+
    Google integration -+ -+ -+ -+
    -+ Your personal results are private from Google. -+
    -+
    Help us improve -+ -+
    -+ -+ -+ -+ -+
    Save your preferences -+when finished.
    -+ -+

    [$~BOTTOMLINE~$]
    -+
    ©2005 Google
    -+
    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/preprocess_test.html b/tools/grit/grit/testdata/preprocess_test.html -new file mode 100644 -index 0000000000..13ece9a9f6 ---- /dev/null -+++ b/tools/grit/grit/testdata/preprocess_test.html -@@ -0,0 +1,7 @@ -+ -+should be kept -+ -+in the middle... -+ -+should be removed -+ -diff --git a/tools/grit/grit/testdata/privacy.html b/tools/grit/grit/testdata/privacy.html -new file mode 100644 -index 0000000000..1d45f4a539 ---- /dev/null -+++ b/tools/grit/grit/testdata/privacy.html -@@ -0,0 +1,35 @@ -+[!] -+title Privacy and Google Desktop Search -+template -+privacy_bottomline -+hp_image -+ -+ -+ -+
    -+

    Privacy and Google Desktop Search

    -+ -+

    Google is committed to making search on your desktop as easy -+as searching the web. We recognize that privacy is an important issue, -+so we designed and built Google Desktop Search with respect for your privacy. -+

    -+So that you can easily search your computer, the Google Desktop Search application indexes -+and stores versions of your files and other computer activity, -+such as email, chats, and web history. These versions may also be mixed -+with your Web search results to produce -+results pages for you that integrate relevant content from your computer and -+information from the Web. -+

    -+Your computer's content is not made accessible to Google or anyone else without your explicit permission. -+ -+

    You can read the -+Privacy Policy -+and Privacy FAQ online. -+ -+

    -+ -+

    -+ -+
    -+[$~PRIVACY_BOTTOMLINE~$] - ©2005 Google -+
    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/quit_apps.html b/tools/grit/grit/testdata/quit_apps.html -new file mode 100644 -index 0000000000..a501b0e2bf ---- /dev/null -+++ b/tools/grit/grit/testdata/quit_apps.html -@@ -0,0 +1,49 @@ -+ -+Google Desktop Search Preferences -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+
    -+


    To start using Google Desktop Search, we may need to close the following programs if they are running:

    -+

    You can start these programs once Google Desktop Search is running.

    -+ -+
  • AOL Instant Messenger -+
  • Firefox -+
  • Internet Explorer -+
  • Microsoft Excel -+
  • Microsoft Outlook -+
  • Microsoft Word -+
  • Mozilla -+
  • Mozilla Thunderbird -+
  • Netscape -+
  • Opera -+
  • Other web browsers -+ -+

    This will take only a few seconds to complete.

  • -+

    -+

    -+
    -diff --git a/tools/grit/grit/testdata/recrawl.html b/tools/grit/grit/testdata/recrawl.html -new file mode 100644 -index 0000000000..0401e7c2b0 ---- /dev/null -+++ b/tools/grit/grit/testdata/recrawl.html -@@ -0,0 +1,30 @@ -+ -+Refresh index -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+
    Google Desktop Search -+
    -+
    -+
    Google Desktop Search is now recrawling your drive to index new files.
    -+
    Note that new files are indexed automatically, and this step is generally not needed.
    -+
    Click here to continue.
    -+ -+
    -+[$~BOTTOMLINE~$] -+

    ©2005 Google

    -+
    -+ -+ -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/resource_ids b/tools/grit/grit/testdata/resource_ids -new file mode 100644 -index 0000000000..d5d440d57f ---- /dev/null -+++ b/tools/grit/grit/testdata/resource_ids -@@ -0,0 +1,13 @@ -+{ -+ "SRCDIR": ".", -+ "test.grd": { -+ "messages": [100, 10000], -+ }, -+ "substitute_no_ids.grd": { -+ "messages": [10000, 20000], -+ }, -+ "<(FOO)/file.grd": { -+ }, -+ "<(SHARED_INTERMEDIATE_DIR)/devtools/devtools.grd": { -+ }, -+} -diff --git a/tools/grit/grit/testdata/script.html b/tools/grit/grit/testdata/script.html -new file mode 100644 -index 0000000000..f177d9c30e ---- /dev/null -+++ b/tools/grit/grit/testdata/script.html -@@ -0,0 +1,38 @@ -+ -diff --git a/tools/grit/grit/testdata/searchbox.html b/tools/grit/grit/testdata/searchbox.html -new file mode 100644 -index 0000000000..9eccba99a5 ---- /dev/null -+++ b/tools/grit/grit/testdata/searchbox.html -@@ -0,0 +1,22 @@ -+ -+ -+ -+ -+ -+
    Go to Google Desktop Search   -+ -+ -+ -+ -+
    -+ -+ -+
    -+[$~LINKS~$] -+
    -+
    -+[$~FLAGS~$]
      Desktop Preferences
      [DELETE_NAME]
    -+ -+ -+
     
    -+
    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/sidebar_h.html b/tools/grit/grit/testdata/sidebar_h.html -new file mode 100644 -index 0000000000..e103e8f8db ---- /dev/null -+++ b/tools/grit/grit/testdata/sidebar_h.html -@@ -0,0 +1,82 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+
    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
     Google Desktop Search
    -+
    -+ -+
    -+ -+[HEADER_SECTION1] -+[CONTENT_INBOX] -+ -+ -+ -+[HEADER_SECTION2] -+[CONTENT_HIST] -+ -+ -+ -+[CONTENT_NEWS] -+[CONTENT_OTHER] -+ -+ -+ -+ -+ -+
    -+ -+ -+ -+[SCRIPT] -+ -diff --git a/tools/grit/grit/testdata/sidebar_v.html b/tools/grit/grit/testdata/sidebar_v.html -new file mode 100644 -index 0000000000..e040d8ec59 ---- /dev/null -+++ b/tools/grit/grit/testdata/sidebar_v.html -@@ -0,0 +1,267 @@ -+ -+Google Desktop Search Sidebar -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+
    -+ -+ -+ -+ -+ -+ -+
    Google Desktop Search  Web 
    -+
    -+ -+

    -+
    -+
     News
    -+
    -+ -+ -+[CONTENT_NEWS] -+

    -+ -+ -+
    -+
     Email
    -+
    -+ -+ -+[CONTENT_INBOX] -+

    -+ -+ -+
    -+
     Related History
    -+
    -+ -+ -+[CONTENT_HIST] -+

    -+ -+ -+ -+
    -+
     Recent
    -+
    -+ -+ -+[CONTENT_RECENT] -+

    -+ -+ -+ -+
    -+
     Frequently Visited
    -+
    -+ -+ -+[CONTENT_POPULAR] -+

    -+ -+ -+ -+
    -+
     Implicit Query Debug
    -+
    -+ -+ -+[CONTENT_QUIB_DEBUG] -+ -+ -+ -+ -+[CONTENT_OTHER] -+ -+[SCRIPT] -+ -+ -diff --git a/tools/grit/grit/testdata/simple-input.xml b/tools/grit/grit/testdata/simple-input.xml -new file mode 100644 -index 0000000000..92827fa4b5 ---- /dev/null -+++ b/tools/grit/grit/testdata/simple-input.xml -@@ -0,0 +1,52 @@ -+ -+ -+ -+ -+ Hello earthlings! -+ -+ -+ -+ -+ -+ -+ -+ -+ Go! -+ -+ Hello %sJoi, how are you doing today? -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/simple.html b/tools/grit/grit/testdata/simple.html -new file mode 100644 -index 0000000000..4392d23e98 ---- /dev/null -+++ b/tools/grit/grit/testdata/simple.html -@@ -0,0 +1,3 @@ -+

    -+ Hello! -+

    -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/source.rc b/tools/grit/grit/testdata/source.rc -new file mode 100644 -index 0000000000..fbc72284e9 ---- /dev/null -+++ b/tools/grit/grit/testdata/source.rc -@@ -0,0 +1,57 @@ -+IDC_KLONKMENU MENU -+BEGIN -+ POPUP "&File" -+ BEGIN -+ MENUITEM "E&xit", IDM_EXIT -+ MENUITEM "This be ""Klonk"" me like", ID_FILE_THISBE -+ POPUP "gonk" -+ BEGIN -+ MENUITEM "Klonk && is [good]", ID_GONK_KLONKIS -+ END -+ END -+ POPUP "&Help" -+ BEGIN -+ MENUITEM "&About ...", IDM_ABOUT -+ END -+END -+ -+IDD_ABOUTBOX DIALOGEX 22, 17, 230, 75 -+STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -+CAPTION "About" -+FONT 8, "System", 0, 0, 0x0 -+BEGIN -+ ICON IDI_KLONK,IDC_MYICON,14,9,20,20 -+ LTEXT "klonk Version ""yibbee"" 1.0",IDC_STATIC,49,10,119,8, -+ SS_NOPREFIX -+ LTEXT "Copyright (C) 2005",IDC_STATIC,49,20,119,8 -+ DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP -+ CONTROL "Jack ""Black"" Daniels",IDC_RADIO1,"Button", -+ BS_AUTORADIOBUTTON,46,51,84,10 -+END -+ -+IDD_DIFFERENT_LENGTH_IN_TRANSL DIALOGEX 22, 17, 230, 75 -+STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -+CAPTION "Bingobobbi" -+FONT 8, "System", 0, 0, 0x0 -+BEGIN -+ LTEXT "Howdie dodie!",IDC_STATIC,49,10,119,8,SS_NOPREFIX -+ LTEXT "Yo froodie!",IDC_STATIC,49,20,119,8 -+END -+ -+STRINGTABLE -+BEGIN -+ IDS_SIMPLE "One" -+ IDS_PLACEHOLDER "%s birds" -+ IDS_PLACEHOLDERS "%d of %d" -+ IDS_REORDERED_PLACEHOLDERS "$1 of $2" -+ // Won't be in translations list because it has changed -+ IDS_CHANGED "This was the old version" -+ IDS_TWIN_1 "Hello" -+ IDS_TWIN_2 "Hello" -+ IDS_NOT_TRANSLATEABLE ":" -+ IDS_LONGER_TRANSLATED "Removed document $1" -+ // Won't appear in the list of translations because it's not in the .grd file -+ IDS_NO_LONGER_USED "Not used" -+ IDS_DIFFERENT_TWIN_1 "Howdie" -+ IDS_DIFFERENT_TWIN_2 "Howdie" -+END -diff --git a/tools/grit/grit/testdata/special_100_percent/a.png b/tools/grit/grit/testdata/special_100_percent/a.png -new file mode 100644 -index 0000000000000000000000000000000000000000..5d5089038ca71172e95db9e7aae1e1fa5cebd505 -GIT binary patch -literal 159 -zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>0wld=oSO}#(mY)pLnNjq|2Y3)zGGzYPN&L+ -zMSC}CcCfp=Dtxv4%6W%G#Q=|R|L;6pCCLUWO)Z<5eoL%TkDTw=s4X!^d(Qa<2khAN -zZPy!XToBAic1Ss}vcWiD27B3&`Zj^H6CO>7R1{ToQ;=ggdEYbV=IISvfHpFCy85}S -Ib4q9e0O9jEh5!Hn - -literal 0 -HcmV?d00001 - -diff --git a/tools/grit/grit/testdata/status.html b/tools/grit/grit/testdata/status.html -new file mode 100644 -index 0000000000..6b997b9369 ---- /dev/null -+++ b/tools/grit/grit/testdata/status.html -@@ -0,0 +1,44 @@ -+[HEADER] -+ -+ -+
    -+ -+ -+
     Desktop Search Status
    -+
    -+
    -+[$~MESSAGE~$] -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
     Number of itemsTime of newest item
      Total searchable items[TOTAL_COUNT][TOTAL_TIME]
           Emails[EMAIL_COUNT][EMAIL_TIME]
           Chats[IM_COUNT][IM_TIME]
           Web history[WEB_COUNT][WEB_TIME]
           Files[FILE_COUNT][FILE_TIME]
    -+
    -+[FOOTER] -\ No newline at end of file -diff --git a/tools/grit/grit/testdata/structure_variables.html b/tools/grit/grit/testdata/structure_variables.html -new file mode 100644 -index 0000000000..2a15de8072 ---- /dev/null -+++ b/tools/grit/grit/testdata/structure_variables.html -@@ -0,0 +1,4 @@ -+

    [GREETING]!

    -+Some cool things are [THINGS]. -+Did you know that [EQUATION]? -+ -diff --git a/tools/grit/grit/testdata/substitute.grd b/tools/grit/grit/testdata/substitute.grd -new file mode 100644 -index 0000000000..95dcc56e1d ---- /dev/null -+++ b/tools/grit/grit/testdata/substitute.grd -@@ -0,0 +1,31 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Copyright 2008 Google Inc. All Rights Reserved. -+ -+ -+ Google Desktop News gadget -+[IDS_COPYRIGHT_GOOGLE_LONG] -+View news that is personalized based on the articles you read. -+ -+For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/substitute.xmb b/tools/grit/grit/testdata/substitute.xmb -new file mode 100644 -index 0000000000..e592069c8b ---- /dev/null -+++ b/tools/grit/grit/testdata/substitute.xmb -@@ -0,0 +1,10 @@ -+ -+ -+ -+© 2008 Google Inc. Med ensamrätt. -+Google Desktop News gadget -+ -+Se nyheter som är anpassade till dig, baserat på de artiklar du läser. -+ -+Om du t.ex. läser massor av sportnyheter kommer du att se fler sportartiklar. Om du inte läser tekniknyheter lika ofta ser du färre av dessa artiklar. -+ -diff --git a/tools/grit/grit/testdata/substitute_no_ids.grd b/tools/grit/grit/testdata/substitute_no_ids.grd -new file mode 100644 -index 0000000000..d569d1cacd ---- /dev/null -+++ b/tools/grit/grit/testdata/substitute_no_ids.grd -@@ -0,0 +1,31 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Copyright 2008 Google Inc. All Rights Reserved. -+ -+ -+ Google Desktop News gadget -+[IDS_COPYRIGHT_GOOGLE_LONG] -+View news that is personalized based on the articles you read. -+ -+For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/substitute_tmpl.grd b/tools/grit/grit/testdata/substitute_tmpl.grd -new file mode 100644 -index 0000000000..be7b601707 ---- /dev/null -+++ b/tools/grit/grit/testdata/substitute_tmpl.grd -@@ -0,0 +1,31 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Copyright 2008 Google Inc. All Rights Reserved. -+ -+ -+ Google Desktop News gadget -+[IDS_COPYRIGHT_GOOGLE_LONG] -+View news that is personalized based on the articles you read. -+ -+For example, if you read lots of sports news, you'll see more sports articles. If you read technology news less often, you'll see fewer of those articles. -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/test_css.css b/tools/grit/grit/testdata/test_css.css -new file mode 100644 -index 0000000000..55d5dd1770 ---- /dev/null -+++ b/tools/grit/grit/testdata/test_css.css -@@ -0,0 +1 @@ -+This is a test! -diff --git a/tools/grit/grit/testdata/test_html.html b/tools/grit/grit/testdata/test_html.html -new file mode 100644 -index 0000000000..55d5dd1770 ---- /dev/null -+++ b/tools/grit/grit/testdata/test_html.html -@@ -0,0 +1 @@ -+This is a test! -diff --git a/tools/grit/grit/testdata/test_js.js b/tools/grit/grit/testdata/test_js.js -new file mode 100644 -index 0000000000..55d5dd1770 ---- /dev/null -+++ b/tools/grit/grit/testdata/test_js.js -@@ -0,0 +1 @@ -+This is a test! -diff --git a/tools/grit/grit/testdata/test_svg.svg b/tools/grit/grit/testdata/test_svg.svg -new file mode 100644 -index 0000000000..55d5dd1770 ---- /dev/null -+++ b/tools/grit/grit/testdata/test_svg.svg -@@ -0,0 +1 @@ -+This is a test! -diff --git a/tools/grit/grit/testdata/test_text.txt b/tools/grit/grit/testdata/test_text.txt -new file mode 100644 -index 0000000000..55d5dd1770 ---- /dev/null -+++ b/tools/grit/grit/testdata/test_text.txt -@@ -0,0 +1 @@ -+This is a test! -diff --git a/tools/grit/grit/testdata/time_related.html b/tools/grit/grit/testdata/time_related.html -new file mode 100644 -index 0000000000..ee64b1665e ---- /dev/null -+++ b/tools/grit/grit/testdata/time_related.html -@@ -0,0 +1,11 @@ -+[HEADER] -+[CHROME] -+[NAV_PRE_POST] -+[$~MESSAGE~$]
    -+ -+[CONTENTS] -+

    -+ -+[NAV_PRE_POST] -+[FOOTER] -+ -diff --git a/tools/grit/grit/testdata/toolbar_about.html b/tools/grit/grit/testdata/toolbar_about.html -new file mode 100644 -index 0000000000..bb4b0eb355 ---- /dev/null -+++ b/tools/grit/grit/testdata/toolbar_about.html -@@ -0,0 +1,138 @@ -+ -+ -+ -+About Google Toolbar -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
    -+ -+ -+ -+ -+ -+ -+
    -+
    Google Toolbar
    -+
    -+
    -+ -+ -+
    -+
    -+ -+
    -+
    -+
    -+ -+ -+ De parvis grandis acervus erit -+ -+ -+
    -+ -+ © 2006 Google -+ -+ -+
    -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/tools/grit/resource_ids b/tools/grit/grit/testdata/tools/grit/resource_ids -new file mode 100644 -index 0000000000..8a2b608df1 ---- /dev/null -+++ b/tools/grit/grit/testdata/tools/grit/resource_ids -@@ -0,0 +1,176 @@ -+# Copyright (c) 2011 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+# -+# This file is used to assign starting resource ids for resources and strings -+# used by Chromium. This is done to ensure that resource ids are unique -+# across all the grd files. If you are adding a new grd file, please add -+# a new entry to this file. -+# -+# The first entry in the file, SRCDIR, is special: It is a relative path from -+# this file to the base of your checkout. -+# -+# http://msdn.microsoft.com/en-us/library/t2zechd4(VS.71).aspx says that the -+# range for IDR_ is 1 to 28,671 and the range for IDS_ is 1 to 32,767 and -+# common convention starts practical use of IDs at 100 or 101. -+{ -+ "SRCDIR": "../..", -+ -+ "chrome/browser/browser_resources.grd": { -+ "includes": [500], -+ }, -+ "chrome/browser/resources/component_extension_resources.grd": { -+ "includes": [1000], -+ }, -+ "chrome/browser/resources/net_internals_resources.grd": { -+ "includes": [1500], -+ }, -+ "chrome/browser/resources/shared_resources.grd": { -+ "includes": [2000], -+ }, -+ "chrome/common/common_resources.grd": { -+ "includes": [2500], -+ }, -+ "chrome/default_plugin/default_plugin_resources.grd": { -+ "includes": [3000], -+ }, -+ "chrome/renderer/renderer_resources.grd": { -+ "includes": [3500], -+ }, -+ "net/base/net_resources.grd": { -+ "includes": [4000], -+ }, -+ "webkit/glue/webkit_resources.grd": { -+ "includes": [4500], -+ }, -+ "webkit/tools/test_shell/test_shell_resources.grd": { -+ "includes": [5000], -+ }, -+ "ui/resources/ui_resources.grd": { -+ "includes": [5500], -+ }, -+ "chrome/app/theme/theme_resources.grd": { -+ "includes": [6000], -+ }, -+ "chrome_frame/resources/chrome_frame_resources.grd": { -+ "includes": [6500], -+ }, -+ # WebKit.grd can be in two different places depending on whether we are -+ # in a chromium checkout or a webkit-only checkout. -+ "third_party/WebKit/Source/WebKit/chromium/WebKit.grd": { -+ "includes": [7000], -+ }, -+ "WebKit.grd": { -+ "includes": [7000], -+ }, -+ -+ "ui/base/strings/app_locale_settings.grd": { -+ "META": {"join": 2}, -+ "messages": [7500], -+ }, -+ "chrome/app/resources/locale_settings.grd": { -+ "includes": [8000], -+ "messages": [8500], -+ }, -+ # These each start with the same resource id because we only use one -+ # file for each build (cros, linux, mac, or win). -+ "chrome/app/resources/locale_settings_cros.grd": { -+ "messages": [9000], -+ }, -+ "chrome/app/resources/locale_settings_linux.grd": { -+ "messages": [9000], -+ }, -+ "chrome/app/resources/locale_settings_mac.grd": { -+ "messages": [9000], -+ }, -+ "chrome/app/resources/locale_settings_win.grd": { -+ "messages": [9000], -+ }, -+ -+ "ui/base/strings/ui_strings.grd": { -+ "META": {"join": 4}, -+ "messages": [9500], -+ }, -+ # Chromium strings and Google Chrome strings must start at the same id. -+ # We only use one file depending on whether we're building Chromium or -+ # Google Chrome. -+ "chrome/app/chromium_strings.grd": { -+ "messages": [10000], -+ }, -+ "chrome/app/google_chrome_strings.grd": { -+ "messages": [10000], -+ }, -+ # Leave lots of space for generated_resources since it has most of our -+ # strings. -+ "chrome/app/generated_resources.grd": { -+ "META": {"join": 2}, -+ "structures": [10500], -+ "messages": [11000], -+ }, -+ # The chrome frame dialogs are also in generated_resources.grd so they -+ # get included by the translation console. We make sure that the ids -+ # for structures here are the same as for generated_resources.grd. -+ "chrome_frame/resources/chrome_frame_dialogs.grd": { -+ "structures": [10500], -+ "includes": [10750], -+ }, -+ "webkit/glue/inspector_strings.grd": { -+ "messages": [16000], -+ }, -+ "webkit/glue/webkit_strings.grd": { -+ "messages": [16500], -+ }, -+ -+ "chrome_frame/resources/chrome_frame_resources.grd": { -+ "includes": [17500], -+ "structures": [18000], -+ }, -+ -+ "ui/gfx/gfx_resources.grd": { -+ "includes": [18500], -+ }, -+ -+ "chrome/app/policy/policy_templates.grd": { -+ "structures": [19000], -+ "messages": [19010], -+ }, -+ -+ "chrome/browser/autofill/autofill_resources.grd": { -+ "messages": [19500], -+ }, -+ "chrome/browser/resources/sync_internals_resources.grd": { -+ "includes": [20000], -+ }, -+ # This file is generated during the build. -+ "<(SHARED_INTERMEDIATE_DIR)/devtools/devtools_resources.grd": { -+ "includes": [20500], -+ }, -+ # All standard and large theme resources should have the same IDs. -+ "chrome/app/theme/theme_resources_standard.grd": { -+ "includes": [21000], -+ }, -+ "chrome/app/theme/theme_resources_large.grd": { -+ "includes": [21000], -+ }, -+ # This file is generated during the build. -+ "chrome/browser/debugger/frontend/devtools_frontend_resources.grd": { -+ "META": {"join": 2}, -+ "includes": [21500], -+ }, -+ "cloud_print/virtual_driver/win/install/virtual_driver_setup_resources.grd": { -+ "messages": [22500], -+ }, -+ "chrome/browser/resources/quota_internals_resources.grd": { -+ "includes": [23000], -+ }, -+ "chrome/browser/resources/workers_resources.grd": { -+ "includes": [23500], -+ }, -+ # All standard and large theme resources should have the same IDs. -+ "ui/resources/ui_resources_standard.grd": { -+ "includes": [24000], -+ }, -+ "ui/resources/ui_resources_large.grd": { -+ "includes": [24000], -+ }, -+} -diff --git a/tools/grit/grit/testdata/transl.rc b/tools/grit/grit/testdata/transl.rc -new file mode 100644 -index 0000000000..2f2595db3f ---- /dev/null -+++ b/tools/grit/grit/testdata/transl.rc -@@ -0,0 +1,56 @@ -+IDC_KLONKMENU MENU -+BEGIN -+ POPUP "&Skra" -+ BEGIN -+ MENUITEM "&Haetta", IDM_EXIT -+ MENUITEM "Thetta er ""Klonk"" sem eg fyla", ID_FILE_THISBE -+ POPUP "gonkurinn" -+ BEGIN -+ MENUITEM "Klonk && er [good]", ID_GONK_KLONKIS -+ END -+ END -+ POPUP "&Hjalp" -+ BEGIN -+ MENUITEM "&Um...", IDM_ABOUT -+ END -+END -+ -+IDD_ABOUTBOX DIALOGEX 22, 17, 230, 75 -+STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -+CAPTION "Um Klonk" -+FONT 8, "System", 0, 0, 0x0 -+BEGIN -+ ICON IDI_KLONK,IDC_MYICON,14,9,20,20 -+ LTEXT "klonk utgafa ""jibbi"" 1.0",IDC_STATIC,49,10,119,8, -+ SS_NOPREFIX -+ LTEXT "Hofundarrettur (C) 2005",IDC_STATIC,49,20,119,8 -+ DEFPUSHBUTTON "I lagi",IDOK,195,6,30,11,WS_GROUP -+ CONTROL "Jack ""Black"" Daniels",IDC_RADIO1,"Button", -+ BS_AUTORADIOBUTTON,46,51,84,10 -+END -+ -+IDD_DIFFERENT_LENGTH_IN_TRANSL DIALOGEX 22, 17, 230, 75 -+STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -+CAPTION "Bingobobbi" -+FONT 8, "System", 0, 0, 0x0 -+BEGIN -+ LTEXT "Howdie dodie!",IDC_STATIC,49,10,119,8,SS_NOPREFIX -+END -+ -+STRINGTABLE -+BEGIN -+ IDS_SIMPLE "Ein" -+ IDS_PLACEHOLDER "%s Vogeln" -+ IDS_PLACEHOLDERS "%d von %d" -+ // Shouldn't be part of translations list because the translation is -+ // reordered so placeholder fixup fails -+ IDS_REORDERED_PLACEHOLDERS "$2 auf $1" -+ IDS_CHANGED "Dass war die alte Version" -+ IDS_TWIN_1 "Hallo" -+ IDS_TWIN_2 "Hallo" -+ IDS_NOT_TRANSLATEABLE ":" -+ IDS_LONGER_TRANSLATED "Dokument $1 ist entfernt worden" -+ IDS_NO_LONGER_USED "Nicht verwendet" -+ IDS_DIFFERENT_TWIN_1 "Howdie" -+ IDS_DIFFERENT_TWIN_2 "Hallo sagt man" -+END -diff --git a/tools/grit/grit/testdata/versions.html b/tools/grit/grit/testdata/versions.html -new file mode 100644 -index 0000000000..d1f40d8d72 ---- /dev/null -+++ b/tools/grit/grit/testdata/versions.html -@@ -0,0 +1,7 @@ -+[HEADER] -+ -+[TOP_CHROME] -+[CONTENTS] -+ -+[NEXT_PREV] -+[FOOTER] -diff --git a/tools/grit/grit/testdata/whitelist.txt b/tools/grit/grit/testdata/whitelist.txt -new file mode 100644 -index 0000000000..5b3aca40b5 ---- /dev/null -+++ b/tools/grit/grit/testdata/whitelist.txt -@@ -0,0 +1,4 @@ -+IDS_MESSAGE_WHITELISTED -+IDR_STRUCTURE_WHITELISTED -+IDR_STRUCTURE_IN_TRUE_IF_WHITELISTED -+IDR_INCLUDE_WHITELISTED -diff --git a/tools/grit/grit/testdata/whitelist_resources.grd b/tools/grit/grit/testdata/whitelist_resources.grd -new file mode 100644 -index 0000000000..9925688ff5 ---- /dev/null -+++ b/tools/grit/grit/testdata/whitelist_resources.grd -@@ -0,0 +1,54 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tools/grit/grit/testdata/whitelist_strings.grd b/tools/grit/grit/testdata/whitelist_strings.grd -new file mode 100644 -index 0000000000..df80f5fd32 ---- /dev/null -+++ b/tools/grit/grit/testdata/whitelist_strings.grd -@@ -0,0 +1,23 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ Whitelisted. -+ -+ -+ Not whitelisted. -+ -+ -+ -+ -diff --git a/tools/grit/grit/tool/__init__.py b/tools/grit/grit/tool/__init__.py -new file mode 100644 -index 0000000000..cc455b36e7 ---- /dev/null -+++ b/tools/grit/grit/tool/__init__.py -@@ -0,0 +1,8 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Package grit.tool -+''' -+ -+pass -diff --git a/tools/grit/grit/tool/android2grd.py b/tools/grit/grit/tool/android2grd.py -new file mode 100644 -index 0000000000..005297bafe ---- /dev/null -+++ b/tools/grit/grit/tool/android2grd.py -@@ -0,0 +1,484 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""The 'grit android2grd' tool.""" -+ -+from __future__ import print_function -+ -+import getopt -+import os.path -+import sys -+from xml.dom import Node -+import xml.dom.minidom -+ -+import six -+from six import StringIO -+ -+import grit.node.empty -+from grit.node import node_io -+from grit.node import message -+ -+from grit.tool import interface -+ -+from grit import grd_reader -+from grit import lazy_re -+from grit import tclib -+ -+ -+# The name of a string in strings.xml -+_STRING_NAME = lazy_re.compile(r'[a-z0-9_]+\Z') -+ -+# A string's character limit in strings.xml -+_CHAR_LIMIT = lazy_re.compile(r'\[CHAR-LIMIT=(\d+)\]') -+ -+# Finds String.Format() style format specifiers such as "%-5.2f". -+_FORMAT_SPECIFIER = lazy_re.compile( -+ r'%' -+ r'([1-9][0-9]*\$|<)?' # argument_index -+ r'([-#+ 0,(]*)' # flags -+ r'([0-9]+)?' # width -+ r'(\.[0-9]+)?' # precision -+ r'([bBhHsScCdoxXeEfgGaAtT%n])') # conversion -+ -+ -+class Android2Grd(interface.Tool): -+ """Tool for converting Android string.xml files into chrome Grd files. -+ -+Usage: grit [global options] android2grd [OPTIONS] STRINGS_XML -+ -+The Android2Grd tool will convert an Android strings.xml file (whose path is -+specified by STRINGS_XML) and create a chrome style grd file containing the -+relevant information. -+ -+Because grd documents are much richer than strings.xml documents we supplement -+the information required by grds using OPTIONS with sensible defaults. -+ -+OPTIONS may be any of the following: -+ -+ --name FILENAME Specify the base FILENAME. This should be without -+ any file type suffix. By default -+ "chrome_android_strings" will be used. -+ -+ --languages LANGUAGES Comma separated list of ISO language codes (e.g. -+ en-US, en-GB, ru, zh-CN). These codes will be used -+ to determine the names of resource and translations -+ files that will be declared by the output grd file. -+ -+ --grd-dir GRD_DIR Specify where the resultant grd file -+ (FILENAME.grd) should be output. By default this -+ will be the present working directory. -+ -+ --header-dir HEADER_DIR Specify the location of the directory where grit -+ generated C++ headers (whose name will be -+ FILENAME.h) will be placed. Use an empty string to -+ disable rc generation. Default: empty. -+ -+ --rc-dir RC_DIR Specify the directory where resource files will -+ be located relative to grit build's output -+ directory. Use an empty string to disable rc -+ generation. Default: empty. -+ -+ --xml-dir XML_DIR Specify where to place localized strings.xml files -+ relative to grit build's output directory. For each -+ language xx a values-xx/strings.xml file will be -+ generated. Use an empty string to disable -+ strings.xml generation. Default: '.'. -+ -+ --xtb-dir XTB_DIR Specify where the xtb files containing translations -+ will be located relative to the grd file. Default: -+ '.'. -+""" -+ -+ _NAME_FLAG = 'name' -+ _LANGUAGES_FLAG = 'languages' -+ _GRD_DIR_FLAG = 'grd-dir' -+ _RC_DIR_FLAG = 'rc-dir' -+ _HEADER_DIR_FLAG = 'header-dir' -+ _XTB_DIR_FLAG = 'xtb-dir' -+ _XML_DIR_FLAG = 'xml-dir' -+ -+ def __init__(self): -+ self.name = 'chrome_android_strings' -+ self.languages = [] -+ self.grd_dir = '.' -+ self.rc_dir = None -+ self.xtb_dir = '.' -+ self.xml_res_dir = '.' -+ self.header_dir = None -+ -+ def ShortDescription(self): -+ """Returns a short description of the Android2Grd tool. -+ -+ Overridden from grit.interface.Tool -+ -+ Returns: -+ A string containing a short description of the android2grd tool. -+ """ -+ return 'Converts Android string.xml files into Chrome grd files.' -+ -+ def ParseOptions(self, args): -+ """Set this objects and return all non-option arguments.""" -+ flags = [ -+ Android2Grd._NAME_FLAG, -+ Android2Grd._LANGUAGES_FLAG, -+ Android2Grd._GRD_DIR_FLAG, -+ Android2Grd._RC_DIR_FLAG, -+ Android2Grd._HEADER_DIR_FLAG, -+ Android2Grd._XTB_DIR_FLAG, -+ Android2Grd._XML_DIR_FLAG, ] -+ (opts, args) = getopt.getopt( -+ args, None, ['%s=' % o for o in flags] + ['help']) -+ -+ for key, val in opts: -+ # Get rid of the preceding hypens. -+ k = key[2:] -+ if k == Android2Grd._NAME_FLAG: -+ self.name = val -+ elif k == Android2Grd._LANGUAGES_FLAG: -+ self.languages = val.split(',') -+ elif k == Android2Grd._GRD_DIR_FLAG: -+ self.grd_dir = val -+ elif k == Android2Grd._RC_DIR_FLAG: -+ self.rc_dir = val -+ elif k == Android2Grd._HEADER_DIR_FLAG: -+ self.header_dir = val -+ elif k == Android2Grd._XTB_DIR_FLAG: -+ self.xtb_dir = val -+ elif k == Android2Grd._XML_DIR_FLAG: -+ self.xml_res_dir = val -+ elif k == 'help': -+ self.ShowUsage() -+ sys.exit(0) -+ return args -+ -+ def Run(self, opts, args): -+ """Runs the Android2Grd tool. -+ -+ Inherited from grit.interface.Tool. -+ -+ Args: -+ opts: List of string arguments that should be parsed. -+ args: String containing the path of the strings.xml file to be converted. -+ """ -+ args = self.ParseOptions(args) -+ if len(args) != 1: -+ print('Tool requires one argument, the path to the Android ' -+ 'strings.xml resource file to be converted.') -+ return 2 -+ self.SetOptions(opts) -+ -+ android_path = args[0] -+ -+ # Read and parse the Android strings.xml file. -+ with open(android_path) as android_file: -+ android_dom = xml.dom.minidom.parse(android_file) -+ -+ # Do the hard work -- convert the Android dom to grd file contents. -+ grd_dom = self.AndroidDomToGrdDom(android_dom) -+ grd_string = six.text_type(grd_dom) -+ -+ # Write the grd string to a file in grd_dir. -+ grd_filename = self.name + '.grd' -+ grd_path = os.path.join(self.grd_dir, grd_filename) -+ with open(grd_path, 'w') as grd_file: -+ grd_file.write(grd_string) -+ -+ def AndroidDomToGrdDom(self, android_dom): -+ """Converts a strings.xml DOM into a DOM representing the contents of -+ a grd file. -+ -+ Args: -+ android_dom: A xml.dom.Document containing the contents of the Android -+ string.xml document. -+ Returns: -+ The DOM for the grd xml document produced by converting the Android DOM. -+ """ -+ -+ # Start with a basic skeleton for the .grd file. -+ root = grd_reader.Parse(StringIO( -+ ''' -+ -+ -+ -+ -+ -+ -+ '''), dir='.') -+ outputs = root.children[0] -+ translations = root.children[1] -+ messages = root.children[2].children[0] -+ assert (isinstance(messages, grit.node.empty.MessagesNode) and -+ isinstance(translations, grit.node.empty.TranslationsNode) and -+ isinstance(outputs, grit.node.empty.OutputsNode)) -+ -+ if self.header_dir: -+ cpp_header = self.__CreateCppHeaderOutputNode(outputs, self.header_dir) -+ for lang in self.languages: -+ # Create an output element for each language. -+ if self.rc_dir: -+ self.__CreateRcOutputNode(outputs, lang, self.rc_dir) -+ if self.xml_res_dir: -+ self.__CreateAndroidXmlOutputNode(outputs, lang, self.xml_res_dir) -+ if lang != 'en': -+ self.__CreateFileNode(translations, lang) -+ # Convert all the strings.xml strings into grd messages. -+ self.__CreateMessageNodes(messages, android_dom.documentElement) -+ -+ return root -+ -+ def __CreateMessageNodes(self, messages, resources): -+ """Creates the elements and adds them as children of . -+ -+ Args: -+ messages: the element in the strings.xml dom. -+ resources: the element in the grd dom. -+ """ -+ # elements contain the definition of the resource. -+ # The description of a element is contained within the comment -+ # node element immediately preceeding the string element in question. -+ description = '' -+ for child in resources.childNodes: -+ if child.nodeType == Node.COMMENT_NODE: -+ # Remove leading/trailing whitespace; collapse consecutive whitespaces. -+ description = ' '.join(child.data.split()) -+ elif child.nodeType == Node.ELEMENT_NODE: -+ if child.tagName != 'string': -+ print('Warning: ignoring unknown tag <%s>' % child.tagName) -+ else: -+ translatable = self.IsTranslatable(child) -+ raw_name = child.getAttribute('name') -+ if not _STRING_NAME.match(raw_name): -+ print('Error: illegal string name: %s' % raw_name) -+ grd_name = 'IDS_' + raw_name.upper() -+ # Transform the node contents into a tclib.Message, taking -+ # care to handle whitespace transformations and escaped characters, -+ # and coverting placeholders into placeholders. -+ msg = self.CreateTclibMessage(child) -+ msg_node = self.__CreateMessageNode(messages, grd_name, description, -+ msg, translatable) -+ messages.AddChild(msg_node) -+ # Reset the description once a message has been parsed. -+ description = '' -+ -+ def CreateTclibMessage(self, android_string): -+ """Transforms a element from strings.xml into a tclib.Message. -+ -+ Interprets whitespace, quotes, and escaped characters in the android_string -+ according to Android's formatting and styling rules for strings. Also -+ converts placeholders into placeholders, e.g.: -+ -+ %s -+ becomes -+ google.com%s -+ -+ Returns: -+ The tclib.Message. -+ """ -+ msg = tclib.Message() -+ current_text = '' # Accumulated text that hasn't yet been added to msg. -+ nodes = android_string.childNodes -+ -+ for i, node in enumerate(nodes): -+ # Handle text nodes. -+ if node.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): -+ current_text += node.data -+ -+ # Handle and other tags. -+ elif node.nodeType == Node.ELEMENT_NODE: -+ if node.tagName == 'xliff:g': -+ assert node.hasAttribute('id'), 'missing id: ' + node.data() -+ placeholder_id = node.getAttribute('id') -+ placeholder_text = self.__FormatPlaceholderText(node) -+ placeholder_example = node.getAttribute('example') -+ if not placeholder_example: -+ print('Info: placeholder does not contain an example: %s' % -+ node.toxml()) -+ placeholder_example = placeholder_id.upper() -+ msg.AppendPlaceholder(tclib.Placeholder(placeholder_id, -+ placeholder_text, placeholder_example)) -+ else: -+ print('Warning: removing tag <%s> which must be inside a ' -+ 'placeholder: %s' % (node.tagName, node.toxml())) -+ msg.AppendText(self.__FormatPlaceholderText(node)) -+ -+ # Handle other nodes. -+ elif node.nodeType != Node.COMMENT_NODE: -+ assert False, 'Unknown node type: %s' % node.nodeType -+ -+ is_last_node = (i == len(nodes) - 1) -+ if (current_text and -+ (is_last_node or nodes[i + 1].nodeType == Node.ELEMENT_NODE)): -+ # For messages containing just text and comments (no xml tags) Android -+ # strips leading and trailing whitespace. We mimic that behavior. -+ if not msg.GetContent() and is_last_node: -+ current_text = current_text.strip() -+ msg.AppendText(self.__FormatAndroidString(current_text)) -+ current_text = '' -+ -+ return msg -+ -+ def __FormatAndroidString(self, android_string, inside_placeholder=False): -+ r"""Returns android_string formatted for a .grd file. -+ -+ * Collapses consecutive whitespaces, except when inside double-quotes. -+ * Replaces \\, \n, \t, \", \' with \, newline, tab, ", '. -+ """ -+ backslash_map = {'\\' : '\\', 'n' : '\n', 't' : '\t', '"' : '"', "'" : "'"} -+ is_quoted_section = False # True when we're inside double quotes. -+ is_backslash_sequence = False # True after seeing an unescaped backslash. -+ prev_char = '' -+ output = [] -+ for c in android_string: -+ if is_backslash_sequence: -+ # Unescape \\, \n, \t, \", and \'. -+ assert c in backslash_map, 'Illegal escape sequence: \\%s' % c -+ output.append(backslash_map[c]) -+ is_backslash_sequence = False -+ elif c == '\\': -+ is_backslash_sequence = True -+ elif c.isspace() and not is_quoted_section: -+ # Turn whitespace into ' ' and collapse consecutive whitespaces. -+ if not prev_char.isspace(): -+ output.append(' ') -+ elif c == '"': -+ is_quoted_section = not is_quoted_section -+ else: -+ output.append(c) -+ prev_char = c -+ output = ''.join(output) -+ -+ if is_quoted_section: -+ print('Warning: unbalanced quotes in string: %s' % android_string) -+ -+ if is_backslash_sequence: -+ print('Warning: trailing backslash in string: %s' % android_string) -+ -+ # Check for format specifiers outside of placeholder tags. -+ if not inside_placeholder: -+ format_specifier = _FORMAT_SPECIFIER.search(output) -+ if format_specifier: -+ print('Warning: format specifiers are not inside a placeholder ' -+ ' tag: %s' % output) -+ -+ return output -+ -+ def __FormatPlaceholderText(self, placeholder_node): -+ """Returns the text inside of an placeholder node.""" -+ text = [] -+ for childNode in placeholder_node.childNodes: -+ if childNode.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): -+ text.append(childNode.data) -+ elif childNode.nodeType != Node.COMMENT_NODE: -+ assert False, 'Unknown node type in ' + placeholder_node.toxml() -+ return self.__FormatAndroidString(''.join(text), inside_placeholder=True) -+ -+ def __CreateMessageNode(self, messages_node, grd_name, description, msg, -+ translatable): -+ """Creates and initializes a element. -+ -+ Message elements correspond to Android elements in that they -+ declare a string resource along with a programmatic id. -+ """ -+ if not description: -+ print('Warning: no description for %s' % grd_name) -+ # Check that we actually fit within the character limit we've specified. -+ match = _CHAR_LIMIT.search(description) -+ if match: -+ char_limit = int(match.group(1)) -+ msg_content = msg.GetRealContent() -+ if len(msg_content) > char_limit: -+ print('Warning: char-limit for %s is %d, but length is %d: %s' % -+ (grd_name, char_limit, len(msg_content), msg_content)) -+ return message.MessageNode.Construct(parent=messages_node, -+ name=grd_name, -+ message=msg, -+ desc=description, -+ translateable=translatable) -+ -+ def __CreateFileNode(self, translations_node, lang): -+ """Creates and initializes the elements. -+ -+ File elements provide information on the location of translation files -+ (xtbs) -+ """ -+ xtb_file = os.path.normpath(os.path.join( -+ self.xtb_dir, '%s_%s.xtb' % (self.name, lang))) -+ fnode = node_io.FileNode() -+ fnode.StartParsing(u'file', translations_node) -+ fnode.HandleAttribute('path', xtb_file) -+ fnode.HandleAttribute('lang', lang) -+ fnode.EndParsing() -+ translations_node.AddChild(fnode) -+ return fnode -+ -+ def __CreateCppHeaderOutputNode(self, outputs_node, header_dir): -+ """Creates the element corresponding to the generated c header.""" -+ header_file_name = os.path.join(header_dir, self.name + '.h') -+ header_node = node_io.OutputNode() -+ header_node.StartParsing(u'output', outputs_node) -+ header_node.HandleAttribute('filename', header_file_name) -+ header_node.HandleAttribute('type', 'rc_header') -+ emit_node = node_io.EmitNode() -+ emit_node.StartParsing(u'emit', header_node) -+ emit_node.HandleAttribute('emit_type', 'prepend') -+ emit_node.EndParsing() -+ header_node.AddChild(emit_node) -+ header_node.EndParsing() -+ outputs_node.AddChild(header_node) -+ return header_node -+ -+ def __CreateRcOutputNode(self, outputs_node, lang, rc_dir): -+ """Creates the element corresponding to various rc file output.""" -+ rc_file_name = self.name + '_' + lang + ".rc" -+ rc_path = os.path.join(rc_dir, rc_file_name) -+ node = node_io.OutputNode() -+ node.StartParsing(u'output', outputs_node) -+ node.HandleAttribute('filename', rc_path) -+ node.HandleAttribute('lang', lang) -+ node.HandleAttribute('type', 'rc_all') -+ node.EndParsing() -+ outputs_node.AddChild(node) -+ return node -+ -+ def __CreateAndroidXmlOutputNode(self, outputs_node, locale, xml_res_dir): -+ """Creates the element corresponding to various rc file output.""" -+ # Need to check to see if the locale has a region, e.g. the GB in en-GB. -+ # When a locale has a region Android expects the region to be prefixed -+ # with an 'r'. For example for en-GB Android expects a values-en-rGB -+ # directory. Also, Android expects nb, tl, in, iw, ji as the language -+ # codes for Norwegian, Tagalog/Filipino, Indonesian, Hebrew, and Yiddish: -+ # http://developer.android.com/reference/java/util/Locale.html -+ if locale == 'es-419': -+ android_locale = 'es-rUS' -+ else: -+ android_lang, dash, region = locale.partition('-') -+ lang_map = {'no': 'nb', 'fil': 'tl', 'id': 'in', 'he': 'iw', 'yi': 'ji'} -+ android_lang = lang_map.get(android_lang, android_lang) -+ android_locale = android_lang + ('-r' + region if region else '') -+ values = 'values-' + android_locale if android_locale != 'en' else 'values' -+ xml_path = os.path.normpath(os.path.join( -+ xml_res_dir, values, 'strings.xml')) -+ -+ node = node_io.OutputNode() -+ node.StartParsing(u'output', outputs_node) -+ node.HandleAttribute('filename', xml_path) -+ node.HandleAttribute('lang', locale) -+ node.HandleAttribute('type', 'android') -+ node.EndParsing() -+ outputs_node.AddChild(node) -+ return node -+ -+ def IsTranslatable(self, android_string): -+ """Determines if a element is a candidate for translation. -+ -+ A element is by default translatable unless otherwise marked. -+ """ -+ if android_string.hasAttribute('translatable'): -+ value = android_string.getAttribute('translatable').lower() -+ if value not in ('true', 'false'): -+ print('Warning: translatable attribute has invalid value: %s' % value) -+ return value == 'true' -+ else: -+ return True -diff --git a/tools/grit/grit/tool/android2grd_unittest.py b/tools/grit/grit/tool/android2grd_unittest.py -new file mode 100644 -index 0000000000..a6934a707c ---- /dev/null -+++ b/tools/grit/grit/tool/android2grd_unittest.py -@@ -0,0 +1,181 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.tool.android2grd''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import unittest -+import xml.dom.minidom -+ -+from grit import util -+from grit.node import empty -+from grit.node import message -+from grit.node import misc -+from grit.node import node_io -+from grit.tool import android2grd -+ -+ -+class Android2GrdUnittest(unittest.TestCase): -+ -+ def __Parse(self, xml_string): -+ return xml.dom.minidom.parseString(xml_string).childNodes[0] -+ -+ def testCreateTclibMessage(self): -+ tool = android2grd.Android2Grd() -+ msg = tool.CreateTclibMessage(self.__Parse(r''' -+ A simple string''')) -+ self.assertEqual(msg.GetRealContent(), 'A simple string') -+ msg = tool.CreateTclibMessage(self.__Parse(r''' -+ -+ Strip leading/trailing whitespace -+ ''')) -+ self.assertEqual(msg.GetRealContent(), 'Strip leading/trailing whitespace') -+ msg = tool.CreateTclibMessage(self.__Parse(r''' -+ Fold multiple spaces''')) -+ self.assertEqual(msg.GetRealContent(), 'Fold multiple spaces') -+ msg = tool.CreateTclibMessage(self.__Parse(r''' -+ Retain \n escaped\t spaces''')) -+ self.assertEqual(msg.GetRealContent(), 'Retain \n escaped\t spaces') -+ msg = tool.CreateTclibMessage(self.__Parse(r''' -+ " Quotes preserve -+ whitespace" but only for "enclosed elements " -+ ''')) -+ self.assertEqual(msg.GetRealContent(), ''' Quotes preserve -+ whitespace but only for enclosed elements ''') -+ msg = tool.CreateTclibMessage(self.__Parse( -+ r'''Escaped characters: \"\'\\\t\n''' -+ '')) -+ self.assertEqual(msg.GetRealContent(), '''Escaped characters: "'\\\t\n''') -+ msg = tool.CreateTclibMessage(self.__Parse( -+ '' -+ 'Open %s?' -+ '')) -+ self.assertEqual(msg.GetRealContent(), 'Open %s?') -+ self.assertEqual(len(msg.GetPlaceholders()), 1) -+ self.assertEqual(msg.GetPlaceholders()[0].presentation, 'FILENAME') -+ self.assertEqual(msg.GetPlaceholders()[0].original, '%s') -+ self.assertEqual(msg.GetPlaceholders()[0].example, 'internet.html') -+ msg = tool.CreateTclibMessage(self.__Parse(r''' -+ Contains a comment -+ ''')) -+ self.assertEqual(msg.GetRealContent(), 'Contains a comment') -+ -+ def testIsTranslatable(self): -+ tool = android2grd.Android2Grd() -+ string_el = self.__Parse('Hi') -+ self.assertTrue(tool.IsTranslatable(string_el)) -+ string_el = self.__Parse( -+ 'Hi') -+ self.assertTrue(tool.IsTranslatable(string_el)) -+ string_el = self.__Parse( -+ 'Hi') -+ self.assertFalse(tool.IsTranslatable(string_el)) -+ -+ def __ParseAndroidXml(self, options = []): -+ tool = android2grd.Android2Grd() -+ -+ tool.ParseOptions(options) -+ -+ android_path = util.PathFromRoot('grit/testdata/android.xml') -+ with open(android_path) as android_file: -+ android_dom = xml.dom.minidom.parse(android_file) -+ -+ grd = tool.AndroidDomToGrdDom(android_dom) -+ self.assertTrue(isinstance(grd, misc.GritNode)) -+ -+ return grd -+ -+ def testAndroidDomToGrdDom(self): -+ grd = self.__ParseAndroidXml(['--languages', 'en-US,en-GB,ru']) -+ -+ # Check that the structure of the GritNode is as expected. -+ messages = grd.GetChildrenOfType(message.MessageNode) -+ translations = grd.GetChildrenOfType(empty.TranslationsNode) -+ files = grd.GetChildrenOfType(node_io.FileNode) -+ -+ self.assertEqual(len(translations), 1) -+ self.assertEqual(len(files), 3) -+ self.assertEqual(len(messages), 5) -+ -+ # Check that a message node is constructed correctly. -+ msg = [x for x in messages if x.GetTextualIds()[0] == 'IDS_PLACEHOLDERS'] -+ self.assertTrue(msg) -+ msg = msg[0] -+ -+ self.assertTrue(msg.IsTranslateable()) -+ self.assertEqual(msg.attrs["desc"], "A string with placeholder.") -+ -+ def testTranslatableAttribute(self): -+ grd = self.__ParseAndroidXml([]) -+ messages = grd.GetChildrenOfType(message.MessageNode) -+ msgs = [x for x in messages if x.GetTextualIds()[0] == 'IDS_CONSTANT'] -+ self.assertTrue(msgs) -+ self.assertFalse(msgs[0].IsTranslateable()) -+ -+ def testTranslations(self): -+ grd = self.__ParseAndroidXml(['--languages', 'en-US,en-GB,ru,id']) -+ -+ files = grd.GetChildrenOfType(node_io.FileNode) -+ us_file = [x for x in files if x.attrs['lang'] == 'en-US'] -+ self.assertTrue(us_file) -+ self.assertEqual(us_file[0].GetInputPath(), -+ 'chrome_android_strings_en-US.xtb') -+ -+ id_file = [x for x in files if x.attrs['lang'] == 'id'] -+ self.assertTrue(id_file) -+ self.assertEqual(id_file[0].GetInputPath(), -+ 'chrome_android_strings_id.xtb') -+ -+ def testOutputs(self): -+ grd = self.__ParseAndroidXml(['--languages', 'en-US,ru,id', -+ '--rc-dir', 'rc/dir', -+ '--header-dir', 'header/dir', -+ '--xtb-dir', 'xtb/dir', -+ '--xml-dir', 'xml/dir']) -+ -+ outputs = grd.GetChildrenOfType(node_io.OutputNode) -+ self.assertEqual(len(outputs), 7) -+ -+ header_outputs = [x for x in outputs if x.GetType() == 'rc_header'] -+ rc_outputs = [x for x in outputs if x.GetType() == 'rc_all'] -+ xml_outputs = [x for x in outputs if x.GetType() == 'android'] -+ -+ self.assertEqual(len(header_outputs), 1) -+ self.assertEqual(len(rc_outputs), 3) -+ self.assertEqual(len(xml_outputs), 3) -+ -+ # The header node should have an "" child and the proper filename. -+ self.assertTrue(header_outputs[0].GetChildrenOfType(node_io.EmitNode)) -+ self.assertEqual(util.normpath(header_outputs[0].GetFilename()), -+ util.normpath('header/dir/chrome_android_strings.h')) -+ -+ id_rc = [x for x in rc_outputs if x.GetLanguage() == 'id'] -+ id_xml = [x for x in xml_outputs if x.GetLanguage() == 'id'] -+ self.assertTrue(id_rc) -+ self.assertTrue(id_xml) -+ self.assertEqual(util.normpath(id_rc[0].GetFilename()), -+ util.normpath('rc/dir/chrome_android_strings_id.rc')) -+ self.assertEqual(util.normpath(id_xml[0].GetFilename()), -+ util.normpath('xml/dir/values-in/strings.xml')) -+ -+ us_rc = [x for x in rc_outputs if x.GetLanguage() == 'en-US'] -+ us_xml = [x for x in xml_outputs if x.GetLanguage() == 'en-US'] -+ self.assertTrue(us_rc) -+ self.assertTrue(us_xml) -+ self.assertEqual(util.normpath(us_rc[0].GetFilename()), -+ util.normpath('rc/dir/chrome_android_strings_en-US.rc')) -+ self.assertEqual(util.normpath(us_xml[0].GetFilename()), -+ util.normpath('xml/dir/values-en-rUS/strings.xml')) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/tool/build.py b/tools/grit/grit/tool/build.py -new file mode 100644 -index 0000000000..204592bf0d ---- /dev/null -+++ b/tools/grit/grit/tool/build.py -@@ -0,0 +1,556 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''The 'grit build' tool. -+''' -+ -+from __future__ import print_function -+ -+import codecs -+import filecmp -+import getopt -+import gzip -+import os -+import shutil -+import sys -+ -+import six -+ -+from grit import grd_reader -+from grit import shortcuts -+from grit import util -+from grit.format import minifier -+from grit.node import brotli_util -+from grit.node import include -+from grit.node import message -+from grit.node import structure -+from grit.tool import interface -+ -+ -+# It would be cleaner to have each module register itself, but that would -+# require importing all of them on every run of GRIT. -+'''Map from node types to modules under grit.format.''' -+_format_modules = { -+ 'android': 'android_xml', -+ 'c_format': 'c_format', -+ 'chrome_messages_json': 'chrome_messages_json', -+ 'chrome_messages_json_gzip': 'chrome_messages_json', -+ 'data_package': 'data_pack', -+ 'policy_templates': 'policy_templates_json', -+ 'rc_all': 'rc', -+ 'rc_header': 'rc_header', -+ 'rc_nontranslateable': 'rc', -+ 'rc_translateable': 'rc', -+ 'resource_file_map_source': 'resource_map', -+ 'resource_map_header': 'resource_map', -+ 'resource_map_source': 'resource_map', -+} -+ -+def GetFormatter(type): -+ modulename = 'grit.format.' + _format_modules[type] -+ __import__(modulename) -+ module = sys.modules[modulename] -+ try: -+ return module.Format -+ except AttributeError: -+ return module.GetFormatter(type) -+ -+ -+class RcBuilder(interface.Tool): -+ '''A tool that builds RC files and resource header files for compilation. -+ -+Usage: grit build [-o OUTPUTDIR] [-D NAME[=VAL]]* -+ -+All output options for this tool are specified in the input file (see -+'grit help' for details on how to specify the input file - it is a global -+option). -+ -+Options: -+ -+ -a FILE Assert that the given file is an output. There can be -+ multiple "-a" flags listed for multiple outputs. If a "-a" -+ or "--assert-file-list" argument is present, then the list -+ of asserted files must match the output files or the tool -+ will fail. The use-case is for the build system to maintain -+ separate lists of output files and to catch errors if the -+ build system's list and the grit list are out-of-sync. -+ -+ --assert-file-list Provide a file listing multiple asserted output files. -+ There is one file name per line. This acts like specifying -+ each file with "-a" on the command line, but without the -+ possibility of running into OS line-length limits for very -+ long lists. -+ -+ -o OUTPUTDIR Specify what directory output paths are relative to. -+ Defaults to the current directory. -+ -+ -p FILE Specify a file containing a pre-determined mapping from -+ resource names to resource ids which will be used to assign -+ resource ids to those resources. Resources not found in this -+ file will be assigned ids normally. The motivation is to run -+ your app's startup and have it dump the resources it loads, -+ and then pass these via this flag. This will pack startup -+ resources together, thus reducing paging while all other -+ resources are unperturbed. The file should have the format: -+ RESOURCE_ONE_NAME 123 -+ RESOURCE_TWO_NAME 124 -+ -+ -D NAME[=VAL] Specify a C-preprocessor-like define NAME with optional -+ value VAL (defaults to 1) which will be used to control -+ conditional inclusion of resources. -+ -+ -E NAME=VALUE Set environment variable NAME to VALUE (within grit). -+ -+ -f FIRSTIDSFILE Path to a python file that specifies the first id of -+ value to use for resources. A non-empty value here will -+ override the value specified in the node's -+ first_ids_file. -+ -+ -w WHITELISTFILE Path to a file containing the string names of the -+ resources to include. Anything not listed is dropped. -+ -+ -t PLATFORM Specifies the platform the build is targeting; defaults -+ to the value of sys.platform. The value provided via this -+ flag should match what sys.platform would report for your -+ target platform; see grit.node.base.EvaluateCondition. -+ -+ --whitelist-support -+ Generate code to support extracting a resource whitelist -+ from executables. -+ -+ --write-only-new flag -+ If flag is non-0, write output files to a temporary file -+ first, and copy it to the real output only if the new file -+ is different from the old file. This allows some build -+ systems to realize that dependent build steps might be -+ unnecessary, at the cost of comparing the output data at -+ grit time. -+ -+ --depend-on-stamp -+ If specified along with --depfile and --depdir, the depfile -+ generated will depend on a stampfile instead of the first -+ output in the input .grd file. -+ -+ --js-minifier A command to run the Javascript minifier. If not set then -+ Javascript won't be minified. The command should read the -+ original Javascript from standard input, and output the -+ minified Javascript to standard output. A non-zero exit -+ status will be taken as indicating failure. -+ -+ --css-minifier A command to run the CSS minifier. If not set then CSS won't -+ be minified. The command should read the original CSS from -+ standard input, and output the minified CSS to standard -+ output. A non-zero exit status will be taken as indicating -+ failure. -+ -+ --brotli The full path to the brotli executable generated by -+ third_party/brotli/BUILD.gn, required if any entries use -+ compress="brotli". -+ -+Conditional inclusion of resources only affects the output of files which -+control which resources get linked into a binary, e.g. it affects .rc files -+meant for compilation but it does not affect resource header files (that define -+IDs). This helps ensure that values of IDs stay the same, that all messages -+are exported to translation interchange files (e.g. XMB files), etc. -+''' -+ -+ def ShortDescription(self): -+ return 'A tool that builds RC files for compilation.' -+ -+ def Run(self, opts, args): -+ brotli_util.SetBrotliCommand(None) -+ os.environ['cwd'] = os.getcwd() -+ self.output_directory = '.' -+ first_ids_file = None -+ predetermined_ids_file = None -+ whitelist_filenames = [] -+ assert_output_files = [] -+ target_platform = None -+ depfile = None -+ depdir = None -+ whitelist_support = False -+ write_only_new = False -+ depend_on_stamp = False -+ js_minifier = None -+ css_minifier = None -+ replace_ellipsis = True -+ (own_opts, args) = getopt.getopt( -+ args, 'a:p:o:D:E:f:w:t:', -+ ('depdir=', 'depfile=', 'assert-file-list=', 'help', -+ 'output-all-resource-defines', 'no-output-all-resource-defines', -+ 'no-replace-ellipsis', 'depend-on-stamp', 'js-minifier=', -+ 'css-minifier=', 'write-only-new=', 'whitelist-support', 'brotli=')) -+ for (key, val) in own_opts: -+ if key == '-a': -+ assert_output_files.append(val) -+ elif key == '--assert-file-list': -+ with open(val) as f: -+ assert_output_files += f.read().splitlines() -+ elif key == '-o': -+ self.output_directory = val -+ elif key == '-D': -+ name, val = util.ParseDefine(val) -+ self.defines[name] = val -+ elif key == '-E': -+ (env_name, env_value) = val.split('=', 1) -+ os.environ[env_name] = env_value -+ elif key == '-f': -+ # TODO(joi@chromium.org): Remove this override once change -+ # lands in WebKit.grd to specify the first_ids_file in the -+ # .grd itself. -+ first_ids_file = val -+ elif key == '-w': -+ whitelist_filenames.append(val) -+ elif key == '--no-replace-ellipsis': -+ replace_ellipsis = False -+ elif key == '-p': -+ predetermined_ids_file = val -+ elif key == '-t': -+ target_platform = val -+ elif key == '--depdir': -+ depdir = val -+ elif key == '--depfile': -+ depfile = val -+ elif key == '--write-only-new': -+ write_only_new = val != '0' -+ elif key == '--depend-on-stamp': -+ depend_on_stamp = True -+ elif key == '--js-minifier': -+ js_minifier = val -+ elif key == '--css-minifier': -+ css_minifier = val -+ elif key == '--whitelist-support': -+ whitelist_support = True -+ elif key == '--brotli': -+ brotli_util.SetBrotliCommand([os.path.abspath(val)]) -+ elif key == '--help': -+ self.ShowUsage() -+ sys.exit(0) -+ -+ if len(args): -+ print('This tool takes no tool-specific arguments.') -+ return 2 -+ self.SetOptions(opts) -+ self.VerboseOut('Output directory: %s (absolute path: %s)\n' % -+ (self.output_directory, -+ os.path.abspath(self.output_directory))) -+ -+ if whitelist_filenames: -+ self.whitelist_names = set() -+ for whitelist_filename in whitelist_filenames: -+ self.VerboseOut('Using whitelist: %s\n' % whitelist_filename); -+ whitelist_contents = util.ReadFile(whitelist_filename, 'utf-8') -+ self.whitelist_names.update(whitelist_contents.strip().split('\n')) -+ -+ if js_minifier: -+ minifier.SetJsMinifier(js_minifier) -+ -+ if css_minifier: -+ minifier.SetCssMinifier(css_minifier) -+ -+ self.write_only_new = write_only_new -+ -+ self.res = grd_reader.Parse(opts.input, -+ debug=opts.extra_verbose, -+ first_ids_file=first_ids_file, -+ predetermined_ids_file=predetermined_ids_file, -+ defines=self.defines, -+ target_platform=target_platform) -+ -+ # Set an output context so that conditionals can use defines during the -+ # gathering stage; we use a dummy language here since we are not outputting -+ # a specific language. -+ self.res.SetOutputLanguage('en') -+ self.res.SetWhitelistSupportEnabled(whitelist_support) -+ self.res.RunGatherers() -+ -+ # Replace ... with the single-character version. http://crbug.com/621772 -+ if replace_ellipsis: -+ for node in self.res: -+ if isinstance(node, message.MessageNode): -+ node.SetReplaceEllipsis(True) -+ -+ self.Process() -+ -+ if assert_output_files: -+ if not self.CheckAssertedOutputFiles(assert_output_files): -+ return 2 -+ -+ if depfile and depdir: -+ self.GenerateDepfile(depfile, depdir, first_ids_file, depend_on_stamp) -+ -+ return 0 -+ -+ def __init__(self, defines=None): -+ # Default file-creation function is codecs.open(). Only done to allow -+ # overriding by unit test. -+ self.fo_create = codecs.open -+ -+ # key/value pairs of C-preprocessor like defines that are used for -+ # conditional output of resources -+ self.defines = defines or {} -+ -+ # self.res is a fully-populated resource tree if Run() -+ # has been called, otherwise None. -+ self.res = None -+ -+ # The set of names that are whitelisted to actually be included in the -+ # output. -+ self.whitelist_names = None -+ -+ # Whether to compare outputs to their old contents before writing. -+ self.write_only_new = False -+ -+ @staticmethod -+ def AddWhitelistTags(start_node, whitelist_names): -+ # Walk the tree of nodes added attributes for the nodes that shouldn't -+ # be written into the target files (skip markers). -+ for node in start_node: -+ # Same trick data_pack.py uses to see what nodes actually result in -+ # real items. -+ if (isinstance(node, include.IncludeNode) or -+ isinstance(node, message.MessageNode) or -+ isinstance(node, structure.StructureNode)): -+ text_ids = node.GetTextualIds() -+ # Mark the item to be skipped if it wasn't in the whitelist. -+ if text_ids and text_ids[0] not in whitelist_names: -+ node.SetWhitelistMarkedAsSkip(True) -+ -+ @staticmethod -+ def ProcessNode(node, output_node, outfile): -+ '''Processes a node in-order, calling its formatter before and after -+ recursing to its children. -+ -+ Args: -+ node: grit.node.base.Node subclass -+ output_node: grit.node.io.OutputNode -+ outfile: open filehandle -+ ''' -+ base_dir = util.dirname(output_node.GetOutputFilename()) -+ -+ formatter = GetFormatter(output_node.GetType()) -+ formatted = formatter(node, output_node.GetLanguage(), output_dir=base_dir) -+ # NB: Formatters may be generators or return lists. The writelines API -+ # accepts iterables as a shortcut to calling write directly. That means -+ # you can pass strings (iteration yields characters), but not bytes (as -+ # iteration yields integers). Python 2 worked due to its quirks with -+ # bytes/string implementation, but Python 3 fails. It's also a bit more -+ # inefficient to call write once per character/byte. Handle all of this -+ # ourselves by calling write directly on strings/bytes before falling back -+ # to writelines. -+ if isinstance(formatted, (six.string_types, six.binary_type)): -+ outfile.write(formatted) -+ else: -+ outfile.writelines(formatted) -+ if output_node.GetType() == 'data_package': -+ with open(output_node.GetOutputFilename() + '.info', 'w') as infofile: -+ if node.info: -+ # We terminate with a newline so that when these files are -+ # concatenated later we consistently terminate with a newline so -+ # consumers can account for terminating newlines. -+ infofile.writelines(['\n'.join(node.info), '\n']) -+ -+ @staticmethod -+ def _EncodingForOutputType(output_type): -+ # Microsoft's RC compiler can only deal with single-byte or double-byte -+ # files (no UTF-8), so we make all RC files UTF-16 to support all -+ # character sets. -+ if output_type in ('rc_header', 'resource_file_map_source', -+ 'resource_map_header', 'resource_map_source'): -+ return 'cp1252' -+ if output_type in ('android', 'c_format', 'plist', 'plist_strings', 'doc', -+ 'json', 'android_policy', 'chrome_messages_json', -+ 'chrome_messages_json_gzip', 'policy_templates'): -+ return 'utf_8' -+ # TODO(gfeher) modify here to set utf-8 encoding for admx/adml -+ return 'utf_16' -+ -+ def Process(self): -+ for output in self.res.GetOutputFiles(): -+ output.output_filename = os.path.abspath(os.path.join( -+ self.output_directory, output.GetOutputFilename())) -+ -+ # If there are whitelisted names, tag the tree once up front, this way -+ # while looping through the actual output, it is just an attribute check. -+ if self.whitelist_names: -+ self.AddWhitelistTags(self.res, self.whitelist_names) -+ -+ for output in self.res.GetOutputFiles(): -+ self.VerboseOut('Creating %s...' % output.GetOutputFilename()) -+ -+ # Set the context, for conditional inclusion of resources -+ self.res.SetOutputLanguage(output.GetLanguage()) -+ self.res.SetOutputContext(output.GetContext()) -+ self.res.SetFallbackToDefaultLayout(output.GetFallbackToDefaultLayout()) -+ self.res.SetDefines(self.defines) -+ -+ # Assign IDs only once to ensure that all outputs use the same IDs. -+ if self.res.GetIdMap() is None: -+ self.res.InitializeIds() -+ -+ # Make the output directory if it doesn't exist. -+ self.MakeDirectoriesTo(output.GetOutputFilename()) -+ -+ # Write the results to a temporary file and only overwrite the original -+ # if the file changed. This avoids unnecessary rebuilds. -+ out_filename = output.GetOutputFilename() -+ tmp_filename = out_filename + '.tmp' -+ tmpfile = self.fo_create(tmp_filename, 'wb') -+ -+ output_type = output.GetType() -+ if output_type != 'data_package': -+ encoding = self._EncodingForOutputType(output_type) -+ tmpfile = util.WrapOutputStream(tmpfile, encoding) -+ -+ # Iterate in-order through entire resource tree, calling formatters on -+ # the entry into a node and on exit out of it. -+ with tmpfile: -+ self.ProcessNode(self.res, output, tmpfile) -+ -+ if output_type == 'chrome_messages_json_gzip': -+ gz_filename = tmp_filename + '.gz' -+ with open(tmp_filename, 'rb') as tmpfile, open(gz_filename, 'wb') as f: -+ with gzip.GzipFile(filename='', mode='wb', fileobj=f, mtime=0) as fgz: -+ shutil.copyfileobj(tmpfile, fgz) -+ os.remove(tmp_filename) -+ tmp_filename = gz_filename -+ -+ # Now copy from the temp file back to the real output, but on Windows, -+ # only if the real output doesn't exist or the contents of the file -+ # changed. This prevents identical headers from being written and .cc -+ # files from recompiling (which is painful on Windows). -+ if not os.path.exists(out_filename): -+ os.rename(tmp_filename, out_filename) -+ else: -+ # CHROMIUM SPECIFIC CHANGE. -+ # This clashes with gyp + vstudio, which expect the output timestamp -+ # to change on a rebuild, even if nothing has changed, so only do -+ # it when opted in. -+ if not self.write_only_new: -+ write_file = True -+ else: -+ files_match = filecmp.cmp(out_filename, tmp_filename) -+ write_file = not files_match -+ if write_file: -+ shutil.copy2(tmp_filename, out_filename) -+ os.remove(tmp_filename) -+ -+ self.VerboseOut(' done.\n') -+ -+ # Print warnings if there are any duplicate shortcuts. -+ warnings = shortcuts.GenerateDuplicateShortcutsWarnings( -+ self.res.UberClique(), self.res.GetTcProject()) -+ if warnings: -+ print('\n'.join(warnings)) -+ -+ # Print out any fallback warnings, and missing translation errors, and -+ # exit with an error code if there are missing translations in a non-pseudo -+ # and non-official build. -+ warnings = (self.res.UberClique().MissingTranslationsReport(). -+ encode('ascii', 'replace')) -+ if warnings: -+ self.VerboseOut(warnings) -+ if self.res.UberClique().HasMissingTranslations(): -+ print(self.res.UberClique().missing_translations_) -+ sys.exit(-1) -+ -+ -+ def CheckAssertedOutputFiles(self, assert_output_files): -+ '''Checks that the asserted output files are specified in the given list. -+ -+ Returns true if the asserted files are present. If they are not, returns -+ False and prints the failure. -+ ''' -+ # Compare the absolute path names, sorted. -+ asserted = sorted([os.path.abspath(i) for i in assert_output_files]) -+ actual = sorted([ -+ os.path.abspath(os.path.join(self.output_directory, -+ i.GetOutputFilename())) -+ for i in self.res.GetOutputFiles()]) -+ -+ if asserted != actual: -+ missing = list(set(asserted) - set(actual)) -+ extra = list(set(actual) - set(asserted)) -+ error = '''Asserted file list does not match. -+ -+Expected output files: -+%s -+Actual output files: -+%s -+Missing output files: -+%s -+Extra output files: -+%s -+''' -+ print(error % ('\n'.join(asserted), '\n'.join(actual), '\n'.join(missing), -+ ' \n'.join(extra))) -+ return False -+ return True -+ -+ -+ def GenerateDepfile(self, depfile, depdir, first_ids_file, depend_on_stamp): -+ '''Generate a depfile that contains the imlicit dependencies of the input -+ grd. The depfile will be in the same format as a makefile, and will contain -+ references to files relative to |depdir|. It will be put in |depfile|. -+ -+ For example, supposing we have three files in a directory src/ -+ -+ src/ -+ blah.grd <- depends on input{1,2}.xtb -+ input1.xtb -+ input2.xtb -+ -+ and we run -+ -+ grit -i blah.grd -o ../out/gen \ -+ --depdir ../out \ -+ --depfile ../out/gen/blah.rd.d -+ -+ from the directory src/ we will generate a depfile ../out/gen/blah.grd.d -+ that has the contents -+ -+ gen/blah.h: ../src/input1.xtb ../src/input2.xtb -+ -+ Where "gen/blah.h" is the first output (Ninja expects the .d file to list -+ the first output in cases where there is more than one). If the flag -+ --depend-on-stamp is specified, "gen/blah.rd.d.stamp" will be used that is -+ 'touched' whenever a new depfile is generated. -+ -+ Note that all paths in the depfile are relative to ../out, the depdir. -+ ''' -+ depfile = os.path.abspath(depfile) -+ depdir = os.path.abspath(depdir) -+ infiles = self.res.GetInputFiles() -+ -+ # We want to trigger a rebuild if the first ids change. -+ if first_ids_file is not None: -+ infiles.append(first_ids_file) -+ -+ if (depend_on_stamp): -+ output_file = depfile + ".stamp" -+ # Touch the stamp file before generating the depfile. -+ with open(output_file, 'a'): -+ os.utime(output_file, None) -+ else: -+ # Get the first output file relative to the depdir. -+ outputs = self.res.GetOutputFiles() -+ output_file = os.path.join(self.output_directory, -+ outputs[0].GetOutputFilename()) -+ -+ output_file = os.path.relpath(output_file, depdir) -+ # The path prefix to prepend to dependencies in the depfile. -+ prefix = os.path.relpath(os.getcwd(), depdir) -+ deps_text = ' '.join([os.path.join(prefix, i) for i in infiles]) -+ -+ depfile_contents = output_file + ': ' + deps_text -+ self.MakeDirectoriesTo(depfile) -+ outfile = self.fo_create(depfile, 'w', encoding='utf-8') -+ outfile.write(depfile_contents) -+ -+ @staticmethod -+ def MakeDirectoriesTo(file): -+ '''Creates directories necessary to contain |file|.''' -+ dir = os.path.split(file)[0] -+ if not os.path.exists(dir): -+ os.makedirs(dir) -diff --git a/tools/grit/grit/tool/build_unittest.py b/tools/grit/grit/tool/build_unittest.py -new file mode 100644 -index 0000000000..c4a2f2752b ---- /dev/null -+++ b/tools/grit/grit/tool/build_unittest.py -@@ -0,0 +1,341 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for the 'grit build' tool. -+''' -+ -+from __future__ import print_function -+ -+import codecs -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import unittest -+ -+from grit import util -+from grit.tool import build -+ -+ -+class BuildUnittest(unittest.TestCase): -+ -+ # IDs should not change based on whitelisting. -+ # Android WebView currently relies on this. -+ EXPECTED_ID_MAP = { -+ 'IDS_MESSAGE_WHITELISTED': 6889, -+ 'IDR_STRUCTURE_WHITELISTED': 11546, -+ 'IDR_STRUCTURE_IN_TRUE_IF_WHITELISTED': 11548, -+ 'IDR_INCLUDE_WHITELISTED': 15601, -+ } -+ -+ def testFindTranslationsWithSubstitutions(self): -+ # This is a regression test; we had a bug where GRIT would fail to find -+ # messages with substitutions e.g. "Hello [IDS_USER]" where IDS_USER is -+ # another . -+ output_dir = util.TempDir({}) -+ builder = build.RcBuilder() -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/substitute.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ builder.Run(DummyOpts(), ['-o', output_dir.GetPath()]) -+ output_dir.CleanUp() -+ -+ def testGenerateDepFile(self): -+ output_dir = util.TempDir({}) -+ builder = build.RcBuilder() -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/depfile.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ expected_dep_file = output_dir.GetPath('substitute.grd.d') -+ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), -+ '--depdir', output_dir.GetPath(), -+ '--depfile', expected_dep_file]) -+ -+ self.failUnless(os.path.isfile(expected_dep_file)) -+ with open(expected_dep_file) as f: -+ line = f.readline() -+ (dep_output_file, deps_string) = line.split(': ') -+ deps = deps_string.split(' ') -+ -+ self.failUnlessEqual("default_100_percent.pak", dep_output_file) -+ self.failUnlessEqual(deps, [ -+ util.PathFromRoot('grit/testdata/default_100_percent/a.png'), -+ util.PathFromRoot('grit/testdata/grit_part.grdp'), -+ util.PathFromRoot('grit/testdata/special_100_percent/a.png'), -+ ]) -+ output_dir.CleanUp() -+ -+ def testGenerateDepFileWithResourceIds(self): -+ output_dir = util.TempDir({}) -+ builder = build.RcBuilder() -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/substitute_no_ids.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ expected_dep_file = output_dir.GetPath('substitute_no_ids.grd.d') -+ builder.Run(DummyOpts(), -+ ['-f', util.PathFromRoot('grit/testdata/resource_ids'), -+ '-o', output_dir.GetPath(), -+ '--depdir', output_dir.GetPath(), -+ '--depfile', expected_dep_file]) -+ -+ self.failUnless(os.path.isfile(expected_dep_file)) -+ with open(expected_dep_file) as f: -+ line = f.readline() -+ (dep_output_file, deps_string) = line.split(': ') -+ deps = deps_string.split(' ') -+ -+ self.failUnlessEqual("resource.h", dep_output_file) -+ self.failUnlessEqual(2, len(deps)) -+ self.failUnlessEqual(deps[0], -+ util.PathFromRoot('grit/testdata/substitute.xmb')) -+ self.failUnlessEqual(deps[1], -+ util.PathFromRoot('grit/testdata/resource_ids')) -+ output_dir.CleanUp() -+ -+ def testAssertOutputs(self): -+ output_dir = util.TempDir({}) -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/substitute.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ -+ # Incomplete output file list should fail. -+ builder_fail = build.RcBuilder() -+ self.failUnlessEqual(2, -+ builder_fail.Run(DummyOpts(), [ -+ '-o', output_dir.GetPath(), -+ '-a', os.path.abspath( -+ output_dir.GetPath('en_generated_resources.rc'))])) -+ -+ # Complete output file list should succeed. -+ builder_ok = build.RcBuilder() -+ self.failUnlessEqual(0, -+ builder_ok.Run(DummyOpts(), [ -+ '-o', output_dir.GetPath(), -+ '-a', os.path.abspath( -+ output_dir.GetPath('en_generated_resources.rc')), -+ '-a', os.path.abspath( -+ output_dir.GetPath('sv_generated_resources.rc')), -+ '-a', os.path.abspath(output_dir.GetPath('resource.h'))])) -+ output_dir.CleanUp() -+ -+ def testAssertTemplateOutputs(self): -+ output_dir = util.TempDir({}) -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/substitute_tmpl.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ -+ # Incomplete output file list should fail. -+ builder_fail = build.RcBuilder() -+ self.failUnlessEqual(2, -+ builder_fail.Run(DummyOpts(), [ -+ '-o', output_dir.GetPath(), -+ '-E', 'name=foo', -+ '-a', os.path.abspath(output_dir.GetPath('en_foo_resources.rc'))])) -+ -+ # Complete output file list should succeed. -+ builder_ok = build.RcBuilder() -+ self.failUnlessEqual(0, -+ builder_ok.Run(DummyOpts(), [ -+ '-o', output_dir.GetPath(), -+ '-E', 'name=foo', -+ '-a', os.path.abspath(output_dir.GetPath('en_foo_resources.rc')), -+ '-a', os.path.abspath(output_dir.GetPath('sv_foo_resources.rc')), -+ '-a', os.path.abspath(output_dir.GetPath('resource.h'))])) -+ output_dir.CleanUp() -+ -+ def _verifyWhitelistedOutput(self, -+ filename, -+ whitelisted_ids, -+ non_whitelisted_ids, -+ encoding='utf8'): -+ self.failUnless(os.path.exists(filename)) -+ whitelisted_ids_found = [] -+ non_whitelisted_ids_found = [] -+ with codecs.open(filename, encoding=encoding) as f: -+ for line in f.readlines(): -+ for whitelisted_id in whitelisted_ids: -+ if whitelisted_id in line: -+ whitelisted_ids_found.append(whitelisted_id) -+ if filename.endswith('.h'): -+ numeric_id = int(line.split()[2]) -+ expected_numeric_id = self.EXPECTED_ID_MAP.get(whitelisted_id) -+ self.assertEqual( -+ expected_numeric_id, numeric_id, -+ 'Numeric ID for {} was {} should be {}'.format( -+ whitelisted_id, numeric_id, expected_numeric_id)) -+ for non_whitelisted_id in non_whitelisted_ids: -+ if non_whitelisted_id in line: -+ non_whitelisted_ids_found.append(non_whitelisted_id) -+ self.longMessage = True -+ self.assertEqual(whitelisted_ids, -+ whitelisted_ids_found, -+ '\nin file {}'.format(os.path.basename(filename))) -+ non_whitelisted_msg = ('Non-Whitelisted IDs {} found in {}' -+ .format(non_whitelisted_ids_found, os.path.basename(filename))) -+ self.assertFalse(non_whitelisted_ids_found, non_whitelisted_msg) -+ -+ def testWhitelistStrings(self): -+ output_dir = util.TempDir({}) -+ builder = build.RcBuilder() -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/whitelist_strings.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ whitelist_file = util.PathFromRoot('grit/testdata/whitelist.txt') -+ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), -+ '-w', whitelist_file]) -+ header = output_dir.GetPath('whitelist_test_resources.h') -+ rc = output_dir.GetPath('en_whitelist_test_strings.rc') -+ -+ whitelisted_ids = ['IDS_MESSAGE_WHITELISTED'] -+ non_whitelisted_ids = ['IDS_MESSAGE_NOT_WHITELISTED'] -+ self._verifyWhitelistedOutput( -+ header, -+ whitelisted_ids, -+ non_whitelisted_ids, -+ ) -+ self._verifyWhitelistedOutput( -+ rc, -+ whitelisted_ids, -+ non_whitelisted_ids, -+ encoding='utf16' -+ ) -+ output_dir.CleanUp() -+ -+ def testWhitelistResources(self): -+ output_dir = util.TempDir({}) -+ builder = build.RcBuilder() -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/whitelist_resources.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ whitelist_file = util.PathFromRoot('grit/testdata/whitelist.txt') -+ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), -+ '-w', whitelist_file]) -+ header = output_dir.GetPath('whitelist_test_resources.h') -+ map_cc = output_dir.GetPath('whitelist_test_resources_map.cc') -+ map_h = output_dir.GetPath('whitelist_test_resources_map.h') -+ pak = output_dir.GetPath('whitelist_test_resources.pak') -+ -+ # Ensure the resource map header and .pak files exist, but don't verify -+ # their content. -+ self.failUnless(os.path.exists(map_h)) -+ self.failUnless(os.path.exists(pak)) -+ -+ whitelisted_ids = [ -+ 'IDR_STRUCTURE_WHITELISTED', -+ 'IDR_STRUCTURE_IN_TRUE_IF_WHITELISTED', -+ 'IDR_INCLUDE_WHITELISTED', -+ ] -+ non_whitelisted_ids = [ -+ 'IDR_STRUCTURE_NOT_WHITELISTED', -+ 'IDR_STRUCTURE_IN_TRUE_IF_NOT_WHITELISTED', -+ 'IDR_STRUCTURE_IN_FALSE_IF_WHITELISTED', -+ 'IDR_STRUCTURE_IN_FALSE_IF_NOT_WHITELISTED', -+ 'IDR_INCLUDE_NOT_WHITELISTED', -+ ] -+ for output_file in (header, map_cc): -+ self._verifyWhitelistedOutput( -+ output_file, -+ whitelisted_ids, -+ non_whitelisted_ids, -+ ) -+ output_dir.CleanUp() -+ -+ def testWriteOnlyNew(self): -+ output_dir = util.TempDir({}) -+ builder = build.RcBuilder() -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/substitute.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ UNCHANGED = 10 -+ header = output_dir.GetPath('resource.h') -+ -+ builder.Run(DummyOpts(), ['-o', output_dir.GetPath()]) -+ self.failUnless(os.path.exists(header)) -+ first_mtime = os.stat(header).st_mtime -+ -+ os.utime(header, (UNCHANGED, UNCHANGED)) -+ builder.Run(DummyOpts(), -+ ['-o', output_dir.GetPath(), '--write-only-new', '0']) -+ self.failUnless(os.path.exists(header)) -+ second_mtime = os.stat(header).st_mtime -+ -+ os.utime(header, (UNCHANGED, UNCHANGED)) -+ builder.Run(DummyOpts(), -+ ['-o', output_dir.GetPath(), '--write-only-new', '1']) -+ self.failUnless(os.path.exists(header)) -+ third_mtime = os.stat(header).st_mtime -+ -+ self.assertTrue(abs(second_mtime - UNCHANGED) > 5) -+ self.assertTrue(abs(third_mtime - UNCHANGED) < 5) -+ output_dir.CleanUp() -+ -+ def testGenerateDepFileWithDependOnStamp(self): -+ output_dir = util.TempDir({}) -+ builder = build.RcBuilder() -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = util.PathFromRoot('grit/testdata/substitute.grd') -+ self.verbose = False -+ self.extra_verbose = False -+ expected_dep_file_name = 'substitute.grd.d' -+ expected_stamp_file_name = expected_dep_file_name + '.stamp' -+ expected_dep_file = output_dir.GetPath(expected_dep_file_name) -+ expected_stamp_file = output_dir.GetPath(expected_stamp_file_name) -+ if os.path.isfile(expected_stamp_file): -+ os.remove(expected_stamp_file) -+ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), -+ '--depdir', output_dir.GetPath(), -+ '--depfile', expected_dep_file, -+ '--depend-on-stamp']) -+ self.failUnless(os.path.isfile(expected_stamp_file)) -+ first_mtime = os.stat(expected_stamp_file).st_mtime -+ -+ # Reset mtime to very old. -+ OLDTIME = 10 -+ os.utime(expected_stamp_file, (OLDTIME, OLDTIME)) -+ -+ builder.Run(DummyOpts(), ['-o', output_dir.GetPath(), -+ '--depdir', output_dir.GetPath(), -+ '--depfile', expected_dep_file, -+ '--depend-on-stamp']) -+ self.failUnless(os.path.isfile(expected_stamp_file)) -+ second_mtime = os.stat(expected_stamp_file).st_mtime -+ -+ # Some OS have a 2s stat resolution window, so can't do a direct comparison. -+ self.assertTrue((second_mtime - OLDTIME) > 5) -+ self.assertTrue(abs(second_mtime - first_mtime) < 5) -+ -+ self.failUnless(os.path.isfile(expected_dep_file)) -+ with open(expected_dep_file) as f: -+ line = f.readline() -+ (dep_output_file, deps_string) = line.split(': ') -+ deps = deps_string.split(' ') -+ -+ self.failUnlessEqual(expected_stamp_file_name, dep_output_file) -+ self.failUnlessEqual(deps, [ -+ util.PathFromRoot('grit/testdata/substitute.xmb'), -+ ]) -+ output_dir.CleanUp() -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/tool/buildinfo.py b/tools/grit/grit/tool/buildinfo.py -new file mode 100644 -index 0000000000..7f8d1a3b04 ---- /dev/null -+++ b/tools/grit/grit/tool/buildinfo.py -@@ -0,0 +1,78 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""Output the list of files to be generated by GRIT from an input. -+""" -+ -+from __future__ import print_function -+ -+import getopt -+import os -+import sys -+ -+from grit import grd_reader -+from grit.node import structure -+from grit.tool import interface -+ -+class DetermineBuildInfo(interface.Tool): -+ """Determine what files will be read and output by GRIT. -+Outputs the list of generated files and inputs used to stdout. -+ -+Usage: grit buildinfo [-o DIR] -+ -+The output directory is used for display only. -+""" -+ -+ def __init__(self): -+ pass -+ -+ def ShortDescription(self): -+ """Describes this tool for the usage message.""" -+ return ('Determine what files will be needed and\n' -+ 'output by GRIT with a given input.') -+ -+ def Run(self, opts, args): -+ """Main method for the buildinfo tool.""" -+ self.output_directory = '.' -+ (own_opts, args) = getopt.getopt(args, 'o:', ('help',)) -+ for (key, val) in own_opts: -+ if key == '-o': -+ self.output_directory = val -+ elif key == '--help': -+ self.ShowUsage() -+ sys.exit(0) -+ if len(args) > 0: -+ print('This tool takes exactly one argument: the output directory via -o') -+ return 2 -+ self.SetOptions(opts) -+ -+ res_tree = grd_reader.Parse(opts.input, debug=opts.extra_verbose) -+ -+ langs = {} -+ for output in res_tree.GetOutputFiles(): -+ if output.attrs['lang']: -+ langs[output.attrs['lang']] = os.path.dirname(output.GetFilename()) -+ -+ for lang, dirname in langs.items(): -+ old_output_language = res_tree.output_language -+ res_tree.SetOutputLanguage(lang) -+ for node in res_tree.ActiveDescendants(): -+ with node: -+ if (isinstance(node, structure.StructureNode) and -+ node.HasFileForLanguage()): -+ path = node.FileForLanguage(lang, dirname, create_file=False, -+ return_if_not_generated=False) -+ if path: -+ path = os.path.join(self.output_directory, path) -+ path = os.path.normpath(path) -+ print('%s|%s' % ('rc_all', path)) -+ res_tree.SetOutputLanguage(old_output_language) -+ -+ for output in res_tree.GetOutputFiles(): -+ path = os.path.join(self.output_directory, output.GetFilename()) -+ path = os.path.normpath(path) -+ print('%s|%s' % (output.GetType(), path)) -+ -+ for infile in res_tree.GetInputFiles(): -+ print('input|%s' % os.path.normpath(infile)) -diff --git a/tools/grit/grit/tool/buildinfo_unittest.py b/tools/grit/grit/tool/buildinfo_unittest.py -new file mode 100644 -index 0000000000..24e9ddf8d8 ---- /dev/null -+++ b/tools/grit/grit/tool/buildinfo_unittest.py -@@ -0,0 +1,90 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""Unit tests for the 'grit buildinfo' tool. -+""" -+ -+from __future__ import print_function -+ -+import os -+import sys -+import unittest -+ -+# This is needed to find some of the imports below. -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+from six import StringIO -+ -+# pylint: disable-msg=C6204 -+from grit.tool import buildinfo -+ -+ -+class BuildInfoUnittest(unittest.TestCase): -+ def setUp(self): -+ self.old_cwd = os.getcwd() -+ # Change CWD to make tests work independently of callers CWD. -+ os.chdir(os.path.dirname(__file__)) -+ os.chdir('..') -+ self.buf = StringIO() -+ self.old_stdout = sys.stdout -+ sys.stdout = self.buf -+ -+ def tearDown(self): -+ sys.stdout = self.old_stdout -+ os.chdir(self.old_cwd) -+ -+ def testBuildOutput(self): -+ """Find all of the inputs and outputs for a GRD file.""" -+ info_object = buildinfo.DetermineBuildInfo() -+ -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = '../grit/testdata/buildinfo.grd' -+ self.print_header = False -+ self.verbose = False -+ self.extra_verbose = False -+ info_object.Run(DummyOpts(), []) -+ output = self.buf.getvalue().replace('\\', '/') -+ self.failUnless(output.count(r'rc_all|sv_sidebar_loading.html')) -+ self.failUnless(output.count(r'rc_header|resource.h')) -+ self.failUnless(output.count(r'rc_all|en_generated_resources.rc')) -+ self.failUnless(output.count(r'rc_all|sv_generated_resources.rc')) -+ self.failUnless(output.count(r'input|../grit/testdata/substitute.xmb')) -+ self.failUnless(output.count(r'input|../grit/testdata/pr.bmp')) -+ self.failUnless(output.count(r'input|../grit/testdata/pr2.bmp')) -+ self.failUnless( -+ output.count(r'input|../grit/testdata/sidebar_loading.html')) -+ self.failUnless(output.count(r'input|../grit/testdata/transl.rc')) -+ self.failUnless(output.count(r'input|../grit/testdata/transl1.rc')) -+ -+ def testBuildOutputWithDir(self): -+ """Find all the inputs and outputs for a GRD file with an output dir.""" -+ info_object = buildinfo.DetermineBuildInfo() -+ -+ class DummyOpts(object): -+ def __init__(self): -+ self.input = '../grit/testdata/buildinfo.grd' -+ self.print_header = False -+ self.verbose = False -+ self.extra_verbose = False -+ info_object.Run(DummyOpts(), ['-o', '../grit/testdata']) -+ output = self.buf.getvalue().replace('\\', '/') -+ self.failUnless( -+ output.count(r'rc_all|../grit/testdata/sv_sidebar_loading.html')) -+ self.failUnless(output.count(r'rc_header|../grit/testdata/resource.h')) -+ self.failUnless( -+ output.count(r'rc_all|../grit/testdata/en_generated_resources.rc')) -+ self.failUnless( -+ output.count(r'rc_all|../grit/testdata/sv_generated_resources.rc')) -+ self.failUnless(output.count(r'input|../grit/testdata/substitute.xmb')) -+ self.failUnlessEqual(0, -+ output.count(r'rc_all|../grit/testdata/sv_welcome_toast.html')) -+ self.failUnless( -+ output.count(r'rc_all|../grit/testdata/en_welcome_toast.html')) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/tool/count.py b/tools/grit/grit/tool/count.py -new file mode 100644 -index 0000000000..ab37f2ddb3 ---- /dev/null -+++ b/tools/grit/grit/tool/count.py -@@ -0,0 +1,52 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Count number of occurrences of a given message ID.''' -+ -+from __future__ import print_function -+ -+import getopt -+import sys -+ -+from grit import grd_reader -+from grit.tool import interface -+ -+ -+class CountMessage(interface.Tool): -+ '''Count the number of times a given message ID is used.''' -+ -+ def __init__(self): -+ pass -+ -+ def ShortDescription(self): -+ return 'Count the number of times a given message ID is used.' -+ -+ def ParseOptions(self, args): -+ """Set this objects and return all non-option arguments.""" -+ own_opts, args = getopt.getopt(args, '', ('help',)) -+ for key, val in own_opts: -+ if key == '--help': -+ self.ShowUsage() -+ sys.exit(0) -+ return args -+ -+ def Run(self, opts, args): -+ args = self.ParseOptions(args) -+ if len(args) != 1: -+ print('This tool takes a single tool-specific argument, the message ' -+ 'ID to count.') -+ return 2 -+ self.SetOptions(opts) -+ -+ id = args[0] -+ res_tree = grd_reader.Parse(opts.input, debug=opts.extra_verbose) -+ res_tree.OnlyTheseTranslations([]) -+ res_tree.RunGatherers() -+ -+ count = 0 -+ for c in res_tree.UberClique().AllCliques(): -+ if c.GetId() == id: -+ count += 1 -+ -+ print("There are %d occurrences of message %s." % (count, id)) -diff --git a/tools/grit/grit/tool/diff_structures.py b/tools/grit/grit/tool/diff_structures.py -new file mode 100644 -index 0000000000..d69e009b58 ---- /dev/null -+++ b/tools/grit/grit/tool/diff_structures.py -@@ -0,0 +1,119 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''The 'grit sdiff' tool. -+''' -+ -+from __future__ import print_function -+ -+import os -+import getopt -+import sys -+import tempfile -+ -+from grit.node import structure -+from grit.tool import interface -+ -+from grit import constants -+from grit import util -+ -+# Builds the description for the tool (used as the __doc__ -+# for the DiffStructures class). -+_class_doc = """\ -+Allows you to view the differences in the structure of two files, -+disregarding their translateable content. Translateable portions of -+each file are changed to the string "TTTTTT" before invoking the diff program -+specified by the P4DIFF environment variable. -+ -+Usage: grit sdiff [-t TYPE] [-s SECTION] [-e ENCODING] LEFT RIGHT -+ -+LEFT and RIGHT are the files you want to diff. SECTION is required -+for structure types like 'dialog' to identify the part of the file to look at. -+ENCODING indicates the encoding of the left and right files (default 'cp1252'). -+TYPE can be one of the following, defaults to 'tr_html': -+""" -+for gatherer in structure._GATHERERS: -+ _class_doc += " - %s\n" % gatherer -+ -+ -+class DiffStructures(interface.Tool): -+ __doc__ = _class_doc -+ -+ def __init__(self): -+ self.section = None -+ self.left_encoding = 'cp1252' -+ self.right_encoding = 'cp1252' -+ self.structure_type = 'tr_html' -+ -+ def ShortDescription(self): -+ return 'View differences without regard for translateable portions.' -+ -+ def Run(self, global_opts, args): -+ (opts, args) = getopt.getopt(args, 's:e:t:', -+ ('help', 'left_encoding=', 'right_encoding=')) -+ for key, val in opts: -+ if key == '-s': -+ self.section = val -+ elif key == '-e': -+ self.left_encoding = val -+ self.right_encoding = val -+ elif key == '-t': -+ self.structure_type = val -+ elif key == '--left_encoding': -+ self.left_encoding = val -+ elif key == '--right_encoding': -+ self.right_encoding == val -+ elif key == '--help': -+ self.ShowUsage() -+ sys.exit(0) -+ -+ if len(args) != 2: -+ print("Incorrect usage - 'grit help sdiff' for usage details.") -+ return 2 -+ -+ if 'P4DIFF' not in os.environ: -+ print("Environment variable P4DIFF not set; defaulting to 'windiff'.") -+ diff_program = 'windiff' -+ else: -+ diff_program = os.environ['P4DIFF'] -+ -+ left_trans = self.MakeStaticTranslation(args[0], self.left_encoding) -+ try: -+ try: -+ right_trans = self.MakeStaticTranslation(args[1], self.right_encoding) -+ -+ os.system('%s %s %s' % (diff_program, left_trans, right_trans)) -+ finally: -+ os.unlink(right_trans) -+ finally: -+ os.unlink(left_trans) -+ -+ def MakeStaticTranslation(self, original_filename, encoding): -+ """Given the name of the structure type (self.structure_type), the filename -+ of the file holding the original structure, and optionally the "section" key -+ identifying the part of the file to look at (self.section), creates a -+ temporary file holding a "static" translation of the original structure -+ (i.e. one where all translateable parts have been replaced with "TTTTTT") -+ and returns the temporary file name. It is the caller's responsibility to -+ delete the file when finished. -+ -+ Args: -+ original_filename: 'c:\\bingo\\bla.rc' -+ -+ Return: -+ 'c:\\temp\\werlkjsdf334.tmp' -+ """ -+ original = structure._GATHERERS[self.structure_type](original_filename, -+ extkey=self.section, -+ encoding=encoding) -+ original.Parse() -+ translated = original.Translate(constants.CONSTANT_LANGUAGE, False) -+ -+ fname = tempfile.mktemp() -+ with util.WrapOutputStream(open(fname, 'wb')) as writer: -+ writer.write("Original filename: %s\n=============\n\n" -+ % original_filename) -+ writer.write(translated) # write in UTF-8 -+ -+ return fname -diff --git a/tools/grit/grit/tool/diff_structures_unittest.py b/tools/grit/grit/tool/diff_structures_unittest.py -new file mode 100644 -index 0000000000..a6d7585761 ---- /dev/null -+++ b/tools/grit/grit/tool/diff_structures_unittest.py -@@ -0,0 +1,46 @@ -+#!/usr/bin/env python -+# Copyright 2020 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for the 'grit newgrd' tool.''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import unittest -+ -+from grit.tool import diff_structures -+ -+ -+class DummyOpts(object): -+ """Options needed by NewGrd.""" -+ -+ -+class DiffStructuresUnittest(unittest.TestCase): -+ -+ def testMissingFiles(self): -+ """Verify failure w/out file inputs.""" -+ tool = diff_structures.DiffStructures() -+ ret = tool.Run(DummyOpts(), []) -+ self.assertIsNotNone(ret) -+ self.assertGreater(ret, 0) -+ -+ ret = tool.Run(DummyOpts(), ['left']) -+ self.assertIsNotNone(ret) -+ self.assertGreater(ret, 0) -+ -+ def testTooManyArgs(self): -+ """Verify failure w/too many inputs.""" -+ tool = diff_structures.DiffStructures() -+ ret = tool.Run(DummyOpts(), ['a', 'b', 'c']) -+ self.assertIsNotNone(ret) -+ self.assertGreater(ret, 0) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/tool/interface.py b/tools/grit/grit/tool/interface.py -new file mode 100644 -index 0000000000..e923205223 ---- /dev/null -+++ b/tools/grit/grit/tool/interface.py -@@ -0,0 +1,62 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Base class and interface for tools. -+''' -+ -+from __future__ import print_function -+ -+class Tool(object): -+ '''Base class for all tools. Tools should use their docstring (i.e. the -+ class-level docstring) for the help they want to have printed when they -+ are invoked.''' -+ -+ # -+ # Interface (abstract methods) -+ # -+ -+ def ShortDescription(self): -+ '''Returns a short description of the functionality of the tool.''' -+ raise NotImplementedError() -+ -+ def Run(self, global_options, my_arguments): -+ '''Runs the tool. -+ -+ Args: -+ global_options: object grit_runner.Options -+ my_arguments: [arg1 arg2 ...] -+ -+ Return: -+ 0 for success, non-0 for error -+ ''' -+ raise NotImplementedError() -+ -+ # -+ # Base class implementation -+ # -+ -+ def __init__(self): -+ self.o = None -+ -+ def ShowUsage(self): -+ '''Show usage text for this tool.''' -+ print(self.__doc__) -+ -+ def SetOptions(self, opts): -+ self.o = opts -+ -+ def Out(self, text): -+ '''Always writes out 'text'.''' -+ self.o.output_stream.write(text) -+ -+ def VerboseOut(self, text): -+ '''Writes out 'text' if the verbose option is on.''' -+ if self.o.verbose: -+ self.o.output_stream.write(text) -+ -+ def ExtraVerboseOut(self, text): -+ '''Writes out 'text' if the extra-verbose option is on. -+ ''' -+ if self.o.extra_verbose: -+ self.o.output_stream.write(text) -diff --git a/tools/grit/grit/tool/menu_from_parts.py b/tools/grit/grit/tool/menu_from_parts.py -new file mode 100644 -index 0000000000..fcec26c5b1 ---- /dev/null -+++ b/tools/grit/grit/tool/menu_from_parts.py -@@ -0,0 +1,79 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''The 'grit menufromparts' tool.''' -+ -+from __future__ import print_function -+ -+import six -+ -+from grit import grd_reader -+from grit import util -+from grit import xtb_reader -+from grit.tool import interface -+from grit.tool import transl2tc -+ -+import grit.extern.tclib -+ -+ -+class MenuTranslationsFromParts(interface.Tool): -+ '''One-off tool to generate translated menu messages (where each menu is kept -+in a single message) based on existing translations of the individual menu -+items. Was needed when changing menus from being one message per menu item -+to being one message for the whole menu.''' -+ -+ def ShortDescription(self): -+ return ('Create translations of whole menus from existing translations of ' -+ 'menu items.') -+ -+ def Run(self, globopt, args): -+ self.SetOptions(globopt) -+ assert len(args) == 2, "Need exactly two arguments, the XTB file and the output file" -+ -+ xtb_file = args[0] -+ output_file = args[1] -+ -+ grd = grd_reader.Parse(self.o.input, debug=self.o.extra_verbose) -+ grd.OnlyTheseTranslations([]) # don't load translations -+ grd.RunGatherers() -+ -+ xtb = {} -+ def Callback(msg_id, parts): -+ msg = [] -+ for part in parts: -+ if part[0]: -+ msg = [] -+ break # it had a placeholder so ignore it -+ else: -+ msg.append(part[1]) -+ if len(msg): -+ xtb[msg_id] = ''.join(msg) -+ with open(xtb_file, 'rb') as f: -+ xtb_reader.Parse(f, Callback) -+ -+ translations = [] # list of translations as per transl2tc.WriteTranslations -+ for node in grd: -+ if node.name == 'structure' and node.attrs['type'] == 'menu': -+ assert len(node.GetCliques()) == 1 -+ message = node.GetCliques()[0].GetMessage() -+ translation = [] -+ -+ contents = message.GetContent() -+ for part in contents: -+ if isinstance(part, six.string_types): -+ id = grit.extern.tclib.GenerateMessageId(part) -+ if id not in xtb: -+ print("WARNING didn't find all translations for menu %s" % -+ (node.attrs['name'],)) -+ translation = [] -+ break -+ translation.append(xtb[id]) -+ else: -+ translation.append(part.GetPresentation()) -+ -+ if len(translation): -+ translations.append([message.GetId(), ''.join(translation)]) -+ -+ with util.WrapOutputStream(open(output_file, 'wb')) as f: -+ transl2tc.TranslationToTc.WriteTranslations(f, translations) -diff --git a/tools/grit/grit/tool/newgrd.py b/tools/grit/grit/tool/newgrd.py -new file mode 100644 -index 0000000000..66a18e9c04 ---- /dev/null -+++ b/tools/grit/grit/tool/newgrd.py -@@ -0,0 +1,85 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Tool to create a new, empty .grd file with all the basic sections. -+''' -+ -+from __future__ import print_function -+ -+import getopt -+import sys -+ -+from grit.tool import interface -+from grit import constants -+from grit import util -+ -+# The contents of the new .grd file -+_FILE_CONTENTS = '''\ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+''' % constants.ENCODING_CHECK -+ -+ -+class NewGrd(interface.Tool): -+ '''Usage: grit newgrd OUTPUT_FILE -+ -+Creates a new, empty .grd file OUTPUT_FILE with comments about what to put -+where in the file.''' -+ -+ def ShortDescription(self): -+ return 'Create a new empty .grd file.' -+ -+ def ParseOptions(self, args): -+ """Set this objects and return all non-option arguments.""" -+ own_opts, args = getopt.getopt(args, '', ('help',)) -+ for key, val in own_opts: -+ if key == '--help': -+ self.ShowUsage() -+ sys.exit(0) -+ return args -+ -+ def Run(self, opts, args): -+ args = self.ParseOptions(args) -+ if len(args) != 1: -+ print('This tool requires exactly one argument, the name of the output ' -+ 'file.') -+ return 2 -+ filename = args[0] -+ with util.WrapOutputStream(open(filename, 'wb'), 'utf-8') as out: -+ out.write(_FILE_CONTENTS) -+ print("Wrote file %s" % filename) -diff --git a/tools/grit/grit/tool/newgrd_unittest.py b/tools/grit/grit/tool/newgrd_unittest.py -new file mode 100644 -index 0000000000..f7c8831df5 ---- /dev/null -+++ b/tools/grit/grit/tool/newgrd_unittest.py -@@ -0,0 +1,51 @@ -+#!/usr/bin/env python -+# Copyright 2020 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for the 'grit newgrd' tool.''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import unittest -+ -+from grit import util -+from grit.tool import newgrd -+ -+ -+class DummyOpts(object): -+ """Options needed by NewGrd.""" -+ -+ -+class NewgrdUnittest(unittest.TestCase): -+ -+ def testNewFile(self): -+ """Create a new file.""" -+ tool = newgrd.NewGrd() -+ with util.TempDir({}) as output_dir: -+ output_file = os.path.join(output_dir.GetPath(), 'new.grd') -+ self.assertIsNone(tool.Run(DummyOpts(), [output_file])) -+ self.assertTrue(os.path.exists(output_file)) -+ -+ def testMissingFile(self): -+ """Verify failure w/out file output.""" -+ tool = newgrd.NewGrd() -+ ret = tool.Run(DummyOpts(), []) -+ self.assertIsNotNone(ret) -+ self.assertGreater(ret, 0) -+ -+ def testTooManyArgs(self): -+ """Verify failure w/too many outputs.""" -+ tool = newgrd.NewGrd() -+ ret = tool.Run(DummyOpts(), ['a', 'b']) -+ self.assertIsNotNone(ret) -+ self.assertGreater(ret, 0) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/tool/postprocess_interface.py b/tools/grit/grit/tool/postprocess_interface.py -new file mode 100644 -index 0000000000..4bb8c5871f ---- /dev/null -+++ b/tools/grit/grit/tool/postprocess_interface.py -@@ -0,0 +1,29 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+''' Base class for postprocessing of RC files. -+''' -+ -+from __future__ import print_function -+ -+class PostProcessor(object): -+ ''' Base class for postprocessing of the RC file data before being -+ output through the RC2GRD tool. You should implement this class if -+ you want GRIT to do specific things to the RC files after it has -+ converted the data into GRD format, i.e. change the content of the -+ RC file, and put it into a P4 changelist, etc.''' -+ -+ -+ def Process(self, rctext, rcpath, grdnode): -+ ''' Processes the data in rctext and grdnode. -+ Args: -+ rctext: string containing the contents of the RC file being processed. -+ rcpath: the path used to access the file. -+ grdtext: the root node of the grd xml data generated by -+ the rc2grd tool. -+ -+ Return: -+ The root node of the processed GRD tree. -+ ''' -+ raise NotImplementedError() -diff --git a/tools/grit/grit/tool/postprocess_unittest.py b/tools/grit/grit/tool/postprocess_unittest.py -new file mode 100644 -index 0000000000..77fe228bbe ---- /dev/null -+++ b/tools/grit/grit/tool/postprocess_unittest.py -@@ -0,0 +1,64 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit test that checks postprocessing of files. -+ Tests postprocessing by having the postprocessor -+ modify the grd data tree, changing the message name attributes. -+''' -+ -+from __future__ import print_function -+ -+import os -+import re -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import unittest -+ -+import grit.tool.postprocess_interface -+from grit.tool import rc2grd -+ -+ -+class PostProcessingUnittest(unittest.TestCase): -+ -+ def testPostProcessing(self): -+ rctext = '''STRINGTABLE -+BEGIN -+ DUMMY_STRING_1 "String 1" -+ // Some random description -+ DUMMY_STRING_2 "This text was added during preprocessing" -+END -+ ''' -+ tool = rc2grd.Rc2Grd() -+ class DummyOpts(object): -+ verbose = False -+ extra_verbose = False -+ tool.o = DummyOpts() -+ tool.post_process = 'grit.tool.postprocess_unittest.DummyPostProcessor' -+ result = tool.Process(rctext, '.\resource.rc') -+ -+ self.failUnless( -+ result.children[2].children[2].children[0].attrs['name'] == 'SMART_STRING_1') -+ self.failUnless( -+ result.children[2].children[2].children[1].attrs['name'] == 'SMART_STRING_2') -+ -+class DummyPostProcessor(grit.tool.postprocess_interface.PostProcessor): -+ ''' -+ Post processing replaces all message name attributes containing "DUMMY" to -+ "SMART". -+ ''' -+ def Process(self, rctext, rcpath, grdnode): -+ smarter = re.compile(r'(DUMMY)(.*)') -+ messages = grdnode.children[2].children[2] -+ for node in messages.children: -+ name_attr = node.attrs['name'] -+ m = smarter.search(name_attr) -+ if m: -+ node.attrs['name'] = 'SMART' + m.group(2) -+ return grdnode -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/tool/preprocess_interface.py b/tools/grit/grit/tool/preprocess_interface.py -new file mode 100644 -index 0000000000..67974e704e ---- /dev/null -+++ b/tools/grit/grit/tool/preprocess_interface.py -@@ -0,0 +1,25 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+''' Base class for preprocessing of RC files. -+''' -+ -+from __future__ import print_function -+ -+class PreProcessor(object): -+ ''' Base class for preprocessing of the RC file data before being -+ output through the RC2GRD tool. You should implement this class if -+ you have specific constructs in your RC files that GRIT cannot handle.''' -+ -+ -+ def Process(self, rctext, rcpath): -+ ''' Processes the data in rctext. -+ Args: -+ rctext: string containing the contents of the RC file being processed -+ rcpath: the path used to access the file. -+ -+ Return: -+ The processed text. -+ ''' -+ raise NotImplementedError() -diff --git a/tools/grit/grit/tool/preprocess_unittest.py b/tools/grit/grit/tool/preprocess_unittest.py -new file mode 100644 -index 0000000000..40b95cd6f8 ---- /dev/null -+++ b/tools/grit/grit/tool/preprocess_unittest.py -@@ -0,0 +1,50 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit test that checks preprocessing of files. -+ Tests preprocessing by adding having the preprocessor -+ provide the actual rctext data. -+''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import unittest -+ -+import grit.tool.preprocess_interface -+from grit.tool import rc2grd -+ -+ -+class PreProcessingUnittest(unittest.TestCase): -+ -+ def testPreProcessing(self): -+ tool = rc2grd.Rc2Grd() -+ class DummyOpts(object): -+ verbose = False -+ extra_verbose = False -+ tool.o = DummyOpts() -+ tool.pre_process = 'grit.tool.preprocess_unittest.DummyPreProcessor' -+ result = tool.Process('', '.\resource.rc') -+ -+ self.failUnless( -+ result.children[2].children[2].children[0].attrs['name'] == 'DUMMY_STRING_1') -+ -+class DummyPreProcessor(grit.tool.preprocess_interface.PreProcessor): -+ def Process(self, rctext, rcpath): -+ rctext = '''STRINGTABLE -+BEGIN -+ DUMMY_STRING_1 "String 1" -+ // Some random description -+ DUMMY_STRING_2 "This text was added during preprocessing" -+END -+ ''' -+ return rctext -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/tools/grit/grit/tool/rc2grd.py b/tools/grit/grit/tool/rc2grd.py -new file mode 100644 -index 0000000000..3195b39000 ---- /dev/null -+++ b/tools/grit/grit/tool/rc2grd.py -@@ -0,0 +1,418 @@ -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''The 'grit rc2grd' tool.''' -+ -+from __future__ import print_function -+ -+import os.path -+import getopt -+import re -+import sys -+ -+import six -+from six import StringIO -+ -+import grit.node.empty -+from grit.node import include -+from grit.node import structure -+from grit.node import message -+ -+from grit.gather import rc -+from grit.gather import tr_html -+ -+from grit.tool import interface -+from grit.tool import postprocess_interface -+from grit.tool import preprocess_interface -+ -+from grit import grd_reader -+from grit import lazy_re -+from grit import tclib -+from grit import util -+ -+ -+# Matches files referenced from an .rc file -+_FILE_REF = lazy_re.compile(r''' -+ ^(?P[A-Z_0-9.]+)[ \t]+ -+ (?P[A-Z_0-9]+)[ \t]+ -+ "(?P.*?([^"]|""))"[ \t]*$''', re.VERBOSE | re.MULTILINE) -+ -+ -+# Matches a dialog section -+_DIALOG = lazy_re.compile( -+ r'^(?P[A-Z0-9_]+)\s+DIALOG(EX)?\s.+?^BEGIN\s*$.+?^END\s*$', -+ re.MULTILINE | re.DOTALL) -+ -+ -+# Matches a menu section -+_MENU = lazy_re.compile(r'^(?P[A-Z0-9_]+)\s+MENU.+?^BEGIN\s*$.+?^END\s*$', -+ re.MULTILINE | re.DOTALL) -+ -+ -+# Matches a versioninfo section -+_VERSIONINFO = lazy_re.compile( -+ r'^(?P[A-Z0-9_]+)\s+VERSIONINFO\s.+?^BEGIN\s*$.+?^END\s*$', -+ re.MULTILINE | re.DOTALL) -+ -+ -+# Matches a stringtable -+_STRING_TABLE = lazy_re.compile( -+ (r'^STRINGTABLE(\s+(PRELOAD|DISCARDABLE|CHARACTERISTICS.+|LANGUAGE.+|' -+ r'VERSION.+))*\s*\nBEGIN\s*$(?P.+?)^END\s*$'), -+ re.MULTILINE | re.DOTALL) -+ -+ -+# Matches each message inside a stringtable, breaking it up into comments, -+# the ID of the message, and the (RC-escaped) message text. -+_MESSAGE = lazy_re.compile(r''' -+ (?P(^\s+//.+?)*) # 0 or more lines of comments preceding the message -+ ^\s* -+ (?P[A-Za-z0-9_]+) # id -+ \s+ -+ "(?P.*?([^"]|""))"([^"]|$) # The message itself -+ ''', re.MULTILINE | re.DOTALL | re.VERBOSE) -+ -+ -+# Matches each line of comment text in a multi-line comment. -+_COMMENT_TEXT = lazy_re.compile(r'^\s*//\s*(?P.+?)$', re.MULTILINE) -+ -+ -+# Matches a string that is empty or all whitespace -+_WHITESPACE_ONLY = lazy_re.compile(r'\A\s*\Z', re.MULTILINE) -+ -+ -+# Finds printf and FormatMessage style format specifiers -+# Uses non-capturing groups except for the outermost group, so the output of -+# re.split() should include both the normal text and what we intend to -+# replace with placeholders. -+# TODO(joi) Check documentation for printf (and Windows variants) and FormatMessage -+_FORMAT_SPECIFIER = lazy_re.compile( -+ r'(%[-# +]?(?:[0-9]*|\*)(?:\.(?:[0-9]+|\*))?(?:h|l|L)?' # printf up to last char -+ r'(?:d|i|o|u|x|X|e|E|f|F|g|G|c|r|s|ls|ws)' # printf last char -+ r'|\$[1-9][0-9]*)') # FormatMessage -+ -+ -+class Rc2Grd(interface.Tool): -+ '''A tool for converting .rc files to .grd files. This tool is only for -+converting the source (nontranslated) .rc file to a .grd file. For importing -+existing translations, use the rc2xtb tool. -+ -+Usage: grit [global options] rc2grd [OPTIONS] RCFILE -+ -+The tool takes a single argument, which is the path to the .rc file to convert. -+It outputs a .grd file with the same name in the same directory as the .rc file. -+The .grd file may have one or more TODO comments for things that have to be -+cleaned up manually. -+ -+OPTIONS may be any of the following: -+ -+ -e ENCODING Specify the ENCODING of the .rc file. Default is 'cp1252'. -+ -+ -h TYPE Specify the TYPE attribute for HTML structures. -+ Default is 'tr_html'. -+ -+ -u ENCODING Specify the ENCODING of HTML files. Default is 'utf-8'. -+ -+ -n MATCH Specify the regular expression to match in comments that will -+ indicate that the resource the comment belongs to is not -+ translateable. Default is 'Not locali(s|z)able'. -+ -+ -r GRDFILE Specify that GRDFILE should be used as a "role model" for -+ any placeholders that otherwise would have had TODO names. -+ This attempts to find an identical message in the GRDFILE -+ and uses that instead of the automatically placeholderized -+ message. -+ -+ --pre CLASS Specify an optional, fully qualified classname, which -+ has to be a subclass of grit.tool.PreProcessor, to -+ run on the text of the RC file before conversion occurs. -+ This can be used to support constructs in the RC files -+ that GRIT cannot handle on its own. -+ -+ --post CLASS Specify an optional, fully qualified classname, which -+ has to be a subclass of grit.tool.PostProcessor, to -+ run on the text of the converted RC file. -+ This can be used to alter the content of the RC file -+ based on the conversion that occured. -+ -+For menus, dialogs and version info, the .grd file will refer to the original -+.rc file. Once conversion is complete, you can strip the original .rc file -+of its string table and all comments as these will be available in the .grd -+file. -+ -+Note that this tool WILL NOT obey C preprocessor rules, so even if something -+is #if 0-ed out it will still be included in the output of this tool -+Therefore, if your .rc file contains sections like this, you should run the -+C preprocessor on the .rc file or manually edit it before using this tool. -+''' -+ -+ def ShortDescription(self): -+ return 'A tool for converting .rc source files to .grd files.' -+ -+ def __init__(self): -+ self.input_encoding = 'cp1252' -+ self.html_type = 'tr_html' -+ self.html_encoding = 'utf-8' -+ self.not_localizable_re = re.compile('Not locali(s|z)able') -+ self.role_model = None -+ self.pre_process = None -+ self.post_process = None -+ -+ def ParseOptions(self, args, help_func=None): -+ '''Given a list of arguments, set this object's options and return -+ all non-option arguments. -+ ''' -+ (own_opts, args) = getopt.getopt(args, 'e:h:u:n:r', -+ ('help', 'pre=', 'post=')) -+ for (key, val) in own_opts: -+ if key == '-e': -+ self.input_encoding = val -+ elif key == '-h': -+ self.html_type = val -+ elif key == '-u': -+ self.html_encoding = val -+ elif key == '-n': -+ self.not_localizable_re = re.compile(val) -+ elif key == '-r': -+ self.role_model = grd_reader.Parse(val) -+ elif key == '--pre': -+ self.pre_process = val -+ elif key == '--post': -+ self.post_process = val -+ elif key == '--help': -+ if help_func is None: -+ self.ShowUsage() -+ else: -+ help_func() -+ sys.exit(0) -+ return args -+ -+ def Run(self, opts, args): -+ args = self.ParseOptions(args) -+ if len(args) != 1: -+ print('This tool takes a single tool-specific argument, the path to the\n' -+ '.rc file to process.') -+ return 2 -+ self.SetOptions(opts) -+ -+ path = args[0] -+ out_path = os.path.join(util.dirname(path), -+ os.path.splitext(os.path.basename(path))[0] + '.grd') -+ -+ rctext = util.ReadFile(path, self.input_encoding) -+ grd_text = six.text_type(self.Process(rctext, path)) -+ with util.WrapOutputStream(open(out_path, 'wb'), 'utf-8') as outfile: -+ outfile.write(grd_text) -+ -+ print('Wrote output file %s.\nPlease check for TODO items in the file.' % -+ (out_path,)) -+ -+ -+ def Process(self, rctext, rc_path): -+ '''Processes 'rctext' and returns a resource tree corresponding to it. -+ -+ Args: -+ rctext: complete text of the rc file -+ rc_path: 'resource\resource.rc' -+ -+ Return: -+ grit.node.base.Node subclass -+ ''' -+ -+ if self.pre_process: -+ preprocess_class = util.NewClassInstance(self.pre_process, -+ preprocess_interface.PreProcessor) -+ if preprocess_class: -+ rctext = preprocess_class.Process(rctext, rc_path) -+ else: -+ self.Out( -+ 'PreProcessing class could not be found. Skipping preprocessing.\n') -+ -+ # Start with a basic skeleton for the .grd file -+ root = grd_reader.Parse(StringIO( -+ ''' -+ -+ -+ -+ -+ -+ -+ -+ -+ '''), util.dirname(rc_path)) -+ includes = root.children[2].children[0] -+ structures = root.children[2].children[1] -+ messages = root.children[2].children[2] -+ assert (isinstance(includes, grit.node.empty.IncludesNode) and -+ isinstance(structures, grit.node.empty.StructuresNode) and -+ isinstance(messages, grit.node.empty.MessagesNode)) -+ -+ self.AddIncludes(rctext, includes) -+ self.AddStructures(rctext, structures, os.path.basename(rc_path)) -+ self.AddMessages(rctext, messages) -+ -+ self.VerboseOut('Validating that all IDs are unique...\n') -+ root.ValidateUniqueIds() -+ self.ExtraVerboseOut('Done validating that all IDs are unique.\n') -+ -+ if self.post_process: -+ postprocess_class = util.NewClassInstance(self.post_process, -+ postprocess_interface.PostProcessor) -+ if postprocess_class: -+ root = postprocess_class.Process(rctext, rc_path, root) -+ else: -+ self.Out( -+ 'PostProcessing class could not be found. Skipping postprocessing.\n') -+ -+ return root -+ -+ -+ def IsHtml(self, res_type, fname): -+ '''Check whether both the type and file extension indicate HTML''' -+ fext = fname.split('.')[-1].lower() -+ return res_type == 'HTML' and fext in ('htm', 'html') -+ -+ -+ def AddIncludes(self, rctext, node): -+ '''Scans 'rctext' for included resources (e.g. BITMAP, ICON) and -+ adds each included resource as an child node of 'node'.''' -+ for m in _FILE_REF.finditer(rctext): -+ id = m.group('id') -+ res_type = m.group('type').upper() -+ fname = rc.Section.UnEscape(m.group('file')) -+ assert fname.find('\n') == -1 -+ if not self.IsHtml(res_type, fname): -+ self.VerboseOut('Processing %s with ID %s (filename: %s)\n' % -+ (res_type, id, fname)) -+ node.AddChild(include.IncludeNode.Construct(node, id, res_type, fname)) -+ -+ -+ def AddStructures(self, rctext, node, rc_filename): -+ '''Scans 'rctext' for structured resources (e.g. menus, dialogs, version -+ information resources and HTML templates) and adds each as a -+ child of 'node'.''' -+ # First add HTML includes -+ for m in _FILE_REF.finditer(rctext): -+ id = m.group('id') -+ res_type = m.group('type').upper() -+ fname = rc.Section.UnEscape(m.group('file')) -+ if self.IsHtml(type, fname): -+ node.AddChild(structure.StructureNode.Construct( -+ node, id, self.html_type, fname, self.html_encoding)) -+ -+ # Then add all RC includes -+ def AddStructure(res_type, id): -+ self.VerboseOut('Processing %s with ID %s\n' % (res_type, id)) -+ node.AddChild(structure.StructureNode.Construct(node, id, res_type, -+ rc_filename, -+ encoding=self.input_encoding)) -+ for m in _MENU.finditer(rctext): -+ AddStructure('menu', m.group('id')) -+ for m in _DIALOG.finditer(rctext): -+ AddStructure('dialog', m.group('id')) -+ for m in _VERSIONINFO.finditer(rctext): -+ AddStructure('version', m.group('id')) -+ -+ -+ def AddMessages(self, rctext, node): -+ '''Scans 'rctext' for all messages in string tables, preprocesses them as -+ much as possible for placeholders (e.g. messages containing $1, $2 or %s, %d -+ type format specifiers get those specifiers replaced with placeholders, and -+ HTML-formatted messages get run through the HTML-placeholderizer). Adds -+ each message as a node child of 'node'.''' -+ for tm in _STRING_TABLE.finditer(rctext): -+ table = tm.group('body') -+ for mm in _MESSAGE.finditer(table): -+ comment_block = mm.group('comment') -+ comment_text = [] -+ for cm in _COMMENT_TEXT.finditer(comment_block): -+ comment_text.append(cm.group('text')) -+ comment_text = ' '.join(comment_text) -+ -+ id = mm.group('id') -+ text = rc.Section.UnEscape(mm.group('text')) -+ -+ self.VerboseOut('Processing message %s (text: "%s")\n' % (id, text)) -+ -+ msg_obj = self.Placeholderize(text) -+ -+ # Messages that contain only placeholders do not need translation. -+ is_translateable = False -+ for item in msg_obj.GetContent(): -+ if isinstance(item, six.string_types): -+ if not _WHITESPACE_ONLY.match(item): -+ is_translateable = True -+ -+ if self.not_localizable_re.search(comment_text): -+ is_translateable = False -+ -+ message_meaning = '' -+ internal_comment = '' -+ -+ # If we have a "role model" (existing GRD file) and this node exists -+ # in the role model, use the description, meaning and translateable -+ # attributes from the role model. -+ if self.role_model: -+ role_node = self.role_model.GetNodeById(id) -+ if role_node: -+ is_translateable = role_node.IsTranslateable() -+ message_meaning = role_node.attrs['meaning'] -+ comment_text = role_node.attrs['desc'] -+ internal_comment = role_node.attrs['internal_comment'] -+ -+ # For nontranslateable messages, we don't want the complexity of -+ # placeholderizing everything. -+ if not is_translateable: -+ msg_obj = tclib.Message(text=text) -+ -+ msg_node = message.MessageNode.Construct(node, msg_obj, id, -+ desc=comment_text, -+ translateable=is_translateable, -+ meaning=message_meaning) -+ msg_node.attrs['internal_comment'] = internal_comment -+ -+ node.AddChild(msg_node) -+ self.ExtraVerboseOut('Done processing message %s\n' % id) -+ -+ -+ def Placeholderize(self, text): -+ '''Creates a tclib.Message object from 'text', attempting to recognize -+ a few different formats of text that can be automatically placeholderized -+ (HTML code, printf-style format strings, and FormatMessage-style format -+ strings). -+ ''' -+ -+ try: -+ # First try HTML placeholderizing. -+ # TODO(joi) Allow use of non-TotalRecall flavors of HTML placeholderizing -+ msg = tr_html.HtmlToMessage(text, True) -+ for item in msg.GetContent(): -+ if not isinstance(item, six.string_types): -+ return msg # Contained at least one placeholder, so we're done -+ -+ # HTML placeholderization didn't do anything, so try to find printf or -+ # FormatMessage format specifiers and change them into placeholders. -+ msg = tclib.Message() -+ parts = _FORMAT_SPECIFIER.split(text) -+ todo_counter = 1 # We make placeholder IDs 'TODO_0001' etc. -+ for part in parts: -+ if _FORMAT_SPECIFIER.match(part): -+ msg.AppendPlaceholder(tclib.Placeholder( -+ 'TODO_%04d' % todo_counter, part, 'TODO')) -+ todo_counter += 1 -+ elif part != '': -+ msg.AppendText(part) -+ -+ if self.role_model and len(parts) > 1: # there are TODO placeholders -+ role_model_msg = self.role_model.UberClique().BestCliqueByOriginalText( -+ msg.GetRealContent(), '') -+ if role_model_msg: -+ # replace wholesale to get placeholder names and examples -+ msg = role_model_msg -+ -+ return msg -+ except: -+ print('Exception processing message with text "%s"' % text) -+ raise -diff --git a/tools/grit/grit/tool/rc2grd_unittest.py b/tools/grit/grit/tool/rc2grd_unittest.py -new file mode 100644 -index 0000000000..6d53794c27 ---- /dev/null -+++ b/tools/grit/grit/tool/rc2grd_unittest.py -@@ -0,0 +1,163 @@ -+#!/usr/bin/env python -+# Copyright (c) 2012 The Chromium Authors. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+'''Unit tests for grit.tool.rc2grd''' -+ -+from __future__ import print_function -+ -+import os -+import sys -+if __name__ == '__main__': -+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -+ -+import re -+import unittest -+ -+from six import StringIO -+ -+from grit import grd_reader -+from grit import util -+from grit.node import base -+from grit.tool import rc2grd -+ -+ -+class Rc2GrdUnittest(unittest.TestCase): -+ def testPlaceholderize(self): -+ tool = rc2grd.Rc2Grd() -+ original = "Hello %s, how are you? I'm $1 years old!" -+ msg = tool.Placeholderize(original) -+ self.failUnless(msg.GetPresentableContent() == "Hello TODO_0001, how are you? I'm TODO_0002 years old!") -+ self.failUnless(msg.GetRealContent() == original) -+ -+ def testHtmlPlaceholderize(self): -+ tool = rc2grd.Rc2Grd() -+ original = "Hello [USERNAME], how are you? I'm [AGE] years old!" -+ msg = tool.Placeholderize(original) -+ self.failUnless(msg.GetPresentableContent() == -+ "Hello BEGIN_BOLDX_USERNAME_XEND_BOLD, how are you? I'm X_AGE_X years old!") -+ self.failUnless(msg.GetRealContent() == original) -+ -+ def testMenuWithoutWhitespaceRegression(self): -+ # There was a problem in the original regular expression for parsing out -+ # menu sections, that would parse the following block of text as a single -+ # menu instead of two. -+ two_menus = ''' -+// Hyper context menus -+IDR_HYPERMENU_FOLDER MENU -+BEGIN -+ POPUP "HyperFolder" -+ BEGIN -+ MENUITEM "Open Containing Folder", IDM_OPENFOLDER -+ END -+END -+ -+IDR_HYPERMENU_FILE MENU -+BEGIN -+ POPUP "HyperFile" -+ BEGIN -+ MENUITEM "Open Folder", IDM_OPENFOLDER -+ END -+END -+ -+''' -+ self.failUnless(len(rc2grd._MENU.findall(two_menus)) == 2) -+ -+ def testRegressionScriptWithTranslateable(self): -+ tool = rc2grd.Rc2Grd() -+ -+ # test rig -+ class DummyNode(base.Node): -+ def AddChild(self, item): -+ self.node = item -+ verbose = False -+ extra_verbose = False -+ tool.not_localizable_re = re.compile('') -+ tool.o = DummyNode() -+ -+ rc_text = '''STRINGTABLE\nBEGIN\nID_BINGO ""\nEND\n''' -+ tool.AddMessages(rc_text, tool.o) -+ self.failUnless(tool.o.node.GetCdata().find('Set As Homepage') != -1) -+ -+ # TODO(joi) Improve the HTML parser to support translateables inside -+ #