You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.6KB

  1. /*
  2. Copyright (C) 2001-2002 Michael Niedermayer (michaelni@gmx.at)
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. /**
  16. * @file postprocess_internal.h
  17. * internal api header.
  18. */
  19. #define V_DEBLOCK 0x01
  20. #define H_DEBLOCK 0x02
  21. #define DERING 0x04
  22. #define LEVEL_FIX 0x08 ///< Brightness & Contrast
  23. #define LUM_V_DEBLOCK V_DEBLOCK // 1
  24. #define LUM_H_DEBLOCK H_DEBLOCK // 2
  25. #define CHROM_V_DEBLOCK (V_DEBLOCK<<4) // 16
  26. #define CHROM_H_DEBLOCK (H_DEBLOCK<<4) // 32
  27. #define LUM_DERING DERING // 4
  28. #define CHROM_DERING (DERING<<4) // 64
  29. #define LUM_LEVEL_FIX LEVEL_FIX // 8
  30. #define CHROM_LEVEL_FIX (LEVEL_FIX<<4) // 128 (not implemented yet)
  31. // Experimental vertical filters
  32. #define V_X1_FILTER 0x0200 // 512
  33. // Experimental horizontal filters
  34. #define H_X1_FILTER 0x2000 // 8192
  35. /// select between full y range (255-0) or standart one (234-16)
  36. #define FULL_Y_RANGE 0x8000 // 32768
  37. //Deinterlacing Filters
  38. #define LINEAR_IPOL_DEINT_FILTER 0x10000 // 65536
  39. #define LINEAR_BLEND_DEINT_FILTER 0x20000 // 131072
  40. #define CUBIC_BLEND_DEINT_FILTER 0x8000 // (not implemented yet)
  41. #define CUBIC_IPOL_DEINT_FILTER 0x40000 // 262144
  42. #define MEDIAN_DEINT_FILTER 0x80000 // 524288
  43. #define FFMPEG_DEINT_FILTER 0x400000
  44. #define LOWPASS5_DEINT_FILTER 0x800000
  45. #define TEMP_NOISE_FILTER 0x100000
  46. #define FORCE_QUANT 0x200000
  47. //use if u want a faster postprocessing code
  48. //cant differentiate between chroma & luma filters (both on or both off)
  49. //obviosly the -pp option at the commandline has no effect except turning the here selected
  50. //filters on
  51. //#define COMPILE_TIME_MODE 0x77
  52. #if 1
  53. static inline int CLIP(int a){
  54. if(a&256) return ((a)>>31)^(-1);
  55. else return a;
  56. }
  57. //#define CLIP(a) (((a)&256) ? ((a)>>31)^(-1) : (a))
  58. #elif 0
  59. #define CLIP(a) clip_tab[a]
  60. #else
  61. #define CLIP(a) (a)
  62. #endif
  63. /**
  64. * Postprocessng filter.
  65. */
  66. struct PPFilter{
  67. char *shortName;
  68. char *longName;
  69. int chromDefault; ///< is chrominance filtering on by default if this filter is manually activated
  70. int minLumQuality; ///< minimum quality to turn luminance filtering on
  71. int minChromQuality; ///< minimum quality to turn chrominance filtering on
  72. int mask; ///< Bitmask to turn this filter on
  73. };
  74. /**
  75. * Postprocessng mode.
  76. */
  77. typedef struct PPMode{
  78. int lumMode; ///< acivates filters for luminance
  79. int chromMode; ///< acivates filters for chrominance
  80. int error; ///< non zero on error
  81. int minAllowedY; ///< for brigtness correction
  82. int maxAllowedY; ///< for brihtness correction
  83. float maxClippedThreshold; ///< amount of "black" u r willing to loose to get a brightness corrected picture
  84. int maxTmpNoise[3]; ///< for Temporal Noise Reducing filter (Maximal sum of abs differences)
  85. int baseDcDiff;
  86. int flatnessThreshold;
  87. int forcedQuant; ///< quantizer if FORCE_QUANT is used
  88. } PPMode;
  89. /**
  90. * postprocess context.
  91. */
  92. typedef struct PPContext{
  93. uint8_t *tempBlocks; ///<used for the horizontal code
  94. /**
  95. * luma histogram.
  96. * we need 64bit here otherwise we'll going to have a problem
  97. * after watching a black picture for 5 hours
  98. */
  99. uint64_t *yHistogram;
  100. uint64_t __attribute__((aligned(8))) packedYOffset;
  101. uint64_t __attribute__((aligned(8))) packedYScale;
  102. /** Temporal noise reducing buffers */
  103. uint8_t *tempBlured[3];
  104. int32_t *tempBluredPast[3];
  105. /** Temporary buffers for handling the last row(s) */
  106. uint8_t *tempDst;
  107. uint8_t *tempSrc;
  108. uint8_t *deintTemp;
  109. uint64_t __attribute__((aligned(8))) pQPb;
  110. uint64_t __attribute__((aligned(8))) pQPb2;
  111. uint64_t __attribute__((aligned(8))) mmxDcOffset[32];
  112. uint64_t __attribute__((aligned(8))) mmxDcThreshold[32];
  113. QP_STORE_T *stdQPTable; ///< used to fix MPEG2 style qscale
  114. QP_STORE_T *nonBQPTable;
  115. QP_STORE_T *forcedQPTable;
  116. int QP;
  117. int nonBQP;
  118. int frameNum;
  119. int cpuCaps;
  120. int qpStride; ///<size of qp buffers (needed to realloc them if needed)
  121. int stride; ///<size of some buffers (needed to realloc them if needed)
  122. int hChromaSubSample;
  123. int vChromaSubSample;
  124. PPMode ppMode;
  125. } PPContext;