ext/dv/gstdvdec.c: Fix format conversion and position querying.

Original commit message from CVS:
* ext/dv/gstdvdec.c: (gst_dvdec_init), (gst_dvdec_get_formats),
(gst_dvdec_src_convert), (gst_dvdec_sink_convert):
Fix format conversion and position querying.
* gst/debug/progressreport.c: (gst_progressreport_report):
Don't output a bogus total value that we didn't query.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_xv_support):
Always set XV_AUTOPAINT_COLORKEY to true. Fixes xvimagesink showing
only a blank window after xine has been used.
This commit is contained in:
Jan Schmidt 2004-05-21 13:28:24 +00:00
parent dcc87f1efd
commit 4d97abb272
3 changed files with 50 additions and 14 deletions

View file

@ -1,3 +1,14 @@
2004-05-21 Jan Schmidt <thaytan@mad.scientist.com>
* ext/dv/gstdvdec.c: (gst_dvdec_init), (gst_dvdec_get_formats),
(gst_dvdec_src_convert), (gst_dvdec_sink_convert):
Fix format conversion and position querying.
* gst/debug/progressreport.c: (gst_progressreport_report):
Don't output a bogus total value that we didn't query.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_xv_support):
Always set XV_AUTOPAINT_COLORKEY to true. Fixes xvimagesink showing
only a blank window after xine has been used.
2004-05-21 Thomas Vander Stichele <thomas (at) apestaart (dot) org> 2004-05-21 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* m4/as-arts.m4: * m4/as-arts.m4:

View file

@ -308,12 +308,12 @@ gst_dvdec_init (GstDVDec * dvdec)
dvdec->sinkpad = dvdec->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get (&sink_temp), gst_pad_new_from_template (gst_static_pad_template_get (&sink_temp),
"sink"); "sink");
gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->sinkpad);
gst_pad_set_query_function (dvdec->sinkpad, NULL); gst_pad_set_query_function (dvdec->sinkpad, NULL);
gst_pad_set_convert_function (dvdec->sinkpad, gst_pad_set_convert_function (dvdec->sinkpad,
GST_DEBUG_FUNCPTR (gst_dvdec_sink_convert)); GST_DEBUG_FUNCPTR (gst_dvdec_sink_convert));
gst_pad_set_formats_function (dvdec->sinkpad, gst_pad_set_formats_function (dvdec->sinkpad,
GST_DEBUG_FUNCPTR (gst_dvdec_get_formats)); GST_DEBUG_FUNCPTR (gst_dvdec_get_formats));
gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->sinkpad);
dvdec->videosrcpad = dvdec->videosrcpad =
gst_pad_new_from_template (gst_static_pad_template_get (&video_src_temp), gst_pad_new_from_template (gst_static_pad_template_get (&video_src_temp),
@ -388,6 +388,7 @@ gst_dvdec_get_formats (GstPad * pad)
static const GstFormat sink_formats[] = { static const GstFormat sink_formats[] = {
GST_FORMAT_BYTES, GST_FORMAT_BYTES,
GST_FORMAT_TIME, GST_FORMAT_TIME,
GST_FORMAT_DEFAULT,
0 0
}; };
@ -400,7 +401,6 @@ gst_dvdec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
{ {
gboolean res = TRUE; gboolean res = TRUE;
GstDVDec *dvdec; GstDVDec *dvdec;
gint scale = 1;
dvdec = GST_DVDEC (gst_pad_get_parent (pad)); dvdec = GST_DVDEC (gst_pad_get_parent (pad));
@ -413,7 +413,21 @@ gst_dvdec_src_convert (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_BYTES:
*dest_value = src_value;
break;
case GST_FORMAT_DEFAULT:
case GST_FORMAT_TIME: case GST_FORMAT_TIME:
*dest_format = GST_FORMAT_TIME;
if (pad == dvdec->videosrcpad)
*dest_value = src_value * GST_SECOND /
(720 * dvdec->height * dvdec->bpp * dvdec->framerate /
GST_SECOND);
else if (pad == dvdec->audiosrcpad)
*dest_value = src_value * GST_SECOND /
(2 * dvdec->decoder->audio->frequency *
dvdec->decoder->audio->num_channels);
break;
default: default:
res = FALSE; res = FALSE;
} }
@ -422,18 +436,16 @@ gst_dvdec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
switch (*dest_format) { switch (*dest_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
if (pad == dvdec->videosrcpad) if (pad == dvdec->videosrcpad)
scale = 720 * dvdec->height * dvdec->bpp; *dest_value = src_value * 720 * dvdec->height * dvdec->bpp *
dvdec->framerate / GST_SECOND;
else if (pad == dvdec->audiosrcpad) else if (pad == dvdec->audiosrcpad)
scale = dvdec->decoder->audio->num_channels * 2; *dest_value = 2 * src_value * dvdec->decoder->audio->frequency *
/* fallthrough */ dvdec->decoder->audio->num_channels / GST_SECOND;
break;
case GST_FORMAT_TIME:
case GST_FORMAT_DEFAULT: case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME; *dest_format = GST_FORMAT_TIME;
if (pad == dvdec->videosrcpad) *dest_value = src_value;
*dest_value = src_value * dvdec->framerate * scale / GST_SECOND;
else if (pad == dvdec->audiosrcpad)
*dest_value =
src_value * dvdec->decoder->audio->frequency * scale /
GST_SECOND;
break; break;
default: default:
res = FALSE; res = FALSE;
@ -457,6 +469,9 @@ gst_dvdec_sink_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
if (dvdec->length == 0) if (dvdec->length == 0)
return FALSE; return FALSE;
if (*dest_format == GST_FORMAT_DEFAULT)
*dest_format = GST_FORMAT_TIME;
switch (src_format) { switch (src_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
switch (*dest_format) { switch (*dest_format) {
@ -470,6 +485,9 @@ gst_dvdec_sink_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
*dest_value = (frame * GST_SECOND) / dvdec->framerate; *dest_value = (frame * GST_SECOND) / dvdec->framerate;
break; break;
} }
case GST_FORMAT_BYTES:
*dest_value = src_value;
break;
default: default:
res = FALSE; res = FALSE;
} }
@ -486,6 +504,9 @@ gst_dvdec_sink_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
*dest_value = frame * dvdec->length; *dest_value = frame * dvdec->length;
break; break;
} }
case GST_FORMAT_TIME:
*dest_value = src_value;
break;
default: default:
res = FALSE; res = FALSE;
} }

View file

@ -172,6 +172,12 @@ gst_progressreport_report (GstProgressReport * progressreport,
GST_QUERY_POSITION, &peer_format, &cur_progress)) { GST_QUERY_POSITION, &peer_format, &cur_progress)) {
GstFormat peer_format2 = peer_format; GstFormat peer_format2 = peer_format;
gchar *format_name = NULL; gchar *format_name = NULL;
gboolean got_total = FALSE;
if ((gst_pad_query (gst_pad_get_peer (progressreport->sinkpad),
GST_QUERY_TOTAL, &peer_format2, &total_progress)) &&
(peer_format == peer_format2))
got_total = TRUE;
switch (peer_format) { switch (peer_format) {
case GST_FORMAT_BYTES: case GST_FORMAT_BYTES:
@ -193,9 +199,7 @@ gst_progressreport_report (GstProgressReport * progressreport,
break; break;
} }
if ((gst_pad_query (gst_pad_get_peer (progressreport->sinkpad), if (got_total == TRUE) {
GST_QUERY_TOTAL, &peer_format2, &total_progress)) &&
(peer_format == peer_format2)) {
g_print ("%s (%2d:%2d:%2d): %lld / %lld %s (%3.2g %%)\n", g_print ("%s (%2d:%2d:%2d): %lld / %lld %s (%3.2g %%)\n",
gst_object_get_name (GST_OBJECT (progressreport)), hh, mm, ss, gst_object_get_name (GST_OBJECT (progressreport)), hh, mm, ss,
cur_progress, total_progress, format_name, cur_progress, total_progress, format_name,