mingw64-i686-gstreamer1.0-plugins-bad-free 1.6.4
[git/cygwin-packages/mingw64-i686-gstreamer1.0-plugins-bad-free.git] / 1.6.3-acm-port-to-gst1.patch
1 From 47d2a13d48e1b227e0566be9386a0864a27dfdfa Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= <fred.wang@free.fr>
3 Date: Thu, 12 Mar 2015 11:29:00 +0000
4 Subject: acm: Port ACM MP3 decoder and encoders to GStreamer 1.x
5
6 https://bugzilla.gnome.org/show_bug.cgi?id=744047
7
8 diff --git a/configure.ac b/configure.ac
9 index 18c4472..184e9b2 100644
10 --- a/configure.ac
11 +++ b/configure.ac
12 @@ -426,7 +426,7 @@ GST_PLUGINS_NONPORTED=" cdxaparse \
13 apexsink dc1394 \
14 gsettings \
15 musepack nas sdl timidity \
16 - acm wininet \
17 + wininet \
18 xvid lv2 teletextdec sndio libvisual"
19 AC_SUBST(GST_PLUGINS_NONPORTED)
20
21 diff --git a/sys/acmenc/acmenc.c b/sys/acmenc/acmenc.c
22 index 67f5efb..601c937 100644
23 --- a/sys/acmenc/acmenc.c
24 +++ b/sys/acmenc/acmenc.c
25 @@ -50,7 +50,7 @@ GST_DEBUG_CATEGORY_STATIC (acmenc_debug);
26
27 static GstStaticPadTemplate acmenc_sink_template =
28 GST_STATIC_PAD_TEMPLATE ("sink",
29 - GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-int, "
30 + GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw, "
31 "depth = (int)16, "
32 "width = (int)16, "
33 "endianness = (int)" G_STRINGIFY (G_BYTE_ORDER) ", "
34 @@ -106,7 +106,7 @@ static GstCaps *
35 acmenc_caps_from_format (WAVEFORMATEX * fmt)
36 {
37 return gst_riff_create_audio_caps (fmt->wFormatTag, NULL,
38 - (gst_riff_strf_auds *) fmt, NULL, NULL, NULL);
39 + (gst_riff_strf_auds *) fmt, NULL, NULL, NULL, NULL);
40 }
41
42 static gboolean
43 @@ -298,8 +298,18 @@ acmenc_push_output (ACMEnc * enc)
44 GstFlowReturn ret = GST_FLOW_OK;
45 if (enc->header.cbDstLengthUsed > 0) {
46 GstBuffer *outbuf = gst_buffer_new_and_alloc (enc->header.cbDstLengthUsed);
47 - memcpy (GST_BUFFER_DATA (outbuf), enc->header.pbDst,
48 - enc->header.cbDstLengthUsed);
49 + if (!outbuf) {
50 + GST_WARNING_OBJECT (enc, "cannot allocate a new GstBuffer");
51 + goto done_push_output;
52 + }
53 +
54 + if (gst_buffer_fill (outbuf, 0, enc->header.pbDst,
55 + enc->header.cbDstLengthUsed) != enc->header.cbDstLengthUsed) {
56 + gst_buffer_unref (outbuf);
57 + GST_WARNING_OBJECT (enc, "unable to fill output buffer");
58 + goto done_push_output;
59 + }
60 +
61 if (enc->outfmt->nAvgBytesPerSec > 0) {
62
63 /* We have a bitrate, so we can create a timestamp, hopefully */
64 @@ -312,18 +322,24 @@ acmenc_push_output (ACMEnc * enc)
65 enc->header.cbDstLengthUsed);
66 ret = gst_pad_push (enc->srcpad, outbuf);
67 }
68 +
69 +done_push_output:
70 return ret;
71 }
72
73 static GstFlowReturn
74 -acmenc_chain (GstPad * pad, GstBuffer * buf)
75 +acmenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
76 {
77 MMRESULT res;
78 ACMEnc *enc = (ACMEnc *) GST_PAD_PARENT (pad);
79 - guchar *data = GST_BUFFER_DATA (buf);
80 - gint len = GST_BUFFER_SIZE (buf);
81 + GstMapInfo map;
82 + guchar *data;
83 + gint len;
84 int chunklen;
85 GstFlowReturn ret = GST_FLOW_OK;
86 + gst_buffer_map (buf, &map, GST_MAP_READ);
87 + len = map.size;
88 + data = map.data;
89 while (len) {
90 chunklen = MIN (len, ACM_BUFFER_SIZE - enc->offset);
91 memcpy (enc->header.pbSrc + enc->offset, data, chunklen);
92 @@ -356,6 +372,7 @@ acmenc_chain (GstPad * pad, GstBuffer * buf)
93 /* Write out any data produced */
94 acmenc_push_output (enc);
95 }
96 + gst_buffer_unmap (buf, &map);
97 return ret;
98 }
99
100 @@ -381,11 +398,17 @@ acmenc_finish_stream (ACMEnc * enc)
101 }
102
103 static gboolean
104 -acmenc_sink_event (GstPad * pad, GstEvent * event)
105 +acmenc_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
106 {
107 ACMEnc *enc = (ACMEnc *) GST_PAD_PARENT (pad);
108 gboolean res;
109 switch (GST_EVENT_TYPE (event)) {
110 + case GST_EVENT_CAPS:{
111 + GstCaps *caps;
112 + gst_event_parse_caps (event, &caps);
113 + return acmenc_sink_setcaps (pad, caps);
114 + break;
115 + }
116 case GST_EVENT_EOS:
117 acmenc_finish_stream (enc);
118 res = gst_pad_push_event (enc->srcpad, event);
119 @@ -409,8 +432,6 @@ acmenc_init (ACMEnc * enc)
120 {
121 enc->sinkpad =
122 gst_pad_new_from_static_template (&acmenc_sink_template, "sink");
123 - gst_pad_set_setcaps_function (enc->sinkpad,
124 - GST_DEBUG_FUNCPTR (acmenc_sink_setcaps));
125 gst_pad_set_chain_function (enc->sinkpad, GST_DEBUG_FUNCPTR (acmenc_chain));
126 gst_pad_set_event_function (enc->sinkpad,
127 GST_DEBUG_FUNCPTR (acmenc_sink_event));
128 @@ -451,6 +472,12 @@ static void
129 acmenc_class_init (ACMEncClass * klass)
130 {
131 GObjectClass *gobjectclass = (GObjectClass *) klass;
132 + GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
133 + ACMEncParams *params;
134 + ACMDRIVERDETAILS driverdetails;
135 + gchar *shortname, *longname, *detail, *description;
136 + MMRESULT res;
137 +
138 parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
139 gobjectclass->dispose = acmenc_dispose;
140 gobjectclass->set_property = acmenc_set_property;
141 @@ -458,15 +485,6 @@ acmenc_class_init (ACMEncClass * klass)
142 g_object_class_install_property (gobjectclass, ARG_BITRATE,
143 g_param_spec_int ("bitrate", "Bitrate", "Bitrate to encode at (in bps)",
144 0, 1000000, DEFAULT_BITRATE, G_PARAM_READWRITE));
145 -} static void
146 -
147 -acmenc_base_init (ACMEncClass * klass)
148 -{
149 - GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
150 - ACMEncParams *params;
151 - ACMDRIVERDETAILS driverdetails;
152 - gchar *shortname, *longname, *detail, *description;
153 - MMRESULT res;
154
155 gst_element_class_add_pad_template (element_class,
156 gst_static_pad_template_get (&acmenc_sink_template));
157 @@ -545,7 +563,7 @@ acmenc_register_file (GstPlugin * plugin, wchar_t * filename)
158 GType type;
159 GTypeInfo typeinfo = {
160 sizeof (ACMEncClass),
161 - (GBaseInitFunc) acmenc_base_init, NULL,
162 + NULL, NULL,
163 (GClassInitFunc) acmenc_class_init, NULL, NULL, sizeof (ACMEnc),
164 0, (GInstanceInitFunc) acmenc_init,
165 };
166 diff --git a/sys/acmmp3dec/acmmp3dec.c b/sys/acmmp3dec/acmmp3dec.c
167 index 737d4a0..a0b9c36 100644
168 --- a/sys/acmmp3dec/acmmp3dec.c
169 +++ b/sys/acmmp3dec/acmmp3dec.c
170 @@ -36,6 +36,12 @@
171 (acmmp3dec_get_type())
172 #define GST_ACM_MP3_DEC(obj) \
173 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ACM_MP3_DEC,ACMMP3Dec))
174 +#define GST_ACM_MP3_DEC_CLASS(klass) \
175 + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ACM_MP3_DEC,ACMMP3DecClass))
176 +#define GST_IS_ACM_MP3_DEC(obj) \
177 + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ACM_MP3_DEC))
178 +#define GST_IS_ACM_MP3_DEC_CLASS(klass) \
179 + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ACM_MP3_DEC))
180
181 #define GST_CAT_DEFAULT acmmp3dec_debug
182 GST_DEBUG_CATEGORY_STATIC (acmmp3dec_debug);
183 @@ -44,7 +50,7 @@ static GstStaticPadTemplate acmmp3dec_src_template =
184 GST_STATIC_PAD_TEMPLATE ("src",
185 GST_PAD_SRC,
186 GST_PAD_ALWAYS,
187 - GST_STATIC_CAPS ("audio/x-raw-int, "
188 + GST_STATIC_CAPS ("audio/x-raw, "
189 "depth = (int)16, "
190 "width = (int)16, "
191 "endianness = (int)" G_STRINGIFY (G_BYTE_ORDER) ", "
192 @@ -96,13 +102,14 @@ typedef struct _ACMMP3Dec
193
194 GType acmmp3dec_get_type (void);
195
196 -GST_BOILERPLATE (ACMMP3Dec, acmmp3dec, GstElement, GST_TYPE_ELEMENT);
197 +#define acmmp3dec_parent_class parent_class
198 +G_DEFINE_TYPE (ACMMP3Dec, acmmp3dec, GST_TYPE_ELEMENT);
199
200 static GstCaps *
201 acmmp3dec_caps_from_format (WAVEFORMATEX * fmt)
202 {
203 return gst_riff_create_audio_caps (fmt->wFormatTag,
204 - NULL, (gst_riff_strf_auds *) fmt, NULL, NULL, NULL);
205 + NULL, (gst_riff_strf_auds *) fmt, NULL, NULL, NULL, NULL);
206 }
207
208 static gboolean
209 @@ -239,21 +246,28 @@ acmmp3dec_push_output (ACMMP3Dec * dec)
210
211 if (dec->header.cbDstLengthUsed > 0) {
212 GstBuffer *outbuf = gst_buffer_new_and_alloc (dec->header.cbDstLengthUsed);
213 - memcpy (GST_BUFFER_DATA (outbuf), dec->header.pbDst,
214 - dec->header.cbDstLengthUsed);
215 + if (!outbuf) {
216 + GST_WARNING_OBJECT (dec, "cannot allocate a new GstBuffer");
217 + goto done_push_output;
218 + }
219 +
220 + if (gst_buffer_fill (outbuf, 0, dec->header.pbDst,
221 + dec->header.cbDstLengthUsed) != dec->header.cbDstLengthUsed) {
222 + gst_buffer_unref (outbuf);
223 + GST_WARNING_OBJECT (dec, "unable to fill output buffer");
224 + goto done_push_output;
225 + }
226
227 if (dec->timestamp != GST_CLOCK_TIME_NONE)
228 GST_BUFFER_TIMESTAMP (outbuf) = dec->timestamp;
229 GST_BUFFER_DURATION (outbuf) =
230 - gst_util_uint64_scale_int (GST_BUFFER_SIZE (outbuf), GST_SECOND,
231 + gst_util_uint64_scale_int (dec->header.cbDstLengthUsed, GST_SECOND,
232 dec->rate * dec->channels * 2);
233
234 GST_DEBUG_OBJECT (dec, "decoded buffer has ts %d, duration %d",
235 (int) (GST_BUFFER_TIMESTAMP (outbuf)),
236 (int) (GST_BUFFER_DURATION (outbuf)));
237
238 - gst_buffer_set_caps (outbuf, dec->output_caps);
239 -
240 if (dec->timestamp != GST_CLOCK_TIME_NONE)
241 dec->timestamp += GST_BUFFER_DURATION (outbuf);
242
243 @@ -263,20 +277,21 @@ acmmp3dec_push_output (ACMMP3Dec * dec)
244 } else
245 GST_DEBUG_OBJECT (dec, "Not pushing decoded buffer, no output");
246
247 -
248 +done_push_output:
249 return ret;
250 }
251
252 static GstFlowReturn
253 -acmmp3dec_chain (GstPad * pad, GstBuffer * buf)
254 +acmmp3dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
255 {
256 MMRESULT res;
257 ACMMP3Dec *dec = (ACMMP3Dec *) GST_PAD_PARENT (pad);
258 - guchar *data = GST_BUFFER_DATA (buf);
259 - gint len = GST_BUFFER_SIZE (buf);
260 + GstMapInfo map;
261 GstFlowReturn ret = GST_FLOW_OK;
262
263 - if (len > ACM_BUFFER_SIZE) {
264 + gst_buffer_map (buf, &map, GST_MAP_READ);
265 +
266 + if (map.size > ACM_BUFFER_SIZE) {
267 GST_WARNING_OBJECT (dec, "Impossibly large mp3 frame!");
268 ret = GST_FLOW_ERROR;
269 goto done;
270 @@ -288,8 +303,8 @@ acmmp3dec_chain (GstPad * pad, GstBuffer * buf)
271 dec->timestamp = GST_BUFFER_TIMESTAMP (buf);
272 }
273
274 - memcpy (dec->header.pbSrc, data, len);
275 - dec->header.cbSrcLength = len;
276 + memcpy (dec->header.pbSrc, map.data, map.size);
277 + dec->header.cbSrcLength = map.size;
278
279 /* Now we have a buffer ready to go */
280 res = acmStreamConvert (dec->stream, &dec->header,
281 @@ -314,6 +329,7 @@ acmmp3dec_chain (GstPad * pad, GstBuffer * buf)
282 }
283
284 done:
285 + gst_buffer_unmap (buf, &map);
286 gst_buffer_unref (buf);
287
288 return ret;
289 @@ -340,11 +356,17 @@ acmmp3dec_finish_stream (ACMMP3Dec * dec)
290 }
291
292 static gboolean
293 -acmmp3dec_sink_event (GstPad * pad, GstEvent * event)
294 +acmmp3dec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
295 {
296 ACMMP3Dec *dec = (ACMMP3Dec *) GST_PAD_PARENT (pad);
297
298 switch (GST_EVENT_TYPE (event)) {
299 + case GST_EVENT_CAPS:{
300 + GstCaps *caps;
301 + gst_event_parse_caps (event, &caps);
302 + return acmmp3dec_sink_setcaps (pad, caps);
303 + break;
304 + }
305 case GST_EVENT_EOS:
306 acmmp3dec_finish_stream (dec);
307 break;
308 @@ -373,12 +395,10 @@ acmmp3dec_dispose (GObject * obj)
309 }
310
311 static void
312 -acmmp3dec_init (ACMMP3Dec * dec, ACMMP3DecClass * decclass)
313 +acmmp3dec_init (ACMMP3Dec * dec)
314 {
315 dec->sinkpad =
316 gst_pad_new_from_static_template (&acmmp3dec_sink_template, "sink");
317 - gst_pad_set_setcaps_function (dec->sinkpad,
318 - GST_DEBUG_FUNCPTR (acmmp3dec_sink_setcaps));
319 gst_pad_set_chain_function (dec->sinkpad,
320 GST_DEBUG_FUNCPTR (acmmp3dec_chain));
321 gst_pad_set_event_function (dec->sinkpad,
322 @@ -395,13 +415,8 @@ static void
323 acmmp3dec_class_init (ACMMP3DecClass * klass)
324 {
325 GObjectClass *gobjectclass = (GObjectClass *) klass;
326 - gobjectclass->dispose = acmmp3dec_dispose;
327 -}
328 -
329 -static void
330 -acmmp3dec_base_init (gpointer klass)
331 -{
332 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
333 + gobjectclass->dispose = acmmp3dec_dispose;
334
335 gst_element_class_add_pad_template (element_class,
336 gst_static_pad_template_get (&acmmp3dec_sink_template));
337 --
338 cgit v0.10.2
339
This page took 0.046803 seconds and 5 git commands to generate.