Blender  V3.3
cryptomatte.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 
8 #include "BKE_cryptomatte.h"
9 #include "BKE_cryptomatte.hh"
10 #include "BKE_image.h"
11 #include "BKE_main.h"
12 
13 #include "DNA_layer_types.h"
14 #include "DNA_material_types.h"
15 #include "DNA_node_types.h"
16 #include "DNA_object_types.h"
17 #include "DNA_scene_types.h"
18 
19 #include "BLI_compiler_attrs.h"
20 #include "BLI_dynstr.h"
21 #include "BLI_hash_mm3.h"
22 #include "BLI_listbase.h"
23 #include "BLI_string.h"
24 
25 #include "RE_pipeline.h"
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include <cctype>
30 #include <cstring>
31 #include <iomanip>
32 #include <sstream>
33 #include <string>
34 #include <string_view>
35 
38  /* Layer names in order of creation. */
40 
41  CryptomatteSession() = default;
42  CryptomatteSession(const Main *bmain);
43  CryptomatteSession(StampData *stamp_data);
45 
47  std::optional<std::string> operator[](float encoded_hash) const;
48 
49 #ifdef WITH_CXX_GUARDEDALLOC
50  MEM_CXX_CLASS_ALLOC_FUNCS("cryptomatte:CryptomatteSession")
51 #endif
52 };
53 
55 {
56  if (!BLI_listbase_is_empty(&bmain->objects)) {
57  blender::bke::cryptomatte::CryptomatteLayer &objects = add_layer("CryptoObject");
58  LISTBASE_FOREACH (ID *, id, &bmain->objects) {
59  objects.add_ID(*id);
60  }
61  }
62  if (!BLI_listbase_is_empty(&bmain->materials)) {
64  LISTBASE_FOREACH (ID *, id, &bmain->materials) {
65  materials.add_ID(*id);
66  }
67  }
68 }
69 
71 {
73  callback_data.session = this;
75  &callback_data,
76  stamp_data,
78  false);
80  &callback_data,
81  stamp_data,
83  false);
84 }
85 
87 {
88  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
89  eViewLayerCryptomatteFlags cryptoflags = static_cast<eViewLayerCryptomatteFlags>(
90  view_layer->cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_ALL);
91  if (cryptoflags == 0) {
92  cryptoflags = static_cast<eViewLayerCryptomatteFlags>(VIEW_LAYER_CRYPTOMATTE_ALL);
93  }
94 
95  if (cryptoflags & VIEW_LAYER_CRYPTOMATTE_OBJECT) {
96  add_layer(blender::StringRefNull(view_layer->name) + ".CryptoObject");
97  }
98  if (cryptoflags & VIEW_LAYER_CRYPTOMATTE_ASSET) {
99  add_layer(blender::StringRefNull(view_layer->name) + ".CryptoAsset");
100  }
101  if (cryptoflags & VIEW_LAYER_CRYPTOMATTE_MATERIAL) {
102  add_layer(blender::StringRefNull(view_layer->name) + ".CryptoMaterial");
103  }
104  }
105 }
106 
108 {
109  if (!layer_names.contains(layer_name)) {
110  layer_names.append(layer_name);
111  }
112  return layers.lookup_or_add_default(layer_name);
113 }
114 
115 std::optional<std::string> CryptomatteSession::operator[](float encoded_hash) const
116 {
118  std::optional<std::string> result = layer[encoded_hash];
119  if (result) {
120  return result;
121  }
122  }
123  return std::nullopt;
124 }
125 
127 {
128  CryptomatteSession *session = new CryptomatteSession();
129  return session;
130 }
131 
133  const struct RenderResult *render_result)
134 {
135  CryptomatteSession *session = new CryptomatteSession(render_result->stamp_data);
136  return session;
137 }
138 
140 {
142  return session;
143 }
144 
145 void BKE_cryptomatte_add_layer(struct CryptomatteSession *session, const char *layer_name)
146 {
147  session->add_layer(layer_name);
148 }
149 
151 {
152  BLI_assert(session != nullptr);
153  delete session;
154 }
155 
156 uint32_t BKE_cryptomatte_hash(const char *name, const int name_len)
157 {
159  return hash.hash;
160 }
161 
163  const char *layer_name,
164  const Object *object)
165 {
166  blender::bke::cryptomatte::CryptomatteLayer *layer = session->layers.lookup_ptr(layer_name);
167  BLI_assert(layer);
168  return layer->add_ID(object->id);
169 }
170 
172  const char *layer_name,
173  const Material *material)
174 {
175  if (material == nullptr) {
176  return 0.0f;
177  }
178  blender::bke::cryptomatte::CryptomatteLayer *layer = session->layers.lookup_ptr(layer_name);
179  BLI_assert(layer);
180  return layer->add_ID(material->id);
181 }
182 
184  const char *layer_name,
185  const Object *object)
186 {
187  const Object *asset_object = object;
188  while (asset_object->parent != nullptr) {
189  asset_object = asset_object->parent;
190  }
191  return BKE_cryptomatte_object_hash(session, layer_name, asset_object);
192 }
193 
195 {
197 }
198 
200  const float encoded_hash,
201  char *r_name,
202  int name_len)
203 {
204  std::optional<std::string> name = (*session)[encoded_hash];
205  if (!name) {
206  return false;
207  }
208 
209  BLI_strncpy(r_name, name->c_str(), name_len);
210  return true;
211 }
212 
214 {
215  DynStr *matte_id = BLI_dynstr_new();
216  bool first = true;
217  LISTBASE_FOREACH (CryptomatteEntry *, entry, &node_storage->entries) {
218  if (!first) {
219  BLI_dynstr_append(matte_id, ",");
220  }
221  if (BLI_strnlen(entry->name, sizeof(entry->name)) != 0) {
222  BLI_dynstr_nappend(matte_id, entry->name, sizeof(entry->name));
223  }
224  else {
225  BLI_dynstr_appendf(matte_id, "<%.9g>", entry->encoded_hash);
226  }
227  first = false;
228  }
229  char *result = BLI_dynstr_get_cstring(matte_id);
230  BLI_dynstr_free(matte_id);
231  return result;
232 }
233 
234 void BKE_cryptomatte_matte_id_to_entries(NodeCryptomatte *node_storage, const char *matte_id)
235 {
236  BLI_freelistN(&node_storage->entries);
237 
238  if (matte_id == nullptr) {
239  MEM_SAFE_FREE(node_storage->matte_id);
240  return;
241  }
242  /* Update the matte_id so the files can be opened in versions that don't
243  * use `CryptomatteEntry`. */
244  if (matte_id != node_storage->matte_id && node_storage->matte_id &&
245  STREQ(node_storage->matte_id, matte_id)) {
246  MEM_SAFE_FREE(node_storage->matte_id);
247  node_storage->matte_id = static_cast<char *>(MEM_dupallocN(matte_id));
248  }
249 
250  std::istringstream ss(matte_id);
251  while (ss.good()) {
252  CryptomatteEntry *entry = nullptr;
253  std::string token;
254  getline(ss, token, ',');
255  /* Ignore empty tokens. */
256  if (token.length() > 0) {
257  size_t first = token.find_first_not_of(' ');
258  size_t last = token.find_last_not_of(' ');
259  if (first == std::string::npos || last == std::string::npos) {
260  break;
261  }
262  token = token.substr(first, (last - first + 1));
263  if (*token.begin() == '<' && *(--token.end()) == '>') {
264  float encoded_hash = atof(token.substr(1, token.length() - 2).c_str());
265  entry = MEM_cnew<CryptomatteEntry>(__func__);
266  entry->encoded_hash = encoded_hash;
267  }
268  else {
269  const char *name = token.c_str();
270  int name_len = token.length();
271  entry = MEM_cnew<CryptomatteEntry>(__func__);
272  STRNCPY(entry->name, name);
273  uint32_t hash = BKE_cryptomatte_hash(name, name_len);
275  }
276  }
277  if (entry != nullptr) {
278  BLI_addtail(&node_storage->entries, entry);
279  }
280  }
281 }
282 
283 static std::string cryptomatte_determine_name(const ViewLayer *view_layer,
284  const blender::StringRefNull cryptomatte_layer_name)
285 {
286  std::stringstream stream;
287  const size_t view_layer_name_len = BLI_strnlen(view_layer->name, sizeof(view_layer->name));
288  stream << std::string(view_layer->name, view_layer_name_len) << "." << cryptomatte_layer_name;
289  return stream.str();
290 }
291 
293 {
294  return BLI_hash_mm3(reinterpret_cast<const unsigned char *>(name.data()), name.size(), 0);
295 }
296 
297 static void add_render_result_meta_data(RenderResult *render_result,
298  const blender::StringRef layer_name,
299  const blender::StringRefNull key_name,
300  const blender::StringRefNull value)
301 {
303  render_result,
304  blender::bke::cryptomatte::BKE_cryptomatte_meta_data_key(layer_name, key_name).c_str(),
305  value.data());
306 }
307 
309  RenderResult *render_result,
310  const ViewLayer *view_layer)
311 {
313  session->layers.items()) {
314  const blender::StringRefNull layer_name(item.key);
315  const blender::bke::cryptomatte::CryptomatteLayer &layer = item.value;
316 
317  const std::string manifest = layer.manifest();
318  const std::string name = cryptomatte_determine_name(view_layer, layer_name);
319 
320  add_render_result_meta_data(render_result, name, "name", name);
321  add_render_result_meta_data(render_result, name, "hash", "MurmurHash3_32");
322  add_render_result_meta_data(render_result, name, "conversion", "uint32_to_float32");
323  add_render_result_meta_data(render_result, name, "manifest", manifest);
324  }
325 }
326 
327 namespace blender::bke::cryptomatte {
328 namespace manifest {
329 constexpr StringRef WHITESPACES = " \t\n\v\f\r";
330 
332 {
333  size_t skip = ref.find_first_not_of(WHITESPACES);
334  if (skip == blender::StringRef::not_found) {
335  return ref;
336  }
337  return ref.drop_prefix(skip);
338 }
339 
340 static constexpr int quoted_string_len_(blender::StringRef ref)
341 {
342  int len = 1;
343  bool skip_next = false;
344  while (len < ref.size()) {
345  char current_char = ref[len];
346  if (skip_next) {
347  skip_next = false;
348  }
349  else {
350  if (current_char == '\\') {
351  skip_next = true;
352  }
353  if (current_char == '\"') {
354  len += 1;
355  break;
356  }
357  }
358  len += 1;
359  }
360  return len;
361 }
362 
363 static std::string unquote_(const blender::StringRef ref)
364 {
365  std::ostringstream stream;
366  for (char c : ref) {
367  if (c != '\\') {
368  stream << c;
369  }
370  }
371  return stream.str();
372 }
373 
375 {
376  StringRef ref = manifest;
377  ref = skip_whitespaces_(ref);
378  if (ref.is_empty() || ref.front() != '{') {
379  return false;
380  }
381  ref = ref.drop_prefix(1);
382  while (!ref.is_empty()) {
383  char front = ref.front();
384 
385  if (front == '\"') {
386  const int quoted_name_len = quoted_string_len_(ref);
387  const int name_len = quoted_name_len - 2;
388  std::string name = unquote_(ref.substr(1, name_len));
389  ref = ref.drop_prefix(quoted_name_len);
390  ref = skip_whitespaces_(ref);
391 
392  if (ref.is_empty()) {
393  return false;
394  }
395  char colon = ref.front();
396  if (colon != ':') {
397  return false;
398  }
399  ref = ref.drop_prefix(1);
400  ref = skip_whitespaces_(ref);
401 
402  if (ref.is_empty() || ref.front() != '\"') {
403  return false;
404  }
405 
406  const int quoted_hash_len = quoted_string_len_(ref);
407  if (quoted_hash_len < 2) {
408  return false;
409  }
410  const int hash_len = quoted_hash_len - 2;
412  ref = ref.drop_prefix(quoted_hash_len);
413  layer.add_hash(name, hash);
414  }
415  else if (front == ',') {
416  ref = ref.drop_prefix(1);
417  }
418  else if (front == '}') {
419  ref = ref.drop_prefix(1);
420  ref = skip_whitespaces_(ref);
421  break;
422  }
423  ref = skip_whitespaces_(ref);
424  }
425 
426  if (!ref.is_empty()) {
427  return false;
428  }
429 
430  return true;
431 }
432 
433 static std::string to_manifest(const CryptomatteLayer *layer)
434 {
435  std::stringstream manifest;
436 
437  bool is_first = true;
438  const blender::Map<std::string, CryptomatteHash> &const_map = layer->hashes;
439  manifest << "{";
441  if (is_first) {
442  is_first = false;
443  }
444  else {
445  manifest << ",";
446  }
447  manifest << quoted(item.key) << ":\"" << (item.value.hex_encoded()) << "\"";
448  }
449  manifest << "}";
450  return manifest.str();
451 }
452 
453 } // namespace manifest
454 
455 /* Return the hash of the given cryptomatte layer name.
456  *
457  * The cryptomatte specification limits the hash to 7 characters.
458  * The 7 position limitation solves issues when using cryptomatte together with OpenEXR.
459  * The specification suggests to use the first 7 chars of the hashed layer_name.
460  */
461 static std::string cryptomatte_layer_name_hash(const StringRef layer_name)
462 {
463  std::stringstream stream;
464  const uint32_t render_pass_identifier = cryptomatte_determine_identifier(layer_name);
465  stream << std::setfill('0') << std::setw(sizeof(uint32_t) * 2) << std::hex
466  << render_pass_identifier;
467  return stream.str().substr(0, 7);
468 }
469 
470 std::string BKE_cryptomatte_meta_data_key(const StringRef layer_name, const StringRefNull key_name)
471 {
472  return "cryptomatte/" + cryptomatte_layer_name_hash(layer_name) + "/" + key_name;
473 }
474 
476 {
477  int64_t last_token = render_pass_name.size();
478  while (last_token > 0 && std::isdigit(render_pass_name[last_token - 1])) {
479  last_token -= 1;
480  }
481  return render_pass_name.substr(0, last_token);
482 }
483 
485 {
486 }
487 
488 CryptomatteHash::CryptomatteHash(const char *name, const int name_len)
489 {
490  hash = BLI_hash_mm3((const unsigned char *)name, name_len, 0);
491 }
492 
494 {
496  std::istringstream(hex_encoded) >> std::hex >> result.hash;
497  return result;
498 }
499 
500 std::string CryptomatteHash::hex_encoded() const
501 {
502  std::stringstream encoded;
503  encoded << std::setfill('0') << std::setw(sizeof(uint32_t) * 2) << std::hex << hash;
504  return encoded.str();
505 }
506 
508 {
509  uint32_t mantissa = hash & ((1 << 23) - 1);
510  uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
511  exponent = MAX2(exponent, (uint32_t)1);
512  exponent = MIN2(exponent, (uint32_t)254);
513  exponent = exponent << 23;
514  uint32_t sign = (hash >> 31);
515  sign = sign << 31;
516  uint32_t float_bits = sign | exponent | mantissa;
517  float f;
518  memcpy(&f, &float_bits, sizeof(uint32_t));
519  return f;
520 }
521 
522 std::unique_ptr<CryptomatteLayer> CryptomatteLayer::read_from_manifest(
523  blender::StringRefNull manifest)
524 {
525  std::unique_ptr<CryptomatteLayer> layer = std::make_unique<CryptomatteLayer>();
527  return layer;
528 }
529 
531 {
532  const char *name = &id.name[2];
533  const int name_len = BLI_strnlen(name, MAX_NAME - 2);
534  uint32_t cryptohash_int = BKE_cryptomatte_hash(name, name_len);
535 
536  add_hash(blender::StringRef(name, name_len), cryptohash_int);
537 
538  return cryptohash_int;
539 }
540 
542 {
543  hashes.add_overwrite(name, cryptomatte_hash);
544 }
545 
546 std::optional<std::string> CryptomatteLayer::operator[](float encoded_hash) const
547 {
550  if (BKE_cryptomatte_hash_to_float(item.value.hash) == encoded_hash) {
551  return std::make_optional(item.key);
552  }
553  }
554  return std::nullopt;
555 }
556 
557 std::string CryptomatteLayer::manifest() const
558 {
560 }
561 
563 {
564  BLI_assert(key.startswith("cryptomatte/"));
565 
566  size_t start_index = key.find_first_of('/');
567  size_t end_index = key.find_last_of('/');
568  if (start_index == blender::StringRef::not_found) {
569  return "";
570  }
571  if (end_index == blender::StringRef::not_found) {
572  return "";
573  }
574  if (end_index <= start_index) {
575  return "";
576  }
577  return key.substr(start_index + 1, end_index - start_index - 1);
578 }
579 
581  const char *propname,
582  char *propvalue,
583  int UNUSED(len))
584 {
586 
587  blender::StringRefNull key(propname);
588  if (!key.startswith("cryptomatte/")) {
589  return;
590  }
591  if (!key.endswith("/name")) {
592  return;
593  }
594  blender::StringRef layer_hash = extract_layer_hash(key);
595  data->hash_to_layer_name.add(layer_hash, propvalue);
596 }
597 
599  const char *propname,
600  char *propvalue,
601  int UNUSED(len))
602 {
604 
605  blender::StringRefNull key(propname);
606  if (!key.startswith("cryptomatte/")) {
607  return;
608  }
609  if (!key.endswith("/manifest")) {
610  return;
611  }
612  blender::StringRef layer_hash = extract_layer_hash(key);
613  if (!data->hash_to_layer_name.contains(layer_hash)) {
614  return;
615  }
616 
617  blender::StringRef layer_name = data->hash_to_layer_name.lookup(layer_hash);
618  blender::bke::cryptomatte::CryptomatteLayer &layer = data->session->add_layer(layer_name);
620 }
621 
623  const CryptomatteSession &session)
624 {
625  return session.layer_names;
626 }
627 
628 } // namespace blender::bke::cryptomatte
void BKE_render_result_stamp_data(struct RenderResult *rr, const char *key, const char *value)
void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip)
#define BLI_assert(a)
Definition: BLI_assert.h:46
A dynamically sized string ADT.
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: BLI_dynstr.c:50
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
Definition: BLI_dynstr.c:94
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_dynstr.c:256
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
Definition: BLI_dynstr.c:281
void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format,...) ATTR_PRINTF_FORMAT(2
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
Definition: BLI_dynstr.c:75
uint32_t BLI_hash_mm3(const unsigned char *data, size_t len, uint32_t seed)
Definition: hash_mm3.c:72
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
#define STRNCPY(dst, src)
Definition: BLI_string.h:483
size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:899
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
#define UNUSED(x)
#define MAX2(a, b)
#define MIN2(a, b)
#define STREQ(a, b)
#define MAX_NAME
Definition: DNA_defs.h:48
eViewLayerCryptomatteFlags
@ VIEW_LAYER_CRYPTOMATTE_MATERIAL
@ VIEW_LAYER_CRYPTOMATTE_ASSET
@ VIEW_LAYER_CRYPTOMATTE_OBJECT
#define VIEW_LAYER_CRYPTOMATTE_ALL
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
ValueIterator values() const
Definition: BLI_map.hh:840
Value & lookup_or_add_default(const Key &key)
Definition: BLI_map.hh:580
ItemIterator items() const
Definition: BLI_map.hh:859
const Value * lookup_ptr(const Key &key) const
Definition: BLI_map.hh:463
constexpr const char & front() const
static constexpr int64_t not_found
constexpr int64_t find_last_of(StringRef chars, int64_t pos=INT64_MAX) const
constexpr int64_t find_first_not_of(StringRef chars, int64_t pos=0) const
constexpr bool is_empty() const
constexpr StringRef substr(int64_t start, int64_t size) const
constexpr bool startswith(StringRef prefix) const
constexpr bool endswith(StringRef suffix) const
constexpr int64_t find_first_of(StringRef chars, int64_t pos=0) const
constexpr int64_t size() const
constexpr const char * data() const
constexpr StringRef drop_prefix(int64_t n) const
bool contains(const T &value) const
Definition: BLI_vector.hh:837
void append(const T &value)
Definition: BLI_vector.hh:433
void BKE_cryptomatte_add_layer(struct CryptomatteSession *session, const char *layer_name)
Definition: cryptomatte.cc:145
CryptomatteSession * BKE_cryptomatte_init()
Definition: cryptomatte.cc:126
uint32_t BKE_cryptomatte_hash(const char *name, const int name_len)
Definition: cryptomatte.cc:156
static void add_render_result_meta_data(RenderResult *render_result, const blender::StringRef layer_name, const blender::StringRefNull key_name, const blender::StringRefNull value)
Definition: cryptomatte.cc:297
struct CryptomatteSession * BKE_cryptomatte_init_from_render_result(const struct RenderResult *render_result)
Definition: cryptomatte.cc:132
void BKE_cryptomatte_free(CryptomatteSession *session)
Definition: cryptomatte.cc:150
float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash)
Definition: cryptomatte.cc:194
char * BKE_cryptomatte_entries_to_matte_id(NodeCryptomatte *node_storage)
Definition: cryptomatte.cc:213
void BKE_cryptomatte_store_metadata(const struct CryptomatteSession *session, RenderResult *render_result, const ViewLayer *view_layer)
Definition: cryptomatte.cc:308
struct CryptomatteSession * BKE_cryptomatte_init_from_scene(const struct Scene *scene)
Definition: cryptomatte.cc:139
uint32_t BKE_cryptomatte_asset_hash(CryptomatteSession *session, const char *layer_name, const Object *object)
Definition: cryptomatte.cc:183
static uint32_t cryptomatte_determine_identifier(const blender::StringRef name)
Definition: cryptomatte.cc:292
bool BKE_cryptomatte_find_name(const CryptomatteSession *session, const float encoded_hash, char *r_name, int name_len)
Definition: cryptomatte.cc:199
void BKE_cryptomatte_matte_id_to_entries(NodeCryptomatte *node_storage, const char *matte_id)
Definition: cryptomatte.cc:234
uint32_t BKE_cryptomatte_object_hash(CryptomatteSession *session, const char *layer_name, const Object *object)
Definition: cryptomatte.cc:162
static std::string cryptomatte_determine_name(const ViewLayer *view_layer, const blender::StringRefNull cryptomatte_layer_name)
Definition: cryptomatte.cc:283
uint32_t BKE_cryptomatte_material_hash(CryptomatteSession *session, const char *layer_name, const Material *material)
Definition: cryptomatte.cc:171
Scene scene
Material material
int len
Definition: draw_manager.c:108
smooth(Type::VEC4, "color_mul") .smooth(Type gpFillTexture gpSceneDepthTexture materials[GPENCIL_MATERIAL_BUFFER_LEN]
Definition: gpencil_info.hh:29
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
static unsigned c
Definition: RandGen.cpp:83
double sign(double arg)
Definition: utility.h:250
static bool from_manifest(CryptomatteLayer &layer, blender::StringRefNull manifest)
Definition: cryptomatte.cc:374
static constexpr int quoted_string_len_(blender::StringRef ref)
Definition: cryptomatte.cc:340
static std::string unquote_(const blender::StringRef ref)
Definition: cryptomatte.cc:363
static constexpr blender::StringRef skip_whitespaces_(blender::StringRef ref)
Definition: cryptomatte.cc:331
static std::string to_manifest(const CryptomatteLayer *layer)
Definition: cryptomatte.cc:433
StringRef BKE_cryptomatte_extract_layer_name(const StringRef render_pass_name)
Definition: cryptomatte.cc:475
std::string BKE_cryptomatte_meta_data_key(const StringRef layer_name, const StringRefNull key_name)
Definition: cryptomatte.cc:470
static std::string cryptomatte_layer_name_hash(const StringRef layer_name)
Definition: cryptomatte.cc:461
const blender::Vector< std::string > & BKE_cryptomatte_layer_names_get(const CryptomatteSession &session)
Definition: cryptomatte.cc:622
#define hash
Definition: noise.c:153
unsigned int uint32_t
Definition: stdint.h:80
__int64 int64_t
Definition: stdint.h:89
CryptomatteSession()=default
blender::Map< std::string, blender::bke::cryptomatte::CryptomatteLayer > layers
Definition: cryptomatte.cc:37
std::optional< std::string > operator[](float encoded_hash) const
Definition: cryptomatte.cc:115
blender::bke::cryptomatte::CryptomatteLayer & add_layer(std::string layer_name)
Definition: cryptomatte.cc:107
blender::Vector< std::string > layer_names
Definition: cryptomatte.cc:39
Definition: DNA_ID.h:368
Definition: BKE_main.h:121
ListBase materials
Definition: BKE_main.h:174
ListBase objects
Definition: BKE_main.h:170
struct Object * parent
struct StampData * stamp_data
Definition: RE_pipeline.h:141
ListBase view_layers
char name[64]
static CryptomatteHash from_hex_encoded(blender::StringRef hex_encoded)
Definition: cryptomatte.cc:493
void add_hash(blender::StringRef name, CryptomatteHash cryptomatte_hash)
Definition: cryptomatte.cc:541
blender::Map< std::string, CryptomatteHash > hashes
static std::unique_ptr< CryptomatteLayer > read_from_manifest(blender::StringRefNull manifest)
Definition: cryptomatte.cc:522
std::optional< std::string > operator[](float encoded_hash) const
Definition: cryptomatte.cc:546
uint32_t add_ID(const struct ID &id)
Definition: cryptomatte.cc:530
static void extract_layer_names(void *_data, const char *propname, char *propvalue, int len)
Definition: cryptomatte.cc:580
static blender::StringRef extract_layer_hash(blender::StringRefNull key)
Definition: cryptomatte.cc:562
static void extract_layer_manifest(void *_data, const char *propname, char *propvalue, int len)
Definition: cryptomatte.cc:598
static const char hex[17]
Definition: thumbs.c:156