llpatch_dct.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @file llpatch_dct.h
  3. * @brief Function declarations for DCT and IDCT routines
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewergpl$
  6. *
  7. * Copyright (c) 2000-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_PATCH_DCT_H
  33. #define LL_PATCH_DCT_H
  34. class LLVector3;
  35. // Code Values
  36. constexpr U8 ZERO_CODE = 0x0;
  37. constexpr U8 ZERO_EOB = 0x2;
  38. constexpr U8 POSITIVE_VALUE = 0x6;
  39. constexpr U8 NEGATIVE_VALUE = 0x7;
  40. constexpr S8 NORMAL_PATCH_SIZE = 16;
  41. constexpr S8 LARGE_PATCH_SIZE = 32;
  42. constexpr U8 END_OF_PATCHES = 97;
  43. #define _PATCH_SIZE_16_AND_32_ONLY
  44. // Top level header for group of headers
  45. //typedef struct LL_Group_Header
  46. //{
  47. // U16 stride; // 2 = 2
  48. // U8 patch_size; // 1 = 3
  49. // U8 layer_type; // 1 = 4
  50. //} LLGroupHeader;
  51. class LLGroupHeader
  52. {
  53. public:
  54. U16 stride; // 2 = 2
  55. U8 patch_size; // 1 = 3
  56. U8 layer_type; // 1 = 4
  57. };
  58. // Individual patch header
  59. //typedef struct LL_Patch_Header
  60. //{
  61. // F32 dc_offset; // 4 bytes
  62. // U16 range; // 2 = 7 ((S16) FP range (breaks if we need > 32K meters in 1 patch)
  63. // U8 quant_wbits; // 1 = 8 (upper 4 bits is quant - 2, lower 4 bits is word bits - 2)
  64. // U32 patchids; // 2 = 10 (actually only uses 10 bits for 256m sims, 5 for each)
  65. //} LLPatchHeader;
  66. class LLPatchHeader
  67. {
  68. public:
  69. F32 dc_offset; // 4 bytes
  70. U16 range; // 2 = 7 ((S16) FP range (breaks if we need > 32K meters in 1 patch)
  71. U8 quant_wbits; // 1 = 8 (upper 4 bits is quant - 2, lower 4 bits is word bits - 2)
  72. U32 patchids; // 2 = 10 (actually only uses 10 bits for 256m sims, 5 for each)
  73. };
  74. // Compression routines
  75. void init_patch_compressor(S32 patch_size, S32 patch_stride, S32 layer_type);
  76. void prescan_patch(F32* patch, LLPatchHeader* php, F32& zmax, F32& zmin);
  77. void compress_patch(F32* patch, S32* cpatch, LLPatchHeader* php, S32 prequant);
  78. void get_patch_group_header(LLGroupHeader* gopp);
  79. // Decompression routines
  80. void set_group_of_patch_header(LLGroupHeader* gopp);
  81. void init_patch_decompressor(S32 size);
  82. void decompress_patch(F32* patch, S32* cpatch, LLPatchHeader* ph);
  83. void decompress_patchv(LLVector3* v, S32* cpatch, LLPatchHeader* ph);
  84. #endif