codec.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __codec_h__
  21. #define __codec_h__
  22. #define MAXERRORMAX 200
  23. #define IPSIZE int
  24. const float MOTION_MIN = 1.0f;
  25. const float MIN_SNR = 3.0f;
  26. #define FULLFRAME 0
  27. #define JUSTMOTION 1
  28. #define VQDATA double
  29. #include "gdefs.h"
  30. #include "roq.h"
  31. #include "quaddefs.h"
  32. class codec {
  33. public:
  34. codec();
  35. ~codec();
  36. void SparseEncode( void );
  37. void EncodeNothing( void );
  38. void IRGBtab(void);
  39. void InitImages(void);
  40. void QuadX( int startX, int startY, int quadSize);
  41. void InitQStatus();
  42. float Snr(byte *old, byte *bnew, int size);
  43. void FvqData( byte *bitmap, int size, int realx, int realy, quadcel *pquad, bool clamp);
  44. void GetData( unsigned char *iData, int qSize, int startX, int startY, NSBitmapImageRep *bitmap);
  45. int ComputeMotionBlock( byte *old, byte *bnew, int size);
  46. void VqData8( byte *cel, quadcel *pquad);
  47. void VqData4( byte *cel, quadcel *pquad);
  48. void VqData2( byte *cel, quadcel *pquad);
  49. int MotMeanY(void);
  50. int MotMeanX(void);
  51. void SetPreviousImage( const char*filename, NSBitmapImageRep *timage );
  52. int BestCodeword( unsigned char *tempvector, int dimension, VQDATA **codebook );
  53. private:
  54. void VQ( const int numEntries, const int dimension, const unsigned char *vectors, float *snr, VQDATA **codebook, const bool optimize );
  55. void Sort( float *list, int *intIndex, int numElements );
  56. void Segment( int *alist, float *flist, int numElements, float rmse);
  57. void LowestQuad( quadcel*qtemp, int* status, float* snr, int bweigh);
  58. void MakePreviousImage( quadcel *pquad );
  59. float GetCurrentRMSE( quadcel *pquad );
  60. int GetCurrentQuadOutputSize( quadcel *pquad );
  61. int AddQuad( quadcel *pquad, int lownum );
  62. NSBitmapImageRep *image;
  63. NSBitmapImageRep *newImage;
  64. NSBitmapImageRep *previousImage[2]; // the ones in video ram and offscreen ram
  65. int numQuadCels;
  66. int whichFrame;
  67. int slop;
  68. bool detail;
  69. int onQuad;
  70. int initRGBtab;
  71. quadcel *qStatus;
  72. int dxMean;
  73. int dyMean;
  74. int codebooksize;
  75. int index2[256];
  76. int overAmount;
  77. int pixelsWide;
  78. int pixelsHigh;
  79. int codebookmade;
  80. bool used2[256];
  81. bool used4[256];
  82. int dimension2;
  83. int dimension4;
  84. byte luty[256];
  85. byte *luti;
  86. VQDATA **codebook2;
  87. VQDATA **codebook4;
  88. };
  89. #endif // __codec_h__