invert.c revision 65953da4636fbf5f0a24b8f5f2b5fa7d76ff13d9
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
19int invert_process(const char** inputs,
20                   const int* input_sizes,
21                   int input_count,
22                   char* output,
23                   int output_size,
24                   void* user_data) {
25  // Make sure we have exactly one input
26  if (input_count != 1)
27    return 0;
28
29  // Make sure sizes match up
30  if (input_sizes[0] != output_size)
31    return 0;
32
33  // Get the input and output pointers
34  const char* input_ptr = inputs[0];
35  char* output_ptr = output;
36  if (!input_ptr || !output_ptr)
37    return 0;
38
39  // Run the inversion
40  int i;
41  for (i = 0; i < output_size; ++i)
42    *(output_ptr++) = 255 - *(input_ptr++);
43
44  return 1;
45}
46
47