EtcBlock4x4Encoding_RGB8.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2015 The Etc2Comp Authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include "EtcBlock4x4Encoding_ETC1.h"
  18. namespace Etc
  19. {
  20. class Block4x4Encoding_RGB8 : public Block4x4Encoding_ETC1
  21. {
  22. public:
  23. Block4x4Encoding_RGB8(void);
  24. virtual ~Block4x4Encoding_RGB8(void);
  25. virtual void InitFromEncodingBits(Block4x4 *a_pblockParent,
  26. unsigned char *a_paucEncodingBits,
  27. ColorFloatRGBA *a_pafrgbaSource,
  28. ErrorMetric a_errormetric);
  29. virtual void PerformIteration(float a_fEffort);
  30. virtual void SetEncodingBits(void);
  31. inline ColorFloatRGBA GetColor3(void) const
  32. {
  33. return m_frgbaColor3;
  34. }
  35. protected:
  36. static const unsigned int PLANAR_CORNER_COLORS = 3;
  37. static const unsigned int MAX_PLANAR_REGRESSION_SIZE = 4;
  38. static const unsigned int TH_DISTANCES = 8;
  39. static float s_afTHDistanceTable[TH_DISTANCES];
  40. void TryPlanar(unsigned int a_uiRadius);
  41. void TryTAndH(unsigned int a_uiRadius);
  42. void InitFromEncodingBits_Planar(void);
  43. ColorFloatRGBA m_frgbaColor3; // used for planar
  44. void SetEncodingBits_T(void);
  45. void SetEncodingBits_H(void);
  46. void SetEncodingBits_Planar(void);
  47. // state shared between iterations
  48. ColorFloatRGBA m_frgbaOriginalColor1_TAndH;
  49. ColorFloatRGBA m_frgbaOriginalColor2_TAndH;
  50. void CalculateBaseColorsForTAndH(void);
  51. void TryT(unsigned int a_uiRadius);
  52. void TryT_BestSelectorCombination(void);
  53. void TryH(unsigned int a_uiRadius);
  54. void TryH_BestSelectorCombination(void);
  55. private:
  56. void InitFromEncodingBits_T(void);
  57. void InitFromEncodingBits_H(void);
  58. void CalculatePlanarCornerColors(void);
  59. void ColorRegression(ColorFloatRGBA *a_pafrgbaPixels, unsigned int a_uiPixels,
  60. ColorFloatRGBA *a_pfrgbaSlope, ColorFloatRGBA *a_pfrgbaOffset);
  61. bool TwiddlePlanar(void);
  62. bool TwiddlePlanarR();
  63. bool TwiddlePlanarG();
  64. bool TwiddlePlanarB();
  65. void DecodePixels_T(void);
  66. void DecodePixels_H(void);
  67. void DecodePixels_Planar(void);
  68. };
  69. } // namespace Etc