blob: 2bb4dabbfddfedb1609cd2ebbddd09b4263d7cb2 [file]
// 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_GIF_CONSTANTS_H_
#define THIRD_PARTY_CREDENTIO_FORMATS_GIF_CONSTANTS_H_
#include <cstdint>
#include "absl/strings/string_view.h"
namespace credentio {
// GIF format: https://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html
// C2PA only supports GIF89a format:
// https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_gif_specific_handling
constexpr absl::string_view kGifHeaderBlock = "GIF89a";
// Header Block (6) + Logical Screen Descriptor (7) + Trailer (1)
constexpr int64_t kMinGifSize = 6 + 7 + 1;
// Introducers (First Byte)
constexpr uint8_t kGifExtensionIntroducer = 0x21;
constexpr uint8_t kGifImageDescriptorIntroducer = 0x2C;
constexpr uint8_t kGifTrailerIntroducer = 0x3B;
// Extension Label (Second Byte when introducer is 0x21)
constexpr uint8_t kGifExtensionPlainText = 0x01;
constexpr uint8_t kGifExtensionGraphicsControl = 0xF9;
constexpr uint8_t kGifExtensionComment = 0xFE;
constexpr uint8_t kGifExtensionApplication = 0xFF;
// Corresponding C2PA Box Labels
constexpr absl::string_view kGifLogicalScreenDescriptorLabel = "LSD";
constexpr absl::string_view kGifImageDescriptorLabel = "2C";
constexpr absl::string_view kGifTrailerLabel = "3B";
constexpr absl::string_view kGifImageDataLabel = "TBID";
constexpr absl::string_view kGifExtensionPlainTextLabel = "2101";
constexpr absl::string_view kGifExtensionGraphicsControlLabel = "21F9";
constexpr absl::string_view kGifExtensionCommentLabel = "21FE";
constexpr absl::string_view kGifExtensionApplicationLabel = "21FF";
constexpr absl::string_view kGifAfterLabel = "c2pa.after";
// C2PA Block Information
// Embedding Information:
// https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_embedding_manifests_into_gifs
constexpr uint8_t kGifC2paExtensionInfoSize = 0x0B;
constexpr absl::string_view kGifC2paIdentifier = "C2PA_GIF";
constexpr uint16_t kGifC2paAuthenticationCode = 0x0100;
constexpr absl::string_view kGifC2paLabel = "C2PA";
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_FORMATS_GIF_CONSTANTS_H_