[Bf-blender-cvs] [0c384362272] master: Alembic: remove support for HDF5 archive format

Sybren A. Stüvel noreply at git.blender.org
Mon Jun 15 11:12:45 CEST 2020


Commit: 0c384362272637a3e55b480ac03527a1d1df7a90
Author: Sybren A. Stüvel
Date:   Mon Jun 15 11:06:46 2020 +0200
Branches: master
https://developer.blender.org/rB0c384362272637a3e55b480ac03527a1d1df7a90

Alembic: remove support for HDF5 archive format

Alembic is not a single file format, it can be stored in two different
ways: Ogawa and HDF5. Ogawa replaced HDF5 and is smaller and much faster
(4-25x) to read ([source](http://exocortex.com/blog/alembic_is_about_to_get_really_fast)).

As long as Blender has had Alembic support, it has never supported the
HDF5 format in any release. There is a build option `WITH_ALEMBIC_HDF5`
that can be used to enable HDF5 support in your own build. This commit
removes this build option and the code that it manages.

In the years that I have been maintainer of Blender's Alembic code, I
only remember getting a request to support HDF5 once, and that was to
support very old software that has likely since then been updated to
support Ogawa. Ubuntu and Fedora also seem to bundle Blender without
HDF5 support.

This decision was discussed on
[DevTalk](https://devtalk.blender.org/t/alembic-hdf5-support-completely-remove)
where someone also mentioned that there is a tool available that can
convert HDF5 files to the Ogawa format.

===================================================================

M	source/blender/editors/io/CMakeLists.txt
M	source/blender/editors/io/io_alembic.c
M	source/blender/io/alembic/ABC_alembic.h
M	source/blender/io/alembic/CMakeLists.txt
M	source/blender/io/alembic/intern/abc_exporter.cc
M	source/blender/io/alembic/intern/abc_exporter.h
M	source/blender/io/alembic/intern/abc_reader_archive.cc
M	source/blender/io/alembic/intern/abc_reader_archive.h
M	source/blender/io/alembic/intern/abc_writer_archive.cc
M	source/blender/io/alembic/intern/abc_writer_archive.h
M	source/blender/io/alembic/intern/alembic_capi.cc
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/rna_scene_api.c

===================================================================

diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt
index 39548449a86..e7effd05d34 100644
--- a/source/blender/editors/io/CMakeLists.txt
+++ b/source/blender/editors/io/CMakeLists.txt
@@ -66,10 +66,6 @@ if(WITH_ALEMBIC)
     bf_alembic
   )
   add_definitions(-DWITH_ALEMBIC)
-
-  if(WITH_ALEMBIC_HDF5)
-    add_definitions(-DWITH_ALEMBIC_HDF5)
-  endif()
 endif()
 
 if(WITH_USD)
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index 24c0c1a39ba..fc2c55ffeda 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -133,7 +133,6 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op)
       .use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
       .export_hair = RNA_boolean_get(op->ptr, "export_hair"),
       .export_particles = RNA_boolean_get(op->ptr, "export_particles"),
-      .compression_type = RNA_enum_get(op->ptr, "compression_type"),
       .packuv = RNA_boolean_get(op->ptr, "packuv"),
       .triangulate = RNA_boolean_get(op->ptr, "triangulate"),
       .quad_method = RNA_enum_get(op->ptr, "quad_method"),
@@ -163,15 +162,6 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
   uiLayout *row;
   uiLayout *col;
 
-#  ifdef WITH_ALEMBIC_HDF5
-  box = uiLayoutBox(layout);
-  row = uiLayoutRow(box, false);
-  uiItemL(row, IFACE_("Archive Options:"), ICON_NONE);
-
-  row = uiLayoutRow(box, false);
-  uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE);
-#  endif
-
   box = uiLayoutBox(layout);
   row = uiLayoutRow(box, false);
   uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
@@ -429,13 +419,6 @@ void WM_OT_alembic_export(wmOperatorType *ot)
                   "Curves as Mesh",
                   "Export curves and NURBS surfaces as meshes");
 
-  RNA_def_enum(ot->srna,
-               "compression_type",
-               rna_enum_abc_compression_items,
-               ABC_ARCHIVE_OGAWA,
-               "Compression",
-               "");
-
   RNA_def_float(
       ot->srna,
       "global_scale",
diff --git a/source/blender/io/alembic/ABC_alembic.h b/source/blender/io/alembic/ABC_alembic.h
index ccc53c589fb..ba430752b29 100644
--- a/source/blender/io/alembic/ABC_alembic.h
+++ b/source/blender/io/alembic/ABC_alembic.h
@@ -35,11 +35,6 @@ struct bContext;
 
 typedef struct AbcArchiveHandle AbcArchiveHandle;
 
-enum {
-  ABC_ARCHIVE_OGAWA = 0,
-  ABC_ARCHIVE_HDF5 = 1,
-};
-
 int ABC_get_version(void);
 
 struct AlembicExportParams {
@@ -68,8 +63,6 @@ struct AlembicExportParams {
   bool export_hair;
   bool export_particles;
 
-  unsigned int compression_type : 1;
-
   /* See MOD_TRIANGULATE_NGON_xxx and MOD_TRIANGULATE_QUAD_xxx
    * in DNA_modifier_types.h */
   int quad_method;
diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt
index 6de7d327d4e..16f2d944876 100644
--- a/source/blender/io/alembic/CMakeLists.txt
+++ b/source/blender/io/alembic/CMakeLists.txt
@@ -36,7 +36,6 @@ set(INC
 set(INC_SYS
   ${ALEMBIC_INCLUDE_DIRS}
   ${BOOST_INCLUDE_DIR}
-  ${HDF5_INCLUDE_DIRS}
   ${OPENEXR_INCLUDE_DIRS}
 )
 
@@ -98,13 +97,6 @@ set(LIB
   ${OPENEXR_LIBRARIES}
 )
 
-if(WITH_ALEMBIC_HDF5)
-  add_definitions(-DWITH_ALEMBIC_HDF5)
-  list(APPEND LIB
-    ${HDF5_LIBRARIES}
-  )
-endif()
-
 list(APPEND LIB
   ${BOOST_LIBRARIES}
 )
diff --git a/source/blender/io/alembic/intern/abc_exporter.cc b/source/blender/io/alembic/intern/abc_exporter.cc
index dbf24452b78..8dad8dff199 100644
--- a/source/blender/io/alembic/intern/abc_exporter.cc
+++ b/source/blender/io/alembic/intern/abc_exporter.cc
@@ -93,7 +93,6 @@ ExportSettings::ExportSettings()
       apply_subdiv(false),
       use_subdiv_schema(false),
       export_child_hairs(true),
-      export_ogawa(true),
       pack_uv(false),
       triangulate(false),
       quad_method(0),
@@ -276,8 +275,7 @@ void AbcExporter::operator()(short *do_update, float *progress, bool *was_cancel
     abc_scene_name = "untitled";
   }
 
-  m_writer = new ArchiveWriter(
-      m_filename, abc_scene_name, m_settings.scene, m_settings.export_ogawa);
+  m_writer = new ArchiveWriter(m_filename, abc_scene_name, m_settings.scene);
 
   /* Create time samplings for transforms and shapes. */
 
diff --git a/source/blender/io/alembic/intern/abc_exporter.h b/source/blender/io/alembic/intern/abc_exporter.h
index 398004d2ec5..049ccb291bd 100644
--- a/source/blender/io/alembic/intern/abc_exporter.h
+++ b/source/blender/io/alembic/intern/abc_exporter.h
@@ -73,7 +73,6 @@ struct ExportSettings {
   bool curves_as_mesh;
   bool use_subdiv_schema;
   bool export_child_hairs;
-  bool export_ogawa;
   bool pack_uv;
   bool triangulate;
 
diff --git a/source/blender/io/alembic/intern/abc_reader_archive.cc b/source/blender/io/alembic/intern/abc_reader_archive.cc
index 563466d81bc..d55736f732a 100644
--- a/source/blender/io/alembic/intern/abc_reader_archive.cc
+++ b/source/blender/io/alembic/intern/abc_reader_archive.cc
@@ -40,11 +40,8 @@ using Alembic::Abc::IArchive;
 using Alembic::Abc::kWrapExisting;
 
 static IArchive open_archive(const std::string &filename,
-                             const std::vector<std::istream *> &input_streams,
-                             bool &is_hdf5)
+                             const std::vector<std::istream *> &input_streams)
 {
-  is_hdf5 = false;
-
   try {
     Alembic::AbcCoreOgawa::ReadArchive archive_reader(input_streams);
 
@@ -53,22 +50,7 @@ static IArchive open_archive(const std::string &filename,
   catch (const Exception &e) {
     std::cerr << e.what() << '\n';
 
-#ifdef WITH_ALEMBIC_HDF5
-    try {
-      is_hdf5 = true;
-      Alembic::AbcCoreAbstract::ReadArraySampleCachePtr cache_ptr;
-
-      return IArchive(Alembic::AbcCoreHDF5::ReadArchive(),
-                      filename.c_str(),
-                      ErrorHandler::kThrowPolicy,
-                      cache_ptr);
-    }
-    catch (const Exception &) {
-      std::cerr << e.what() << '\n';
-      return IArchive();
-    }
-#else
-    /* Inspect the file to see whether it's really a HDF5 file. */
+    /* Inspect the file to see whether it's actually a HDF5 file. */
     char header[4]; /* char(0x89) + "HDF" */
     std::ifstream the_file(filename.c_str(), std::ios::in | std::ios::binary);
     if (!the_file) {
@@ -81,16 +63,12 @@ static IArchive open_archive(const std::string &filename,
       std::cerr << filename << " has an unknown file format, unable to read." << std::endl;
     }
     else {
-      is_hdf5 = true;
       std::cerr << filename << " is in the obsolete HDF5 format, unable to read." << std::endl;
     }
 
     if (the_file.is_open()) {
       the_file.close();
     }
-
-    return IArchive();
-#endif
   }
 
   return IArchive();
@@ -113,18 +91,7 @@ ArchiveReader::ArchiveReader(struct Main *bmain, const char *filename)
 
   m_streams.push_back(&m_infile);
 
-  m_archive = open_archive(abs_filename, m_streams, m_is_hdf5);
-
-  /* We can't open an HDF5 file from a stream, so close it. */
-  if (m_is_hdf5) {
-    m_infile.close();
-    m_streams.clear();
-  }
-}
-
-bool ArchiveReader::is_hdf5() const
-{
-  return m_is_hdf5;
+  m_archive = open_archive(abs_filename, m_streams);
 }
 
 bool ArchiveReader::valid() const
diff --git a/source/blender/io/alembic/intern/abc_reader_archive.h b/source/blender/io/alembic/intern/abc_reader_archive.h
index 35273e10108..304c876adce 100644
--- a/source/blender/io/alembic/intern/abc_reader_archive.h
+++ b/source/blender/io/alembic/intern/abc_reader_archive.h
@@ -25,11 +25,6 @@
 #define __ABC_READER_ARCHIVE_H__
 
 #include <Alembic/Abc/All.h>
-
-#ifdef WITH_ALEMBIC_HDF5
-#  include <Alembic/AbcCoreHDF5/All.h>
-#endif
-
 #include <Alembic/AbcCoreOgawa/All.h>
 
 #include <fstream>
@@ -46,21 +41,12 @@ class ArchiveReader {
   Alembic::Abc::IArchive m_archive;
   std::ifstream m_infile;
   std::vector<std::istream *> m_streams;
-  bool m_is_hdf5;
 
  public:
   ArchiveReader(struct Main *bmain, const char *filename);
 
   bool valid() const;
 
-  /**
-   * Returns true when either Blender is compiled with HDF5 support and
-   * the archive was successfully opened (valid() will also return true),
-   * or when Blender was built without HDF5 support but a HDF5 file was
-   * detected (valid() will return false).
-   */
-  bool is_hdf5() const;
-
   Alembic::Abc::IObject getTop();
 };
 
diff --git a/source/blender/io/alembic/intern/abc_writer_archive.cc b/source/blender/io/alembic/intern/abc_writer_archive.cc
index e7dee536cb9..40926532f85 100644
--- a/source/blender/io/alembic/intern/abc_writer_archive.cc
+++ b/source/blender/io/alembic/intern/abc_writer_archive.cc
@@ -43,10 +43,8 @@ using Alembic::Abc::OArchive;
 /* This kinda duplicates CreateArchiveWithInfo, but Alembic does not seem to
  * have a version supporting streams. */
 static OArchive create_archive(std::ostream *ostream,
-                               const std::string &filename,
                                const std::string &scene_name,
-                               double scene_fps,
-                               bool ogawa)
+                               double scene_fps)
 {
   Alembic::Abc::MetaData abc_metadata;
 
@@ -73,38 +71,25 @@ static OArchive create_archive(std::ostream *ostream,
   abc_metadata.set(Alembic::Abc::kDateWrittenKey, buffer);
 
   ErrorHandler::Policy policy = ErrorHandler::kThrowPolicy;
-
-#ifdef WITH_ALEMBIC_HDF5
-  if (!ogawa) {
-    return OArchive(Alembic::AbcCoreHDF5::WriteArchive(), filename, abc_metadata, policy);
-  }
-#else
-  static_cast<void>(filename);
-  static_cast<void>(ogawa);
-#endif
-
   Alembic::AbcCoreOgawa::WriteArchive archive_writer;
   return OArchive(archive_writer(ostream, abc_metadata), kWrapExisting, policy);
 }
 
 ArchiveWriter::ArchiveWriter(const char *filename,
                              const std::string &abc_scene_name,
-                             const Scene *scene,
-                             bool do_ogawa)
+                             const Scene *scene)
 {
   /* Use stream to support unicode character paths on Windows. */
-  if (do_ogawa) {
 #ifdef WIN32
-    UTF16_ENCODE(filename);
-    std::wstring wstr(filename_16);
- 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list