riff: map IPRD ("product") tag to GST_TAG_ALBUM
[platform/upstream/gstreamer.git] / ext / vorbis / gstvorbisdeclib.h
1 /* GStreamer
2  * Copyright (C) 2010 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
3  * Copyright (C) 2010 Nokia Corporation. All rights reserved.
4  *   Contact: Stefan Kost <stefan.kost@nokia.com>
5  *
6  * Tremor modifications <2006>:
7  *   Chris Lord, OpenedHand Ltd. <chris@openedhand.com>, http://www.o-hand.com/
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #ifndef __GST_VORBIS_DEC_LIB_H__
26 #define __GST_VORBIS_DEC_LIB_H__
27
28 #include <gst/gst.h>
29
30 #ifndef TREMOR
31
32 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to float audio"
33
34 #define GST_VORBIS_DEC_SRC_CAPS \
35     GST_STATIC_CAPS ("audio/x-raw-float, " \
36         "rate = (int) [ 1, MAX ], " \
37         "channels = (int) [ 1, 256 ], " \
38         "endianness = (int) BYTE_ORDER, " \
39         "width = (int) 32")
40
41 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH           (32)
42
43 #define GST_VORBIS_DEC_GLIB_TYPE_NAME      GstVorbisDec
44
45 #else /* TREMOR */
46
47 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to integer audio"
48
49 #define GST_VORBIS_DEC_SRC_CAPS \
50     GST_STATIC_CAPS ("audio/x-raw-int, "   \
51         "rate = (int) [ 1, MAX ], "        \
52         "channels = (int) [ 1, 6 ], "      \
53         "endianness = (int) BYTE_ORDER, "  \
54         "width = (int) { 16, 32 }, "       \
55         "depth = (int) 16, "               \
56         "signed = (boolean) true")
57
58 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH           (16)
59
60 /* we need a different type name here */
61 #define GST_VORBIS_DEC_GLIB_TYPE_NAME      GstIVorbisDec
62
63 /* and still have it compile */
64 typedef struct _GstVorbisDec               GstIVorbisDec;
65 typedef struct _GstVorbisDecClass          GstIVorbisDecClass;
66
67 #endif /* TREMOR */
68
69 #ifndef USE_TREMOLO
70
71 #ifdef TREMOR
72  #include <tremor/ivorbiscodec.h>
73  typedef ogg_int32_t                    vorbis_sample_t;
74 #else
75  #include <vorbis/codec.h>
76  typedef float                          vorbis_sample_t;
77 #endif
78
79 typedef ogg_packet                     ogg_packet_wrapper;
80
81 static inline guint8 *
82 gst_ogg_packet_data (ogg_packet * p)
83 {
84   return (guint8 *) p->packet;
85 }
86
87 static inline gint
88 gst_ogg_packet_size (ogg_packet * p)
89 {
90   return p->bytes;
91 }
92
93 static inline void
94 gst_ogg_packet_wrapper_from_buffer (ogg_packet * packet, GstBuffer * buffer)
95 {
96   packet->packet = GST_BUFFER_DATA (buffer);
97   packet->bytes = GST_BUFFER_SIZE (buffer);
98 }
99
100 static inline ogg_packet *
101 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
102 {
103   return packet;
104 }
105
106 #else /* USE_TREMOLO */
107
108 #include <Tremolo/ivorbiscodec.h>
109 #include <Tremolo/codec_internal.h>
110 typedef ogg_int16_t                    vorbis_sample_t;
111 typedef struct _ogg_packet_wrapper     ogg_packet_wrapper;
112
113 struct _ogg_packet_wrapper {
114   ogg_packet          packet;
115   ogg_reference       ref;
116   ogg_buffer          buf;
117 };
118
119 /* compensate minor variation */
120 #define vorbis_synthesis(a, b)             vorbis_synthesis (a, b, 1)
121
122 static inline guint8 *
123 gst_ogg_packet_data (ogg_packet * p)
124 {
125   return (guint8 *) p->packet->buffer->data;
126 }
127
128 static inline gint
129 gst_ogg_packet_size (ogg_packet * p)
130 {
131   return p->packet->buffer->size;
132 }
133
134 static inline void
135 gst_ogg_packet_wrapper_from_buffer (ogg_packet_wrapper * packet,
136     GstBuffer * buffer)
137 {
138   ogg_reference *ref = &packet->ref;
139   ogg_buffer *buf = &packet->buf;
140
141   buf->data = GST_BUFFER_DATA (buffer);
142   buf->size = GST_BUFFER_SIZE (buffer);
143   buf->refcount = 1;
144   buf->ptr.owner = NULL;
145   buf->ptr.next = NULL;
146
147   ref->buffer = buf;
148   ref->begin = 0;
149   ref->length = buf->size;
150   ref->next = NULL;
151
152   packet->packet.packet = ref;
153   packet->packet.bytes = ref->length;
154 }
155
156 static inline ogg_packet *
157 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
158 {
159   return &(packet->packet);
160 }
161
162 #endif /* USE_TREMOLO */
163
164 typedef void (*CopySampleFunc)(vorbis_sample_t *out, vorbis_sample_t **in,
165                            guint samples, gint channels, gint width);
166
167 CopySampleFunc get_copy_sample_func (gint channels, gint width);
168
169 #endif /* __GST_VORBIS_DEC_LIB_H__ */