summaryrefslogtreecommitdiffstats
path: root/ext/wavpack
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2006-08-16 10:40:04 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-08-16 10:40:04 +0000
commitf349fb381066e316a38e3a068cb287ce36684a5f (patch)
tree8d454c6eccd9a3243b2d29bd66a7cc7c6b5c6d8c /ext/wavpack
parent058dec01f1356d6dbb0a2d3d053ed6558fa3504e (diff)
downloadgst-plugins-bad-f349fb381066e316a38e3a068cb287ce36684a5f.tar.gz
gst-plugins-bad-f349fb381066e316a38e3a068cb287ce36684a5f.tar.bz2
gst-plugins-bad-f349fb381066e316a38e3a068cb287ce36684a5f.zip
ext/wavpack/: In push mode, re-sync to next wavpack header if sync is lost (#351557). Also use hyphens instead of und...
Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_resync_adapter), (gst_wavpack_parse_chain): In push mode, re-sync to next wavpack header if sync is lost (#351557). Also use hyphens instead of underscores in GObject property names.
Diffstat (limited to 'ext/wavpack')
-rw-r--r--ext/wavpack/gstwavpackenc.c6
-rw-r--r--ext/wavpack/gstwavpackparse.c37
2 files changed, 38 insertions, 5 deletions
diff --git a/ext/wavpack/gstwavpackenc.c b/ext/wavpack/gstwavpackenc.c
index 60ab40a2..d5cd0191 100644
--- a/ext/wavpack/gstwavpackenc.c
+++ b/ext/wavpack/gstwavpackenc.c
@@ -238,7 +238,7 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass)
"This enables lossy encoding! A value smaller than 2.0 disables this.",
0.0, 24.0, 0.0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_CORRECTION_MODE,
- g_param_spec_enum ("correction_mode", "Correction file mode",
+ g_param_spec_enum ("correction-mode", "Correction file mode",
"Use this mode for correction file creation. Only works in lossy mode!",
GST_TYPE_WAVPACK_ENC_CORRECTION_MODE, DEFAULT_CORRECTION_MODE,
G_PARAM_READWRITE));
@@ -247,10 +247,10 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass)
"Store MD5 hash of raw samples within the file.", FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_EXTRA_PROCESSING,
- g_param_spec_boolean ("extra_processing", "Extra processing",
+ g_param_spec_boolean ("extra-processing", "Extra processing",
"Extra encode processing.", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_JOINT_STEREO_MODE,
- g_param_spec_enum ("joint_stereo_mode", "Joint-Stereo mode",
+ g_param_spec_enum ("joint-stereo-mode", "Joint-Stereo mode",
"Use this joint-stereo mode.", GST_TYPE_WAVPACK_ENC_JOINT_STEREO_MODE,
DEFAULT_JS_MODE, G_PARAM_READWRITE));
}
diff --git a/ext/wavpack/gstwavpackparse.c b/ext/wavpack/gstwavpackparse.c
index 720b25b0..20b024f3 100644
--- a/ext/wavpack/gstwavpackparse.c
+++ b/ext/wavpack/gstwavpackparse.c
@@ -935,6 +935,34 @@ pause:
}
}
+static gboolean
+gst_wavpack_parse_resync_adapter (GstAdapter * adapter)
+{
+ const guint8 *buf;
+ guint avail = gst_adapter_available (adapter);
+ gchar *marker;
+
+ if (avail < 4)
+ return FALSE;
+
+ /* if the marker is at the beginning don't do the expensive search */
+ buf = gst_adapter_peek (adapter, 4);
+ if (memcmp (buf, "wvpk", 4) == 0)
+ return TRUE;
+
+ if (avail == 4)
+ return FALSE;
+
+ /* search for the marker in the complete content of the adapter */
+ buf = gst_adapter_peek (adapter, avail);
+ if (buf && (marker = g_strstr_len ((gchar *) buf, avail, "wvpk"))) {
+ gst_adapter_flush (adapter, marker - (gchar *) buf);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static GstFlowReturn
gst_wavpack_parse_chain (GstPad * pad, GstBuffer * buf)
{
@@ -956,11 +984,12 @@ gst_wavpack_parse_chain (GstPad * pad, GstBuffer * buf)
if (gst_adapter_available (wvparse->adapter) < sizeof (WavpackHeader))
return ret;
+ if (!gst_wavpack_parse_resync_adapter (wvparse->adapter))
+ return ret;
+
tmp_buf = gst_adapter_peek (wvparse->adapter, sizeof (WavpackHeader));
gst_wavpack_read_header (&wph, (guint8 *) tmp_buf);
- /* FIXME: should check for wavpack marker here and re-sync if not */
-
while (gst_adapter_available (wvparse->adapter) >= wph.ckSize + 4 * 1 + 4) {
GstBuffer *outbuf =
gst_adapter_take_buffer (wvparse->adapter, wph.ckSize + 4 * 1 + 4);
@@ -983,6 +1012,10 @@ gst_wavpack_parse_chain (GstPad * pad, GstBuffer * buf)
if (gst_adapter_available (wvparse->adapter) >= sizeof (WavpackHeader)) {
tmp_buf = gst_adapter_peek (wvparse->adapter, sizeof (WavpackHeader));
+
+ if (!gst_wavpack_parse_resync_adapter (wvparse->adapter))
+ break;
+
gst_wavpack_read_header (&wph, (guint8 *) tmp_buf);
}
}