2010-02-15 11:09:53 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2010 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
|
|
|
|
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
|
|
|
|
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
|
|
|
*
|
|
|
|
* Tremor modifications <2006>:
|
|
|
|
* Chris Lord, OpenedHand Ltd. <chris@openedhand.com>, http://www.o-hand.com/
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_VORBIS_DEC_LIB_H__
|
|
|
|
#define __GST_VORBIS_DEC_LIB_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2011-08-18 17:15:03 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2010-02-15 11:09:53 +00:00
|
|
|
|
|
|
|
#ifndef TREMOR
|
|
|
|
|
2010-03-16 14:45:23 +00:00
|
|
|
#define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to float audio"
|
2010-02-15 11:09:53 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
#define GST_VORBIS_AUDIO_FORMAT GST_AUDIO_FORMAT_F32
|
2011-09-06 10:06:39 +00:00
|
|
|
#define GST_VORBIS_AUDIO_FORMAT_STR GST_AUDIO_NE (F32)
|
2011-08-18 17:15:03 +00:00
|
|
|
|
|
|
|
#define GST_VORBIS_DEC_SRC_CAPS \
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw, " \
|
|
|
|
"format = (string)" GST_VORBIS_AUDIO_FORMAT_STR ", " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, 256 ]")
|
2010-02-15 11:09:53 +00:00
|
|
|
|
|
|
|
#define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (32)
|
|
|
|
|
|
|
|
#define GST_VORBIS_DEC_GLIB_TYPE_NAME GstVorbisDec
|
|
|
|
|
2012-01-25 22:53:04 +00:00
|
|
|
#else /* TREMOR */
|
|
|
|
|
|
|
|
#define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to integer audio"
|
|
|
|
|
2012-03-22 10:35:13 +00:00
|
|
|
#define GST_VORBIS_AUDIO_FORMAT GST_AUDIO_FORMAT_S16
|
|
|
|
#define GST_VORBIS_AUDIO_FORMAT_STR GST_AUDIO_NE (S16)
|
|
|
|
|
|
|
|
#define GST_VORBIS_DEC_SRC_CAPS \
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw, " \
|
|
|
|
"format = (string) " GST_VORBIS_AUDIO_FORMAT_STR ", " \
|
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"channels = (int) [ 1, 6 ]")
|
2012-01-25 22:53:04 +00:00
|
|
|
|
|
|
|
#define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (16)
|
|
|
|
|
|
|
|
/* we need a different type name here */
|
|
|
|
#define GST_VORBIS_DEC_GLIB_TYPE_NAME GstIVorbisDec
|
|
|
|
|
|
|
|
/* and still have it compile */
|
|
|
|
typedef struct _GstVorbisDec GstIVorbisDec;
|
|
|
|
typedef struct _GstVorbisDecClass GstIVorbisDecClass;
|
|
|
|
|
|
|
|
#endif /* TREMOR */
|
|
|
|
|
|
|
|
#ifndef USE_TREMOLO
|
|
|
|
|
|
|
|
#ifdef TREMOR
|
|
|
|
#include <tremor/ivorbiscodec.h>
|
|
|
|
typedef ogg_int32_t vorbis_sample_t;
|
|
|
|
#else
|
|
|
|
#include <vorbis/codec.h>
|
|
|
|
typedef float vorbis_sample_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef ogg_packet ogg_packet_wrapper;
|
|
|
|
|
2010-02-15 11:09:53 +00:00
|
|
|
static inline guint8 *
|
|
|
|
gst_ogg_packet_data (ogg_packet * p)
|
|
|
|
{
|
|
|
|
return (guint8 *) p->packet;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gint
|
|
|
|
gst_ogg_packet_size (ogg_packet * p)
|
|
|
|
{
|
|
|
|
return p->bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_ogg_packet_wrapper_map (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
|
2010-02-15 11:09:53 +00:00
|
|
|
{
|
2011-10-08 09:05:29 +00:00
|
|
|
gst_buffer_ref (buffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (buffer, map, GST_MAP_READ);
|
|
|
|
packet->packet = map->data;
|
|
|
|
packet->bytes = map->size;
|
2011-03-28 08:20:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
|
2011-03-28 08:20:06 +00:00
|
|
|
{
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (buffer, map);
|
2011-10-08 09:05:29 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2010-02-15 11:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ogg_packet *
|
|
|
|
gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
|
|
|
|
{
|
|
|
|
return packet;
|
|
|
|
}
|
|
|
|
|
2012-01-25 22:53:04 +00:00
|
|
|
#else /* USE_TREMOLO */
|
2010-02-15 11:09:53 +00:00
|
|
|
|
2012-01-25 22:53:04 +00:00
|
|
|
#include <Tremolo/ivorbiscodec.h>
|
|
|
|
#include <Tremolo/codec_internal.h>
|
|
|
|
typedef ogg_int16_t vorbis_sample_t;
|
2010-02-15 11:09:53 +00:00
|
|
|
typedef struct _ogg_packet_wrapper ogg_packet_wrapper;
|
|
|
|
|
|
|
|
struct _ogg_packet_wrapper {
|
|
|
|
ogg_packet packet;
|
|
|
|
ogg_reference ref;
|
|
|
|
ogg_buffer buf;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* compensate minor variation */
|
|
|
|
#define vorbis_synthesis(a, b) vorbis_synthesis (a, b, 1)
|
|
|
|
|
|
|
|
static inline guint8 *
|
|
|
|
gst_ogg_packet_data (ogg_packet * p)
|
|
|
|
{
|
|
|
|
return (guint8 *) p->packet->buffer->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline gint
|
|
|
|
gst_ogg_packet_size (ogg_packet * p)
|
|
|
|
{
|
|
|
|
return p->packet->buffer->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2011-03-28 08:20:06 +00:00
|
|
|
gst_ogg_packet_wrapper_map (ogg_packet_wrapper * packet,
|
2012-02-13 14:17:09 +00:00
|
|
|
GstBuffer * buffer, GstMapInfo * map)
|
2010-02-15 11:09:53 +00:00
|
|
|
{
|
2012-02-13 14:17:09 +00:00
|
|
|
GstMapInfo info;
|
2010-02-15 11:09:53 +00:00
|
|
|
ogg_reference *ref = &packet->ref;
|
|
|
|
ogg_buffer *buf = &packet->buf;
|
2011-03-28 08:20:06 +00:00
|
|
|
gsize size;
|
2010-02-15 11:09:53 +00:00
|
|
|
|
2011-10-08 09:05:29 +00:00
|
|
|
gst_buffer_ref (buffer);
|
2012-02-13 14:17:09 +00:00
|
|
|
gst_buffer_map (buffer, map, GST_MAP_READ);
|
|
|
|
buf->data = map->data;
|
|
|
|
buf->size = map->size;
|
2010-02-15 11:09:53 +00:00
|
|
|
buf->refcount = 1;
|
|
|
|
buf->ptr.owner = NULL;
|
|
|
|
buf->ptr.next = NULL;
|
|
|
|
|
|
|
|
ref->buffer = buf;
|
|
|
|
ref->begin = 0;
|
|
|
|
ref->length = buf->size;
|
|
|
|
ref->next = NULL;
|
|
|
|
|
|
|
|
packet->packet.packet = ref;
|
|
|
|
packet->packet.bytes = ref->length;
|
|
|
|
}
|
|
|
|
|
2011-03-28 08:20:06 +00:00
|
|
|
static inline void
|
|
|
|
gst_ogg_packet_wrapper_unmap (ogg_packet_wrapper * packet,
|
2012-02-13 14:17:09 +00:00
|
|
|
GstBuffer * buffer, GstMapInfo * map)
|
2011-03-28 08:20:06 +00:00
|
|
|
{
|
|
|
|
ogg_reference *ref = &packet->ref;
|
|
|
|
ogg_buffer *buf = &packet->buf;
|
|
|
|
|
2012-02-13 14:17:09 +00:00
|
|
|
gst_buffer_unmap (buffer, map);
|
2011-10-08 09:05:29 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2011-03-28 08:20:06 +00:00
|
|
|
}
|
|
|
|
|
2010-02-15 11:09:53 +00:00
|
|
|
static inline ogg_packet *
|
|
|
|
gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
|
|
|
|
{
|
|
|
|
return &(packet->packet);
|
|
|
|
}
|
|
|
|
|
2012-01-25 22:53:04 +00:00
|
|
|
#endif /* USE_TREMOLO */
|
2010-02-15 11:09:53 +00:00
|
|
|
|
2010-05-06 05:20:10 +00:00
|
|
|
typedef void (*CopySampleFunc)(vorbis_sample_t *out, vorbis_sample_t **in,
|
2011-08-18 17:15:03 +00:00
|
|
|
guint samples, gint channels);
|
2010-02-15 11:09:53 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
CopySampleFunc get_copy_sample_func (gint channels);
|
2010-02-15 11:09:53 +00:00
|
|
|
|
|
|
|
#endif /* __GST_VORBIS_DEC_LIB_H__ */
|