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