Merge branch 4.x

pull/23718/head
Alexander Smorkalov 2 years ago
commit 5af40a0269
  1. 3
      .github/FUNDING.yml
  2. 2
      .github/ISSUE_TEMPLATE/documentation.yml
  3. 2
      .github/ISSUE_TEMPLATE/feature_request.yml
  4. 202
      3rdparty/flatbuffers/LICENSE.txt
  5. 1
      3rdparty/flatbuffers/README.md
  6. 68
      3rdparty/flatbuffers/include/flatbuffers/allocator.h
  7. 256
      3rdparty/flatbuffers/include/flatbuffers/array.h
  8. 495
      3rdparty/flatbuffers/include/flatbuffers/base.h
  9. 199
      3rdparty/flatbuffers/include/flatbuffers/buffer.h
  10. 53
      3rdparty/flatbuffers/include/flatbuffers/buffer_ref.h
  11. 64
      3rdparty/flatbuffers/include/flatbuffers/default_allocator.h
  12. 114
      3rdparty/flatbuffers/include/flatbuffers/detached_buffer.h
  13. 1471
      3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h
  14. 273
      3rdparty/flatbuffers/include/flatbuffers/flatbuffers.h
  15. 513
      3rdparty/flatbuffers/include/flatbuffers/stl_emulation.h
  16. 64
      3rdparty/flatbuffers/include/flatbuffers/string.h
  17. 53
      3rdparty/flatbuffers/include/flatbuffers/struct.h
  18. 188
      3rdparty/flatbuffers/include/flatbuffers/table.h
  19. 400
      3rdparty/flatbuffers/include/flatbuffers/vector.h
  20. 288
      3rdparty/flatbuffers/include/flatbuffers/vector_downward.h
  21. 330
      3rdparty/flatbuffers/include/flatbuffers/verifier.h
  22. 20
      3rdparty/include/vulkan/vk_platform.h
  23. 52
      3rdparty/include/vulkan/vulkan.h
  24. 45
      3rdparty/include/vulkan/vulkan_android.h
  25. 492
      3rdparty/include/vulkan/vulkan_beta.h
  26. 16178
      3rdparty/include/vulkan/vulkan_core.h
  27. 54
      3rdparty/include/vulkan/vulkan_directfb.h
  28. 238
      3rdparty/include/vulkan/vulkan_fuchsia.h
  29. 58
      3rdparty/include/vulkan/vulkan_ggp.h
  30. 29
      3rdparty/include/vulkan/vulkan_ios.h
  31. 29
      3rdparty/include/vulkan/vulkan_macos.h
  32. 193
      3rdparty/include/vulkan/vulkan_metal.h
  33. 65
      3rdparty/include/vulkan/vulkan_mir.h
  34. 54
      3rdparty/include/vulkan/vulkan_screen.h
  35. 27
      3rdparty/include/vulkan/vulkan_vi.h
  36. 27
      3rdparty/include/vulkan/vulkan_wayland.h
  37. 117
      3rdparty/include/vulkan/vulkan_win32.h
  38. 27
      3rdparty/include/vulkan/vulkan_xcb.h
  39. 27
      3rdparty/include/vulkan/vulkan_xlib.h
  40. 25
      3rdparty/include/vulkan/vulkan_xlib_xrandr.h
  41. 2
      3rdparty/ippicv/CMakeLists.txt
  42. 22
      3rdparty/ippicv/ippicv.cmake
  43. 121
      3rdparty/openjpeg/CHANGELOG.md
  44. 6
      3rdparty/openjpeg/CMakeLists.txt
  45. 16
      3rdparty/openjpeg/README.md
  46. 1
      3rdparty/openjpeg/openjp2/CMakeLists.txt
  47. 353
      3rdparty/openjpeg/openjp2/bench_dwt.c
  48. 259
      3rdparty/openjpeg/openjp2/cidx_manager.c
  49. 70
      3rdparty/openjpeg/openjp2/cidx_manager.h
  50. 2
      3rdparty/openjpeg/openjp2/cio.h
  51. 29
      3rdparty/openjpeg/openjp2/dwt.c
  52. 2640
      3rdparty/openjpeg/openjp2/ht_dec.c
  53. 1
      3rdparty/openjpeg/openjp2/image.c
  54. 157
      3rdparty/openjpeg/openjp2/indexbox_manager.h
  55. 297
      3rdparty/openjpeg/openjp2/j2k.c
  56. 17
      3rdparty/openjpeg/openjp2/j2k.h
  57. 23
      3rdparty/openjpeg/openjp2/jp2.c
  58. 9
      3rdparty/openjpeg/openjp2/jp2.h
  59. 14
      3rdparty/openjpeg/openjp2/libopenjp2.pc.cmake.in
  60. 2
      3rdparty/openjpeg/openjp2/mct.c
  61. 63
      3rdparty/openjpeg/openjp2/openjpeg.c
  62. 48
      3rdparty/openjpeg/openjp2/openjpeg.h
  63. 3
      3rdparty/openjpeg/openjp2/opj_codec.h
  64. 38
      3rdparty/openjpeg/openjp2/opj_intmath.h
  65. 210
      3rdparty/openjpeg/openjp2/phix_manager.c
  66. 16
      3rdparty/openjpeg/openjp2/pi.c
  67. 215
      3rdparty/openjpeg/openjp2/ppix_manager.c
  68. 4
      3rdparty/openjpeg/openjp2/sparse_array.c
  69. 61
      3rdparty/openjpeg/openjp2/t1.c
  70. 2
      3rdparty/openjpeg/openjp2/t1.h
  71. 323
      3rdparty/openjpeg/openjp2/t1_generate_luts.c
  72. 973
      3rdparty/openjpeg/openjp2/t1_ht_generate_luts.c
  73. 261
      3rdparty/openjpeg/openjp2/t1_ht_luts.h
  74. 143
      3rdparty/openjpeg/openjp2/t2.c
  75. 5
      3rdparty/openjpeg/openjp2/tcd.h
  76. 174
      3rdparty/openjpeg/openjp2/test_sparse_array.c
  77. 146
      3rdparty/openjpeg/openjp2/thix_manager.c
  78. 190
      3rdparty/openjpeg/openjp2/tpix_manager.c
  79. 2
      3rdparty/quirc/include/quirc.h
  80. 19
      3rdparty/quirc/src/decode.c
  81. 7
      CMakeLists.txt
  82. 89
      SECURITY.md
  83. 6
      apps/createsamples/utility.cpp
  84. 7
      apps/interactive-calibration/calibCommon.hpp
  85. 83
      apps/interactive-calibration/frameProcessor.cpp
  86. 3
      apps/interactive-calibration/frameProcessor.hpp
  87. 7
      apps/interactive-calibration/main.cpp
  88. 56
      apps/interactive-calibration/parametersController.cpp
  89. 56
      apps/python_app_test.py
  90. 22
      apps/traincascade/boost.cpp
  91. 5
      apps/traincascade/cascadeclassifier.cpp
  92. 68
      apps/traincascade/old_ml.hpp
  93. 110
      apps/traincascade/old_ml_boost.cpp
  94. 32
      apps/traincascade/old_ml_inner_functions.cpp
  95. 6
      apps/traincascade/old_ml_precomp.hpp
  96. 317
      apps/traincascade/old_ml_tree.cpp
  97. 10
      cmake/OpenCVDetectCUDA.cmake
  98. 19
      cmake/OpenCVDetectFlatbuffers.cmake
  99. 7
      cmake/OpenCVDetectPython.cmake
  100. 2
      cmake/OpenCVDetectVulkan.cmake
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,3 @@
# These are supported funding model platforms
github: opencv

@ -10,7 +10,7 @@ body:
- type: textarea
attributes:
label: Descripe the doc issue
label: Describe the doc issue
description: >
Please provide a clear and concise description of what content in https://docs.opencv.org/ is an issue. Note that there are multiple active branches, such as 3.4, 4.x and 5.x, so please specify the branch with the problem.
placeholder: |

@ -10,7 +10,7 @@ body:
- type: textarea
attributes:
label: Descripe the feature and motivation
label: Describe the feature and motivation
description: |
Please provide a clear and concise proposal of the feature and outline the motivation.
validations:

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -0,0 +1 @@
Origin: https://github.com/google/flatbuffers/tree/v23.5.9

@ -0,0 +1,68 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_ALLOCATOR_H_
#define FLATBUFFERS_ALLOCATOR_H_
#include "flatbuffers/base.h"
namespace flatbuffers {
// Allocator interface. This is flatbuffers-specific and meant only for
// `vector_downward` usage.
class Allocator {
public:
virtual ~Allocator() {}
// Allocate `size` bytes of memory.
virtual uint8_t *allocate(size_t size) = 0;
// Deallocate `size` bytes of memory at `p` allocated by this allocator.
virtual void deallocate(uint8_t *p, size_t size) = 0;
// Reallocate `new_size` bytes of memory, replacing the old region of size
// `old_size` at `p`. In contrast to a normal realloc, this grows downwards,
// and is intended specifcally for `vector_downward` use.
// `in_use_back` and `in_use_front` indicate how much of `old_size` is
// actually in use at each end, and needs to be copied.
virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size,
size_t new_size, size_t in_use_back,
size_t in_use_front) {
FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows
uint8_t *new_p = allocate(new_size);
memcpy_downward(old_p, old_size, new_p, new_size, in_use_back,
in_use_front);
deallocate(old_p, old_size);
return new_p;
}
protected:
// Called by `reallocate_downward` to copy memory from `old_p` of `old_size`
// to `new_p` of `new_size`. Only memory of size `in_use_front` and
// `in_use_back` will be copied from the front and back of the old memory
// allocation.
void memcpy_downward(uint8_t *old_p, size_t old_size, uint8_t *new_p,
size_t new_size, size_t in_use_back,
size_t in_use_front) {
memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back,
in_use_back);
memcpy(new_p, old_p, in_use_front);
}
};
} // namespace flatbuffers
#endif // FLATBUFFERS_ALLOCATOR_H_

@ -0,0 +1,256 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_ARRAY_H_
#define FLATBUFFERS_ARRAY_H_
#include <cstdint>
#include <memory>
#include "flatbuffers/base.h"
#include "flatbuffers/stl_emulation.h"
#include "flatbuffers/vector.h"
namespace flatbuffers {
// This is used as a helper type for accessing arrays.
template<typename T, uint16_t length> class Array {
// Array<T> can carry only POD data types (scalars or structs).
typedef typename flatbuffers::bool_constant<flatbuffers::is_scalar<T>::value>
scalar_tag;
typedef
typename flatbuffers::conditional<scalar_tag::value, T, const T *>::type
IndirectHelperType;
public:
typedef uint16_t size_type;
typedef typename IndirectHelper<IndirectHelperType>::return_type return_type;
typedef VectorConstIterator<T, return_type, uoffset_t> const_iterator;
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
// If T is a LE-scalar or a struct (!scalar_tag::value).
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
(scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1)) ||
!scalar_tag::value;
FLATBUFFERS_CONSTEXPR uint16_t size() const { return length; }
return_type Get(uoffset_t i) const {
FLATBUFFERS_ASSERT(i < size());
return IndirectHelper<IndirectHelperType>::Read(Data(), i);
}
return_type operator[](uoffset_t i) const { return Get(i); }
// If this is a Vector of enums, T will be its storage type, not the enum
// type. This function makes it convenient to retrieve value with enum
// type E.
template<typename E> E GetEnum(uoffset_t i) const {
return static_cast<E>(Get(i));
}
const_iterator begin() const { return const_iterator(Data(), 0); }
const_iterator end() const { return const_iterator(Data(), size()); }
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
const_reverse_iterator rend() const {
return const_reverse_iterator(begin());
}
const_iterator cbegin() const { return begin(); }
const_iterator cend() const { return end(); }
const_reverse_iterator crbegin() const { return rbegin(); }
const_reverse_iterator crend() const { return rend(); }
// Get a mutable pointer to elements inside this array.
// This method used to mutate arrays of structs followed by a @p Mutate
// operation. For primitive types use @p Mutate directly.
// @warning Assignments and reads to/from the dereferenced pointer are not
// automatically converted to the correct endianness.
typename flatbuffers::conditional<scalar_tag::value, void, T *>::type
GetMutablePointer(uoffset_t i) const {
FLATBUFFERS_ASSERT(i < size());
return const_cast<T *>(&data()[i]);
}
// Change elements if you have a non-const pointer to this object.
void Mutate(uoffset_t i, const T &val) { MutateImpl(scalar_tag(), i, val); }
// The raw data in little endian format. Use with care.
const uint8_t *Data() const { return data_; }
uint8_t *Data() { return data_; }
// Similarly, but typed, much like std::vector::data
const T *data() const { return reinterpret_cast<const T *>(Data()); }
T *data() { return reinterpret_cast<T *>(Data()); }
// Copy data from a span with endian conversion.
// If this Array and the span overlap, the behavior is undefined.
void CopyFromSpan(flatbuffers::span<const T, length> src) {
const auto p1 = reinterpret_cast<const uint8_t *>(src.data());
const auto p2 = Data();
FLATBUFFERS_ASSERT(!(p1 >= p2 && p1 < (p2 + length)) &&
!(p2 >= p1 && p2 < (p1 + length)));
(void)p1;
(void)p2;
CopyFromSpanImpl(flatbuffers::bool_constant<is_span_observable>(), src);
}
protected:
void MutateImpl(flatbuffers::true_type, uoffset_t i, const T &val) {
FLATBUFFERS_ASSERT(i < size());
WriteScalar(data() + i, val);
}
void MutateImpl(flatbuffers::false_type, uoffset_t i, const T &val) {
*(GetMutablePointer(i)) = val;
}
void CopyFromSpanImpl(flatbuffers::true_type,
flatbuffers::span<const T, length> src) {
// Use std::memcpy() instead of std::copy() to avoid performance degradation
// due to aliasing if T is char or unsigned char.
// The size is known at compile time, so memcpy would be inlined.
std::memcpy(data(), src.data(), length * sizeof(T));
}
// Copy data from flatbuffers::span with endian conversion.
void CopyFromSpanImpl(flatbuffers::false_type,
flatbuffers::span<const T, length> src) {
for (size_type k = 0; k < length; k++) { Mutate(k, src[k]); }
}
// This class is only used to access pre-existing data. Don't ever
// try to construct these manually.
// 'constexpr' allows us to use 'size()' at compile time.
// @note Must not use 'FLATBUFFERS_CONSTEXPR' here, as const is not allowed on
// a constructor.
#if defined(__cpp_constexpr)
constexpr Array();
#else
Array();
#endif
uint8_t data_[length * sizeof(T)];
private:
// This class is a pointer. Copying will therefore create an invalid object.
// Private and unimplemented copy constructor.
Array(const Array &);
Array &operator=(const Array &);
};
// Specialization for Array[struct] with access using Offset<void> pointer.
// This specialization used by idl_gen_text.cpp.
template<typename T, uint16_t length, template<typename> class OffsetT>
class Array<OffsetT<T>, length> {
static_assert(flatbuffers::is_same<T, void>::value, "unexpected type T");
public:
typedef const void *return_type;
typedef uint16_t size_type;
const uint8_t *Data() const { return data_; }
// Make idl_gen_text.cpp::PrintContainer happy.
return_type operator[](uoffset_t) const {
FLATBUFFERS_ASSERT(false);
return nullptr;
}
private:
// This class is only used to access pre-existing data.
Array();
Array(const Array &);
Array &operator=(const Array &);
uint8_t data_[1];
};
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U, N> make_span(Array<U, N> &arr)
FLATBUFFERS_NOEXCEPT {
static_assert(
Array<U, N>::is_span_observable,
"wrong type U, only plain struct, LE-scalar, or byte types are allowed");
return span<U, N>(arr.data(), N);
}
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U, N> make_span(
const Array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
static_assert(
Array<U, N>::is_span_observable,
"wrong type U, only plain struct, LE-scalar, or byte types are allowed");
return span<const U, N>(arr.data(), N);
}
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<uint8_t, sizeof(U) * N>
make_bytes_span(Array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
static_assert(Array<U, N>::is_span_observable,
"internal error, Array<T> might hold only scalars or structs");
return span<uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
}
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t, sizeof(U) * N>
make_bytes_span(const Array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
static_assert(Array<U, N>::is_span_observable,
"internal error, Array<T> might hold only scalars or structs");
return span<const uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
}
// Cast a raw T[length] to a raw flatbuffers::Array<T, length>
// without endian conversion. Use with care.
// TODO: move these Cast-methods to `internal` namespace.
template<typename T, uint16_t length>
Array<T, length> &CastToArray(T (&arr)[length]) {
return *reinterpret_cast<Array<T, length> *>(arr);
}
template<typename T, uint16_t length>
const Array<T, length> &CastToArray(const T (&arr)[length]) {
return *reinterpret_cast<const Array<T, length> *>(arr);
}
template<typename E, typename T, uint16_t length>
Array<E, length> &CastToArrayOfEnum(T (&arr)[length]) {
static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
return *reinterpret_cast<Array<E, length> *>(arr);
}
template<typename E, typename T, uint16_t length>
const Array<E, length> &CastToArrayOfEnum(const T (&arr)[length]) {
static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
return *reinterpret_cast<const Array<E, length> *>(arr);
}
template<typename T, uint16_t length>
bool operator==(const Array<T, length> &lhs,
const Array<T, length> &rhs) noexcept {
return std::addressof(lhs) == std::addressof(rhs) ||
(lhs.size() == rhs.size() &&
std::memcmp(lhs.Data(), rhs.Data(), rhs.size() * sizeof(T)) == 0);
}
} // namespace flatbuffers
#endif // FLATBUFFERS_ARRAY_H_

@ -0,0 +1,495 @@
#ifndef FLATBUFFERS_BASE_H_
#define FLATBUFFERS_BASE_H_
// clang-format off
// If activate should be declared and included first.
#if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
defined(_MSC_VER) && defined(_DEBUG)
// The _CRTDBG_MAP_ALLOC inside <crtdbg.h> will replace
// calloc/free (etc) to its debug version using #define directives.
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
// Replace operator new by trace-enabled version.
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#if !defined(FLATBUFFERS_ASSERT)
#include <assert.h>
#define FLATBUFFERS_ASSERT assert
#elif defined(FLATBUFFERS_ASSERT_INCLUDE)
// Include file with forward declaration
#include FLATBUFFERS_ASSERT_INCLUDE
#endif
#ifndef ARDUINO
#include <cstdint>
#endif
#include <cstddef>
#include <cstdlib>
#include <cstring>
#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H) && defined(__AVR__)
#include <utility.h>
#else
#include <utility>
#endif
#include <string>
#include <type_traits>
#include <vector>
#include <set>
#include <algorithm>
#include <limits>
#include <iterator>
#include <memory>
#if defined(__unix__) && !defined(FLATBUFFERS_LOCALE_INDEPENDENT)
#include <unistd.h>
#endif
#ifdef __ANDROID__
#include <android/api-level.h>
#endif
#if defined(__ICCARM__)
#include <intrinsics.h>
#endif
// Note the __clang__ check is needed, because clang presents itself
// as an older GNUC compiler (4.2).
// Clang 3.3 and later implement all of the ISO C++ 2011 standard.
// Clang 3.4 and later implement all of the ISO C++ 2014 standard.
// http://clang.llvm.org/cxx_status.html
// Note the MSVC value '__cplusplus' may be incorrect:
// The '__cplusplus' predefined macro in the MSVC stuck at the value 199711L,
// indicating (erroneously!) that the compiler conformed to the C++98 Standard.
// This value should be correct starting from MSVC2017-15.7-Preview-3.
// The '__cplusplus' will be valid only if MSVC2017-15.7-P3 and the `/Zc:__cplusplus` switch is set.
// Workaround (for details see MSDN):
// Use the _MSC_VER and _MSVC_LANG definition instead of the __cplusplus for compatibility.
// The _MSVC_LANG macro reports the Standard version regardless of the '/Zc:__cplusplus' switch.
#if defined(__GNUC__) && !defined(__clang__)
#define FLATBUFFERS_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#else
#define FLATBUFFERS_GCC 0
#endif
#if defined(__clang__)
#define FLATBUFFERS_CLANG (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#else
#define FLATBUFFERS_CLANG 0
#endif
/// @cond FLATBUFFERS_INTERNAL
#if __cplusplus <= 199711L && \
(!defined(_MSC_VER) || _MSC_VER < 1600) && \
(!defined(__GNUC__) || \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400))
#error A C++11 compatible compiler with support for the auto typing is \
required for FlatBuffers.
#error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__
#endif
#if !defined(__clang__) && \
defined(__GNUC__) && \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600)
// Backwards compatibility for g++ 4.4, and 4.5 which don't have the nullptr
// and constexpr keywords. Note the __clang__ check is needed, because clang
// presents itself as an older GNUC compiler.
#ifndef nullptr_t
const class nullptr_t {
public:
template<class T> inline operator T*() const { return 0; }
private:
void operator&() const;
} nullptr = {};
#endif
#ifndef constexpr
#define constexpr const
#endif
#endif
// The wire format uses a little endian encoding (since that's efficient for
// the common platforms).
#if defined(__s390x__)
#define FLATBUFFERS_LITTLEENDIAN 0
#endif // __s390x__
#if !defined(FLATBUFFERS_LITTLEENDIAN)
#if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
#if (defined(__BIG_ENDIAN__) || \
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
#define FLATBUFFERS_LITTLEENDIAN 0
#else
#define FLATBUFFERS_LITTLEENDIAN 1
#endif // __BIG_ENDIAN__
#elif defined(_MSC_VER)
#if defined(_M_PPC)
#define FLATBUFFERS_LITTLEENDIAN 0
#else
#define FLATBUFFERS_LITTLEENDIAN 1
#endif
#else
#error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN.
#endif
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
#define FLATBUFFERS_VERSION_MAJOR 23
#define FLATBUFFERS_VERSION_MINOR 5
#define FLATBUFFERS_VERSION_REVISION 9
#define FLATBUFFERS_STRING_EXPAND(X) #X
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
namespace flatbuffers {
// Returns version as string "MAJOR.MINOR.REVISION".
const char* FLATBUFFERS_VERSION();
}
#if (!defined(_MSC_VER) || _MSC_VER > 1600) && \
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) || \
defined(__clang__)
#define FLATBUFFERS_FINAL_CLASS final
#define FLATBUFFERS_OVERRIDE override
#define FLATBUFFERS_EXPLICIT_CPP11 explicit
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : flatbuffers::voffset_t
#else
#define FLATBUFFERS_FINAL_CLASS
#define FLATBUFFERS_OVERRIDE
#define FLATBUFFERS_EXPLICIT_CPP11
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE
#endif
#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
(defined(__cpp_constexpr) && __cpp_constexpr >= 200704)
#define FLATBUFFERS_CONSTEXPR constexpr
#define FLATBUFFERS_CONSTEXPR_CPP11 constexpr
#define FLATBUFFERS_CONSTEXPR_DEFINED
#else
#define FLATBUFFERS_CONSTEXPR const
#define FLATBUFFERS_CONSTEXPR_CPP11
#endif
#if (defined(__cplusplus) && __cplusplus >= 201402L) || \
(defined(__cpp_constexpr) && __cpp_constexpr >= 201304)
#define FLATBUFFERS_CONSTEXPR_CPP14 FLATBUFFERS_CONSTEXPR_CPP11
#else
#define FLATBUFFERS_CONSTEXPR_CPP14
#endif
#if (defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
(defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023026)) || \
defined(__clang__)
#define FLATBUFFERS_NOEXCEPT noexcept
#else
#define FLATBUFFERS_NOEXCEPT
#endif
// NOTE: the FLATBUFFERS_DELETE_FUNC macro may change the access mode to
// private, so be sure to put it at the end or reset access mode explicitly.
#if (!defined(_MSC_VER) || _MSC_FULL_VER >= 180020827) && \
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) || \
defined(__clang__)
#define FLATBUFFERS_DELETE_FUNC(func) func = delete
#else
#define FLATBUFFERS_DELETE_FUNC(func) private: func
#endif
#if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
(!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
defined(__clang__)
#define FLATBUFFERS_DEFAULT_DECLARATION
#endif
// Check if we can use template aliases
// Not possible if Microsoft Compiler before 2012
// Possible is the language feature __cpp_alias_templates is defined well
// Or possible if the C++ std is C+11 or newer
#if (defined(_MSC_VER) && _MSC_VER > 1700 /* MSVC2012 */) \
|| (defined(__cpp_alias_templates) && __cpp_alias_templates >= 200704) \
|| (defined(__cplusplus) && __cplusplus >= 201103L)
#define FLATBUFFERS_TEMPLATES_ALIASES
#endif
#ifndef FLATBUFFERS_HAS_STRING_VIEW
// Only provide flatbuffers::string_view if __has_include can be used
// to detect a header that provides an implementation
#if defined(__has_include)
// Check for std::string_view (in c++17)
#if __has_include(<string_view>) && (__cplusplus >= 201606 || (defined(_HAS_CXX17) && _HAS_CXX17))
#include <string_view>
namespace flatbuffers {
typedef std::string_view string_view;
}
#define FLATBUFFERS_HAS_STRING_VIEW 1
// Check for std::experimental::string_view (in c++14, compiler-dependent)
#elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411)
#include <experimental/string_view>
namespace flatbuffers {
typedef std::experimental::string_view string_view;
}
#define FLATBUFFERS_HAS_STRING_VIEW 1
// Check for absl::string_view
#elif __has_include("absl/strings/string_view.h") && \
__has_include("absl/base/config.h") && \
(__cplusplus >= 201411)
#include "absl/base/config.h"
#if !defined(ABSL_USES_STD_STRING_VIEW)
#include "absl/strings/string_view.h"
namespace flatbuffers {
typedef absl::string_view string_view;
}
#define FLATBUFFERS_HAS_STRING_VIEW 1
#endif
#endif
#endif // __has_include
#endif // !FLATBUFFERS_HAS_STRING_VIEW
#ifndef FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
// Allow heap allocations to be used
#define FLATBUFFERS_GENERAL_HEAP_ALLOC_OK 1
#endif // !FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
#ifndef FLATBUFFERS_HAS_NEW_STRTOD
// Modern (C++11) strtod and strtof functions are available for use.
// 1) nan/inf strings as argument of strtod;
// 2) hex-float as argument of strtod/strtof.
#if (defined(_MSC_VER) && _MSC_VER >= 1900) || \
(defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
(defined(__clang__))
#define FLATBUFFERS_HAS_NEW_STRTOD 1
#endif
#endif // !FLATBUFFERS_HAS_NEW_STRTOD
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
// strtoull_l}.
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
(defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
(defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
(!defined(__Fuchsia__) && !defined(__ANDROID_API__))
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
#else
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
#endif
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
// - __suppress_ubsan__("undefined")
// - __suppress_ubsan__("signed-integer-overflow")
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
#define __suppress_ubsan__(type) __attribute__((no_sanitize(type)))
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
#define __suppress_ubsan__(type) __attribute__((no_sanitize_undefined))
#else
#define __suppress_ubsan__(type)
#endif
// This is constexpr function used for checking compile-time constants.
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
return !!t;
}
// Enable C++ attribute [[]] if std:c++17 or higher.
#if ((__cplusplus >= 201703L) \
|| (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
// All attributes unknown to an implementation are ignored without causing an error.
#define FLATBUFFERS_ATTRIBUTE(attr) attr
#define FLATBUFFERS_FALLTHROUGH() [[fallthrough]]
#else
#define FLATBUFFERS_ATTRIBUTE(attr)
#if FLATBUFFERS_CLANG >= 30800
#define FLATBUFFERS_FALLTHROUGH() [[clang::fallthrough]]
#elif FLATBUFFERS_GCC >= 70300
#define FLATBUFFERS_FALLTHROUGH() [[gnu::fallthrough]]
#else
#define FLATBUFFERS_FALLTHROUGH()
#endif
#endif
/// @endcond
/// @file
namespace flatbuffers {
/// @cond FLATBUFFERS_INTERNAL
// Our default offset / size type, 32bit on purpose on 64bit systems.
// Also, using a consistent offset type maintains compatibility of serialized
// offset values between 32bit and 64bit systems.
typedef uint32_t uoffset_t;
typedef uint64_t uoffset64_t;
// Signed offsets for references that can go in both directions.
typedef int32_t soffset_t;
typedef int64_t soffset64_t;
// Offset/index used in v-tables, can be changed to uint8_t in
// format forks to save a bit of space if desired.
typedef uint16_t voffset_t;
typedef uintmax_t largest_scalar_t;
// In 32bits, this evaluates to 2GB - 1
#define FLATBUFFERS_MAX_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset_t>::max()
#define FLATBUFFERS_MAX_64_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset64_t>::max()
// The minimum size buffer that can be a valid flatbuffer.
// Includes the offset to the root table (uoffset_t), the offset to the vtable
// of the root table (soffset_t), the size of the vtable (uint16_t), and the
// size of the referring table (uint16_t).
#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(uoffset_t) + sizeof(soffset_t) + \
sizeof(uint16_t) + sizeof(uint16_t)
// We support aligning the contents of buffers up to this size.
#ifndef FLATBUFFERS_MAX_ALIGNMENT
#define FLATBUFFERS_MAX_ALIGNMENT 32
#endif
/// @brief The length of a FlatBuffer file header.
static const size_t kFileIdentifierLength = 4;
inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) {
return (min_align <= align) && (align <= (FLATBUFFERS_MAX_ALIGNMENT)) &&
(align & (align - 1)) == 0; // must be power of 2
}
#if defined(_MSC_VER)
#pragma warning(disable: 4351) // C4351: new behavior: elements of array ... will be default initialized
#pragma warning(push)
#pragma warning(disable: 4127) // C4127: conditional expression is constant
#endif
template<typename T> T EndianSwap(T t) {
#if defined(_MSC_VER)
#define FLATBUFFERS_BYTESWAP16 _byteswap_ushort
#define FLATBUFFERS_BYTESWAP32 _byteswap_ulong
#define FLATBUFFERS_BYTESWAP64 _byteswap_uint64
#elif defined(__ICCARM__)
#define FLATBUFFERS_BYTESWAP16 __REV16
#define FLATBUFFERS_BYTESWAP32 __REV
#define FLATBUFFERS_BYTESWAP64(x) \
((__REV(static_cast<uint32_t>(x >> 32U))) | (static_cast<uint64_t>(__REV(static_cast<uint32_t>(x)))) << 32U)
#else
#if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__)
// __builtin_bswap16 was missing prior to GCC 4.8.
#define FLATBUFFERS_BYTESWAP16(x) \
static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16))
#else
#define FLATBUFFERS_BYTESWAP16 __builtin_bswap16
#endif
#define FLATBUFFERS_BYTESWAP32 __builtin_bswap32
#define FLATBUFFERS_BYTESWAP64 __builtin_bswap64
#endif
if (sizeof(T) == 1) { // Compile-time if-then's.
return t;
} else if (sizeof(T) == 2) {
union { T t; uint16_t i; } u = { t };
u.i = FLATBUFFERS_BYTESWAP16(u.i);
return u.t;
} else if (sizeof(T) == 4) {
union { T t; uint32_t i; } u = { t };
u.i = FLATBUFFERS_BYTESWAP32(u.i);
return u.t;
} else if (sizeof(T) == 8) {
union { T t; uint64_t i; } u = { t };
u.i = FLATBUFFERS_BYTESWAP64(u.i);
return u.t;
} else {
FLATBUFFERS_ASSERT(0);
return t;
}
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
template<typename T> T EndianScalar(T t) {
#if FLATBUFFERS_LITTLEENDIAN
return t;
#else
return EndianSwap(t);
#endif
}
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
__suppress_ubsan__("alignment")
T ReadScalar(const void *p) {
return EndianScalar(*reinterpret_cast<const T *>(p));
}
// See https://github.com/google/flatbuffers/issues/5950
#if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
__suppress_ubsan__("alignment")
void WriteScalar(void *p, T t) {
*reinterpret_cast<T *>(p) = EndianScalar(t);
}
template<typename T> struct Offset;
template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
}
#if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
#pragma GCC diagnostic pop
#endif
// Computes how many bytes you'd have to pad to be able to write an
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
// memory).
__suppress_ubsan__("unsigned-integer-overflow")
inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
return ((~buf_size) + 1) & (scalar_size - 1);
}
// Generic 'operator==' with conditional specialisations.
// T e - new value of a scalar field.
// T def - default of scalar (is known at compile-time).
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
#if defined(FLATBUFFERS_NAN_DEFAULTS) && \
defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
// Like `operator==(e, def)` with weak NaN if T=(float|double).
template<typename T> inline bool IsFloatTheSameAs(T e, T def) {
return (e == def) || ((def != def) && (e != e));
}
template<> inline bool IsTheSameAs<float>(float e, float def) {
return IsFloatTheSameAs(e, def);
}
template<> inline bool IsTheSameAs<double>(double e, double def) {
return IsFloatTheSameAs(e, def);
}
#endif
// Check 'v' is out of closed range [low; high].
// Workaround for GCC warning [-Werror=type-limits]:
// comparison is always true due to limited range of data type.
template<typename T>
inline bool IsOutRange(const T &v, const T &low, const T &high) {
return (v < low) || (high < v);
}
// Check 'v' is in closed range [low; high].
template<typename T>
inline bool IsInRange(const T &v, const T &low, const T &high) {
return !IsOutRange(v, low, high);
}
} // namespace flatbuffers
#endif // FLATBUFFERS_BASE_H_

@ -0,0 +1,199 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_BUFFER_H_
#define FLATBUFFERS_BUFFER_H_
#include <algorithm>
#include "flatbuffers/base.h"
namespace flatbuffers {
// Wrapper for uoffset_t to allow safe template specialization.
// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset).
template<typename T = void> struct Offset {
// The type of offset to use.
typedef uoffset_t offset_type;
offset_type o;
Offset() : o(0) {}
Offset(const offset_type _o) : o(_o) {}
Offset<> Union() const { return o; }
bool IsNull() const { return !o; }
};
// Wrapper for uoffset64_t Offsets.
template<typename T = void> struct Offset64 {
// The type of offset to use.
typedef uoffset64_t offset_type;
offset_type o;
Offset64() : o(0) {}
Offset64(const offset_type offset) : o(offset) {}
Offset64<> Union() const { return o; }
bool IsNull() const { return !o; }
};
// Litmus check for ensuring the Offsets are the expected size.
static_assert(sizeof(Offset<>) == 4, "Offset has wrong size");
static_assert(sizeof(Offset64<>) == 8, "Offset64 has wrong size");
inline void EndianCheck() {
int endiantest = 1;
// If this fails, see FLATBUFFERS_LITTLEENDIAN above.
FLATBUFFERS_ASSERT(*reinterpret_cast<char *>(&endiantest) ==
FLATBUFFERS_LITTLEENDIAN);
(void)endiantest;
}
template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() {
// clang-format off
#ifdef _MSC_VER
return __alignof(T);
#else
#ifndef alignof
return __alignof__(T);
#else
return alignof(T);
#endif
#endif
// clang-format on
}
// Lexicographically compare two strings (possibly containing nulls), and
// return true if the first is less than the second.
static inline bool StringLessThan(const char *a_data, uoffset_t a_size,
const char *b_data, uoffset_t b_size) {
const auto cmp = memcmp(a_data, b_data, (std::min)(a_size, b_size));
return cmp == 0 ? a_size < b_size : cmp < 0;
}
// When we read serialized data from memory, in the case of most scalars,
// we want to just read T, but in the case of Offset, we want to actually
// perform the indirection and return a pointer.
// The template specialization below does just that.
// It is wrapped in a struct since function templates can't overload on the
// return type like this.
// The typedef is for the convenience of callers of this function
// (avoiding the need for a trailing return decltype)
template<typename T> struct IndirectHelper {
typedef T return_type;
typedef T mutable_return_type;
static const size_t element_stride = sizeof(T);
static return_type Read(const uint8_t *p, const size_t i) {
return EndianScalar((reinterpret_cast<const T *>(p))[i]);
}
static mutable_return_type Read(uint8_t *p, const size_t i) {
return reinterpret_cast<mutable_return_type>(
Read(const_cast<const uint8_t *>(p), i));
}
};
// For vector of Offsets.
template<typename T, template<typename> class OffsetT>
struct IndirectHelper<OffsetT<T>> {
typedef const T *return_type;
typedef T *mutable_return_type;
typedef typename OffsetT<T>::offset_type offset_type;
static const offset_type element_stride = sizeof(offset_type);
static return_type Read(const uint8_t *const p, const offset_type i) {
// Offsets are relative to themselves, so first update the pointer to
// point to the offset location.
const uint8_t *const offset_location = p + i * element_stride;
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
// then determine the relative location from the offset location.
return reinterpret_cast<return_type>(
offset_location + ReadScalar<offset_type>(offset_location));
}
static mutable_return_type Read(uint8_t *const p, const offset_type i) {
// Offsets are relative to themselves, so first update the pointer to
// point to the offset location.
uint8_t *const offset_location = p + i * element_stride;
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
// then determine the relative location from the offset location.
return reinterpret_cast<mutable_return_type>(
offset_location + ReadScalar<offset_type>(offset_location));
}
};
// For vector of structs.
template<typename T> struct IndirectHelper<const T *> {
typedef const T *return_type;
typedef T *mutable_return_type;
static const size_t element_stride = sizeof(T);
static return_type Read(const uint8_t *const p, const size_t i) {
// Structs are stored inline, relative to the first struct pointer.
return reinterpret_cast<return_type>(p + i * element_stride);
}
static mutable_return_type Read(uint8_t *const p, const size_t i) {
// Structs are stored inline, relative to the first struct pointer.
return reinterpret_cast<mutable_return_type>(p + i * element_stride);
}
};
/// @brief Get a pointer to the file_identifier section of the buffer.
/// @return Returns a const char pointer to the start of the file_identifier
/// characters in the buffer. The returned char * has length
/// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'.
/// This function is UNDEFINED for FlatBuffers whose schema does not include
/// a file_identifier (likely points at padding or the start of a the root
/// vtable).
inline const char *GetBufferIdentifier(const void *buf,
bool size_prefixed = false) {
return reinterpret_cast<const char *>(buf) +
((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t));
}
// Helper to see if the identifier in a buffer has the expected value.
inline bool BufferHasIdentifier(const void *buf, const char *identifier,
bool size_prefixed = false) {
return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier,
flatbuffers::kFileIdentifierLength) == 0;
}
/// @cond FLATBUFFERS_INTERNAL
// Helpers to get a typed pointer to the root object contained in the buffer.
template<typename T> T *GetMutableRoot(void *buf) {
if (!buf) return nullptr;
EndianCheck();
return reinterpret_cast<T *>(
reinterpret_cast<uint8_t *>(buf) +
EndianScalar(*reinterpret_cast<uoffset_t *>(buf)));
}
template<typename T, typename SizeT = uoffset_t>
T *GetMutableSizePrefixedRoot(void *buf) {
return GetMutableRoot<T>(reinterpret_cast<uint8_t *>(buf) + sizeof(SizeT));
}
template<typename T> const T *GetRoot(const void *buf) {
return GetMutableRoot<T>(const_cast<void *>(buf));
}
template<typename T, typename SizeT = uoffset_t>
const T *GetSizePrefixedRoot(const void *buf) {
return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(SizeT));
}
} // namespace flatbuffers
#endif // FLATBUFFERS_BUFFER_H_

@ -0,0 +1,53 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_BUFFER_REF_H_
#define FLATBUFFERS_BUFFER_REF_H_
#include "flatbuffers/base.h"
#include "flatbuffers/verifier.h"
namespace flatbuffers {
// Convenient way to bundle a buffer and its length, to pass it around
// typed by its root.
// A BufferRef does not own its buffer.
struct BufferRefBase {}; // for std::is_base_of
template<typename T> struct BufferRef : BufferRefBase {
BufferRef() : buf(nullptr), len(0), must_free(false) {}
BufferRef(uint8_t *_buf, uoffset_t _len)
: buf(_buf), len(_len), must_free(false) {}
~BufferRef() {
if (must_free) free(buf);
}
const T *GetRoot() const { return flatbuffers::GetRoot<T>(buf); }
bool Verify() {
Verifier verifier(buf, len);
return verifier.VerifyBuffer<T>(nullptr);
}
uint8_t *buf;
uoffset_t len;
bool must_free;
};
} // namespace flatbuffers
#endif // FLATBUFFERS_BUFFER_REF_H_

@ -0,0 +1,64 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_DEFAULT_ALLOCATOR_H_
#define FLATBUFFERS_DEFAULT_ALLOCATOR_H_
#include "flatbuffers/allocator.h"
#include "flatbuffers/base.h"
namespace flatbuffers {
// DefaultAllocator uses new/delete to allocate memory regions
class DefaultAllocator : public Allocator {
public:
uint8_t *allocate(size_t size) FLATBUFFERS_OVERRIDE {
return new uint8_t[size];
}
void deallocate(uint8_t *p, size_t) FLATBUFFERS_OVERRIDE { delete[] p; }
static void dealloc(void *p, size_t) { delete[] static_cast<uint8_t *>(p); }
};
// These functions allow for a null allocator to mean use the default allocator,
// as used by DetachedBuffer and vector_downward below.
// This is to avoid having a statically or dynamically allocated default
// allocator, or having to move it between the classes that may own it.
inline uint8_t *Allocate(Allocator *allocator, size_t size) {
return allocator ? allocator->allocate(size)
: DefaultAllocator().allocate(size);
}
inline void Deallocate(Allocator *allocator, uint8_t *p, size_t size) {
if (allocator)
allocator->deallocate(p, size);
else
DefaultAllocator().deallocate(p, size);
}
inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p,
size_t old_size, size_t new_size,
size_t in_use_back, size_t in_use_front) {
return allocator ? allocator->reallocate_downward(old_p, old_size, new_size,
in_use_back, in_use_front)
: DefaultAllocator().reallocate_downward(
old_p, old_size, new_size, in_use_back, in_use_front);
}
} // namespace flatbuffers
#endif // FLATBUFFERS_DEFAULT_ALLOCATOR_H_

@ -0,0 +1,114 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_DETACHED_BUFFER_H_
#define FLATBUFFERS_DETACHED_BUFFER_H_
#include "flatbuffers/allocator.h"
#include "flatbuffers/base.h"
#include "flatbuffers/default_allocator.h"
namespace flatbuffers {
// DetachedBuffer is a finished flatbuffer memory region, detached from its
// builder. The original memory region and allocator are also stored so that
// the DetachedBuffer can manage the memory lifetime.
class DetachedBuffer {
public:
DetachedBuffer()
: allocator_(nullptr),
own_allocator_(false),
buf_(nullptr),
reserved_(0),
cur_(nullptr),
size_(0) {}
DetachedBuffer(Allocator *allocator, bool own_allocator, uint8_t *buf,
size_t reserved, uint8_t *cur, size_t sz)
: allocator_(allocator),
own_allocator_(own_allocator),
buf_(buf),
reserved_(reserved),
cur_(cur),
size_(sz) {}
DetachedBuffer(DetachedBuffer &&other) noexcept
: allocator_(other.allocator_),
own_allocator_(other.own_allocator_),
buf_(other.buf_),
reserved_(other.reserved_),
cur_(other.cur_),
size_(other.size_) {
other.reset();
}
DetachedBuffer &operator=(DetachedBuffer &&other) noexcept {
if (this == &other) return *this;
destroy();
allocator_ = other.allocator_;
own_allocator_ = other.own_allocator_;
buf_ = other.buf_;
reserved_ = other.reserved_;
cur_ = other.cur_;
size_ = other.size_;
other.reset();
return *this;
}
~DetachedBuffer() { destroy(); }
const uint8_t *data() const { return cur_; }
uint8_t *data() { return cur_; }
size_t size() const { return size_; }
// These may change access mode, leave these at end of public section
FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other));
FLATBUFFERS_DELETE_FUNC(
DetachedBuffer &operator=(const DetachedBuffer &other));
protected:
Allocator *allocator_;
bool own_allocator_;
uint8_t *buf_;
size_t reserved_;
uint8_t *cur_;
size_t size_;
inline void destroy() {
if (buf_) Deallocate(allocator_, buf_, reserved_);
if (own_allocator_ && allocator_) { delete allocator_; }
reset();
}
inline void reset() {
allocator_ = nullptr;
own_allocator_ = false;
buf_ = nullptr;
reserved_ = 0;
cur_ = nullptr;
size_ = 0;
}
};
} // namespace flatbuffers
#endif // FLATBUFFERS_DETACHED_BUFFER_H_

File diff suppressed because it is too large Load Diff

@ -0,0 +1,273 @@
/*
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_H_
#define FLATBUFFERS_H_
#include <algorithm>
// TODO: These includes are for mitigating the pains of users editing their
// source because they relied on flatbuffers.h to include everything for them.
#include "flatbuffers/array.h"
#include "flatbuffers/base.h"
#include "flatbuffers/buffer.h"
#include "flatbuffers/buffer_ref.h"
#include "flatbuffers/detached_buffer.h"
#include "flatbuffers/flatbuffer_builder.h"
#include "flatbuffers/stl_emulation.h"
#include "flatbuffers/string.h"
#include "flatbuffers/struct.h"
#include "flatbuffers/table.h"
#include "flatbuffers/vector.h"
#include "flatbuffers/vector_downward.h"
#include "flatbuffers/verifier.h"
namespace flatbuffers {
/// @brief This can compute the start of a FlatBuffer from a root pointer, i.e.
/// it is the opposite transformation of GetRoot().
/// This may be useful if you want to pass on a root and have the recipient
/// delete the buffer afterwards.
inline const uint8_t *GetBufferStartFromRootPointer(const void *root) {
auto table = reinterpret_cast<const Table *>(root);
auto vtable = table->GetVTable();
// Either the vtable is before the root or after the root.
auto start = (std::min)(vtable, reinterpret_cast<const uint8_t *>(root));
// Align to at least sizeof(uoffset_t).
start = reinterpret_cast<const uint8_t *>(reinterpret_cast<uintptr_t>(start) &
~(sizeof(uoffset_t) - 1));
// Additionally, there may be a file_identifier in the buffer, and the root
// offset. The buffer may have been aligned to any size between
// sizeof(uoffset_t) and FLATBUFFERS_MAX_ALIGNMENT (see "force_align").
// Sadly, the exact alignment is only known when constructing the buffer,
// since it depends on the presence of values with said alignment properties.
// So instead, we simply look at the next uoffset_t values (root,
// file_identifier, and alignment padding) to see which points to the root.
// None of the other values can "impersonate" the root since they will either
// be 0 or four ASCII characters.
static_assert(flatbuffers::kFileIdentifierLength == sizeof(uoffset_t),
"file_identifier is assumed to be the same size as uoffset_t");
for (auto possible_roots = FLATBUFFERS_MAX_ALIGNMENT / sizeof(uoffset_t) + 1;
possible_roots; possible_roots--) {
start -= sizeof(uoffset_t);
if (ReadScalar<uoffset_t>(start) + start ==
reinterpret_cast<const uint8_t *>(root))
return start;
}
// We didn't find the root, either the "root" passed isn't really a root,
// or the buffer is corrupt.
// Assert, because calling this function with bad data may cause reads
// outside of buffer boundaries.
FLATBUFFERS_ASSERT(false);
return nullptr;
}
/// @brief This return the prefixed size of a FlatBuffer.
template<typename SizeT = uoffset_t>
inline SizeT GetPrefixedSize(const uint8_t *buf) {
return ReadScalar<SizeT>(buf);
}
// Base class for native objects (FlatBuffer data de-serialized into native
// C++ data structures).
// Contains no functionality, purely documentative.
struct NativeTable {};
/// @brief Function types to be used with resolving hashes into objects and
/// back again. The resolver gets a pointer to a field inside an object API
/// object that is of the type specified in the schema using the attribute
/// `cpp_type` (it is thus important whatever you write to this address
/// matches that type). The value of this field is initially null, so you
/// may choose to implement a delayed binding lookup using this function
/// if you wish. The resolver does the opposite lookup, for when the object
/// is being serialized again.
typedef uint64_t hash_value_t;
typedef std::function<void(void **pointer_adr, hash_value_t hash)>
resolver_function_t;
typedef std::function<hash_value_t(void *pointer)> rehasher_function_t;
// Helper function to test if a field is present, using any of the field
// enums in the generated code.
// `table` must be a generated table type. Since this is a template parameter,
// this is not typechecked to be a subclass of Table, so beware!
// Note: this function will return false for fields equal to the default
// value, since they're not stored in the buffer (unless force_defaults was
// used).
template<typename T>
bool IsFieldPresent(const T *table, typename T::FlatBuffersVTableOffset field) {
// Cast, since Table is a private baseclass of any table types.
return reinterpret_cast<const Table *>(table)->CheckField(
static_cast<voffset_t>(field));
}
// Utility function for reverse lookups on the EnumNames*() functions
// (in the generated C++ code)
// names must be NULL terminated.
inline int LookupEnum(const char **names, const char *name) {
for (const char **p = names; *p; p++)
if (!strcmp(*p, name)) return static_cast<int>(p - names);
return -1;
}
// These macros allow us to layout a struct with a guarantee that they'll end
// up looking the same on different compilers and platforms.
// It does this by disallowing the compiler to do any padding, and then
// does padding itself by inserting extra padding fields that make every
// element aligned to its own size.
// Additionally, it manually sets the alignment of the struct as a whole,
// which is typically its largest element, or a custom size set in the schema
// by the force_align attribute.
// These are used in the generated code only.
// clang-format off
#if defined(_MSC_VER)
#define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
__pragma(pack(1)) \
struct __declspec(align(alignment))
#define FLATBUFFERS_STRUCT_END(name, size) \
__pragma(pack()) \
static_assert(sizeof(name) == size, "compiler breaks packing rules")
#elif defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
#define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
_Pragma("pack(1)") \
struct __attribute__((aligned(alignment)))
#define FLATBUFFERS_STRUCT_END(name, size) \
_Pragma("pack()") \
static_assert(sizeof(name) == size, "compiler breaks packing rules")
#else
#error Unknown compiler, please define structure alignment macros
#endif
// clang-format on
// Minimal reflection via code generation.
// Besides full-fat reflection (see reflection.h) and parsing/printing by
// loading schemas (see idl.h), we can also have code generation for minimal
// reflection data which allows pretty-printing and other uses without needing
// a schema or a parser.
// Generate code with --reflect-types (types only) or --reflect-names (names
// also) to enable.
// See minireflect.h for utilities using this functionality.
// These types are organized slightly differently as the ones in idl.h.
enum SequenceType { ST_TABLE, ST_STRUCT, ST_UNION, ST_ENUM };
// Scalars have the same order as in idl.h
// clang-format off
#define FLATBUFFERS_GEN_ELEMENTARY_TYPES(ET) \
ET(ET_UTYPE) \
ET(ET_BOOL) \
ET(ET_CHAR) \
ET(ET_UCHAR) \
ET(ET_SHORT) \
ET(ET_USHORT) \
ET(ET_INT) \
ET(ET_UINT) \
ET(ET_LONG) \
ET(ET_ULONG) \
ET(ET_FLOAT) \
ET(ET_DOUBLE) \
ET(ET_STRING) \
ET(ET_SEQUENCE) // See SequenceType.
enum ElementaryType {
#define FLATBUFFERS_ET(E) E,
FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET)
#undef FLATBUFFERS_ET
};
inline const char * const *ElementaryTypeNames() {
static const char * const names[] = {
#define FLATBUFFERS_ET(E) #E,
FLATBUFFERS_GEN_ELEMENTARY_TYPES(FLATBUFFERS_ET)
#undef FLATBUFFERS_ET
};
return names;
}
// clang-format on
// Basic type info cost just 16bits per field!
// We're explicitly defining the signedness since the signedness of integer
// bitfields is otherwise implementation-defined and causes warnings on older
// GCC compilers.
struct TypeCode {
// ElementaryType
unsigned short base_type : 4;
// Either vector (in table) or array (in struct)
unsigned short is_repeating : 1;
// Index into type_refs below, or -1 for none.
signed short sequence_ref : 11;
};
static_assert(sizeof(TypeCode) == 2, "TypeCode");
struct TypeTable;
// Signature of the static method present in each type.
typedef const TypeTable *(*TypeFunction)();
struct TypeTable {
SequenceType st;
size_t num_elems; // of type_codes, values, names (but not type_refs).
const TypeCode *type_codes; // num_elems count
const TypeFunction *type_refs; // less than num_elems entries (see TypeCode).
const int16_t *array_sizes; // less than num_elems entries (see TypeCode).
const int64_t *values; // Only set for non-consecutive enum/union or structs.
const char *const *names; // Only set if compiled with --reflect-names.
};
// String which identifies the current version of FlatBuffers.
inline const char *flatbuffers_version_string() {
return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
}
// clang-format off
#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
inline E operator | (E lhs, E rhs){\
return E(T(lhs) | T(rhs));\
}\
inline E operator & (E lhs, E rhs){\
return E(T(lhs) & T(rhs));\
}\
inline E operator ^ (E lhs, E rhs){\
return E(T(lhs) ^ T(rhs));\
}\
inline E operator ~ (E lhs){\
return E(~T(lhs));\
}\
inline E operator |= (E &lhs, E rhs){\
lhs = lhs | rhs;\
return lhs;\
}\
inline E operator &= (E &lhs, E rhs){\
lhs = lhs & rhs;\
return lhs;\
}\
inline E operator ^= (E &lhs, E rhs){\
lhs = lhs ^ rhs;\
return lhs;\
}\
inline bool operator !(E rhs) \
{\
return !bool(T(rhs)); \
}
/// @endcond
} // namespace flatbuffers
// clang-format on
#endif // FLATBUFFERS_H_

@ -0,0 +1,513 @@
/*
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_STL_EMULATION_H_
#define FLATBUFFERS_STL_EMULATION_H_
// clang-format off
#include "flatbuffers/base.h"
#include <string>
#include <type_traits>
#include <vector>
#include <memory>
#include <limits>
#ifndef FLATBUFFERS_USE_STD_OPTIONAL
// Detect C++17 compatible compiler.
// __cplusplus >= 201703L - a compiler has support of 'static inline' variables.
#if (defined(__cplusplus) && __cplusplus >= 201703L) \
|| (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
#define FLATBUFFERS_USE_STD_OPTIONAL 1
#else
#define FLATBUFFERS_USE_STD_OPTIONAL 0
#endif // (defined(__cplusplus) && __cplusplus >= 201703L) ...
#endif // FLATBUFFERS_USE_STD_OPTIONAL
#if FLATBUFFERS_USE_STD_OPTIONAL
#include <optional>
#endif
#ifndef FLATBUFFERS_USE_STD_SPAN
// Testing __cpp_lib_span requires including either <version> or <span>,
// both of which were added in C++20.
// See: https://en.cppreference.com/w/cpp/utility/feature_test
#if defined(__cplusplus) && __cplusplus >= 202002L
#define FLATBUFFERS_USE_STD_SPAN 1
#endif
#endif // FLATBUFFERS_USE_STD_SPAN
#if defined(FLATBUFFERS_USE_STD_SPAN)
#include <array>
#include <span>
#else
// Disable non-trivial ctors if FLATBUFFERS_SPAN_MINIMAL defined.
#if !defined(FLATBUFFERS_TEMPLATES_ALIASES)
#define FLATBUFFERS_SPAN_MINIMAL
#else
// Enable implicit construction of a span<T,N> from a std::array<T,N>.
#include <array>
#endif
#endif // defined(FLATBUFFERS_USE_STD_SPAN)
// This header provides backwards compatibility for older versions of the STL.
namespace flatbuffers {
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
template <typename T>
using numeric_limits = std::numeric_limits<T>;
#else
template <typename T> class numeric_limits :
public std::numeric_limits<T> {};
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
template <typename T> using is_scalar = std::is_scalar<T>;
template <typename T, typename U> using is_same = std::is_same<T,U>;
template <typename T> using is_floating_point = std::is_floating_point<T>;
template <typename T> using is_unsigned = std::is_unsigned<T>;
template <typename T> using is_enum = std::is_enum<T>;
template <typename T> using make_unsigned = std::make_unsigned<T>;
template<bool B, class T, class F>
using conditional = std::conditional<B, T, F>;
template<class T, T v>
using integral_constant = std::integral_constant<T, v>;
template <bool B>
using bool_constant = integral_constant<bool, B>;
using true_type = std::true_type;
using false_type = std::false_type;
#else
// MSVC 2010 doesn't support C++11 aliases.
template <typename T> struct is_scalar : public std::is_scalar<T> {};
template <typename T, typename U> struct is_same : public std::is_same<T,U> {};
template <typename T> struct is_floating_point :
public std::is_floating_point<T> {};
template <typename T> struct is_unsigned : public std::is_unsigned<T> {};
template <typename T> struct is_enum : public std::is_enum<T> {};
template <typename T> struct make_unsigned : public std::make_unsigned<T> {};
template<bool B, class T, class F>
struct conditional : public std::conditional<B, T, F> {};
template<class T, T v>
struct integral_constant : public std::integral_constant<T, v> {};
template <bool B>
struct bool_constant : public integral_constant<bool, B> {};
typedef bool_constant<true> true_type;
typedef bool_constant<false> false_type;
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
template <class T> using unique_ptr = std::unique_ptr<T>;
#else
// MSVC 2010 doesn't support C++11 aliases.
// We're manually "aliasing" the class here as we want to bring unique_ptr
// into the flatbuffers namespace. We have unique_ptr in the flatbuffers
// namespace we have a completely independent implementation (see below)
// for C++98 STL implementations.
template <class T> class unique_ptr : public std::unique_ptr<T> {
public:
unique_ptr() {}
explicit unique_ptr(T* p) : std::unique_ptr<T>(p) {}
unique_ptr(std::unique_ptr<T>&& u) { *this = std::move(u); }
unique_ptr(unique_ptr&& u) { *this = std::move(u); }
unique_ptr& operator=(std::unique_ptr<T>&& u) {
std::unique_ptr<T>::reset(u.release());
return *this;
}
unique_ptr& operator=(unique_ptr&& u) {
std::unique_ptr<T>::reset(u.release());
return *this;
}
unique_ptr& operator=(T* p) {
return std::unique_ptr<T>::operator=(p);
}
};
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
#if FLATBUFFERS_USE_STD_OPTIONAL
template<class T>
using Optional = std::optional<T>;
using nullopt_t = std::nullopt_t;
inline constexpr nullopt_t nullopt = std::nullopt;
#else
// Limited implementation of Optional<T> type for a scalar T.
// This implementation limited by trivial types compatible with
// std::is_arithmetic<T> or std::is_enum<T> type traits.
// A tag to indicate an empty flatbuffers::optional<T>.
struct nullopt_t {
explicit FLATBUFFERS_CONSTEXPR_CPP11 nullopt_t(int) {}
};
#if defined(FLATBUFFERS_CONSTEXPR_DEFINED)
namespace internal {
template <class> struct nullopt_holder {
static constexpr nullopt_t instance_ = nullopt_t(0);
};
template<class Dummy>
constexpr nullopt_t nullopt_holder<Dummy>::instance_;
}
static constexpr const nullopt_t &nullopt = internal::nullopt_holder<void>::instance_;
#else
namespace internal {
template <class> struct nullopt_holder {
static const nullopt_t instance_;
};
template<class Dummy>
const nullopt_t nullopt_holder<Dummy>::instance_ = nullopt_t(0);
}
static const nullopt_t &nullopt = internal::nullopt_holder<void>::instance_;
#endif
template<class T>
class Optional FLATBUFFERS_FINAL_CLASS {
// Non-scalar 'T' would extremely complicated Optional<T>.
// Use is_scalar<T> checking because flatbuffers flatbuffers::is_arithmetic<T>
// isn't implemented.
static_assert(flatbuffers::is_scalar<T>::value, "unexpected type T");
public:
~Optional() {}
FLATBUFFERS_CONSTEXPR_CPP11 Optional() FLATBUFFERS_NOEXCEPT
: value_(), has_value_(false) {}
FLATBUFFERS_CONSTEXPR_CPP11 Optional(nullopt_t) FLATBUFFERS_NOEXCEPT
: value_(), has_value_(false) {}
FLATBUFFERS_CONSTEXPR_CPP11 Optional(T val) FLATBUFFERS_NOEXCEPT
: value_(val), has_value_(true) {}
FLATBUFFERS_CONSTEXPR_CPP11 Optional(const Optional &other) FLATBUFFERS_NOEXCEPT
: value_(other.value_), has_value_(other.has_value_) {}
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(const Optional &other) FLATBUFFERS_NOEXCEPT {
value_ = other.value_;
has_value_ = other.has_value_;
return *this;
}
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(nullopt_t) FLATBUFFERS_NOEXCEPT {
value_ = T();
has_value_ = false;
return *this;
}
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(T val) FLATBUFFERS_NOEXCEPT {
value_ = val;
has_value_ = true;
return *this;
}
void reset() FLATBUFFERS_NOEXCEPT {
*this = nullopt;
}
void swap(Optional &other) FLATBUFFERS_NOEXCEPT {
std::swap(value_, other.value_);
std::swap(has_value_, other.has_value_);
}
FLATBUFFERS_CONSTEXPR_CPP11 FLATBUFFERS_EXPLICIT_CPP11 operator bool() const FLATBUFFERS_NOEXCEPT {
return has_value_;
}
FLATBUFFERS_CONSTEXPR_CPP11 bool has_value() const FLATBUFFERS_NOEXCEPT {
return has_value_;
}
FLATBUFFERS_CONSTEXPR_CPP11 const T& operator*() const FLATBUFFERS_NOEXCEPT {
return value_;
}
const T& value() const {
FLATBUFFERS_ASSERT(has_value());
return value_;
}
T value_or(T default_value) const FLATBUFFERS_NOEXCEPT {
return has_value() ? value_ : default_value;
}
private:
T value_;
bool has_value_;
};
template<class T>
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& opt, nullopt_t) FLATBUFFERS_NOEXCEPT {
return !opt;
}
template<class T>
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(nullopt_t, const Optional<T>& opt) FLATBUFFERS_NOEXCEPT {
return !opt;
}
template<class T, class U>
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const U& rhs) FLATBUFFERS_NOEXCEPT {
return static_cast<bool>(lhs) && (*lhs == rhs);
}
template<class T, class U>
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const T& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
return static_cast<bool>(rhs) && (lhs == *rhs);
}
template<class T, class U>
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
return static_cast<bool>(lhs) != static_cast<bool>(rhs)
? false
: !static_cast<bool>(lhs) ? false : (*lhs == *rhs);
}
#endif // FLATBUFFERS_USE_STD_OPTIONAL
// Very limited and naive partial implementation of C++20 std::span<T,Extent>.
#if defined(FLATBUFFERS_USE_STD_SPAN)
inline constexpr std::size_t dynamic_extent = std::dynamic_extent;
template<class T, std::size_t Extent = std::dynamic_extent>
using span = std::span<T, Extent>;
#else // !defined(FLATBUFFERS_USE_STD_SPAN)
FLATBUFFERS_CONSTEXPR std::size_t dynamic_extent = static_cast<std::size_t>(-1);
// Exclude this code if MSVC2010 or non-STL Android is active.
// The non-STL Android doesn't have `std::is_convertible` required for SFINAE.
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
namespace internal {
// This is SFINAE helper class for checking of a common condition:
// > This overload only participates in overload resolution
// > Check whether a pointer to an array of From can be converted
// > to a pointer to an array of To.
// This helper is used for checking of 'From -> const From'.
template<class To, std::size_t Extent, class From, std::size_t N>
struct is_span_convertible {
using type =
typename std::conditional<std::is_convertible<From (*)[], To (*)[]>::value
&& (Extent == dynamic_extent || N == Extent),
int, void>::type;
};
template<typename T>
struct SpanIterator {
// TODO: upgrade to std::random_access_iterator_tag.
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = typename std::remove_cv<T>::type;
using reference = T&;
using pointer = T*;
// Convince MSVC compiler that this iterator is trusted (it is verified).
#ifdef _MSC_VER
using _Unchecked_type = pointer;
#endif // _MSC_VER
SpanIterator(pointer ptr) : ptr_(ptr) {}
reference operator*() const { return *ptr_; }
pointer operator->() { return ptr_; }
SpanIterator& operator++() { ptr_++; return *this; }
SpanIterator operator++(int) { auto tmp = *this; ++(*this); return tmp; }
friend bool operator== (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ == rhs.ptr_; }
friend bool operator!= (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ != rhs.ptr_; }
private:
pointer ptr_;
};
} // namespace internal
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
// T - element type; must be a complete type that is not an abstract
// class type.
// Extent - the number of elements in the sequence, or dynamic.
template<class T, std::size_t Extent = dynamic_extent>
class span FLATBUFFERS_FINAL_CLASS {
public:
typedef T element_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef std::size_t size_type;
static FLATBUFFERS_CONSTEXPR size_type extent = Extent;
// Returns the number of elements in the span.
FLATBUFFERS_CONSTEXPR_CPP11 size_type size() const FLATBUFFERS_NOEXCEPT {
return count_;
}
// Returns the size of the sequence in bytes.
FLATBUFFERS_CONSTEXPR_CPP11
size_type size_bytes() const FLATBUFFERS_NOEXCEPT {
return size() * sizeof(element_type);
}
// Checks if the span is empty.
FLATBUFFERS_CONSTEXPR_CPP11 bool empty() const FLATBUFFERS_NOEXCEPT {
return size() == 0;
}
// Returns a pointer to the beginning of the sequence.
FLATBUFFERS_CONSTEXPR_CPP11 pointer data() const FLATBUFFERS_NOEXCEPT {
return data_;
}
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
using Iterator = internal::SpanIterator<T>;
Iterator begin() const { return Iterator(data()); }
Iterator end() const { return Iterator(data() + size()); }
#endif
// Returns a reference to the idx-th element of the sequence.
// The behavior is undefined if the idx is greater than or equal to size().
FLATBUFFERS_CONSTEXPR_CPP11 reference operator[](size_type idx) const {
return data()[idx];
}
FLATBUFFERS_CONSTEXPR_CPP11 span(const span &other) FLATBUFFERS_NOEXCEPT
: data_(other.data_), count_(other.count_) {}
FLATBUFFERS_CONSTEXPR_CPP14 span &operator=(const span &other)
FLATBUFFERS_NOEXCEPT {
data_ = other.data_;
count_ = other.count_;
}
// Limited implementation of
// `template <class It> constexpr std::span(It first, size_type count);`.
//
// Constructs a span that is a view over the range [first, first + count);
// the resulting span has: data() == first and size() == count.
// The behavior is undefined if [first, first + count) is not a valid range,
// or if (extent != flatbuffers::dynamic_extent && count != extent).
FLATBUFFERS_CONSTEXPR_CPP11
explicit span(pointer first, size_type count) FLATBUFFERS_NOEXCEPT
: data_ (Extent == dynamic_extent ? first : (Extent == count ? first : nullptr)),
count_(Extent == dynamic_extent ? count : (Extent == count ? Extent : 0)) {
// Make span empty if the count argument is incompatible with span<T,N>.
}
// Exclude this code if MSVC2010 is active. The MSVC2010 isn't C++11
// compliant, it doesn't support default template arguments for functions.
#if defined(FLATBUFFERS_SPAN_MINIMAL)
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
count_(0) {
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
}
#else
// Constructs an empty span whose data() == nullptr and size() == 0.
// This overload only participates in overload resolution if
// extent == 0 || extent == flatbuffers::dynamic_extent.
// A dummy template argument N is need dependency for SFINAE.
template<std::size_t N = 0,
typename internal::is_span_convertible<element_type, Extent, element_type, (N - N)>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
count_(0) {
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
}
// Constructs a span that is a view over the array arr; the resulting span
// has size() == N and data() == std::data(arr). These overloads only
// participate in overload resolution if
// extent == std::dynamic_extent || N == extent is true and
// std::remove_pointer_t<decltype(std::data(arr))>(*)[]
// is convertible to element_type (*)[].
template<std::size_t N,
typename internal::is_span_convertible<element_type, Extent, element_type, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(element_type (&arr)[N]) FLATBUFFERS_NOEXCEPT
: data_(arr), count_(N) {}
template<class U, std::size_t N,
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
: data_(arr.data()), count_(N) {}
//template<class U, std::size_t N,
// int = 0>
//FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
// : data_(arr.data()), count_(N) {}
template<class U, std::size_t N,
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(const std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
: data_(arr.data()), count_(N) {}
// Converting constructor from another span s;
// the resulting span has size() == s.size() and data() == s.data().
// This overload only participates in overload resolution
// if extent == std::dynamic_extent || N == extent is true and U (*)[]
// is convertible to element_type (*)[].
template<class U, std::size_t N,
typename internal::is_span_convertible<element_type, Extent, U, N>::type = 0>
FLATBUFFERS_CONSTEXPR_CPP11 span(const flatbuffers::span<U, N> &s) FLATBUFFERS_NOEXCEPT
: span(s.data(), s.size()) {
}
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
private:
// This is a naive implementation with 'count_' member even if (Extent != dynamic_extent).
pointer const data_;
size_type count_;
};
#endif // defined(FLATBUFFERS_USE_STD_SPAN)
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
flatbuffers::span<ElementType, Extent> make_span(ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT {
return span<ElementType, Extent>(arr);
}
template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
flatbuffers::span<const ElementType, Extent> make_span(const ElementType(&arr)[Extent]) FLATBUFFERS_NOEXCEPT {
return span<const ElementType, Extent>(arr);
}
template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
flatbuffers::span<ElementType, Extent> make_span(std::array<ElementType, Extent> &arr) FLATBUFFERS_NOEXCEPT {
return span<ElementType, Extent>(arr);
}
template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
flatbuffers::span<const ElementType, Extent> make_span(const std::array<ElementType, Extent> &arr) FLATBUFFERS_NOEXCEPT {
return span<const ElementType, Extent>(arr);
}
template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
flatbuffers::span<ElementType, dynamic_extent> make_span(ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
return span<ElementType, dynamic_extent>(first, count);
}
template<class ElementType, std::size_t Extent>
FLATBUFFERS_CONSTEXPR_CPP11
flatbuffers::span<const ElementType, dynamic_extent> make_span(const ElementType *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
return span<const ElementType, dynamic_extent>(first, count);
}
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
} // namespace flatbuffers
#endif // FLATBUFFERS_STL_EMULATION_H_

@ -0,0 +1,64 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_STRING_H_
#define FLATBUFFERS_STRING_H_
#include "flatbuffers/base.h"
#include "flatbuffers/vector.h"
namespace flatbuffers {
struct String : public Vector<char> {
const char *c_str() const { return reinterpret_cast<const char *>(Data()); }
std::string str() const { return std::string(c_str(), size()); }
// clang-format off
#ifdef FLATBUFFERS_HAS_STRING_VIEW
flatbuffers::string_view string_view() const {
return flatbuffers::string_view(c_str(), size());
}
#endif // FLATBUFFERS_HAS_STRING_VIEW
// clang-format on
bool operator<(const String &o) const {
return StringLessThan(this->data(), this->size(), o.data(), o.size());
}
};
// Convenience function to get std::string from a String returning an empty
// string on null pointer.
static inline std::string GetString(const String *str) {
return str ? str->str() : "";
}
// Convenience function to get char* from a String returning an empty string on
// null pointer.
static inline const char *GetCstring(const String *str) {
return str ? str->c_str() : "";
}
#ifdef FLATBUFFERS_HAS_STRING_VIEW
// Convenience function to get string_view from a String returning an empty
// string_view on null pointer.
static inline flatbuffers::string_view GetStringView(const String *str) {
return str ? str->string_view() : flatbuffers::string_view();
}
#endif // FLATBUFFERS_HAS_STRING_VIEW
} // namespace flatbuffers
#endif // FLATBUFFERS_STRING_H_

@ -0,0 +1,53 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_STRUCT_H_
#define FLATBUFFERS_STRUCT_H_
#include "flatbuffers/base.h"
namespace flatbuffers {
// "structs" are flat structures that do not have an offset table, thus
// always have all members present and do not support forwards/backwards
// compatible extensions.
class Struct FLATBUFFERS_FINAL_CLASS {
public:
template<typename T> T GetField(uoffset_t o) const {
return ReadScalar<T>(&data_[o]);
}
template<typename T> T GetStruct(uoffset_t o) const {
return reinterpret_cast<T>(&data_[o]);
}
const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; }
uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; }
private:
// private constructor & copy constructor: you obtain instances of this
// class by pointing to existing data only
Struct();
Struct(const Struct &);
Struct &operator=(const Struct &);
uint8_t data_[1];
};
} // namespace flatbuffers
#endif // FLATBUFFERS_STRUCT_H_

@ -0,0 +1,188 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_TABLE_H_
#define FLATBUFFERS_TABLE_H_
#include "flatbuffers/base.h"
#include "flatbuffers/verifier.h"
namespace flatbuffers {
// "tables" use an offset table (possibly shared) that allows fields to be
// omitted and added at will, but uses an extra indirection to read.
class Table {
public:
const uint8_t *GetVTable() const {
return data_ - ReadScalar<soffset_t>(data_);
}
// This gets the field offset for any of the functions below it, or 0
// if the field was not present.
voffset_t GetOptionalFieldOffset(voffset_t field) const {
// The vtable offset is always at the start.
auto vtable = GetVTable();
// The first element is the size of the vtable (fields + type id + itself).
auto vtsize = ReadScalar<voffset_t>(vtable);
// If the field we're accessing is outside the vtable, we're reading older
// data, so it's the same as if the offset was 0 (not present).
return field < vtsize ? ReadScalar<voffset_t>(vtable + field) : 0;
}
template<typename T> T GetField(voffset_t field, T defaultval) const {
auto field_offset = GetOptionalFieldOffset(field);
return field_offset ? ReadScalar<T>(data_ + field_offset) : defaultval;
}
template<typename P, typename OffsetSize = uoffset_t>
P GetPointer(voffset_t field) {
auto field_offset = GetOptionalFieldOffset(field);
auto p = data_ + field_offset;
return field_offset ? reinterpret_cast<P>(p + ReadScalar<OffsetSize>(p))
: nullptr;
}
template<typename P, typename OffsetSize = uoffset_t>
P GetPointer(voffset_t field) const {
return const_cast<Table *>(this)->GetPointer<P, OffsetSize>(field);
}
template<typename P> P GetPointer64(voffset_t field) {
return GetPointer<P, uoffset64_t>(field);
}
template<typename P> P GetPointer64(voffset_t field) const {
return GetPointer<P, uoffset64_t>(field);
}
template<typename P> P GetStruct(voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
auto p = const_cast<uint8_t *>(data_ + field_offset);
return field_offset ? reinterpret_cast<P>(p) : nullptr;
}
template<typename Raw, typename Face>
flatbuffers::Optional<Face> GetOptional(voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
auto p = data_ + field_offset;
return field_offset ? Optional<Face>(static_cast<Face>(ReadScalar<Raw>(p)))
: Optional<Face>();
}
template<typename T> bool SetField(voffset_t field, T val, T def) {
auto field_offset = GetOptionalFieldOffset(field);
if (!field_offset) return IsTheSameAs(val, def);
WriteScalar(data_ + field_offset, val);
return true;
}
template<typename T> bool SetField(voffset_t field, T val) {
auto field_offset = GetOptionalFieldOffset(field);
if (!field_offset) return false;
WriteScalar(data_ + field_offset, val);
return true;
}
bool SetPointer(voffset_t field, const uint8_t *val) {
auto field_offset = GetOptionalFieldOffset(field);
if (!field_offset) return false;
WriteScalar(data_ + field_offset,
static_cast<uoffset_t>(val - (data_ + field_offset)));
return true;
}
uint8_t *GetAddressOf(voffset_t field) {
auto field_offset = GetOptionalFieldOffset(field);
return field_offset ? data_ + field_offset : nullptr;
}
const uint8_t *GetAddressOf(voffset_t field) const {
return const_cast<Table *>(this)->GetAddressOf(field);
}
bool CheckField(voffset_t field) const {
return GetOptionalFieldOffset(field) != 0;
}
// Verify the vtable of this table.
// Call this once per table, followed by VerifyField once per field.
bool VerifyTableStart(Verifier &verifier) const {
return verifier.VerifyTableStart(data_);
}
// Verify a particular field.
template<typename T>
bool VerifyField(const Verifier &verifier, voffset_t field,
size_t align) const {
// Calling GetOptionalFieldOffset should be safe now thanks to
// VerifyTable().
auto field_offset = GetOptionalFieldOffset(field);
// Check the actual field.
return !field_offset || verifier.VerifyField<T>(data_, field_offset, align);
}
// VerifyField for required fields.
template<typename T>
bool VerifyFieldRequired(const Verifier &verifier, voffset_t field,
size_t align) const {
auto field_offset = GetOptionalFieldOffset(field);
return verifier.Check(field_offset != 0) &&
verifier.VerifyField<T>(data_, field_offset, align);
}
// Versions for offsets.
template<typename OffsetT = uoffset_t>
bool VerifyOffset(const Verifier &verifier, voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
return !field_offset || verifier.VerifyOffset<OffsetT>(data_, field_offset);
}
template<typename OffsetT = uoffset_t>
bool VerifyOffsetRequired(const Verifier &verifier, voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
return verifier.Check(field_offset != 0) &&
verifier.VerifyOffset<OffsetT>(data_, field_offset);
}
bool VerifyOffset64(const Verifier &verifier, voffset_t field) const {
return VerifyOffset<uoffset64_t>(verifier, field);
}
bool VerifyOffset64Required(const Verifier &verifier, voffset_t field) const {
return VerifyOffsetRequired<uoffset64_t>(verifier, field);
}
private:
// private constructor & copy constructor: you obtain instances of this
// class by pointing to existing data only
Table();
Table(const Table &other);
Table &operator=(const Table &);
uint8_t data_[1];
};
// This specialization allows avoiding warnings like:
// MSVC C4800: type: forcing value to bool 'true' or 'false'.
template<>
inline flatbuffers::Optional<bool> Table::GetOptional<uint8_t, bool>(
voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
auto p = data_ + field_offset;
return field_offset ? Optional<bool>(ReadScalar<uint8_t>(p) != 0)
: Optional<bool>();
}
} // namespace flatbuffers
#endif // FLATBUFFERS_TABLE_H_

@ -0,0 +1,400 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_VECTOR_H_
#define FLATBUFFERS_VECTOR_H_
#include "flatbuffers/base.h"
#include "flatbuffers/buffer.h"
#include "flatbuffers/stl_emulation.h"
namespace flatbuffers {
struct String;
// An STL compatible iterator implementation for Vector below, effectively
// calling Get() for every element.
template<typename T, typename IT, typename Data = uint8_t *,
typename SizeT = uoffset_t>
struct VectorIterator {
typedef std::random_access_iterator_tag iterator_category;
typedef IT value_type;
typedef ptrdiff_t difference_type;
typedef IT *pointer;
typedef IT &reference;
static const SizeT element_stride = IndirectHelper<T>::element_stride;
VectorIterator(Data data, SizeT i) : data_(data + element_stride * i) {}
VectorIterator(const VectorIterator &other) : data_(other.data_) {}
VectorIterator() : data_(nullptr) {}
VectorIterator &operator=(const VectorIterator &other) {
data_ = other.data_;
return *this;
}
VectorIterator &operator=(VectorIterator &&other) {
data_ = other.data_;
return *this;
}
bool operator==(const VectorIterator &other) const {
return data_ == other.data_;
}
bool operator<(const VectorIterator &other) const {
return data_ < other.data_;
}
bool operator!=(const VectorIterator &other) const {
return data_ != other.data_;
}
difference_type operator-(const VectorIterator &other) const {
return (data_ - other.data_) / element_stride;
}
// Note: return type is incompatible with the standard
// `reference operator*()`.
IT operator*() const { return IndirectHelper<T>::Read(data_, 0); }
// Note: return type is incompatible with the standard
// `pointer operator->()`.
IT operator->() const { return IndirectHelper<T>::Read(data_, 0); }
VectorIterator &operator++() {
data_ += element_stride;
return *this;
}
VectorIterator operator++(int) {
VectorIterator temp(data_, 0);
data_ += element_stride;
return temp;
}
VectorIterator operator+(const SizeT &offset) const {
return VectorIterator(data_ + offset * element_stride, 0);
}
VectorIterator &operator+=(const SizeT &offset) {
data_ += offset * element_stride;
return *this;
}
VectorIterator &operator--() {
data_ -= element_stride;
return *this;
}
VectorIterator operator--(int) {
VectorIterator temp(data_, 0);
data_ -= element_stride;
return temp;
}
VectorIterator operator-(const SizeT &offset) const {
return VectorIterator(data_ - offset * element_stride, 0);
}
VectorIterator &operator-=(const SizeT &offset) {
data_ -= offset * element_stride;
return *this;
}
private:
Data data_;
};
template<typename T, typename IT, typename SizeT = uoffset_t>
using VectorConstIterator = VectorIterator<T, IT, const uint8_t *, SizeT>;
template<typename Iterator>
struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
explicit VectorReverseIterator(Iterator iter)
: std::reverse_iterator<Iterator>(iter) {}
// Note: return type is incompatible with the standard
// `reference operator*()`.
typename Iterator::value_type operator*() const {
auto tmp = std::reverse_iterator<Iterator>::current;
return *--tmp;
}
// Note: return type is incompatible with the standard
// `pointer operator->()`.
typename Iterator::value_type operator->() const {
auto tmp = std::reverse_iterator<Iterator>::current;
return *--tmp;
}
};
// This is used as a helper type for accessing vectors.
// Vector::data() assumes the vector elements start after the length field.
template<typename T, typename SizeT = uoffset_t> class Vector {
public:
typedef VectorIterator<T,
typename IndirectHelper<T>::mutable_return_type,
uint8_t *, SizeT>
iterator;
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type,
SizeT>
const_iterator;
typedef VectorReverseIterator<iterator> reverse_iterator;
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
typedef typename flatbuffers::bool_constant<flatbuffers::is_scalar<T>::value>
scalar_tag;
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1);
SizeT size() const { return EndianScalar(length_); }
// Deprecated: use size(). Here for backwards compatibility.
FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]])
SizeT Length() const { return size(); }
typedef SizeT size_type;
typedef typename IndirectHelper<T>::return_type return_type;
typedef typename IndirectHelper<T>::mutable_return_type
mutable_return_type;
typedef return_type value_type;
return_type Get(SizeT i) const {
FLATBUFFERS_ASSERT(i < size());
return IndirectHelper<T>::Read(Data(), i);
}
return_type operator[](SizeT i) const { return Get(i); }
// If this is a Vector of enums, T will be its storage type, not the enum
// type. This function makes it convenient to retrieve value with enum
// type E.
template<typename E> E GetEnum(SizeT i) const {
return static_cast<E>(Get(i));
}
// If this a vector of unions, this does the cast for you. There's no check
// to make sure this is the right type!
template<typename U> const U *GetAs(SizeT i) const {
return reinterpret_cast<const U *>(Get(i));
}
// If this a vector of unions, this does the cast for you. There's no check
// to make sure this is actually a string!
const String *GetAsString(SizeT i) const {
return reinterpret_cast<const String *>(Get(i));
}
const void *GetStructFromOffset(size_t o) const {
return reinterpret_cast<const void *>(Data() + o);
}
iterator begin() { return iterator(Data(), 0); }
const_iterator begin() const { return const_iterator(Data(), 0); }
iterator end() { return iterator(Data(), size()); }
const_iterator end() const { return const_iterator(Data(), size()); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const {
return const_reverse_iterator(end());
}
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const {
return const_reverse_iterator(begin());
}
const_iterator cbegin() const { return begin(); }
const_iterator cend() const { return end(); }
const_reverse_iterator crbegin() const { return rbegin(); }
const_reverse_iterator crend() const { return rend(); }
// Change elements if you have a non-const pointer to this object.
// Scalars only. See reflection.h, and the documentation.
void Mutate(SizeT i, const T &val) {
FLATBUFFERS_ASSERT(i < size());
WriteScalar(data() + i, val);
}
// Change an element of a vector of tables (or strings).
// "val" points to the new table/string, as you can obtain from
// e.g. reflection::AddFlatBuffer().
void MutateOffset(SizeT i, const uint8_t *val) {
FLATBUFFERS_ASSERT(i < size());
static_assert(sizeof(T) == sizeof(SizeT), "Unrelated types");
WriteScalar(data() + i,
static_cast<SizeT>(val - (Data() + i * sizeof(SizeT))));
}
// Get a mutable pointer to tables/strings inside this vector.
mutable_return_type GetMutableObject(SizeT i) const {
FLATBUFFERS_ASSERT(i < size());
return const_cast<mutable_return_type>(IndirectHelper<T>::Read(Data(), i));
}
// The raw data in little endian format. Use with care.
const uint8_t *Data() const {
return reinterpret_cast<const uint8_t *>(&length_ + 1);
}
uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); }
// Similarly, but typed, much like std::vector::data
const T *data() const { return reinterpret_cast<const T *>(Data()); }
T *data() { return reinterpret_cast<T *>(Data()); }
template<typename K> return_type LookupByKey(K key) const {
void *search_result = std::bsearch(
&key, Data(), size(), IndirectHelper<T>::element_stride, KeyCompare<K>);
if (!search_result) {
return nullptr; // Key not found.
}
const uint8_t *element = reinterpret_cast<const uint8_t *>(search_result);
return IndirectHelper<T>::Read(element, 0);
}
template<typename K> mutable_return_type MutableLookupByKey(K key) {
return const_cast<mutable_return_type>(LookupByKey(key));
}
protected:
// This class is only used to access pre-existing data. Don't ever
// try to construct these manually.
Vector();
SizeT length_;
private:
// This class is a pointer. Copying will therefore create an invalid object.
// Private and unimplemented copy constructor.
Vector(const Vector &);
Vector &operator=(const Vector &);
template<typename K> static int KeyCompare(const void *ap, const void *bp) {
const K *key = reinterpret_cast<const K *>(ap);
const uint8_t *data = reinterpret_cast<const uint8_t *>(bp);
auto table = IndirectHelper<T>::Read(data, 0);
// std::bsearch compares with the operands transposed, so we negate the
// result here.
return -table->KeyCompareWithValue(*key);
}
};
template<typename T> using Vector64 = Vector<T, uoffset64_t>;
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U> &vec)
FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<U>(vec.data(), vec.size());
}
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
const Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<const U>(vec.data(), vec.size());
}
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<uint8_t> make_bytes_span(
Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::scalar_tag::value,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<uint8_t>(vec.Data(), vec.size() * sizeof(U));
}
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t> make_bytes_span(
const Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::scalar_tag::value,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
}
// Convenient helper functions to get a span of any vector, regardless
// of whether it is null or not (the field is not set).
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U> *ptr)
FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return ptr ? make_span(*ptr) : span<U>();
}
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
const Vector<U> *ptr) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return ptr ? make_span(*ptr) : span<const U>();
}
// Represent a vector much like the template above, but in this case we
// don't know what the element types are (used with reflection.h).
class VectorOfAny {
public:
uoffset_t size() const { return EndianScalar(length_); }
const uint8_t *Data() const {
return reinterpret_cast<const uint8_t *>(&length_ + 1);
}
uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); }
protected:
VectorOfAny();
uoffset_t length_;
private:
VectorOfAny(const VectorOfAny &);
VectorOfAny &operator=(const VectorOfAny &);
};
template<typename T, typename U>
Vector<Offset<T>> *VectorCast(Vector<Offset<U>> *ptr) {
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
return reinterpret_cast<Vector<Offset<T>> *>(ptr);
}
template<typename T, typename U>
const Vector<Offset<T>> *VectorCast(const Vector<Offset<U>> *ptr) {
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
return reinterpret_cast<const Vector<Offset<T>> *>(ptr);
}
// Convenient helper function to get the length of any vector, regardless
// of whether it is null or not (the field is not set).
template<typename T> static inline size_t VectorLength(const Vector<T> *v) {
return v ? v->size() : 0;
}
} // namespace flatbuffers
#endif // FLATBUFFERS_VERIFIER_H_

@ -0,0 +1,288 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_VECTOR_DOWNWARD_H_
#define FLATBUFFERS_VECTOR_DOWNWARD_H_
#include <cstdint>
#include <algorithm>
#include "flatbuffers/base.h"
#include "flatbuffers/default_allocator.h"
#include "flatbuffers/detached_buffer.h"
namespace flatbuffers {
// This is a minimal replication of std::vector<uint8_t> functionality,
// except growing from higher to lower addresses. i.e. push_back() inserts data
// in the lowest address in the vector.
// Since this vector leaves the lower part unused, we support a "scratch-pad"
// that can be stored there for temporary data, to share the allocated space.
// Essentially, this supports 2 std::vectors in a single buffer.
template<typename SizeT = uoffset_t> class vector_downward {
public:
explicit vector_downward(size_t initial_size, Allocator *allocator,
bool own_allocator, size_t buffer_minalign,
const SizeT max_size = FLATBUFFERS_MAX_BUFFER_SIZE)
: allocator_(allocator),
own_allocator_(own_allocator),
initial_size_(initial_size),
max_size_(max_size),
buffer_minalign_(buffer_minalign),
reserved_(0),
size_(0),
buf_(nullptr),
cur_(nullptr),
scratch_(nullptr) {}
vector_downward(vector_downward &&other) noexcept
// clang-format on
: allocator_(other.allocator_),
own_allocator_(other.own_allocator_),
initial_size_(other.initial_size_),
max_size_(other.max_size_),
buffer_minalign_(other.buffer_minalign_),
reserved_(other.reserved_),
size_(other.size_),
buf_(other.buf_),
cur_(other.cur_),
scratch_(other.scratch_) {
// No change in other.allocator_
// No change in other.initial_size_
// No change in other.buffer_minalign_
other.own_allocator_ = false;
other.reserved_ = 0;
other.buf_ = nullptr;
other.cur_ = nullptr;
other.scratch_ = nullptr;
}
vector_downward &operator=(vector_downward &&other) noexcept {
// Move construct a temporary and swap idiom
vector_downward temp(std::move(other));
swap(temp);
return *this;
}
~vector_downward() {
clear_buffer();
clear_allocator();
}
void reset() {
clear_buffer();
clear();
}
void clear() {
if (buf_) {
cur_ = buf_ + reserved_;
} else {
reserved_ = 0;
cur_ = nullptr;
}
size_ = 0;
clear_scratch();
}
void clear_scratch() { scratch_ = buf_; }
void clear_allocator() {
if (own_allocator_ && allocator_) { delete allocator_; }
allocator_ = nullptr;
own_allocator_ = false;
}
void clear_buffer() {
if (buf_) Deallocate(allocator_, buf_, reserved_);
buf_ = nullptr;
}
// Relinquish the pointer to the caller.
uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) {
auto *buf = buf_;
allocated_bytes = reserved_;
offset = vector_downward::offset();
// release_raw only relinquishes the buffer ownership.
// Does not deallocate or reset the allocator. Destructor will do that.
buf_ = nullptr;
clear();
return buf;
}
// Relinquish the pointer to the caller.
DetachedBuffer release() {
// allocator ownership (if any) is transferred to DetachedBuffer.
DetachedBuffer fb(allocator_, own_allocator_, buf_, reserved_, cur_,
size());
if (own_allocator_) {
allocator_ = nullptr;
own_allocator_ = false;
}
buf_ = nullptr;
clear();
return fb;
}
size_t ensure_space(size_t len) {
FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_);
// If the length is larger than the unused part of the buffer, we need to
// grow.
if (len > unused_buffer_size()) { reallocate(len); }
FLATBUFFERS_ASSERT(size() < max_size_);
return len;
}
inline uint8_t *make_space(size_t len) {
if (len) {
ensure_space(len);
cur_ -= len;
size_ += static_cast<SizeT>(len);
}
return cur_;
}
// Returns nullptr if using the DefaultAllocator.
Allocator *get_custom_allocator() { return allocator_; }
// The current offset into the buffer.
size_t offset() const { return cur_ - buf_; }
// The total size of the vector (both the buffer and scratch parts).
inline SizeT size() const { return size_; }
// The size of the buffer part of the vector that is currently unused.
SizeT unused_buffer_size() const { return static_cast<SizeT>(cur_ - scratch_); }
// The size of the scratch part of the vector.
SizeT scratch_size() const { return static_cast<SizeT>(scratch_ - buf_); }
size_t capacity() const { return reserved_; }
uint8_t *data() const {
FLATBUFFERS_ASSERT(cur_);
return cur_;
}
uint8_t *scratch_data() const {
FLATBUFFERS_ASSERT(buf_);
return buf_;
}
uint8_t *scratch_end() const {
FLATBUFFERS_ASSERT(scratch_);
return scratch_;
}
uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; }
void push(const uint8_t *bytes, size_t num) {
if (num > 0) { memcpy(make_space(num), bytes, num); }
}
// Specialized version of push() that avoids memcpy call for small data.
template<typename T> void push_small(const T &little_endian_t) {
make_space(sizeof(T));
*reinterpret_cast<T *>(cur_) = little_endian_t;
}
template<typename T> void scratch_push_small(const T &t) {
ensure_space(sizeof(T));
*reinterpret_cast<T *>(scratch_) = t;
scratch_ += sizeof(T);
}
// fill() is most frequently called with small byte counts (<= 4),
// which is why we're using loops rather than calling memset.
void fill(size_t zero_pad_bytes) {
make_space(zero_pad_bytes);
for (size_t i = 0; i < zero_pad_bytes; i++) cur_[i] = 0;
}
// Version for when we know the size is larger.
// Precondition: zero_pad_bytes > 0
void fill_big(size_t zero_pad_bytes) {
memset(make_space(zero_pad_bytes), 0, zero_pad_bytes);
}
void pop(size_t bytes_to_remove) {
cur_ += bytes_to_remove;
size_ -= static_cast<SizeT>(bytes_to_remove);
}
void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; }
void swap(vector_downward &other) {
using std::swap;
swap(allocator_, other.allocator_);
swap(own_allocator_, other.own_allocator_);
swap(initial_size_, other.initial_size_);
swap(buffer_minalign_, other.buffer_minalign_);
swap(reserved_, other.reserved_);
swap(size_, other.size_);
swap(max_size_, other.max_size_);
swap(buf_, other.buf_);
swap(cur_, other.cur_);
swap(scratch_, other.scratch_);
}
void swap_allocator(vector_downward &other) {
using std::swap;
swap(allocator_, other.allocator_);
swap(own_allocator_, other.own_allocator_);
}
private:
// You shouldn't really be copying instances of this class.
FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward &));
FLATBUFFERS_DELETE_FUNC(vector_downward &operator=(const vector_downward &));
Allocator *allocator_;
bool own_allocator_;
size_t initial_size_;
// The maximum size the vector can be.
SizeT max_size_;
size_t buffer_minalign_;
size_t reserved_;
SizeT size_;
uint8_t *buf_;
uint8_t *cur_; // Points at location between empty (below) and used (above).
uint8_t *scratch_; // Points to the end of the scratchpad in use.
void reallocate(size_t len) {
auto old_reserved = reserved_;
auto old_size = size();
auto old_scratch_size = scratch_size();
reserved_ +=
(std::max)(len, old_reserved ? old_reserved / 2 : initial_size_);
reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1);
if (buf_) {
buf_ = ReallocateDownward(allocator_, buf_, old_reserved, reserved_,
old_size, old_scratch_size);
} else {
buf_ = Allocate(allocator_, reserved_);
}
cur_ = buf_ + reserved_ - old_size;
scratch_ = buf_ + old_scratch_size;
}
};
} // namespace flatbuffers
#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_

@ -0,0 +1,330 @@
/*
* Copyright 2021 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLATBUFFERS_VERIFIER_H_
#define FLATBUFFERS_VERIFIER_H_
#include "flatbuffers/base.h"
#include "flatbuffers/vector.h"
namespace flatbuffers {
// Helper class to verify the integrity of a FlatBuffer
class Verifier FLATBUFFERS_FINAL_CLASS {
public:
struct Options {
// The maximum nesting of tables and vectors before we call it invalid.
uoffset_t max_depth = 64;
// The maximum number of tables we will verify before we call it invalid.
uoffset_t max_tables = 1000000;
// If true, verify all data is aligned.
bool check_alignment = true;
// If true, run verifier on nested flatbuffers
bool check_nested_flatbuffers = true;
// The maximum size of a buffer.
size_t max_size = FLATBUFFERS_MAX_BUFFER_SIZE;
// Use assertions to check for errors.
bool assert = false;
};
explicit Verifier(const uint8_t *const buf, const size_t buf_len,
const Options &opts)
: buf_(buf), size_(buf_len), opts_(opts) {
FLATBUFFERS_ASSERT(size_ < opts.max_size);
}
// Deprecated API, please construct with Verifier::Options.
Verifier(const uint8_t *const buf, const size_t buf_len,
const uoffset_t max_depth = 64, const uoffset_t max_tables = 1000000,
const bool check_alignment = true)
: Verifier(buf, buf_len, [&] {
Options opts;
opts.max_depth = max_depth;
opts.max_tables = max_tables;
opts.check_alignment = check_alignment;
return opts;
}()) {}
// Central location where any verification failures register.
bool Check(const bool ok) const {
// clang-format off
#ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
if (opts_.assert) { FLATBUFFERS_ASSERT(ok); }
#endif
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
if (!ok)
upper_bound_ = 0;
#endif
// clang-format on
return ok;
}
// Verify any range within the buffer.
bool Verify(const size_t elem, const size_t elem_len) const {
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
auto upper_bound = elem + elem_len;
if (upper_bound_ < upper_bound)
upper_bound_ = upper_bound;
#endif
// clang-format on
return Check(elem_len < size_ && elem <= size_ - elem_len);
}
bool VerifyAlignment(const size_t elem, const size_t align) const {
return Check((elem & (align - 1)) == 0 || !opts_.check_alignment);
}
// Verify a range indicated by sizeof(T).
template<typename T> bool Verify(const size_t elem) const {
return VerifyAlignment(elem, sizeof(T)) && Verify(elem, sizeof(T));
}
bool VerifyFromPointer(const uint8_t *const p, const size_t len) {
return Verify(static_cast<size_t>(p - buf_), len);
}
// Verify relative to a known-good base pointer.
bool VerifyFieldStruct(const uint8_t *const base, const voffset_t elem_off,
const size_t elem_len, const size_t align) const {
const auto f = static_cast<size_t>(base - buf_) + elem_off;
return VerifyAlignment(f, align) && Verify(f, elem_len);
}
template<typename T>
bool VerifyField(const uint8_t *const base, const voffset_t elem_off,
const size_t align) const {
const auto f = static_cast<size_t>(base - buf_) + elem_off;
return VerifyAlignment(f, align) && Verify(f, sizeof(T));
}
// Verify a pointer (may be NULL) of a table type.
template<typename T> bool VerifyTable(const T *const table) {
return !table || table->Verify(*this);
}
// Verify a pointer (may be NULL) of any vector type.
template<int &..., typename T, typename LenT>
bool VerifyVector(const Vector<T, LenT> *const vec) const {
return !vec || VerifyVectorOrString<LenT>(
reinterpret_cast<const uint8_t *>(vec), sizeof(T));
}
// Verify a pointer (may be NULL) of a vector to struct.
template<int &..., typename T, typename LenT>
bool VerifyVector(const Vector<const T *, LenT> *const vec) const {
return VerifyVector(reinterpret_cast<const Vector<T, LenT> *>(vec));
}
// Verify a pointer (may be NULL) to string.
bool VerifyString(const String *const str) const {
size_t end;
return !str || (VerifyVectorOrString<uoffset_t>(
reinterpret_cast<const uint8_t *>(str), 1, &end) &&
Verify(end, 1) && // Must have terminator
Check(buf_[end] == '\0')); // Terminating byte must be 0.
}
// Common code between vectors and strings.
template<typename LenT = uoffset_t>
bool VerifyVectorOrString(const uint8_t *const vec, const size_t elem_size,
size_t *const end = nullptr) const {
const auto vec_offset = static_cast<size_t>(vec - buf_);
// Check we can read the size field.
if (!Verify<LenT>(vec_offset)) return false;
// Check the whole array. If this is a string, the byte past the array must
// be 0.
const LenT size = ReadScalar<LenT>(vec);
const auto max_elems = opts_.max_size / elem_size;
if (!Check(size < max_elems))
return false; // Protect against byte_size overflowing.
const auto byte_size = sizeof(LenT) + elem_size * size;
if (end) *end = vec_offset + byte_size;
return Verify(vec_offset, byte_size);
}
// Special case for string contents, after the above has been called.
bool VerifyVectorOfStrings(const Vector<Offset<String>> *const vec) const {
if (vec) {
for (uoffset_t i = 0; i < vec->size(); i++) {
if (!VerifyString(vec->Get(i))) return false;
}
}
return true;
}
// Special case for table contents, after the above has been called.
template<typename T>
bool VerifyVectorOfTables(const Vector<Offset<T>> *const vec) {
if (vec) {
for (uoffset_t i = 0; i < vec->size(); i++) {
if (!vec->Get(i)->Verify(*this)) return false;
}
}
return true;
}
__suppress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart(
const uint8_t *const table) {
// Check the vtable offset.
const auto tableo = static_cast<size_t>(table - buf_);
if (!Verify<soffset_t>(tableo)) return false;
// This offset may be signed, but doing the subtraction unsigned always
// gives the result we want.
const auto vtableo =
tableo - static_cast<size_t>(ReadScalar<soffset_t>(table));
// Check the vtable size field, then check vtable fits in its entirety.
if (!(VerifyComplexity() && Verify<voffset_t>(vtableo) &&
VerifyAlignment(ReadScalar<voffset_t>(buf_ + vtableo),
sizeof(voffset_t))))
return false;
const auto vsize = ReadScalar<voffset_t>(buf_ + vtableo);
return Check((vsize & 1) == 0) && Verify(vtableo, vsize);
}
template<typename T>
bool VerifyBufferFromStart(const char *const identifier, const size_t start) {
// Buffers have to be of some size to be valid. The reason it is a runtime
// check instead of static_assert, is that nested flatbuffers go through
// this call and their size is determined at runtime.
if (!Check(size_ >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
// If an identifier is provided, check that we have a buffer
if (identifier && !Check((size_ >= 2 * sizeof(flatbuffers::uoffset_t) &&
BufferHasIdentifier(buf_ + start, identifier)))) {
return false;
}
// Call T::Verify, which must be in the generated code for this type.
const auto o = VerifyOffset<uoffset_t>(start);
return Check(o != 0) &&
reinterpret_cast<const T *>(buf_ + start + o)->Verify(*this)
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
&& GetComputedSize()
#endif
;
// clang-format on
}
template<typename T, int &..., typename SizeT>
bool VerifyNestedFlatBuffer(const Vector<uint8_t, SizeT> *const buf,
const char *const identifier) {
// Caller opted out of this.
if (!opts_.check_nested_flatbuffers) return true;
// An empty buffer is OK as it indicates not present.
if (!buf) return true;
// If there is a nested buffer, it must be greater than the min size.
if (!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
Verifier nested_verifier(buf->data(), buf->size(), opts_);
return nested_verifier.VerifyBuffer<T>(identifier);
}
// Verify this whole buffer, starting with root type T.
template<typename T> bool VerifyBuffer() { return VerifyBuffer<T>(nullptr); }
template<typename T> bool VerifyBuffer(const char *const identifier) {
return VerifyBufferFromStart<T>(identifier, 0);
}
template<typename T, typename SizeT = uoffset_t>
bool VerifySizePrefixedBuffer(const char *const identifier) {
return Verify<SizeT>(0U) &&
Check(ReadScalar<SizeT>(buf_) == size_ - sizeof(SizeT)) &&
VerifyBufferFromStart<T>(identifier, sizeof(SizeT));
}
template<typename OffsetT = uoffset_t, typename SOffsetT = soffset_t>
size_t VerifyOffset(const size_t start) const {
if (!Verify<OffsetT>(start)) return 0;
const auto o = ReadScalar<OffsetT>(buf_ + start);
// May not point to itself.
if (!Check(o != 0)) return 0;
// Can't wrap around larger than the max size.
if (!Check(static_cast<SOffsetT>(o) >= 0)) return 0;
// Must be inside the buffer to create a pointer from it (pointer outside
// buffer is UB).
if (!Verify(start + o, 1)) return 0;
return o;
}
template<typename OffsetT = uoffset_t>
size_t VerifyOffset(const uint8_t *const base, const voffset_t start) const {
return VerifyOffset<OffsetT>(static_cast<size_t>(base - buf_) + start);
}
// Called at the start of a table to increase counters measuring data
// structure depth and amount, and possibly bails out with false if limits set
// by the constructor have been hit. Needs to be balanced with EndTable().
bool VerifyComplexity() {
depth_++;
num_tables_++;
return Check(depth_ <= opts_.max_depth && num_tables_ <= opts_.max_tables);
}
// Called at the end of a table to pop the depth count.
bool EndTable() {
depth_--;
return true;
}
// Returns the message size in bytes
size_t GetComputedSize() const {
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
uintptr_t size = upper_bound_;
// Align the size to uoffset_t
size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1);
return (size > size_) ? 0 : size;
#else
// Must turn on FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE for this to work.
(void)upper_bound_;
FLATBUFFERS_ASSERT(false);
return 0;
#endif
// clang-format on
}
std::vector<uint8_t> *GetFlexReuseTracker() { return flex_reuse_tracker_; }
void SetFlexReuseTracker(std::vector<uint8_t> *const rt) {
flex_reuse_tracker_ = rt;
}
private:
const uint8_t *buf_;
const size_t size_;
const Options opts_;
mutable size_t upper_bound_ = 0;
uoffset_t depth_ = 0;
uoffset_t num_tables_ = 0;
std::vector<uint8_t> *flex_reuse_tracker_ = nullptr;
};
// Specialization for 64-bit offsets.
template<>
inline size_t Verifier::VerifyOffset<uoffset64_t>(const size_t start) const {
return VerifyOffset<uoffset64_t, soffset64_t>(start);
}
} // namespace flatbuffers
#endif // FLATBUFFERS_VERIFIER_H_

@ -2,19 +2,9 @@
// File: vk_platform.h
//
/*
** Copyright (c) 2014-2017 The Khronos Group Inc.
** Copyright 2014-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
@ -52,7 +42,7 @@ extern "C"
#define VKAPI_CALL __stdcall
#define VKAPI_PTR VKAPI_CALL
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
#error "Vulkan is not supported for the 'armeabi' NDK ABI"
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
// calling convention, i.e. float parameters are passed in registers. This
@ -68,7 +58,9 @@ extern "C"
#define VKAPI_PTR
#endif
#include <stddef.h>
#if !defined(VK_NO_STDDEF_H)
#include <stddef.h>
#endif // !defined(VK_NO_STDDEF_H)
#if !defined(VK_NO_STDINT_H)
#if defined(_MSC_VER) && (_MSC_VER < 1600)

@ -2,19 +2,9 @@
#define VULKAN_H_ 1
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
#include "vk_platform.h"
@ -38,20 +28,16 @@
#include "vulkan_macos.h"
#endif
#ifdef VK_USE_PLATFORM_MIR_KHR
#include <mir_toolkit/client_types.h>
#include "vulkan_mir.h"
#ifdef VK_USE_PLATFORM_METAL_EXT
#include "vulkan_metal.h"
#endif
#ifdef VK_USE_PLATFORM_VI_NN
#include "vulkan_vi.h"
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#include <wayland-client.h>
#include "vulkan_wayland.h"
#endif
@ -74,10 +60,40 @@
#endif
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
#include <directfb.h>
#include "vulkan_directfb.h"
#endif
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include "vulkan_xlib_xrandr.h"
#endif
#ifdef VK_USE_PLATFORM_GGP
#include <ggp_c/vulkan_types.h>
#include "vulkan_ggp.h"
#endif
#ifdef VK_USE_PLATFORM_SCREEN_QNX
#include <screen/screen.h>
#include "vulkan_screen.h"
#endif
#ifdef VK_USE_PLATFORM_SCI
#include <nvscisync.h>
#include <nvscibuf.h>
#include "vulkan_sci.h"
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
#include "vulkan_beta.h"
#endif
#endif // VULKAN_H_

@ -1,24 +1,10 @@
#ifndef VULKAN_ANDROID_H_
#define VULKAN_ANDROID_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,14 +13,17 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_android_surface 1
struct ANativeWindow;
#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface"
typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
typedef struct VkAndroidSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
@ -42,7 +31,6 @@ typedef struct VkAndroidSurfaceCreateInfoKHR {
struct ANativeWindow* window;
} VkAndroidSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
@ -53,12 +41,11 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
VkSurfaceKHR* pSurface);
#endif
#define VK_ANDROID_external_memory_android_hardware_buffer 1
struct AHardwareBuffer;
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 3
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 5
#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer"
typedef struct VkAndroidHardwareBufferUsageANDROID {
VkStructureType sType;
void* pNext;
@ -103,6 +90,18 @@ typedef struct VkExternalFormatANDROID {
uint64_t externalFormat;
} VkExternalFormatANDROID;
typedef struct VkAndroidHardwareBufferFormatProperties2ANDROID {
VkStructureType sType;
void* pNext;
VkFormat format;
uint64_t externalFormat;
VkFormatFeatureFlags2 formatFeatures;
VkComponentMapping samplerYcbcrConversionComponents;
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
VkSamplerYcbcrRange suggestedYcbcrRange;
VkChromaLocation suggestedXChromaOffset;
VkChromaLocation suggestedYChromaOffset;
} VkAndroidHardwareBufferFormatProperties2ANDROID;
typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer);

@ -0,0 +1,492 @@
#ifndef VULKAN_BETA_H_
#define VULKAN_BETA_H_ 1
/*
** Copyright 2015-2023 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_portability_subset 1
#define VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION 1
#define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset"
typedef struct VkPhysicalDevicePortabilitySubsetFeaturesKHR {
VkStructureType sType;
void* pNext;
VkBool32 constantAlphaColorBlendFactors;
VkBool32 events;
VkBool32 imageViewFormatReinterpretation;
VkBool32 imageViewFormatSwizzle;
VkBool32 imageView2DOn3DImage;
VkBool32 multisampleArrayImage;
VkBool32 mutableComparisonSamplers;
VkBool32 pointPolygons;
VkBool32 samplerMipLodBias;
VkBool32 separateStencilMaskRef;
VkBool32 shaderSampleRateInterpolationFunctions;
VkBool32 tessellationIsolines;
VkBool32 tessellationPointMode;
VkBool32 triangleFans;
VkBool32 vertexAttributeAccessBeyondStride;
} VkPhysicalDevicePortabilitySubsetFeaturesKHR;
typedef struct VkPhysicalDevicePortabilitySubsetPropertiesKHR {
VkStructureType sType;
void* pNext;
uint32_t minVertexInputBindingStrideAlignment;
} VkPhysicalDevicePortabilitySubsetPropertiesKHR;
#define VK_KHR_video_encode_queue 1
#define VK_KHR_VIDEO_ENCODE_QUEUE_SPEC_VERSION 8
#define VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME "VK_KHR_video_encode_queue"
typedef enum VkVideoEncodeTuningModeKHR {
VK_VIDEO_ENCODE_TUNING_MODE_DEFAULT_KHR = 0,
VK_VIDEO_ENCODE_TUNING_MODE_HIGH_QUALITY_KHR = 1,
VK_VIDEO_ENCODE_TUNING_MODE_LOW_LATENCY_KHR = 2,
VK_VIDEO_ENCODE_TUNING_MODE_ULTRA_LOW_LATENCY_KHR = 3,
VK_VIDEO_ENCODE_TUNING_MODE_LOSSLESS_KHR = 4,
VK_VIDEO_ENCODE_TUNING_MODE_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeTuningModeKHR;
typedef VkFlags VkVideoEncodeFlagsKHR;
typedef enum VkVideoEncodeCapabilityFlagBitsKHR {
VK_VIDEO_ENCODE_CAPABILITY_PRECEDING_EXTERNALLY_ENCODED_BYTES_BIT_KHR = 0x00000001,
VK_VIDEO_ENCODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeCapabilityFlagBitsKHR;
typedef VkFlags VkVideoEncodeCapabilityFlagsKHR;
typedef enum VkVideoEncodeRateControlModeFlagBitsKHR {
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DEFAULT_KHR = 0,
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR = 0x00000001,
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR = 0x00000002,
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR = 0x00000004,
VK_VIDEO_ENCODE_RATE_CONTROL_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeRateControlModeFlagBitsKHR;
typedef VkFlags VkVideoEncodeRateControlModeFlagsKHR;
typedef enum VkVideoEncodeFeedbackFlagBitsKHR {
VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BUFFER_OFFSET_BIT_KHR = 0x00000001,
VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BYTES_WRITTEN_BIT_KHR = 0x00000002,
VK_VIDEO_ENCODE_FEEDBACK_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeFeedbackFlagBitsKHR;
typedef VkFlags VkVideoEncodeFeedbackFlagsKHR;
typedef enum VkVideoEncodeUsageFlagBitsKHR {
VK_VIDEO_ENCODE_USAGE_DEFAULT_KHR = 0,
VK_VIDEO_ENCODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001,
VK_VIDEO_ENCODE_USAGE_STREAMING_BIT_KHR = 0x00000002,
VK_VIDEO_ENCODE_USAGE_RECORDING_BIT_KHR = 0x00000004,
VK_VIDEO_ENCODE_USAGE_CONFERENCING_BIT_KHR = 0x00000008,
VK_VIDEO_ENCODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeUsageFlagBitsKHR;
typedef VkFlags VkVideoEncodeUsageFlagsKHR;
typedef enum VkVideoEncodeContentFlagBitsKHR {
VK_VIDEO_ENCODE_CONTENT_DEFAULT_KHR = 0,
VK_VIDEO_ENCODE_CONTENT_CAMERA_BIT_KHR = 0x00000001,
VK_VIDEO_ENCODE_CONTENT_DESKTOP_BIT_KHR = 0x00000002,
VK_VIDEO_ENCODE_CONTENT_RENDERED_BIT_KHR = 0x00000004,
VK_VIDEO_ENCODE_CONTENT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkVideoEncodeContentFlagBitsKHR;
typedef VkFlags VkVideoEncodeContentFlagsKHR;
typedef VkFlags VkVideoEncodeRateControlFlagsKHR;
typedef struct VkVideoEncodeInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoEncodeFlagsKHR flags;
uint32_t qualityLevel;
VkBuffer dstBuffer;
VkDeviceSize dstBufferOffset;
VkDeviceSize dstBufferRange;
VkVideoPictureResourceInfoKHR srcPictureResource;
const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot;
uint32_t referenceSlotCount;
const VkVideoReferenceSlotInfoKHR* pReferenceSlots;
uint32_t precedingExternallyEncodedBytes;
} VkVideoEncodeInfoKHR;
typedef struct VkVideoEncodeCapabilitiesKHR {
VkStructureType sType;
void* pNext;
VkVideoEncodeCapabilityFlagsKHR flags;
VkVideoEncodeRateControlModeFlagsKHR rateControlModes;
uint32_t maxRateControlLayers;
uint32_t maxQualityLevels;
VkExtent2D inputImageDataFillAlignment;
VkVideoEncodeFeedbackFlagsKHR supportedEncodeFeedbackFlags;
} VkVideoEncodeCapabilitiesKHR;
typedef struct VkQueryPoolVideoEncodeFeedbackCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoEncodeFeedbackFlagsKHR encodeFeedbackFlags;
} VkQueryPoolVideoEncodeFeedbackCreateInfoKHR;
typedef struct VkVideoEncodeUsageInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoEncodeUsageFlagsKHR videoUsageHints;
VkVideoEncodeContentFlagsKHR videoContentHints;
VkVideoEncodeTuningModeKHR tuningMode;
} VkVideoEncodeUsageInfoKHR;
typedef struct VkVideoEncodeRateControlLayerInfoKHR {
VkStructureType sType;
const void* pNext;
uint64_t averageBitrate;
uint64_t maxBitrate;
uint32_t frameRateNumerator;
uint32_t frameRateDenominator;
uint32_t virtualBufferSizeInMs;
uint32_t initialVirtualBufferSizeInMs;
} VkVideoEncodeRateControlLayerInfoKHR;
typedef struct VkVideoEncodeRateControlInfoKHR {
VkStructureType sType;
const void* pNext;
VkVideoEncodeRateControlFlagsKHR flags;
VkVideoEncodeRateControlModeFlagBitsKHR rateControlMode;
uint32_t layerCount;
const VkVideoEncodeRateControlLayerInfoKHR* pLayers;
} VkVideoEncodeRateControlInfoKHR;
typedef void (VKAPI_PTR *PFN_vkCmdEncodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoEncodeInfoKHR* pEncodeInfo);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR void VKAPI_CALL vkCmdEncodeVideoKHR(
VkCommandBuffer commandBuffer,
const VkVideoEncodeInfoKHR* pEncodeInfo);
#endif
#define VK_EXT_video_encode_h264 1
#include "vk_video/vulkan_video_codec_h264std.h"
#include "vk_video/vulkan_video_codec_h264std_encode.h"
#define VK_EXT_VIDEO_ENCODE_H264_SPEC_VERSION 10
#define VK_EXT_VIDEO_ENCODE_H264_EXTENSION_NAME "VK_EXT_video_encode_h264"
typedef enum VkVideoEncodeH264RateControlStructureEXT {
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_UNKNOWN_EXT = 0,
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_FLAT_EXT = 1,
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_DYADIC_EXT = 2,
VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH264RateControlStructureEXT;
typedef enum VkVideoEncodeH264CapabilityFlagBitsEXT {
VK_VIDEO_ENCODE_H264_CAPABILITY_DIRECT_8X8_INFERENCE_ENABLED_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H264_CAPABILITY_DIRECT_8X8_INFERENCE_DISABLED_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H264_CAPABILITY_SEPARATE_COLOUR_PLANE_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H264_CAPABILITY_QPPRIME_Y_ZERO_TRANSFORM_BYPASS_BIT_EXT = 0x00000008,
VK_VIDEO_ENCODE_H264_CAPABILITY_SCALING_LISTS_BIT_EXT = 0x00000010,
VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_EXT = 0x00000020,
VK_VIDEO_ENCODE_H264_CAPABILITY_CHROMA_QP_OFFSET_BIT_EXT = 0x00000040,
VK_VIDEO_ENCODE_H264_CAPABILITY_SECOND_CHROMA_QP_OFFSET_BIT_EXT = 0x00000080,
VK_VIDEO_ENCODE_H264_CAPABILITY_PIC_INIT_QP_MINUS26_BIT_EXT = 0x00000100,
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_PRED_BIT_EXT = 0x00000200,
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BIPRED_EXPLICIT_BIT_EXT = 0x00000400,
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BIPRED_IMPLICIT_BIT_EXT = 0x00000800,
VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_PRED_NO_TABLE_BIT_EXT = 0x00001000,
VK_VIDEO_ENCODE_H264_CAPABILITY_TRANSFORM_8X8_BIT_EXT = 0x00002000,
VK_VIDEO_ENCODE_H264_CAPABILITY_CABAC_BIT_EXT = 0x00004000,
VK_VIDEO_ENCODE_H264_CAPABILITY_CAVLC_BIT_EXT = 0x00008000,
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_DISABLED_BIT_EXT = 0x00010000,
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_ENABLED_BIT_EXT = 0x00020000,
VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_PARTIAL_BIT_EXT = 0x00040000,
VK_VIDEO_ENCODE_H264_CAPABILITY_DISABLE_DIRECT_SPATIAL_MV_PRED_BIT_EXT = 0x00080000,
VK_VIDEO_ENCODE_H264_CAPABILITY_MULTIPLE_SLICE_PER_FRAME_BIT_EXT = 0x00100000,
VK_VIDEO_ENCODE_H264_CAPABILITY_SLICE_MB_COUNT_BIT_EXT = 0x00200000,
VK_VIDEO_ENCODE_H264_CAPABILITY_ROW_UNALIGNED_SLICE_BIT_EXT = 0x00400000,
VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_EXT = 0x00800000,
VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_EXT = 0x01000000,
VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_REFERENCE_FINAL_LISTS_BIT_EXT = 0x02000000,
VK_VIDEO_ENCODE_H264_CAPABILITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH264CapabilityFlagBitsEXT;
typedef VkFlags VkVideoEncodeH264CapabilityFlagsEXT;
typedef struct VkVideoEncodeH264CapabilitiesEXT {
VkStructureType sType;
void* pNext;
VkVideoEncodeH264CapabilityFlagsEXT flags;
uint32_t maxPPictureL0ReferenceCount;
uint32_t maxBPictureL0ReferenceCount;
uint32_t maxL1ReferenceCount;
VkBool32 motionVectorsOverPicBoundariesFlag;
uint32_t maxBytesPerPicDenom;
uint32_t maxBitsPerMbDenom;
uint32_t log2MaxMvLengthHorizontal;
uint32_t log2MaxMvLengthVertical;
} VkVideoEncodeH264CapabilitiesEXT;
typedef struct VkVideoEncodeH264SessionParametersAddInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t stdSPSCount;
const StdVideoH264SequenceParameterSet* pStdSPSs;
uint32_t stdPPSCount;
const StdVideoH264PictureParameterSet* pStdPPSs;
} VkVideoEncodeH264SessionParametersAddInfoEXT;
typedef struct VkVideoEncodeH264SessionParametersCreateInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t maxStdSPSCount;
uint32_t maxStdPPSCount;
const VkVideoEncodeH264SessionParametersAddInfoEXT* pParametersAddInfo;
} VkVideoEncodeH264SessionParametersCreateInfoEXT;
typedef struct VkVideoEncodeH264NaluSliceInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t mbCount;
const StdVideoEncodeH264ReferenceListsInfo* pStdReferenceFinalLists;
const StdVideoEncodeH264SliceHeader* pStdSliceHeader;
} VkVideoEncodeH264NaluSliceInfoEXT;
typedef struct VkVideoEncodeH264VclFrameInfoEXT {
VkStructureType sType;
const void* pNext;
const StdVideoEncodeH264ReferenceListsInfo* pStdReferenceFinalLists;
uint32_t naluSliceEntryCount;
const VkVideoEncodeH264NaluSliceInfoEXT* pNaluSliceEntries;
const StdVideoEncodeH264PictureInfo* pStdPictureInfo;
} VkVideoEncodeH264VclFrameInfoEXT;
typedef struct VkVideoEncodeH264DpbSlotInfoEXT {
VkStructureType sType;
const void* pNext;
const StdVideoEncodeH264ReferenceInfo* pStdReferenceInfo;
} VkVideoEncodeH264DpbSlotInfoEXT;
typedef struct VkVideoEncodeH264ProfileInfoEXT {
VkStructureType sType;
const void* pNext;
StdVideoH264ProfileIdc stdProfileIdc;
} VkVideoEncodeH264ProfileInfoEXT;
typedef struct VkVideoEncodeH264RateControlInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t gopFrameCount;
uint32_t idrPeriod;
uint32_t consecutiveBFrameCount;
VkVideoEncodeH264RateControlStructureEXT rateControlStructure;
uint32_t temporalLayerCount;
} VkVideoEncodeH264RateControlInfoEXT;
typedef struct VkVideoEncodeH264QpEXT {
int32_t qpI;
int32_t qpP;
int32_t qpB;
} VkVideoEncodeH264QpEXT;
typedef struct VkVideoEncodeH264FrameSizeEXT {
uint32_t frameISize;
uint32_t framePSize;
uint32_t frameBSize;
} VkVideoEncodeH264FrameSizeEXT;
typedef struct VkVideoEncodeH264RateControlLayerInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t temporalLayerId;
VkBool32 useInitialRcQp;
VkVideoEncodeH264QpEXT initialRcQp;
VkBool32 useMinQp;
VkVideoEncodeH264QpEXT minQp;
VkBool32 useMaxQp;
VkVideoEncodeH264QpEXT maxQp;
VkBool32 useMaxFrameSize;
VkVideoEncodeH264FrameSizeEXT maxFrameSize;
} VkVideoEncodeH264RateControlLayerInfoEXT;
#define VK_EXT_video_encode_h265 1
#include "vk_video/vulkan_video_codec_h265std.h"
#include "vk_video/vulkan_video_codec_h265std_encode.h"
#define VK_EXT_VIDEO_ENCODE_H265_SPEC_VERSION 10
#define VK_EXT_VIDEO_ENCODE_H265_EXTENSION_NAME "VK_EXT_video_encode_h265"
typedef enum VkVideoEncodeH265RateControlStructureEXT {
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_UNKNOWN_EXT = 0,
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_FLAT_EXT = 1,
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_DYADIC_EXT = 2,
VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH265RateControlStructureEXT;
typedef enum VkVideoEncodeH265CapabilityFlagBitsEXT {
VK_VIDEO_ENCODE_H265_CAPABILITY_SEPARATE_COLOUR_PLANE_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H265_CAPABILITY_SCALING_LISTS_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H265_CAPABILITY_SAMPLE_ADAPTIVE_OFFSET_ENABLED_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H265_CAPABILITY_PCM_ENABLE_BIT_EXT = 0x00000008,
VK_VIDEO_ENCODE_H265_CAPABILITY_SPS_TEMPORAL_MVP_ENABLED_BIT_EXT = 0x00000010,
VK_VIDEO_ENCODE_H265_CAPABILITY_HRD_COMPLIANCE_BIT_EXT = 0x00000020,
VK_VIDEO_ENCODE_H265_CAPABILITY_INIT_QP_MINUS26_BIT_EXT = 0x00000040,
VK_VIDEO_ENCODE_H265_CAPABILITY_LOG2_PARALLEL_MERGE_LEVEL_MINUS2_BIT_EXT = 0x00000080,
VK_VIDEO_ENCODE_H265_CAPABILITY_SIGN_DATA_HIDING_ENABLED_BIT_EXT = 0x00000100,
VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSFORM_SKIP_ENABLED_BIT_EXT = 0x00000200,
VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSFORM_SKIP_DISABLED_BIT_EXT = 0x00000400,
VK_VIDEO_ENCODE_H265_CAPABILITY_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT_BIT_EXT = 0x00000800,
VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_PRED_BIT_EXT = 0x00001000,
VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_BIPRED_BIT_EXT = 0x00002000,
VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_PRED_NO_TABLE_BIT_EXT = 0x00004000,
VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSQUANT_BYPASS_ENABLED_BIT_EXT = 0x00008000,
VK_VIDEO_ENCODE_H265_CAPABILITY_ENTROPY_CODING_SYNC_ENABLED_BIT_EXT = 0x00010000,
VK_VIDEO_ENCODE_H265_CAPABILITY_DEBLOCKING_FILTER_OVERRIDE_ENABLED_BIT_EXT = 0x00020000,
VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILE_PER_FRAME_BIT_EXT = 0x00040000,
VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_SLICE_PER_TILE_BIT_EXT = 0x00080000,
VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILE_PER_SLICE_BIT_EXT = 0x00100000,
VK_VIDEO_ENCODE_H265_CAPABILITY_SLICE_SEGMENT_CTB_COUNT_BIT_EXT = 0x00200000,
VK_VIDEO_ENCODE_H265_CAPABILITY_ROW_UNALIGNED_SLICE_SEGMENT_BIT_EXT = 0x00400000,
VK_VIDEO_ENCODE_H265_CAPABILITY_DEPENDENT_SLICE_SEGMENT_BIT_EXT = 0x00800000,
VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_EXT = 0x01000000,
VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_EXT = 0x02000000,
VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_REFERENCE_FINAL_LISTS_BIT_EXT = 0x04000000,
VK_VIDEO_ENCODE_H265_CAPABILITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH265CapabilityFlagBitsEXT;
typedef VkFlags VkVideoEncodeH265CapabilityFlagsEXT;
typedef enum VkVideoEncodeH265CtbSizeFlagBitsEXT {
VK_VIDEO_ENCODE_H265_CTB_SIZE_16_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H265_CTB_SIZE_32_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H265_CTB_SIZE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH265CtbSizeFlagBitsEXT;
typedef VkFlags VkVideoEncodeH265CtbSizeFlagsEXT;
typedef enum VkVideoEncodeH265TransformBlockSizeFlagBitsEXT {
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_4_BIT_EXT = 0x00000001,
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_8_BIT_EXT = 0x00000002,
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_16_BIT_EXT = 0x00000004,
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_32_BIT_EXT = 0x00000008,
VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkVideoEncodeH265TransformBlockSizeFlagBitsEXT;
typedef VkFlags VkVideoEncodeH265TransformBlockSizeFlagsEXT;
typedef struct VkVideoEncodeH265CapabilitiesEXT {
VkStructureType sType;
void* pNext;
VkVideoEncodeH265CapabilityFlagsEXT flags;
VkVideoEncodeH265CtbSizeFlagsEXT ctbSizes;
VkVideoEncodeH265TransformBlockSizeFlagsEXT transformBlockSizes;
uint32_t maxPPictureL0ReferenceCount;
uint32_t maxBPictureL0ReferenceCount;
uint32_t maxL1ReferenceCount;
uint32_t maxSubLayersCount;
uint32_t minLog2MinLumaCodingBlockSizeMinus3;
uint32_t maxLog2MinLumaCodingBlockSizeMinus3;
uint32_t minLog2MinLumaTransformBlockSizeMinus2;
uint32_t maxLog2MinLumaTransformBlockSizeMinus2;
uint32_t minMaxTransformHierarchyDepthInter;
uint32_t maxMaxTransformHierarchyDepthInter;
uint32_t minMaxTransformHierarchyDepthIntra;
uint32_t maxMaxTransformHierarchyDepthIntra;
uint32_t maxDiffCuQpDeltaDepth;
uint32_t minMaxNumMergeCand;
uint32_t maxMaxNumMergeCand;
} VkVideoEncodeH265CapabilitiesEXT;
typedef struct VkVideoEncodeH265SessionParametersAddInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t stdVPSCount;
const StdVideoH265VideoParameterSet* pStdVPSs;
uint32_t stdSPSCount;
const StdVideoH265SequenceParameterSet* pStdSPSs;
uint32_t stdPPSCount;
const StdVideoH265PictureParameterSet* pStdPPSs;
} VkVideoEncodeH265SessionParametersAddInfoEXT;
typedef struct VkVideoEncodeH265SessionParametersCreateInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t maxStdVPSCount;
uint32_t maxStdSPSCount;
uint32_t maxStdPPSCount;
const VkVideoEncodeH265SessionParametersAddInfoEXT* pParametersAddInfo;
} VkVideoEncodeH265SessionParametersCreateInfoEXT;
typedef struct VkVideoEncodeH265NaluSliceSegmentInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t ctbCount;
const StdVideoEncodeH265ReferenceListsInfo* pStdReferenceFinalLists;
const StdVideoEncodeH265SliceSegmentHeader* pStdSliceSegmentHeader;
} VkVideoEncodeH265NaluSliceSegmentInfoEXT;
typedef struct VkVideoEncodeH265VclFrameInfoEXT {
VkStructureType sType;
const void* pNext;
const StdVideoEncodeH265ReferenceListsInfo* pStdReferenceFinalLists;
uint32_t naluSliceSegmentEntryCount;
const VkVideoEncodeH265NaluSliceSegmentInfoEXT* pNaluSliceSegmentEntries;
const StdVideoEncodeH265PictureInfo* pStdPictureInfo;
} VkVideoEncodeH265VclFrameInfoEXT;
typedef struct VkVideoEncodeH265DpbSlotInfoEXT {
VkStructureType sType;
const void* pNext;
const StdVideoEncodeH265ReferenceInfo* pStdReferenceInfo;
} VkVideoEncodeH265DpbSlotInfoEXT;
typedef struct VkVideoEncodeH265ProfileInfoEXT {
VkStructureType sType;
const void* pNext;
StdVideoH265ProfileIdc stdProfileIdc;
} VkVideoEncodeH265ProfileInfoEXT;
typedef struct VkVideoEncodeH265RateControlInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t gopFrameCount;
uint32_t idrPeriod;
uint32_t consecutiveBFrameCount;
VkVideoEncodeH265RateControlStructureEXT rateControlStructure;
uint32_t subLayerCount;
} VkVideoEncodeH265RateControlInfoEXT;
typedef struct VkVideoEncodeH265QpEXT {
int32_t qpI;
int32_t qpP;
int32_t qpB;
} VkVideoEncodeH265QpEXT;
typedef struct VkVideoEncodeH265FrameSizeEXT {
uint32_t frameISize;
uint32_t framePSize;
uint32_t frameBSize;
} VkVideoEncodeH265FrameSizeEXT;
typedef struct VkVideoEncodeH265RateControlLayerInfoEXT {
VkStructureType sType;
const void* pNext;
uint32_t temporalId;
VkBool32 useInitialRcQp;
VkVideoEncodeH265QpEXT initialRcQp;
VkBool32 useMinQp;
VkVideoEncodeH265QpEXT minQp;
VkBool32 useMaxQp;
VkVideoEncodeH265QpEXT maxQp;
VkBool32 useMaxFrameSize;
VkVideoEncodeH265FrameSizeEXT maxFrameSize;
} VkVideoEncodeH265RateControlLayerInfoEXT;
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,54 @@
#ifndef VULKAN_DIRECTFB_H_
#define VULKAN_DIRECTFB_H_ 1
/*
** Copyright 2015-2023 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_EXT_directfb_surface 1
#define VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION 1
#define VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "VK_EXT_directfb_surface"
typedef VkFlags VkDirectFBSurfaceCreateFlagsEXT;
typedef struct VkDirectFBSurfaceCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkDirectFBSurfaceCreateFlagsEXT flags;
IDirectFB* dfb;
IDirectFBSurface* surface;
} VkDirectFBSurfaceCreateInfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkCreateDirectFBSurfaceEXT)(VkInstance instance, const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, IDirectFB* dfb);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT(
VkInstance instance,
const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
IDirectFB* dfb);
#endif
#ifdef __cplusplus
}
#endif
#endif

@ -1,24 +1,10 @@
#ifndef VULKAN_FUCHSIA_H_
#define VULKAN_FUCHSIA_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_FUCHSIA_imagepipe_surface 1
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1
#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface"
typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA;
typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
@ -40,7 +30,6 @@ typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA {
zx_handle_t imagePipeHandle;
} VkImagePipeSurfaceCreateInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
@ -51,6 +40,217 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA(
VkSurfaceKHR* pSurface);
#endif
#define VK_FUCHSIA_external_memory 1
#define VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION 1
#define VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME "VK_FUCHSIA_external_memory"
typedef struct VkImportMemoryZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkExternalMemoryHandleTypeFlagBits handleType;
zx_handle_t handle;
} VkImportMemoryZirconHandleInfoFUCHSIA;
typedef struct VkMemoryZirconHandlePropertiesFUCHSIA {
VkStructureType sType;
void* pNext;
uint32_t memoryTypeBits;
} VkMemoryZirconHandlePropertiesFUCHSIA;
typedef struct VkMemoryGetZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkDeviceMemory memory;
VkExternalMemoryHandleTypeFlagBits handleType;
} VkMemoryGetZirconHandleInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandleFUCHSIA)(VkDevice device, const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle);
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, zx_handle_t zirconHandle, VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandleFUCHSIA(
VkDevice device,
const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo,
zx_handle_t* pZirconHandle);
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA(
VkDevice device,
VkExternalMemoryHandleTypeFlagBits handleType,
zx_handle_t zirconHandle,
VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties);
#endif
#define VK_FUCHSIA_external_semaphore 1
#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION 1
#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_FUCHSIA_external_semaphore"
typedef struct VkImportSemaphoreZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkSemaphoreImportFlags flags;
VkExternalSemaphoreHandleTypeFlagBits handleType;
zx_handle_t zirconHandle;
} VkImportSemaphoreZirconHandleInfoFUCHSIA;
typedef struct VkSemaphoreGetZirconHandleInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkExternalSemaphoreHandleTypeFlagBits handleType;
} VkSemaphoreGetZirconHandleInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreZirconHandleFUCHSIA(
VkDevice device,
const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreZirconHandleFUCHSIA(
VkDevice device,
const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo,
zx_handle_t* pZirconHandle);
#endif
#define VK_FUCHSIA_buffer_collection 1
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferCollectionFUCHSIA)
#define VK_FUCHSIA_BUFFER_COLLECTION_SPEC_VERSION 2
#define VK_FUCHSIA_BUFFER_COLLECTION_EXTENSION_NAME "VK_FUCHSIA_buffer_collection"
typedef VkFlags VkImageFormatConstraintsFlagsFUCHSIA;
typedef enum VkImageConstraintsInfoFlagBitsFUCHSIA {
VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_RARELY_FUCHSIA = 0x00000001,
VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_OFTEN_FUCHSIA = 0x00000002,
VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_RARELY_FUCHSIA = 0x00000004,
VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_OFTEN_FUCHSIA = 0x00000008,
VK_IMAGE_CONSTRAINTS_INFO_PROTECTED_OPTIONAL_FUCHSIA = 0x00000010,
VK_IMAGE_CONSTRAINTS_INFO_FLAG_BITS_MAX_ENUM_FUCHSIA = 0x7FFFFFFF
} VkImageConstraintsInfoFlagBitsFUCHSIA;
typedef VkFlags VkImageConstraintsInfoFlagsFUCHSIA;
typedef struct VkBufferCollectionCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
zx_handle_t collectionToken;
} VkBufferCollectionCreateInfoFUCHSIA;
typedef struct VkImportMemoryBufferCollectionFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCollectionFUCHSIA collection;
uint32_t index;
} VkImportMemoryBufferCollectionFUCHSIA;
typedef struct VkBufferCollectionImageCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCollectionFUCHSIA collection;
uint32_t index;
} VkBufferCollectionImageCreateInfoFUCHSIA;
typedef struct VkBufferCollectionConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
uint32_t minBufferCount;
uint32_t maxBufferCount;
uint32_t minBufferCountForCamping;
uint32_t minBufferCountForDedicatedSlack;
uint32_t minBufferCountForSharedSlack;
} VkBufferCollectionConstraintsInfoFUCHSIA;
typedef struct VkBufferConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCreateInfo createInfo;
VkFormatFeatureFlags requiredFormatFeatures;
VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints;
} VkBufferConstraintsInfoFUCHSIA;
typedef struct VkBufferCollectionBufferCreateInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkBufferCollectionFUCHSIA collection;
uint32_t index;
} VkBufferCollectionBufferCreateInfoFUCHSIA;
typedef struct VkSysmemColorSpaceFUCHSIA {
VkStructureType sType;
const void* pNext;
uint32_t colorSpace;
} VkSysmemColorSpaceFUCHSIA;
typedef struct VkBufferCollectionPropertiesFUCHSIA {
VkStructureType sType;
void* pNext;
uint32_t memoryTypeBits;
uint32_t bufferCount;
uint32_t createInfoIndex;
uint64_t sysmemPixelFormat;
VkFormatFeatureFlags formatFeatures;
VkSysmemColorSpaceFUCHSIA sysmemColorSpaceIndex;
VkComponentMapping samplerYcbcrConversionComponents;
VkSamplerYcbcrModelConversion suggestedYcbcrModel;
VkSamplerYcbcrRange suggestedYcbcrRange;
VkChromaLocation suggestedXChromaOffset;
VkChromaLocation suggestedYChromaOffset;
} VkBufferCollectionPropertiesFUCHSIA;
typedef struct VkImageFormatConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
VkImageCreateInfo imageCreateInfo;
VkFormatFeatureFlags requiredFormatFeatures;
VkImageFormatConstraintsFlagsFUCHSIA flags;
uint64_t sysmemPixelFormat;
uint32_t colorSpaceCount;
const VkSysmemColorSpaceFUCHSIA* pColorSpaces;
} VkImageFormatConstraintsInfoFUCHSIA;
typedef struct VkImageConstraintsInfoFUCHSIA {
VkStructureType sType;
const void* pNext;
uint32_t formatConstraintsCount;
const VkImageFormatConstraintsInfoFUCHSIA* pFormatConstraints;
VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints;
VkImageConstraintsInfoFlagsFUCHSIA flags;
} VkImageConstraintsInfoFUCHSIA;
typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferCollectionFUCHSIA)(VkDevice device, const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferCollectionFUCHSIA* pCollection);
typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionImageConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo);
typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo);
typedef void (VKAPI_PTR *PFN_vkDestroyBufferCollectionFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkGetBufferCollectionPropertiesFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, VkBufferCollectionPropertiesFUCHSIA* pProperties);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferCollectionFUCHSIA(
VkDevice device,
const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkBufferCollectionFUCHSIA* pCollection);
VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionImageConstraintsFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionBufferConstraintsFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo);
VKAPI_ATTR void VKAPI_CALL vkDestroyBufferCollectionFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkGetBufferCollectionPropertiesFUCHSIA(
VkDevice device,
VkBufferCollectionFUCHSIA collection,
VkBufferCollectionPropertiesFUCHSIA* pProperties);
#endif
#ifdef __cplusplus
}
#endif

@ -0,0 +1,58 @@
#ifndef VULKAN_GGP_H_
#define VULKAN_GGP_H_ 1
/*
** Copyright 2015-2023 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_GGP_stream_descriptor_surface 1
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1
#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface"
typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP;
typedef struct VkStreamDescriptorSurfaceCreateInfoGGP {
VkStructureType sType;
const void* pNext;
VkStreamDescriptorSurfaceCreateFlagsGGP flags;
GgpStreamDescriptor streamDescriptor;
} VkStreamDescriptorSurfaceCreateInfoGGP;
typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP(
VkInstance instance,
const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#define VK_GGP_frame_token 1
#define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1
#define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token"
typedef struct VkPresentFrameTokenGGP {
VkStructureType sType;
const void* pNext;
GgpFrameToken frameToken;
} VkPresentFrameTokenGGP;
#ifdef __cplusplus
}
#endif
#endif

@ -1,24 +1,10 @@
#ifndef VULKAN_IOS_H_
#define VULKAN_IOS_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_MVK_ios_surface 1
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 2
#define VK_MVK_IOS_SURFACE_SPEC_VERSION 3
#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface"
typedef VkFlags VkIOSSurfaceCreateFlagsMVK;
typedef struct VkIOSSurfaceCreateInfoMVK {
VkStructureType sType;
const void* pNext;
@ -40,7 +30,6 @@ typedef struct VkIOSSurfaceCreateInfoMVK {
const void* pView;
} VkIOSSurfaceCreateInfoMVK;
typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES

@ -1,24 +1,10 @@
#ifndef VULKAN_MACOS_H_
#define VULKAN_MACOS_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_MVK_macos_surface 1
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 2
#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 3
#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface"
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
typedef struct VkMacOSSurfaceCreateInfoMVK {
VkStructureType sType;
const void* pNext;
@ -40,7 +30,6 @@ typedef struct VkMacOSSurfaceCreateInfoMVK {
const void* pView;
} VkMacOSSurfaceCreateInfoMVK;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES

@ -0,0 +1,193 @@
#ifndef VULKAN_METAL_H_
#define VULKAN_METAL_H_ 1
/*
** Copyright 2015-2023 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_EXT_metal_surface 1
#ifdef __OBJC__
@class CAMetalLayer;
#else
typedef void CAMetalLayer;
#endif
#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
typedef struct VkMetalSurfaceCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkMetalSurfaceCreateFlagsEXT flags;
const CAMetalLayer* pLayer;
} VkMetalSurfaceCreateInfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(
VkInstance instance,
const VkMetalSurfaceCreateInfoEXT* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
#endif
#define VK_EXT_metal_objects 1
#ifdef __OBJC__
@protocol MTLDevice;
typedef id<MTLDevice> MTLDevice_id;
#else
typedef void* MTLDevice_id;
#endif
#ifdef __OBJC__
@protocol MTLCommandQueue;
typedef id<MTLCommandQueue> MTLCommandQueue_id;
#else
typedef void* MTLCommandQueue_id;
#endif
#ifdef __OBJC__
@protocol MTLBuffer;
typedef id<MTLBuffer> MTLBuffer_id;
#else
typedef void* MTLBuffer_id;
#endif
#ifdef __OBJC__
@protocol MTLTexture;
typedef id<MTLTexture> MTLTexture_id;
#else
typedef void* MTLTexture_id;
#endif
typedef struct __IOSurface* IOSurfaceRef;
#ifdef __OBJC__
@protocol MTLSharedEvent;
typedef id<MTLSharedEvent> MTLSharedEvent_id;
#else
typedef void* MTLSharedEvent_id;
#endif
#define VK_EXT_METAL_OBJECTS_SPEC_VERSION 1
#define VK_EXT_METAL_OBJECTS_EXTENSION_NAME "VK_EXT_metal_objects"
typedef enum VkExportMetalObjectTypeFlagBitsEXT {
VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT = 0x00000001,
VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT = 0x00000002,
VK_EXPORT_METAL_OBJECT_TYPE_METAL_BUFFER_BIT_EXT = 0x00000004,
VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT = 0x00000008,
VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT = 0x00000010,
VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT = 0x00000020,
VK_EXPORT_METAL_OBJECT_TYPE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkExportMetalObjectTypeFlagBitsEXT;
typedef VkFlags VkExportMetalObjectTypeFlagsEXT;
typedef struct VkExportMetalObjectCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkExportMetalObjectTypeFlagBitsEXT exportObjectType;
} VkExportMetalObjectCreateInfoEXT;
typedef struct VkExportMetalObjectsInfoEXT {
VkStructureType sType;
const void* pNext;
} VkExportMetalObjectsInfoEXT;
typedef struct VkExportMetalDeviceInfoEXT {
VkStructureType sType;
const void* pNext;
MTLDevice_id mtlDevice;
} VkExportMetalDeviceInfoEXT;
typedef struct VkExportMetalCommandQueueInfoEXT {
VkStructureType sType;
const void* pNext;
VkQueue queue;
MTLCommandQueue_id mtlCommandQueue;
} VkExportMetalCommandQueueInfoEXT;
typedef struct VkExportMetalBufferInfoEXT {
VkStructureType sType;
const void* pNext;
VkDeviceMemory memory;
MTLBuffer_id mtlBuffer;
} VkExportMetalBufferInfoEXT;
typedef struct VkImportMetalBufferInfoEXT {
VkStructureType sType;
const void* pNext;
MTLBuffer_id mtlBuffer;
} VkImportMetalBufferInfoEXT;
typedef struct VkExportMetalTextureInfoEXT {
VkStructureType sType;
const void* pNext;
VkImage image;
VkImageView imageView;
VkBufferView bufferView;
VkImageAspectFlagBits plane;
MTLTexture_id mtlTexture;
} VkExportMetalTextureInfoEXT;
typedef struct VkImportMetalTextureInfoEXT {
VkStructureType sType;
const void* pNext;
VkImageAspectFlagBits plane;
MTLTexture_id mtlTexture;
} VkImportMetalTextureInfoEXT;
typedef struct VkExportMetalIOSurfaceInfoEXT {
VkStructureType sType;
const void* pNext;
VkImage image;
IOSurfaceRef ioSurface;
} VkExportMetalIOSurfaceInfoEXT;
typedef struct VkImportMetalIOSurfaceInfoEXT {
VkStructureType sType;
const void* pNext;
IOSurfaceRef ioSurface;
} VkImportMetalIOSurfaceInfoEXT;
typedef struct VkExportMetalSharedEventInfoEXT {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkEvent event;
MTLSharedEvent_id mtlSharedEvent;
} VkExportMetalSharedEventInfoEXT;
typedef struct VkImportMetalSharedEventInfoEXT {
VkStructureType sType;
const void* pNext;
MTLSharedEvent_id mtlSharedEvent;
} VkImportMetalSharedEventInfoEXT;
typedef void (VKAPI_PTR *PFN_vkExportMetalObjectsEXT)(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR void VKAPI_CALL vkExportMetalObjectsEXT(
VkDevice device,
VkExportMetalObjectsInfoEXT* pMetalObjectsInfo);
#endif
#ifdef __cplusplus
}
#endif
#endif

@ -1,65 +0,0 @@
#ifndef VULKAN_MIR_H_
#define VULKAN_MIR_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#define VK_KHR_mir_surface 1
#define VK_KHR_MIR_SURFACE_SPEC_VERSION 4
#define VK_KHR_MIR_SURFACE_EXTENSION_NAME "VK_KHR_mir_surface"
typedef VkFlags VkMirSurfaceCreateFlagsKHR;
typedef struct VkMirSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkMirSurfaceCreateFlagsKHR flags;
MirConnection* connection;
MirSurface* mirSurface;
} VkMirSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMirSurfaceKHR)(VkInstance instance, const VkMirSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection* connection);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
VkInstance instance,
const VkMirSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
MirConnection* connection);
#endif
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,54 @@
#ifndef VULKAN_SCREEN_H_
#define VULKAN_SCREEN_H_ 1
/*
** Copyright 2015-2023 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_QNX_screen_surface 1
#define VK_QNX_SCREEN_SURFACE_SPEC_VERSION 1
#define VK_QNX_SCREEN_SURFACE_EXTENSION_NAME "VK_QNX_screen_surface"
typedef VkFlags VkScreenSurfaceCreateFlagsQNX;
typedef struct VkScreenSurfaceCreateInfoQNX {
VkStructureType sType;
const void* pNext;
VkScreenSurfaceCreateFlagsQNX flags;
struct _screen_context* context;
struct _screen_window* window;
} VkScreenSurfaceCreateInfoQNX;
typedef VkResult (VKAPI_PTR *PFN_vkCreateScreenSurfaceQNX)(VkInstance instance, const VkScreenSurfaceCreateInfoQNX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct _screen_window* window);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateScreenSurfaceQNX(
VkInstance instance,
const VkScreenSurfaceCreateInfoQNX* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceScreenPresentationSupportQNX(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
struct _screen_window* window);
#endif
#ifdef __cplusplus
}
#endif
#endif

@ -1,24 +1,10 @@
#ifndef VULKAN_VI_H_
#define VULKAN_VI_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_NN_vi_surface 1
#define VK_NN_VI_SURFACE_SPEC_VERSION 1
#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface"
typedef VkFlags VkViSurfaceCreateFlagsNN;
typedef struct VkViSurfaceCreateInfoNN {
VkStructureType sType;
const void* pNext;
@ -40,7 +30,6 @@ typedef struct VkViSurfaceCreateInfoNN {
void* window;
} VkViSurfaceCreateInfoNN;
typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
#ifndef VK_NO_PROTOTYPES

@ -1,24 +1,10 @@
#ifndef VULKAN_WAYLAND_H_
#define VULKAN_WAYLAND_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_wayland_surface 1
#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6
#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface"
typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
typedef struct VkWaylandSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
@ -41,7 +31,6 @@ typedef struct VkWaylandSurfaceCreateInfoKHR {
struct wl_surface* surface;
} VkWaylandSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display);

@ -1,24 +1,10 @@
#ifndef VULKAN_WIN32_H_
#define VULKAN_WIN32_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_win32_surface 1
#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6
#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface"
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
typedef struct VkWin32SurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
@ -41,7 +31,6 @@ typedef struct VkWin32SurfaceCreateInfoKHR {
HWND hwnd;
} VkWin32SurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
@ -57,10 +46,10 @@ VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
uint32_t queueFamilyIndex);
#endif
#define VK_KHR_external_memory_win32 1
#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32"
typedef struct VkImportMemoryWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
@ -90,7 +79,6 @@ typedef struct VkMemoryGetWin32HandleInfoKHR {
VkExternalMemoryHandleTypeFlagBits handleType;
} VkMemoryGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
@ -107,10 +95,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR(
VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
#endif
#define VK_KHR_win32_keyed_mutex 1
#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1
#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex"
typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
VkStructureType sType;
const void* pNext;
@ -128,7 +116,6 @@ typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
#define VK_KHR_external_semaphore_win32 1
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32"
typedef struct VkImportSemaphoreWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
@ -163,7 +150,6 @@ typedef struct VkSemaphoreGetWin32HandleInfoKHR {
VkExternalSemaphoreHandleTypeFlagBits handleType;
} VkSemaphoreGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
@ -178,10 +164,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR(
HANDLE* pHandle);
#endif
#define VK_KHR_external_fence_win32 1
#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32"
typedef struct VkImportFenceWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
@ -207,7 +193,6 @@ typedef struct VkFenceGetWin32HandleInfoKHR {
VkExternalFenceHandleTypeFlagBits handleType;
} VkFenceGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
@ -222,10 +207,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR(
HANDLE* pHandle);
#endif
#define VK_NV_external_memory_win32 1
#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32"
typedef struct VkImportMemoryWin32HandleInfoNV {
VkStructureType sType;
const void* pNext;
@ -240,7 +225,6 @@ typedef struct VkExportMemoryWin32HandleInfoNV {
DWORD dwAccess;
} VkExportMemoryWin32HandleInfoNV;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle);
#ifndef VK_NO_PROTOTYPES
@ -251,10 +235,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
HANDLE* pHandle);
#endif
#define VK_NV_win32_keyed_mutex 1
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 1
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
VkStructureType sType;
const void* pNext;
@ -269,6 +253,79 @@ typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
#define VK_EXT_full_screen_exclusive 1
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive"
typedef enum VkFullScreenExclusiveEXT {
VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0,
VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1,
VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2,
VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3,
VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF
} VkFullScreenExclusiveEXT;
typedef struct VkSurfaceFullScreenExclusiveInfoEXT {
VkStructureType sType;
void* pNext;
VkFullScreenExclusiveEXT fullScreenExclusive;
} VkSurfaceFullScreenExclusiveInfoEXT;
typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT {
VkStructureType sType;
void* pNext;
VkBool32 fullScreenExclusiveSupported;
} VkSurfaceCapabilitiesFullScreenExclusiveEXT;
typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT {
VkStructureType sType;
const void* pNext;
HMONITOR hmonitor;
} VkSurfaceFullScreenExclusiveWin32InfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
uint32_t* pPresentModeCount,
VkPresentModeKHR* pPresentModes);
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT(
VkDevice device,
VkSwapchainKHR swapchain);
VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT(
VkDevice device,
VkSwapchainKHR swapchain);
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT(
VkDevice device,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
VkDeviceGroupPresentModeFlagsKHR* pModes);
#endif
#define VK_NV_acquire_winrt_display 1
#define VK_NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION 1
#define VK_NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME "VK_NV_acquire_winrt_display"
typedef VkResult (VKAPI_PTR *PFN_vkAcquireWinrtDisplayNV)(VkPhysicalDevice physicalDevice, VkDisplayKHR display);
typedef VkResult (VKAPI_PTR *PFN_vkGetWinrtDisplayNV)(VkPhysicalDevice physicalDevice, uint32_t deviceRelativeId, VkDisplayKHR* pDisplay);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireWinrtDisplayNV(
VkPhysicalDevice physicalDevice,
VkDisplayKHR display);
VKAPI_ATTR VkResult VKAPI_CALL vkGetWinrtDisplayNV(
VkPhysicalDevice physicalDevice,
uint32_t deviceRelativeId,
VkDisplayKHR* pDisplay);
#endif
#ifdef __cplusplus
}
#endif

@ -1,24 +1,10 @@
#ifndef VULKAN_XCB_H_
#define VULKAN_XCB_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_xcb_surface 1
#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6
#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface"
typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
typedef struct VkXcbSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
@ -41,7 +31,6 @@ typedef struct VkXcbSurfaceCreateInfoKHR {
xcb_window_t window;
} VkXcbSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id);

@ -1,24 +1,10 @@
#ifndef VULKAN_XLIB_H_
#define VULKAN_XLIB_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,12 +13,16 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_xlib_surface 1
#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6
#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface"
typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
typedef struct VkXlibSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
@ -41,7 +31,6 @@ typedef struct VkXlibSurfaceCreateInfoKHR {
Window window;
} VkXlibSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID);

@ -1,24 +1,10 @@
#ifndef VULKAN_XLIB_XRANDR_H_
#define VULKAN_XLIB_XRANDR_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
** Copyright 2015-2023 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
** SPDX-License-Identifier: Apache-2.0
*/
/*
@ -27,10 +13,15 @@ extern "C" {
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_EXT_acquire_xlib_display 1
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1
#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display"
typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display);
typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay);

@ -24,7 +24,7 @@ if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-missing-braces -Wno-missing-field-initializers")
endif()
if(CV_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-self-assign")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-self-assign -Wno-strict-prototypes")
endif()
endif()

@ -2,32 +2,32 @@ function(download_ippicv root_var)
set(${root_var} "" PARENT_SCOPE)
# Commit SHA in the opencv_3rdparty repo
set(IPPICV_COMMIT "a56b6ac6f030c312b2dce17430eef13aed9af274")
set(IPPICV_COMMIT "1224f78da6684df04397ac0f40c961ed37f79ccb")
# Define actual ICV versions
if(APPLE)
set(OPENCV_ICV_PLATFORM "macosx")
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_mac")
set(OPENCV_ICV_NAME "ippicv_2020_mac_intel64_20191018_general.tgz")
set(OPENCV_ICV_HASH "1c3d675c2a2395d094d523024896e01b")
set(OPENCV_ICV_NAME "ippicv_2021.8_mac_intel64_20230330_general.tgz")
set(OPENCV_ICV_HASH "d2b234a86af1b616958619a4560356d9")
elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86"))
set(OPENCV_ICV_PLATFORM "linux")
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_lnx")
if(X86_64)
set(OPENCV_ICV_NAME "ippicv_2020_lnx_intel64_20191018_general.tgz")
set(OPENCV_ICV_HASH "7421de0095c7a39162ae13a6098782f9")
set(OPENCV_ICV_NAME "ippicv_2021.8_lnx_intel64_20230330_general.tgz")
set(OPENCV_ICV_HASH "43219bdc7e3805adcbe3a1e2f1f3ef3b")
else()
set(OPENCV_ICV_NAME "ippicv_2020_lnx_ia32_20191018_general.tgz")
set(OPENCV_ICV_HASH "ad189a940fb60eb71f291321322fe3e8")
set(OPENCV_ICV_NAME "ippicv_2021.8_lnx_ia32_20230330_general.tgz")
set(OPENCV_ICV_HASH "165875443d72faa3fd2146869da90d07")
endif()
elseif(WIN32 AND NOT ARM)
set(OPENCV_ICV_PLATFORM "windows")
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_win")
if(X86_64)
set(OPENCV_ICV_NAME "ippicv_2020_win_intel64_20191018_general.zip")
set(OPENCV_ICV_HASH "879741a7946b814455eee6c6ffde2984")
set(OPENCV_ICV_NAME "ippicv_2021.8_win_intel64_20230330_general.zip")
set(OPENCV_ICV_HASH "71e4f58de939f0348ec7fb58ffb17dbf")
else()
set(OPENCV_ICV_NAME "ippicv_2020_win_ia32_20191018_general.zip")
set(OPENCV_ICV_HASH "cd39bdf0c2e1cac9a61101dad7a2413e")
set(OPENCV_ICV_NAME "ippicv_2021.8_win_ia32_20230330_general.zip")
set(OPENCV_ICV_HASH "57fd4648cfe64eae9e2ad9d50173a553")
endif()
else()
return()

@ -1,5 +1,124 @@
# Changelog
## [v2.5.0](https://github.com/uclouvain/openjpeg/releases/v2.5.0) (2022-05-13)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.4.0...v2.5.0)
**Merged pull requests:**
- tools/travis-ci/install.sh: git clone with https:// to fix 'The unaut… [\#1419](https://github.com/uclouvain/openjpeg/pull/1419) ([rouault](https://github.com/rouault))
- Java Support 1.8 now... [\#1418](https://github.com/uclouvain/openjpeg/pull/1418) ([jiapei100](https://github.com/jiapei100))
- Separate fuzz targets to increase coverage [\#1416](https://github.com/uclouvain/openjpeg/pull/1416) ([Navidem](https://github.com/Navidem))
- CMakeLists.txt: do not set INSTALL\_NAME\_DIR for MacOS builds for CMake \>= 3.0 \(fixes \#1404\) [\#1410](https://github.com/uclouvain/openjpeg/pull/1410) ([rouault](https://github.com/rouault))
- Avoid integer overflows in DWT. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44544 [\#1408](https://github.com/uclouvain/openjpeg/pull/1408) ([rouault](https://github.com/rouault))
- Updated "added support for partial bitstream decoding" [\#1407](https://github.com/uclouvain/openjpeg/pull/1407) ([Neopallium](https://github.com/Neopallium))
- opj\_encoder\_set\_extra\_options\(\): add a GUARD\_BITS=value option [\#1403](https://github.com/uclouvain/openjpeg/pull/1403) ([rouault](https://github.com/rouault))
- More overflow related bug fixes [\#1402](https://github.com/uclouvain/openjpeg/pull/1402) ([Eharve14](https://github.com/Eharve14))
- opj\_j2k\_setup\_encoder\(\): validate number of tiles to avoid illegal values and potential overflow \(fixes \#1399\) [\#1401](https://github.com/uclouvain/openjpeg/pull/1401) ([rouault](https://github.com/rouault))
- Missed conversion from unsigned int to OPJ\_INT32 [\#1398](https://github.com/uclouvain/openjpeg/pull/1398) ([Eharve14](https://github.com/Eharve14))
- Added check for integer overflow in get\_num\_images [\#1397](https://github.com/uclouvain/openjpeg/pull/1397) ([Eharve14](https://github.com/Eharve14))
- Added overflow check for CVE-2021-29338 [\#1396](https://github.com/uclouvain/openjpeg/pull/1396) ([Eharve14](https://github.com/Eharve14))
- Fix integer overflow in num\_images [\#1395](https://github.com/uclouvain/openjpeg/pull/1395) ([baparham](https://github.com/baparham))
- Remove duplicate assignments in function tiftoimage [\#1392](https://github.com/uclouvain/openjpeg/pull/1392) ([stweil](https://github.com/stweil))
- Fix some typos \(found by codespell\) [\#1390](https://github.com/uclouvain/openjpeg/pull/1390) ([stweil](https://github.com/stweil))
- CI: Add CIFuzz action [\#1386](https://github.com/uclouvain/openjpeg/pull/1386) ([DavidKorczynski](https://github.com/DavidKorczynski))
- Feature/decimation [\#1384](https://github.com/uclouvain/openjpeg/pull/1384) ([msheby](https://github.com/msheby))
- API: deprecate 'bpp' member in favor of 'prec' [\#1383](https://github.com/uclouvain/openjpeg/pull/1383) ([rouault](https://github.com/rouault))
- Added support for high throughput \(HTJ2K\) decoding. [\#1381](https://github.com/uclouvain/openjpeg/pull/1381) ([rouault](https://github.com/rouault))
- verify-indentation.sh: fix for pull request from bar/master to foo/master [\#1380](https://github.com/uclouvain/openjpeg/pull/1380) ([rouault](https://github.com/rouault))
- Change integer for version libtiff 4.3.0 [\#1377](https://github.com/uclouvain/openjpeg/pull/1377) ([Jamaika1](https://github.com/Jamaika1))
- Port continuous integration to github actions [\#1376](https://github.com/uclouvain/openjpeg/pull/1376) ([rouault](https://github.com/rouault))
- Avoid integer overflows in DWT. [\#1375](https://github.com/uclouvain/openjpeg/pull/1375) ([rouault](https://github.com/rouault))
- LGTM warning: Comparison result is always the same [\#1373](https://github.com/uclouvain/openjpeg/pull/1373) ([DimitriPapadopoulos](https://github.com/DimitriPapadopoulos))
- A couple typos found by codespell [\#1371](https://github.com/uclouvain/openjpeg/pull/1371) ([DimitriPapadopoulos](https://github.com/DimitriPapadopoulos))
- cmake: add install interface include directory [\#1370](https://github.com/uclouvain/openjpeg/pull/1370) ([madebr](https://github.com/madebr))
- fix issues 1368: exist a issues of freeing uninitialized pointer in src/bin/jp2/opj\_decompress.c,that will cause a segfault [\#1369](https://github.com/uclouvain/openjpeg/pull/1369) ([xiaoxiaoafeifei](https://github.com/xiaoxiaoafeifei))
- opj\_j2k\_is\_imf\_compliant: Fix out of bounds access [\#1366](https://github.com/uclouvain/openjpeg/pull/1366) ([sebras](https://github.com/sebras))
- opj\_j2k\_is\_imf\_compliant: Fix argument formatting for warnings. [\#1365](https://github.com/uclouvain/openjpeg/pull/1365) ([sebras](https://github.com/sebras))
- CMakeLists.txt/appveyor.yml: update version number to 2.5.0… [\#1361](https://github.com/uclouvain/openjpeg/pull/1361) ([rouault](https://github.com/rouault))
- .travis.yml: try to fix gcc 4.8 config by updating to xenial [\#1360](https://github.com/uclouvain/openjpeg/pull/1360) ([rouault](https://github.com/rouault))
- Add support for enabling generation of TLM markers in encoder [\#1359](https://github.com/uclouvain/openjpeg/pull/1359) ([rouault](https://github.com/rouault))
- Fix various compiler warnings [\#1358](https://github.com/uclouvain/openjpeg/pull/1358) ([rouault](https://github.com/rouault))
- fix \#1345: don't remove big endian test for other platforms [\#1354](https://github.com/uclouvain/openjpeg/pull/1354) ([msabwat](https://github.com/msabwat))
- Remove obsolete components JPWL, JP3D and MJ2 [\#1350](https://github.com/uclouvain/openjpeg/pull/1350) ([rouault](https://github.com/rouault))
- tools/travis-ci/install.sh: fix links to Kakadu and jpylyzer binaries [\#1348](https://github.com/uclouvain/openjpeg/pull/1348) ([rouault](https://github.com/rouault))
- emscripten: disable big endian test [\#1345](https://github.com/uclouvain/openjpeg/pull/1345) ([msabwat](https://github.com/msabwat))
- Fix cmake file with DESTDIR [\#1321](https://github.com/uclouvain/openjpeg/pull/1321) ([ffontaine](https://github.com/ffontaine))
- CMakeLists.txt: Don't require a C++ compiler [\#1317](https://github.com/uclouvain/openjpeg/pull/1317) ([ffontaine](https://github.com/ffontaine))
- Import files tiff and yuv\(raw\) [\#1316](https://github.com/uclouvain/openjpeg/pull/1316) ([Jamaika1](https://github.com/Jamaika1))
- Fix year in NEWS [\#1312](https://github.com/uclouvain/openjpeg/pull/1312) ([stweil](https://github.com/stweil))
- Fix lcms2 static linking using pgk config [\#867](https://github.com/uclouvain/openjpeg/pull/867) ([pseiderer](https://github.com/pseiderer))
- fix static build only against tiff and its indirect dependencies [\#866](https://github.com/uclouvain/openjpeg/pull/866) ([tSed](https://github.com/tSed))
**Closed issues:**
- integer constant is too large for 'long' type [\#61](https://github.com/uclouvain/openjpeg/issues/61)
- Openjpeg3D lossy compression not working [\#501](https://github.com/uclouvain/openjpeg/issues/501)
- mj2: Array overflow [\#485](https://github.com/uclouvain/openjpeg/issues/485)
- OPJ fails to decode image that KDU manages correctly [\#419](https://github.com/uclouvain/openjpeg/issues/419)
- yuvtoimage\(\) bug in v1 and v2 for 16-Bit: please apply ASAP [\#384](https://github.com/uclouvain/openjpeg/issues/384)
- JP3D: Fix CVE-2013-4289 CVE-2013-4290 [\#298](https://github.com/uclouvain/openjpeg/issues/298)
- MJ2 libraries are installed in lib [\#204](https://github.com/uclouvain/openjpeg/issues/204)
- MJ2: realloc is misused and may leak memory [\#168](https://github.com/uclouvain/openjpeg/issues/168)
- MJ2 wrapper not functional [\#143](https://github.com/uclouvain/openjpeg/issues/143)
- JPWL is broken in trunk [\#137](https://github.com/uclouvain/openjpeg/issues/137)
- MJ2 files not using OPENJPEG API correctly [\#53](https://github.com/uclouvain/openjpeg/issues/53)
- Maximum bit depth supported by the OpenJPEG implementation of JP3D [\#9](https://github.com/uclouvain/openjpeg/issues/9)
- does openjpeg support either visually lossless or numerically lossless jpeg2000 compression? [\#1406](https://github.com/uclouvain/openjpeg/issues/1406)
- extract jpeg2000 tile without decompression [\#1405](https://github.com/uclouvain/openjpeg/issues/1405)
- openjpeg doesn't install a relocatable shared lib on macOS [\#1404](https://github.com/uclouvain/openjpeg/issues/1404)
- pull request - the cinema industry awaits! [\#1400](https://github.com/uclouvain/openjpeg/issues/1400)
- Integer overflows in j2K [\#1399](https://github.com/uclouvain/openjpeg/issues/1399)
- why lossly compression performance worse than jpeg when compress png? [\#1393](https://github.com/uclouvain/openjpeg/issues/1393)
- cect [\#1389](https://github.com/uclouvain/openjpeg/issues/1389)
- the docs don't describe bpp and prec in opj\_image\_comp very well [\#1379](https://github.com/uclouvain/openjpeg/issues/1379)
- converting .png to .jp2 by opj\_compress is different from the original image [\#1378](https://github.com/uclouvain/openjpeg/issues/1378)
- Comparison result is always the same [\#1372](https://github.com/uclouvain/openjpeg/issues/1372)
- Exist a issues of freeing uninitialized pointer in src/bin/jp2/opj\_decompress.c,that will cause a segfault [\#1368](https://github.com/uclouvain/openjpeg/issues/1368)
- \[TEST NOT RUNNING\]: bigendian test [\#1355](https://github.com/uclouvain/openjpeg/issues/1355)
- opj\_decompress 2.4.0 built with library 2.3.0. [\#1352](https://github.com/uclouvain/openjpeg/issues/1352)
- New library htjpeg2000 [\#1351](https://github.com/uclouvain/openjpeg/issues/1351)
- Integer Overflow in num\_images [\#1338](https://github.com/uclouvain/openjpeg/issues/1338)
- All IMF Profile Selections Result in PART1 [\#1337](https://github.com/uclouvain/openjpeg/issues/1337)
- grayscale image [\#1334](https://github.com/uclouvain/openjpeg/issues/1334)
- error C2169: 'lrintf': intrinsic function, cannot be defined [\#1333](https://github.com/uclouvain/openjpeg/issues/1333)
- Generate lower-case extension [\#1332](https://github.com/uclouvain/openjpeg/issues/1332)
- color of reconstructed png file much darker [\#1330](https://github.com/uclouvain/openjpeg/issues/1330)
- CVE-2019-6988, CVE-2018-20846 and CVE-2018-16376 [\#1328](https://github.com/uclouvain/openjpeg/issues/1328)
- opj 2.4.0: opj\_free missing in opj3d [\#1327](https://github.com/uclouvain/openjpeg/issues/1327)
- Not able to compress volumetric data [\#1326](https://github.com/uclouvain/openjpeg/issues/1326)
- HTML documents are not installed in specified place [\#1322](https://github.com/uclouvain/openjpeg/issues/1322)
- Can't find openjpeg.h when cross-compile. [\#1320](https://github.com/uclouvain/openjpeg/issues/1320)
- OpenJPEG is available with EasyConfig [\#1319](https://github.com/uclouvain/openjpeg/issues/1319)
- Building Test Programs [\#1318](https://github.com/uclouvain/openjpeg/issues/1318)
- Builds are not reproducible [\#1275](https://github.com/uclouvain/openjpeg/issues/1275)
- strange behaviour of opj\_jp3d\_compress/decompress utility [\#1274](https://github.com/uclouvain/openjpeg/issues/1274)
- Potential heap-based buffer overflow in function t2\_encode\_packet in src/lib/openmj2/t2.c and src/lib/openjp3d/t2.c [\#1272](https://github.com/uclouvain/openjpeg/issues/1272)
- Function tgatoimage in src/bin/jpwl/convert.c need to check that the file is big enough to avoid excessive memory allocations [\#1271](https://github.com/uclouvain/openjpeg/issues/1271)
- memory & cpu are exhausted when converting jp2 file into png [\#1250](https://github.com/uclouvain/openjpeg/issues/1250)
- Cannot compress PGX into JP3D despite following the directions? [\#1134](https://github.com/uclouvain/openjpeg/issues/1134)
- sscanf buffer overflow in opj\_jp3d\_compress.c [\#1130](https://github.com/uclouvain/openjpeg/issues/1130)
- integer underflow may lead to writing garbage [\#1089](https://github.com/uclouvain/openjpeg/issues/1089)
- sscanf buffer overflow [\#1087](https://github.com/uclouvain/openjpeg/issues/1087)
- strcpy overflows [\#1086](https://github.com/uclouvain/openjpeg/issues/1086)
- sprintf buffer overflows [\#1084](https://github.com/uclouvain/openjpeg/issues/1084)
- strcpy buffer overflow [\#1083](https://github.com/uclouvain/openjpeg/issues/1083)
- integer overflow in malloc\(\) [\#1082](https://github.com/uclouvain/openjpeg/issues/1082)
- out of bounds writes [\#1078](https://github.com/uclouvain/openjpeg/issues/1078)
- out of bounds writes [\#1077](https://github.com/uclouvain/openjpeg/issues/1077)
- divide by zero, perhaps multiplication overflow [\#1076](https://github.com/uclouvain/openjpeg/issues/1076)
- missing format string parameter [\#1075](https://github.com/uclouvain/openjpeg/issues/1075)
- leaks from cppcheck in lib folder [\#1038](https://github.com/uclouvain/openjpeg/issues/1038)
- How to initialize DEBUG\_PROFILE in color.c? [\#958](https://github.com/uclouvain/openjpeg/issues/958)
- JP3D sample files [\#865](https://github.com/uclouvain/openjpeg/issues/865)
- BIG\_ENDIAN bug in jpwl.c [\#839](https://github.com/uclouvain/openjpeg/issues/839)
- OpenJPEG fails to decode partial j2c where kdu succeeds [\#715](https://github.com/uclouvain/openjpeg/issues/715)
- building mj2 binaries fails [\#652](https://github.com/uclouvain/openjpeg/issues/652)
- openmj2\mj2.c: Out of bounds [\#646](https://github.com/uclouvain/openjpeg/issues/646)
- bin\mj2\opj\_mj2\_decompress.c 101 wrong check / leak [\#608](https://github.com/uclouvain/openjpeg/issues/608)
## [v2.4.0](https://github.com/uclouvain/openjpeg/releases/v2.4.0) (2020-12-28)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.3.1...v2.4.0)
@ -79,7 +198,7 @@
- tests/fuzzers: link fuzz binaries using $LIB\_FUZZING\_ENGINE. [\#1230](https://github.com/uclouvain/openjpeg/pull/1230) ([Dor1s](https://github.com/Dor1s))
- opj\_j2k\_update\_image\_dimensions\(\): reject images whose coordinates are beyond INT\_MAX \(fixes \#1228\) [\#1229](https://github.com/uclouvain/openjpeg/pull/1229) ([rouault](https://github.com/rouault))
- Fix resource leaks [\#1226](https://github.com/uclouvain/openjpeg/pull/1226) ([dodys](https://github.com/dodys))
- abi-check.sh: fix false postive ABI error, and display output error log [\#1218](https://github.com/uclouvain/openjpeg/pull/1218) ([rouault](https://github.com/rouault))
- abi-check.sh: fix false positive ABI error, and display output error log [\#1218](https://github.com/uclouvain/openjpeg/pull/1218) ([rouault](https://github.com/rouault))
- pi.c: avoid integer overflow, resulting in later invalid access to memory in opj\_t2\_decode\_packets\(\) [\#1217](https://github.com/uclouvain/openjpeg/pull/1217) ([rouault](https://github.com/rouault))
- Add check to validate SGcod/SPcoc/SPcod parameter values. [\#1211](https://github.com/uclouvain/openjpeg/pull/1211) ([sebras](https://github.com/sebras))
- Fix buffer overflow reading an image file less than four characters [\#1196](https://github.com/uclouvain/openjpeg/pull/1196) ([robert-ancell](https://github.com/robert-ancell))

@ -14,12 +14,13 @@ project(openjpeg C)
ocv_warnings_disable(CMAKE_C_FLAGS
-Wimplicit-const-int-float-conversion # clang
-Wunused-but-set-variable # clang15
-Wmissing-prototypes # clang, function opj_t1_ht_decode_cblk
)
#-----------------------------------------------------------------------------
# OPENJPEG version number, useful for packaging and doxygen doc:
set(OPENJPEG_VERSION_MAJOR 2)
set(OPENJPEG_VERSION_MINOR 4)
set(OPENJPEG_VERSION_MINOR 5)
set(OPENJPEG_VERSION_BUILD 0)
set(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
@ -45,6 +46,7 @@ set(PACKAGE_VERSION
# 2.3.0 | 7
# 2.3.1 | 7
# 2.4.0 | 7
# 2.5.0 | 7
# above is the recommendation by the OPJ team. If you really need to override this default,
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
@ -92,8 +94,10 @@ endif()
#-----------------------------------------------------------------------------
# Big endian test:
if (NOT EMSCRIPTEN)
include(TestBigEndian)
test_big_endian(OPJ_BIG_ENDIAN)
endif()
#-----------------------------------------------------------------------------
# opj_config.h generation (1/2)

@ -29,18 +29,12 @@ The library is developed and maintained by the Image and Signal Processing Group
* src
* lib
* openjp2: contains the sources of the openjp2 library (Part 1 & 2)
* openjpwl: contains the additional sources if you want to build a JPWL-flavoured library.
* openjpip: complete client-server architecture for remote browsing of jpeg 2000 images.
* openjp3d: JP3D implementation
* openmj2: MJ2 implementation
* bin: contains all applications that use the openjpeg library
* common: common files to all applications
* jp2: a basic codec
* mj2: motion jpeg 2000 executables
* jpip: OpenJPIP applications (server and dec server)
* java: a Java client viewer for JPIP
* jp3d: JP3D applications
* tcltk: a test tool for JP3D
* wx
* OPJViewer: gui for displaying j2k files (based on wxWidget)
* wrapping
@ -57,6 +51,12 @@ See [INSTALL](https://github.com/uclouvain/openjpeg/blob/master/INSTALL.md) for
See [NEWS](https://github.com/uclouvain/openjpeg/blob/master/NEWS.md) for user visible changes in successive releases.
## Deprecated components
The openjpwl, openjp3d and openmj2 components have been removed after the
2.4.0 release. Their building and working state is unknown. People interested
in them should start from the 2.4.0 tag.
## API/ABI
An API/ABI timeline is automatically updated [here][link-api-timeline].
@ -74,8 +74,8 @@ API available is the one supported by OpenJPEG.
[comment-license]: https://img.shields.io/github/license/uclouvain/openjpeg.svg "https://img.shields.io/badge/license-BSD--2--Clause-blue.svg"
[badge-license]: https://img.shields.io/badge/license-BSD--2--Clause-blue.svg "BSD 2-clause \"Simplified\" License"
[link-license]: https://github.com/uclouvain/openjpeg/blob/master/LICENSE "BSD 2-clause \"Simplified\" License"
[badge-build]: https://travis-ci.org/uclouvain/openjpeg.svg?branch=master "Build Status"
[link-build]: https://travis-ci.org/uclouvain/openjpeg "Build Status"
[badge-build]: https://github.com/uclouvain/openjpeg/actions/workflows/build.yml/badge.svg "Build Status"
[link-build]: https://github.com/uclouvain/openjpeg/actions/workflows/build.yml "Build Status"
[badge-msvc-build]: https://ci.appveyor.com/api/projects/status/github/uclouvain/openjpeg?branch=master&svg=true "Windows Build Status"
[link-msvc-build]: https://ci.appveyor.com/project/detonin/openjpeg/branch/master "Windows Build Status"
[badge-coverity]: https://scan.coverity.com/projects/6383/badge.svg "Coverity Scan Build Status"

@ -5,6 +5,7 @@ set(OPENJPEG_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/cio.c
${CMAKE_CURRENT_SOURCE_DIR}/dwt.c
${CMAKE_CURRENT_SOURCE_DIR}/event.c
${CMAKE_CURRENT_SOURCE_DIR}/ht_dec.c
${CMAKE_CURRENT_SOURCE_DIR}/image.c
${CMAKE_CURRENT_SOURCE_DIR}/invert.c
${CMAKE_CURRENT_SOURCE_DIR}/j2k.c

@ -0,0 +1,353 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2017, IntoPix SA <contact@intopix.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "opj_includes.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/times.h>
#endif /* _WIN32 */
OPJ_INT32 getValue(OPJ_UINT32 i)
{
return ((OPJ_INT32)i % 511) - 256;
}
void init_tilec(opj_tcd_tilecomp_t * l_tilec,
OPJ_INT32 x0,
OPJ_INT32 y0,
OPJ_INT32 x1,
OPJ_INT32 y1,
OPJ_UINT32 numresolutions,
OPJ_BOOL irreversible)
{
opj_tcd_resolution_t* l_res;
OPJ_UINT32 resno, l_level_no;
size_t i, nValues;
memset(l_tilec, 0, sizeof(*l_tilec));
l_tilec->x0 = x0;
l_tilec->y0 = y0;
l_tilec->x1 = x1;
l_tilec->y1 = y1;
nValues = (size_t)(l_tilec->x1 - l_tilec->x0) *
(size_t)(l_tilec->y1 - l_tilec->y0);
l_tilec->data = (OPJ_INT32*) opj_malloc(sizeof(OPJ_INT32) * nValues);
for (i = 0; i < nValues; i++) {
OPJ_INT32 val = getValue((OPJ_UINT32)i);
if (irreversible) {
OPJ_FLOAT32 fVal = (OPJ_FLOAT32)val;
memcpy(&l_tilec->data[i], &fVal, sizeof(OPJ_FLOAT32));
} else {
l_tilec->data[i] = val;
}
}
l_tilec->numresolutions = numresolutions;
l_tilec->minimum_num_resolutions = numresolutions;
l_tilec->resolutions = (opj_tcd_resolution_t*) opj_calloc(
l_tilec->numresolutions,
sizeof(opj_tcd_resolution_t));
l_level_no = l_tilec->numresolutions;
l_res = l_tilec->resolutions;
/* Adapted from opj_tcd_init_tile() */
for (resno = 0; resno < l_tilec->numresolutions; ++resno) {
--l_level_no;
/* border for each resolution level (global) */
l_res->x0 = opj_int_ceildivpow2(l_tilec->x0, (OPJ_INT32)l_level_no);
l_res->y0 = opj_int_ceildivpow2(l_tilec->y0, (OPJ_INT32)l_level_no);
l_res->x1 = opj_int_ceildivpow2(l_tilec->x1, (OPJ_INT32)l_level_no);
l_res->y1 = opj_int_ceildivpow2(l_tilec->y1, (OPJ_INT32)l_level_no);
++l_res;
}
}
void free_tilec(opj_tcd_tilecomp_t * l_tilec)
{
opj_free(l_tilec->data);
opj_free(l_tilec->resolutions);
}
void usage(void)
{
printf(
"bench_dwt [-decode|encode] [-I] [-size value] [-check] [-display]\n");
printf(
" [-num_resolutions val] [-offset x y] [-num_threads val]\n");
exit(1);
}
OPJ_FLOAT64 opj_clock(void)
{
#ifdef _WIN32
/* _WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq, t ;
/* freq is the clock speed of the CPU */
QueryPerformanceFrequency(&freq) ;
/* cout << "freq = " << ((double) freq.QuadPart) << endl; */
/* t is the high resolution performance counter (see MSDN) */
QueryPerformanceCounter(& t) ;
return freq.QuadPart ? (t.QuadPart / (OPJ_FLOAT64) freq.QuadPart) : 0 ;
#else
/* Unix or Linux: use resource usage */
struct rusage t;
OPJ_FLOAT64 procTime;
/* (1) Get the rusage data structure at this moment (man getrusage) */
getrusage(0, &t);
/* (2) What is the elapsed time ? - CPU time = User time + System time */
/* (2a) Get the seconds */
procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec);
/* (2b) More precisely! Get the microseconds part ! */
return (procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) *
1e-6) ;
#endif
}
static OPJ_FLOAT64 opj_wallclock(void)
{
#ifdef _WIN32
return opj_clock();
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return (OPJ_FLOAT64)tv.tv_sec + 1e-6 * (OPJ_FLOAT64)tv.tv_usec;
#endif
}
int main(int argc, char** argv)
{
int num_threads = 0;
opj_tcd_t tcd;
opj_tcd_image_t tcd_image;
opj_tcd_tile_t tcd_tile;
opj_tcd_tilecomp_t tilec;
opj_image_t image;
opj_image_comp_t image_comp;
opj_thread_pool_t* tp;
OPJ_INT32 i, j, k;
OPJ_BOOL display = OPJ_FALSE;
OPJ_BOOL check = OPJ_FALSE;
OPJ_INT32 size = 16384 - 1;
OPJ_FLOAT64 start, stop;
OPJ_FLOAT64 start_wc, stop_wc;
OPJ_UINT32 offset_x = ((OPJ_UINT32)size + 1) / 2 - 1;
OPJ_UINT32 offset_y = ((OPJ_UINT32)size + 1) / 2 - 1;
OPJ_UINT32 num_resolutions = 6;
OPJ_BOOL bench_decode = OPJ_TRUE;
OPJ_BOOL irreversible = OPJ_FALSE;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-encode") == 0) {
bench_decode = OPJ_FALSE;
} else if (strcmp(argv[i], "-decode") == 0) {
bench_decode = OPJ_TRUE;
} else if (strcmp(argv[i], "-display") == 0) {
display = OPJ_TRUE;
} else if (strcmp(argv[i], "-check") == 0) {
check = OPJ_TRUE;
} else if (strcmp(argv[i], "-I") == 0) {
irreversible = OPJ_TRUE;
} else if (strcmp(argv[i], "-size") == 0 && i + 1 < argc) {
size = atoi(argv[i + 1]);
i ++;
} else if (strcmp(argv[i], "-num_threads") == 0 && i + 1 < argc) {
num_threads = atoi(argv[i + 1]);
i ++;
} else if (strcmp(argv[i], "-num_resolutions") == 0 && i + 1 < argc) {
num_resolutions = (OPJ_UINT32)atoi(argv[i + 1]);
if (num_resolutions == 0 || num_resolutions > 32) {
fprintf(stderr,
"Invalid value for num_resolutions. Should be >= 1 and <= 32\n");
exit(1);
}
i ++;
} else if (strcmp(argv[i], "-offset") == 0 && i + 2 < argc) {
offset_x = (OPJ_UINT32)atoi(argv[i + 1]);
offset_y = (OPJ_UINT32)atoi(argv[i + 2]);
i += 2;
} else {
usage();
}
}
if (irreversible && check) {
/* Due to irreversible inverse DWT not being symmetric of forward */
/* See BUG_WEIRD_TWO_INVK in dwt.c */
printf("-I and -check aren't compatible\n");
exit(1);
}
tp = opj_thread_pool_create(num_threads);
init_tilec(&tilec, (OPJ_INT32)offset_x, (OPJ_INT32)offset_y,
(OPJ_INT32)offset_x + size, (OPJ_INT32)offset_y + size,
num_resolutions, irreversible);
if (display) {
printf("Before\n");
k = 0;
for (j = 0; j < tilec.y1 - tilec.y0; j++) {
for (i = 0; i < tilec.x1 - tilec.x0; i++) {
if (irreversible) {
printf("%f ", ((OPJ_FLOAT32*)tilec.data)[k]);
} else {
printf("%d ", tilec.data[k]);
}
k ++;
}
printf("\n");
}
}
memset(&tcd, 0, sizeof(tcd));
tcd.thread_pool = tp;
tcd.whole_tile_decoding = OPJ_TRUE;
tcd.win_x0 = (OPJ_UINT32)tilec.x0;
tcd.win_y0 = (OPJ_UINT32)tilec.y0;
tcd.win_x1 = (OPJ_UINT32)tilec.x1;
tcd.win_y1 = (OPJ_UINT32)tilec.y1;
tcd.tcd_image = &tcd_image;
memset(&tcd_image, 0, sizeof(tcd_image));
tcd_image.tiles = &tcd_tile;
memset(&tcd_tile, 0, sizeof(tcd_tile));
tcd_tile.x0 = tilec.x0;
tcd_tile.y0 = tilec.y0;
tcd_tile.x1 = tilec.x1;
tcd_tile.y1 = tilec.y1;
tcd_tile.numcomps = 1;
tcd_tile.comps = &tilec;
tcd.image = &image;
memset(&image, 0, sizeof(image));
image.numcomps = 1;
image.comps = &image_comp;
memset(&image_comp, 0, sizeof(image_comp));
image_comp.dx = 1;
image_comp.dy = 1;
start = opj_clock();
start_wc = opj_wallclock();
if (bench_decode) {
if (irreversible) {
opj_dwt_decode_real(&tcd, &tilec, tilec.numresolutions);
} else {
opj_dwt_decode(&tcd, &tilec, tilec.numresolutions);
}
} else {
if (irreversible) {
opj_dwt_encode_real(&tcd, &tilec);
} else {
opj_dwt_encode(&tcd, &tilec);
}
}
stop = opj_clock();
stop_wc = opj_wallclock();
printf("time for %s: total = %.03f s, wallclock = %.03f s\n",
bench_decode ? "dwt_decode" : "dwt_encode",
stop - start,
stop_wc - start_wc);
if (display) {
if (bench_decode) {
printf("After IDWT\n");
} else {
printf("After FDWT\n");
}
k = 0;
for (j = 0; j < tilec.y1 - tilec.y0; j++) {
for (i = 0; i < tilec.x1 - tilec.x0; i++) {
if (irreversible) {
printf("%f ", ((OPJ_FLOAT32*)tilec.data)[k]);
} else {
printf("%d ", tilec.data[k]);
}
k ++;
}
printf("\n");
}
}
if ((display || check) && !irreversible) {
if (bench_decode) {
opj_dwt_encode(&tcd, &tilec);
} else {
opj_dwt_decode(&tcd, &tilec, tilec.numresolutions);
}
if (display && !irreversible) {
if (bench_decode) {
printf("After FDWT\n");
} else {
printf("After IDWT\n");
}
k = 0;
for (j = 0; j < tilec.y1 - tilec.y0; j++) {
for (i = 0; i < tilec.x1 - tilec.x0; i++) {
if (irreversible) {
printf("%f ", ((OPJ_FLOAT32*)tilec.data)[k]);
} else {
printf("%d ", tilec.data[k]);
}
k ++;
}
printf("\n");
}
}
}
if (check) {
size_t idx;
size_t nValues = (size_t)(tilec.x1 - tilec.x0) *
(size_t)(tilec.y1 - tilec.y0);
for (idx = 0; idx < nValues; idx++) {
if (tilec.data[idx] != getValue((OPJ_UINT32)idx)) {
printf("Difference found at idx = %u\n", (OPJ_UINT32)idx);
exit(1);
}
}
}
free_tilec(&tilec);
opj_thread_pool_destroy(tp);
return 0;
}

@ -0,0 +1,259 @@
/*
* $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "opj_includes.h"
/*
* Write CPTR Codestream finder box
*
* @param[in] coff offset of j2k codestream
* @param[in] clen length of j2k codestream
* @param[in] cio file output handle
*/
void opj_write_cptr(int coff, int clen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
int opj_write_cidx(int offset, opj_stream_private_t *cio,
opj_codestream_info_t cstr_info, int j2klen,
opj_event_mgr_t * p_manager)
{
int i;
OPJ_OFF_T lenp;
OPJ_UINT32 len;
opj_jp2_box_t *box;
int num_box = 0;
OPJ_BOOL EPHused;
OPJ_BYTE l_data_header [4];
lenp = -1;
box = (opj_jp2_box_t *)opj_calloc(32, sizeof(opj_jp2_box_t));
if (box == NULL) {
return 0;
}
for (i = 0; i < 2; i++) {
if (i) {
opj_stream_seek(cio, lenp, p_manager);
}
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_CIDX, 4); /* CIDX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_cptr(offset, cstr_info.codestream_size, cio, p_manager);
opj_write_manf(i, num_box, box, cio, p_manager);
num_box = 0;
box[num_box].length = (OPJ_UINT32)opj_write_mainmhix(offset, cstr_info, cio,
p_manager);
box[num_box].type = JPIP_MHIX;
num_box++;
box[num_box].length = (OPJ_UINT32)opj_write_tpix(offset, cstr_info, j2klen, cio,
p_manager);
box[num_box].type = JPIP_TPIX;
num_box++;
box[num_box].length = (OPJ_UINT32)opj_write_thix(offset, cstr_info, cio,
p_manager);
box[num_box].type = JPIP_THIX;
num_box++;
EPHused = opj_check_EPHuse(offset, cstr_info.marker, cstr_info.marknum, cio,
p_manager);
box[num_box].length = (OPJ_UINT32)opj_write_ppix(offset, cstr_info, EPHused,
j2klen, cio, p_manager);
box[num_box].type = JPIP_PPIX;
num_box++;
box[num_box].length = (OPJ_UINT32)opj_write_phix(offset, cstr_info, EPHused,
j2klen, cio, p_manager);
box[num_box].type = JPIP_PHIX;
num_box++;
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
}
opj_free(box);
return (int)len;
}
void opj_write_cptr(int coff, int clen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [3 * 8];
OPJ_UINT32 len;
OPJ_OFF_T lenp;
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_CPTR, 4); /* T */
opj_write_bytes(l_data_header + 4, 0, 2); /* DR A PRECISER !! */
opj_write_bytes(l_data_header + 6, 0, 2); /* CONT */
opj_write_bytes(l_data_header + 8, (OPJ_UINT32)coff,
8); /* COFF A PRECISER !! */
opj_write_bytes(l_data_header + 16, (OPJ_UINT32)clen,
8); /* CLEN */
opj_stream_write_data(cio, l_data_header, 3 * 8, p_manager);
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
}
void opj_write_manf(int second,
int v,
opj_jp2_box_t *box,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [4];
int i;
OPJ_UINT32 len;
OPJ_OFF_T lenp;
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_MANF, 4); /* T */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
if (second) { /* Write only during the second pass */
for (i = 0; i < v; i++) {
opj_write_bytes(l_data_header, box[i].length,
4); /* Box length */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_bytes(l_data_header, box[i].type,
4); /* Box type */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
}
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4);/* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
}
int opj_write_mainmhix(int coff, opj_codestream_info_t cstr_info,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [8];
OPJ_UINT32 i;
OPJ_UINT32 len;
OPJ_OFF_T lenp;
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4,
p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_MHIX,
4); /* MHIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_bytes(l_data_header,
(OPJ_UINT32)(cstr_info.main_head_end - cstr_info.main_head_start + 1),
8); /* TLEN */
opj_stream_write_data(cio, l_data_header, 8, p_manager);
for (i = 1; i < (OPJ_UINT32)cstr_info.marknum;
i++) { /* Marker restricted to 1 apparition, skip SOC marker */
opj_write_bytes(l_data_header, cstr_info.marker[i].type, 2);
opj_write_bytes(l_data_header + 2, 0, 2);
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_bytes(l_data_header, (OPJ_UINT32)(cstr_info.marker[i].pos - coff), 8);
opj_stream_write_data(cio, l_data_header, 8, p_manager);
opj_write_bytes(l_data_header, (OPJ_UINT32)cstr_info.marker[i].len, 2);
opj_stream_write_data(cio, l_data_header, 2, p_manager);
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
return (int)len;
}
OPJ_BOOL opj_check_EPHuse(int coff, opj_marker_info_t *markers, int marknum,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [4];
OPJ_BOOL EPHused = OPJ_FALSE;
int i = 0;
OPJ_OFF_T org_pos;
unsigned int Scod;
for (i = 0; i < marknum; i++) {
if (markers[i].type == J2K_MS_COD) {
org_pos = opj_stream_tell(cio);
opj_stream_seek(cio, coff + markers[i].pos + 2, p_manager);
opj_stream_read_data(cio, l_data_header, 1, p_manager);
opj_read_bytes(l_data_header, &Scod, 1);
if (((Scod >> 2) & 1)) {
EPHused = OPJ_TRUE;
}
opj_stream_seek(cio, org_pos, p_manager);
break;
}
}
return EPHused;
}

@ -0,0 +1,70 @@
/*
* $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.h from 2KAN indexer
*/
#ifndef CIDX_MANAGER_H_
# define CIDX_MANAGER_H_
#include "openjpeg.h"
/*
* Write Codestream index box (superbox)
*
* @param[in] offset offset of j2k codestream
* @param[in] cio file output handle
* @param[in] image image data
* @param[in] cstr_info codestream information
* @param[in] j2klen length of j2k codestream
* @return length of cidx box
*/
int opj_write_cidx(int offset, opj_stream_private_t *cio,
opj_codestream_info_t cstr_info, int j2klen,
opj_event_mgr_t * p_manager);
/*
* Check if EPH option is used
*
* @param[in] coff offset of j2k codestream
* @param[in] markers marker information
* @param[in] marknum number of markers
* @param[in] cio file output handle
* @return true if EPH is used
*/
OPJ_BOOL opj_check_EPHuse(int coff, opj_marker_info_t *markers, int marknum,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
#endif /* !CIDX_MANAGER_H_ */

@ -118,7 +118,7 @@ typedef struct opj_stream_private {
opj_stream_seek_fn m_seek_fn;
/**
* Actual data stored into the stream if readed from. Data is read by chunk of fixed size.
* Actual data stored into the stream if read from. Data is read by chunk of fixed size.
* you should never access this data directly.
*/
OPJ_BYTE * m_stored_data;

@ -385,7 +385,8 @@ static void opj_idwt53_h_cas0(OPJ_INT32* tmp,
s0n = s1n - ((d1c + d1n + 2) >> 2);
tmp[i ] = s0c;
tmp[i + 1] = d1c + ((s0c + s0n) >> 1);
tmp[i + 1] = opj_int_add_no_overflow(d1c, opj_int_add_no_overflow(s0c,
s0n) >> 1);
}
tmp[i] = s0n;
@ -450,7 +451,7 @@ static void opj_idwt53_h_cas1(OPJ_INT32* tmp,
dn = in_odd[j] - ((s1 + s2 + 2) >> 2);
tmp[i ] = dc;
tmp[i + 1] = s1 + ((dn + dc) >> 1);
tmp[i + 1] = opj_int_add_no_overflow(s1, opj_int_add_no_overflow(dn, dc) >> 1);
dc = dn;
s1 = s2;
@ -512,7 +513,7 @@ static void opj_idwt53_h(const opj_dwt_t *dwt,
#if (defined(__SSE2__) || defined(__AVX2__)) && !defined(STANDARD_SLOW_VERSION)
/* Conveniency macros to improve the readabilty of the formulas */
/* Conveniency macros to improve the readability of the formulas */
#if __AVX2__
#define VREG __m256i
#define LOAD_CST(x) _mm256_set1_epi32(x)
@ -796,10 +797,12 @@ static void opj_idwt3_v_cas0(OPJ_INT32* tmp,
s1n = tiledp_col[(OPJ_SIZE_T)(j + 1) * stride];
d1n = tiledp_col[(OPJ_SIZE_T)(sn + j + 1) * stride];
s0n = s1n - ((d1c + d1n + 2) >> 2);
s0n = opj_int_sub_no_overflow(s1n,
opj_int_add_no_overflow(opj_int_add_no_overflow(d1c, d1n), 2) >> 2);
tmp[i ] = s0c;
tmp[i + 1] = d1c + ((s0c + s0n) >> 1);
tmp[i + 1] = opj_int_add_no_overflow(d1c, opj_int_add_no_overflow(s0c,
s0n) >> 1);
}
tmp[i] = s0n;
@ -2343,10 +2346,13 @@ static void opj_dwt_decode_partial_1(OPJ_INT32 *a, OPJ_INT32 dn, OPJ_INT32 sn,
OPJ_S(0) /= 2;
} else {
for (i = win_l_x0; i < win_l_x1; i++) {
OPJ_D(i) -= (OPJ_SS_(i) + OPJ_SS_(i + 1) + 2) >> 2;
OPJ_D(i) = opj_int_sub_no_overflow(OPJ_D(i),
opj_int_add_no_overflow(opj_int_add_no_overflow(OPJ_SS_(i), OPJ_SS_(i + 1)),
2) >> 2);
}
for (i = win_h_x0; i < win_h_x1; i++) {
OPJ_S(i) += (OPJ_DD_(i) + OPJ_DD_(i - 1)) >> 1;
OPJ_S(i) = opj_int_add_no_overflow(OPJ_S(i),
opj_int_add_no_overflow(OPJ_DD_(i), OPJ_DD_(i - 1)) >> 1);
}
}
}
@ -2484,12 +2490,17 @@ static void opj_dwt_decode_partial_1_parallel(OPJ_INT32 *a,
} else {
for (i = win_l_x0; i < win_l_x1; i++) {
for (off = 0; off < 4; off++) {
OPJ_D_off(i, off) -= (OPJ_SS__off(i, off) + OPJ_SS__off(i + 1, off) + 2) >> 2;
OPJ_D_off(i, off) = opj_int_sub_no_overflow(
OPJ_D_off(i, off),
opj_int_add_no_overflow(
opj_int_add_no_overflow(OPJ_SS__off(i, off), OPJ_SS__off(i + 1, off)), 2) >> 2);
}
}
for (i = win_h_x0; i < win_h_x1; i++) {
for (off = 0; off < 4; off++) {
OPJ_S_off(i, off) += (OPJ_DD__off(i, off) + OPJ_DD__off(i - 1, off)) >> 1;
OPJ_S_off(i, off) = opj_int_add_no_overflow(
OPJ_S_off(i, off),
opj_int_add_no_overflow(OPJ_DD__off(i, off), OPJ_DD__off(i - 1, off)) >> 1);
}
}
}

File diff suppressed because it is too large Load Diff

@ -66,7 +66,6 @@ opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts,
comp->x0 = cmptparms[compno].x0;
comp->y0 = cmptparms[compno].y0;
comp->prec = cmptparms[compno].prec;
comp->bpp = cmptparms[compno].bpp;
comp->sgnd = cmptparms[compno].sgnd;
if (comp->h != 0 &&
(OPJ_SIZE_T)comp->w > SIZE_MAX / comp->h / sizeof(OPJ_INT32)) {

@ -0,0 +1,157 @@
/*
* $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#ifndef INDEXBOX_MANAGER_H_
# define INDEXBOX_MANAGER_H_
#include "openjpeg.h"
#include "j2k.h" /* needed to use jp2.h */
#include "jp2.h"
#define JPIP_CIDX 0x63696478 /* Codestream index */
#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */
#define JPIP_MANF 0x6d616e66 /* Manifest Box */
#define JPIP_FAIX 0x66616978 /* Fragment array Index box */
#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */
#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */
#define JPIP_THIX 0x74686978 /* Tile header Index Table box */
#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */
#define JPIP_PHIX 0x70686978 /* Packet Header index Table */
#define JPIP_FIDX 0x66696478 /* File Index */
#define JPIP_FPTR 0x66707472 /* File Finder */
#define JPIP_PRXY 0x70727879 /* Proxy boxes */
#define JPIP_IPTR 0x69707472 /* Index finder box */
#define JPIP_PHLD 0x70686c64 /* Place holder */
/*
* Write tile-part Index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of tpix box
*/
int opj_write_tpix(int coff, opj_codestream_info_t cstr_info, int j2klen,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
/*
* Write tile header index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information pointer
* @param[in] cio file output handle
* @return length of thix box
*/
int opj_write_thix(int coff, opj_codestream_info_t cstr_info,
opj_stream_private_t *cio, opj_event_mgr_t * p_manager);
/*
* Write precinct packet index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] EPHused true if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of ppix box
*/
int opj_write_ppix(int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
/*
* Write packet header index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] EPHused true if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of ppix box
*/
int opj_write_phix(int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
/*
* Write manifest box (box)
*
* @param[in] second number to be visited
* @param[in] v number of boxes
* @param[in] box box to be manifested
* @param[in] cio file output handle
*/
void opj_write_manf(int second,
int v,
opj_jp2_box_t *box,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
/*
* Write main header index table (box)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] cio file output handle
* @return length of mainmhix box
*/
int opj_write_mainmhix(int coff, opj_codestream_info_t cstr_info,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
int opj_write_phixfaix(int coff, int compno, opj_codestream_info_t cstr_info,
OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
int opj_write_ppixfaix(int coff, int compno, opj_codestream_info_t cstr_info,
OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
int opj_write_tilemhix(int coff, opj_codestream_info_t cstr_info, int tileno,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
int opj_write_tpixfaix(int coff, int compno, opj_codestream_info_t cstr_info,
int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager);
#endif /* !INDEXBOX_MANAGER_H_ */

@ -50,7 +50,7 @@
/*@{*/
/**
* Sets up the procedures to do on reading header. Developpers wanting to extend the library can add their own reading procedures.
* Sets up the procedures to do on reading header. Developers wanting to extend the library can add their own reading procedures.
*/
static OPJ_BOOL opj_j2k_setup_header_reading(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
@ -89,22 +89,22 @@ static OPJ_BOOL opj_j2k_decoding_validation(opj_j2k_t * p_j2k,
opj_event_mgr_t * p_manager);
/**
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
* are valid. Developpers wanting to extend the library can add their own validation procedures.
* Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
* are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_j2k_setup_encoding_validation(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
/**
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
* are valid. Developpers wanting to extend the library can add their own validation procedures.
* Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
* are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_j2k_setup_decoding_validation(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
/**
* Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
* are valid. Developpers wanting to extend the library can add their own validation procedures.
* Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
* are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_j2k_setup_end_compress(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
@ -147,7 +147,7 @@ static OPJ_BOOL opj_j2k_create_tcd(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
/**
* Excutes the given procedures on the given codec.
* Executes the given procedures on the given codec.
*
* @param p_procedure_list the list of procedures to execute
* @param p_j2k the jpeg2000 codec to execute the procedures on.
@ -910,9 +910,15 @@ static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
static void opj_j2k_update_tlm(opj_j2k_t * p_j2k, OPJ_UINT32 p_tile_part_size)
{
opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,
p_j2k->m_current_tile_number, 1); /* PSOT */
++p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current;
if (p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte) {
opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,
p_j2k->m_current_tile_number, 1);
p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 1;
} else {
opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,
p_j2k->m_current_tile_number, 2);
p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 2;
}
opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,
p_tile_part_size, 4); /* PSOT */
@ -1171,6 +1177,32 @@ static OPJ_BOOL opj_j2k_read_cbd(opj_j2k_t *p_j2k,
OPJ_UINT32 p_header_size,
opj_event_mgr_t * p_manager);
/**
* Reads a CAP marker (extended capabilities definition). Empty implementation.
* Found in HTJ2K files
*
* @param p_header_data the data contained in the CAP box.
* @param p_j2k the jpeg2000 codec.
* @param p_header_size the size of the data contained in the CAP marker.
* @param p_manager the user event manager.
*/
static OPJ_BOOL opj_j2k_read_cap(opj_j2k_t *p_j2k,
OPJ_BYTE * p_header_data,
OPJ_UINT32 p_header_size,
opj_event_mgr_t * p_manager);
/**
* Reads a CPF marker (corresponding profile). Empty implementation. Found in HTJ2K files
* @param p_header_data the data contained in the CPF box.
* @param p_j2k the jpeg2000 codec.
* @param p_header_size the size of the data contained in the CPF marker.
* @param p_manager the user event manager.
*/
static OPJ_BOOL opj_j2k_read_cpf(opj_j2k_t *p_j2k,
OPJ_BYTE * p_header_data,
OPJ_UINT32 p_header_size,
opj_event_mgr_t * p_manager);
/**
* Writes COC marker for each component.
@ -1393,10 +1425,12 @@ static const opj_dec_memory_marker_handler_t j2k_memory_marker_handler_tab [] =
{J2K_MS_COM, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_com},
{J2K_MS_MCT, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mct},
{J2K_MS_CBD, J2K_STATE_MH, opj_j2k_read_cbd},
{J2K_MS_CAP, J2K_STATE_MH, opj_j2k_read_cap},
{J2K_MS_CPF, J2K_STATE_MH, opj_j2k_read_cpf},
{J2K_MS_MCC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mcc},
{J2K_MS_MCO, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mco},
#ifdef USE_JPWL
#ifdef TODO_MS /* remove these functions which are not commpatible with the v2 API */
#ifdef TODO_MS /* remove these functions which are not compatible with the v2 API */
{J2K_MS_EPC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epc},
{J2K_MS_EPB, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epb},
{J2K_MS_ESD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_esd},
@ -1643,7 +1677,7 @@ static OPJ_BOOL opj_j2k_check_poc_val(const opj_poc_t *p_pocs,
assert(p_nb_pocs > 0);
packet_array = (OPJ_UINT32*) opj_calloc(step_l * p_num_layers,
packet_array = (OPJ_UINT32*) opj_calloc((size_t)step_l * p_num_layers,
sizeof(OPJ_UINT32));
if (packet_array == 00) {
opj_event_msg(p_manager, EVT_ERROR,
@ -1756,7 +1790,7 @@ static OPJ_UINT32 opj_j2k_get_num_tp(opj_cp_t *cp, OPJ_UINT32 pino,
tpnum *= l_current_poc->layE;
break;
}
/* whould we split here ? */
/* would we split here ? */
if (cp->m_specific_param.m_enc.m_tp_flag == prog[i]) {
cp->m_specific_param.m_enc.m_tp_pos = i;
break;
@ -4170,13 +4204,33 @@ static OPJ_BOOL opj_j2k_write_tlm(opj_j2k_t *p_j2k,
{
OPJ_BYTE * l_current_data = 00;
OPJ_UINT32 l_tlm_size;
OPJ_UINT32 size_per_tile_part;
/* preconditions */
assert(p_j2k != 00);
assert(p_manager != 00);
assert(p_stream != 00);
l_tlm_size = 6 + (5 * p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
/* 10921 = (65535 - header_size) / size_per_tile_part where */
/* header_size = 4 and size_per_tile_part = 6 */
if (p_j2k->m_specific_param.m_encoder.m_total_tile_parts > 10921) {
/* We could do more but it would require writing several TLM markers */
opj_event_msg(p_manager, EVT_ERROR,
"A maximum of 10921 tile-parts are supported currently "
"when writing TLM marker\n");
return OPJ_FALSE;
}
if (p_j2k->m_specific_param.m_encoder.m_total_tile_parts <= 255) {
size_per_tile_part = 5;
p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte = OPJ_TRUE;
} else {
size_per_tile_part = 6;
p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte = OPJ_FALSE;
}
l_tlm_size = 2 + 4 + (size_per_tile_part *
p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
if (l_tlm_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(
@ -4191,6 +4245,7 @@ static OPJ_BOOL opj_j2k_write_tlm(opj_j2k_t *p_j2k,
p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_tlm_size;
}
memset(p_j2k->m_specific_param.m_encoder.m_header_tile_data, 0, l_tlm_size);
l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data;
@ -4210,11 +4265,14 @@ static OPJ_BOOL opj_j2k_write_tlm(opj_j2k_t *p_j2k,
1); /* Ztlm=0*/
++l_current_data;
opj_write_bytes(l_current_data, 0x50,
1); /* Stlm ST=1(8bits-255 tiles max),SP=1(Ptlm=32bits) */
/* Stlm 0x50= ST=1(8bits-255 tiles max),SP=1(Ptlm=32bits) */
/* Stlm 0x60= ST=2(16bits-65535 tiles max),SP=1(Ptlm=32bits) */
opj_write_bytes(l_current_data,
size_per_tile_part == 5 ? 0x50 : 0x60,
1);
++l_current_data;
/* do nothing on the 5 * l_j2k->m_specific_param.m_encoder.m_total_tile_parts remaining data */
/* do nothing on the size_per_tile_part * l_j2k->m_specific_param.m_encoder.m_total_tile_parts remaining data */
if (opj_stream_write_data(p_stream,
p_j2k->m_specific_param.m_encoder.m_header_tile_data, l_tlm_size,
p_manager) != l_tlm_size) {
@ -4906,9 +4964,14 @@ static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
/* Check enough bytes left in stream before allocation */
if ((OPJ_OFF_T)p_j2k->m_specific_param.m_decoder.m_sot_length >
opj_stream_get_number_byte_left(p_stream)) {
opj_event_msg(p_manager, EVT_ERROR,
"Tile part length size inconsistent with stream length\n");
return OPJ_FALSE;
if (p_j2k->m_cp.strict) {
opj_event_msg(p_manager, EVT_ERROR,
"Tile part length size inconsistent with stream length\n");
return OPJ_FALSE;
} else {
opj_event_msg(p_manager, EVT_WARNING,
"Tile part length size inconsistent with stream length\n");
}
}
if (p_j2k->m_specific_param.m_decoder.m_sot_length >
UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA) {
@ -5354,9 +5417,9 @@ static OPJ_BOOL opj_j2k_update_rates(opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
if (OPJ_IS_CINEMA(l_cp->rsiz) || OPJ_IS_IMF(l_cp->rsiz)) {
if (p_j2k->m_specific_param.m_encoder.m_TLM) {
p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer =
(OPJ_BYTE *) opj_malloc(5 *
(OPJ_BYTE *) opj_malloc(6 *
p_j2k->m_specific_param.m_encoder.m_total_tile_parts);
if (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) {
return OPJ_FALSE;
@ -6564,6 +6627,60 @@ static OPJ_BOOL opj_j2k_read_cbd(opj_j2k_t *p_j2k,
return OPJ_TRUE;
}
/**
* Reads a CAP marker (extended capabilities definition). Empty implementation.
* Found in HTJ2K files.
*
* @param p_header_data the data contained in the CAP box.
* @param p_j2k the jpeg2000 codec.
* @param p_header_size the size of the data contained in the CAP marker.
* @param p_manager the user event manager.
*/
static OPJ_BOOL opj_j2k_read_cap(opj_j2k_t *p_j2k,
OPJ_BYTE * p_header_data,
OPJ_UINT32 p_header_size,
opj_event_mgr_t * p_manager
)
{
/* preconditions */
assert(p_header_data != 00);
assert(p_j2k != 00);
assert(p_manager != 00);
(void)p_j2k;
(void)p_header_data;
(void)p_header_size;
(void)p_manager;
return OPJ_TRUE;
}
/**
* Reads a CPF marker (corresponding profile). Empty implementation. Found in HTJ2K files
* @param p_header_data the data contained in the CPF box.
* @param p_j2k the jpeg2000 codec.
* @param p_header_size the size of the data contained in the CPF marker.
* @param p_manager the user event manager.
*/
static OPJ_BOOL opj_j2k_read_cpf(opj_j2k_t *p_j2k,
OPJ_BYTE * p_header_data,
OPJ_UINT32 p_header_size,
opj_event_mgr_t * p_manager
)
{
/* preconditions */
assert(p_header_data != 00);
assert(p_j2k != 00);
assert(p_manager != 00);
(void)p_j2k;
(void)p_header_data;
(void)p_header_size;
(void)p_manager;
return OPJ_TRUE;
}
/* ----------------------------------------------------------------------- */
/* J2K / JPT decoder interface */
/* ----------------------------------------------------------------------- */
@ -6583,6 +6700,13 @@ void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
}
}
void opj_j2k_decoder_set_strict_mode(opj_j2k_t *j2k, OPJ_BOOL strict)
{
if (j2k) {
j2k->m_cp.strict = strict;
}
}
OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads)
{
/* Currently we pass the thread-pool to the tcd, so we cannot re-set it */
@ -6863,7 +6987,7 @@ static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz,
/* Bitdepth */
for (i = 0; i < image->numcomps; i++) {
if ((image->comps[i].bpp != 12) | (image->comps[i].sgnd)) {
if ((image->comps[i].prec != 12) | (image->comps[i].sgnd)) {
char signed_str[] = "signed";
char unsigned_str[] = "unsigned";
char *tmp_str = image->comps[i].sgnd ? signed_str : unsigned_str;
@ -6872,7 +6996,7 @@ static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz,
"Precision of each component shall be 12 bits unsigned"
"-> At least component %d of input image (%d bits, %s) is not compliant\n"
"-> Non-profile-3 codestream will be generated\n",
i, image->comps[i].bpp, tmp_str);
i, image->comps[i].prec, tmp_str);
return OPJ_FALSE;
}
}
@ -7070,20 +7194,20 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
"-> Non-IMF codestream will be generated\n",
mainlevel);
ret = OPJ_FALSE;
}
/* Validate sublevel */
assert(sizeof(tabMaxSubLevelFromMainLevel) ==
(OPJ_IMF_MAINLEVEL_MAX + 1) * sizeof(tabMaxSubLevelFromMainLevel[0]));
if (sublevel > tabMaxSubLevelFromMainLevel[mainlevel]) {
opj_event_msg(p_manager, EVT_WARNING,
"IMF profile require sublevel <= %d for mainlevel = %d.\n"
"-> %d is thus not compliant\n"
"-> Non-IMF codestream will be generated\n",
tabMaxSubLevelFromMainLevel[mainlevel],
mainlevel,
sublevel);
ret = OPJ_FALSE;
} else {
/* Validate sublevel */
assert(sizeof(tabMaxSubLevelFromMainLevel) ==
(OPJ_IMF_MAINLEVEL_MAX + 1) * sizeof(tabMaxSubLevelFromMainLevel[0]));
if (sublevel > tabMaxSubLevelFromMainLevel[mainlevel]) {
opj_event_msg(p_manager, EVT_WARNING,
"IMF profile require sublevel <= %d for mainlevel = %d.\n"
"-> %d is thus not compliant\n"
"-> Non-IMF codestream will be generated\n",
tabMaxSubLevelFromMainLevel[mainlevel],
mainlevel,
sublevel);
ret = OPJ_FALSE;
}
}
/* Number of components */
@ -7163,7 +7287,7 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
/* Bitdepth */
for (i = 0; i < image->numcomps; i++) {
if (!(image->comps[i].bpp >= 8 && image->comps[i].bpp <= 16) ||
if (!(image->comps[i].prec >= 8 && image->comps[i].prec <= 16) ||
(image->comps[i].sgnd)) {
char signed_str[] = "signed";
char unsigned_str[] = "unsigned";
@ -7172,7 +7296,7 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
"IMF profiles require precision of each component to b in [8-16] bits unsigned"
"-> At least component %d of input image (%d bits, %s) is not compliant\n"
"-> Non-IMF codestream will be generated\n",
i, image->comps[i].bpp, tmp_str);
i, image->comps[i].prec, tmp_str);
ret = OPJ_FALSE;
}
}
@ -7204,7 +7328,7 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
if (image->comps[i].dy != 1) {
opj_event_msg(p_manager, EVT_WARNING,
"IMF profiles require YRsiz == 1. "
"Here it is set to %d for component i.\n"
"Here it is set to %d for component %d.\n"
"-> Non-IMF codestream will be generated\n",
image->comps[i].dy, i);
ret = OPJ_FALSE;
@ -7468,8 +7592,7 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
opj_event_msg(p_manager, EVT_WARNING,
"IMF profiles require PPx = PPy = 7 for NLLL band, else 8.\n"
"-> Supplied values are different from that.\n"
"-> Non-IMF codestream will be generated\n",
NL);
"-> Non-IMF codestream will be generated\n");
ret = OPJ_FALSE;
}
} else {
@ -7480,8 +7603,7 @@ static OPJ_BOOL opj_j2k_is_imf_compliant(opj_cparameters_t *parameters,
opj_event_msg(p_manager, EVT_WARNING,
"IMF profiles require PPx = PPy = 7 for NLLL band, else 8.\n"
"-> Supplied values are different from that.\n"
"-> Non-IMF codestream will be generated\n",
NL);
"-> Non-IMF codestream will be generated\n");
ret = OPJ_FALSE;
}
}
@ -7544,6 +7666,8 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
p_j2k->m_specific_param.m_encoder.m_nb_comps = image->numcomps;
/* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
cp = &(p_j2k->m_cp);
@ -7709,6 +7833,10 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
}
}
if (OPJ_IS_CINEMA(parameters->rsiz) || OPJ_IS_IMF(parameters->rsiz)) {
p_j2k->m_specific_param.m_encoder.m_TLM = OPJ_TRUE;
}
/* Manage profiles and applications and set RSIZ */
/* set cinema parameters if required */
if (OPJ_IS_CINEMA(parameters->rsiz)) {
@ -7839,6 +7967,13 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
(OPJ_INT32)cp->tdx);
cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp->ty0),
(OPJ_INT32)cp->tdy);
/* Check that the number of tiles is valid */
if (cp->tw > 65535 / cp->th) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
cp->tw, cp->th);
return OPJ_FALSE;
}
} else {
cp->tdx = image->x1 - cp->tx0;
cp->tdy = image->y1 - cp->ty0;
@ -7905,7 +8040,7 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
}
#endif /* USE_JPWL */
/* initialize the mutiple tiles */
/* initialize the multiple tiles */
/* ---------------------------- */
cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
if (!cp->tcps) {
@ -8715,7 +8850,7 @@ static OPJ_BOOL opj_j2k_read_header_procedure(opj_j2k_t *p_j2k,
if (l_marker_handler->id == J2K_MS_UNK) {
if (! opj_j2k_read_unk(p_j2k, p_stream, &l_current_marker, p_manager)) {
opj_event_msg(p_manager, EVT_ERROR,
"Unknow marker have been detected and generated error.\n");
"Unknown marker has been detected and generated error.\n");
return OPJ_FALSE;
}
@ -9720,7 +9855,7 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
/* When using the opj_read_tile_header / opj_decode_tile_data API */
/* such as in test_tile_decoder, m_output_image is NULL, so fall back */
/* to the full image dimension. This is a bit surprising that */
/* opj_set_decode_area() is only used to determinte intersecting tiles, */
/* opj_set_decode_area() is only used to determine intersecting tiles, */
/* but full tile decoding is done */
l_image_for_bounds = p_j2k->m_output_image ? p_j2k->m_output_image :
p_j2k->m_private_image;
@ -9766,10 +9901,10 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC) {
if (opj_stream_read_data(p_stream, l_data, 2, p_manager) != 2) {
opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
return OPJ_FALSE;
opj_event_msg(p_manager, p_j2k->m_cp.strict ? EVT_ERROR : EVT_WARNING,
"Stream too short\n");
return p_j2k->m_cp.strict ? OPJ_FALSE : OPJ_TRUE;
}
opj_read_bytes(l_data, &l_current_marker, 2);
if (l_current_marker == J2K_MS_EOC) {
@ -10286,6 +10421,9 @@ opj_j2k_t* opj_j2k_create_decompress(void)
/* per component is allowed */
l_j2k->m_cp.allow_different_bit_depth_sign = 1;
/* Default to using strict mode. */
l_j2k->m_cp.strict = OPJ_TRUE;
#ifdef OPJ_DISABLE_TPSOT_FIX
l_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1;
#endif
@ -10585,9 +10723,10 @@ static OPJ_BOOL opj_j2k_read_SPCod_SPCoc(opj_j2k_t *p_j2k,
/* SPcod (G) / SPcoc (D) */
opj_read_bytes(l_current_ptr, &l_tccp->cblksty, 1);
++l_current_ptr;
if (l_tccp->cblksty & 0xC0U) { /* 2 msb are reserved, assume we can't read */
if ((l_tccp->cblksty & J2K_CCP_CBLKSTY_HTMIXED) != 0) {
/* We do not support HT mixed mode yet. For conformance, it should be supported.*/
opj_event_msg(p_manager, EVT_ERROR,
"Error reading SPCod SPCoc element, Invalid code-block style found\n");
"Error reading SPCod SPCoc element. Unsupported Mixed HT code-block style found\n");
return OPJ_FALSE;
}
@ -11610,7 +11749,7 @@ static OPJ_BOOL opj_j2k_decode_tiles(opj_j2k_t *p_j2k,
}
/**
* Sets up the procedures to do on decoding data. Developpers wanting to extend the library can add their own reading procedures.
* Sets up the procedures to do on decoding data. Developers wanting to extend the library can add their own reading procedures.
*/
static OPJ_BOOL opj_j2k_setup_decoding(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager)
@ -11742,7 +11881,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile(opj_j2k_t *p_j2k,
}
/**
* Sets up the procedures to do on decoding one tile. Developpers wanting to extend the library can add their own reading procedures.
* Sets up the procedures to do on decoding one tile. Developers wanting to extend the library can add their own reading procedures.
*/
static OPJ_BOOL opj_j2k_setup_decoding_tile(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager)
@ -11968,7 +12107,7 @@ OPJ_BOOL opj_j2k_get_tile(opj_j2k_t *p_j2k,
opj_image_destroy(p_j2k->m_output_image);
}
/* Create the ouput image from the information previously computed*/
/* Create the output image from the information previously computed*/
p_j2k->m_output_image = opj_image_create0();
if (!(p_j2k->m_output_image)) {
return OPJ_FALSE;
@ -12048,6 +12187,35 @@ OPJ_BOOL opj_j2k_encoder_set_extra_options(
"Invalid value for option: %s.\n", *p_option_iter);
return OPJ_FALSE;
}
} else if (strncmp(*p_option_iter, "TLM=", 4) == 0) {
if (strcmp(*p_option_iter, "TLM=YES") == 0) {
p_j2k->m_specific_param.m_encoder.m_TLM = OPJ_TRUE;
} else if (strcmp(*p_option_iter, "TLM=NO") == 0) {
p_j2k->m_specific_param.m_encoder.m_TLM = OPJ_FALSE;
} else {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid value for option: %s.\n", *p_option_iter);
return OPJ_FALSE;
}
} else if (strncmp(*p_option_iter, "GUARD_BITS=", strlen("GUARD_BITS=")) == 0) {
OPJ_UINT32 tileno;
opj_cp_t *cp = cp = &(p_j2k->m_cp);
int numgbits = atoi(*p_option_iter + strlen("GUARD_BITS="));
if (numgbits < 0 || numgbits > 7) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid value for option: %s. Should be in [0,7]\n", *p_option_iter);
return OPJ_FALSE;
}
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
OPJ_UINT32 i;
opj_tcp_t *tcp = &cp->tcps[tileno];
for (i = 0; i < p_j2k->m_specific_param.m_encoder.m_nb_comps; i++) {
opj_tccp_t *tccp = &tcp->tccps[i];
tccp->numgbits = (OPJ_UINT32)numgbits;
}
}
} else {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid option: %s.\n", *p_option_iter);
@ -12445,7 +12613,7 @@ static OPJ_BOOL opj_j2k_setup_end_compress(opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz) || OPJ_IS_IMF(p_j2k->m_cp.rsiz)) {
if (p_j2k->m_specific_param.m_encoder.m_TLM) {
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
(opj_procedure)opj_j2k_write_updated_tlm, p_manager)) {
return OPJ_FALSE;
@ -12528,7 +12696,7 @@ static OPJ_BOOL opj_j2k_setup_header_writing(opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz) || OPJ_IS_IMF(p_j2k->m_cp.rsiz)) {
if (p_j2k->m_specific_param.m_encoder.m_TLM) {
if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,
(opj_procedure)opj_j2k_write_tlm, p_manager)) {
return OPJ_FALSE;
@ -12661,7 +12829,7 @@ static OPJ_BOOL opj_j2k_write_first_tile_part(opj_j2k_t *p_j2k,
opj_write_bytes(l_begin_data + 6, l_nb_bytes_written,
4); /* PSOT */
if (OPJ_IS_CINEMA(l_cp->rsiz) || OPJ_IS_IMF(l_cp->rsiz)) {
if (p_j2k->m_specific_param.m_encoder.m_TLM) {
opj_j2k_update_tlm(p_j2k, l_nb_bytes_written);
}
@ -12731,7 +12899,7 @@ static OPJ_BOOL opj_j2k_write_all_tile_parts(opj_j2k_t *p_j2k,
opj_write_bytes(l_begin_data + 6, l_part_tile_size,
4); /* PSOT */
if (OPJ_IS_CINEMA(l_cp->rsiz) || OPJ_IS_IMF(l_cp->rsiz)) {
if (p_j2k->m_specific_param.m_encoder.m_TLM) {
opj_j2k_update_tlm(p_j2k, l_part_tile_size);
}
@ -12777,7 +12945,7 @@ static OPJ_BOOL opj_j2k_write_all_tile_parts(opj_j2k_t *p_j2k,
opj_write_bytes(l_begin_data + 6, l_part_tile_size,
4); /* PSOT */
if (OPJ_IS_CINEMA(l_cp->rsiz) || OPJ_IS_IMF(l_cp->rsiz)) {
if (p_j2k->m_specific_param.m_encoder.m_TLM) {
opj_j2k_update_tlm(p_j2k, l_part_tile_size);
}
@ -12796,13 +12964,16 @@ static OPJ_BOOL opj_j2k_write_updated_tlm(opj_j2k_t *p_j2k,
{
OPJ_UINT32 l_tlm_size;
OPJ_OFF_T l_tlm_position, l_current_position;
OPJ_UINT32 size_per_tile_part;
/* preconditions */
assert(p_j2k != 00);
assert(p_manager != 00);
assert(p_stream != 00);
l_tlm_size = 5 * p_j2k->m_specific_param.m_encoder.m_total_tile_parts;
size_per_tile_part = p_j2k->m_specific_param.m_encoder.m_Ttlmi_is_byte ? 5 : 6;
l_tlm_size = size_per_tile_part *
p_j2k->m_specific_param.m_encoder.m_total_tile_parts;
l_tlm_position = 6 + p_j2k->m_specific_param.m_encoder.m_tlm_start;
l_current_position = opj_stream_tell(p_stream);

@ -61,6 +61,8 @@ The functions in J2K.C have for goal to read/write the several parts of the code
#define J2K_CCP_CBLKSTY_VSC 0x08 /**< Vertically stripe causal context */
#define J2K_CCP_CBLKSTY_PTERM 0x10 /**< Predictable termination */
#define J2K_CCP_CBLKSTY_SEGSYM 0x20 /**< Segmentation symbols are used */
#define J2K_CCP_CBLKSTY_HT 0x40 /**< (high throughput) HT codeblocks */
#define J2K_CCP_CBLKSTY_HTMIXED 0x80 /**< MIXED mode HT codeblocks */
#define J2K_CCP_QNTSTY_NOQNT 0
#define J2K_CCP_QNTSTY_SIQNT 1
#define J2K_CCP_QNTSTY_SEQNT 2
@ -71,9 +73,11 @@ The functions in J2K.C have for goal to read/write the several parts of the code
#define J2K_MS_SOT 0xff90 /**< SOT marker value */
#define J2K_MS_SOD 0xff93 /**< SOD marker value */
#define J2K_MS_EOC 0xffd9 /**< EOC marker value */
#define J2K_MS_CAP 0xff50 /**< CAP marker value */
#define J2K_MS_SIZ 0xff51 /**< SIZ marker value */
#define J2K_MS_COD 0xff52 /**< COD marker value */
#define J2K_MS_COC 0xff53 /**< COC marker value */
#define J2K_MS_CPF 0xff59 /**< CPF marker value */
#define J2K_MS_RGN 0xff5e /**< RGN marker value */
#define J2K_MS_QCD 0xff5c /**< QCD marker value */
#define J2K_MS_QCC 0xff5d /**< QCC marker value */
@ -398,6 +402,8 @@ typedef struct opj_cp {
}
m_specific_param;
/** OPJ_TRUE if entire bit stream must be decoded, OPJ_FALSE if partial bitstream decoding allowed */
OPJ_BOOL strict;
/* UniPG>> */
#ifdef USE_JPWL
@ -503,6 +509,12 @@ typedef struct opj_j2k_enc {
/** Tile part number currently coding, taking into account POC. m_current_tile_part_number holds the total number of tile parts while encoding the last tile part.*/
OPJ_UINT32 m_current_tile_part_number; /*cur_tp_num */
/* whether to generate TLM markers */
OPJ_BOOL m_TLM;
/* whether the Ttlmi field in a TLM marker is a byte (otherwise a uint16) */
OPJ_BOOL m_Ttlmi_is_byte;
/**
locate the start position of the TLM marker
after encoding the tilepart, a jump (in j2k_write_sod) is done to the TLM marker to store the value of its length.
@ -540,6 +552,9 @@ typedef struct opj_j2k_enc {
/* reserved bytes in m_encoded_tile_size for PLT markers */
OPJ_UINT32 m_reserved_bytes_for_PLT;
/** Number of components */
OPJ_UINT32 m_nb_comps;
} opj_j2k_enc_t;
@ -612,6 +627,8 @@ Decoding parameters are returned in j2k->cp.
*/
void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
void opj_j2k_decoder_set_strict_mode(opj_j2k_t *j2k, OPJ_BOOL strict);
OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads);
/**

@ -331,14 +331,14 @@ static OPJ_BOOL opj_jp2_read_colr(opj_jp2_t *jp2,
/**
* Sets up the procedures to do on writing header after the codestream.
* Developpers wanting to extend the library can add their own writing procedures.
* Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_end_header_writing(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
/**
* Sets up the procedures to do on reading header after the codestream.
* Developpers wanting to extend the library can add their own writing procedures.
* Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_end_header_reading(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
@ -388,13 +388,13 @@ static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
/**
* Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
* are valid. Developpers wanting to extend the library can add their own validation procedures.
* are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_jp2_setup_encoding_validation(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
/**
* Sets up the procedures to do on writing header. Developpers wanting to extend the library can add their own writing procedures.
* Sets up the procedures to do on writing header. Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_header_writing(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
@ -457,14 +457,14 @@ static OPJ_BOOL opj_jp2_read_boxhdr_char(opj_jp2_box_t *box,
/**
* Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
* are valid. Developpers wanting to extend the library can add their own validation procedures.
* are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_jp2_setup_decoding_validation(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
/**
* Sets up the procedures to do on reading header.
* Developpers wanting to extend the library can add their own writing procedures.
* Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_header_reading(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
@ -1136,9 +1136,9 @@ static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image,
}
max = image->numcomps;
for (i = 0; i < max; ++i) {
if (old_comps[i].data) {
opj_image_data_free(old_comps[i].data);
for (j = 0; j < max; ++j) {
if (old_comps[j].data) {
opj_image_data_free(old_comps[j].data);
}
}
@ -1901,6 +1901,11 @@ void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
}
void opj_jp2_decoder_set_strict_mode(opj_jp2_t *jp2, OPJ_BOOL strict)
{
opj_j2k_decoder_set_strict_mode(jp2->j2k, strict);
}
OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads)
{
return opj_j2k_set_threads(jp2->j2k, num_threads);

@ -235,6 +235,15 @@ Decoding parameters are returned in jp2->j2k->cp.
*/
void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
/**
Set the strict mode parameter. When strict mode is enabled, the entire
bitstream must be decoded or an error is returned. When it is disabled,
the decoder will decode partial bitstreams.
@param jp2 JP2 decompressor handle
@param strict OPJ_TRUE for strict mode
*/
void opj_jp2_decoder_set_strict_mode(opj_jp2_t *jp2, OPJ_BOOL strict);
/** Allocates worker threads for the compressor/decompressor.
*
* @param jp2 JP2 decompressor handle

@ -0,0 +1,14 @@
prefix=@CMAKE_INSTALL_PREFIX@
bindir=${prefix}/@OPENJPEG_INSTALL_BIN_DIR@
mandir=${prefix}/@OPENJPEG_INSTALL_MAN_DIR@
docdir=${prefix}/@OPENJPEG_INSTALL_DOC_DIR@
libdir=${prefix}/@OPENJPEG_INSTALL_LIB_DIR@
includedir=${prefix}/@OPENJPEG_INSTALL_INCLUDE_DIR@
Name: openjp2
Description: JPEG2000 library (Part 1 and 2)
URL: http://www.openjpeg.org/
Version: @OPENJPEG_VERSION@
Libs: -L${libdir} -lopenjp2
Libs.private: -lm
Cflags: -I${includedir}

@ -457,7 +457,7 @@ void opj_calculate_norms(OPJ_FLOAT64 * pNorms,
for (j = 0; j < pNbComps; ++j) {
lCurrentValue = lMatrix[lIndex];
lIndex += pNbComps;
lNorms[i] += lCurrentValue * lCurrentValue;
lNorms[i] += (OPJ_FLOAT64) lCurrentValue * lCurrentValue;
}
lNorms[i] = sqrt(lNorms[i]);
}

@ -89,14 +89,16 @@ OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec,
/* ---------------------------------------------------------------------- */
static OPJ_SIZE_T opj_read_from_file(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
FILE * p_file)
void * p_user_data)
{
OPJ_SIZE_T l_nb_read = fread(p_buffer, 1, p_nb_bytes, p_file);
FILE* p_file = (FILE*)p_user_data;
OPJ_SIZE_T l_nb_read = fread(p_buffer, 1, p_nb_bytes, (FILE*)p_file);
return l_nb_read ? l_nb_read : (OPJ_SIZE_T) - 1;
}
static OPJ_UINT64 opj_get_data_length_from_file(FILE * p_file)
static OPJ_UINT64 opj_get_data_length_from_file(void * p_user_data)
{
FILE* p_file = (FILE*)p_user_data;
OPJ_OFF_T file_length = 0;
OPJ_FSEEK(p_file, 0, SEEK_END);
@ -107,29 +109,38 @@ static OPJ_UINT64 opj_get_data_length_from_file(FILE * p_file)
}
static OPJ_SIZE_T opj_write_from_file(void * p_buffer, OPJ_SIZE_T p_nb_bytes,
FILE * p_file)
void * p_user_data)
{
FILE* p_file = (FILE*)p_user_data;
return fwrite(p_buffer, 1, p_nb_bytes, p_file);
}
static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
static OPJ_OFF_T opj_skip_from_file(OPJ_OFF_T p_nb_bytes, void * p_user_data)
{
if (OPJ_FSEEK(p_user_data, p_nb_bytes, SEEK_CUR)) {
FILE* p_file = (FILE*)p_user_data;
if (OPJ_FSEEK(p_file, p_nb_bytes, SEEK_CUR)) {
return -1;
}
return p_nb_bytes;
}
static OPJ_BOOL opj_seek_from_file(OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
static OPJ_BOOL opj_seek_from_file(OPJ_OFF_T p_nb_bytes, void * p_user_data)
{
if (OPJ_FSEEK(p_user_data, p_nb_bytes, SEEK_SET)) {
FILE* p_file = (FILE*)p_user_data;
if (OPJ_FSEEK(p_file, p_nb_bytes, SEEK_SET)) {
return OPJ_FALSE;
}
return OPJ_TRUE;
}
static void opj_close_from_file(void* p_user_data)
{
FILE* p_file = (FILE*)p_user_data;
fclose(p_file);
}
/* ---------------------------------------------------------------------- */
#ifdef _WIN32
#ifndef OPJ_STATIC
@ -208,6 +219,10 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
(void (*)(void *, opj_dparameters_t *)) opj_j2k_setup_decoder;
l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
(void (*)(void *, OPJ_BOOL)) opj_j2k_decoder_set_strict_mode;
l_codec->m_codec_data.m_decompression.opj_read_tile_header =
(OPJ_BOOL(*)(void *,
OPJ_UINT32*,
@ -315,6 +330,9 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
(void (*)(void *, opj_dparameters_t *)) opj_jp2_setup_decoder;
l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
(void (*)(void *, OPJ_BOOL)) opj_jp2_decoder_set_strict_mode;
l_codec->m_codec_data.m_decompression.opj_set_decode_area =
(OPJ_BOOL(*)(void *,
opj_image_t*,
@ -415,6 +433,26 @@ OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
return OPJ_FALSE;
}
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
OPJ_BOOL strict)
{
if (p_codec) {
opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
if (! l_codec->is_decompressor) {
opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
"Codec provided to the opj_decoder_set_strict_mode function is not a decompressor handler.\n");
return OPJ_FALSE;
}
l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode(
l_codec->m_codec,
strict);
return OPJ_TRUE;
}
return OPJ_FALSE;
}
OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
opj_codec_t *p_codec,
opj_image_t **p_image)
@ -1074,15 +1112,14 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream(
return NULL;
}
opj_stream_set_user_data(l_stream, p_file,
(opj_stream_free_user_data_fn) fclose);
opj_stream_set_user_data(l_stream, p_file, opj_close_from_file);
opj_stream_set_user_data_length(l_stream,
opj_get_data_length_from_file(p_file));
opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_file);
opj_stream_set_read_function(l_stream, opj_read_from_file);
opj_stream_set_write_function(l_stream,
(opj_stream_write_fn) opj_write_from_file);
opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_file);
opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_file);
opj_stream_set_skip_function(l_stream, opj_skip_from_file);
opj_stream_set_seek_function(l_stream, opj_seek_from_file);
return l_stream;
}

@ -76,6 +76,12 @@ Most compilers implement their own version of this keyword ...
#define OPJ_DEPRECATED(func) func
#endif
#if defined(__GNUC__) && __GNUC__ >= 6
#define OPJ_DEPRECATED_STRUCT_MEMBER(memb, msg) __attribute__ ((deprecated(msg))) memb
#else
#define OPJ_DEPRECATED_STRUCT_MEMBER(memb, msg) memb
#endif
#if defined(OPJ_STATIC) || !defined(_WIN32)
/* http://gcc.gnu.org/wiki/Visibility */
# if !defined(_WIN32) && __GNUC__ >= 4
@ -449,9 +455,9 @@ typedef struct opj_cparameters {
char infile[OPJ_PATH_LEN];
/** output file name */
char outfile[OPJ_PATH_LEN];
/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
/** DEPRECATED. Index generation is now handled with the opj_encode_with_info() function. Set to NULL */
int index_on;
/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
/** DEPRECATED. Index generation is now handled with the opj_encode_with_info() function. Set to NULL */
char index[OPJ_PATH_LEN];
/** subimage encoding: origin image offset in x direction */
int image_offset_x0;
@ -681,10 +687,10 @@ typedef struct opj_image_comp {
OPJ_UINT32 x0;
/** y component offset compared to the whole image */
OPJ_UINT32 y0;
/** precision */
/** precision: number of bits per component per pixel */
OPJ_UINT32 prec;
/** image depth in bits */
OPJ_UINT32 bpp;
/** obsolete: use prec instead */
OPJ_DEPRECATED_STRUCT_MEMBER(OPJ_UINT32 bpp, "Use prec instead");
/** signed (1) / unsigned (0) */
OPJ_UINT32 sgnd;
/** number of decoded resolution */
@ -738,10 +744,10 @@ typedef struct opj_image_comptparm {
OPJ_UINT32 x0;
/** y component offset compared to the whole image */
OPJ_UINT32 y0;
/** precision */
/** precision: number of bits per component per pixel */
OPJ_UINT32 prec;
/** image depth in bits */
OPJ_UINT32 bpp;
/** obsolete: use prec instead */
OPJ_DEPRECATED_STRUCT_MEMBER(OPJ_UINT32 bpp, "Use prec instead");
/** signed (1) / unsigned (0) */
OPJ_UINT32 sgnd;
} opj_image_cmptparm_t;
@ -1339,6 +1345,20 @@ OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
opj_dparameters_t *parameters);
/**
* Set strict decoding parameter for this decoder. If strict decoding is enabled, partial bit
* streams will fail to decode. If strict decoding is disabled, the decoder will decode partial
* bitstreams as much as possible without erroring
*
* @param p_codec decompressor handler
* @param strict OPJ_TRUE to enable strict decoding, OPJ_FALSE to disable
*
* @return true if the decoder is correctly set
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
OPJ_BOOL strict);
/**
* Allocates worker threads for the compressor/decompressor.
*
@ -1447,7 +1467,7 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor,
* Get the decoded tile from the codec
*
* @param p_codec the jpeg2000 codec.
* @param p_stream input streamm
* @param p_stream input stream
* @param p_image output image
* @param tile_index index of the tile which will be decode
*
@ -1592,7 +1612,13 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
* <ul>
* <li>PLT=YES/NO. Defaults to NO. If set to YES, PLT marker segments,
* indicating the length of each packet in the tile-part header, will be
* written. Since 2.3.2</li>
* written. Since 2.4.0</li>
* <li>TLM=YES/NO. Defaults to NO (except for Cinema and IMF profiles).
* If set to YES, TLM marker segments, indicating the length of each
* tile-part part will be written. Since 2.4.0</li>
* <li>GUARD_BITS=value. Number of guard bits in [0,7] range. Default value is 2.
* 1 may be used sometimes (like in SMPTE DCP Bv2.1 Application Profile for 2K images).
* Since 2.5.0</li>
* </ul>
*
* @param p_codec Compressor handle
@ -1600,7 +1626,7 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
* array of strings. Each string is of the form KEY=VALUE.
*
* @return OPJ_TRUE in case of success.
* @since 2.3.2
* @since 2.4.0
*/
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encoder_set_extra_options(
opj_codec_t *p_codec,

@ -90,6 +90,9 @@ typedef struct opj_codec_private {
/** Setup decoder function handler */
void (*opj_setup_decoder)(void * p_codec, opj_dparameters_t * p_param);
/** Strict mode function handler */
void (*opj_decoder_set_strict_mode)(void * p_codec, OPJ_BOOL strict);
/** Set decode area function handler */
OPJ_BOOL(*opj_set_decode_area)(void * p_codec,
opj_image_t * p_image,

@ -276,6 +276,44 @@ static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b)
return (OPJ_INT32)(temp >> (13 + 11 - T1_NMSEDEC_FRACBITS)) ;
}
/**
Addition two signed integers with a wrap-around behaviour.
Assumes complement-to-two signed integers.
@param a
@param b
@return Returns a + b
*/
static INLINE OPJ_INT32 opj_int_add_no_overflow(OPJ_INT32 a, OPJ_INT32 b)
{
void* pa = &a;
void* pb = &b;
OPJ_UINT32* upa = (OPJ_UINT32*)pa;
OPJ_UINT32* upb = (OPJ_UINT32*)pb;
OPJ_UINT32 ures = *upa + *upb;
void* pures = &ures;
OPJ_INT32* ipres = (OPJ_INT32*)pures;
return *ipres;
}
/**
Subtract two signed integers with a wrap-around behaviour.
Assumes complement-to-two signed integers.
@param a
@param b
@return Returns a - b
*/
static INLINE OPJ_INT32 opj_int_sub_no_overflow(OPJ_INT32 a, OPJ_INT32 b)
{
void* pa = &a;
void* pb = &b;
OPJ_UINT32* upa = (OPJ_UINT32*)pa;
OPJ_UINT32* upb = (OPJ_UINT32*)pb;
OPJ_UINT32 ures = *upa - *upb;
void* pures = &ures;
OPJ_INT32* ipres = (OPJ_INT32*)pures;
return *ipres;
}
/* ----------------------------------------------------------------------- */
/*@}*/

@ -0,0 +1,210 @@
/*
* $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include "opj_includes.h"
/*
* Write faix box of phix
*
* @param[in] coff offset of j2k codestream
* @param[in] compno component number
* @param[in] cstr_info codestream information
* @param[in] EPHused true if if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of faix box
*/
int opj_write_phix(int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [8];
OPJ_UINT32 len, compno, i;
opj_jp2_box_t *box;
OPJ_OFF_T lenp = 0;
box = (opj_jp2_box_t *)opj_calloc((size_t)cstr_info.numcomps,
sizeof(opj_jp2_box_t));
if (box == NULL) {
return 0;
}
for (i = 0; i < 2; i++) {
if (i) {
opj_stream_seek(cio, lenp, p_manager);
}
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_PHIX, 4); /* PHIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_manf((int)i, cstr_info.numcomps, box, cio, p_manager);
for (compno = 0; compno < (OPJ_UINT32)cstr_info.numcomps; compno++) {
box[compno].length = (OPJ_UINT32)opj_write_phixfaix(coff, (int)compno,
cstr_info, EPHused, j2klen, cio, p_manager);
box[compno].type = JPIP_FAIX;
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, 4, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
}
opj_free(box);
return (int)len;
}
int opj_write_phixfaix(int coff, int compno, opj_codestream_info_t cstr_info,
OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_UINT32 tileno, version, i, nmax, size_of_coding; /* 4 or 8 */
opj_tile_info_t *tile_Idx;
opj_packet_info_t packet;
int resno, precno, layno;
OPJ_UINT32 num_packet;
int numOfres, numOfprec, numOflayers;
OPJ_BYTE l_data_header [8];
OPJ_OFF_T lenp;
OPJ_UINT32 len;
packet.end_ph_pos = packet.start_pos = -1;
(void)EPHused; /* unused ? */
if (j2klen > pow(2, 32)) {
size_of_coding = 8;
version = 1;
} else {
size_of_coding = 4;
version = 0;
}
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_FAIX, 4); /* FAIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_bytes(l_data_header, version, 1); /* Version 0 = 4 bytes */
opj_stream_write_data(cio, l_data_header, 1, p_manager);
nmax = 0;
for (i = 0; i <= (OPJ_UINT32)cstr_info.numdecompos[compno]; i++) {
nmax += (OPJ_UINT32)(cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] *
cstr_info.numlayers);
}
opj_write_bytes(l_data_header, nmax, size_of_coding); /* NMAX */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header, (OPJ_UINT32)(cstr_info.tw * cstr_info.th),
size_of_coding); /* M */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
for (tileno = 0; tileno < (OPJ_UINT32)(cstr_info.tw * cstr_info.th); tileno++) {
tile_Idx = &cstr_info.tile[ tileno];
num_packet = 0;
numOfres = cstr_info.numdecompos[compno] + 1;
for (resno = 0; resno < numOfres ; resno++) {
numOfprec = tile_Idx->pw[resno] * tile_Idx->ph[resno];
for (precno = 0; precno < numOfprec; precno++) {
numOflayers = cstr_info.numlayers;
for (layno = 0; layno < numOflayers; layno++) {
switch (cstr_info.prog) {
case OPJ_LRCP:
packet = tile_Idx->packet[((layno * numOfres + resno) * cstr_info.numcomps +
compno) * numOfprec + precno];
break;
case OPJ_RLCP:
packet = tile_Idx->packet[((resno * numOflayers + layno) * cstr_info.numcomps +
compno) * numOfprec + precno];
break;
case OPJ_RPCL:
packet = tile_Idx->packet[((resno * numOfprec + precno) * cstr_info.numcomps +
compno) * numOflayers + layno];
break;
case OPJ_PCRL:
packet = tile_Idx->packet[((precno * cstr_info.numcomps + compno) * numOfres +
resno) * numOflayers + layno];
break;
case OPJ_CPRL:
packet = tile_Idx->packet[((compno * numOfprec + precno) * numOfres + resno) *
numOflayers + layno];
break;
default:
fprintf(stderr, "failed to ppix indexing\n");
}
opj_write_bytes(l_data_header, (OPJ_UINT32)(packet.start_pos - coff),
size_of_coding); /* start position */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header,
(OPJ_UINT32)(packet.end_ph_pos - packet.start_pos + 1),
size_of_coding); /* length */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
num_packet++;
}
}
}
/* PADDING */
while (num_packet < nmax) {
opj_write_bytes(l_data_header, 0,
size_of_coding); /* start position */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header, 0,
size_of_coding); /* length */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
num_packet++;
}
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
return (int)len;
}

@ -943,7 +943,7 @@ static void opj_get_all_encoding_parameters(const opj_image_t *p_image,
*p_dy_min = 0x7fffffff;
for (compno = 0; compno < p_image->numcomps; ++compno) {
/* aritmetic variables to calculate*/
/* arithmetic variables to calculate*/
OPJ_UINT32 l_level_no;
OPJ_UINT32 l_rx0, l_ry0, l_rx1, l_ry1;
OPJ_UINT32 l_px0, l_py0, l_px1, py1;
@ -1225,7 +1225,7 @@ static void opj_pi_update_decode_poc(opj_pi_iterator_t * p_pi,
/* loop*/
OPJ_UINT32 pino;
/* encoding prameters to set*/
/* encoding parameters to set*/
OPJ_UINT32 l_bound;
opj_pi_iterator_t * l_current_pi = 00;
@ -1272,7 +1272,7 @@ static void opj_pi_update_decode_not_poc(opj_pi_iterator_t * p_pi,
/* loop*/
OPJ_UINT32 pino;
/* encoding prameters to set*/
/* encoding parameters to set*/
OPJ_UINT32 l_bound;
opj_pi_iterator_t * l_current_pi = 00;
@ -1312,7 +1312,7 @@ static OPJ_BOOL opj_pi_check_next_level(OPJ_INT32 pos,
opj_poc_t *tcp = &tcps->pocs[pino];
if (pos >= 0) {
for (i = pos; pos >= 0; i--) {
for (i = pos; i >= 0; i--) {
switch (prog[i]) {
case 'R':
if (tcp->res_t == tcp->resE) {
@ -1401,11 +1401,11 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
OPJ_UINT32 pino;
OPJ_UINT32 compno, resno;
/* to store w, h, dx and dy fro all components and resolutions */
/* to store w, h, dx and dy for all components and resolutions */
OPJ_UINT32 * l_tmp_data;
OPJ_UINT32 ** l_tmp_ptr;
/* encoding prameters to set */
/* encoding parameters to set */
OPJ_UINT32 l_max_res;
OPJ_UINT32 l_max_prec;
OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;
@ -1624,11 +1624,11 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
OPJ_UINT32 pino;
OPJ_UINT32 compno, resno;
/* to store w, h, dx and dy fro all components and resolutions*/
/* to store w, h, dx and dy for all components and resolutions*/
OPJ_UINT32 * l_tmp_data;
OPJ_UINT32 ** l_tmp_ptr;
/* encoding prameters to set*/
/* encoding parameters to set*/
OPJ_UINT32 l_max_res;
OPJ_UINT32 l_max_prec;
OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;

@ -0,0 +1,215 @@
/*
* $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include "opj_includes.h"
/*
* Write faix box of ppix
*
* @param[in] coff offset of j2k codestream
* @param[in] compno component number
* @param[in] cstr_info codestream information
* @param[in] EPHused true if if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of faix box
*/
int opj_write_ppix(int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused,
int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [4];
int compno, i;
opj_jp2_box_t *box;
OPJ_OFF_T lenp;
OPJ_UINT32 len;
/* printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */
lenp = -1;
box = (opj_jp2_box_t *)opj_calloc((size_t)cstr_info.numcomps,
sizeof(opj_jp2_box_t));
if (box == NULL) {
return 0;
}
for (i = 0; i < 2; i++) {
if (i)
{
opj_stream_seek(cio, lenp, p_manager);
}
lenp = (OPJ_UINT32)(opj_stream_tell(cio));
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_PPIX, 4); /* PPIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_manf(i, cstr_info.numcomps, box, cio, p_manager);
for (compno = 0; compno < cstr_info.numcomps; compno++) {
box[compno].length = (OPJ_UINT32)opj_write_ppixfaix(coff, compno, cstr_info,
EPHused, j2klen, cio, p_manager);
box[compno].type = JPIP_FAIX;
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
}
opj_free(box);
return (int)len;
}
int opj_write_ppixfaix(int coff, int compno, opj_codestream_info_t cstr_info,
OPJ_BOOL EPHused, int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [8];
OPJ_UINT32 tileno, version, i, nmax, size_of_coding; /* 4 or 8*/
OPJ_UINT32 len;
OPJ_OFF_T lenp;
opj_tile_info_t *tile_Idx;
opj_packet_info_t packet;
int resno, precno, layno;
OPJ_UINT32 num_packet;
int numOfres, numOfprec, numOflayers;
packet.end_pos = packet.end_ph_pos = packet.start_pos = -1;
(void)EPHused; /* unused ? */
if (j2klen > pow(2, 32)) {
size_of_coding = 8;
version = 1;
} else {
size_of_coding = 4;
version = 0;
}
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_FAIX, 4); /* FAIX */
opj_write_bytes(l_data_header, version, 1);
opj_stream_write_data(cio, l_data_header, 1,
p_manager); /* Version 0 = 4 bytes */
nmax = 0;
for (i = 0; i <= (OPJ_UINT32)cstr_info.numdecompos[compno]; i++) {
nmax += (OPJ_UINT32)(cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] *
cstr_info.numlayers);
}
opj_write_bytes(l_data_header, nmax, size_of_coding); /* NMAX */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header, (OPJ_UINT32)(cstr_info.tw * cstr_info.th),
size_of_coding); /* M */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
for (tileno = 0; tileno < (OPJ_UINT32)(cstr_info.tw * cstr_info.th); tileno++) {
tile_Idx = &cstr_info.tile[ tileno];
num_packet = 0;
numOfres = cstr_info.numdecompos[compno] + 1;
for (resno = 0; resno < numOfres ; resno++) {
numOfprec = tile_Idx->pw[resno] * tile_Idx->ph[resno];
for (precno = 0; precno < numOfprec; precno++) {
numOflayers = cstr_info.numlayers;
for (layno = 0; layno < numOflayers; layno++) {
switch (cstr_info.prog) {
case OPJ_LRCP:
packet = tile_Idx->packet[((layno * numOfres + resno) * cstr_info.numcomps +
compno) * numOfprec + precno];
break;
case OPJ_RLCP:
packet = tile_Idx->packet[((resno * numOflayers + layno) * cstr_info.numcomps +
compno) * numOfprec + precno];
break;
case OPJ_RPCL:
packet = tile_Idx->packet[((resno * numOfprec + precno) * cstr_info.numcomps +
compno) * numOflayers + layno];
break;
case OPJ_PCRL:
packet = tile_Idx->packet[((precno * cstr_info.numcomps + compno) * numOfres +
resno) * numOflayers + layno];
break;
case OPJ_CPRL:
packet = tile_Idx->packet[((compno * numOfprec + precno) * numOfres + resno) *
numOflayers + layno];
break;
default:
fprintf(stderr, "failed to ppix indexing\n");
}
opj_write_bytes(l_data_header, (OPJ_UINT32)(packet.start_pos - coff),
size_of_coding); /* start position */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header,
(OPJ_UINT32)(packet.end_pos - packet.start_pos + 1),
size_of_coding); /* length */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
num_packet++;
}
}
}
while (num_packet < nmax) { /* PADDING */
opj_write_bytes(l_data_header, 0,
size_of_coding); /* start position */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header, 0,
size_of_coding); /* length */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
num_packet++;
}
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
return (int)len;
}

@ -69,7 +69,7 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
return NULL;
}
sa->data_blocks = (OPJ_INT32**) opj_calloc(sizeof(OPJ_INT32*),
sa->block_count_hor * sa->block_count_ver);
(size_t) sa->block_count_hor * sa->block_count_ver);
if (sa->data_blocks == NULL) {
opj_free(sa);
return NULL;
@ -235,7 +235,7 @@ static OPJ_BOOL opj_sparse_array_int32_read_or_write(
} else {
if (src_block == NULL) {
src_block = (OPJ_INT32*) opj_calloc(1,
sa->block_width * sa->block_height * sizeof(OPJ_INT32));
(size_t) sa->block_width * sa->block_height * sizeof(OPJ_INT32));
if (src_block == NULL) {
return OPJ_FALSE;
}

@ -217,6 +217,27 @@ static OPJ_BOOL opj_t1_decode_cblk(opj_t1_t *t1,
opj_mutex_t* p_manager_mutex,
OPJ_BOOL check_pterm);
/**
Decode 1 HT code-block
@param t1 T1 handle
@param cblk Code-block coding parameters
@param orient
@param roishift Region of interest shifting value
@param cblksty Code-block style
@param p_manager the event manager
@param p_manager_mutex mutex for the event manager
@param check_pterm whether PTERM correct termination should be checked
*/
OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
opj_tcd_cblk_dec_t* cblk,
OPJ_UINT32 orient,
OPJ_UINT32 roishift,
OPJ_UINT32 cblksty,
opj_event_mgr_t *p_manager,
opj_mutex_t* p_manager_mutex,
OPJ_BOOL check_pterm);
static OPJ_BOOL opj_t1_allocate_buffers(opj_t1_t *t1,
OPJ_UINT32 w,
OPJ_UINT32 h);
@ -1665,18 +1686,34 @@ static void opj_t1_clbl_decode_processor(void* user_data, opj_tls_t* tls)
}
t1->mustuse_cblkdatabuffer = job->mustuse_cblkdatabuffer;
if (OPJ_FALSE == opj_t1_decode_cblk(
t1,
cblk,
band->bandno,
(OPJ_UINT32)tccp->roishift,
tccp->cblksty,
job->p_manager,
job->p_manager_mutex,
job->check_pterm)) {
*(job->pret) = OPJ_FALSE;
opj_free(job);
return;
if ((tccp->cblksty & J2K_CCP_CBLKSTY_HT) != 0) {
if (OPJ_FALSE == opj_t1_ht_decode_cblk(
t1,
cblk,
band->bandno,
(OPJ_UINT32)tccp->roishift,
tccp->cblksty,
job->p_manager,
job->p_manager_mutex,
job->check_pterm)) {
*(job->pret) = OPJ_FALSE;
opj_free(job);
return;
}
} else {
if (OPJ_FALSE == opj_t1_decode_cblk(
t1,
cblk,
band->bandno,
(OPJ_UINT32)tccp->roishift,
tccp->cblksty,
job->p_manager,
job->p_manager_mutex,
job->check_pterm)) {
*(job->pret) = OPJ_FALSE;
opj_free(job);
return;
}
}
x = cblk->x0 - band->x0;

@ -200,7 +200,7 @@ typedef struct opj_t1 {
OPJ_UINT32 flagssize;
OPJ_BOOL encoder;
/* Thre 3 variables below are only used by the decoder */
/* The 3 variables below are only used by the decoder */
/* set to TRUE in multithreaded context */
OPJ_BOOL mustuse_cblkdatabuffer;
/* Temporary buffer to concatenate all chunks of a codebock */

@ -0,0 +1,323 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
* Copyright (c) 2003-2007, Francois-Olivier Devaux
* Copyright (c) 2003-2014, Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
* Copyright (c) 2012, Carl Hetherington
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "opj_includes.h"
// defined elsewhere
extern OPJ_BOOL vlc_init_tables();
extern OPJ_BOOL vlc_tables_initialized;
extern int vlc_tbl0[1024];
extern int vlc_tbl1[1024];
static int t1_init_ctxno_zc(OPJ_UINT32 f, OPJ_UINT32 orient)
{
int h, v, d, n, t, hv;
n = 0;
h = ((f & T1_SIGMA_3) != 0) + ((f & T1_SIGMA_5) != 0);
v = ((f & T1_SIGMA_1) != 0) + ((f & T1_SIGMA_7) != 0);
d = ((f & T1_SIGMA_0) != 0) + ((f & T1_SIGMA_2) != 0) + ((
f & T1_SIGMA_8) != 0) + ((f & T1_SIGMA_6) != 0);
switch (orient) {
case 2:
t = h;
h = v;
v = t;
case 0:
case 1:
if (!h) {
if (!v) {
if (!d) {
n = 0;
} else if (d == 1) {
n = 1;
} else {
n = 2;
}
} else if (v == 1) {
n = 3;
} else {
n = 4;
}
} else if (h == 1) {
if (!v) {
if (!d) {
n = 5;
} else {
n = 6;
}
} else {
n = 7;
}
} else {
n = 8;
}
break;
case 3:
hv = h + v;
if (!d) {
if (!hv) {
n = 0;
} else if (hv == 1) {
n = 1;
} else {
n = 2;
}
} else if (d == 1) {
if (!hv) {
n = 3;
} else if (hv == 1) {
n = 4;
} else {
n = 5;
}
} else if (d == 2) {
if (!hv) {
n = 6;
} else {
n = 7;
}
} else {
n = 8;
}
break;
}
return (T1_CTXNO_ZC + n);
}
static int t1_init_ctxno_sc(OPJ_UINT32 f)
{
int hc, vc, n;
n = 0;
hc = opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
T1_LUT_SIG_E) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == T1_LUT_SIG_W),
1) - opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
(T1_LUT_SIG_E | T1_LUT_SGN_E)) +
((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) ==
(T1_LUT_SIG_W | T1_LUT_SGN_W)), 1);
vc = opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
T1_LUT_SIG_N) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == T1_LUT_SIG_S),
1) - opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
(T1_LUT_SIG_N | T1_LUT_SGN_N)) +
((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) ==
(T1_LUT_SIG_S | T1_LUT_SGN_S)), 1);
if (hc < 0) {
hc = -hc;
vc = -vc;
}
if (!hc) {
if (vc == -1) {
n = 1;
} else if (!vc) {
n = 0;
} else {
n = 1;
}
} else if (hc == 1) {
if (vc == -1) {
n = 2;
} else if (!vc) {
n = 3;
} else {
n = 4;
}
}
return (T1_CTXNO_SC + n);
}
static int t1_init_spb(OPJ_UINT32 f)
{
int hc, vc, n;
hc = opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
T1_LUT_SIG_E) + ((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) == T1_LUT_SIG_W),
1) - opj_int_min(((f & (T1_LUT_SIG_E | T1_LUT_SGN_E)) ==
(T1_LUT_SIG_E | T1_LUT_SGN_E)) +
((f & (T1_LUT_SIG_W | T1_LUT_SGN_W)) ==
(T1_LUT_SIG_W | T1_LUT_SGN_W)), 1);
vc = opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
T1_LUT_SIG_N) + ((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) == T1_LUT_SIG_S),
1) - opj_int_min(((f & (T1_LUT_SIG_N | T1_LUT_SGN_N)) ==
(T1_LUT_SIG_N | T1_LUT_SGN_N)) +
((f & (T1_LUT_SIG_S | T1_LUT_SGN_S)) ==
(T1_LUT_SIG_S | T1_LUT_SGN_S)), 1);
if (!hc && !vc) {
n = 0;
} else {
n = (!(hc > 0 || (!hc && vc > 0)));
}
return n;
}
static void dump_array16(int array[], int size)
{
int i;
--size;
for (i = 0; i < size; ++i) {
printf("0x%04x,", array[i]);
if (!((i + 1) & 0x7)) {
printf("\n ");
} else {
printf(" ");
}
}
printf("0x%04x\n};\n\n", array[size]);
}
int main(int argc, char **argv)
{
unsigned int i, j;
double u, v, t;
int lut_ctxno_zc[2048];
int lut_nmsedec_sig[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_sig0[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
int lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
(void)argc;
(void)argv;
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
/* lut_ctxno_zc */
for (j = 0; j < 4; ++j) {
for (i = 0; i < 512; ++i) {
OPJ_UINT32 orient = j;
if (orient == 2) {
orient = 1;
} else if (orient == 1) {
orient = 2;
}
lut_ctxno_zc[(orient << 9) | i] = t1_init_ctxno_zc(i, j);
}
}
printf("static const OPJ_BYTE lut_ctxno_zc[2048] = {\n ");
for (i = 0; i < 2047; ++i) {
printf("%i,", lut_ctxno_zc[i]);
if (!((i + 1) & 0x1f)) {
printf("\n ");
} else {
printf(" ");
}
}
printf("%i\n};\n\n", lut_ctxno_zc[2047]);
/* lut_ctxno_sc */
printf("static const OPJ_BYTE lut_ctxno_sc[256] = {\n ");
for (i = 0; i < 255; ++i) {
printf("0x%x,", t1_init_ctxno_sc(i));
if (!((i + 1) & 0xf)) {
printf("\n ");
} else {
printf(" ");
}
}
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255));
/* lut_spb */
printf("static const OPJ_BYTE lut_spb[256] = {\n ");
for (i = 0; i < 255; ++i) {
printf("%i,", t1_init_spb(i));
if (!((i + 1) & 0x1f)) {
printf("\n ");
} else {
printf(" ");
}
}
printf("%i\n};\n\n", t1_init_spb(255));
/* FIXME FIXME FIXME */
/* fprintf(stdout,"nmsedec luts:\n"); */
for (i = 0U; i < (1U << T1_NMSEDEC_BITS); ++i) {
t = i / pow(2, T1_NMSEDEC_FRACBITS);
u = t;
v = t - 1.5;
lut_nmsedec_sig[i] =
opj_int_max(0,
(int)(floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2,
T1_NMSEDEC_FRACBITS) * 8192.0));
lut_nmsedec_sig0[i] =
opj_int_max(0,
(int)(floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2,
T1_NMSEDEC_FRACBITS) * 8192.0));
u = t - 1.0;
if (i & (1 << (T1_NMSEDEC_BITS - 1))) {
v = t - 1.5;
} else {
v = t - 0.5;
}
lut_nmsedec_ref[i] =
opj_int_max(0,
(int)(floor((u * u - v * v) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2,
T1_NMSEDEC_FRACBITS) * 8192.0));
lut_nmsedec_ref0[i] =
opj_int_max(0,
(int)(floor((u * u) * pow(2, T1_NMSEDEC_FRACBITS) + 0.5) / pow(2,
T1_NMSEDEC_FRACBITS) * 8192.0));
}
printf("static const OPJ_INT16 lut_nmsedec_sig[1U << T1_NMSEDEC_BITS] = {\n ");
dump_array16(lut_nmsedec_sig, 1U << T1_NMSEDEC_BITS);
printf("static const OPJ_INT16 lut_nmsedec_sig0[1U << T1_NMSEDEC_BITS] = {\n ");
dump_array16(lut_nmsedec_sig0, 1U << T1_NMSEDEC_BITS);
printf("static const OPJ_INT16 lut_nmsedec_ref[1U << T1_NMSEDEC_BITS] = {\n ");
dump_array16(lut_nmsedec_ref, 1U << T1_NMSEDEC_BITS);
printf("static const OPJ_INT16 lut_nmsedec_ref0[1U << T1_NMSEDEC_BITS] = {\n ");
dump_array16(lut_nmsedec_ref0, 1U << T1_NMSEDEC_BITS);
vlc_tables_initialized = vlc_init_tables();
printf("static const OPJ_UINT16 vlc_tbl0[1024] = {\n ");
dump_array16(vlc_tbl0, 1024);
printf("static const OPJ_UINT16 vlc_tbl1[1024] = {\n ");
dump_array16(vlc_tbl1, 1024);
return 0;
}

@ -0,0 +1,973 @@
//***************************************************************************/
// This software is released under the 2-Clause BSD license, included
// below.
//
// Copyright (c) 2021, Aous Naman
// Copyright (c) 2021, Kakadu Software Pty Ltd, Australia
// Copyright (c) 2021, The University of New South Wales, Australia
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//***************************************************************************/
// This file is part of the OpenJpeg software implementation.
// File: t1_ht_generate_luts.c
// Author: Aous Naman
// Date: 01 September 2021
//***************************************************************************/
#include <string.h>
#include <stdio.h>
#include <assert.h>
typedef int OPJ_BOOL;
#define OPJ_TRUE 1
#define OPJ_FALSE 0
#include "opj_stdint.h"
typedef int8_t OPJ_INT8;
typedef uint8_t OPJ_UINT8;
typedef int16_t OPJ_INT16;
typedef uint16_t OPJ_UINT16;
typedef int32_t OPJ_INT32;
typedef uint32_t OPJ_UINT32;
typedef int64_t OPJ_INT64;
typedef uint64_t OPJ_UINT64;
//************************************************************************/
/** @brief HT decoding tables, as given in the standard
*
* Data in the table is arranged in this format:
* c_q is the context for a quad
* rho is the signficance pattern for a quad
* u_off indicate if u value is 0 (u_off is 0), or communicated
* e_k, e_1 EMB patterns
* cwd VLC codeword
* cwd VLC codeword length
*/
typedef struct vlc_src_table {
int c_q, rho, u_off, e_k, e_1, cwd, cwd_len;
}
vlc_src_table_t;
// initial quad rows
static vlc_src_table_t tbl0[] = {
{0, 0x1, 0x0, 0x0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0x0, 0x0, 0x00, 3},
{7, 0xF, 0x1, 0xF, 0xF, 0x6B, 7},
{7, 0xF, 0x1, 0xF, 0x7, 0x2B, 7},
{7, 0xF, 0x1, 0xF, 0xB, 0x4B, 7},
{7, 0xF, 0x1, 0xF, 0x3, 0x11, 6},
{7, 0xF, 0x1, 0x7, 0x6, 0x21, 6},
{7, 0xF, 0x1, 0xF, 0xA, 0x01, 6},
{7, 0xF, 0x1, 0xF, 0x2, 0x0A, 5},
{7, 0xF, 0x1, 0xB, 0x9, 0x1E, 6},
{7, 0xF, 0x1, 0xF, 0xC, 0x0E, 6},
{7, 0xF, 0x1, 0xF, 0x8, 0x12, 5},
{7, 0xF, 0x1, 0xF, 0x5, 0x2E, 6},
{7, 0xF, 0x1, 0xF, 0x1, 0x02, 5},
{7, 0xF, 0x1, 0xF, 0x4, 0x1C, 5}
};
//************************************************************************/
/** @defgroup vlc_decoding_tables_grp VLC decoding tables
* @{
* VLC tables to decode VLC codewords to these fields: (in order) \n
* \li \c cwd_len : 3bits -> the codeword length of the VLC codeword;
* the VLC cwd is in the LSB of bitstream \n
* \li \c u_off : 1bit -> u_offset, which is 1 if u value is not 0 \n
* \li \c rho : 4bits -> significant samples within a quad \n
* \li \c e_1 : 4bits -> EMB e_1 \n
* \li \c e_k : 4bits -> EMB e_k \n
* \n
* The table index is 10 bits and composed of two parts: \n
* The 7 LSBs contain a codeword which might be shorter than 7 bits;
* this word is the next decoable bits in the bitstream. \n
* The 3 MSB is the context of for the codeword. \n
*/
/// @brief vlc_tbl0 contains decoding information for initial row of quads
int vlc_tbl0[1024] = { 0 };
/// @brief vlc_tbl1 contains decoding information for non-initial row of
/// quads
int vlc_tbl1[1024] = { 0 };
/// @}
//************************************************************************/
/** @ingroup vlc_decoding_tables_grp
* @brief Initializes vlc_tbl0 and vlc_tbl1 tables, from table0.h and
* table1.h
*/
OPJ_BOOL vlc_init_tables()
{
const OPJ_BOOL debug = OPJ_FALSE; //useful for checking
// number of entries in the table
size_t tbl0_size = sizeof(tbl0) / sizeof(vlc_src_table_t);
// number of entries in the table
size_t tbl1_size = sizeof(tbl1) / sizeof(vlc_src_table_t);
if (debug) {
memset(vlc_tbl0, 0, sizeof(vlc_tbl0)); //unnecessary
}
// this is to convert table entries into values for decoder look up
// There can be at most 1024 possibilities, not all of them are valid.
//
for (int i = 0; i < 1024; ++i) {
int cwd = i & 0x7F; // from i extract codeword
int c_q = i >> 7; // from i extract context
// See if this case exist in the table, if so then set the entry in
// vlc_tbl0
for (size_t j = 0; j < tbl0_size; ++j)
if (tbl0[j].c_q == c_q) // this is an and operation
if (tbl0[j].cwd == (cwd & ((1 << tbl0[j].cwd_len) - 1))) {
if (debug) {
assert(vlc_tbl0[i] == 0);
}
// Put this entry into the table
vlc_tbl0[i] = (tbl0[j].rho << 4) | (tbl0[j].u_off << 3)
| (tbl0[j].e_k << 12) | (tbl0[j].e_1 << 8) | tbl0[j].cwd_len;
}
}
if (debug) {
memset(vlc_tbl1, 0, sizeof(vlc_tbl1)); //unnecessary
}
// this the same as above but for non-initial rows
for (int i = 0; i < 1024; ++i) {
int cwd = i & 0x7F; //7 bits
int c_q = i >> 7;
for (size_t j = 0; j < tbl1_size; ++j)
if (tbl1[j].c_q == c_q) // this is an and operation
if (tbl1[j].cwd == (cwd & ((1 << tbl1[j].cwd_len) - 1))) {
if (debug) {
assert(vlc_tbl1[i] == 0);
}
vlc_tbl1[i] = (tbl1[j].rho << 4) | (tbl1[j].u_off << 3)
| (tbl1[j].e_k << 12) | (tbl1[j].e_1 << 8) | tbl1[j].cwd_len;
}
}
return OPJ_TRUE;
}
//************************************************************************/
/** @ingroup vlc_decoding_tables_grp
* @brief Initializes VLC tables vlc_tbl0 and vlc_tbl1
*/
OPJ_BOOL vlc_tables_initialized = OPJ_FALSE;

@ -0,0 +1,261 @@
static const OPJ_UINT16 vlc_tbl0[1024] = {
0x0023, 0x00a5, 0x0043, 0x0066, 0x0083, 0xa8ee, 0x0014, 0xd8df,
0x0023, 0x10be, 0x0043, 0xf5ff, 0x0083, 0x207e, 0x0055, 0x515f,
0x0023, 0x0035, 0x0043, 0x444e, 0x0083, 0xc4ce, 0x0014, 0xcccf,
0x0023, 0xe2fe, 0x0043, 0x99ff, 0x0083, 0x0096, 0x00c5, 0x313f,
0x0023, 0x00a5, 0x0043, 0x445e, 0x0083, 0xc8ce, 0x0014, 0x11df,
0x0023, 0xf4fe, 0x0043, 0xfcff, 0x0083, 0x009e, 0x0055, 0x0077,
0x0023, 0x0035, 0x0043, 0xf1ff, 0x0083, 0x88ae, 0x0014, 0x00b7,
0x0023, 0xf8fe, 0x0043, 0xe4ef, 0x0083, 0x888e, 0x00c5, 0x111f,
0x0023, 0x00a5, 0x0043, 0x0066, 0x0083, 0xa8ee, 0x0014, 0x54df,
0x0023, 0x10be, 0x0043, 0x22ef, 0x0083, 0x207e, 0x0055, 0x227f,
0x0023, 0x0035, 0x0043, 0x444e, 0x0083, 0xc4ce, 0x0014, 0x11bf,
0x0023, 0xe2fe, 0x0043, 0x00f7, 0x0083, 0x0096, 0x00c5, 0x223f,
0x0023, 0x00a5, 0x0043, 0x445e, 0x0083, 0xc8ce, 0x0014, 0x00d7,
0x0023, 0xf4fe, 0x0043, 0xbaff, 0x0083, 0x009e, 0x0055, 0x006f,
0x0023, 0x0035, 0x0043, 0xe6ff, 0x0083, 0x88ae, 0x0014, 0xa2af,
0x0023, 0xf8fe, 0x0043, 0x00e7, 0x0083, 0x888e, 0x00c5, 0x222f,
0x0002, 0x00c5, 0x0084, 0x207e, 0x0002, 0xc4ce, 0x0024, 0x00f7,
0x0002, 0xa2fe, 0x0044, 0x0056, 0x0002, 0x009e, 0x0014, 0x00d7,
0x0002, 0x10be, 0x0084, 0x0066, 0x0002, 0x88ae, 0x0024, 0x11df,
0x0002, 0xa8ee, 0x0044, 0x0036, 0x0002, 0x888e, 0x0014, 0x111f,
0x0002, 0x00c5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0x88ff,
0x0002, 0xb8fe, 0x0044, 0x444e, 0x0002, 0x0096, 0x0014, 0x00b7,
0x0002, 0xe4fe, 0x0084, 0x445e, 0x0002, 0x00a6, 0x0024, 0x00e7,
0x0002, 0x54de, 0x0044, 0x222e, 0x0002, 0x003e, 0x0014, 0x0077,
0x0002, 0x00c5, 0x0084, 0x207e, 0x0002, 0xc4ce, 0x0024, 0xf1ff,
0x0002, 0xa2fe, 0x0044, 0x0056, 0x0002, 0x009e, 0x0014, 0x11bf,
0x0002, 0x10be, 0x0084, 0x0066, 0x0002, 0x88ae, 0x0024, 0x22ef,
0x0002, 0xa8ee, 0x0044, 0x0036, 0x0002, 0x888e, 0x0014, 0x227f,
0x0002, 0x00c5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0xe4ef,
0x0002, 0xb8fe, 0x0044, 0x444e, 0x0002, 0x0096, 0x0014, 0xa2af,
0x0002, 0xe4fe, 0x0084, 0x445e, 0x0002, 0x00a6, 0x0024, 0xd8df,
0x0002, 0x54de, 0x0044, 0x222e, 0x0002, 0x003e, 0x0014, 0x515f,
0x0002, 0x0055, 0x0084, 0x0066, 0x0002, 0x88de, 0x0024, 0x32ff,
0x0002, 0x11fe, 0x0044, 0x444e, 0x0002, 0x00ae, 0x0014, 0x00b7,
0x0002, 0x317e, 0x0084, 0x515e, 0x0002, 0x00c6, 0x0024, 0x00d7,
0x0002, 0x20ee, 0x0044, 0x111e, 0x0002, 0x009e, 0x0014, 0x0077,
0x0002, 0x0055, 0x0084, 0x545e, 0x0002, 0x44ce, 0x0024, 0x00e7,
0x0002, 0xf1fe, 0x0044, 0x0036, 0x0002, 0x00a6, 0x0014, 0x555f,
0x0002, 0x74fe, 0x0084, 0x113e, 0x0002, 0x20be, 0x0024, 0x747f,
0x0002, 0xc4de, 0x0044, 0xf8ff, 0x0002, 0x0096, 0x0014, 0x222f,
0x0002, 0x0055, 0x0084, 0x0066, 0x0002, 0x88de, 0x0024, 0x00f7,
0x0002, 0x11fe, 0x0044, 0x444e, 0x0002, 0x00ae, 0x0014, 0x888f,
0x0002, 0x317e, 0x0084, 0x515e, 0x0002, 0x00c6, 0x0024, 0xc8cf,
0x0002, 0x20ee, 0x0044, 0x111e, 0x0002, 0x009e, 0x0014, 0x006f,
0x0002, 0x0055, 0x0084, 0x545e, 0x0002, 0x44ce, 0x0024, 0xd1df,
0x0002, 0xf1fe, 0x0044, 0x0036, 0x0002, 0x00a6, 0x0014, 0x227f,
0x0002, 0x74fe, 0x0084, 0x113e, 0x0002, 0x20be, 0x0024, 0x22bf,
0x0002, 0xc4de, 0x0044, 0x22ef, 0x0002, 0x0096, 0x0014, 0x323f,
0x0003, 0xd4de, 0xf4fd, 0xfcff, 0x0014, 0x113e, 0x0055, 0x888f,
0x0003, 0x32be, 0x0085, 0x00e7, 0x0025, 0x515e, 0xaafe, 0x727f,
0x0003, 0x44ce, 0xf8fd, 0x44ef, 0x0014, 0x647e, 0x0045, 0xa2af,
0x0003, 0x00a6, 0x555d, 0x99df, 0xf1fd, 0x0036, 0xf5fe, 0x626f,
0x0003, 0xd1de, 0xf4fd, 0xe6ff, 0x0014, 0x717e, 0x0055, 0xb1bf,
0x0003, 0x88ae, 0x0085, 0xd5df, 0x0025, 0x444e, 0xf2fe, 0x667f,
0x0003, 0x00c6, 0xf8fd, 0xe2ef, 0x0014, 0x545e, 0x0045, 0x119f,
0x0003, 0x0096, 0x555d, 0xc8cf, 0xf1fd, 0x111e, 0xc8ee, 0x0067,
0x0003, 0xd4de, 0xf4fd, 0xf3ff, 0x0014, 0x113e, 0x0055, 0x11bf,
0x0003, 0x32be, 0x0085, 0xd8df, 0x0025, 0x515e, 0xaafe, 0x222f,
0x0003, 0x44ce, 0xf8fd, 0x00f7, 0x0014, 0x647e, 0x0045, 0x989f,
0x0003, 0x00a6, 0x555d, 0x00d7, 0xf1fd, 0x0036, 0xf5fe, 0x446f,
0x0003, 0xd1de, 0xf4fd, 0xb9ff, 0x0014, 0x717e, 0x0055, 0x00b7,
0x0003, 0x88ae, 0x0085, 0xdcdf, 0x0025, 0x444e, 0xf2fe, 0x0077,
0x0003, 0x00c6, 0xf8fd, 0xe4ef, 0x0014, 0x545e, 0x0045, 0x737f,
0x0003, 0x0096, 0x555d, 0xb8bf, 0xf1fd, 0x111e, 0xc8ee, 0x323f,
0x0002, 0x00a5, 0x0084, 0x407e, 0x0002, 0x10de, 0x0024, 0x11df,
0x0002, 0x72fe, 0x0044, 0x0056, 0x0002, 0xa8ae, 0x0014, 0xb2bf,
0x0002, 0x0096, 0x0084, 0x0066, 0x0002, 0x00c6, 0x0024, 0x00e7,
0x0002, 0xc8ee, 0x0044, 0x222e, 0x0002, 0x888e, 0x0014, 0x0077,
0x0002, 0x00a5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0x00f7,
0x0002, 0x91fe, 0x0044, 0x0036, 0x0002, 0xa2ae, 0x0014, 0xaaaf,
0x0002, 0xb8fe, 0x0084, 0x005e, 0x0002, 0x00be, 0x0024, 0xc4cf,
0x0002, 0x44ee, 0x0044, 0xf4ff, 0x0002, 0x223e, 0x0014, 0x111f,
0x0002, 0x00a5, 0x0084, 0x407e, 0x0002, 0x10de, 0x0024, 0x99ff,
0x0002, 0x72fe, 0x0044, 0x0056, 0x0002, 0xa8ae, 0x0014, 0x00b7,
0x0002, 0x0096, 0x0084, 0x0066, 0x0002, 0x00c6, 0x0024, 0x00d7,
0x0002, 0xc8ee, 0x0044, 0x222e, 0x0002, 0x888e, 0x0014, 0x444f,
0x0002, 0x00a5, 0x0084, 0x006e, 0x0002, 0x88ce, 0x0024, 0xe2ef,
0x0002, 0x91fe, 0x0044, 0x0036, 0x0002, 0xa2ae, 0x0014, 0x447f,
0x0002, 0xb8fe, 0x0084, 0x005e, 0x0002, 0x00be, 0x0024, 0x009f,
0x0002, 0x44ee, 0x0044, 0x76ff, 0x0002, 0x223e, 0x0014, 0x313f,
0x0003, 0x00c6, 0x0085, 0xd9ff, 0xf2fd, 0x647e, 0xf1fe, 0x99bf,
0x0003, 0xa2ae, 0x0025, 0x66ef, 0xf4fd, 0x0056, 0xe2ee, 0x737f,
0x0003, 0x98be, 0x0045, 0x00f7, 0xf8fd, 0x0066, 0x76fe, 0x889f,
0x0003, 0x888e, 0x0015, 0xd5df, 0x00a5, 0x222e, 0x98de, 0x444f,
0x0003, 0xb2be, 0x0085, 0xfcff, 0xf2fd, 0x226e, 0x0096, 0x00b7,
0x0003, 0xaaae, 0x0025, 0xd1df, 0xf4fd, 0x0036, 0xd4de, 0x646f,
0x0003, 0xa8ae, 0x0045, 0xeaef, 0xf8fd, 0x445e, 0xe8ee, 0x717f,
0x0003, 0x323e, 0x0015, 0xc4cf, 0x00a5, 0xfaff, 0x88ce, 0x313f,
0x0003, 0x00c6, 0x0085, 0x77ff, 0xf2fd, 0x647e, 0xf1fe, 0xb3bf,
0x0003, 0xa2ae, 0x0025, 0x00e7, 0xf4fd, 0x0056, 0xe2ee, 0x0077,
0x0003, 0x98be, 0x0045, 0xe4ef, 0xf8fd, 0x0066, 0x76fe, 0x667f,
0x0003, 0x888e, 0x0015, 0x00d7, 0x00a5, 0x222e, 0x98de, 0x333f,
0x0003, 0xb2be, 0x0085, 0x75ff, 0xf2fd, 0x226e, 0x0096, 0x919f,
0x0003, 0xaaae, 0x0025, 0x99df, 0xf4fd, 0x0036, 0xd4de, 0x515f,
0x0003, 0xa8ae, 0x0045, 0xecef, 0xf8fd, 0x445e, 0xe8ee, 0x727f,
0x0003, 0x323e, 0x0015, 0xb1bf, 0x00a5, 0xf3ff, 0x88ce, 0x111f,
0x0003, 0x54de, 0xf2fd, 0x111e, 0x0014, 0x647e, 0xf8fe, 0xcccf,
0x0003, 0x91be, 0x0045, 0x22ef, 0x0025, 0x222e, 0xf3fe, 0x888f,
0x0003, 0x00c6, 0x0085, 0x00f7, 0x0014, 0x115e, 0xfcfe, 0xa8af,
0x0003, 0x00a6, 0x0035, 0xc8df, 0xf1fd, 0x313e, 0x66fe, 0x646f,
0x0003, 0xc8ce, 0xf2fd, 0xf5ff, 0x0014, 0x0066, 0xf4fe, 0xbabf,
0x0003, 0x22ae, 0x0045, 0x00e7, 0x0025, 0x323e, 0xeafe, 0x737f,
0x0003, 0xb2be, 0x0085, 0x55df, 0x0014, 0x0056, 0x717e, 0x119f,
0x0003, 0x0096, 0x0035, 0xc4cf, 0xf1fd, 0x333e, 0xe8ee, 0x444f,
0x0003, 0x54de, 0xf2fd, 0x111e, 0x0014, 0x647e, 0xf8fe, 0x99bf,
0x0003, 0x91be, 0x0045, 0xe2ef, 0x0025, 0x222e, 0xf3fe, 0x667f,
0x0003, 0x00c6, 0x0085, 0xe4ef, 0x0014, 0x115e, 0xfcfe, 0x989f,
0x0003, 0x00a6, 0x0035, 0x00d7, 0xf1fd, 0x313e, 0x66fe, 0x226f,
0x0003, 0xc8ce, 0xf2fd, 0xb9ff, 0x0014, 0x0066, 0xf4fe, 0x00b7,
0x0003, 0x22ae, 0x0045, 0xd1df, 0x0025, 0x323e, 0xeafe, 0x0077,
0x0003, 0xb2be, 0x0085, 0xecef, 0x0014, 0x0056, 0x717e, 0x727f,
0x0003, 0x0096, 0x0035, 0xb8bf, 0xf1fd, 0x333e, 0xe8ee, 0x545f,
0xf1fc, 0xd1de, 0xfafd, 0x00d7, 0xf8fc, 0x0016, 0xfffd, 0x747f,
0xf4fc, 0x717e, 0xf3fd, 0xb3bf, 0xf2fc, 0xeaef, 0xe8ee, 0x444f,
0xf1fc, 0x22ae, 0x0005, 0xb8bf, 0xf8fc, 0x00f7, 0xfcfe, 0x0077,
0xf4fc, 0x115e, 0xf5fd, 0x757f, 0xf2fc, 0xd8df, 0xe2ee, 0x333f,
0xf1fc, 0xb2be, 0xfafd, 0x88cf, 0xf8fc, 0xfbff, 0xfffd, 0x737f,
0xf4fc, 0x006e, 0xf3fd, 0x00b7, 0xf2fc, 0x66ef, 0xf9fe, 0x313f,
0xf1fc, 0x009e, 0x0005, 0xbabf, 0xf8fc, 0xfdff, 0xf6fe, 0x0067,
0xf4fc, 0x0026, 0xf5fd, 0x888f, 0xf2fc, 0xdcdf, 0xd4de, 0x222f,
0xf1fc, 0xd1de, 0xfafd, 0xc4cf, 0xf8fc, 0x0016, 0xfffd, 0x727f,
0xf4fc, 0x717e, 0xf3fd, 0x99bf, 0xf2fc, 0xecef, 0xe8ee, 0x0047,
0xf1fc, 0x22ae, 0x0005, 0x00a7, 0xf8fc, 0xf7ff, 0xfcfe, 0x0057,
0xf4fc, 0x115e, 0xf5fd, 0x0097, 0xf2fc, 0xd5df, 0xe2ee, 0x0037,
0xf1fc, 0xb2be, 0xfafd, 0x00c7, 0xf8fc, 0xfeff, 0xfffd, 0x667f,
0xf4fc, 0x006e, 0xf3fd, 0xa8af, 0xf2fc, 0x00e7, 0xf9fe, 0x323f,
0xf1fc, 0x009e, 0x0005, 0xb1bf, 0xf8fc, 0xe4ef, 0xf6fe, 0x545f,
0xf4fc, 0x0026, 0xf5fd, 0x0087, 0xf2fc, 0x99df, 0xd4de, 0x111f
};
static const OPJ_UINT16 vlc_tbl1[1024] = {
0x0013, 0x0065, 0x0043, 0x00de, 0x0083, 0x888d, 0x0023, 0x444e,
0x0013, 0x00a5, 0x0043, 0x88ae, 0x0083, 0x0035, 0x0023, 0x00d7,
0x0013, 0x00c5, 0x0043, 0x009e, 0x0083, 0x0055, 0x0023, 0x222e,
0x0013, 0x0095, 0x0043, 0x007e, 0x0083, 0x10fe, 0x0023, 0x0077,
0x0013, 0x0065, 0x0043, 0x88ce, 0x0083, 0x888d, 0x0023, 0x111e,
0x0013, 0x00a5, 0x0043, 0x005e, 0x0083, 0x0035, 0x0023, 0x00e7,
0x0013, 0x00c5, 0x0043, 0x00be, 0x0083, 0x0055, 0x0023, 0x11ff,
0x0013, 0x0095, 0x0043, 0x003e, 0x0083, 0x40ee, 0x0023, 0xa2af,
0x0013, 0x0065, 0x0043, 0x00de, 0x0083, 0x888d, 0x0023, 0x444e,
0x0013, 0x00a5, 0x0043, 0x88ae, 0x0083, 0x0035, 0x0023, 0x44ef,
0x0013, 0x00c5, 0x0043, 0x009e, 0x0083, 0x0055, 0x0023, 0x222e,
0x0013, 0x0095, 0x0043, 0x007e, 0x0083, 0x10fe, 0x0023, 0x00b7,
0x0013, 0x0065, 0x0043, 0x88ce, 0x0083, 0x888d, 0x0023, 0x111e,
0x0013, 0x00a5, 0x0043, 0x005e, 0x0083, 0x0035, 0x0023, 0xc4cf,
0x0013, 0x00c5, 0x0043, 0x00be, 0x0083, 0x0055, 0x0023, 0x00f7,
0x0013, 0x0095, 0x0043, 0x003e, 0x0083, 0x40ee, 0x0023, 0x006f,
0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0014, 0x0001, 0x00d7,
0x0001, 0x0024, 0x0001, 0x0096, 0x0001, 0x0045, 0x0001, 0x0077,
0x0001, 0x0084, 0x0001, 0x00c6, 0x0001, 0x0014, 0x0001, 0x888f,
0x0001, 0x0024, 0x0001, 0x00f7, 0x0001, 0x0035, 0x0001, 0x222f,
0x0001, 0x0084, 0x0001, 0x40fe, 0x0001, 0x0014, 0x0001, 0x00b7,
0x0001, 0x0024, 0x0001, 0x00bf, 0x0001, 0x0045, 0x0001, 0x0067,
0x0001, 0x0084, 0x0001, 0x00a6, 0x0001, 0x0014, 0x0001, 0x444f,
0x0001, 0x0024, 0x0001, 0x00e7, 0x0001, 0x0035, 0x0001, 0x113f,
0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0014, 0x0001, 0x00cf,
0x0001, 0x0024, 0x0001, 0x0096, 0x0001, 0x0045, 0x0001, 0x006f,
0x0001, 0x0084, 0x0001, 0x00c6, 0x0001, 0x0014, 0x0001, 0x009f,
0x0001, 0x0024, 0x0001, 0x00ef, 0x0001, 0x0035, 0x0001, 0x323f,
0x0001, 0x0084, 0x0001, 0x40fe, 0x0001, 0x0014, 0x0001, 0x00af,
0x0001, 0x0024, 0x0001, 0x44ff, 0x0001, 0x0045, 0x0001, 0x005f,
0x0001, 0x0084, 0x0001, 0x00a6, 0x0001, 0x0014, 0x0001, 0x007f,
0x0001, 0x0024, 0x0001, 0x00df, 0x0001, 0x0035, 0x0001, 0x111f,
0x0001, 0x0024, 0x0001, 0x0056, 0x0001, 0x0085, 0x0001, 0x00bf,
0x0001, 0x0014, 0x0001, 0x00f7, 0x0001, 0x00c6, 0x0001, 0x0077,
0x0001, 0x0024, 0x0001, 0xf8ff, 0x0001, 0x0045, 0x0001, 0x007f,
0x0001, 0x0014, 0x0001, 0x00df, 0x0001, 0x00a6, 0x0001, 0x313f,
0x0001, 0x0024, 0x0001, 0x222e, 0x0001, 0x0085, 0x0001, 0x00b7,
0x0001, 0x0014, 0x0001, 0x44ef, 0x0001, 0xa2ae, 0x0001, 0x0067,
0x0001, 0x0024, 0x0001, 0x51ff, 0x0001, 0x0045, 0x0001, 0x0097,
0x0001, 0x0014, 0x0001, 0x00cf, 0x0001, 0x0036, 0x0001, 0x223f,
0x0001, 0x0024, 0x0001, 0x0056, 0x0001, 0x0085, 0x0001, 0xb2bf,
0x0001, 0x0014, 0x0001, 0x40ef, 0x0001, 0x00c6, 0x0001, 0x006f,
0x0001, 0x0024, 0x0001, 0x72ff, 0x0001, 0x0045, 0x0001, 0x009f,
0x0001, 0x0014, 0x0001, 0x00d7, 0x0001, 0x00a6, 0x0001, 0x444f,
0x0001, 0x0024, 0x0001, 0x222e, 0x0001, 0x0085, 0x0001, 0xa8af,
0x0001, 0x0014, 0x0001, 0x00e7, 0x0001, 0xa2ae, 0x0001, 0x005f,
0x0001, 0x0024, 0x0001, 0x44ff, 0x0001, 0x0045, 0x0001, 0x888f,
0x0001, 0x0014, 0x0001, 0xaaaf, 0x0001, 0x0036, 0x0001, 0x111f,
0x0002, 0xf8fe, 0x0024, 0x0056, 0x0002, 0x00b6, 0x0085, 0x66ff,
0x0002, 0x00ce, 0x0014, 0x111e, 0x0002, 0x0096, 0x0035, 0xa8af,
0x0002, 0x00f6, 0x0024, 0x313e, 0x0002, 0x00a6, 0x0045, 0xb3bf,
0x0002, 0xb2be, 0x0014, 0xf5ff, 0x0002, 0x0066, 0x517e, 0x545f,
0x0002, 0xf2fe, 0x0024, 0x222e, 0x0002, 0x22ae, 0x0085, 0x44ef,
0x0002, 0x00c6, 0x0014, 0xf4ff, 0x0002, 0x0076, 0x0035, 0x447f,
0x0002, 0x40de, 0x0024, 0x323e, 0x0002, 0x009e, 0x0045, 0x00d7,
0x0002, 0x88be, 0x0014, 0xfaff, 0x0002, 0x115e, 0xf1fe, 0x444f,
0x0002, 0xf8fe, 0x0024, 0x0056, 0x0002, 0x00b6, 0x0085, 0xc8ef,
0x0002, 0x00ce, 0x0014, 0x111e, 0x0002, 0x0096, 0x0035, 0x888f,
0x0002, 0x00f6, 0x0024, 0x313e, 0x0002, 0x00a6, 0x0045, 0x44df,
0x0002, 0xb2be, 0x0014, 0xa8ff, 0x0002, 0x0066, 0x517e, 0x006f,
0x0002, 0xf2fe, 0x0024, 0x222e, 0x0002, 0x22ae, 0x0085, 0x00e7,
0x0002, 0x00c6, 0x0014, 0xe2ef, 0x0002, 0x0076, 0x0035, 0x727f,
0x0002, 0x40de, 0x0024, 0x323e, 0x0002, 0x009e, 0x0045, 0xb1bf,
0x0002, 0x88be, 0x0014, 0x73ff, 0x0002, 0x115e, 0xf1fe, 0x333f,
0x0001, 0x0084, 0x0001, 0x20ee, 0x0001, 0x00c5, 0x0001, 0xc4cf,
0x0001, 0x0044, 0x0001, 0x32ff, 0x0001, 0x0015, 0x0001, 0x888f,
0x0001, 0x0084, 0x0001, 0x0066, 0x0001, 0x0025, 0x0001, 0x00af,
0x0001, 0x0044, 0x0001, 0x22ef, 0x0001, 0x00a6, 0x0001, 0x005f,
0x0001, 0x0084, 0x0001, 0x444e, 0x0001, 0x00c5, 0x0001, 0xcccf,
0x0001, 0x0044, 0x0001, 0x00f7, 0x0001, 0x0015, 0x0001, 0x006f,
0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0025, 0x0001, 0x009f,
0x0001, 0x0044, 0x0001, 0x00df, 0x0001, 0x30fe, 0x0001, 0x222f,
0x0001, 0x0084, 0x0001, 0x20ee, 0x0001, 0x00c5, 0x0001, 0xc8cf,
0x0001, 0x0044, 0x0001, 0x11ff, 0x0001, 0x0015, 0x0001, 0x0077,
0x0001, 0x0084, 0x0001, 0x0066, 0x0001, 0x0025, 0x0001, 0x007f,
0x0001, 0x0044, 0x0001, 0x00e7, 0x0001, 0x00a6, 0x0001, 0x0037,
0x0001, 0x0084, 0x0001, 0x444e, 0x0001, 0x00c5, 0x0001, 0x00b7,
0x0001, 0x0044, 0x0001, 0x00bf, 0x0001, 0x0015, 0x0001, 0x003f,
0x0001, 0x0084, 0x0001, 0x0056, 0x0001, 0x0025, 0x0001, 0x0097,
0x0001, 0x0044, 0x0001, 0x00d7, 0x0001, 0x30fe, 0x0001, 0x111f,
0x0002, 0xa8ee, 0x0044, 0x888e, 0x0002, 0x00d6, 0x00c5, 0xf3ff,
0x0002, 0xfcfe, 0x0025, 0x003e, 0x0002, 0x00b6, 0x0055, 0xd8df,
0x0002, 0xf8fe, 0x0044, 0x0066, 0x0002, 0x207e, 0x0085, 0x99ff,
0x0002, 0x00e6, 0x00f5, 0x0036, 0x0002, 0x00a6, 0x0015, 0x009f,
0x0002, 0xf2fe, 0x0044, 0x0076, 0x0002, 0x44ce, 0x00c5, 0x76ff,
0x0002, 0xf1fe, 0x0025, 0x444e, 0x0002, 0x00ae, 0x0055, 0xc8cf,
0x0002, 0xf4fe, 0x0044, 0x445e, 0x0002, 0x10be, 0x0085, 0xe4ef,
0x0002, 0x54de, 0x00f5, 0x111e, 0x0002, 0x0096, 0x0015, 0x222f,
0x0002, 0xa8ee, 0x0044, 0x888e, 0x0002, 0x00d6, 0x00c5, 0xfaff,
0x0002, 0xfcfe, 0x0025, 0x003e, 0x0002, 0x00b6, 0x0055, 0x11bf,
0x0002, 0xf8fe, 0x0044, 0x0066, 0x0002, 0x207e, 0x0085, 0x22ef,
0x0002, 0x00e6, 0x00f5, 0x0036, 0x0002, 0x00a6, 0x0015, 0x227f,
0x0002, 0xf2fe, 0x0044, 0x0076, 0x0002, 0x44ce, 0x00c5, 0xd5ff,
0x0002, 0xf1fe, 0x0025, 0x444e, 0x0002, 0x00ae, 0x0055, 0x006f,
0x0002, 0xf4fe, 0x0044, 0x445e, 0x0002, 0x10be, 0x0085, 0x11df,
0x0002, 0x54de, 0x00f5, 0x111e, 0x0002, 0x0096, 0x0015, 0x515f,
0x0003, 0x00f6, 0x0014, 0x111e, 0x0044, 0x888e, 0x00a5, 0xd4df,
0x0003, 0xa2ae, 0x0055, 0x76ff, 0x0024, 0x223e, 0x00b6, 0xaaaf,
0x0003, 0x00e6, 0x0014, 0xf5ff, 0x0044, 0x0066, 0x0085, 0xcccf,
0x0003, 0x009e, 0x00c5, 0x44ef, 0x0024, 0x0036, 0xf8fe, 0x317f,
0x0003, 0xe8ee, 0x0014, 0xf1ff, 0x0044, 0x0076, 0x00a5, 0xc4cf,
0x0003, 0x227e, 0x0055, 0xd1df, 0x0024, 0x444e, 0xf4fe, 0x515f,
0x0003, 0x00d6, 0x0014, 0xe2ef, 0x0044, 0x445e, 0x0085, 0x22bf,
0x0003, 0x0096, 0x00c5, 0xc8df, 0x0024, 0x222e, 0xf2fe, 0x226f,
0x0003, 0x00f6, 0x0014, 0x111e, 0x0044, 0x888e, 0x00a5, 0xb1bf,
0x0003, 0xa2ae, 0x0055, 0x33ff, 0x0024, 0x223e, 0x00b6, 0xa8af,
0x0003, 0x00e6, 0x0014, 0xb9ff, 0x0044, 0x0066, 0x0085, 0xa8bf,
0x0003, 0x009e, 0x00c5, 0xe4ef, 0x0024, 0x0036, 0xf8fe, 0x646f,
0x0003, 0xe8ee, 0x0014, 0xfcff, 0x0044, 0x0076, 0x00a5, 0xc8cf,
0x0003, 0x227e, 0x0055, 0xeaef, 0x0024, 0x444e, 0xf4fe, 0x747f,
0x0003, 0x00d6, 0x0014, 0xfaff, 0x0044, 0x445e, 0x0085, 0xb2bf,
0x0003, 0x0096, 0x00c5, 0x44df, 0x0024, 0x222e, 0xf2fe, 0x313f,
0x00f3, 0xfafe, 0xf1fd, 0x0036, 0x0004, 0x32be, 0x0075, 0x11df,
0x00f3, 0x54de, 0xf2fd, 0xe4ef, 0x00d5, 0x717e, 0xfcfe, 0x737f,
0x00f3, 0xf3fe, 0xf8fd, 0x111e, 0x0004, 0x0096, 0x0055, 0xb1bf,
0x00f3, 0x00ce, 0x00b5, 0xd8df, 0xf4fd, 0x0066, 0xb9fe, 0x545f,
0x00f3, 0x76fe, 0xf1fd, 0x0026, 0x0004, 0x00a6, 0x0075, 0x009f,
0x00f3, 0x00ae, 0xf2fd, 0xf7ff, 0x00d5, 0x0046, 0xf5fe, 0x747f,
0x00f3, 0x00e6, 0xf8fd, 0x0016, 0x0004, 0x0086, 0x0055, 0x888f,
0x00f3, 0x00c6, 0x00b5, 0xe2ef, 0xf4fd, 0x115e, 0xa8ee, 0x113f,
0x00f3, 0xfafe, 0xf1fd, 0x0036, 0x0004, 0x32be, 0x0075, 0xd1df,
0x00f3, 0x54de, 0xf2fd, 0xfbff, 0x00d5, 0x717e, 0xfcfe, 0x447f,
0x00f3, 0xf3fe, 0xf8fd, 0x111e, 0x0004, 0x0096, 0x0055, 0x727f,
0x00f3, 0x00ce, 0x00b5, 0x22ef, 0xf4fd, 0x0066, 0xb9fe, 0x444f,
0x00f3, 0x76fe, 0xf1fd, 0x0026, 0x0004, 0x00a6, 0x0075, 0x11bf,
0x00f3, 0x00ae, 0xf2fd, 0xffff, 0x00d5, 0x0046, 0xf5fe, 0x323f,
0x00f3, 0x00e6, 0xf8fd, 0x0016, 0x0004, 0x0086, 0x0055, 0x006f,
0x00f3, 0x00c6, 0x00b5, 0xb8bf, 0xf4fd, 0x115e, 0xa8ee, 0x222f
};

@ -502,7 +502,6 @@ OPJ_BOOL opj_t2_decode_packets(opj_tcd_t* tcd,
l_current_pi->precno, l_current_pi->layno, skip_packet ? "skipped" : "kept");
*/
}
if (!skip_packet) {
l_nb_bytes_read = 0;
@ -1124,7 +1123,7 @@ static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
/*
When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
This part deal with this caracteristic
This part deal with this characteristic
step 1: Read packet header in the saved structure
step 2: Return to codestream for decoding
*/
@ -1229,6 +1228,7 @@ static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
++i;
}
l_cblk->Mb = (OPJ_UINT32)l_band->numbps;
l_cblk->numbps = (OPJ_UINT32)l_band->numbps + 1 - i;
l_cblk->numlenbits = 3;
}
@ -1258,34 +1258,63 @@ static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
}
n = (OPJ_INT32)l_cblk->numnewpasses;
do {
OPJ_UINT32 bit_number;
l_cblk->segs[l_segno].numnewpasses = (OPJ_UINT32)opj_int_min((OPJ_INT32)(
l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses), n);
bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
l_cblk->segs[l_segno].numnewpasses);
if (bit_number > 32) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid bit number %d in opj_t2_read_packet_header()\n",
bit_number);
opj_bio_destroy(l_bio);
return OPJ_FALSE;
}
l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
l_cblk->segs[l_segno].newlen);
if ((p_tcp->tccps[p_pi->compno].cblksty & J2K_CCP_CBLKSTY_HT) != 0)
do {
OPJ_UINT32 bit_number;
l_cblk->segs[l_segno].numnewpasses = l_segno == 0 ? 1 : (OPJ_UINT32)n;
bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
l_cblk->segs[l_segno].numnewpasses);
if (bit_number > 32) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid bit number %d in opj_t2_read_packet_header()\n",
bit_number);
opj_bio_destroy(l_bio);
return OPJ_FALSE;
}
l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
l_cblk->segs[l_segno].newlen);
n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
if (n > 0) {
++l_segno;
n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
if (n > 0) {
++l_segno;
if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
opj_bio_destroy(l_bio);
return OPJ_FALSE;
}
}
} while (n > 0);
else
do {
OPJ_UINT32 bit_number;
l_cblk->segs[l_segno].numnewpasses = (OPJ_UINT32)opj_int_min((OPJ_INT32)(
l_cblk->segs[l_segno].maxpasses - l_cblk->segs[l_segno].numpasses), n);
bit_number = l_cblk->numlenbits + opj_uint_floorlog2(
l_cblk->segs[l_segno].numnewpasses);
if (bit_number > 32) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid bit number %d in opj_t2_read_packet_header()\n",
bit_number);
opj_bio_destroy(l_bio);
return OPJ_FALSE;
}
}
} while (n > 0);
l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number);
JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n",
l_included, l_cblk->segs[l_segno].numnewpasses, l_increment,
l_cblk->segs[l_segno].newlen);
n -= (OPJ_INT32)l_cblk->segs[l_segno].numnewpasses;
if (n > 0) {
++l_segno;
if (! opj_t2_init_seg(l_cblk, l_segno, p_tcp->tccps[p_pi->compno].cblksty, 0)) {
opj_bio_destroy(l_bio);
return OPJ_FALSE;
}
}
} while (n > 0);
++l_cblk;
}
@ -1348,6 +1377,7 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
opj_tcd_cblk_dec_t* l_cblk = 00;
opj_tcd_resolution_t* l_res =
&p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
OPJ_BOOL partial_buffer = OPJ_FALSE;
OPJ_ARG_NOT_USED(p_t2);
OPJ_ARG_NOT_USED(pack_info);
@ -1367,6 +1397,12 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
opj_tcd_seg_t *l_seg = 00;
// if we have a partial data stream, set numchunks to zero
// since we have no data to actually decode.
if (partial_buffer) {
l_cblk->numchunks = 0;
}
if (!l_cblk->numnewpasses) {
/* nothing to do */
++l_cblk;
@ -1389,12 +1425,32 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
/* Check possible overflow (on l_current_data only, assumes input args already checked) then size */
if ((((OPJ_SIZE_T)l_current_data + (OPJ_SIZE_T)l_seg->newlen) <
(OPJ_SIZE_T)l_current_data) ||
(l_current_data + l_seg->newlen > p_src_data + p_max_length)) {
opj_event_msg(p_manager, EVT_ERROR,
"read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
return OPJ_FALSE;
(l_current_data + l_seg->newlen > p_src_data + p_max_length) ||
(partial_buffer)) {
if (p_t2->cp->strict) {
opj_event_msg(p_manager, EVT_ERROR,
"read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
return OPJ_FALSE;
} else {
opj_event_msg(p_manager, EVT_WARNING,
"read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
// skip this codeblock since it is a partial read
partial_buffer = OPJ_TRUE;
l_cblk->numchunks = 0;
l_seg->numpasses += l_seg->numnewpasses;
l_cblk->numnewpasses -= l_seg->numnewpasses;
if (l_cblk->numnewpasses > 0) {
++l_seg;
++l_cblk->numsegs;
break;
}
continue;
}
}
#ifdef USE_JPWL
@ -1456,8 +1512,12 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
++l_band;
}
*(p_data_read) = (OPJ_UINT32)(l_current_data - p_src_data);
// return the number of bytes read
if (partial_buffer) {
*(p_data_read) = p_max_length;
} else {
*(p_data_read) = (OPJ_UINT32)(l_current_data - p_src_data);
}
return OPJ_TRUE;
}
@ -1519,11 +1579,18 @@ static OPJ_BOOL opj_t2_skip_packet_data(opj_t2_t* p_t2,
/* Check possible overflow then size */
if (((*p_data_read + l_seg->newlen) < (*p_data_read)) ||
((*p_data_read + l_seg->newlen) > p_max_length)) {
opj_event_msg(p_manager, EVT_ERROR,
"skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
return OPJ_FALSE;
if (p_t2->cp->strict) {
opj_event_msg(p_manager, EVT_ERROR,
"skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
return OPJ_FALSE;
} else {
opj_event_msg(p_manager, EVT_WARNING,
"skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
}
}
#ifdef USE_JPWL

@ -122,6 +122,11 @@ typedef struct opj_tcd_cblk_dec {
opj_tcd_seg_data_chunk_t* chunks; /* Array of chunks */
/* position of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
OPJ_INT32 x0, y0, x1, y1;
/* Mb is The maximum number of bit-planes available for the representation of
coefficients in any sub-band, b, as defined in Equation (E-2). See
Section B.10.5 of the standard */
OPJ_UINT32 Mb; /* currently used only to check if HT decoding is correct */
/* numbps is Mb - P as defined in Section B.10.5 of the standard */
OPJ_UINT32 numbps;
/* number of bits for len, for the current packet. Transitory value */
OPJ_UINT32 numlenbits;

@ -0,0 +1,174 @@
/*
* The copyright in this software is being made available under the 2-clauses
* BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
* Copyright (c) 2017, IntoPix SA <contact@intopix.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#undef NDEBUG
#include "opj_includes.h"
int main()
{
OPJ_UINT32 i, j, w, h;
OPJ_INT32 buffer[ 99 * 101 ];
OPJ_BOOL ret;
opj_sparse_array_int32_t* sa;
sa = opj_sparse_array_int32_create(0, 1, 1, 1);
assert(sa == NULL);
opj_sparse_array_int32_free(sa);
sa = opj_sparse_array_int32_create(1, 0, 1, 1);
assert(sa == NULL);
sa = opj_sparse_array_int32_create(1, 1, 0, 1);
assert(sa == NULL);
sa = opj_sparse_array_int32_create(1, 1, 1, 0);
assert(sa == NULL);
sa = opj_sparse_array_int32_create(99, 101, ~0U, ~0U);
assert(sa == NULL);
sa = opj_sparse_array_int32_create(99, 101, 15, 17);
opj_sparse_array_int32_free(sa);
sa = opj_sparse_array_int32_create(99, 101, 15, 17);
ret = opj_sparse_array_int32_read(sa, 0, 0, 0, 1, buffer, 1, 1, OPJ_FALSE);
assert(!ret);
ret = opj_sparse_array_int32_read(sa, 0, 0, 1, 0, buffer, 1, 1, OPJ_FALSE);
assert(!ret);
ret = opj_sparse_array_int32_read(sa, 0, 0, 100, 1, buffer, 1, 1, OPJ_FALSE);
assert(!ret);
ret = opj_sparse_array_int32_read(sa, 0, 0, 1, 102, buffer, 1, 1, OPJ_FALSE);
assert(!ret);
ret = opj_sparse_array_int32_read(sa, 1, 0, 0, 1, buffer, 1, 1, OPJ_FALSE);
assert(!ret);
ret = opj_sparse_array_int32_read(sa, 0, 1, 1, 0, buffer, 1, 1, OPJ_FALSE);
assert(!ret);
ret = opj_sparse_array_int32_read(sa, 99, 101, 99, 101, buffer, 1, 1,
OPJ_FALSE);
assert(!ret);
buffer[0] = 1;
ret = opj_sparse_array_int32_read(sa, 0, 0, 1, 1, buffer, 1, 1, OPJ_FALSE);
assert(ret);
assert(buffer[0] == 0);
memset(buffer, 0xFF, sizeof(buffer));
ret = opj_sparse_array_int32_read(sa, 0, 0, 99, 101, buffer, 1, 99, OPJ_FALSE);
assert(ret);
for (i = 0; i < 99 * 101; i++) {
assert(buffer[i] == 0);
}
buffer[0] = 1;
ret = opj_sparse_array_int32_write(sa, 4, 5, 4 + 1, 5 + 1, buffer, 1, 1,
OPJ_FALSE);
assert(ret);
buffer[0] = 2;
ret = opj_sparse_array_int32_write(sa, 4, 5, 4 + 1, 5 + 1, buffer, 1, 1,
OPJ_FALSE);
assert(ret);
buffer[0] = 0;
buffer[1] = 0xFF;
ret = opj_sparse_array_int32_read(sa, 4, 5, 4 + 1, 5 + 1, buffer, 1, 1,
OPJ_FALSE);
assert(ret);
assert(buffer[0] == 2);
assert(buffer[1] == 0xFF);
buffer[0] = 0xFF;
buffer[1] = 0xFF;
buffer[2] = 0xFF;
ret = opj_sparse_array_int32_read(sa, 4, 5, 4 + 1, 5 + 2, buffer, 0, 1,
OPJ_FALSE);
assert(ret);
assert(buffer[0] == 2);
assert(buffer[1] == 0);
assert(buffer[2] == 0xFF);
buffer[0] = 3;
ret = opj_sparse_array_int32_write(sa, 4, 5, 4 + 1, 5 + 1, buffer, 0, 1,
OPJ_FALSE);
assert(ret);
buffer[0] = 0;
buffer[1] = 0xFF;
ret = opj_sparse_array_int32_read(sa, 4, 5, 4 + 1, 5 + 1, buffer, 1, 1,
OPJ_FALSE);
assert(ret);
assert(buffer[0] == 3);
assert(buffer[1] == 0xFF);
w = 15 + 1;
h = 17 + 1;
memset(buffer, 0xFF, sizeof(buffer));
ret = opj_sparse_array_int32_read(sa, 2, 1, 2 + w, 1 + h, buffer, 1, w,
OPJ_FALSE);
assert(ret);
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
if (i == 4 - 2 && j == 5 - 1) {
assert(buffer[ j * w + i ] == 3);
} else {
assert(buffer[ j * w + i ] == 0);
}
}
}
opj_sparse_array_int32_free(sa);
sa = opj_sparse_array_int32_create(99, 101, 15, 17);
memset(buffer, 0xFF, sizeof(buffer));
ret = opj_sparse_array_int32_read(sa, 0, 0, 2, 1, buffer, 2, 4, OPJ_FALSE);
assert(ret);
assert(buffer[0] == 0);
assert(buffer[1] == -1);
assert(buffer[2] == 0);
buffer[0] = 1;
buffer[2] = 3;
ret = opj_sparse_array_int32_write(sa, 0, 0, 2, 1, buffer, 2, 4, OPJ_FALSE);
assert(ret);
memset(buffer, 0xFF, sizeof(buffer));
ret = opj_sparse_array_int32_read(sa, 0, 0, 2, 1, buffer, 2, 4, OPJ_FALSE);
assert(ret);
assert(buffer[0] == 1);
assert(buffer[1] == -1);
assert(buffer[2] == 3);
opj_sparse_array_int32_free(sa);
return 0;
}

@ -0,0 +1,146 @@
/*
* $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include "opj_includes.h"
int opj_write_thix(int coff, opj_codestream_info_t cstr_info,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [4];
int i;
int tileno;
opj_jp2_box_t *box;
OPJ_UINT32 len;
OPJ_OFF_T lenp;
lenp = 0;
box = (opj_jp2_box_t *)opj_calloc((size_t)(cstr_info.tw * cstr_info.th),
sizeof(opj_jp2_box_t));
if (box == NULL) {
return 0;
}
for (i = 0; i < 2 ; i++) {
if (i) {
opj_stream_seek(cio, lenp, p_manager);
}
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_THIX, 4); /* THIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_manf(i, cstr_info.tw * cstr_info.th, box, cio, p_manager);
for (tileno = 0; tileno < cstr_info.tw * cstr_info.th; tileno++) {
box[tileno].length = (OPJ_UINT32)opj_write_tilemhix(coff, cstr_info, tileno,
cio, p_manager);
box[tileno].type = JPIP_MHIX;
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
}
opj_free(box);
return (int)len;
}
/*
* Write tile-part headers mhix box
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] tileno tile number
* @param[in] cio file output handle
* @return length of mhix box
*/
int opj_write_tilemhix(int coff, opj_codestream_info_t cstr_info, int tileno,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [8];
int i;
opj_tile_info_t tile;
opj_tp_info_t tp;
opj_marker_info_t *marker;
OPJ_UINT32 len;
OPJ_OFF_T lenp;
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4,
p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_MHIX,
4); /* MHIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
tile = cstr_info.tile[tileno];
tp = tile.tp[0];
opj_write_bytes(l_data_header,
(OPJ_UINT32)(tp.tp_end_header - tp.tp_start_pos + 1),
8); /* TLEN */
opj_stream_write_data(cio, l_data_header, 8, p_manager);
marker = cstr_info.tile[tileno].marker;
for (i = 0; i < cstr_info.tile[tileno].marknum;
i++) { /* Marker restricted to 1 apparition */
opj_write_bytes(l_data_header, marker[i].type, 2);
opj_write_bytes(l_data_header + 2, 0, 2);
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_bytes(l_data_header, (OPJ_UINT32)(marker[i].pos - coff), 8);
opj_stream_write_data(cio, l_data_header, 8, p_manager);
opj_write_bytes(l_data_header, (OPJ_UINT32)marker[i].len, 2);
opj_stream_write_data(cio, l_data_header, 2, p_manager);
}
/* free( marker);*/
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
return (int)len;
}

@ -0,0 +1,190 @@
/*
* $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2014, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include "opj_includes.h"
#define MAX(a,b) ((a)>(b)?(a):(b))
/*
* Get number of maximum tile parts per tile
*
* @param[in] cstr_info codestream information
* @return number of maximum tile parts per tile
*/
int get_num_max_tile_parts(opj_codestream_info_t cstr_info);
/*
* Write faix box of tpix
*
* @param[in] coff offset of j2k codestream
* @param[in] compno component number
* @param[in] cstr_info codestream information
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of faix box
*/
int opj_write_tpix(int coff,
opj_codestream_info_t cstr_info,
int j2klen, opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_BYTE l_data_header [4];
OPJ_UINT32 len;
OPJ_OFF_T lenp;
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager);
opj_write_bytes(l_data_header, JPIP_TPIX, 4); /* TPIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_tpixfaix(coff, 0, cstr_info, j2klen, cio, p_manager);
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_skip(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
return (int)len;
}
int opj_write_tpixfaix(int coff,
int compno,
opj_codestream_info_t cstr_info,
int j2klen,
opj_stream_private_t *cio,
opj_event_mgr_t * p_manager)
{
OPJ_UINT32 len;
OPJ_OFF_T lenp;
OPJ_UINT32 i, j;
OPJ_UINT32 Aux;
OPJ_UINT32 num_max_tile_parts;
OPJ_UINT32 size_of_coding; /* 4 or 8 */
opj_tp_info_t tp;
OPJ_BYTE l_data_header [8];
OPJ_UINT32 version;
num_max_tile_parts = (OPJ_UINT32)get_num_max_tile_parts(cstr_info);
if (j2klen > pow(2, 32)) {
size_of_coding = 8;
version = num_max_tile_parts == 1 ? 1 : 3;
} else {
size_of_coding = 4;
version = num_max_tile_parts == 1 ? 0 : 2;
}
lenp = opj_stream_tell(cio);
opj_stream_skip(cio, 4, p_manager); /* L [at the end] */
opj_write_bytes(l_data_header, JPIP_FAIX, 4); /* FAIX */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_write_bytes(l_data_header, version, 1); /* Version 0 = 4 bytes */
opj_stream_write_data(cio, l_data_header, 1, p_manager);
opj_write_bytes(l_data_header, num_max_tile_parts,
size_of_coding); /* NMAX */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header, (OPJ_UINT32)(cstr_info.tw * cstr_info.th),
size_of_coding); /* M */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
for (i = 0; i < (OPJ_UINT32)(cstr_info.tw * cstr_info.th); i++) {
for (j = 0; j < (OPJ_UINT32)cstr_info.tile[i].num_tps; j++) {
tp = cstr_info.tile[i].tp[j];
opj_write_bytes(l_data_header, (OPJ_UINT32)(tp.tp_start_pos - coff),
size_of_coding); /* start position */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header,
(OPJ_UINT32)(tp.tp_end_pos - tp.tp_start_pos + 1),
size_of_coding); /* length */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
if (version & 0x02) {
if (cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1) {
Aux = (OPJ_UINT32)(cstr_info.numdecompos[compno] + 1);
} else {
Aux = j + 1;
}
opj_write_bytes(l_data_header, Aux, 4);
opj_stream_write_data(cio, l_data_header, 4, p_manager);
/*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */
/* fprintf(stderr,"AUX value %d\n",Aux);*/
}
/*cio_write(0,4);*/
}
/* PADDING */
while (j < num_max_tile_parts) {
opj_write_bytes(l_data_header, 0,
size_of_coding); /* start position */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
opj_write_bytes(l_data_header, 0,
size_of_coding); /* length */
opj_stream_write_data(cio, l_data_header, size_of_coding, p_manager);
if (version & 0x02) {
opj_write_bytes(l_data_header, 0, 4); /* Aux_i,j : Auxiliary value */
}
opj_stream_write_data(cio, l_data_header, 4, p_manager);
j++;
}
}
len = (OPJ_UINT32)(opj_stream_tell(cio) - lenp);
opj_stream_seek(cio, lenp, p_manager);
opj_write_bytes(l_data_header, len, 4); /* L */
opj_stream_write_data(cio, l_data_header, 4, p_manager);
opj_stream_seek(cio, lenp + len, p_manager);
return (int)len;
}
int get_num_max_tile_parts(opj_codestream_info_t cstr_info)
{
int num_max_tp = 0, i;
for (i = 0; i < cstr_info.tw * cstr_info.th; i++) {
num_max_tp = MAX(cstr_info.tile[i].num_tps, num_max_tp);
}
return num_max_tp;
}

@ -165,6 +165,8 @@ void quirc_extract(const struct quirc *q, int index,
/* Decode a QR-code, returning the payload data. */
quirc_decode_error_t quirc_decode(const struct quirc_code *code,
struct quirc_data *data);
/* flip the QR code horizontaly (mirror flip) */
void quirc_flip(struct quirc_code *code);
#ifdef __cplusplus
}

@ -917,3 +917,22 @@ quirc_decode_error_t quirc_decode(const struct quirc_code *code,
return QUIRC_SUCCESS;
}
void quirc_flip(struct quirc_code *code)
{
struct quirc_code flipped;
unsigned int offset = 0;
int y;
int x;
memset(&flipped, 0, sizeof(flipped));
for (y = 0; y < code->size; y++) {
for (x = 0; x < code->size; x++) {
if (grid_bit(code, y, x)) {
flipped.cell_bitmap[offset >> 3u] |= (1u << (offset & 7u));
}
offset++;
}
}
memcpy(&code->cell_bitmap, &flipped.cell_bitmap, sizeof(flipped.cell_bitmap));
}

@ -472,6 +472,9 @@ OCV_OPTION(WITH_OBSENSOR "Include obsensor support (Orbbec RGB-D modules: Astra+
OCV_OPTION(WITH_CANN "Include CANN support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_CANN)
OCV_OPTION(WITH_FLATBUFFERS "Include Flatbuffers support (required by DNN/TFLite importer)" ON
VISIBLE_IF TRUE
VERIFY HAVE_FLATBUFFERS)
# OpenCV build components
# ===================================================
@ -509,6 +512,7 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
# ===================================================
OCV_OPTION(ENABLE_CCACHE "Use ccache" (UNIX AND (CMAKE_GENERATOR MATCHES "Makefile" OR CMAKE_GENERATOR MATCHES "Ninja" OR CMAKE_GENERATOR MATCHES "Xcode")) )
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" MSVC IF (MSVC OR (NOT IOS AND NOT CMAKE_CROSSCOMPILING) ) )
OCV_OPTION(ENABLE_DELAYLOAD "Enable delayed loading of OpenCV DLLs" OFF VISIBLE_IF MSVC AND BUILD_SHARED_LIBS)
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CV_GCC )
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CV_GCC )
@ -757,6 +761,7 @@ if(WITH_LAPACK)
ocv_assert(HAVE_LAPACK) # Lapack is required for OpenCV 5.0+
endif()
include(cmake/OpenCVFindProtobuf.cmake)
include(cmake/OpenCVDetectFlatbuffers.cmake)
if(WITH_TENGINE)
include(cmake/OpenCVFindTengine.cmake)
endif()
@ -919,7 +924,7 @@ foreach(hal ${OpenCV_HAL})
endif()
endif()
endforeach()
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/custom_hal.hpp.in" "${CMAKE_BINARY_DIR}/custom_hal.hpp" @ONLY)
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/custom_hal.hpp.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/custom_hal.hpp" @ONLY)
unset(_hal_includes)

@ -16,59 +16,48 @@ A member of the Security Team will review your e-mail and contact you to collabo
## PGP Key
If a security vulnerability report has extremely sensitive information you may encrypt it using our PGP public key:
If a security vulnerability report has extremely sensitive information you may encrypt it using our PGP public key (updated 2023-APR-19):
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF3D4kMBEADMujKXgYtH1RFA25OTz+AFVZJlsQj8vC9WqKxvx7lluU33J8H0
QUTwqysupVKmeLLdhWLrhMdN22qV33rn/Ba4VaosIkjBs6TSJg752J9qK07C+ps5
4a8DDiqUV5B5aOO1ZI82rcw0EB4uTyJdsynY2zs1ylfNA3UothN30nSmv8HK22wO
rt7R0/W29AoREihDWiGsTm6PxPA/jGN9WawqzVZF4Iv5kC6jFSojoyj1vVDn/55l
JcjjRD88tSvjLeJE4vVgoN5LzvaNnwHOv8z+wDakt7cc/BLO0GdUOZvo5iBqv9sF
y/6G4SULEY+LD1ByTEjajZCkfzURq7qVdRehseplOO5qPLDYU1PumzFYMqhkGRcu
yH0q1bnqzKilARYCDUjlfPinQR6ko1CZ6aFCVPXHjs6btJ3kiP7SohjO8maO8IXD
DvHS/qzxQ4NiqunSd8/Nh54WhckV3t+u1UUY7sesN+BDFHcpPOwvjubSpmoBT1TC
lS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TABEBAAGJAbYEGAEKACAWIQSTc4F61Uez5que1zcFgMvfILyb9QUCZEARbQIb
DAAKCRAFgMvfILyb9WOeDACFaHUdxZjaZmCxeoRyT6lLMJKwUNulJ8lbX1DvLmCS
AtQdFwaa3hT7fpmqD5UFnKSTUUdXe6DVBNoe1wde5hjBn7F/j7HJe3gYneRB0uuA
CSq9wUrg7GPUMYyFNNbdGPFMMNvcPREUlx5qYEJH1VSIYfbCNmG4ESuuOa0xXxvC
7FoLk3tHQzNP9H4p11fq70SycDGwBDjtNQWqf2l2PuQxIuefICZ4C+SJY/eOSpVj
bo1wnHCHznZS7+tMsqET5IFG16ckGK3nTW7gsXhu+CJ8DalIQCXAq5w0IdDfWDG8
9ocXIPDa8gcJRLUFZi/CYg+vdgI6mJ8RSLzJz75T2pl0m6kds4o+mdp5pIQYXio9
1KAo+vtmGY7gQzjqQYoc4Ne6DWRpjS2iO4aGZu+/pGpSU3/Tu/u5Y9RNrP8MycGV
M0vnhRnHJFDsLnIy1os/S0MDLYqlYB5zR04A4Znj+aPhViJMn9V4c2UdZ1TFEaZp
tVpvxypkp4FAHRP7cIS8ODU=
=g4fo
-----END PGP PUBLIC KEY BLOCK-----
```

@ -1167,7 +1167,7 @@ void cvCreateTestSamples( const char* infoname,
}
else
{
filename++;
filename++; // character after last / or \
}
count = MIN( count, cvbgdata->count );
@ -1199,8 +1199,8 @@ void cvCreateTestSamples( const char* infoname,
1, 0.0, 0.0, &data );
sprintf( filename, "%04d_%04d_%04d_%04d_%04d.jpg",
(i + 1), x, y, width, height );
snprintf( filename, sizeof(fullname) - (filename - fullname), "%04d_%04d_%04d_%04d_%04d.jpg",
(i + 1), x, y, width, height );
if( info )
{

@ -21,7 +21,7 @@ namespace calib
enum InputType { Video, Pictures };
enum InputVideoSource { Camera, File };
enum TemplateType { AcirclesGrid, Chessboard, chAruco, DoubleAcirclesGrid, CirclesGrid };
enum TemplateType { AcirclesGrid, Chessboard, ChArUco, DoubleAcirclesGrid, CirclesGrid };
static const std::string mainWindowName = "Calibration";
static const std::string gridWindowName = "Board locations";
@ -79,8 +79,11 @@ namespace calib
InputType captureMethod;
InputVideoSource source;
TemplateType board;
cv::Size boardSize;
cv::Size inputBoardSize;
cv::Size boardSizeInnerCorners; // board size in inner corners for chessboard
cv::Size boardSizeUnits; // board size in squares, circles, etc.
int charucoDictName;
std::string charucoDictFile;
int calibrationStep;
float charucoSquareLength, charucoMarkerSize;
float captureDelay;

@ -59,14 +59,14 @@ FrameProcessor::~FrameProcessor()
bool CalibProcessor::detectAndParseChessboard(const cv::Mat &frame)
{
int chessBoardFlags = cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_NORMALIZE_IMAGE | cv::CALIB_CB_FAST_CHECK;
bool isTemplateFound = cv::findChessboardCorners(frame, mBoardSize, mCurrentImagePoints, chessBoardFlags);
bool isTemplateFound = cv::findChessboardCorners(frame, mBoardSizeInnerCorners, mCurrentImagePoints, chessBoardFlags);
if (isTemplateFound) {
cv::Mat viewGray;
cv::cvtColor(frame, viewGray, cv::COLOR_BGR2GRAY);
cv::cornerSubPix(viewGray, mCurrentImagePoints, cv::Size(11,11),
cv::Size(-1,-1), cv::TermCriteria( cv::TermCriteria::EPS+cv::TermCriteria::COUNT, 30, 0.1 ));
cv::drawChessboardCorners(frame, mBoardSize, cv::Mat(mCurrentImagePoints), isTemplateFound);
cv::drawChessboardCorners(frame, mBoardSizeInnerCorners, cv::Mat(mCurrentImagePoints), isTemplateFound);
mTemplateLocations.insert(mTemplateLocations.begin(), mCurrentImagePoints[0]);
}
return isTemplateFound;
@ -76,7 +76,7 @@ bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame)
{
cv::Ptr<cv::aruco::Board> board = mCharucoBoard.staticCast<cv::aruco::Board>();
std::vector<std::vector<cv::Point2f> > corners, rejected;
std::vector<std::vector<cv::Point2f> > corners;
std::vector<int> ids;
cv::Mat currentCharucoCorners, currentCharucoIds;
detector->detectBoard(frame, currentCharucoCorners, currentCharucoIds, corners, ids);
@ -102,20 +102,20 @@ bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame)
bool CalibProcessor::detectAndParseCircles(const cv::Mat &frame)
{
bool isTemplateFound = findCirclesGrid(frame, mBoardSize, mCurrentImagePoints, cv::CALIB_CB_SYMMETRIC_GRID, mBlobDetectorPtr);
bool isTemplateFound = findCirclesGrid(frame, mBoardSizeUnits, mCurrentImagePoints, cv::CALIB_CB_SYMMETRIC_GRID, mBlobDetectorPtr);
if(isTemplateFound) {
mTemplateLocations.insert(mTemplateLocations.begin(), mCurrentImagePoints[0]);
cv::drawChessboardCorners(frame, mBoardSize, cv::Mat(mCurrentImagePoints), isTemplateFound);
cv::drawChessboardCorners(frame, mBoardSizeUnits, cv::Mat(mCurrentImagePoints), isTemplateFound);
}
return isTemplateFound;
}
bool CalibProcessor::detectAndParseACircles(const cv::Mat &frame)
{
bool isTemplateFound = findCirclesGrid(frame, mBoardSize, mCurrentImagePoints, cv::CALIB_CB_ASYMMETRIC_GRID, mBlobDetectorPtr);
bool isTemplateFound = findCirclesGrid(frame, mBoardSizeUnits, mCurrentImagePoints, cv::CALIB_CB_ASYMMETRIC_GRID, mBlobDetectorPtr);
if(isTemplateFound) {
mTemplateLocations.insert(mTemplateLocations.begin(), mCurrentImagePoints[0]);
cv::drawChessboardCorners(frame, mBoardSize, cv::Mat(mCurrentImagePoints), isTemplateFound);
cv::drawChessboardCorners(frame, mBoardSizeUnits, cv::Mat(mCurrentImagePoints), isTemplateFound);
}
return isTemplateFound;
}
@ -126,18 +126,18 @@ bool CalibProcessor::detectAndParseDualACircles(const cv::Mat &frame)
cv::Mat invertedView;
cv::bitwise_not(frame, invertedView);
bool isWhiteGridFound = cv::findCirclesGrid(frame, mBoardSize, mCurrentImagePoints, cv::CALIB_CB_ASYMMETRIC_GRID, mBlobDetectorPtr);
bool isWhiteGridFound = cv::findCirclesGrid(frame, mBoardSizeUnits, mCurrentImagePoints, cv::CALIB_CB_ASYMMETRIC_GRID, mBlobDetectorPtr);
if(!isWhiteGridFound)
return false;
bool isBlackGridFound = cv::findCirclesGrid(invertedView, mBoardSize, blackPointbuf, cv::CALIB_CB_ASYMMETRIC_GRID, mBlobDetectorPtr);
bool isBlackGridFound = cv::findCirclesGrid(invertedView, mBoardSizeUnits, blackPointbuf, cv::CALIB_CB_ASYMMETRIC_GRID, mBlobDetectorPtr);
if(!isBlackGridFound)
{
mCurrentImagePoints.clear();
return false;
}
cv::drawChessboardCorners(frame, mBoardSize, cv::Mat(mCurrentImagePoints), isWhiteGridFound);
cv::drawChessboardCorners(frame, mBoardSize, cv::Mat(blackPointbuf), isBlackGridFound);
cv::drawChessboardCorners(frame, mBoardSizeUnits, cv::Mat(mCurrentImagePoints), isWhiteGridFound);
cv::drawChessboardCorners(frame, mBoardSizeUnits, cv::Mat(blackPointbuf), isBlackGridFound);
mCurrentImagePoints.insert(mCurrentImagePoints.end(), blackPointbuf.begin(), blackPointbuf.end());
mTemplateLocations.insert(mTemplateLocations.begin(), mCurrentImagePoints[0]);
@ -152,14 +152,14 @@ void CalibProcessor::saveFrameData()
switch(mBoardType)
{
case Chessboard:
objectPoints.reserve(mBoardSize.height*mBoardSize.width);
for( int i = 0; i < mBoardSize.height; ++i )
for( int j = 0; j < mBoardSize.width; ++j )
objectPoints.reserve(mBoardSizeInnerCorners.height*mBoardSizeInnerCorners.width);
for( int i = 0; i < mBoardSizeInnerCorners.height; ++i )
for( int j = 0; j < mBoardSizeInnerCorners.width; ++j )
objectPoints.push_back(cv::Point3f(j*mSquareSize, i*mSquareSize, 0));
mCalibData->imagePoints.push_back(mCurrentImagePoints);
mCalibData->objectPoints.push_back(objectPoints);
break;
case chAruco:
case ChArUco:
mCalibData->allCharucoCorners.push_back(mCurrentCharucoCorners);
mCalibData->allCharucoIds.push_back(mCurrentCharucoIds);
@ -169,38 +169,38 @@ void CalibProcessor::saveFrameData()
mCalibData->objectPoints.push_back(objectPoints);
break;
case CirclesGrid:
objectPoints.reserve(mBoardSize.height*mBoardSize.width);
for( int i = 0; i < mBoardSize.height; i++ )
for( int j = 0; j < mBoardSize.width; j++ )
objectPoints.reserve(mBoardSizeUnits.height*mBoardSizeUnits.width);
for( int i = 0; i < mBoardSizeUnits.height; i++ )
for( int j = 0; j < mBoardSizeUnits.width; j++ )
objectPoints.push_back(cv::Point3f(j*mSquareSize, i*mSquareSize, 0));
mCalibData->imagePoints.push_back(mCurrentImagePoints);
mCalibData->objectPoints.push_back(objectPoints);
break;
case AcirclesGrid:
objectPoints.reserve(mBoardSize.height*mBoardSize.width);
for( int i = 0; i < mBoardSize.height; i++ )
for( int j = 0; j < mBoardSize.width; j++ )
objectPoints.reserve(mBoardSizeUnits.height*mBoardSizeUnits.width);
for( int i = 0; i < mBoardSizeUnits.height; i++ )
for( int j = 0; j < mBoardSizeUnits.width; j++ )
objectPoints.push_back(cv::Point3f((2*j + i % 2)*mSquareSize, i*mSquareSize, 0));
mCalibData->imagePoints.push_back(mCurrentImagePoints);
mCalibData->objectPoints.push_back(objectPoints);
break;
case DoubleAcirclesGrid:
{
float gridCenterX = (2*((float)mBoardSize.width - 1) + 1)*mSquareSize + mTemplDist / 2;
float gridCenterY = (mBoardSize.height - 1)*mSquareSize / 2;
objectPoints.reserve(2*mBoardSize.height*mBoardSize.width);
float gridCenterX = (2*((float)mBoardSizeUnits.width - 1) + 1)*mSquareSize + mTemplDist / 2;
float gridCenterY = (mBoardSizeUnits.height - 1)*mSquareSize / 2;
objectPoints.reserve(2*mBoardSizeUnits.height*mBoardSizeUnits.width);
//white part
for( int i = 0; i < mBoardSize.height; i++ )
for( int j = 0; j < mBoardSize.width; j++ )
for( int i = 0; i < mBoardSizeUnits.height; i++ )
for( int j = 0; j < mBoardSizeUnits.width; j++ )
objectPoints.push_back(
cv::Point3f(-float((2*j + i % 2)*mSquareSize + mTemplDist +
(2*(mBoardSize.width - 1) + 1)*mSquareSize - gridCenterX),
(2*(mBoardSizeUnits.width - 1) + 1)*mSquareSize - gridCenterX),
-float(i*mSquareSize) - gridCenterY,
0));
//black part
for( int i = 0; i < mBoardSize.height; i++ )
for( int j = 0; j < mBoardSize.width; j++ )
for( int i = 0; i < mBoardSizeUnits.height; i++ )
for( int j = 0; j < mBoardSizeUnits.width; j++ )
objectPoints.push_back(cv::Point3f(-float((2*j + i % 2)*mSquareSize - gridCenterX),
-float(i*mSquareSize) - gridCenterY, 0));
@ -262,7 +262,8 @@ bool CalibProcessor::checkLastFrame()
}
CalibProcessor::CalibProcessor(cv::Ptr<calibrationData> data, captureParameters &capParams) :
mCalibData(data), mBoardType(capParams.board), mBoardSize(capParams.boardSize)
mCalibData(data), mBoardType(capParams.board), mBoardSizeUnits(capParams.boardSizeUnits),
mBoardSizeInnerCorners(capParams.boardSizeInnerCorners)
{
mCapuredFrames = 0;
mNeededFramesNum = capParams.calibrationStep;
@ -278,10 +279,18 @@ CalibProcessor::CalibProcessor(cv::Ptr<calibrationData> data, captureParameters
switch(mBoardType)
{
case chAruco:
mArucoDictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType(capParams.charucoDictName));
mCharucoBoard = cv::makePtr<cv::aruco::CharucoBoard>(cv::Size(mBoardSize.width + 1, mBoardSize.height + 1), capParams.charucoSquareLength,
capParams.charucoMarkerSize, mArucoDictionary);
case ChArUco:
if (capParams.charucoDictFile != "None") {
std::string filename = capParams.charucoDictFile;
cv::FileStorage dict_file(filename, cv::FileStorage::Mode::READ);
cv::FileNode fn(dict_file.root());
mArucoDictionary.readDictionary(fn);
}
else {
mArucoDictionary = cv::aruco::getPredefinedDictionary(cv::aruco::PredefinedDictionaryType(capParams.charucoDictName));
}
mCharucoBoard = cv::makePtr<cv::aruco::CharucoBoard>(cv::Size(mBoardSizeUnits.width, mBoardSizeUnits.height), capParams.charucoSquareLength,
capParams.charucoMarkerSize, mArucoDictionary);
detector = cv::makePtr<cv::aruco::CharucoDetector>(cv::aruco::CharucoDetector(*mCharucoBoard, charucoParameters));
break;
case CirclesGrid:
@ -312,7 +321,7 @@ cv::Mat CalibProcessor::processFrame(const cv::Mat &frame)
case Chessboard:
isTemplateFound = detectAndParseChessboard(frameCopy);
break;
case chAruco:
case ChArUco:
isTemplateFound = detectAndParseChAruco(frameCopy);
break;
case CirclesGrid:
@ -392,7 +401,7 @@ void ShowProcessor::drawBoard(cv::Mat &img, cv::InputArray points)
void ShowProcessor::drawGridPoints(const cv::Mat &frame)
{
if(mBoardType != chAruco)
if(mBoardType != ChArUco)
for(std::vector<std::vector<cv::Point2f> >::iterator it = mCalibdata->imagePoints.begin(); it != mCalibdata->imagePoints.end(); ++it)
for(std::vector<cv::Point2f>::iterator pointIt = (*it).begin(); pointIt != (*it).end(); ++pointIt)
cv::circle(frame, *pointIt, POINT_SIZE, cv::Scalar(0, 255, 0), 1, cv::LINE_AA);
@ -514,7 +523,7 @@ void ShowProcessor::updateBoardsView()
if(mVisMode == Window) {
cv::Size originSize = mCalibdata->imageSize;
cv::Mat altGridView = cv::Mat::zeros((int)(originSize.height*mGridViewScale), (int)(originSize.width*mGridViewScale), CV_8UC3);
if(mBoardType != chAruco)
if(mBoardType != ChArUco)
for(std::vector<std::vector<cv::Point2f> >::iterator it = mCalibdata->imagePoints.begin(); it != mCalibdata->imagePoints.end(); ++it)
if(mBoardType != DoubleAcirclesGrid)
drawBoard(altGridView, *it);

@ -30,7 +30,8 @@ class CalibProcessor : public FrameProcessor
protected:
cv::Ptr<calibrationData> mCalibData;
TemplateType mBoardType;
cv::Size mBoardSize;
cv::Size mBoardSizeUnits;
cv::Size mBoardSizeInnerCorners;
std::vector<cv::Point2f> mTemplateLocations;
std::vector<cv::Point2f> mCurrentImagePoints;
cv::Mat mCurrentCharucoCorners;

@ -33,6 +33,12 @@ const std::string keys =
"{dst | 295 | Distance between white and black parts of daulCircles template}"
"{w | | Width of template (in corners or circles)}"
"{h | | Height of template (in corners or circles)}"
"{ad | DICT_4X4_50 | Name of predefined ArUco dictionary. Available ArUco dictionaries: "
"DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, "
"DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, "
"DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL, DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, "
"DICT_APRILTAG_36h10, DICT_APRILTAG_36h11 }"
"{fad | None | name of file with ArUco dictionary}"
"{of | cameraParameters.xml | Output file name}"
"{ft | true | Auto tuning of calibration flags}"
"{vis | grid | Captured boards visualisation (grid, window)}"
@ -118,6 +124,7 @@ int main(int argc, char** argv)
dataController->setParametersFileName(parser.get<std::string>("of"));
cv::Ptr<FrameProcessor> capProcessor, showProcessor;
capProcessor = cv::Ptr<FrameProcessor>(new CalibProcessor(globalData, capParams));
showProcessor = cv::Ptr<FrameProcessor>(new ShowProcessor(globalData, controller, capParams.board));

@ -3,6 +3,7 @@
// of this distribution and at http://opencv.org/license.html.
#include "parametersController.hpp"
#include <opencv2/objdetect/aruco_dictionary.hpp>
#include <iostream>
@ -36,7 +37,6 @@ bool calib::parametersController::loadFromFile(const std::string &inputFileName)
return true;
}
readFromNode(reader["charuco_dict"], mCapParams.charucoDictName);
if (readFromNode(reader["charuco_square_lenght"], mCapParams.charucoSquareLength)) {
std::cout << "DEPRECATION: Parameter 'charuco_square_lenght' has been deprecated (typo). Use 'charuco_square_length' instead." << std::endl;
}
@ -52,7 +52,6 @@ bool calib::parametersController::loadFromFile(const std::string &inputFileName)
readFromNode(reader["frame_filter_conv_param"], mInternalParameters.filterAlpha);
bool retValue =
checkAssertion(mCapParams.charucoDictName >= 0, "Dict name must be >= 0") &&
checkAssertion(mCapParams.charucoMarkerSize > 0, "Marker size must be positive") &&
checkAssertion(mCapParams.charucoSquareLength > 0, "Square size must be positive") &&
checkAssertion(mCapParams.minFramesNum > 1, "Minimal number of frames for calibration < 1") &&
@ -109,27 +108,53 @@ bool calib::parametersController::loadFromParser(cv::CommandLineParser &parser)
std::string templateType = parser.get<std::string>("t");
if(templateType.find("symcircles", 0) == 0) {
mCapParams.board = CirclesGrid;
mCapParams.boardSize = cv::Size(4, 11);
mCapParams.boardSizeUnits = cv::Size(4, 11);
}
else if(templateType.find("circles", 0) == 0) {
mCapParams.board = AcirclesGrid;
mCapParams.boardSize = cv::Size(4, 11);
mCapParams.boardSizeUnits = cv::Size(4, 11);
}
else if(templateType.find("chessboard", 0) == 0) {
mCapParams.board = Chessboard;
mCapParams.boardSize = cv::Size(7, 7);
mCapParams.boardSizeUnits = cv::Size(7, 7);
}
else if(templateType.find("dualcircles", 0) == 0) {
mCapParams.board = DoubleAcirclesGrid;
mCapParams.boardSize = cv::Size(4, 11);
mCapParams.boardSizeUnits = cv::Size(4, 11);
}
else if(templateType.find("charuco", 0) == 0) {
mCapParams.board = chAruco;
mCapParams.boardSize = cv::Size(5, 7);
mCapParams.charucoDictName = 0;
mCapParams.board = ChArUco;
mCapParams.boardSizeUnits = cv::Size(5, 7);
mCapParams.charucoDictFile = parser.get<std::string>("fad");
std::string arucoDictName = parser.get<std::string>("ad");
if (arucoDictName == "DICT_4X4_50") { mCapParams.charucoDictName = cv::aruco::DICT_4X4_50; }
else if (arucoDictName == "DICT_4X4_100") { mCapParams.charucoDictName = cv::aruco::DICT_4X4_100; }
else if (arucoDictName == "DICT_4X4_250") { mCapParams.charucoDictName = cv::aruco::DICT_4X4_250; }
else if (arucoDictName == "DICT_4X4_1000") { mCapParams.charucoDictName = cv::aruco::DICT_4X4_1000; }
else if (arucoDictName == "DICT_5X5_50") { mCapParams.charucoDictName = cv::aruco::DICT_5X5_50; }
else if (arucoDictName == "DICT_5X5_100") { mCapParams.charucoDictName = cv::aruco::DICT_5X5_100; }
else if (arucoDictName == "DICT_5X5_250") { mCapParams.charucoDictName = cv::aruco::DICT_5X5_250; }
else if (arucoDictName == "DICT_5X5_1000") { mCapParams.charucoDictName = cv::aruco::DICT_5X5_1000; }
else if (arucoDictName == "DICT_6X6_50") { mCapParams.charucoDictName = cv::aruco::DICT_6X6_50; }
else if (arucoDictName == "DICT_6X6_100") { mCapParams.charucoDictName = cv::aruco::DICT_6X6_100; }
else if (arucoDictName == "DICT_6X6_250") { mCapParams.charucoDictName = cv::aruco::DICT_6X6_250; }
else if (arucoDictName == "DICT_6X6_1000") { mCapParams.charucoDictName = cv::aruco::DICT_6X6_1000; }
else if (arucoDictName == "DICT_7X7_50") { mCapParams.charucoDictName = cv::aruco::DICT_7X7_50; }
else if (arucoDictName == "DICT_7X7_100") { mCapParams.charucoDictName = cv::aruco::DICT_7X7_100; }
else if (arucoDictName == "DICT_7X7_250") { mCapParams.charucoDictName = cv::aruco::DICT_7X7_250; }
else if (arucoDictName == "DICT_7X7_1000") { mCapParams.charucoDictName = cv::aruco::DICT_7X7_1000; }
else if (arucoDictName == "DICT_ARUCO_ORIGINAL") { mCapParams.charucoDictName = cv::aruco::DICT_ARUCO_ORIGINAL; }
else if (arucoDictName == "DICT_APRILTAG_16h5") { mCapParams.charucoDictName = cv::aruco::DICT_APRILTAG_16h5; }
else if (arucoDictName == "DICT_APRILTAG_25h9") { mCapParams.charucoDictName = cv::aruco::DICT_APRILTAG_25h9; }
else if (arucoDictName == "DICT_APRILTAG_36h10") { mCapParams.charucoDictName = cv::aruco::DICT_APRILTAG_36h10; }
else if (arucoDictName == "DICT_APRILTAG_36h11") { mCapParams.charucoDictName = cv::aruco::DICT_APRILTAG_36h11; }
else {
std::cout << "incorrect name of aruco dictionary \n";
return false;
}
mCapParams.charucoSquareLength = 200;
mCapParams.charucoMarkerSize = 100;
}
@ -139,8 +164,15 @@ bool calib::parametersController::loadFromParser(cv::CommandLineParser &parser)
}
if(parser.has("w") && parser.has("h")) {
mCapParams.boardSize = cv::Size(parser.get<int>("w"), parser.get<int>("h"));
if(!checkAssertion(mCapParams.boardSize.width > 0 || mCapParams.boardSize.height > 0,
mCapParams.inputBoardSize = cv::Size(parser.get<int>("w"), parser.get<int>("h"));
//only for chessboard pattern board size given in inner corners
if (templateType != "chessboard") {
mCapParams.boardSizeUnits = mCapParams.inputBoardSize;
}
else {
mCapParams.boardSizeInnerCorners = mCapParams.inputBoardSize;
}
if(!checkAssertion(mCapParams.inputBoardSize.width > 0 || mCapParams.inputBoardSize.height > 0,
"Board size must be positive"))
return false;
}

@ -0,0 +1,56 @@
#!/usr/bin/env python
from __future__ import print_function
import sys
sys.dont_write_bytecode = True # Don't generate .pyc files / __pycache__ directories
import os
import sys
import unittest
# Python 3 moved urlopen to urllib.requests
try:
from urllib.request import urlopen
except ImportError:
from urllib import urlopen
basedir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(os.path.split(basedir)[0], "modules", "python", "test"))
from tests_common import NewOpenCVTests
def load_tests(loader, tests, pattern):
cwd = os.getcwd()
config_file = 'opencv_apps_python_tests.cfg'
locations = [cwd, basedir]
if os.path.exists(config_file):
with open(config_file, 'r') as f:
locations += [str(s).strip() for s in f.readlines()]
else:
print('WARNING: OpenCV tests config file ({}) is missing, running subset of tests'.format(config_file))
tests_pattern = os.environ.get('OPENCV_APPS_TEST_FILTER', 'test_*') + '.py'
if tests_pattern != 'test_*.py':
print('Tests filter: {}'.format(tests_pattern))
processed = set()
for l in locations:
if not os.path.isabs(l):
l = os.path.normpath(os.path.join(cwd, l))
if l in processed:
continue
processed.add(l)
print('Discovering python tests from: {}'.format(l))
sys_path_modify = l not in sys.path
if sys_path_modify:
sys.path.append(l) # Hack python loader
discovered_tests = loader.discover(l, pattern=tests_pattern, top_level_dir=l)
print(' found {} tests'.format(discovered_tests.countTestCases()))
tests.addTests(loader.discover(l, pattern=tests_pattern))
if sys_path_modify:
sys.path.remove(l)
return tests
if __name__ == '__main__':
NewOpenCVTests.bootstrap()

@ -1005,7 +1005,7 @@ void CvCascadeBoostTree::read( const FileNode &node, CvBoost* _ensemble,
int step = 3 + ( maxCatCount>0 ? subsetN : 1 );
queue<CvDTreeNode*> internalNodesQueue;
FileNodeIterator internalNodesIt, leafValsuesIt;
int internalNodesIdx, leafValsuesIdx;
CvDTreeNode* prntNode, *cldNode;
clear();
@ -1015,9 +1015,9 @@ void CvCascadeBoostTree::read( const FileNode &node, CvBoost* _ensemble,
// read tree nodes
FileNode rnode = node[CC_INTERNAL_NODES];
internalNodesIt = rnode.end();
leafValsuesIt = node[CC_LEAF_VALUES].end();
internalNodesIt--; leafValsuesIt--;
internalNodesIdx = (int) rnode.size() - 1;
FileNode lnode = node[CC_LEAF_VALUES];
leafValsuesIdx = (int) lnode.size() - 1;
for( size_t i = 0; i < rnode.size()/step; i++ )
{
prntNode = data->new_node( 0, 0, 0, 0 );
@ -1026,23 +1026,23 @@ void CvCascadeBoostTree::read( const FileNode &node, CvBoost* _ensemble,
prntNode->split = data->new_split_cat( 0, 0 );
for( int j = subsetN-1; j>=0; j--)
{
*internalNodesIt >> prntNode->split->subset[j]; internalNodesIt--;
rnode[internalNodesIdx] >> prntNode->split->subset[j]; --internalNodesIdx;
}
}
else
{
float split_value;
*internalNodesIt >> split_value; internalNodesIt--;
rnode[internalNodesIdx] >> split_value; --internalNodesIdx;
prntNode->split = data->new_split_ord( 0, split_value, 0, 0, 0);
}
*internalNodesIt >> prntNode->split->var_idx; internalNodesIt--;
rnode[internalNodesIdx] >> prntNode->split->var_idx; --internalNodesIdx;
int ridx, lidx;
*internalNodesIt >> ridx; internalNodesIt--;
*internalNodesIt >> lidx;internalNodesIt--;
rnode[internalNodesIdx] >> ridx; --internalNodesIdx;
rnode[internalNodesIdx] >> lidx; --internalNodesIdx;
if ( ridx <= 0)
{
prntNode->right = cldNode = data->new_node( 0, 0, 0, 0 );
*leafValsuesIt >> cldNode->value; leafValsuesIt--;
lnode[leafValsuesIdx] >> cldNode->value; --leafValsuesIdx;
cldNode->parent = prntNode;
}
else
@ -1055,7 +1055,7 @@ void CvCascadeBoostTree::read( const FileNode &node, CvBoost* _ensemble,
if ( lidx <= 0)
{
prntNode->left = cldNode = data->new_node( 0, 0, 0, 0 );
*leafValsuesIt >> cldNode->value; leafValsuesIt--;
lnode[leafValsuesIdx] >> cldNode->value; --leafValsuesIdx;
cldNode->parent = prntNode;
}
else

@ -370,7 +370,7 @@ void CvCascadeClassifier::writeStages( FileStorage &fs, const Mat& featureMap )
it != stageClassifiers.end();++it, ++i )
{
snprintf( cmnt, sizeof(cmnt), "stage %d", i );
cvWriteComment( fs.fs, cmnt, 0 );
fs.writeComment(cmnt);
fs << "{";
(*it)->write( fs, featureMap );
fs << "}";
@ -466,7 +466,7 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
fs << ICV_HAAR_TREES_NAME << "[";
for( int wi = 0; wi < weak->total; wi++ )
{
int inner_node_idx = -1, total_inner_node_idx = -1;
int total_inner_node_idx = -1;
queue<const CvDTreeNode*> inner_nodes_queue;
CvCascadeBoostTree* tree = *((CvCascadeBoostTree**) cvGetSeqElem( weak, wi ));
@ -482,7 +482,6 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat )
while (!inner_nodes_queue.empty())
{
tempNode = inner_nodes_queue.front();
inner_node_idx++;
fs << "{";
fs << ICV_HAAR_FEATURE_NAME << "{";

@ -800,13 +800,12 @@ public:
virtual const CvMat* get_var_importance();
CV_WRAP virtual void clear();
virtual void read( CvFileStorage* fs, CvFileNode* node );
virtual void write( CvFileStorage* fs, const char* name ) const;
virtual void read( const cv::FileNode& node );
virtual void write( cv::FileStorage& fs, const char* name ) const;
// special read & write methods for trees in the tree ensembles
virtual void read( CvFileStorage* fs, CvFileNode* node,
CvDTreeTrainData* data );
virtual void write( CvFileStorage* fs ) const;
virtual void read( const cv::FileNode& node, CvDTreeTrainData* data );
virtual void write( cv::FileStorage& fs ) const;
const CvDTreeNode* get_root() const;
int get_pruned_tree_idx() const;
@ -843,12 +842,12 @@ protected:
virtual void free_prune_data(bool cut_tree);
virtual void free_tree();
virtual void write_node( CvFileStorage* fs, CvDTreeNode* node ) const;
virtual void write_split( CvFileStorage* fs, CvDTreeSplit* split ) const;
virtual CvDTreeNode* read_node( CvFileStorage* fs, CvFileNode* node, CvDTreeNode* parent );
virtual CvDTreeSplit* read_split( CvFileStorage* fs, CvFileNode* node );
virtual void write_tree_nodes( CvFileStorage* fs ) const;
virtual void read_tree_nodes( CvFileStorage* fs, CvFileNode* node );
virtual void write_node( cv::FileStorage& fs, CvDTreeNode* node ) const;
virtual void write_split( cv::FileStorage& fs, CvDTreeSplit* split ) const;
virtual CvDTreeNode* read_node( const cv::FileNode& node, CvDTreeNode* parent );
virtual CvDTreeSplit* read_split( const cv::FileNode& node );
virtual void write_tree_nodes( cv::FileStorage& fs ) const;
virtual void read_tree_nodes( const cv::FileNode& node );
CvDTreeNode* root;
CvMat* var_importance;
@ -876,7 +875,7 @@ public:
virtual bool train( CvDTreeTrainData* trainData, const CvMat* _subsample_idx, CvRTrees* forest );
virtual int get_var_count() const {return data ? data->var_count : 0;}
virtual void read( CvFileStorage* fs, CvFileNode* node, CvRTrees* forest, CvDTreeTrainData* _data );
virtual void read( cv::FileStorage& fs, cv::FileNode& node, CvRTrees* forest, CvDTreeTrainData* _data );
/* dummy methods to avoid warnings: BEGIN */
virtual bool train( const CvMat* trainData, int tflag,
@ -886,8 +885,8 @@ public:
CvDTreeParams params=CvDTreeParams() );
virtual bool train( CvDTreeTrainData* trainData, const CvMat* _subsample_idx );
virtual void read( CvFileStorage* fs, CvFileNode* node );
virtual void read( CvFileStorage* fs, CvFileNode* node,
virtual void read( cv::FileStorage& fs, cv::FileNode& node );
virtual void read( cv::FileStorage& fs, cv::FileNode& node,
CvDTreeTrainData* data );
/* dummy methods to avoid warnings: END */
@ -949,8 +948,8 @@ public:
virtual float get_train_error();
virtual void read( CvFileStorage* fs, CvFileNode* node );
virtual void write( CvFileStorage* fs, const char* name ) const;
virtual void read( cv::FileStorage& fs, cv::FileNode& node );
virtual void write( cv::FileStorage& fs, const char* name ) const;
CvMat* get_active_var_mask();
CvRNG* get_rng();
@ -1067,7 +1066,7 @@ public:
const CvMat* subsample_idx, CvBoost* ensemble );
virtual void scale( double s );
virtual void read( CvFileStorage* fs, CvFileNode* node,
virtual void read( const cv::FileNode& node,
CvBoost* ensemble, CvDTreeTrainData* _data );
virtual void clear();
@ -1079,9 +1078,8 @@ public:
CvDTreeParams params=CvDTreeParams() );
virtual bool train( CvDTreeTrainData* trainData, const CvMat* _subsample_idx );
virtual void read( CvFileStorage* fs, CvFileNode* node );
virtual void read( CvFileStorage* fs, CvFileNode* node,
CvDTreeTrainData* data );
virtual void read( cv::FileNode& node );
virtual void read( cv::FileNode& node, CvDTreeTrainData* data );
/* dummy methods to avoid warnings: END */
protected:
@ -1160,8 +1158,8 @@ public:
CV_WRAP virtual void clear();
virtual void write( CvFileStorage* storage, const char* name ) const;
virtual void read( CvFileStorage* storage, CvFileNode* node );
virtual void write( cv::FileStorage& storage, const char* name ) const;
virtual void read( cv::FileNode& node );
virtual const CvMat* get_active_vars(bool absolute_idx=true);
CvSeq* get_weak_predictors();
@ -1177,8 +1175,8 @@ protected:
virtual bool set_params( const CvBoostParams& params );
virtual void update_weights( CvBoostTree* tree );
virtual void trim_weights();
virtual void write_params( CvFileStorage* fs ) const;
virtual void read_params( CvFileStorage* fs, CvFileNode* node );
virtual void write_params( cv::FileStorage & fs ) const;
virtual void read_params( cv::FileNode& node );
virtual void initialize_weights(double (&p)[2]);
@ -1548,7 +1546,7 @@ public:
// Write parameters of the gtb model and data. Write learned model.
//
// API
// virtual void write( CvFileStorage* fs, const char* name ) const;
// virtual void write( cv::FileStorage& fs, const char* name ) const;
//
// INPUT
// fs - file storage to read parameters from.
@ -1556,7 +1554,7 @@ public:
// OUTPUT
// RESULT
*/
virtual void write( CvFileStorage* fs, const char* name ) const;
virtual void write( cv::FileStorage& fs, const char* name ) const;
/*
@ -1564,7 +1562,7 @@ public:
// Read parameters of the gtb model and data. Read learned model.
//
// API
// virtual void read( CvFileStorage* fs, CvFileNode* node );
// virtual void read( cv::FileStorage& fs, cv::FileNode& node );
//
// INPUT
// fs - file storage to read parameters from.
@ -1572,7 +1570,7 @@ public:
// OUTPUT
// RESULT
*/
virtual void read( CvFileStorage* fs, CvFileNode* node );
virtual void read( cv::FileStorage& fs, cv::FileNode& node );
// new-style C++ interface
@ -1723,14 +1721,14 @@ protected:
// Write parameters of the gtb model.
//
// API
// virtual void write_params( CvFileStorage* fs ) const;
// virtual void write_params( cv::FileStorage& fs ) const;
//
// INPUT
// fs - file storage to write parameters to.
// OUTPUT
// RESULT
*/
virtual void write_params( CvFileStorage* fs ) const;
virtual void write_params( cv::FileStorage& fs ) const;
/*
@ -1750,7 +1748,7 @@ protected:
// class_labels - output class labels map.
// RESULT
*/
virtual void read_params( CvFileStorage* fs, CvFileNode* fnode );
virtual void read_params( cv::FileStorage& fs, cv::FileNode& fnode );
int get_len(const CvMat* mat) const;
@ -1846,8 +1844,8 @@ public:
// available training flags
enum { UPDATE_WEIGHTS = 1, NO_INPUT_SCALE = 2, NO_OUTPUT_SCALE = 4 };
virtual void read( CvFileStorage* fs, CvFileNode* node );
virtual void write( CvFileStorage* storage, const char* name ) const;
virtual void read( cv::FileStorage& fs, cv::FileNode& node );
virtual void write( cv::FileStorage& storage, const char* name ) const;
int get_layer_count() { return layer_sizes ? layer_sizes->cols : 0; }
const CvMat* get_layer_sizes() { return layer_sizes; }
@ -1880,8 +1878,8 @@ protected:
virtual void calc_input_scale( const CvVectors* vecs, int flags );
virtual void calc_output_scale( const CvVectors* vecs, int flags );
virtual void write_params( CvFileStorage* fs ) const;
virtual void read_params( CvFileStorage* fs, CvFileNode* node );
virtual void write_params( cv::FileStorage& fs ) const;
virtual void read_params( cv::FileStorage& fs, cv::FileNode& node );
CvMat* layer_sizes;
CvMat* wbuf;

@ -876,21 +876,21 @@ CvBoostTree::calc_node_value( CvDTreeNode* node )
}
void CvBoostTree::read( CvFileStorage* fs, CvFileNode* fnode, CvBoost* _ensemble, CvDTreeTrainData* _data )
void CvBoostTree::read( const cv::FileNode& fnode, CvBoost* _ensemble, CvDTreeTrainData* _data )
{
CvDTree::read( fs, fnode, _data );
CvDTree::read( fnode, _data );
ensemble = _ensemble;
}
void CvBoostTree::read( CvFileStorage*, CvFileNode* )
void CvBoostTree::read( cv::FileNode& )
{
assert(0);
}
void CvBoostTree::read( CvFileStorage* _fs, CvFileNode* _node,
void CvBoostTree::read( cv::FileNode& _node,
CvDTreeTrainData* _data )
{
CvDTree::read( _fs, _node, _data );
CvDTree::read( _node, _data );
}
@ -1884,7 +1884,7 @@ float CvBoost::calc_error( CvMLData* _data, int type, std::vector<float> *resp )
return err;
}
void CvBoost::write_params( CvFileStorage* fs ) const
void CvBoost::write_params( cv::FileStorage& fs ) const
{
const char* boost_type_str =
params.boost_type == DISCRETE ? "DiscreteAdaboost" :
@ -1899,35 +1899,33 @@ void CvBoost::write_params( CvFileStorage* fs ) const
params.boost_type == SQERR ? "SquaredErr" : 0;
if( boost_type_str )
cvWriteString( fs, "boosting_type", boost_type_str );
fs.write( "boosting_type", boost_type_str );
else
cvWriteInt( fs, "boosting_type", params.boost_type );
fs.write( "boosting_type", params.boost_type );
if( split_crit_str )
cvWriteString( fs, "splitting_criteria", split_crit_str );
fs.write( "splitting_criteria", split_crit_str );
else
cvWriteInt( fs, "splitting_criteria", params.split_criteria );
fs.write( "splitting_criteria", params.split_criteria );
cvWriteInt( fs, "ntrees", weak->total );
cvWriteReal( fs, "weight_trimming_rate", params.weight_trim_rate );
fs.write( "ntrees", weak->total );
fs.write( "weight_trimming_rate", params.weight_trim_rate );
data->write_params( fs );
}
void CvBoost::read_params( CvFileStorage* fs, CvFileNode* fnode )
void CvBoost::read_params( cv::FileNode& fnode )
{
CV_FUNCNAME( "CvBoost::read_params" );
__BEGIN__;
CvFileNode* temp;
if( !fnode || !CV_NODE_IS_MAP(fnode->tag) )
if( fnode.empty() || !fnode.isMap() )
return;
data = new CvDTreeTrainData();
CV_CALL( data->read_params(fs, fnode));
data->read_params( fnode );
data->shared = true;
params.max_depth = data->params.max_depth;
@ -1937,41 +1935,41 @@ void CvBoost::read_params( CvFileStorage* fs, CvFileNode* fnode )
params.regression_accuracy = data->params.regression_accuracy;
params.use_surrogates = data->params.use_surrogates;
temp = cvGetFileNodeByName( fs, fnode, "boosting_type" );
if( !temp )
cv::FileNode temp = fnode[ "boosting_type" ];
if( temp.empty() )
return;
if( temp && CV_NODE_IS_STRING(temp->tag) )
if ( temp.isString() )
{
const char* boost_type_str = cvReadString( temp, "" );
params.boost_type = strcmp( boost_type_str, "DiscreteAdaboost" ) == 0 ? DISCRETE :
strcmp( boost_type_str, "RealAdaboost" ) == 0 ? REAL :
strcmp( boost_type_str, "LogitBoost" ) == 0 ? LOGIT :
strcmp( boost_type_str, "GentleAdaboost" ) == 0 ? GENTLE : -1;
std::string boost_type_str = temp;
params.boost_type = (boost_type_str == "DiscreteAdaboost") ? DISCRETE :
(boost_type_str == "RealAdaboost") ? REAL :
(boost_type_str == "LogitBoost") ? LOGIT :
(boost_type_str == "GentleAdaboost") ? GENTLE : -1;
}
else
params.boost_type = cvReadInt( temp, -1 );
params.boost_type = temp.empty() ? -1 : (int)temp;
if( params.boost_type < DISCRETE || params.boost_type > GENTLE )
CV_ERROR( CV_StsBadArg, "Unknown boosting type" );
temp = cvGetFileNodeByName( fs, fnode, "splitting_criteria" );
if( temp && CV_NODE_IS_STRING(temp->tag) )
temp = fnode[ "splitting_criteria" ];
if( !temp.empty() && temp.isString() )
{
const char* split_crit_str = cvReadString( temp, "" );
params.split_criteria = strcmp( split_crit_str, "Default" ) == 0 ? DEFAULT :
strcmp( split_crit_str, "Gini" ) == 0 ? GINI :
strcmp( split_crit_str, "Misclassification" ) == 0 ? MISCLASS :
strcmp( split_crit_str, "SquaredErr" ) == 0 ? SQERR : -1;
std::string split_crit_str = temp;
params.split_criteria = ( split_crit_str == "Default" ) ? DEFAULT :
( split_crit_str == "Gini" ) ? GINI :
( split_crit_str == "Misclassification" ) ? MISCLASS :
( split_crit_str == "SquaredErr" ) ? SQERR : -1;
}
else
params.split_criteria = cvReadInt( temp, -1 );
params.split_criteria = temp.empty() ? -1 : (int) temp;
if( params.split_criteria < DEFAULT || params.boost_type > SQERR )
CV_ERROR( CV_StsBadArg, "Unknown boosting type" );
params.weak_count = cvReadIntByName( fs, fnode, "ntrees" );
params.weight_trim_rate = cvReadRealByName( fs, fnode, "weight_trimming_rate", 0. );
params.weak_count = (int) fnode[ "ntrees" ];
params.weight_trim_rate = (double)fnode["weight_trimming_rate"];
__END__;
}
@ -1979,29 +1977,29 @@ void CvBoost::read_params( CvFileStorage* fs, CvFileNode* fnode )
void
CvBoost::read( CvFileStorage* fs, CvFileNode* node )
CvBoost::read( cv::FileNode& node )
{
CV_FUNCNAME( "CvBoost::read" );
__BEGIN__;
CvSeqReader reader;
CvFileNode* trees_fnode;
cv::FileNodeIterator reader;
cv::FileNode trees_fnode;
CvMemStorage* storage;
int i, ntrees;
int ntrees;
clear();
read_params( fs, node );
read_params( node );
if( !data )
EXIT;
trees_fnode = cvGetFileNodeByName( fs, node, "trees" );
if( !trees_fnode || !CV_NODE_IS_SEQ(trees_fnode->tag) )
trees_fnode = node[ "trees" ];
if( trees_fnode.empty() || !trees_fnode.isSeq() )
CV_ERROR( CV_StsParseError, "<trees> tag is missing" );
cvStartReadSeq( trees_fnode->data.seq, &reader );
ntrees = trees_fnode->data.seq->total;
reader = trees_fnode.begin();
ntrees = (int) trees_fnode.size();
if( ntrees != params.weak_count )
CV_ERROR( CV_StsUnmatchedSizes,
@ -2010,11 +2008,11 @@ CvBoost::read( CvFileStorage* fs, CvFileNode* node )
CV_CALL( storage = cvCreateMemStorage() );
weak = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvBoostTree*), storage );
for( i = 0; i < ntrees; i++ )
for( int i = 0; i < ntrees; i++ )
{
CvBoostTree* tree = new CvBoostTree();
CV_CALL(tree->read( fs, (CvFileNode*)reader.ptr, this, data ));
CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
tree->read( *reader, this, data );
reader++;
cvSeqPush( weak, &tree );
}
get_active_vars();
@ -2024,7 +2022,7 @@ CvBoost::read( CvFileStorage* fs, CvFileNode* node )
void
CvBoost::write( CvFileStorage* fs, const char* name ) const
CvBoost::write( cv::FileStorage& fs, const char* name ) const
{
CV_FUNCNAME( "CvBoost::write" );
@ -2033,27 +2031,27 @@ CvBoost::write( CvFileStorage* fs, const char* name ) const
CvSeqReader reader;
int i;
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_BOOSTING );
fs.startWriteStruct( name, cv::FileNode::MAP, CV_TYPE_NAME_ML_BOOSTING );
if( !weak )
CV_ERROR( CV_StsBadArg, "The classifier has not been trained yet" );
write_params( fs );
cvStartWriteStruct( fs, "trees", CV_NODE_SEQ );
fs.startWriteStruct( "trees", cv::FileNode::SEQ );
cvStartReadSeq( weak, &reader );
cvStartReadSeq(weak, &reader);
for( i = 0; i < weak->total; i++ )
{
CvBoostTree* tree;
CV_READ_SEQ_ELEM( tree, reader );
cvStartWriteStruct( fs, 0, CV_NODE_MAP );
fs.startWriteStruct( 0, cv::FileNode::MAP );
tree->write( fs );
cvEndWriteStruct( fs );
fs.endWriteStruct();
}
cvEndWriteStruct( fs );
cvEndWriteStruct( fs );
fs.endWriteStruct();
fs.endWriteStruct();
__END__;
}

@ -60,61 +60,57 @@ void CvStatModel::clear()
void CvStatModel::save( const char* filename, const char* name ) const
{
CvFileStorage* fs = 0;
cv::FileStorage fs;
CV_FUNCNAME( "CvStatModel::save" );
__BEGIN__;
CV_CALL( fs = cvOpenFileStorage( filename, 0, CV_STORAGE_WRITE ));
if( !fs )
if( !fs.open( filename, cv::FileStorage::WRITE ))
CV_ERROR( CV_StsError, "Could not open the file storage. Check the path and permissions" );
write( fs, name ? name : default_model_name );
__END__;
cvReleaseFileStorage( &fs );
}
void CvStatModel::load( const char* filename, const char* name )
{
CvFileStorage* fs = 0;
cv::FileStorage fs;
CV_FUNCNAME( "CvAlgorithm::load" );
CV_FUNCNAME( "CvStatModel::load" );
__BEGIN__;
CvFileNode* model_node = 0;
cv::FileNode model_node;
CV_CALL( fs = cvOpenFileStorage( filename, 0, CV_STORAGE_READ ));
if( !fs )
EXIT;
if( !fs.open(filename, cv::FileStorage::READ) )
CV_ERROR( CV_StsError, "Could not open the file storage. Check the path and permissions" );
if( name )
model_node = cvGetFileNodeByName( fs, 0, name );
model_node = fs[ name ];
else
{
CvFileNode* root = cvGetRootFileNode( fs );
if( root->data.seq->total > 0 )
model_node = (CvFileNode*)cvGetSeqElem( root->data.seq, 0 );
auto root = fs.root();
if ( root.size() > 0 )
model_node = fs[0];
}
read( fs, model_node );
read( model_node );
__END__;
cvReleaseFileStorage( &fs );
}
void CvStatModel::write( CvFileStorage*, const char* ) const
void CvStatModel::write( cv::FileStorage&, const char* ) const
{
OPENCV_ERROR( CV_StsNotImplemented, "CvStatModel::write", "" );
}
void CvStatModel::read( CvFileStorage*, CvFileNode* )
void CvStatModel::read( const cv::FileNode& )
{
OPENCV_ERROR( CV_StsNotImplemented, "CvStatModel::read", "" );
}

@ -321,9 +321,9 @@ cvWritebackLabels( const CvMat* labels, CvMat* dst_labels,
#define cvWritebackResponses cvWritebackLabels
#define XML_FIELD_NAME "_name"
CvFileNode* icvFileNodeGetChild(CvFileNode* father, const char* name);
CvFileNode* icvFileNodeGetChildArrayElem(CvFileNode* father, const char* name,int index);
CvFileNode* icvFileNodeGetNext(CvFileNode* n, const char* name);
cv::FileNode icvFileNodeGetChild( cv::FileNode& father, const char* name );
cv::FileNode icvFileNodeGetChildArrayElem( cv::FileNode& father, const char* name,int index );
cv::FileNode icvFileNodeGetNext( cv::FileNode& n, const char* name );
void cvCheckTrainData( const CvMat* train_data, int tflag,

@ -1287,7 +1287,7 @@ int CvDTreeTrainData::get_child_buf_idx( CvDTreeNode* n )
}
void CvDTreeTrainData::write_params( CvFileStorage* fs ) const
void CvDTreeTrainData::write_params( cv::FileStorage& fs ) const
{
CV_FUNCNAME( "CvDTreeTrainData::write_params" );
@ -1295,113 +1295,118 @@ void CvDTreeTrainData::write_params( CvFileStorage* fs ) const
int vi, vcount = var_count;
cvWriteInt( fs, "is_classifier", is_classifier ? 1 : 0 );
cvWriteInt( fs, "var_all", var_all );
cvWriteInt( fs, "var_count", var_count );
cvWriteInt( fs, "ord_var_count", ord_var_count );
cvWriteInt( fs, "cat_var_count", cat_var_count );
fs.write( "is_classifier", is_classifier ? 1 : 0 );
fs.write( "var_all", var_all );
fs.write( "var_count", var_count );
fs.write( "ord_var_count", ord_var_count );
fs.write( "cat_var_count", cat_var_count );
cvStartWriteStruct( fs, "training_params", CV_NODE_MAP );
cvWriteInt( fs, "use_surrogates", params.use_surrogates ? 1 : 0 );
fs.startWriteStruct( "training_params", FileNode::MAP );
fs.write( "use_surrogates", params.use_surrogates ? 1 : 0 );
if( is_classifier )
{
cvWriteInt( fs, "max_categories", params.max_categories );
fs.write( "max_categories", params.max_categories );
}
else
{
cvWriteReal( fs, "regression_accuracy", params.regression_accuracy );
fs.write( "regression_accuracy", params.regression_accuracy );
}
cvWriteInt( fs, "max_depth", params.max_depth );
cvWriteInt( fs, "min_sample_count", params.min_sample_count );
cvWriteInt( fs, "cross_validation_folds", params.cv_folds );
fs.write( "max_depth", params.max_depth );
fs.write( "min_sample_count", params.min_sample_count );
fs.write( "cross_validation_folds", params.cv_folds );
if( params.cv_folds > 1 )
{
cvWriteInt( fs, "use_1se_rule", params.use_1se_rule ? 1 : 0 );
cvWriteInt( fs, "truncate_pruned_tree", params.truncate_pruned_tree ? 1 : 0 );
fs.write( "use_1se_rule", params.use_1se_rule ? 1 : 0 );
fs.write( "truncate_pruned_tree", params.truncate_pruned_tree ? 1 : 0 );
}
if( priors )
cvWrite( fs, "priors", priors );
fs.write( "priors", cvarrToMat(priors) );
cvEndWriteStruct( fs );
fs.endWriteStruct();
if( var_idx )
cvWrite( fs, "var_idx", var_idx );
fs.write( "var_idx", cvarrToMat(var_idx) );
cvStartWriteStruct( fs, "var_type", CV_NODE_SEQ+CV_NODE_FLOW );
fs.startWriteStruct("var_type", FileNode::SEQ + FileNode::FLOW );
for( vi = 0; vi < vcount; vi++ )
cvWriteInt( fs, 0, var_type->data.i[vi] >= 0 );
fs.write( 0, var_type->data.i[vi] >= 0 );
cvEndWriteStruct( fs );
fs.endWriteStruct();
if( cat_count && (cat_var_count > 0 || is_classifier) )
{
CV_ASSERT( cat_count != 0 );
cvWrite( fs, "cat_count", cat_count );
cvWrite( fs, "cat_map", cat_map );
fs.write( "cat_count", cvarrToMat(cat_count) );
fs.write( "cat_map", cvarrToMat(cat_map) );
}
__END__;
}
void CvDTreeTrainData::read_params( CvFileStorage* fs, CvFileNode* node )
void CvDTreeTrainData::read_params( const cv::FileNode& node )
{
CV_FUNCNAME( "CvDTreeTrainData::read_params" );
__BEGIN__;
CvFileNode *tparams_node, *vartype_node;
CvSeqReader reader;
cv::FileNode tparams_node, vartype_node;
FileNodeIterator reader;
int vi, max_split_size, tree_block_size;
is_classifier = (cvReadIntByName( fs, node, "is_classifier" ) != 0);
var_all = cvReadIntByName( fs, node, "var_all" );
var_count = cvReadIntByName( fs, node, "var_count", var_all );
cat_var_count = cvReadIntByName( fs, node, "cat_var_count" );
ord_var_count = cvReadIntByName( fs, node, "ord_var_count" );
is_classifier = (int) node[ "is_classifier" ] != 0;
var_all = (int) node[ "var_all" ];
var_count = node[ "var_count" ].empty() ? var_all : (int)node[ "var_count" ];
cat_var_count = (int) node[ "cat_var_count" ];
ord_var_count = (int) node[ "ord_var_count" ];
tparams_node = cvGetFileNodeByName( fs, node, "training_params" );
tparams_node = node[ "training_params" ];
if( tparams_node ) // training parameters are not necessary
if( !tparams_node.empty() ) // training parameters are not necessary
{
params.use_surrogates = cvReadIntByName( fs, tparams_node, "use_surrogates", 1 ) != 0;
params.use_surrogates = (tparams_node[ "use_surrogates" ].empty() ? 1 : (int)tparams_node[ "use_surrogates" ] ) != 0;
if( is_classifier )
{
params.max_categories = cvReadIntByName( fs, tparams_node, "max_categories" );
params.max_categories = (int) tparams_node[ "max_categories" ];
}
else
{
params.regression_accuracy =
(float)cvReadRealByName( fs, tparams_node, "regression_accuracy" );
params.regression_accuracy = (float) tparams_node[ "regression_accuracy" ];
}
params.max_depth = cvReadIntByName( fs, tparams_node, "max_depth" );
params.min_sample_count = cvReadIntByName( fs, tparams_node, "min_sample_count" );
params.cv_folds = cvReadIntByName( fs, tparams_node, "cross_validation_folds" );
params.max_depth = (int) tparams_node[ "max_depth" ];
params.min_sample_count = (int) tparams_node[ "min_sample_count" ];
params.cv_folds = (int) tparams_node[ "cross_validation_folds" ];
if( params.cv_folds > 1 )
{
params.use_1se_rule = cvReadIntByName( fs, tparams_node, "use_1se_rule" ) != 0;
params.truncate_pruned_tree =
cvReadIntByName( fs, tparams_node, "truncate_pruned_tree" ) != 0;
params.use_1se_rule = (int)tparams_node[ "use_1se_rule" ] != 0;
params.truncate_pruned_tree = (int) tparams_node[ "truncate_pruned_tree" ] != 0;
}
priors = (CvMat*)cvReadByName( fs, tparams_node, "priors" );
if( priors )
priors = nullptr;
if(!tparams_node[ "priors" ].empty())
{
auto tmat = cvMat( tparams_node[ "priors" ].mat() );
priors = cvCloneMat( &tmat );
if( !CV_IS_MAT(priors) )
CV_ERROR( CV_StsParseError, "priors must stored as a matrix" );
priors_mult = cvCloneMat( priors );
}
}
CV_CALL( var_idx = (CvMat*)cvReadByName( fs, node, "var_idx" ));
var_idx = nullptr;
if (!node[ "var_idx" ].empty())
{
auto tmat = cvMat( tparams_node[ "var_idx" ].mat() );
var_idx = cvCloneMat( &tmat );
}
if( var_idx )
{
if( !CV_IS_MAT(var_idx) ||
@ -1421,25 +1426,25 @@ void CvDTreeTrainData::read_params( CvFileStorage* fs, CvFileNode* node )
cat_var_count = 0;
ord_var_count = -1;
vartype_node = cvGetFileNodeByName( fs, node, "var_type" );
vartype_node = node[ "var_type" ];
if( vartype_node && CV_NODE_TYPE(vartype_node->tag) == CV_NODE_INT && var_count == 1 )
var_type->data.i[0] = vartype_node->data.i ? cat_var_count++ : ord_var_count--;
if( !vartype_node.empty() && vartype_node.isInt() && var_count == 1 )
var_type->data.i[0] = (int)vartype_node ? cat_var_count++ : ord_var_count--;
else
{
if( !vartype_node || CV_NODE_TYPE(vartype_node->tag) != CV_NODE_SEQ ||
vartype_node->data.seq->total != var_count )
if( vartype_node.empty() || !vartype_node.isSeq() ||
vartype_node.size() != (size_t) var_count )
CV_ERROR( CV_StsParseError, "var_type must exist and be a sequence of 0's and 1's" );
cvStartReadSeq( vartype_node->data.seq, &reader );
reader = vartype_node.begin();
for( vi = 0; vi < var_count; vi++ )
{
CvFileNode* n = (CvFileNode*)reader.ptr;
if( CV_NODE_TYPE(n->tag) != CV_NODE_INT || (n->data.i & ~1) )
cv::FileNode n = *reader;
if( !n.isInt() || ((int) n & ~1) )
CV_ERROR( CV_StsParseError, "var_type must exist and be a sequence of 0's and 1's" );
var_type->data.i[vi] = n->data.i ? cat_var_count++ : ord_var_count--;
CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
var_type->data.i[vi] = (int) n ? cat_var_count++ : ord_var_count--;
reader++;
}
}
var_type->data.i[var_count] = cat_var_count;
@ -1450,8 +1455,12 @@ void CvDTreeTrainData::read_params( CvFileStorage* fs, CvFileNode* node )
if( cat_var_count > 0 || is_classifier )
{
int ccount, total_c_count = 0;
CV_CALL( cat_count = (CvMat*)cvReadByName( fs, node, "cat_count" ));
CV_CALL( cat_map = (CvMat*)cvReadByName( fs, node, "cat_map" ));
auto cat_count_m = cvMat( node["cat_count"].mat() );
cat_count = cvCloneMat( &cat_count_m );
auto cat_map_m = cvMat( node[ "cat_map" ].mat() );
cat_map = cvCloneMat( &cat_map_m );
if( !CV_IS_MAT(cat_count) || !CV_IS_MAT(cat_map) ||
(cat_count->cols != 1 && cat_count->rows != 1) ||
@ -3690,10 +3699,8 @@ CvDTreeNode* CvDTree::predict( const CvMat* _sample,
CV_Error( CV_StsBadArg,
"one of input categorical variable is not an integer" );
int sh = 0;
while( a < b )
{
sh++;
c = (a + b) >> 1;
if( ival < cmap[c] )
b = c;
@ -3779,13 +3786,13 @@ const CvMat* CvDTree::get_var_importance()
}
void CvDTree::write_split( CvFileStorage* fs, CvDTreeSplit* split ) const
void CvDTree::write_split( cv::FileStorage& fs, CvDTreeSplit* split ) const
{
int ci;
cvStartWriteStruct( fs, 0, CV_NODE_MAP + CV_NODE_FLOW );
cvWriteInt( fs, "var", split->var_idx );
cvWriteReal( fs, "quality", split->quality );
fs.startWriteStruct( 0, FileNode::MAP + FileNode::FLOW );
fs.write( "var", split->var_idx );
fs.write( "quality", split->quality );
ci = data->get_var_type(split->var_idx);
if( ci >= 0 ) // split on a categorical var
@ -3798,59 +3805,57 @@ void CvDTree::write_split( CvFileStorage* fs, CvDTreeSplit* split ) const
// to achieve more compact and clear representation
default_dir = to_right <= 1 || to_right <= MIN(3, n/2) || to_right <= n/3 ? -1 : 1;
cvStartWriteStruct( fs, default_dir*(split->inversed ? -1 : 1) > 0 ?
"in" : "not_in", CV_NODE_SEQ+CV_NODE_FLOW );
fs.startWriteStruct( default_dir*(split->inversed ? -1 : 1) > 0 ?
"in" : "not_in", FileNode::SEQ+FileNode::FLOW );
for( i = 0; i < n; i++ )
{
int dir = CV_DTREE_CAT_DIR(i,split->subset);
if( dir*default_dir < 0 )
cvWriteInt( fs, 0, i );
fs.write( 0, i );
}
cvEndWriteStruct( fs );
fs.endWriteStruct();
}
else
cvWriteReal( fs, !split->inversed ? "le" : "gt", split->ord.c );
fs.write( !split->inversed ? "le" : "gt", split->ord.c );
cvEndWriteStruct( fs );
fs.endWriteStruct();
}
void CvDTree::write_node( CvFileStorage* fs, CvDTreeNode* node ) const
void CvDTree::write_node( cv::FileStorage& fs, CvDTreeNode* node ) const
{
CvDTreeSplit* split;
cvStartWriteStruct( fs, 0, CV_NODE_MAP );
fs.startWriteStruct( 0, FileNode::MAP );
cvWriteInt( fs, "depth", node->depth );
cvWriteInt( fs, "sample_count", node->sample_count );
cvWriteReal( fs, "value", node->value );
fs.write( "depth", node->depth );
fs.write( "sample_count", node->sample_count );
fs.write( "value", node->value );
if( data->is_classifier )
cvWriteInt( fs, "norm_class_idx", node->class_idx );
fs.write( "norm_class_idx", node->class_idx );
cvWriteInt( fs, "Tn", node->Tn );
cvWriteInt( fs, "complexity", node->complexity );
cvWriteReal( fs, "alpha", node->alpha );
cvWriteReal( fs, "node_risk", node->node_risk );
cvWriteReal( fs, "tree_risk", node->tree_risk );
cvWriteReal( fs, "tree_error", node->tree_error );
fs.write( "Tn", node->Tn );
fs.write( "complexity", node->complexity );
fs.write( "alpha", node->alpha );
fs.write( "node_risk", node->node_risk );
fs.write( "tree_risk", node->tree_risk );
fs.write( "tree_error", node->tree_error );
if( node->left )
{
cvStartWriteStruct( fs, "splits", CV_NODE_SEQ );
fs.startWriteStruct( "splits", FileNode::SEQ );
for( split = node->split; split != 0; split = split->next )
for( CvDTreeSplit* split = node->split; split != 0; split = split->next )
write_split( fs, split );
cvEndWriteStruct( fs );
fs.endWriteStruct();
}
cvEndWriteStruct( fs );
fs.endWriteStruct();
}
void CvDTree::write_tree_nodes( CvFileStorage* fs ) const
void CvDTree::write_tree_nodes( cv::FileStorage& fs ) const
{
//CV_FUNCNAME( "CvDTree::write_tree_nodes" );
@ -3884,13 +3889,13 @@ void CvDTree::write_tree_nodes( CvFileStorage* fs ) const
}
void CvDTree::write( CvFileStorage* fs, const char* name ) const
void CvDTree::write( cv::FileStorage& fs, const char* name ) const
{
//CV_FUNCNAME( "CvDTree::write" );
__BEGIN__;
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_TREE );
fs.startWriteStruct( name, FileNode::MAP, CV_TYPE_NAME_ML_TREE );
//get_var_importance();
data->write_params( fs );
@ -3898,29 +3903,29 @@ void CvDTree::write( CvFileStorage* fs, const char* name ) const
//cvWrite( fs, "var_importance", var_importance );
write( fs );
cvEndWriteStruct( fs );
fs.endWriteStruct();
__END__;
}
void CvDTree::write( CvFileStorage* fs ) const
void CvDTree::write( cv::FileStorage& fs ) const
{
//CV_FUNCNAME( "CvDTree::write" );
__BEGIN__;
cvWriteInt( fs, "best_tree_idx", pruned_tree_idx );
fs.write( "best_tree_idx", pruned_tree_idx );
cvStartWriteStruct( fs, "nodes", CV_NODE_SEQ );
fs.startWriteStruct( "nodes", FileNode::SEQ );
write_tree_nodes( fs );
cvEndWriteStruct( fs );
fs.endWriteStruct();
__END__;
}
CvDTreeSplit* CvDTree::read_split( CvFileStorage* fs, CvFileNode* fnode )
CvDTreeSplit* CvDTree::read_split( const cv::FileNode& fnode )
{
CvDTreeSplit* split = 0;
@ -3930,10 +3935,10 @@ CvDTreeSplit* CvDTree::read_split( CvFileStorage* fs, CvFileNode* fnode )
int vi, ci;
if( !fnode || CV_NODE_TYPE(fnode->tag) != CV_NODE_MAP )
if( fnode.empty() || !fnode.isMap() )
CV_ERROR( CV_StsParseError, "some of the splits are not stored properly" );
vi = cvReadIntByName( fs, fnode, "var", -1 );
vi = fnode[ "var" ].empty() ? -1 : (int) fnode[ "var" ];
if( (unsigned)vi >= (unsigned)data->var_count )
CV_ERROR( CV_StsOutOfRange, "Split variable index is out of range" );
@ -3941,23 +3946,23 @@ CvDTreeSplit* CvDTree::read_split( CvFileStorage* fs, CvFileNode* fnode )
if( ci >= 0 ) // split on categorical var
{
int i, n = data->cat_count->data.i[ci], inversed = 0, val;
CvSeqReader reader;
CvFileNode* inseq;
FileNodeIterator reader;
cv::FileNode inseq;
split = data->new_split_cat( vi, 0 );
inseq = cvGetFileNodeByName( fs, fnode, "in" );
if( !inseq )
inseq = fnode[ "in" ];
if( inseq.empty() )
{
inseq = cvGetFileNodeByName( fs, fnode, "not_in" );
inseq = fnode[ "not_in" ];
inversed = 1;
}
if( !inseq ||
(CV_NODE_TYPE(inseq->tag) != CV_NODE_SEQ && CV_NODE_TYPE(inseq->tag) != CV_NODE_INT))
if( inseq.empty() ||
(!inseq.isSeq() && !inseq.isInt()))
CV_ERROR( CV_StsParseError,
"Either 'in' or 'not_in' tags should be inside a categorical split data" );
if( CV_NODE_TYPE(inseq->tag) == CV_NODE_INT )
if( inseq.isInt() )
{
val = inseq->data.i;
val = (int) inseq;
if( (unsigned)val >= (unsigned)n )
CV_ERROR( CV_StsOutOfRange, "some of in/not_in elements are out of range" );
@ -3965,17 +3970,17 @@ CvDTreeSplit* CvDTree::read_split( CvFileStorage* fs, CvFileNode* fnode )
}
else
{
cvStartReadSeq( inseq->data.seq, &reader );
reader = inseq.begin();
for( i = 0; i < reader.seq->total; i++ )
for( i = 0; i < (int) (*reader).size(); i++ )
{
CvFileNode* inode = (CvFileNode*)reader.ptr;
val = inode->data.i;
if( CV_NODE_TYPE(inode->tag) != CV_NODE_INT || (unsigned)val >= (unsigned)n )
cv::FileNode inode = *reader;
val = (int) inode;
if( !inode.isInt() || (unsigned)val >= (unsigned)n )
CV_ERROR( CV_StsOutOfRange, "some of in/not_in elements are out of range" );
split->subset[val >> 5] |= 1 << (val & 31);
CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
reader++;
}
}
@ -3987,20 +3992,20 @@ CvDTreeSplit* CvDTree::read_split( CvFileStorage* fs, CvFileNode* fnode )
}
else
{
CvFileNode* cmp_node;
cv::FileNode cmp_node;
split = data->new_split_ord( vi, 0, 0, 0, 0 );
cmp_node = cvGetFileNodeByName( fs, fnode, "le" );
if( !cmp_node )
cmp_node = fnode[ "le" ];
if( cmp_node.empty() )
{
cmp_node = cvGetFileNodeByName( fs, fnode, "gt" );
cmp_node = fnode[ "gt" ];
split->inversed = 1;
}
split->ord.c = (float)cvReadReal( cmp_node );
split->ord.c = (float) cmp_node;
}
split->quality = (float)cvReadRealByName( fs, fnode, "quality" );
split->quality = (float) fnode[ "quality" ];
__END__;
@ -4008,7 +4013,7 @@ CvDTreeSplit* CvDTree::read_split( CvFileStorage* fs, CvFileNode* fnode )
}
CvDTreeNode* CvDTree::read_node( CvFileStorage* fs, CvFileNode* fnode, CvDTreeNode* parent )
CvDTreeNode* CvDTree::read_node( const cv::FileNode& fnode, CvDTreeNode* parent )
{
CvDTreeNode* node = 0;
@ -4016,49 +4021,49 @@ CvDTreeNode* CvDTree::read_node( CvFileStorage* fs, CvFileNode* fnode, CvDTreeNo
__BEGIN__;
CvFileNode* splits;
cv::FileNode splits;
int i, depth;
if( !fnode || CV_NODE_TYPE(fnode->tag) != CV_NODE_MAP )
if( fnode.empty() || !fnode.isMap() )
CV_ERROR( CV_StsParseError, "some of the tree elements are not stored properly" );
CV_CALL( node = data->new_node( parent, 0, 0, 0 ));
depth = cvReadIntByName( fs, fnode, "depth", -1 );
depth = fnode[ "depth" ].empty() ? -1 : (int) fnode[ "depth" ];
if( depth != node->depth )
CV_ERROR( CV_StsParseError, "incorrect node depth" );
node->sample_count = cvReadIntByName( fs, fnode, "sample_count" );
node->value = cvReadRealByName( fs, fnode, "value" );
node->sample_count = (int) fnode[ "sample_count" ];
node->value = (double) fnode[ "value" ];
if( data->is_classifier )
node->class_idx = cvReadIntByName( fs, fnode, "norm_class_idx" );
node->class_idx = (int) fnode[ "norm_class_idx" ];
node->Tn = cvReadIntByName( fs, fnode, "Tn" );
node->complexity = cvReadIntByName( fs, fnode, "complexity" );
node->alpha = cvReadRealByName( fs, fnode, "alpha" );
node->node_risk = cvReadRealByName( fs, fnode, "node_risk" );
node->tree_risk = cvReadRealByName( fs, fnode, "tree_risk" );
node->tree_error = cvReadRealByName( fs, fnode, "tree_error" );
node->Tn = (int) fnode[ "Tn" ];
node->complexity = (int) fnode[ "complexity" ];
node->alpha = (double) fnode[ "alpha" ];
node->node_risk = (double) fnode[ "node_risk" ];
node->tree_risk = (double) fnode[ "tree_risk" ];
node->tree_error = (double) fnode[ "tree_error" ];
splits = cvGetFileNodeByName( fs, fnode, "splits" );
if( splits )
splits = fnode[ "splits" ];
if( !splits.empty() )
{
CvSeqReader reader;
FileNodeIterator reader;
CvDTreeSplit* last_split = 0;
if( CV_NODE_TYPE(splits->tag) != CV_NODE_SEQ )
if( !splits.isSeq() )
CV_ERROR( CV_StsParseError, "splits tag must stored as a sequence" );
cvStartReadSeq( splits->data.seq, &reader );
for( i = 0; i < reader.seq->total; i++ )
reader = splits.begin();
for( i = 0; i < (int) (*reader).size(); i++ )
{
CvDTreeSplit* split;
CV_CALL( split = read_split( fs, (CvFileNode*)reader.ptr ));
CV_CALL( split = read_split( *reader ));
if( !last_split )
node->split = last_split = split;
else
last_split = last_split->next = split;
CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
reader++;
}
}
@ -4068,25 +4073,25 @@ CvDTreeNode* CvDTree::read_node( CvFileStorage* fs, CvFileNode* fnode, CvDTreeNo
}
void CvDTree::read_tree_nodes( CvFileStorage* fs, CvFileNode* fnode )
void CvDTree::read_tree_nodes( const cv::FileNode& fnode )
{
CV_FUNCNAME( "CvDTree::read_tree_nodes" );
__BEGIN__;
CvSeqReader reader;
FileNodeIterator reader;
CvDTreeNode _root;
CvDTreeNode* parent = &_root;
int i;
parent->left = parent->right = parent->parent = 0;
cvStartReadSeq( fnode->data.seq, &reader );
reader = fnode.begin();
for( i = 0; i < reader.seq->total; i++ )
for( i = 0; i < (int) (*reader).size(); i++ )
{
CvDTreeNode* node;
CV_CALL( node = read_node( fs, (CvFileNode*)reader.ptr, parent != &_root ? parent : 0 ));
CV_CALL( node = read_node( *reader, parent != &_root ? parent : 0 ));
if( !parent->left )
parent->left = node;
else
@ -4099,7 +4104,7 @@ void CvDTree::read_tree_nodes( CvFileStorage* fs, CvFileNode* fnode )
parent = parent->parent;
}
CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
reader++;
}
root = _root.left;
@ -4108,34 +4113,34 @@ void CvDTree::read_tree_nodes( CvFileStorage* fs, CvFileNode* fnode )
}
void CvDTree::read( CvFileStorage* fs, CvFileNode* fnode )
void CvDTree::read( const cv::FileNode& fnode )
{
CvDTreeTrainData* _data = new CvDTreeTrainData();
_data->read_params( fs, fnode );
_data->read_params( fnode );
read( fs, fnode, _data );
read( fnode, _data );
get_var_importance();
}
// a special entry point for reading weak decision trees from the tree ensembles
void CvDTree::read( CvFileStorage* fs, CvFileNode* node, CvDTreeTrainData* _data )
void CvDTree::read( const cv::FileNode& node, CvDTreeTrainData* _data )
{
CV_FUNCNAME( "CvDTree::read" );
__BEGIN__;
CvFileNode* tree_nodes;
cv::FileNode tree_nodes;
clear();
data = _data;
tree_nodes = cvGetFileNodeByName( fs, node, "nodes" );
if( !tree_nodes || CV_NODE_TYPE(tree_nodes->tag) != CV_NODE_SEQ )
tree_nodes = node[ "nodes" ];
if( tree_nodes.empty() || !tree_nodes.isSeq() )
CV_ERROR( CV_StsParseError, "nodes tag is missing" );
pruned_tree_idx = cvReadIntByName( fs, node, "best_tree_idx", -1 );
read_tree_nodes( fs, tree_nodes );
pruned_tree_idx = node[ "best_tree_idx" ].empty() ? -1 : node[ "best_tree_idx" ];
read_tree_nodes( tree_nodes );
__END__;
}

@ -362,7 +362,7 @@ if(CUDA_FOUND)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)
endif()
OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC)
mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD CUDA_SDK_ROOT_DIR)
@ -565,13 +565,17 @@ if(HAVE_CUDA)
endforeach()
if(MSVC AND CUDA_ENABLE_DELAYLOAD)
set(DELAYFLAGS "delayimp.lib")
file(GLOB CUDA_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/*.dll")
foreach(d ${CUDA_DLLS})
cmake_path(GET "d" FILENAME DLL_NAME)
if(NOT ${DLL_NAME} MATCHES "cudart")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:${DLL_NAME}")
set(DELAYFLAGS "${DELAYFLAGS} /DELAYLOAD:${DLL_NAME}")
endif()
endforeach()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4199")
set(DELAYFLAGS "${DELAYFLAGS} /DELAYLOAD:nvcuda.dll /DELAYLOAD:nvml.dll /IGNORE:4199")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DELAYFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${DELAYFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${DELAYFLAGS}")
endif()
endif()

@ -0,0 +1,19 @@
if(WITH_FLATBUFFERS)
set(HAVE_FLATBUFFERS 1)
set(flatbuffers_VERSION "23.5.9")
ocv_install_3rdparty_licenses(flatbuffers "${OpenCV_SOURCE_DIR}/3rdparty/flatbuffers/LICENSE.txt")
ocv_add_external_target(flatbuffers "${OpenCV_SOURCE_DIR}/3rdparty/flatbuffers/include" "" "HAVE_FLATBUFFERS=1")
set(CUSTOM_STATUS_flatbuffers " Flatbuffers:" "builtin/3rdparty (${flatbuffers_VERSION})")
endif()
if(WITH_FLATBUFFERS OR HAVE_FLATBUFFERS)
list(APPEND CUSTOM_STATUS flatbuffers)
if(HAVE_FLATBUFFERS)
if(NOT CUSTOM_STATUS_flatbuffers)
list(APPEND CUSTOM_STATUS_flatbuffers " Flatbuffers:" "${flatbuffers_VERSION}")
endif()
else()
list(APPEND CUSTOM_STATUS_flatbuffers " Flatbuffers:" "NO")
endif()
endif()

@ -297,3 +297,10 @@ elseif(PYTHON3_EXECUTABLE AND PYTHON3INTERP_FOUND)
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}")
endif()
if(PYTHON_DEFAULT_AVAILABLE)
execute_process(COMMAND ${PYTHON_DEFAULT_EXECUTABLE} --version
OUTPUT_VARIABLE PYTHON_DEFAULT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" PYTHON_DEFAULT_VERSION "${PYTHON_DEFAULT_VERSION}")
endif()

@ -1,5 +1,5 @@
set(VULKAN_INCLUDE_DIRS "${OpenCV_SOURCE_DIR}/3rdparty/include" CACHE PATH "Vulkan include directory")
set(VULKAN_LIBRARIES "")
set(VULKAN_LIBRARIES "" CACHE PATH "Path to Vulkan Libraries.")
try_compile(VALID_VULKAN
"${OpenCV_BINARY_DIR}"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save