<commit_before>/*
 * Copyright (C) 2010 <NAME>
 * Copyright (C) 2016 <NAME>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */


#include <unary_base.h>

#include <math.h>

GType unary_pow_get_type (void);

#define UNARY_LOG_TYPE \
	(unary_pow_get_type())
#define UNARY_LOG(obj) \
	(G_TYPE_CHECK_INSTANCE_CAST((obj), UNARY_LOG_TYPE, UnaryPow))


typedef struct
{
  GstAudioFilter audiofilter;
  double exponent;
} UnaryPow;



static GstFlowReturn
transform_ip (GstBaseTransform * trans, GstBuffer * buf)
{
  UnaryPow *element = UNARY_LOG (trans);
  GstAudioFilter *audiofilter = GST_AUDIO_FILTER (trans);
  GstAudioFormat format = audiofilter->info.finfo->format;

  GstMapInfo info;
  gst_buffer_map (buf, &info, GST_MAP_READ);
  gpointer data = info.data;
  gpointer data_end = data + info.size;
  gst_buffer_unmap (buf, &info);

  const double n = element->exponent;

  if (format >= GST_AUDIO_FORMAT_F64) {
    double *ptr, *end = data_end;
    for (ptr = data; ptr < end; ptr++)
      *ptr = pow (*ptr, n);
  } else if (format >= GST_AUDIO_FORMAT_F32) {
    float *ptr, *end = data_end;
    for (ptr = data; ptr < end; ptr++)
      *ptr = powf (*ptr, n);
  } else {
    g_assert_not_reached ();
  }

  return GST_FLOW_OK;
}


/*
 * ============================================================================
 *
 *                                Type Support
 *
 * ============================================================================
 */


enum property
{
  PROP_EXPONENT = 1,
};


static void
set_property (GObject * object, enum property id, const GValue * value,
    GParamSpec * pspec)
{
  UnaryPow *element = UNARY_LOG (object);

  GST_OBJECT_LOCK (element);

  switch (id) {
    case PROP_EXPONENT:
      element->exponent = g_value_get_double (value);
      break;
  }

  GST_OBJECT_UNLOCK (element);
}


static void
get_property (GObject * object, enum property id, GValue * value,
    GParamSpec * pspec)
{
  UnaryPow *element = UNARY_LOG (object);

  GST_OBJECT_LOCK (element);

  switch (id) {
    case PROP_EXPONENT:
      g_value_set_double (value, element->exponent);
      break;
  }
<commit_msg>Fix copy-paste error<commit_after>/*
 * Copyright (C) 2010 <NAME>
 * Copyright (C) 2016 <NAME>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */


#include <unary_base.h>

#include <math.h>

GType unary_pow_get_type (void);

#define UNARY_POW_TYPE \
	(unary_pow_get_type())
#define UNARY_POW(obj) \
	(G_TYPE_CHECK_INSTANCE_CAST((obj), UNARY_POW_TYPE, UnaryPow))


typedef struct
{
  GstAudioFilter audiofilter;
  double exponent;
} UnaryPow;



static GstFlowReturn
transform_ip (GstBaseTransform * trans, GstBuffer * buf)
{
  UnaryPow *element = UNARY_POW (trans);
  GstAudioFilter *audiofilter = GST_AUDIO_FILTER (trans);
  GstAudioFormat format = audiofilter->info.finfo->format;

  GstMapInfo info;
  gst_buffer_map (buf, &info, GST_MAP_READ);
  gpointer data = info.data;
  gpointer data_end = data + info.size;
  gst_buffer_unmap (buf, &info);

  const double n = element->exponent;

  if (format >= GST_AUDIO_FORMAT_F64) {
    double *ptr, *end = data_end;
    for (ptr = data; ptr < end; ptr++)
      *ptr = pow (*ptr, n);
  } else if (format >= GST_AUDIO_FORMAT_F32) {
    float *ptr, *end = data_end;
    for (ptr = data; ptr < end; ptr++)
      *ptr = powf (*ptr, n);
  } else {
    g_assert_not_reached ();
  }

  return GST_FLOW_OK;
}


/*
 * ============================================================================
 *
 *                                Type Support
 *
 * ============================================================================
 */


enum property
{
  PROP_EXPONENT = 1,
};


static void
set_property (GObject * object, enum property id, const GValue * value,
    GParamSpec * pspec)
{
  UnaryPow *element = UNARY_POW (object);

  GST_OBJECT_LOCK (element);

  switch (id) {
    case PROP_EXPONENT:
      element->exponent = g_value_get_double (value);
      break;
  }

  GST_OBJECT_UNLOCK (element);
}


static void
get_property (GObject * object, enum property id, GValue * value,
    GParamSpec * pspec)
{
  UnaryPow *element = UNARY_POW (object);

  GST_OBJECT_LOCK (element);

  switch (id) {
    case PROP_EXPONENT:
      g_value_set_double (value, element->exponent);
      break;
  }

{'fraction_non_alphanumeric': 0.14974121006603605, 'fraction_numerical': 0.008923790826343031, 'mean_word_length': 3.733108108108108, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3998528', 'n_tokens_mistral': 1892, 'n_tokens_neox': 1764, 'n_words': 566}