mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
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.
This commit is contained in:
parent
577ac36e48
commit
2ea11c1c09
2 changed files with 38 additions and 5 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue