diff --git a/libheif/api/libheif/heif.h b/libheif/api/libheif/heif.h index 82cf0b23d8..855402b74d 100644 --- a/libheif/api/libheif/heif.h +++ b/libheif/api/libheif/heif.h @@ -2429,8 +2429,8 @@ struct heif_tild_image_parameters { // --- version 1 - uint64_t image_width; - uint64_t image_height; + uint32_t image_width; + uint32_t image_height; uint32_t tile_width; uint32_t tile_height; @@ -2441,7 +2441,7 @@ struct heif_tild_image_parameters { uint8_t size_field_length; // one of: 0, 24, 32, 64 uint8_t number_of_extra_dimensions; // 0 for normal images, 1 for volumetric (3D), ... - uint64_t extra_dimensions[8]; // size of extra dimensions (first 8 dimensions) + uint32_t extra_dimensions[8]; // size of extra dimensions (first 8 dimensions) // boolean flags uint8_t tiles_are_sequential; // TODO: can we derive this automatically diff --git a/libheif/codecs/tild.cc b/libheif/codecs/tild.cc index 3b3af35743..51ba05fe4b 100644 --- a/libheif/codecs/tild.cc +++ b/libheif/codecs/tild.cc @@ -66,12 +66,6 @@ uint64_t nTiles_v(const heif_tild_image_parameters& params) } -bool dimensions_64bit(const heif_tild_image_parameters& params) -{ - return (params.image_width > 0xFFFF || params.image_height > 0xFFFF); -} - - void Box_tilC::derive_box_version() { set_version(1); @@ -112,16 +106,10 @@ void Box_tilC::derive_box_version() assert(false); // TODO: return error } - // printf("> %d %d -> %d\n", m_parameters.offset_field_length, m_parameters.size_field_length, (int)flags); - if (m_parameters.tiles_are_sequential) { flags |= 0x10; } - if (dimensions_64bit(m_parameters)) { - flags |= 0x20; - } - set_flags(flags); } @@ -132,26 +120,20 @@ Error Box_tilC::write(StreamWriter& writer) const size_t box_start = reserve_box_header_space(writer); - bool dimensions_are_64bit = dimensions_64bit(m_parameters); - if (m_parameters.number_of_extra_dimensions > 8) { assert(false); // currently not supported } - writer.write8(m_parameters.number_of_extra_dimensions); + writer.write32(m_parameters.tile_width); + writer.write32(m_parameters.tile_height); + writer.write32(m_parameters.compression_type_fourcc); - // TODO: this is redundant because we can also get this from 'ispe' (but currently only as uint32_t) - //writer.write(dimensions_are_64bit ? 8 : 4, m_parameters.image_width); - //writer.write(dimensions_are_64bit ? 8 : 4, m_parameters.image_height); + writer.write8(m_parameters.number_of_extra_dimensions); for (int i = 0; i < m_parameters.number_of_extra_dimensions; i++) { - writer.write(dimensions_are_64bit ? 8 : 4, m_parameters.extra_dimensions[i]); + writer.write32(m_parameters.extra_dimensions[i]); } - writer.write32(m_parameters.tile_width); - writer.write32(m_parameters.tile_height); - writer.write32(m_parameters.compression_type_fourcc); - prepend_header(writer, box_start); return Error::Ok; @@ -226,33 +208,25 @@ Error Box_tilC::parse(BitstreamRange& range) } m_parameters.tiles_are_sequential = !!(flags & 0x10); - bool dimensions_are_64bit = (flags & 0x20); - m_parameters.number_of_extra_dimensions = range.read8(); -#if 0 - if (data.size() < idx + 2 * (dimensions_are_64bit ? 8 : 4)) { - return eofError; - } - - if (data.size() < idx + (2 + m_parameters.number_of_extra_dimensions) * (dimensions_are_64bit ? 8 : 4) + 3 * 4) { - return eofError; - } -#endif - - /* - m_parameters.image_width = (dimensions_are_64bit ? range.read64() : range.read32()); - m_parameters.image_height = (dimensions_are_64bit ? range.read64() : range.read32()); + m_parameters.tile_width = range.read32(); + m_parameters.tile_height = range.read32(); + m_parameters.compression_type_fourcc = range.read32(); - if (m_parameters.image_width == 0 || m_parameters.image_height == 0) { + if (m_parameters.tile_width == 0 || m_parameters.tile_height == 0) { return {heif_error_Invalid_input, heif_suberror_Unspecified, - "'tild' image with zero width or height."}; + "Tile with zero width or height."}; } -*/ + + + // --- extra dimensions + + m_parameters.number_of_extra_dimensions = range.read8(); for (int i = 0; i < m_parameters.number_of_extra_dimensions; i++) { - uint64_t size = (dimensions_are_64bit ? range.read64() : range.read32()); + uint32_t size = range.read32(); if (size == 0) { return {heif_error_Invalid_input, @@ -268,15 +242,6 @@ Error Box_tilC::parse(BitstreamRange& range) } } - m_parameters.tile_width = range.read32(); - m_parameters.tile_height = range.read32(); - m_parameters.compression_type_fourcc = range.read32(); - - if (m_parameters.tile_width == 0 || m_parameters.tile_height == 0) { - return {heif_error_Invalid_input, - heif_suberror_Unspecified, - "Tile with zero width or height."}; - } return range.get_error(); }