JPEG2000Boxes.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2024, Nico Weber <thakis@chromium.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "Boxes.h"
  8. namespace Gfx::ISOBMFF {
  9. struct JPEG2000HeaderBox final : public SuperBox {
  10. BOX_SUBTYPE(JPEG2000HeaderBox);
  11. };
  12. // I.5.3.1 Image Header box
  13. struct JPEG2000ImageHeaderBox final : public Box {
  14. BOX_SUBTYPE(JPEG2000ImageHeaderBox);
  15. u32 height { 0 };
  16. u32 width { 0 };
  17. u16 num_components { 0 };
  18. u8 bits_per_component { 0 };
  19. u8 compression_type { 0 };
  20. u8 is_colorspace_unknown { 0 };
  21. u8 contains_intellectual_property_rights { 0 };
  22. };
  23. // I.5.3.3 Colour Specification box
  24. struct JPEG2000ColorSpecificationBox final : public Box {
  25. BOX_SUBTYPE(JPEG2000ColorSpecificationBox);
  26. u8 method { 0 };
  27. i8 precedence { 0 };
  28. u8 approximation { 0 };
  29. u32 enumerated_color_space { 0 }; // Only set if method == 1
  30. ByteBuffer icc_data; // Only set if method == 2
  31. };
  32. // I.5.3.6 Channel Definition box
  33. struct JPEG2000ChannelDefinitionBox final : public Box {
  34. BOX_SUBTYPE(JPEG2000ChannelDefinitionBox);
  35. struct Channel {
  36. u16 channel_index;
  37. u16 channel_type;
  38. u16 channel_association;
  39. };
  40. Vector<Channel> channels;
  41. };
  42. // I.5.3.7 Resolution box
  43. struct JPEG2000ResolutionBox final : public SuperBox {
  44. BOX_SUBTYPE(JPEG2000ResolutionBox);
  45. };
  46. // I.5.3.7.1 Capture Resolution box
  47. struct JPEG2000CaptureResolutionBox final : public Box {
  48. BOX_SUBTYPE(JPEG2000CaptureResolutionBox);
  49. u16 vertical_capture_grid_resolution_numerator { 0 };
  50. u16 vertical_capture_grid_resolution_denominator { 0 };
  51. u16 horizontal_capture_grid_resolution_numerator { 0 };
  52. u16 horizontal_capture_grid_resolution_denominator { 0 };
  53. i8 vertical_capture_grid_resolution_exponent { 0 };
  54. i8 horizontal_capture_grid_resolution_exponent { 0 };
  55. };
  56. // I.5.4 Contiguous Codestream box
  57. struct JPEG2000ContiguousCodestreamBox final : public Box {
  58. BOX_SUBTYPE(JPEG2000ContiguousCodestreamBox);
  59. ByteBuffer codestream;
  60. };
  61. struct JPEG2000SignatureBox final : public Box {
  62. BOX_SUBTYPE(JPEG2000SignatureBox);
  63. u32 signature { 0 };
  64. };
  65. // I.7.3 UUID Info boxes (superbox)
  66. struct JPEG2000UUIDInfoBox final : public SuperBox {
  67. BOX_SUBTYPE(JPEG2000UUIDInfoBox);
  68. };
  69. // I.7.3.1 UUID List box
  70. struct JPEG2000UUIDListBox final : public Box {
  71. BOX_SUBTYPE(JPEG2000UUIDListBox);
  72. Vector<Array<u8, 16>> uuids;
  73. };
  74. // I.7.3.2 Data Entry URL box
  75. struct JPEG2000URLBox final : public Box {
  76. BOX_SUBTYPE(JPEG2000URLBox);
  77. ErrorOr<String> url_as_string() const;
  78. u8 version_number;
  79. u32 flag;
  80. ByteBuffer url_bytes;
  81. };
  82. }