Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / 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 #include <vorbis/codec.h>
33
34 typedef float                          vorbis_sample_t;
35 typedef ogg_packet                     ogg_packet_wrapper;
36
37 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to float audio"
38
39 #define GST_VORBIS_DEC_SRC_CAPS \
40     GST_STATIC_CAPS ("audio/x-raw-float, " \
41         "rate = (int) [ 1, MAX ], " \
42         "channels = (int) [ 1, 256 ], " \
43         "endianness = (int) BYTE_ORDER, " \
44         "width = (int) 32")
45
46 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH           (32)
47
48 #define GST_VORBIS_DEC_GLIB_TYPE_NAME      GstVorbisDec
49
50 static inline guint8 *
51 gst_ogg_packet_data (ogg_packet * p)
52 {
53   return (guint8 *) p->packet;
54 }
55
56 static inline gint
57 gst_ogg_packet_size (ogg_packet * p)
58 {
59   return p->bytes;
60 }
61
62 static inline void
63 gst_ogg_packet_wrapper_from_buffer (ogg_packet * packet, GstBuffer * buffer)
64 {
65   packet->packet = GST_BUFFER_DATA (buffer);
66   packet->bytes = GST_BUFFER_SIZE (buffer);
67 }
68
69 static inline ogg_packet *
70 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
71 {
72   return packet;
73 }
74
75 #else
76
77 #ifdef USE_TREMOLO
78   #include <Tremolo/ivorbiscodec.h>
79   #include <Tremolo/codec_internal.h>
80   typedef ogg_int16_t                    vorbis_sample_t;
81 #else
82   #include <tremor/ivorbiscodec.h>
83   typedef ogg_int32_t                    vorbis_sample_t;
84 #endif
85
86 typedef struct _ogg_packet_wrapper     ogg_packet_wrapper;
87
88 struct _ogg_packet_wrapper {
89   ogg_packet          packet;
90   ogg_reference       ref;
91   ogg_buffer          buf;
92 };
93
94 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to integer audio"
95
96 #define GST_VORBIS_DEC_SRC_CAPS \
97     GST_STATIC_CAPS ("audio/x-raw-int, "   \
98         "rate = (int) [ 1, MAX ], "        \
99         "channels = (int) [ 1, 6 ], "      \
100         "endianness = (int) BYTE_ORDER, "  \
101         "width = (int) { 16, 32 }, "       \
102         "depth = (int) 16, "               \
103         "signed = (boolean) true")
104
105 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH           (16)
106
107 /* we need a different type name here */
108 #define GST_VORBIS_DEC_GLIB_TYPE_NAME      GstIVorbisDec
109
110 /* and still have it compile */
111 typedef struct _GstVorbisDec               GstIVorbisDec;
112 typedef struct _GstVorbisDecClass          GstIVorbisDecClass;
113
114 /* compensate minor variation */
115 #define vorbis_synthesis(a, b)             vorbis_synthesis (a, b, 1)
116
117 static inline guint8 *
118 gst_ogg_packet_data (ogg_packet * p)
119 {
120   return (guint8 *) p->packet->buffer->data;
121 }
122
123 static inline gint
124 gst_ogg_packet_size (ogg_packet * p)
125 {
126   return p->packet->buffer->size;
127 }
128
129 static inline void
130 gst_ogg_packet_wrapper_from_buffer (ogg_packet_wrapper * packet,
131     GstBuffer * buffer)
132 {
133   ogg_reference *ref = &packet->ref;
134   ogg_buffer *buf = &packet->buf;
135
136   buf->data = GST_BUFFER_DATA (buffer);
137   buf->size = GST_BUFFER_SIZE (buffer);
138   buf->refcount = 1;
139   buf->ptr.owner = NULL;
140   buf->ptr.next = NULL;
141
142   ref->buffer = buf;
143   ref->begin = 0;
144   ref->length = buf->size;
145   ref->next = NULL;
146
147   packet->packet.packet = ref;
148   packet->packet.bytes = ref->length;
149 }
150
151 static inline ogg_packet *
152 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
153 {
154   return &(packet->packet);
155 }
156
157 #endif
158
159 typedef void (*CopySampleFunc)(vorbis_sample_t *out, vorbis_sample_t **in,
160                            guint samples, gint channels, gint width);
161
162 CopySampleFunc get_copy_sample_func (gint channels, gint width);
163
164 #endif /* __GST_VORBIS_DEC_LIB_H__ */