UNITS -> DEFAULT

Original commit message from CVS:
UNITS -> DEFAULT
This commit is contained in:
Wim Taymans 2003-05-24 10:41:21 +00:00
parent ada49e5acc
commit 9dc595c9b9
3 changed files with 35 additions and 41 deletions

View file

@ -436,14 +436,14 @@ gst_flacdec_write (const FLAC__SeekableStreamDecoder *decoder,
GST_DEBUG (0, "send discont"); GST_DEBUG (0, "send discont");
format = GST_FORMAT_TIME; format = GST_FORMAT_TIME;
gst_pad_convert (flacdec->srcpad, GST_FORMAT_UNITS, flacdec->total_samples, gst_pad_convert (flacdec->srcpad, GST_FORMAT_DEFAULT, flacdec->total_samples,
&format, &time); &format, &time);
format = GST_FORMAT_BYTES; format = GST_FORMAT_BYTES;
gst_pad_convert (flacdec->srcpad, GST_FORMAT_UNITS, flacdec->total_samples, gst_pad_convert (flacdec->srcpad, GST_FORMAT_DEFAULT, flacdec->total_samples,
&format, &bytes); &format, &bytes);
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time, discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
GST_FORMAT_BYTES, bytes, GST_FORMAT_BYTES, bytes,
GST_FORMAT_UNITS, flacdec->total_samples, GST_FORMAT_DEFAULT, flacdec->total_samples,
NULL); NULL);
gst_pad_push (flacdec->srcpad, GST_BUFFER (discont)); gst_pad_push (flacdec->srcpad, GST_BUFFER (discont));
@ -552,11 +552,11 @@ gst_flacdec_loop (GstElement *element)
gst_pad_push (flacdec->srcpad, GST_BUFFER (event)); gst_pad_push (flacdec->srcpad, GST_BUFFER (event));
gst_element_set_eos (element); gst_element_set_eos (element);
} }
GST_DEBUG (GST_CAT_PLUGIN_INFO, "flacdec: _loop end"); GST_DEBUG (GST_CAT_PLUGIN_INFO, "flacdec: _loop end");
} }
GST_PAD_FORMATS_FUNCTION (gst_flacdec_get_src_formats, GST_PAD_FORMATS_FUNCTION (gst_flacdec_get_src_formats,
GST_FORMAT_UNITS, GST_FORMAT_DEFAULT,
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
GST_FORMAT_TIME GST_FORMAT_TIME
) )
@ -575,13 +575,11 @@ gst_flacdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
switch (src_format) { switch (src_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_UNITS: case GST_FORMAT_DEFAULT:
if (bytes_per_sample == 0) if (bytes_per_sample == 0)
return FALSE; return FALSE;
*dest_value = src_value / bytes_per_sample; *dest_value = src_value / bytes_per_sample;
break; break;
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
{ {
gint byterate = bytes_per_sample * flacdec->frequency; gint byterate = bytes_per_sample * flacdec->frequency;
@ -595,13 +593,11 @@ gst_flacdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
res = FALSE; res = FALSE;
} }
break; break;
case GST_FORMAT_UNITS: case GST_FORMAT_DEFAULT:
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample; *dest_value = src_value * bytes_per_sample;
break; break;
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
if (flacdec->frequency == 0) if (flacdec->frequency == 0)
return FALSE; return FALSE;
@ -613,11 +609,9 @@ gst_flacdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
break; break;
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_BYTES;
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
scale = bytes_per_sample; scale = bytes_per_sample;
case GST_FORMAT_UNITS: case GST_FORMAT_DEFAULT:
*dest_value = src_value * scale * flacdec->frequency / GST_SECOND; *dest_value = src_value * scale * flacdec->frequency / GST_SECOND;
break; break;
default: default:
@ -653,14 +647,14 @@ gst_flacdec_src_query (GstPad *pad, GstQueryType type,
samples = flacdec->stream_samples; samples = flacdec->stream_samples;
gst_pad_convert (flacdec->srcpad, gst_pad_convert (flacdec->srcpad,
GST_FORMAT_UNITS, GST_FORMAT_DEFAULT,
samples, samples,
format, value); format, value);
break; break;
} }
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
gst_pad_convert (flacdec->srcpad, gst_pad_convert (flacdec->srcpad,
GST_FORMAT_UNITS, GST_FORMAT_DEFAULT,
flacdec->total_samples, flacdec->total_samples,
format, value); format, value);
break; break;
@ -685,7 +679,7 @@ gst_flacdec_src_event (GstPad *pad, GstEvent *event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
format = GST_FORMAT_UNITS; format = GST_FORMAT_DEFAULT;
if (gst_pad_convert (flacdec->srcpad, if (gst_pad_convert (flacdec->srcpad,
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_FORMAT (event),
@ -716,6 +710,7 @@ gst_flacdec_change_state (GstElement *element)
flacdec->total_samples = 0; flacdec->total_samples = 0;
flacdec->init = TRUE; flacdec->init = TRUE;
flacdec->eos = FALSE; flacdec->eos = FALSE;
FLAC__seekable_stream_decoder_reset (flacdec->decoder);
break; break;
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
flacdec->eos = FALSE; flacdec->eos = FALSE;

View file

@ -1048,7 +1048,7 @@ gst_avi_demux_parse_index (GstAviDemux *avi_demux,
} }
/* VBR stream */ /* VBR stream */
else { else {
gst_pad_convert (stream->pad, GST_FORMAT_UNITS, stream->total_frames, gst_pad_convert (stream->pad, GST_FORMAT_DEFAULT, stream->total_frames,
&format, &target->ts); &format, &target->ts);
} }
gst_avi_debug_entry ("index", target); gst_avi_debug_entry ("index", target);
@ -1122,12 +1122,12 @@ gst_avi_demux_get_src_formats (GstPad *pad)
static const GstFormat src_a_formats[] = { static const GstFormat src_a_formats[] = {
GST_FORMAT_TIME, GST_FORMAT_TIME,
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
GST_FORMAT_UNITS, GST_FORMAT_DEFAULT,
0 0
}; };
static const GstFormat src_v_formats[] = { static const GstFormat src_v_formats[] = {
GST_FORMAT_TIME, GST_FORMAT_TIME,
GST_FORMAT_UNITS, GST_FORMAT_DEFAULT,
0 0
}; };
@ -1152,8 +1152,6 @@ gst_avi_demux_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value,
*dest_value = src_value * stream->strh.rate / (stream->strh.scale * GST_SECOND); *dest_value = src_value * stream->strh.rate / (stream->strh.scale * GST_SECOND);
break; break;
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_UNITS;
case GST_FORMAT_UNITS:
*dest_value = src_value * stream->strh.rate / (stream->strh.scale * GST_SECOND); *dest_value = src_value * stream->strh.rate / (stream->strh.scale * GST_SECOND);
break; break;
default: default:
@ -1162,7 +1160,16 @@ gst_avi_demux_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value,
} }
break; break;
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
case GST_FORMAT_UNITS: switch (*dest_format) {
case GST_FORMAT_TIME:
*dest_value = ((gfloat)src_value) * GST_SECOND / stream->strh.rate;
break;
default:
res = FALSE;
break;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
*dest_value = ((((gfloat)src_value) * stream->strh.scale) / stream->strh.rate) * GST_SECOND; *dest_value = ((((gfloat)src_value) * stream->strh.scale) / stream->strh.rate) * GST_SECOND;
@ -1202,9 +1209,6 @@ gst_avi_demux_handle_src_query (GstPad *pad, GstQueryType type,
switch (type) { switch (type) {
case GST_QUERY_TOTAL: case GST_QUERY_TOTAL:
switch (*format) { switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fall through */
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
*value = (((gfloat)stream->strh.scale) * stream->strh.length / stream->strh.rate) * GST_SECOND; *value = (((gfloat)stream->strh.scale) * stream->strh.length / stream->strh.rate) * GST_SECOND;
break; break;
@ -1215,7 +1219,7 @@ gst_avi_demux_handle_src_query (GstPad *pad, GstQueryType type,
else else
res = FALSE; res = FALSE;
break; break;
case GST_FORMAT_UNITS: case GST_FORMAT_DEFAULT:
if (stream->strh.type == GST_RIFF_FCC_auds) if (stream->strh.type == GST_RIFF_FCC_auds)
*value = stream->strh.length * stream->strh.samplesize; *value = stream->strh.length * stream->strh.samplesize;
else if (stream->strh.type == GST_RIFF_FCC_vids) else if (stream->strh.type == GST_RIFF_FCC_vids)
@ -1230,12 +1234,10 @@ gst_avi_demux_handle_src_query (GstPad *pad, GstQueryType type,
break; break;
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
switch (*format) { switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fall through */
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
if (stream->strh.samplesize && stream->strh.type == GST_RIFF_FCC_auds) { if (stream->strh.samplesize && stream->strh.type == GST_RIFF_FCC_auds) {
*value = (((gfloat)stream->current_byte) * stream->strh.scale / stream->strh.rate) * GST_SECOND; //*value = (((gfloat)stream->current_byte) * stream->strh.scale / stream->strh.rate) * GST_SECOND;
*value = ((gfloat)stream->current_byte) * GST_SECOND / stream->strh.rate;
} }
else { else {
*value = (((gfloat)stream->current_frame) * stream->strh.scale / stream->strh.rate) * GST_SECOND; *value = (((gfloat)stream->current_frame) * stream->strh.scale / stream->strh.rate) * GST_SECOND;
@ -1244,7 +1246,7 @@ gst_avi_demux_handle_src_query (GstPad *pad, GstQueryType type,
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
*value = stream->current_byte; *value = stream->current_byte;
break; break;
case GST_FORMAT_UNITS: case GST_FORMAT_DEFAULT:
if (stream->strh.samplesize && stream->strh.type == GST_RIFF_FCC_auds) if (stream->strh.samplesize && stream->strh.type == GST_RIFF_FCC_auds)
*value = stream->current_byte * stream->strh.samplesize; *value = stream->current_byte * stream->strh.samplesize;
else else
@ -1363,7 +1365,7 @@ gst_avi_demux_handle_src_event (GstPad *pad, GstEvent *event)
GST_DEBUG (0, "seek format %d, %08x", GST_EVENT_SEEK_FORMAT (event), stream->strh.type); GST_DEBUG (0, "seek format %d, %08x", GST_EVENT_SEEK_FORMAT (event), stream->strh.type);
switch (GST_EVENT_SEEK_FORMAT (event)) { switch (GST_EVENT_SEEK_FORMAT (event)) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
case GST_FORMAT_UNITS: case GST_FORMAT_DEFAULT:
break; break;
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
{ {
@ -1646,7 +1648,7 @@ gst_avi_demux_loop (GstElement *element)
format = GST_FORMAT_TIME; format = GST_FORMAT_TIME;
gst_pad_query (stream->pad, GST_QUERY_POSITION, &format, &next_ts); gst_pad_query (stream->pad, GST_QUERY_POSITION, &format, &next_ts);
if (stream->strh.init_frames == stream->current_frame && stream->delay==0) if (stream->strh.init_frames == stream->current_frame && stream->delay == 0)
stream->delay = next_ts; stream->delay = next_ts;
stream->current_frame++; stream->current_frame++;

View file

@ -486,7 +486,7 @@ gst_wavparse_get_formats (GstPad *pad)
static GstFormat formats[] = { static GstFormat formats[] = {
GST_FORMAT_TIME, GST_FORMAT_TIME,
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
GST_FORMAT_UNITS, /* a "frame", ie a set of samples per Hz */ GST_FORMAT_DEFAULT, /* a "frame", ie a set of samples per Hz */
0, 0,
0 0
}; };
@ -503,9 +503,6 @@ gst_wavparse_pad_convert (GstPad *pad,
GstWavParse *wavparse; GstWavParse *wavparse;
wavparse = GST_WAVPARSE (gst_pad_get_parent (pad)); wavparse = GST_WAVPARSE (gst_pad_get_parent (pad));
/* FIXME default should be samples in this case IMO */
if (*dest_format == GST_FORMAT_DEFAULT)
*dest_format = GST_FORMAT_TIME;
bytes_per_sample = wavparse->channels * wavparse->width / 8; bytes_per_sample = wavparse->channels * wavparse->width / 8;
if (bytes_per_sample == 0) { if (bytes_per_sample == 0) {
@ -522,14 +519,14 @@ gst_wavparse_pad_convert (GstPad *pad,
switch (src_format) { switch (src_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
if (*dest_format == GST_FORMAT_UNITS) if (*dest_format == GST_FORMAT_DEFAULT)
*dest_value = src_value / bytes_per_sample; *dest_value = src_value / bytes_per_sample;
else if (*dest_format == GST_FORMAT_TIME) else if (*dest_format == GST_FORMAT_TIME)
*dest_value = src_value * GST_SECOND / byterate; *dest_value = src_value * GST_SECOND / byterate;
else else
return FALSE; return FALSE;
break; break;
case GST_FORMAT_UNITS: case GST_FORMAT_DEFAULT:
if (*dest_format == GST_FORMAT_BYTES) if (*dest_format == GST_FORMAT_BYTES)
*dest_value = src_value * bytes_per_sample; *dest_value = src_value * bytes_per_sample;
else if (*dest_format == GST_FORMAT_TIME) else if (*dest_format == GST_FORMAT_TIME)
@ -540,7 +537,7 @@ gst_wavparse_pad_convert (GstPad *pad,
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
if (*dest_format == GST_FORMAT_BYTES) if (*dest_format == GST_FORMAT_BYTES)
*dest_value = src_value * byterate / GST_SECOND; *dest_value = src_value * byterate / GST_SECOND;
else if (*dest_format == GST_FORMAT_UNITS) else if (*dest_format == GST_FORMAT_DEFAULT)
*dest_value = src_value * wavparse->rate / GST_SECOND; *dest_value = src_value * wavparse->rate / GST_SECOND;
else else
return FALSE; return FALSE;