+ the last of the float caps changes ... these are a bit more pervasive

Original commit message from CVS:
+ the last of the float caps changes ... these are a bit more pervasive
This commit is contained in:
Leif Johnson 2003-07-19 23:47:42 +00:00
parent 8c0b28395b
commit abe6f76b9f
7 changed files with 98 additions and 123 deletions

View file

@ -22,77 +22,96 @@
#include <gst/audio/audioclock.h> #include <gst/audio/audioclock.h>
G_BEGIN_DECLS
/* For people that are looking at this source: the purpose of these defines is /* For people that are looking at this source: the purpose of these defines is
* to make GstCaps a bit easier, in that you don't have to know all of the * to make GstCaps a bit easier, in that you don't have to know all of the
* properties that need to be defined. you can just use these macros. currently * properties that need to be defined. you can just use these macros. currently
* (8/01) the only plugins that use these are the passthrough, speed, volume, * (8/01) the only plugins that use these are the passthrough, speed, volume,
* adder, and [de]interleave plugins. * adder, and [de]interleave plugins. These are for convenience only, and do not
* These are for convenience only, and do not specify the 'limits' of * specify the 'limits' of GStreamer. you might also use these definitions as a
* GStreamer. you might also use these definitions as a
* base for making your own caps, if need be. * base for making your own caps, if need be.
* *
* For example, to make a source pad that can output mono streams of either * For example, to make a source pad that can output streams of either mono
* float or int: * float or any channel int:
*
template = gst_pad_template_new * template = gst_pad_template_new
("sink", GST_PAD_SINK, GST_PAD_ALWAYS, * ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
gst_caps_append(gst_caps_new ("sink_int", "audio/raw", * gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int",
GST_AUDIO_INT_PAD_TEMPLATE_PROPS), * GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
gst_caps_new ("sink_float", "audio/raw", * gst_caps_new ("sink_float", "audio/x-raw-float",
GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS)), * GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS)),
NULL); * NULL);
*
srcpad = gst_pad_new_from_template(template,"src"); * sinkpad = gst_pad_new_from_template(template, "sink");
*
* Andy Wingo, 18 August 2001 * Andy Wingo, 18 August 2001
* Thomas, 6 September 2002 */ * Thomas, 6 September 2002 */
/* a few useful defines for arbitrary limits */
#define GST_AUDIO_MIN_RATE 4000
#define GST_AUDIO_MAX_RATE 96000
#define GST_AUDIO_DEF_RATE 44100 #define GST_AUDIO_DEF_RATE 44100
#define GST_AUDIO_INT_PAD_TEMPLATE_PROPS \ #define GST_AUDIO_INT_PAD_TEMPLATE_PROPS \
gst_props_new (\ gst_props_new (\
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\ "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"endianness", GST_PROPS_LIST (\
GST_PROPS_INT (G_LITTLE_ENDIAN),\
GST_PROPS_INT (G_BIG_ENDIAN)\
),\
"width", GST_PROPS_LIST (\
GST_PROPS_INT (8),\
GST_PROPS_INT (16),\
GST_PROPS_INT (32)\
),\
"depth", GST_PROPS_INT_RANGE (1, 32),\
"signed", GST_PROPS_LIST (\ "signed", GST_PROPS_LIST (\
GST_PROPS_BOOLEAN (TRUE),\ GST_PROPS_BOOLEAN (TRUE),\
GST_PROPS_BOOLEAN (FALSE)\ GST_PROPS_BOOLEAN (FALSE)\
),\ ),\
"width", GST_PROPS_LIST (GST_PROPS_INT (8), \
GST_PROPS_INT (16)), \
"depth", GST_PROPS_LIST (GST_PROPS_INT (8), \
GST_PROPS_INT (16)),\
"rate", GST_PROPS_INT_RANGE (GST_AUDIO_MIN_RATE, \
GST_AUDIO_MAX_RATE),\
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL) NULL)
#define GST_AUDIO_INT_MONO_PAD_TEMPLATE_PROPS \ #define GST_AUDIO_INT_MONO_PAD_TEMPLATE_PROPS \
gst_props_new (\ gst_props_new (\
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\ "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"channels", GST_PROPS_INT (1),\
"endianness", GST_PROPS_LIST (\
GST_PROPS_INT (G_LITTLE_ENDIAN),\
GST_PROPS_INT (G_BIG_ENDIAN)\
),\
"width", GST_PROPS_LIST (\
GST_PROPS_INT (8),\
GST_PROPS_INT (16),\
GST_PROPS_INT (32)\
),\
"depth", GST_PROPS_INT_RANGE (1, 32),\
"signed", GST_PROPS_LIST (\ "signed", GST_PROPS_LIST (\
GST_PROPS_BOOLEAN (TRUE),\ GST_PROPS_BOOLEAN (TRUE),\
GST_PROPS_BOOLEAN (FALSE)\ GST_PROPS_BOOLEAN (FALSE)\
),\ ),\
"width", GST_PROPS_LIST (GST_PROPS_INT (8), \
GST_PROPS_INT (16)),\
"depth", GST_PROPS_LIST (GST_PROPS_INT (8), \
GST_PROPS_INT (16)),\
"rate", GST_PROPS_INT_RANGE (GST_AUDIO_MIN_RATE, \
GST_AUDIO_MAX_RATE),\
"channels", GST_PROPS_INT (1),\
NULL) NULL)
#define GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS \ #define GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS \
gst_props_new (\ gst_props_new (\
"depth", GST_PROPS_INT (32),\ "rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\ "channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"intercept", GST_PROPS_FLOAT (0.0),\ "endianness", GST_PROPS_LIST (\
"slope", GST_PROPS_FLOAT (1.0),\ GST_PROPS_INT (G_LITTLE_ENDIAN),\
"rate", GST_PROPS_INT_RANGE (GST_AUDIO_MIN_RATE, \ GST_PROPS_INT (G_BIG_ENDIAN)\
GST_AUDIO_MAX_RATE),\ ),\
"width", GST_PROPS_LIST (\
GST_PROPS_INT (32),\
GST_PROPS_INT (64)\
),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS \
gst_props_new (\
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"channels", GST_PROPS_INT (1),\ "channels", GST_PROPS_INT (1),\
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\
"width", GST_PROPS_INT (32),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL) NULL)
/* /*
@ -118,4 +137,5 @@ long gst_audio_highest_sample_value (GstPad* pad);
/* check if the buffer size is a whole multiple of the frame size */ /* check if the buffer size is a whole multiple of the frame size */
gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf); gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf);
G_END_DECLS

View file

@ -60,7 +60,7 @@ GST_PAD_TEMPLATE_FACTORY (volume_sink_factory,
gst_caps_new ( gst_caps_new (
"volume_float_sink", "volume_float_sink",
"audio/x-raw-float", "audio/x-raw-float",
GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS
), ),
GST_CAPS_NEW ( GST_CAPS_NEW (
"volume_int_sink", "volume_int_sink",
@ -81,7 +81,7 @@ GST_PAD_TEMPLATE_FACTORY (volume_src_factory,
gst_caps_new ( gst_caps_new (
"volume_float_src", "volume_float_src",
"audio/x-raw-float", "audio/x-raw-float",
GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS
), ),
GST_CAPS_NEW ( GST_CAPS_NEW (
"volume_int_src", "volume_int_src",

View file

@ -62,7 +62,6 @@ struct _GstVolume {
gboolean mute; gboolean mute;
gint volume_i, real_vol_i; gint volume_i, real_vol_i;
gfloat volume_f, real_vol_f; gfloat volume_f, real_vol_f;
}; };
struct _GstVolumeClass { struct _GstVolumeClass {

View file

@ -124,11 +124,7 @@ create_pipeline (void)
default: default:
g_assert_not_reached (); g_assert_not_reached ();
} }
g_print ("Setting format to: format: \"float\"\n" g_print ("Setting format to float width %d\n", sinesrc->width);
" layout: \"%s\"\n"
" intercept: 0\n"
" slope: 1\n",
sinesrc->width == 32 ? "gfloat" : "gdouble");
} else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) { } else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) {
gint temp = last - NUMBER_OF_INT_TESTS - NUMBER_OF_FLOAT_TESTS; gint temp = last - NUMBER_OF_INT_TESTS - NUMBER_OF_FLOAT_TESTS;
GstElement *law; GstElement *law;

View file

@ -31,7 +31,6 @@ GST_PAD_TEMPLATE_FACTORY (sinesrc_src_factory,
GST_CAPS_NEW ( GST_CAPS_NEW (
"sinesrc_int_src", "sinesrc_int_src",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0), "law", GST_PROPS_INT (0),
"endianness", GST_PROPS_LIST (GST_PROPS_INT (G_LITTLE_ENDIAN), GST_PROPS_INT (G_BIG_ENDIAN)), "endianness", GST_PROPS_LIST (GST_PROPS_INT (G_LITTLE_ENDIAN), GST_PROPS_INT (G_BIG_ENDIAN)),
"signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (FALSE), GST_PROPS_BOOLEAN (TRUE)), "signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (FALSE), GST_PROPS_BOOLEAN (TRUE)),
@ -43,10 +42,6 @@ GST_PAD_TEMPLATE_FACTORY (sinesrc_src_factory,
GST_CAPS_NEW ( GST_CAPS_NEW (
"sinesrc_float_src", "sinesrc_float_src",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("float"),
"layout", GST_PROPS_LIST (GST_PROPS_STRING ("gfloat"), GST_PROPS_STRING ("gdouble")),
"intercept", GST_PROPS_FLOAT (0),
"slope", GST_PROPS_FLOAT (1),
"channels", GST_PROPS_INT_RANGE (1, 16) "channels", GST_PROPS_INT_RANGE (1, 16)
) )
); );
@ -123,10 +118,8 @@ sinesrc_force_caps (SineSrc *src) {
caps = GST_CAPS_NEW ( caps = GST_CAPS_NEW (
"sinesrc_src_caps", "sinesrc_src_caps",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0), "law", GST_PROPS_INT (0),
"signed", GST_PROPS_BOOLEAN (src->sign), "signed", GST_PROPS_BOOLEAN (src->sign),
"width", GST_PROPS_INT (src->width),
"depth", GST_PROPS_INT (src->depth) "depth", GST_PROPS_INT (src->depth)
); );
if (src->width > 8) if (src->width > 8)
@ -139,25 +132,14 @@ sinesrc_force_caps (SineSrc *src) {
caps = GST_CAPS_NEW ( caps = GST_CAPS_NEW (
"sinesrc_src_caps", "sinesrc_src_caps",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("float"), "endianness", GST_PROPS_INT(src->endianness)
"intercept", GST_PROPS_FLOAT (0),
"slope", GST_PROPS_FLOAT (1)
); );
if (src->width == 32) {
gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("layout",
GST_PROPS_STRING ("gfloat")));
} else if (src->width == 64) {
gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("layout",
GST_PROPS_STRING ("gdouble")));
} else {
g_assert_not_reached ();
}
break; break;
default: default:
g_assert_not_reached(); g_assert_not_reached();
} }
gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("width", GST_PROPS_INT (src->width)));
gst_props_add_entry (gst_caps_get_props (caps), gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("rate", GST_PROPS_INT (src->rate))); gst_props_entry_new ("rate", GST_PROPS_INT (src->rate)));
gst_props_add_entry (gst_caps_get_props (caps), gst_props_add_entry (gst_caps_get_props (caps),

View file

@ -124,11 +124,7 @@ create_pipeline (void)
default: default:
g_assert_not_reached (); g_assert_not_reached ();
} }
g_print ("Setting format to: format: \"float\"\n" g_print ("Setting format to float width %d\n", sinesrc->width);
" layout: \"%s\"\n"
" intercept: 0\n"
" slope: 1\n",
sinesrc->width == 32 ? "gfloat" : "gdouble");
} else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) { } else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) {
gint temp = last - NUMBER_OF_INT_TESTS - NUMBER_OF_FLOAT_TESTS; gint temp = last - NUMBER_OF_INT_TESTS - NUMBER_OF_FLOAT_TESTS;
GstElement *law; GstElement *law;

View file

@ -31,7 +31,6 @@ GST_PAD_TEMPLATE_FACTORY (sinesrc_src_factory,
GST_CAPS_NEW ( GST_CAPS_NEW (
"sinesrc_int_src", "sinesrc_int_src",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0), "law", GST_PROPS_INT (0),
"endianness", GST_PROPS_LIST (GST_PROPS_INT (G_LITTLE_ENDIAN), GST_PROPS_INT (G_BIG_ENDIAN)), "endianness", GST_PROPS_LIST (GST_PROPS_INT (G_LITTLE_ENDIAN), GST_PROPS_INT (G_BIG_ENDIAN)),
"signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (FALSE), GST_PROPS_BOOLEAN (TRUE)), "signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (FALSE), GST_PROPS_BOOLEAN (TRUE)),
@ -43,10 +42,6 @@ GST_PAD_TEMPLATE_FACTORY (sinesrc_src_factory,
GST_CAPS_NEW ( GST_CAPS_NEW (
"sinesrc_float_src", "sinesrc_float_src",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("float"),
"layout", GST_PROPS_LIST (GST_PROPS_STRING ("gfloat"), GST_PROPS_STRING ("gdouble")),
"intercept", GST_PROPS_FLOAT (0),
"slope", GST_PROPS_FLOAT (1),
"channels", GST_PROPS_INT_RANGE (1, 16) "channels", GST_PROPS_INT_RANGE (1, 16)
) )
); );
@ -123,10 +118,8 @@ sinesrc_force_caps (SineSrc *src) {
caps = GST_CAPS_NEW ( caps = GST_CAPS_NEW (
"sinesrc_src_caps", "sinesrc_src_caps",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT (0), "law", GST_PROPS_INT (0),
"signed", GST_PROPS_BOOLEAN (src->sign), "signed", GST_PROPS_BOOLEAN (src->sign),
"width", GST_PROPS_INT (src->width),
"depth", GST_PROPS_INT (src->depth) "depth", GST_PROPS_INT (src->depth)
); );
if (src->width > 8) if (src->width > 8)
@ -139,25 +132,14 @@ sinesrc_force_caps (SineSrc *src) {
caps = GST_CAPS_NEW ( caps = GST_CAPS_NEW (
"sinesrc_src_caps", "sinesrc_src_caps",
"audio/raw", "audio/raw",
"format", GST_PROPS_STRING ("float"), "endianness", GST_PROPS_INT(src->endianness)
"intercept", GST_PROPS_FLOAT (0),
"slope", GST_PROPS_FLOAT (1)
); );
if (src->width == 32) {
gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("layout",
GST_PROPS_STRING ("gfloat")));
} else if (src->width == 64) {
gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("layout",
GST_PROPS_STRING ("gdouble")));
} else {
g_assert_not_reached ();
}
break; break;
default: default:
g_assert_not_reached(); g_assert_not_reached();
} }
gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("width", GST_PROPS_INT (src->width)));
gst_props_add_entry (gst_caps_get_props (caps), gst_props_add_entry (gst_caps_get_props (caps),
gst_props_entry_new ("rate", GST_PROPS_INT (src->rate))); gst_props_entry_new ("rate", GST_PROPS_INT (src->rate)));
gst_props_add_entry (gst_caps_get_props (caps), gst_props_add_entry (gst_caps_get_props (caps),