/** * Process value for brightness/contrast filter. * * @param double *f - Filter, double of 4 * @param uint32_r value - Value to process * @return double **/ static double brcn_filter_process(double *f, uint32_t value) { double result; #define RANGE(i) i[0] #define SCALE(i) i[1] #define SLOPE(i) i[2] #define INTERCEPT(i) i[3] result = ((SLOPE(f) * SCALE(f)) * value + INTERCEPT(f)) * RANGE(f); if (result > RANGE(f)) { result = RANGE(f); } else if (result < 0.0) { result = 0.0; } #undef RANGE #undef SCALE #undef SLOPE #undef INTERCEPT return result; }
/* * Read data from the remote socket and send it to the appropriate local * socket. * If this is a new connection, insert it in the connection table and * place its handle in *chpp. */ static void udp_remote_to_local( struct intercept_s *ip, channel_s **chpp ) { char buf[ MAX_DATAGRAM_SIZE ] ; packet_s packet ; channel_s *chp ; bool_int addr_checked ; *chpp = CHANNEL_NULL ; packet.data = buf ; packet.size = sizeof( buf ) ; if ( get_incoming_packet( ip, &packet ) == FAILED ) return ; chp = int_lookupconn( ip, &packet.from, &addr_checked ) ; if ( chp == CHANNEL_NULL ) { struct server *serp = INT_SERVER( ip ) ; struct service *sp = SERVER_SERVICE( serp ) ; connection_s *cop = SERVER_CONNECTION( serp ) ; if ( ( chp = int_newconn( ip, &packet.from, INT_REMOTE( ip ) ) ) == NULL ) return ; CONN_SETADDR( cop, &packet.from ) ; /* for logging */ if ( INTERCEPT( ip ) ) { mask_t check_mask ; access_e result ; M_OR( check_mask, XMASK( CF_ADDRESS ), XMASK( CF_TIME ) ) ; result = access_control( sp, cop, &check_mask ) ; if ( result != AC_OK ) { svc_log_failure( sp, cop, result ) ; chp->ch_state = BAD_CHANNEL ; return ; } } /* * Since we don't distinguish ports, there is no point to log * another successful attempt from the same address */ if ( ! addr_checked ) svc_log_success( sp, cop, SERVER_PID( serp ) ) ; *chpp = chp ; } else if ( chp->ch_state == BAD_CHANNEL ) return ; #ifdef DEBUG_UDPINT if ( debug.on ) msg( LOG_DEBUG, "udp_remote_to_local", "sending %d bytes to server on port %d", packet.size, ntohs( INT_LOCALADDR( ip )->sin_port ) ) ; #endif send_data( chp->ch_local_socket, packet.data, packet.size, NULL ) ; }