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.

146 lines
4.2KB

  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 TEMP_NOISE_FILTER 0x100000
  45. #define FORCE_QUANT 0x200000
  46. //use if u want a faster postprocessing code
  47. //cant differentiate between chroma & luma filters (both on or both off)
  48. //obviosly the -pp option at the commandline has no effect except turning the here selected
  49. //filters on
  50. //#define COMPILE_TIME_MODE 0x77
  51. /**
  52. * Postprocessng filter.
  53. */
  54. struct PPFilter{
  55. char *shortName;
  56. char *longName;
  57. int chromDefault; ///< is chrominance filtering on by default if this filter is manually activated
  58. int minLumQuality; ///< minimum quality to turn luminance filtering on
  59. int minChromQuality; ///< minimum quality to turn chrominance filtering on
  60. int mask; ///< Bitmask to turn this filter on
  61. };
  62. /**
  63. * Postprocessng mode.
  64. */
  65. typedef struct PPMode{
  66. int lumMode; ///< acivates filters for luminance
  67. int chromMode; ///< acivates filters for chrominance
  68. int error; ///< non zero on error
  69. int minAllowedY; ///< for brigtness correction
  70. int maxAllowedY; ///< for brihtness correction
  71. float maxClippedThreshold; ///< amount of "black" u r willing to loose to get a brightness corrected picture
  72. int maxTmpNoise[3]; ///< for Temporal Noise Reducing filter (Maximal sum of abs differences)
  73. int baseDcDiff;
  74. int flatnessThreshold;
  75. int forcedQuant; ///< quantizer if FORCE_QUANT is used
  76. } PPMode;
  77. /**
  78. * postprocess context.
  79. */
  80. typedef struct PPContext{
  81. uint8_t *tempBlocks; ///<used for the horizontal code
  82. /**
  83. * luma histogram.
  84. * we need 64bit here otherwise we'll going to have a problem
  85. * after watching a black picture for 5 hours
  86. */
  87. uint64_t *yHistogram;
  88. uint64_t __attribute__((aligned(8))) packedYOffset;
  89. uint64_t __attribute__((aligned(8))) packedYScale;
  90. /** Temporal noise reducing buffers */
  91. uint8_t *tempBlured[3];
  92. int32_t *tempBluredPast[3];
  93. /** Temporary buffers for handling the last row(s) */
  94. uint8_t *tempDst;
  95. uint8_t *tempSrc;
  96. uint8_t *deintTemp;
  97. uint64_t __attribute__((aligned(8))) pQPb;
  98. uint64_t __attribute__((aligned(8))) pQPb2;
  99. uint64_t __attribute__((aligned(8))) mmxDcOffset[32];
  100. uint64_t __attribute__((aligned(8))) mmxDcThreshold[32];
  101. QP_STORE_T *nonBQPTable;
  102. QP_STORE_T *forcedQPTable;
  103. int QP;
  104. int nonBQP;
  105. int frameNum;
  106. int cpuCaps;
  107. int stride; ///<size of some buffers (needed to realloc them if needed)
  108. int hChromaSubSample;
  109. int vChromaSubSample;
  110. PPMode ppMode;
  111. } PPContext;