PageRenderTime 247ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/common/video/mpeg4-2000/type/vop.hpp

https://github.com/stsquad/mpeg4ip
C++ Header | 144 lines | 87 code | 13 blank | 44 comment | 1 complexity | c96b55252acdb3169d63bcb70251b07b MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.0
  1. /*************************************************************************
  2. This software module was originally developed by
  3. Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation
  4. Wei-ge Chen (wchen@microsoft.com), Microsoft Corporation
  5. Bruce Lin (blin@microsoft.com), Microsoft Corporation
  6. Chuang Gu (chuanggu@microsoft.com), Microsoft Corporation
  7. (date: March, 1996)
  8. in the course of development of the MPEG-4 Video (ISO/IEC 14496-2).
  9. This software module is an implementation of a part of one or more MPEG-4 Video tools
  10. as specified by the MPEG-4 Video.
  11. ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications
  12. thereof for use in hardware or software products claiming conformance to the MPEG-4 Video.
  13. Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents.
  14. The original developer of this software module and his/her company,
  15. the subsequent editors and their companies,
  16. and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation.
  17. Copyright is not released for non MPEG-4 Video conforming products.
  18. Microsoft retains full right to use the code for his/her own purpose,
  19. assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products.
  20. This copyright notice must be included in all copies or derivative works.
  21. Copyright (c) 1996, 1997.
  22. Module Name:
  23. vop.hpp
  24. Abstract:
  25. class for Video Object Plane
  26. Revision History:
  27. *************************************************************************/
  28. #ifndef __VOP_HPP_
  29. #define __VOP_HPP_
  30. #include <stdio.h>
  31. class CU8Image;
  32. class CFloatImage;
  33. class CIntImage;
  34. class CTransform;
  35. class CVideoObjectPlane
  36. {
  37. public:
  38. // Constructors
  39. ~CVideoObjectPlane ();
  40. CVideoObjectPlane (const CVideoObjectPlane& vop, CRct r = CRct ()); // copy constructor
  41. CVideoObjectPlane (CRct r = CRct (), CPixel pxl = transpPixel);
  42. CVideoObjectPlane ( // load a VOP from MPEG4 file
  43. const Char* pchFileName, // file name
  44. UInt ifr, // frame number, 0 is always the base number
  45. const CRct& rct, // rect for the VOP
  46. ChromType chrType, // chrominance type
  47. Int nszHeader = 0 // header to be skipped
  48. );
  49. CVideoObjectPlane (const Char* vdlFileName); // load from a vdl stream
  50. // Attributes
  51. Bool valid () const {return this != 0;}
  52. CRct where () const {return m_rc;}
  53. CPixel pixel (CoordI x, CoordI y) const {return m_ppxl [m_rc.offset (x, y)];}
  54. CPixel pixel (CoordI x, CoordI y, UInt accuracy) const;
  55. CPixel pixel (const CSite& st, UInt accuracy) const {return pixel (st.x, st.y, accuracy);} // bi-linear interpolation
  56. CPixel pixel (const CSite& st) const {return pixel (st.x, st.y);}
  57. CPixel pixel (CoordD x, CoordD y) const; // bi-linear interpolation
  58. CPixel pixel (const CSiteD& std) const {return pixel (std.x, std.y);} // bi-linear interpolation
  59. const CPixel* pixels () const {return m_ppxl;} // return pointer
  60. const CPixel* pixels (CoordI x, CoordI y) const {return m_ppxl + m_rc.offset (x, y);}
  61. const CPixel* pixels (const CSite& st) const {return pixels (st.x, st.y);}
  62. CRct whereVisible() const; // smallest rect containing all non transparent pixels
  63. // Resultants
  64. own CVideoObjectPlane* warp (const CAffine2D& aff) const; // affine warp
  65. own CVideoObjectPlane* warp (const CAffine2D& aff, const CRct& rctWarp) const; // affine warp to rctWarp
  66. own CVideoObjectPlane* warp (const CPerspective2D& persp) const; // perspective warp
  67. own CVideoObjectPlane* warp (const CPerspective2D& persp, const CRct& rctWarp) const; // perspective warp to rctWarp
  68. own CVideoObjectPlane* warp (const CPerspective2D& persp, const CRct& rctWarp, UInt accuracy) const;
  69. own CVideoObjectPlane* decimate (UInt rateX, UInt rateY) const; // decimate the vframe by rateX and rateY.
  70. own CVideoObjectPlane* zoomup (UInt rateX, UInt rateY) const;
  71. own CVideoObjectPlane* expand (UInt rateX, UInt rateY) const;
  72. own CVideoObjectPlane* biInterpolate () const; // bilinearly interpolate the vframe
  73. own CVideoObjectPlane* biInterpolate (UInt accuracy) const; // bilinearly interpolate the vframe
  74. own CVideoObjectPlane* biInterpolate (const CRct& r) const; // bilinearly interpolate the vframe
  75. own CFloatImage* plane (RGBA pxlCom) const; // get a plane
  76. Void vdlDump (const Char* fileName = "tmp.vdl", CPixel ppxlFalse = CPixel (0, 0, 0, 0)) const;
  77. Void vdlByteDump (const Char* fileName = "tmp.vdl", CPixel ppxlFalse = CPixel (0, 0, 0, 0)) const;
  78. Void dump (FILE* pfFile, ChromType = FOUR_TWO_TWO) const;
  79. Void dumpAlpha (FILE* pfFile) const;
  80. Void dumpAbekas (FILE* pfFile) const; //dump abekas file
  81. // Operations
  82. Void where (const CRct& r); // crop based on r
  83. Void pixel (CoordI x, CoordI y, CPixel p) {m_ppxl [m_rc.offset (x, y)] = p;} // set a pixel
  84. Void pixel (const CSite& st, CPixel p) {pixel (st.x, st.y, p);} // set a pixel
  85. Void lightChange (Int rShift, Int gShift, Int bShift); // lighting change
  86. Void falseColor (CPixel pxl); // replace the rgb values of the transparent pixels by pxl
  87. Void falseColor (U8 r, U8 g, U8 b); // replace the rgb values of the transparent pixels by r, g, b
  88. Void shift (Int nX, Int nY) {m_rc.shift (nX,nY);} // shift CRct by nX and nY
  89. Void mirrorPad (); // mirror padding
  90. Void repeatPad (); // repetitive padding
  91. Void multiplyAlpha (); // multiply alpha
  92. Void multiplyBiAlpha (); // multiply alpha
  93. Void unmultiplyAlpha ();
  94. Void thresholdAlpha (U8 uThresh); // convert 8-bit alpha to binary alpha
  95. Void thresholdRGB (U8 uThresh); // threshold RGB components
  96. Void cropOnAlpha (); // Crop based on the alpha plane
  97. Void overlay (const CVideoObjectPlane& vop); // overlay VOP on top of *this
  98. Void setPlane (const CFloatImage& fi, RGBA pxlCom); // set a plane
  99. Void setPlane (const CIntImage& ii, RGBA pxlCom); // set a plane
  100. Void setPlane (const CU8Image& ci, RGBA pxlCom); // set a plane
  101. Void getDownSampledPlane(CFloatImage &fi,Int plane,Int sx,Int sy); // downsample plane into float image
  102. Void setUpSampledPlane(const CFloatImage &fi,Int plane,Int sx,Int sy); // upsample float image into plane
  103. Void getDownSampledPlane(CIntImage &fi,Int plane,Int sx,Int sy); // downsample plane into int image
  104. Void setUpSampledPlane(const CIntImage &fi,Int plane,Int sx,Int sy); // upsample int image into plane
  105. Void rgbToYUV ();
  106. Void yuvToRGB ();
  107. // Overloaded operators
  108. own CVideoObjectPlane* operator * (const CTransform& tf) const;
  109. own CVideoObjectPlane* operator * (const CAffine2D& aff) const {return warp (aff);} // affine warp
  110. own CVideoObjectPlane* operator * (const CPerspective2D& persp) const {return warp (persp);} // perspective warp
  111. own CVideoObjectPlane* operator - (const CVideoObjectPlane& vop) const;
  112. ///////////////// implementation /////////////////
  113. private:
  114. CPixel* m_ppxl;
  115. CRct m_rc;
  116. Void allocate (CRct r, CPixel pxl = transpPixel);
  117. Void copyConstruct (const CVideoObjectPlane& vop, CRct r = CRct());
  118. Void swap (CVideoObjectPlane& vop);
  119. };
  120. #endif // __VOP_HPP_