| 1135 | /************************************************************************/ |
| 1136 | |
| 1137 | static int ParseDefaultLUT( const char *lut_def, GByte *lut ) |
| 1138 | |
| 1139 | { |
| 1140 | const char *lut_read; |
| 1141 | int last_in=0, last_out=0, all_done=FALSE; |
| 1142 | |
| 1143 | /* -------------------------------------------------------------------- */ |
| 1144 | /* Parse definition, applying to lut on the fly. */ |
| 1145 | /* -------------------------------------------------------------------- */ |
| 1146 | lut_read = lut_def; |
| 1147 | while( !all_done ) |
| 1148 | { |
| 1149 | int this_in=0, this_out=0; |
| 1150 | int lut_i; |
| 1151 | |
| 1152 | while( isspace(*lut_read) ) |
| 1153 | lut_read++; |
| 1154 | |
| 1155 | /* if we are at end, assum 255:255 */ |
| 1156 | if( *lut_read == '\0' ) |
| 1157 | { |
| 1158 | all_done = TRUE; |
| 1159 | if ( last_in != 255 ){ |
| 1160 | this_in = 255; |
| 1161 | this_out = 255; |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | /* otherwise read "in:out", and skip past */ |
| 1166 | else |
| 1167 | { |
| 1168 | this_in = atoi(lut_read); |
| 1169 | while( *lut_read != ':' && *lut_read ) |
| 1170 | lut_read++; |
| 1171 | if( *lut_read == ':' ) |
| 1172 | lut_read++; |
| 1173 | while( isspace(*lut_read) ) |
| 1174 | lut_read++; |
| 1175 | this_out = atoi(lut_read); |
| 1176 | while( *lut_read && *lut_read != ',' && *lut_read != '\n' ) |
| 1177 | lut_read++; |
| 1178 | if( *lut_read == ',' || *lut_read == '\n' ) |
| 1179 | lut_read++; |
| 1180 | while( isspace(*lut_read) ) |
| 1181 | lut_read++; |
| 1182 | } |
| 1183 | |
| 1184 | this_in = MAX(0,MIN(255,this_in)); |
| 1185 | this_out = MAX(0,MIN(255,this_out)); |
| 1186 | |
| 1187 | /* apply linear values from last in:out to this in:out */ |
| 1188 | for( lut_i = last_in; lut_i <= this_in; lut_i++ ) |
| 1189 | { |
| 1190 | double ratio; |
| 1191 | |
| 1192 | if( last_in == this_in ) |
| 1193 | ratio = 1.0; |
| 1194 | else |
no outgoing calls
no test coverage detected