1 /* 2 * Copyright (C) 2011 The Android Open Source Project 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 #include <android/log.h> 18 19 #define ATTRIBUTE_UNUSED __attribute__((unused)) 20 21 int invert_process(const char** inputs, 22 const int* input_sizes, 23 int input_count, 24 char* output, 25 int output_size, 26 void* user_data ATTRIBUTE_UNUSED) { 27 // Make sure we have exactly one input 28 if (input_count != 1) 29 return 0; 30 31 // Make sure sizes match up 32 if (input_sizes[0] != output_size) 33 return 0; 34 35 // Get the input and output pointers 36 const char* input_ptr = inputs[0]; 37 char* output_ptr = output; 38 if (!input_ptr || !output_ptr) 39 return 0; 40 41 // Run the inversion 42 int i; 43 for (i = 0; i < output_size; ++i) 44 *(output_ptr++) = 255 - *(input_ptr++); 45 46 return 1; 47 } 48 49