text: /*
  
   * Copyright (c) 2012-2017 The Khronos Group Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *    http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /*!
   * \file
   * \brief The Filter Kernels.
   * \author Erik Rainey <erik.rainey@gmail.com>
   */
  
  #include "vx_interface.h"
  
  #include "vx_internal.h"
  
  #include <tiling.h>
  
  static vx_status VX_CALLBACK vxFilterInputValidator(vx_node node, vx_uint32 index)
  {
      vx_status status = VX_ERROR_INVALID_PARAMETERS;
      if (index == 0)
      {
          vx_parameter param = vxGetParameterByIndex(node, index);
          if (param)
          {
              vx_image input = 0;
              vxQueryParameter(param, VX_PARAMETER_REF, &input, sizeof(input));
              if (input)
              {
                  vx_df_image format = 0;
                  vxQueryImage(input, VX_IMAGE_FORMAT, &format, sizeof(format));
                  if (format == VX_DF_IMAGE_U1 || format == VX_DF_IMAGE_U8)
                  {
                      status = VX_SUCCESS;
                  }
                  vxReleaseImage(&input);
              }
              vxReleaseParameter(&param);
          }
      }
      return status;
  }
  
  static vx_status VX_CALLBACK vxFilterOutputValidator(vx_node node, vx_uint32 index, vx_meta_format_t *ptr)
  {
      vx_status status = VX_ERROR_INVALID_PARAMETERS;
      if (index == 1)
      {
          vx_parameter param = vxGetParameterByIndex(node, 0); /* we reference the input image */
          if (vxGetStatus((vx_reference)param) == VX_SUCCESS)
          {
              vx_image input = 0;
              vxQueryParameter(param, VX_PARAMETER_REF, &input, sizeof(input));
              if (input)
              {
                  vx_df_image format = 0;
                  vx_uint32 width = 0, height = 0;
                  vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width));
                  vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height));
                  vxQueryImage(input, VX_IMAGE_FORMAT, &format, sizeof(format));
                  ptr->type = VX_TYPE_IMAGE;
                  ptr->dim.image.format = format;
                  ptr->dim.image.width = width;
                  ptr->dim.image.height = height;
                  status = VX_SUCCESS;
                  vxReleaseImage(&input);
              }
              vxReleaseParameter(&param);
          }
      }
      return status;
  }
  
  vx_tiling_kernel_t box_3x3_kernels =
  {
      "org.khronos.openvx.tiling_box_3x3",
      VX_KERNEL_BOX_3x3,
      NULL,
      box3x3_image_tiling_flexible,
      box3x3_image_tiling_fast,
      2,
      { { VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED },
      { VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED } },
      NULL,
      vxFilterInputValidator,
      vxFilterOutputValidator,
      NULL,
      NULL,
      { 16, 16 },
      { -1, 1, -1, 1 },
      { VX_BORDER_MODE_UNDEFINED, 0 },
  };
  
  vx_tiling_kernel_t median3x3_kernel = 
  {
      "org.khronos.openvx.tiling_median_3x3",
      VX_KERNEL_MEDIAN_3x3,
      NULL,
      Median3x3_image_tiling_flexible,
      Median3x3_image_tiling_fast,
      2,
      { { VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED },
      { VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED } },
      NULL,
      vxFilterInputValidator,
      vxFilterOutputValidator,
      NULL,
      NULL,
      { 16, 16 },
      { -1, 1, -1, 1 },
      { VX_BORDER_MODE_UNDEFINED, 0 },
  };
  
  vx_tiling_kernel_t gaussian3x3_kernel = 
  {
      "org.khronos.openvx.tiling_gaussian_3x3",
      VX_KERNEL_GAUSSIAN_3x3,
      NULL,
      Gaussian3x3_image_tiling_flexible,
      Gaussian3x3_image_tiling_fast,
      2,
      { { VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED },
      { VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED } },
      NULL,
      vxFilterInputValidator,
      vxFilterOutputValidator,
      NULL,
      NULL,
      { 16, 16 },
      { -1, 1, -1, 1 },
      { VX_BORDER_MODE_UNDEFINED, 0 },
  };
  