1 /*
2  * Copyright (C) 2014 Intel Corporation.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __ISV_PROFILE_H
19 #define __ISV_PROFILE_H
20 
21 #define MAX_BUF_SIZE (4 * 1024)
22 #define MAX_TAB_SIZE (10)
23 #define MAX_STRING_LEN (50)
24 
25 #include <utils/RefBase.h>
26 using namespace android;
27 
28 typedef enum _FRC_RATE {
29     FRC_RATE_1X = 1,
30     FRC_RATE_2X,
31     FRC_RATE_2_5X,
32     FRC_RATE_4X
33 } FRC_RATE;
34 
35 typedef enum {
36     VPP_COMMON_ON   = 1,        // VPP is on
37     VPP_FRC_ON      = 1 << 1,   // FRC is on
38 } VPP_SETTING_STATUS;
39 
40 typedef struct _ISVParameter {
41     char name[MAX_STRING_LEN];
42     float value;
43 } ISVParameter;
44 
45 typedef struct _ISVConfig {
46     bool enabled;
47     uint32_t minResolution;
48     uint32_t maxResolution;
49     //bool isOn;
50     ISVParameter paraTables[MAX_TAB_SIZE];
51     uint32_t paraSize;
52 } ISVConfig;
53 
54 typedef struct _ISVFRCRate {
55     uint32_t input_fps;
56     FRC_RATE rate;
57 } ISVFRCRate;
58 
59 //FIXME: need align to ProcFilterType
60 typedef enum _FilterType {
61     FilterNone                          = 0x00000001,
62     FilterNoiseReduction                = 0x00000002,
63     FilterDeinterlacing                 = 0x00000004,
64     FilterSharpening                    = 0x00000008,
65     FilterColorBalance                  = 0x00000010,
66     FilterDeblocking                    = 0x00000020,
67     FilterFrameRateConversion           = 0x00000040,
68     FilterSkinToneEnhancement           = 0x00000080,
69     FilterTotalColorCorrection          = 0x00000100,
70     FilterNonLinearAnamorphicScaling    = 0x00000200,
71     FilterImageStabilization            = 0x00000400,
72 } FilterType;
73 
74 class ISVProfile : public RefBase
75 {
76 public:
77     ISVProfile(const uint32_t width, const uint32_t height);
78     ~ISVProfile();
79 
80     /* get the global ISV setting status */
81     FRC_RATE getFRCRate(uint32_t inputFps);
82 
83     /* get filter config data
84      * the filters' status are saved in uint32_t
85      */
86     uint32_t getFilterStatus();
87 
88     /* the global setting for VPP */
89     static bool isVPPOn();
90 
91     /* the global setting for FRC */
92     static bool isFRCOn();
93 
94 private:
95     /* Read the global setting for ISV */
96     static int32_t getGlobalStatus();
97 
98     /* Get the config data from XML file */
99     void getDataFromXmlFile(void);
100 
101     /* Update the filter status */
102     void updateFilterStatus();
103 
104     /* handle the XML file */
105     static void startElement(void *userData, const char *name, const char **atts);
106     static void endElement(void *userData, const char *name);
107     int getFilterID(const char * name);
108     uint32_t getResolution(const char * name);
109     void getConfigData(const char *name, const char **atts);
110     void handleFilterParameter(const char *name, const char **atts);
111     void handleCommonParameter(const char *name, const char **atts);
112 
113     /* dump the config data */
114     void dumpConfigData();
115 
116     typedef enum _ProcFilterType {
117         ProcFilterNone = 0,
118         ProcFilterNoiseReduction,
119         ProcFilterDeinterlacing,
120         ProcFilterSharpening,
121         ProcFilterColorBalance,
122         ProcFilterDeblocking,
123         ProcFilterFrameRateConversion,
124         ProcFilterSkinToneEnhancement,
125         ProcFilterTotalColorCorrection,
126         ProcFilterNonLinearAnamorphicScaling,
127         ProcFilterImageStabilization,
128         ProcFilterCount
129     } ProcFilterType;
130 
131 private:
132     uint32_t mWidth;
133     uint32_t mHeight;
134 
135     /* The default value of VPP/FRC.
136      * They will be read from config xml file.
137      */
138     int32_t mDefaultVPPStatus;
139     int32_t mDefaultFRCStatus;
140 
141     /* the filters' status according to resolution
142      * bit 0  used for ProcFilterNone
143      * bit 1  used for ProcFilterNoiseReduction
144      * ...
145      * bit 10 used for ProcFilterImageStabilization
146      */
147     uint32_t mStatus;
148 
149     ISVConfig mConfigs[ProcFilterCount];
150     uint32_t mCurrentFilter; //used by parasing xml file
151     ISVFRCRate mFrcRates[MAX_TAB_SIZE];
152     uint32_t mCurrentFrcTab;
153 
154     static const int mBufSize = MAX_BUF_SIZE;
155 };
156 
157 #endif /* __ISV_PROFILE_H */
158