mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst/synaesthesia/gstsynaesthesia.c: Some timestamp fixes.
Original commit message from CVS: * gst/synaesthesia/gstsynaesthesia.c: (gst_synaesthesia_init), (gst_synaesthesia_sink_setcaps), (gst_synaesthesia_src_setcaps), (gst_synaesthesia_chain), (gst_synaesthesia_change_state): Some timestamp fixes. * gst/synaesthesia/synaescope.c: (synaescope_coreGo): Fix for 64-bit machines.
This commit is contained in:
parent
47e79a2050
commit
96d8fd786b
3 changed files with 55 additions and 38 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2007-04-12 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/synaesthesia/gstsynaesthesia.c: (gst_synaesthesia_init),
|
||||||
|
(gst_synaesthesia_sink_setcaps), (gst_synaesthesia_src_setcaps),
|
||||||
|
(gst_synaesthesia_chain), (gst_synaesthesia_change_state):
|
||||||
|
Some timestamp fixes.
|
||||||
|
|
||||||
|
* gst/synaesthesia/synaescope.c: (synaescope_coreGo):
|
||||||
|
Fix for 64-bit machines.
|
||||||
|
|
||||||
2007-04-12 Wim Taymans <wim@fluendo.com>
|
2007-04-12 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
Patch by: René Stadler <mail at renestadler dot de>
|
Patch by: René Stadler <mail at renestadler dot de>
|
||||||
|
|
|
@ -69,12 +69,11 @@ struct _GstSynaesthesia
|
||||||
GstPad *sinkpad, *srcpad;
|
GstPad *sinkpad, *srcpad;
|
||||||
GstAdapter *adapter;
|
GstAdapter *adapter;
|
||||||
|
|
||||||
guint64 audio_basetime; /* the timestamp of the next frame */
|
guint64 next_ts; /* the timestamp of the next frame */
|
||||||
guint64 frame_duration;
|
guint64 frame_duration;
|
||||||
guint bps; /* bytes per sample */
|
guint bps; /* bytes per sample */
|
||||||
guint spf; /* samples per video frame */
|
guint spf; /* samples per video frame */
|
||||||
|
|
||||||
guint64 samples_consumed;
|
|
||||||
gint16 datain[2][SYNAES_SAMPLES];
|
gint16 datain[2][SYNAES_SAMPLES];
|
||||||
|
|
||||||
/* video state */
|
/* video state */
|
||||||
|
@ -236,8 +235,7 @@ gst_synaesthesia_init (GstSynaesthesia * synaesthesia)
|
||||||
synaesthesia->rate = GST_AUDIO_DEF_RATE;
|
synaesthesia->rate = GST_AUDIO_DEF_RATE;
|
||||||
synaesthesia->channels = 2;
|
synaesthesia->channels = 2;
|
||||||
|
|
||||||
synaesthesia->audio_basetime = GST_CLOCK_TIME_NONE;
|
synaesthesia->next_ts = GST_CLOCK_TIME_NONE;
|
||||||
synaesthesia->samples_consumed = 0;
|
|
||||||
|
|
||||||
/* FIXME: the size is currently ignored by the engine. It should
|
/* FIXME: the size is currently ignored by the engine. It should
|
||||||
* not be, and also there should be a way to change the size later.
|
* not be, and also there should be a way to change the size later.
|
||||||
|
@ -296,7 +294,6 @@ gst_synaesthesia_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
if (rate <= 0)
|
if (rate <= 0)
|
||||||
goto wrong_rate;
|
goto wrong_rate;
|
||||||
|
|
||||||
|
|
||||||
synaesthesia->channels = channels;
|
synaesthesia->channels = channels;
|
||||||
synaesthesia->rate = rate;
|
synaesthesia->rate = rate;
|
||||||
|
|
||||||
|
@ -306,17 +303,25 @@ done:
|
||||||
|
|
||||||
/* Errors */
|
/* Errors */
|
||||||
missing_caps_details:
|
missing_caps_details:
|
||||||
GST_WARNING ("missing channels or rate in the caps");
|
{
|
||||||
res = FALSE;
|
GST_WARNING_OBJECT (synaesthesia, "missing channels or rate in the caps");
|
||||||
goto done;
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
wrong_channels:
|
wrong_channels:
|
||||||
GST_WARNING ("number of channels must be 2, but is %d", channels);
|
{
|
||||||
res = FALSE;
|
GST_WARNING_OBJECT (synaesthesia, "number of channels must be 2, but is %d",
|
||||||
goto done;
|
channels);
|
||||||
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
wrong_rate:
|
wrong_rate:
|
||||||
GST_WARNING ("sample rate must be >0, but is %d", rate);
|
{
|
||||||
res = FALSE;
|
GST_WARNING_OBJECT (synaesthesia, "sample rate must be >0, but is %d",
|
||||||
goto done;
|
rate);
|
||||||
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
|
@ -387,14 +392,19 @@ done:
|
||||||
|
|
||||||
/* Errors */
|
/* Errors */
|
||||||
missing_caps_details:
|
missing_caps_details:
|
||||||
GST_WARNING ("missing channels or rate in the caps");
|
{
|
||||||
res = FALSE;
|
GST_WARNING_OBJECT (synaesthesia, "missing channels or rate in the caps");
|
||||||
goto done;
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
wrong_resolution:
|
wrong_resolution:
|
||||||
GST_WARNING ("unsupported resolution: %d x %d (wanted %d x %d)",
|
{
|
||||||
w, h, SYNAES_WIDTH, SYNAES_HEIGHT);
|
GST_WARNING_OBJECT (synaesthesia,
|
||||||
res = FALSE;
|
"unsupported resolution: %d x %d (wanted %d x %d)", w, h, SYNAES_WIDTH,
|
||||||
goto done;
|
SYNAES_HEIGHT);
|
||||||
|
res = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -410,8 +420,7 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
|
|
||||||
/* resync on DISCONT */
|
/* resync on DISCONT */
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
|
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
|
||||||
synaesthesia->audio_basetime = GST_CLOCK_TIME_NONE;
|
synaesthesia->next_ts = GST_CLOCK_TIME_NONE;
|
||||||
synaesthesia->samples_consumed = 0;
|
|
||||||
gst_adapter_clear (synaesthesia->adapter);
|
gst_adapter_clear (synaesthesia->adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,11 +437,9 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (synaesthesia->audio_basetime == GST_CLOCK_TIME_NONE)
|
/* Match timestamps from the incoming audio */
|
||||||
synaesthesia->audio_basetime = GST_BUFFER_TIMESTAMP (buffer);
|
if (GST_BUFFER_TIMESTAMP (buffer) != GST_CLOCK_TIME_NONE)
|
||||||
|
synaesthesia->next_ts = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
if (synaesthesia->audio_basetime == GST_CLOCK_TIME_NONE)
|
|
||||||
synaesthesia->audio_basetime = 0;
|
|
||||||
|
|
||||||
gst_adapter_push (synaesthesia->adapter, buffer);
|
gst_adapter_push (synaesthesia->adapter, buffer);
|
||||||
|
|
||||||
|
@ -469,9 +476,7 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) =
|
GST_BUFFER_TIMESTAMP (outbuf) = synaesthesia->next_ts;
|
||||||
synaesthesia->audio_basetime +
|
|
||||||
(GST_SECOND * synaesthesia->samples_consumed / synaesthesia->rate);
|
|
||||||
GST_BUFFER_DURATION (outbuf) = synaesthesia->frame_duration;
|
GST_BUFFER_DURATION (outbuf) = synaesthesia->frame_duration;
|
||||||
|
|
||||||
out_frame = (guchar *)
|
out_frame = (guchar *)
|
||||||
|
@ -484,8 +489,10 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* FIXME: flush what we actually read */
|
if (synaesthesia->next_ts != GST_CLOCK_TIME_NONE)
|
||||||
synaesthesia->samples_consumed += synaesthesia->spf;
|
synaesthesia->next_ts += synaesthesia->frame_duration;
|
||||||
|
|
||||||
|
/* flush sampled for one frame */
|
||||||
gst_adapter_flush (synaesthesia->adapter, synaesthesia->spf *
|
gst_adapter_flush (synaesthesia->adapter, synaesthesia->spf *
|
||||||
synaesthesia->channels * sizeof (gint16));
|
synaesthesia->channels * sizeof (gint16));
|
||||||
|
|
||||||
|
@ -506,7 +513,7 @@ gst_synaesthesia_change_state (GstElement * element, GstStateChange transition)
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
synaesthesia->audio_basetime = GST_CLOCK_TIME_NONE;
|
synaesthesia->next_ts = GST_CLOCK_TIME_NONE;
|
||||||
gst_adapter_clear (synaesthesia->adapter);
|
gst_adapter_clear (synaesthesia->adapter);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -127,8 +127,8 @@ static void
|
||||||
synaescope_coreGo (syn_instance * si)
|
synaescope_coreGo (syn_instance * si)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
register unsigned long *ptr;
|
register guint32 *ptr;
|
||||||
register unsigned long *end;
|
register guint32 *end;
|
||||||
int heightFactor;
|
int heightFactor;
|
||||||
int actualHeight;
|
int actualHeight;
|
||||||
int heightAdd;
|
int heightAdd;
|
||||||
|
@ -160,8 +160,8 @@ synaescope_coreGo (syn_instance * si)
|
||||||
|
|
||||||
/* Asger Alstrupt's optimized 32 bit fade */
|
/* Asger Alstrupt's optimized 32 bit fade */
|
||||||
/* (alstrup@diku.dk) */
|
/* (alstrup@diku.dk) */
|
||||||
ptr = (unsigned long *) si->output;
|
ptr = (guint32 *) si->output;
|
||||||
end = (unsigned long *) (si->output + syn_width * syn_height * 2);
|
end = (guint32 *) (si->output + syn_width * syn_height * 2);
|
||||||
do {
|
do {
|
||||||
/*Bytewize version was: *(ptr++) -= *ptr+(*ptr>>1)>>4; */
|
/*Bytewize version was: *(ptr++) -= *ptr+(*ptr>>1)>>4; */
|
||||||
if (*ptr) {
|
if (*ptr) {
|
||||||
|
|
Loading…
Reference in a new issue