stb_rect_pack.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. // stb_rect_pack.h - v1.01 - public domain - rectangle packing
  2. // Sean Barrett 2014
  3. //
  4. // Useful for e.g. packing rectangular textures into an atlas.
  5. // Does not do rotation.
  6. //
  7. // Before #including,
  8. //
  9. // #define STB_RECT_PACK_IMPLEMENTATION
  10. //
  11. // in the file that you want to have the implementation.
  12. //
  13. // Not necessarily the awesomest packing method, but better than
  14. // the totally naive one in stb_truetype (which is primarily what
  15. // this is meant to replace).
  16. //
  17. // Has only had a few tests run, may have issues.
  18. //
  19. // More docs to come.
  20. //
  21. // No memory allocations; uses qsort() and assert() from stdlib.
  22. // Can override those by defining STBRP_SORT and STBRP_ASSERT.
  23. //
  24. // This library currently uses the Skyline Bottom-Left algorithm.
  25. //
  26. // Please note: better rectangle packers are welcome! Please
  27. // implement them to the same API, but with a different init
  28. // function.
  29. //
  30. // Credits
  31. //
  32. // Library
  33. // Sean Barrett
  34. // Minor features
  35. // Martins Mozeiko
  36. // github:IntellectualKitty
  37. //
  38. // Bugfixes / warning fixes
  39. // Jeremy Jaussaud
  40. // Fabian Giesen
  41. //
  42. // Version history:
  43. //
  44. // 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section
  45. // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
  46. // 0.99 (2019-02-07) warning fixes
  47. // 0.11 (2017-03-03) return packing success/fail result
  48. // 0.10 (2016-10-25) remove cast-away-const to avoid warnings
  49. // 0.09 (2016-08-27) fix compiler warnings
  50. // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
  51. // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
  52. // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
  53. // 0.05: added STBRP_ASSERT to allow replacing assert
  54. // 0.04: fixed minor bug in STBRP_LARGE_RECTS support
  55. // 0.01: initial release
  56. //
  57. // LICENSE
  58. //
  59. // See end of file for license information.
  60. //////////////////////////////////////////////////////////////////////////////
  61. //
  62. // INCLUDE SECTION
  63. //
  64. #ifndef STB_INCLUDE_STB_RECT_PACK_H
  65. #define STB_INCLUDE_STB_RECT_PACK_H
  66. #define STB_RECT_PACK_VERSION 1
  67. #ifdef STBRP_STATIC
  68. #define STBRP_DEF static
  69. #else
  70. #define STBRP_DEF extern
  71. #endif
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif
  75. typedef struct stbrp_context stbrp_context;
  76. typedef struct stbrp_node stbrp_node;
  77. typedef struct stbrp_rect stbrp_rect;
  78. typedef int stbrp_coord;
  79. #define STBRP__MAXVAL 0x7fffffff
  80. // Mostly for internal use, but this is the maximum supported coordinate value.
  81. STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
  82. // Assign packed locations to rectangles. The rectangles are of type
  83. // 'stbrp_rect' defined below, stored in the array 'rects', and there
  84. // are 'num_rects' many of them.
  85. //
  86. // Rectangles which are successfully packed have the 'was_packed' flag
  87. // set to a non-zero value and 'x' and 'y' store the minimum location
  88. // on each axis (i.e. bottom-left in cartesian coordinates, top-left
  89. // if you imagine y increasing downwards). Rectangles which do not fit
  90. // have the 'was_packed' flag set to 0.
  91. //
  92. // You should not try to access the 'rects' array from another thread
  93. // while this function is running, as the function temporarily reorders
  94. // the array while it executes.
  95. //
  96. // To pack into another rectangle, you need to call stbrp_init_target
  97. // again. To continue packing into the same rectangle, you can call
  98. // this function again. Calling this multiple times with multiple rect
  99. // arrays will probably produce worse packing results than calling it
  100. // a single time with the full rectangle array, but the option is
  101. // available.
  102. //
  103. // The function returns 1 if all of the rectangles were successfully
  104. // packed and 0 otherwise.
  105. struct stbrp_rect
  106. {
  107. // reserved for your use:
  108. int id;
  109. // input:
  110. stbrp_coord w, h;
  111. // output:
  112. stbrp_coord x, y;
  113. int was_packed; // non-zero if valid packing
  114. }; // 16 bytes, nominally
  115. STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
  116. // Initialize a rectangle packer to:
  117. // pack a rectangle that is 'width' by 'height' in dimensions
  118. // using temporary storage provided by the array 'nodes', which is 'num_nodes' long
  119. //
  120. // You must call this function every time you start packing into a new target.
  121. //
  122. // There is no "shutdown" function. The 'nodes' memory must stay valid for
  123. // the following stbrp_pack_rects() call (or calls), but can be freed after
  124. // the call (or calls) finish.
  125. //
  126. // Note: to guarantee best results, either:
  127. // 1. make sure 'num_nodes' >= 'width'
  128. // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
  129. //
  130. // If you don't do either of the above things, widths will be quantized to multiples
  131. // of small integers to guarantee the algorithm doesn't run out of temporary storage.
  132. //
  133. // If you do #2, then the non-quantized algorithm will be used, but the algorithm
  134. // may run out of temporary storage and be unable to pack some rectangles.
  135. STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
  136. // Optionally call this function after init but before doing any packing to
  137. // change the handling of the out-of-temp-memory scenario, described above.
  138. // If you call init again, this will be reset to the default (false).
  139. STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
  140. // Optionally select which packing heuristic the library should use. Different
  141. // heuristics will produce better/worse results for different data sets.
  142. // If you call init again, this will be reset to the default.
  143. enum
  144. {
  145. STBRP_HEURISTIC_Skyline_default=0,
  146. STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
  147. STBRP_HEURISTIC_Skyline_BF_sortHeight
  148. };
  149. //////////////////////////////////////////////////////////////////////////////
  150. //
  151. // the details of the following structures don't matter to you, but they must
  152. // be visible so you can handle the memory allocations for them
  153. struct stbrp_node
  154. {
  155. stbrp_coord x,y;
  156. stbrp_node *next;
  157. };
  158. struct stbrp_context
  159. {
  160. int width;
  161. int height;
  162. int align;
  163. int init_mode;
  164. int heuristic;
  165. int num_nodes;
  166. stbrp_node *active_head;
  167. stbrp_node *free_head;
  168. stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
  169. };
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif
  174. //////////////////////////////////////////////////////////////////////////////
  175. //
  176. // IMPLEMENTATION SECTION
  177. //
  178. #ifdef STB_RECT_PACK_IMPLEMENTATION
  179. #ifndef STBRP_SORT
  180. #include <stdlib.h>
  181. #define STBRP_SORT qsort
  182. #endif
  183. #ifndef STBRP_ASSERT
  184. #include <assert.h>
  185. #define STBRP_ASSERT assert
  186. #endif
  187. #ifdef _MSC_VER
  188. #define STBRP__NOTUSED(v) (void)(v)
  189. #define STBRP__CDECL __cdecl
  190. #else
  191. #define STBRP__NOTUSED(v) (void)sizeof(v)
  192. #define STBRP__CDECL
  193. #endif
  194. enum
  195. {
  196. STBRP__INIT_skyline = 1
  197. };
  198. STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
  199. {
  200. switch (context->init_mode) {
  201. case STBRP__INIT_skyline:
  202. STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
  203. context->heuristic = heuristic;
  204. break;
  205. default:
  206. STBRP_ASSERT(0);
  207. }
  208. }
  209. STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
  210. {
  211. if (allow_out_of_mem)
  212. // if it's ok to run out of memory, then don't bother aligning them;
  213. // this gives better packing, but may fail due to OOM (even though
  214. // the rectangles easily fit). @TODO a smarter approach would be to only
  215. // quantize once we've hit OOM, then we could get rid of this parameter.
  216. context->align = 1;
  217. else {
  218. // if it's not ok to run out of memory, then quantize the widths
  219. // so that num_nodes is always enough nodes.
  220. //
  221. // I.e. num_nodes * align >= width
  222. // align >= width / num_nodes
  223. // align = ceil(width/num_nodes)
  224. context->align = (context->width + context->num_nodes-1) / context->num_nodes;
  225. }
  226. }
  227. STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
  228. {
  229. int i;
  230. for (i=0; i < num_nodes-1; ++i)
  231. nodes[i].next = &nodes[i+1];
  232. nodes[i].next = NULL;
  233. context->init_mode = STBRP__INIT_skyline;
  234. context->heuristic = STBRP_HEURISTIC_Skyline_default;
  235. context->free_head = &nodes[0];
  236. context->active_head = &context->extra[0];
  237. context->width = width;
  238. context->height = height;
  239. context->num_nodes = num_nodes;
  240. stbrp_setup_allow_out_of_mem(context, 0);
  241. // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
  242. context->extra[0].x = 0;
  243. context->extra[0].y = 0;
  244. context->extra[0].next = &context->extra[1];
  245. context->extra[1].x = (stbrp_coord) width;
  246. context->extra[1].y = (1<<30);
  247. context->extra[1].next = NULL;
  248. }
  249. // find minimum y position if it starts at x1
  250. static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
  251. {
  252. stbrp_node *node = first;
  253. int x1 = x0 + width;
  254. int min_y, visited_width, waste_area;
  255. STBRP__NOTUSED(c);
  256. STBRP_ASSERT(first->x <= x0);
  257. #if 0
  258. // skip in case we're past the node
  259. while (node->next->x <= x0)
  260. ++node;
  261. #else
  262. STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
  263. #endif
  264. STBRP_ASSERT(node->x <= x0);
  265. min_y = 0;
  266. waste_area = 0;
  267. visited_width = 0;
  268. while (node->x < x1) {
  269. if (node->y > min_y) {
  270. // raise min_y higher.
  271. // we've accounted for all waste up to min_y,
  272. // but we'll now add more waste for everything we've visted
  273. waste_area += visited_width * (node->y - min_y);
  274. min_y = node->y;
  275. // the first time through, visited_width might be reduced
  276. if (node->x < x0)
  277. visited_width += node->next->x - x0;
  278. else
  279. visited_width += node->next->x - node->x;
  280. } else {
  281. // add waste area
  282. int under_width = node->next->x - node->x;
  283. if (under_width + visited_width > width)
  284. under_width = width - visited_width;
  285. waste_area += under_width * (min_y - node->y);
  286. visited_width += under_width;
  287. }
  288. node = node->next;
  289. }
  290. *pwaste = waste_area;
  291. return min_y;
  292. }
  293. typedef struct
  294. {
  295. int x,y;
  296. stbrp_node **prev_link;
  297. } stbrp__findresult;
  298. static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
  299. {
  300. int best_waste = (1<<30), best_x, best_y = (1 << 30);
  301. stbrp__findresult fr;
  302. stbrp_node **prev, *node, *tail, **best = NULL;
  303. // align to multiple of c->align
  304. width = (width + c->align - 1);
  305. width -= width % c->align;
  306. STBRP_ASSERT(width % c->align == 0);
  307. // if it can't possibly fit, bail immediately
  308. if (width > c->width || height > c->height) {
  309. fr.prev_link = NULL;
  310. fr.x = fr.y = 0;
  311. return fr;
  312. }
  313. node = c->active_head;
  314. prev = &c->active_head;
  315. while (node->x + width <= c->width) {
  316. int y,waste;
  317. y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
  318. if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
  319. // bottom left
  320. if (y < best_y) {
  321. best_y = y;
  322. best = prev;
  323. }
  324. } else {
  325. // best-fit
  326. if (y + height <= c->height) {
  327. // can only use it if it first vertically
  328. if (y < best_y || (y == best_y && waste < best_waste)) {
  329. best_y = y;
  330. best_waste = waste;
  331. best = prev;
  332. }
  333. }
  334. }
  335. prev = &node->next;
  336. node = node->next;
  337. }
  338. best_x = (best == NULL) ? 0 : (*best)->x;
  339. // if doing best-fit (BF), we also have to try aligning right edge to each node position
  340. //
  341. // e.g, if fitting
  342. //
  343. // ____________________
  344. // |____________________|
  345. //
  346. // into
  347. //
  348. // | |
  349. // | ____________|
  350. // |____________|
  351. //
  352. // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
  353. //
  354. // This makes BF take about 2x the time
  355. if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
  356. tail = c->active_head;
  357. node = c->active_head;
  358. prev = &c->active_head;
  359. // find first node that's admissible
  360. while (tail->x < width)
  361. tail = tail->next;
  362. while (tail) {
  363. int xpos = tail->x - width;
  364. int y,waste;
  365. STBRP_ASSERT(xpos >= 0);
  366. // find the left position that matches this
  367. while (node->next->x <= xpos) {
  368. prev = &node->next;
  369. node = node->next;
  370. }
  371. STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
  372. y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
  373. if (y + height <= c->height) {
  374. if (y <= best_y) {
  375. if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
  376. best_x = xpos;
  377. STBRP_ASSERT(y <= best_y);
  378. best_y = y;
  379. best_waste = waste;
  380. best = prev;
  381. }
  382. }
  383. }
  384. tail = tail->next;
  385. }
  386. }
  387. fr.prev_link = best;
  388. fr.x = best_x;
  389. fr.y = best_y;
  390. return fr;
  391. }
  392. static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
  393. {
  394. // find best position according to heuristic
  395. stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
  396. stbrp_node *node, *cur;
  397. // bail if:
  398. // 1. it failed
  399. // 2. the best node doesn't fit (we don't always check this)
  400. // 3. we're out of memory
  401. if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
  402. res.prev_link = NULL;
  403. return res;
  404. }
  405. // on success, create new node
  406. node = context->free_head;
  407. node->x = (stbrp_coord) res.x;
  408. node->y = (stbrp_coord) (res.y + height);
  409. context->free_head = node->next;
  410. // insert the new node into the right starting point, and
  411. // let 'cur' point to the remaining nodes needing to be
  412. // stiched back in
  413. cur = *res.prev_link;
  414. if (cur->x < res.x) {
  415. // preserve the existing one, so start testing with the next one
  416. stbrp_node *next = cur->next;
  417. cur->next = node;
  418. cur = next;
  419. } else {
  420. *res.prev_link = node;
  421. }
  422. // from here, traverse cur and free the nodes, until we get to one
  423. // that shouldn't be freed
  424. while (cur->next && cur->next->x <= res.x + width) {
  425. stbrp_node *next = cur->next;
  426. // move the current node to the free list
  427. cur->next = context->free_head;
  428. context->free_head = cur;
  429. cur = next;
  430. }
  431. // stitch the list back in
  432. node->next = cur;
  433. if (cur->x < res.x + width)
  434. cur->x = (stbrp_coord) (res.x + width);
  435. #ifdef _DEBUG
  436. cur = context->active_head;
  437. while (cur->x < context->width) {
  438. STBRP_ASSERT(cur->x < cur->next->x);
  439. cur = cur->next;
  440. }
  441. STBRP_ASSERT(cur->next == NULL);
  442. {
  443. int count=0;
  444. cur = context->active_head;
  445. while (cur) {
  446. cur = cur->next;
  447. ++count;
  448. }
  449. cur = context->free_head;
  450. while (cur) {
  451. cur = cur->next;
  452. ++count;
  453. }
  454. STBRP_ASSERT(count == context->num_nodes+2);
  455. }
  456. #endif
  457. return res;
  458. }
  459. static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
  460. {
  461. const stbrp_rect *p = (const stbrp_rect *) a;
  462. const stbrp_rect *q = (const stbrp_rect *) b;
  463. if (p->h > q->h)
  464. return -1;
  465. if (p->h < q->h)
  466. return 1;
  467. return (p->w > q->w) ? -1 : (p->w < q->w);
  468. }
  469. static int STBRP__CDECL rect_original_order(const void *a, const void *b)
  470. {
  471. const stbrp_rect *p = (const stbrp_rect *) a;
  472. const stbrp_rect *q = (const stbrp_rect *) b;
  473. return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
  474. }
  475. STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
  476. {
  477. int i, all_rects_packed = 1;
  478. // we use the 'was_packed' field internally to allow sorting/unsorting
  479. for (i=0; i < num_rects; ++i) {
  480. rects[i].was_packed = i;
  481. }
  482. // sort according to heuristic
  483. STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
  484. for (i=0; i < num_rects; ++i) {
  485. if (rects[i].w == 0 || rects[i].h == 0) {
  486. rects[i].x = rects[i].y = 0; // empty rect needs no space
  487. } else {
  488. stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
  489. if (fr.prev_link) {
  490. rects[i].x = (stbrp_coord) fr.x;
  491. rects[i].y = (stbrp_coord) fr.y;
  492. } else {
  493. rects[i].x = rects[i].y = STBRP__MAXVAL;
  494. }
  495. }
  496. }
  497. // unsort
  498. STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
  499. // set was_packed flags and all_rects_packed status
  500. for (i=0; i < num_rects; ++i) {
  501. rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
  502. if (!rects[i].was_packed)
  503. all_rects_packed = 0;
  504. }
  505. // return the all_rects_packed status
  506. return all_rects_packed;
  507. }
  508. #endif
  509. /*
  510. ------------------------------------------------------------------------------
  511. This software is available under 2 licenses -- choose whichever you prefer.
  512. ------------------------------------------------------------------------------
  513. ALTERNATIVE A - MIT License
  514. Copyright (c) 2017 Sean Barrett
  515. Permission is hereby granted, free of charge, to any person obtaining a copy of
  516. this software and associated documentation files (the "Software"), to deal in
  517. the Software without restriction, including without limitation the rights to
  518. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  519. of the Software, and to permit persons to whom the Software is furnished to do
  520. so, subject to the following conditions:
  521. The above copyright notice and this permission notice shall be included in all
  522. copies or substantial portions of the Software.
  523. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  524. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  525. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  526. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  527. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  528. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  529. SOFTWARE.
  530. ------------------------------------------------------------------------------
  531. ALTERNATIVE B - Public Domain (www.unlicense.org)
  532. This is free and unencumbered software released into the public domain.
  533. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
  534. software, either in source code form or as a compiled binary, for any purpose,
  535. commercial or non-commercial, and by any means.
  536. In jurisdictions that recognize copyright laws, the author or authors of this
  537. software dedicate any and all copyright interest in the software to the public
  538. domain. We make this dedication for the benefit of the public at large and to
  539. the detriment of our heirs and successors. We intend this dedication to be an
  540. overt act of relinquishment in perpetuity of all present and future rights to
  541. this software under copyright law.
  542. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  543. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  544. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  545. AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  546. ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  547. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  548. ------------------------------------------------------------------------------
  549. */