diff options
Diffstat (limited to 'ext/wavpack')
-rw-r--r-- | ext/wavpack/gstwavpackenc.c | 6 | ||||
-rw-r--r-- | ext/wavpack/gstwavpackparse.c | 37 |
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); } } |