// Copyright 2011 Google Inc.
//
// This code is licensed under the same terms as WebM:
//  Software License Agreement:  http://www.webmproject.org/license/software/
//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
// -----------------------------------------------------------------------------
//
// Coding tools configuration
//
// Author: Skal (pascal.massimino@gmail.com)

#include <assert.h>
#include "webp/encode.h"

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

//-----------------------------------------------------------------------------
// WebPConfig
//-----------------------------------------------------------------------------

int WebPConfigInitInternal(WebPConfig* const config,
                           WebPPreset preset, float quality, int version) {
  if (version != WEBP_ENCODER_ABI_VERSION) {
    return 0;   // caller/system version mismatch!
  }
  if (config == NULL) return 0;

  config->quality = quality;
  config->target_size = 0;
  config->target_PSNR = 0.;
  config->method = 4;
  config->sns_strength = 50;
  config->filter_strength = 20;   // default: light filtering
  config->filter_sharpness = 0;
  config->filter_type = 0;        // default: simple
  config->partitions = 0;
  config->segments = 4;
  config->pass = 1;
  config->show_compressed = 0;
  config->preprocessing = 0;
  config->autofilter = 0;
  config->alpha_compression = 0;

  // TODO(skal): tune.
  switch (preset) {
    case WEBP_PRESET_PICTURE:
      config->sns_strength = 80;
      config->filter_sharpness = 4;
      config->filter_strength = 35;
      break;
    case WEBP_PRESET_PHOTO:
      config->sns_strength = 80;
      config->filter_sharpness = 3;
      config->filter_strength = 30;
      break;
    case WEBP_PRESET_DRAWING:
      config->sns_strength = 25;
      config->filter_sharpness = 6;
      config->filter_strength = 10;
      break;
    case WEBP_PRESET_ICON:
      config->sns_strength = 0;
      config->filter_strength = 0;   // disable filtering to retain sharpness
      break;
    case WEBP_PRESET_TEXT:
      config->sns_strength = 0;
      config->filter_strength = 0;   // disable filtering to retain sharpness
      config->segments = 2;
      break;
    case WEBP_PRESET_DEFAULT:
    default:
      break;
  }
  return WebPValidateConfig(config);
}

int WebPValidateConfig(const WebPConfig* const config) {
  if (config == NULL) return 0;
  if (config->quality < 0 || config->quality > 100)
    return 0;
  if (config->target_size < 0)
    return 0;
  if (config->target_PSNR < 0)
    return 0;
  if (config->method < 0 || config->method > 6)
    return 0;
  if (config->segments < 1 || config->segments > 4)
    return 0;
  if (config->sns_strength < 0 || config->sns_strength > 100)
    return 0;
  if (config->filter_strength < 0 || config->filter_strength > 100)
    return 0;
  if (config->filter_sharpness < 0 || config->filter_sharpness > 7)
    return 0;
  if (config->filter_type < 0 || config->filter_type > 1)
    return 0;
  if (config->autofilter < 0 || config->autofilter > 1)
    return 0;
  if (config->pass < 1 || config->pass > 10)
    return 0;
  if (config->show_compressed < 0 || config->show_compressed > 1)
    return 0;
  if (config->preprocessing < 0 || config->preprocessing > 1)
    return 0;
  if (config->partitions < 0 || config->partitions > 3)
    return 0;
  if (config->alpha_compression < 0)
    return 0;
  return 1;
}

//-----------------------------------------------------------------------------

#if defined(__cplusplus) || defined(c_plusplus)
}    // extern "C"
#endif
