| // Copyright 2026 Google LLC | |
| // | |
| // 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 | |
| // | |
| // https://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 THIRD_PARTY_CREDENTIO_FORMATS_JPEG_TESTING_APP_SEGMENT_CREATOR_H_ | |
| #define THIRD_PARTY_CREDENTIO_FORMATS_JPEG_TESTING_APP_SEGMENT_CREATOR_H_ | |
| #include <cstdint> | |
| #include <optional> | |
| #include <string> | |
| #include <vector> | |
| #include "absl/status/statusor.h" | |
| namespace credentio { | |
| struct AppSegmentParams { | |
| uint16_t marker = 0xffeb; // APP11 Marker | |
| uint16_t cl = 0x4a50; // APP11 JPEG Extension Indicator | |
| std::optional<uint16_t> en = std::nullopt; // En: Instance Number | |
| // Maximum size of the segment in bytes | |
| uint32_t max_size = 65535; | |
| // Z is the sequence number of the segment starting at the speficied value and | |
| // using the z_incrementer function to increment | |
| uint32_t starting_z = 1; | |
| uint32_t (*z_incrementer)(uint32_t) = [](uint32_t z) { return z + 1; }; | |
| // The data to be embedded, potentially split into multiple segments | |
| std::string payload; | |
| }; | |
| // Creates Jpeg APP segments they are APP11 segments by default but can be | |
| // overridden by setting the various fields within the AppSegmentParams | |
| // See ISO/IEC 18477-3:2023 for the specification of APP segments | |
| absl::StatusOr<std::vector<std::string>> CreateAppSegments( | |
| AppSegmentParams params); | |
| } // namespace credentio | |
| #endif // THIRD_PARTY_CREDENTIO_FORMATS_JPEG_TESTING_APP_SEGMENT_CREATOR_H_ |