Blame ext/vorbis/gstvorbisdeclib.h

Packit 971217
/* GStreamer
Packit 971217
 * Copyright (C) 2010 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Packit 971217
 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
Packit 971217
 *   Contact: Stefan Kost <stefan.kost@nokia.com>
Packit 971217
 *
Packit 971217
 * Tremor modifications <2006>:
Packit 971217
 *   Chris Lord, OpenedHand Ltd. <chris@openedhand.com>, http://www.o-hand.com/
Packit 971217
 *
Packit 971217
 * This library is free software; you can redistribute it and/or
Packit 971217
 * modify it under the terms of the GNU Library General Public
Packit 971217
 * License as published by the Free Software Foundation; either
Packit 971217
 * version 2 of the License, or (at your option) any later version.
Packit 971217
 *
Packit 971217
 * This library is distributed in the hope that it will be useful,
Packit 971217
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 971217
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 971217
 * Library General Public License for more details.
Packit 971217
 *
Packit 971217
 * You should have received a copy of the GNU Library General Public
Packit 971217
 * License along with this library; if not, write to the
Packit 971217
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit 971217
 * Boston, MA 02110-1301, USA.
Packit 971217
 */
Packit 971217
Packit 971217
#ifndef __GST_VORBIS_DEC_LIB_H__
Packit 971217
#define __GST_VORBIS_DEC_LIB_H__
Packit 971217
Packit 971217
#include <gst/gst.h>
Packit 971217
#include <gst/audio/audio.h>
Packit 971217
Packit 971217
#ifndef TREMOR
Packit 971217
Packit 971217
#define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to float audio"
Packit 971217
Packit 971217
#define GST_VORBIS_AUDIO_FORMAT     GST_AUDIO_FORMAT_F32
Packit 971217
#define GST_VORBIS_AUDIO_FORMAT_STR GST_AUDIO_NE (F32)
Packit 971217
Packit 971217
#define GST_VORBIS_DEC_SRC_CAPS       \
Packit 971217
    GST_STATIC_CAPS ("audio/x-raw, "  \
Packit 971217
        "format = (string)" GST_VORBIS_AUDIO_FORMAT_STR ", "     \
Packit 971217
        "rate = (int) [ 1, MAX ], "   \
Packit 971217
        "channels = (int) [ 1, 256 ]")
Packit 971217
Packit 971217
#define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH           (32)
Packit 971217
Packit 971217
#else /* TREMOR */
Packit 971217
Packit 971217
#define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to integer audio"
Packit 971217
Packit 971217
#define GST_VORBIS_AUDIO_FORMAT GST_AUDIO_FORMAT_S16
Packit 971217
#define GST_VORBIS_AUDIO_FORMAT_STR GST_AUDIO_NE (S16)
Packit 971217
Packit 971217
#define GST_VORBIS_DEC_SRC_CAPS        \
Packit 971217
    GST_STATIC_CAPS ("audio/x-raw, "   \
Packit 971217
        "format = (string) " GST_VORBIS_AUDIO_FORMAT_STR ", "      \
Packit 971217
        "rate = (int) [ 1, MAX ], "    \
Packit 971217
        "channels = (int) [ 1, 6 ]")
Packit 971217
Packit 971217
#define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH           (16)
Packit 971217
Packit 971217
/* we need a different type name here */
Packit 971217
#define GstVorbisDec GstIVorbisDec
Packit 971217
#define GstVorbisDecClass GstIVorbisDecClass
Packit 971217
#define gst_vorbis_dec_get_type gst_ivorbis_dec_get_type
Packit 971217
#define gst_vorbis_get_copy_sample_func gst_ivorbis_get_copy_sample_func
Packit 971217
Packit 971217
#endif /* TREMOR */
Packit 971217
Packit 971217
#ifndef USE_TREMOLO
Packit 971217
Packit 971217
#ifdef TREMOR
Packit 971217
 #include <tremor/ivorbiscodec.h>
Packit 971217
 typedef ogg_int32_t                    vorbis_sample_t;
Packit 971217
#else
Packit 971217
 #include <vorbis/codec.h>
Packit 971217
 typedef float                          vorbis_sample_t;
Packit 971217
#endif
Packit 971217
Packit 971217
typedef ogg_packet                     ogg_packet_wrapper;
Packit 971217
Packit 971217
static inline guint8 *
Packit 971217
gst_ogg_packet_data (ogg_packet * p)
Packit 971217
{
Packit 971217
  return (guint8 *) p->packet;
Packit 971217
}
Packit 971217
Packit 971217
static inline gint
Packit 971217
gst_ogg_packet_size (ogg_packet * p)
Packit 971217
{
Packit 971217
  return p->bytes;
Packit 971217
}
Packit 971217
Packit 971217
static inline void
Packit 971217
gst_ogg_packet_wrapper_map (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
Packit 971217
{
Packit 971217
  gst_buffer_ref (buffer);
Packit 971217
  gst_buffer_map (buffer, map, GST_MAP_READ);
Packit 971217
  packet->packet = map->data;
Packit 971217
  packet->bytes = map->size;
Packit 971217
}
Packit 971217
Packit 971217
static inline void
Packit 971217
gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
Packit 971217
{
Packit 971217
  gst_buffer_unmap (buffer, map);
Packit 971217
  gst_buffer_unref (buffer);
Packit 971217
}
Packit 971217
Packit 971217
static inline ogg_packet *
Packit 971217
gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
Packit 971217
{
Packit 971217
  return packet;
Packit 971217
}
Packit 971217
Packit 971217
#else /* USE_TREMOLO */
Packit 971217
Packit 971217
#include <Tremolo/ivorbiscodec.h>
Packit 971217
#include <Tremolo/codec_internal.h>
Packit 971217
typedef ogg_int16_t                    vorbis_sample_t;
Packit 971217
typedef struct _ogg_packet_wrapper     ogg_packet_wrapper;
Packit 971217
Packit 971217
struct _ogg_packet_wrapper {
Packit 971217
  ogg_packet          packet;
Packit 971217
  ogg_reference       ref;
Packit 971217
  ogg_buffer          buf;
Packit 971217
};
Packit 971217
Packit 971217
/* compensate minor variation */
Packit 971217
#define vorbis_synthesis(a, b)             vorbis_synthesis (a, b, 1)
Packit 971217
Packit 971217
static inline guint8 *
Packit 971217
gst_ogg_packet_data (ogg_packet * p)
Packit 971217
{
Packit 971217
  return (guint8 *) p->packet->buffer->data;
Packit 971217
}
Packit 971217
Packit 971217
static inline gint
Packit 971217
gst_ogg_packet_size (ogg_packet * p)
Packit 971217
{
Packit 971217
  return p->packet->buffer->size;
Packit 971217
}
Packit 971217
Packit 971217
static inline void
Packit 971217
gst_ogg_packet_wrapper_map (ogg_packet_wrapper * packet,
Packit 971217
    GstBuffer * buffer, GstMapInfo * map)
Packit 971217
{
Packit 971217
  GstMapInfo info;
Packit 971217
  ogg_reference *ref = &packet->ref;
Packit 971217
  ogg_buffer *buf = &packet->buf;
Packit 971217
  gsize size;
Packit 971217
Packit 971217
  gst_buffer_ref (buffer);
Packit 971217
  gst_buffer_map (buffer, map, GST_MAP_READ);
Packit 971217
  buf->data = map->data;
Packit 971217
  buf->size = map->size;
Packit 971217
  buf->refcount = 1;
Packit 971217
  buf->ptr.owner = NULL;
Packit 971217
  buf->ptr.next = NULL;
Packit 971217
Packit 971217
  ref->buffer = buf;
Packit 971217
  ref->begin = 0;
Packit 971217
  ref->length = buf->size;
Packit 971217
  ref->next = NULL;
Packit 971217
Packit 971217
  packet->packet.packet = ref;
Packit 971217
  packet->packet.bytes = ref->length;
Packit 971217
}
Packit 971217
Packit 971217
static inline void
Packit 971217
gst_ogg_packet_wrapper_unmap (ogg_packet_wrapper * packet,
Packit 971217
    GstBuffer * buffer, GstMapInfo * map)
Packit 971217
{
Packit 971217
  ogg_reference *ref = &packet->ref;
Packit 971217
  ogg_buffer *buf = &packet->buf;
Packit 971217
Packit 971217
  gst_buffer_unmap (buffer, map);
Packit 971217
  gst_buffer_unref (buffer);
Packit 971217
}
Packit 971217
Packit 971217
static inline ogg_packet *
Packit 971217
gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
Packit 971217
{
Packit 971217
  return &(packet->packet);
Packit 971217
}
Packit 971217
Packit 971217
#endif /* USE_TREMOLO */
Packit 971217
Packit 971217
typedef void (*CopySampleFunc)(vorbis_sample_t *out, vorbis_sample_t **in,
Packit 971217
                           guint samples, gint channels);
Packit 971217
Packit 971217
CopySampleFunc gst_vorbis_get_copy_sample_func (gint channels);
Packit 971217
Packit 971217
#endif /* __GST_VORBIS_DEC_LIB_H__ */