-good: port to new audio caps

This commit is contained in:
Wim Taymans 2011-09-06 13:16:27 +02:00
parent 24df106272
commit e204c5934c
15 changed files with 106 additions and 146 deletions

View file

@ -50,9 +50,9 @@ typedef jack_default_audio_sample_t sample_t;
#define GST_TYPE_JACK_CLIENT (gst_jack_client_get_type ())
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GST_JACK_FORMAT_STR "F32_LE"
#define GST_JACK_FORMAT_STR "F32LE"
#else
#define GST_JACK_FORMAT_STR "F32_BE"
#define GST_JACK_FORMAT_STR "F32BE"
#endif
GType gst_jack_client_get_type(void);

View file

@ -1717,11 +1717,11 @@ static GstStateChangeReturn gst_pulsesink_change_state (GstElement * element,
GstStateChange transition);
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
# define FORMATS "{ S16_LE, S16_BE, F32_LE, F32_BE, S32_LE, S32_BE, " \
"S24_3LE, S24_3BE, S24_LE, S24_BE, S8 }"
# define FORMATS "{ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, " \
"S24LE, S24BE, S24_32LE, S24_32BE, S8 }"
#else
# define FORMATS "{ S16_BE, S16_LE, F32_BE, F32_LE, S32_BE, S32_LE, " \
"S24_3BE, S24_3LE, S24_BE, S24_LE, S8 }"
# define FORMATS "{ S16BE, S16LE, F32BE, F32LE, S32BE, S32LE, " \
"S24BE, S24LE, S24_32BE, S24_32LE, S8 }"
#endif
static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("sink",

View file

@ -99,9 +99,9 @@ static GstStateChangeReturn gst_pulsesrc_change_state (GstElement *
element, GstStateChange transition);
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
# define FORMATS "{ S16_LE, S16_BE, F32_LE, F32_BE, S32_LE, S32_BE, U8 }"
# define FORMATS "{ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, U8 }"
#else
# define FORMATS "{ S16_BE, S16_LE, F32_BE, F32_LE, S32_BE, S32_LE, U8 }"
# define FORMATS "{ S16BE, S16LE, F32BE, F32LE, S32BE, S32LE, U8 }"
#endif
static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("src",
@ -1084,7 +1084,7 @@ gst_pulsesrc_success_cb (pa_stream * s, int success, void *userdata)
{
GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (userdata);
pulsesrc->operation_success = ! !success;
pulsesrc->operation_success = !!success;
pa_threaded_mainloop_signal (pulsesrc->mainloop, 0);
}

View file

@ -98,34 +98,34 @@ gst_pulse_fill_sample_spec (GstRingBufferSpec * spec, pa_sample_spec * ss)
case GST_AUDIO_FORMAT_U8:
ss->format = PA_SAMPLE_U8;
break;
case GST_AUDIO_FORMAT_S16_LE:
case GST_AUDIO_FORMAT_S16LE:
ss->format = PA_SAMPLE_S16LE;
break;
case GST_AUDIO_FORMAT_S16_BE:
case GST_AUDIO_FORMAT_S16BE:
ss->format = PA_SAMPLE_S16BE;
break;
case GST_AUDIO_FORMAT_F32_LE:
case GST_AUDIO_FORMAT_F32LE:
ss->format = PA_SAMPLE_FLOAT32LE;
break;
case GST_AUDIO_FORMAT_F32_BE:
case GST_AUDIO_FORMAT_F32BE:
ss->format = PA_SAMPLE_FLOAT32BE;
break;
case GST_AUDIO_FORMAT_S32_LE:
case GST_AUDIO_FORMAT_S32LE:
ss->format = PA_SAMPLE_S32LE;
break;
case GST_AUDIO_FORMAT_S32_BE:
case GST_AUDIO_FORMAT_S32BE:
ss->format = PA_SAMPLE_S32BE;
break;
case GST_AUDIO_FORMAT_S24_3LE:
case GST_AUDIO_FORMAT_S24LE:
ss->format = PA_SAMPLE_S24LE;
break;
case GST_AUDIO_FORMAT_S24_3BE:
case GST_AUDIO_FORMAT_S24BE:
ss->format = PA_SAMPLE_S24BE;
break;
case GST_AUDIO_FORMAT_S24_LE:
case GST_AUDIO_FORMAT_S24_32LE:
ss->format = PA_SAMPLE_S24_32LE;
break;
case GST_AUDIO_FORMAT_S24_BE:
case GST_AUDIO_FORMAT_S24_32BE:
ss->format = PA_SAMPLE_S24_32BE;
break;
default:

View file

@ -92,29 +92,17 @@ gst_audio_panorama_method_get_type (void)
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
"audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 2 ], "
"endianness = (int) BYTE_ORDER, "
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) { " GST_AUDIO_NE (S32) ", " GST_AUDIO_NE (S16) "}, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
);
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 1, MAX ], "
"channels = (int) 2, "
"endianness = (int) BYTE_ORDER, " "width = (int) 32; "
"audio/x-raw-int, "
"rate = (int) [ 1, MAX ], "
"channels = (int) 2, "
"endianness = (int) BYTE_ORDER, "
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) { " GST_AUDIO_NE (S32) ", " GST_AUDIO_NE (S16) "}, "
"rate = (int) [ 1, MAX ], " "channels = (int) 2")
);
G_DEFINE_TYPE (GstAudioPanorama, gst_audio_panorama, GST_TYPE_BASE_TRANSFORM);
@ -237,27 +225,27 @@ gst_audio_panorama_init (GstAudioPanorama * filter)
filter->panorama = 0;
filter->method = METHOD_PSYCHOACOUSTIC;
filter->width = 0;
filter->channels = 0;
filter->format_float = FALSE;
gst_audio_info_init (&filter->info);
filter->process = NULL;
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (filter), TRUE);
}
static gboolean
gst_audio_panorama_set_process_function (GstAudioPanorama * filter)
gst_audio_panorama_set_process_function (GstAudioPanorama * filter,
GstAudioInfo * info)
{
gint channel_index, format_index, method_index;
const GstAudioFormatInfo *finfo = info->finfo;
/* set processing function */
channel_index = filter->channels - 1;
channel_index = GST_AUDIO_INFO_CHANNELS (info) - 1;
if (channel_index > 1 || channel_index < 0) {
filter->process = NULL;
return FALSE;
}
format_index = (filter->format_float) ? 1 : 0;
format_index = GST_AUDIO_FORMAT_INFO_IS_FLOAT (finfo) ? 1 : 0;
method_index = filter->method;
if (method_index >= NUM_METHODS || method_index < 0)
@ -280,7 +268,7 @@ gst_audio_panorama_set_property (GObject * object, guint prop_id,
break;
case PROP_METHOD:
filter->method = g_value_get_enum (value);
gst_audio_panorama_set_process_function (filter);
gst_audio_panorama_set_process_function (filter, &filter->info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -356,44 +344,27 @@ gst_audio_panorama_set_caps (GstBaseTransform * base, GstCaps * incaps,
GstCaps * outcaps)
{
GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
const GstStructure *structure;
gboolean ret;
gint width;
const gchar *fmt;
GstAudioInfo info;
/*GST_INFO ("incaps are %" GST_PTR_FORMAT, incaps); */
if (!gst_audio_info_from_caps (&info, incaps))
goto no_format;
structure = gst_caps_get_structure (incaps, 0);
ret = gst_structure_get_int (structure, "channels", &filter->channels);
if (!ret)
goto no_channels;
GST_DEBUG ("try to process %d input with %d channels",
GST_AUDIO_INFO_FORMAT (&info), GST_AUDIO_INFO_CHANNELS (&info));
ret = gst_structure_get_int (structure, "width", &width);
if (!ret)
goto no_width;
filter->width = width / 8;
if (!gst_audio_panorama_set_process_function (filter, &info))
goto no_format;
fmt = gst_structure_get_name (structure);
if (!strcmp (fmt, "audio/x-raw-int"))
filter->format_float = FALSE;
else
filter->format_float = TRUE;
filter->info = info;
GST_DEBUG ("try to process %s input with %d channels", fmt, filter->channels);
return TRUE;
ret = gst_audio_panorama_set_process_function (filter);
if (!ret)
GST_WARNING ("can't process input with %d channels", filter->channels);
return ret;
no_channels:
GST_DEBUG ("no channels in caps");
return ret;
no_width:
GST_DEBUG ("no width in caps");
return ret;
no_format:
{
GST_DEBUG ("invalid caps");
return FALSE;
}
}
/* psychoacoustic processing functions */
@ -672,7 +643,7 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
memset (outdata, 0, outsize);
} else {
guint num_samples = outsize / (2 * filter->width);
guint num_samples = outsize / GST_AUDIO_INFO_BPF (&filter->info);
filter->process (filter, indata, outdata, num_samples);
}

View file

@ -22,6 +22,7 @@
#define __GST_AUDIO_PANORAMA_H__
#include <gst/gst.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
G_BEGIN_DECLS
@ -42,12 +43,11 @@ struct _GstAudioPanorama {
GstBaseTransform element;
gfloat panorama;
/* < private > */
GstAudioPanoramaProcessFunc process;
gint channels;
gboolean format_float;
gint width;
GstAudioInfo info;
gint method;
};

View file

@ -45,9 +45,9 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
#define GST_AU_PARSE_RAW_PAD_TEMPLATE_CAPS \
"audio/x-raw, " \
"format= (string) { S8, S16_LE, S16_BE, S24_3LE, S24_3BE, " \
"S32_LE, S32_BE, F32_LE, F32_BE, " \
"F64_LE, F64_BE }, " \
"format= (string) { S8, S16LE, S16BE, S24LE, S24BE, " \
"S32LE, S32BE, F32LE, F32BE, " \
"F64LE, F64BE }, " \
"rate = (int) [ 8000, 192000 ], " \
"channels = (int) [ 1, 2 ]"
@ -257,38 +257,38 @@ gst_au_parse_parse_header (GstAuParse * auparse)
break;
case 3: /* 16-bit linear PCM */
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_S16_LE;
format = GST_AUDIO_FORMAT_S16LE;
else
format = GST_AUDIO_FORMAT_S16_BE;
format = GST_AUDIO_FORMAT_S16BE;
auparse->sample_size = auparse->channels * 2;
break;
case 4: /* 24-bit linear PCM */
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_S24_3LE;
format = GST_AUDIO_FORMAT_S24LE;
else
format = GST_AUDIO_FORMAT_S24_3BE;
format = GST_AUDIO_FORMAT_S24BE;
auparse->sample_size = auparse->channels * 3;
break;
case 5: /* 32-bit linear PCM */
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_S32_LE;
format = GST_AUDIO_FORMAT_S32LE;
else
format = GST_AUDIO_FORMAT_S32_BE;
format = GST_AUDIO_FORMAT_S32BE;
auparse->sample_size = auparse->channels * 4;
break;
case 6: /* 32-bit IEEE floating point */
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_F32_LE;
format = GST_AUDIO_FORMAT_F32LE;
else
format = GST_AUDIO_FORMAT_F32_BE;
format = GST_AUDIO_FORMAT_F32BE;
auparse->sample_size = auparse->channels * 4;
break;
case 7: /* 64-bit IEEE floating point */
if (endianness == G_LITTLE_ENDIAN)
format = GST_AUDIO_FORMAT_F64_LE;
format = GST_AUDIO_FORMAT_F64LE;
else
format = GST_AUDIO_FORMAT_F64_BE;
format = GST_AUDIO_FORMAT_F64BE;
auparse->sample_size = auparse->channels * 8;
break;

View file

@ -38,7 +38,7 @@
* ! 'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1' \
* ! queue ! mux. \
* audiotestsrc num-buffers=440 ! audioconvert \
* ! 'audio/x-raw-int,rate=44100,channels=2' ! queue ! mux. \
* ! 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. \
* avimux name=mux ! filesink location=test.avi
* ]| This will create an .AVI file containing an uncompressed video stream
* with a test picture and an uncompressed audio stream containing a
@ -47,7 +47,7 @@
* gst-launch videotestsrc num-buffers=250 \
* ! 'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1' \
* ! xvidenc ! queue ! mux. \
* audiotestsrc num-buffers=440 ! audioconvert ! 'audio/x-raw-int,rate=44100,channels=2' \
* audiotestsrc num-buffers=440 ! audioconvert ! 'audio/x-raw,rate=44100,channels=2' \
* ! lame ! queue ! mux. \
* avimux name=mux ! filesink location=test.avi
* ]| This will create an .AVI file containing the same test video and sound
@ -66,6 +66,7 @@
#include <string.h>
#include <gst/video/video.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbytewriter.h>
#include "gstavimux.h"
@ -160,11 +161,8 @@ static GstStaticPadTemplate audio_sink_factory =
GST_STATIC_PAD_TEMPLATE ("audio_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { TRUE, FALSE }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) { U8, S16LE }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/mpeg, "
@ -758,36 +756,27 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps)
avimux->codec_data_size += gst_buffer_get_size (avipad->auds_codec_data);
}
if (!strcmp (mimetype, "audio/x-raw-int")) {
gint width, depth;
gboolean signedness;
if (!strcmp (mimetype, "audio/x-raw")) {
const gchar *format;
GstAudioFormat fmt;
format = gst_structure_get_string (structure, "format");
fmt = gst_audio_format_from_string (format);
switch (fmt) {
case GST_AUDIO_FORMAT_U8:
avipad->auds.blockalign = 8;
avipad->auds.size = 8;
break;
case GST_AUDIO_FORMAT_S16:
avipad->auds.blockalign = 16;
avipad->auds.size = 16;
break;
default:
goto refuse_caps;
}
avipad->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
if (!gst_structure_get_int (structure, "width", &width) ||
!gst_structure_get_int (structure, "depth", &depth) ||
!gst_structure_get_boolean (structure, "signed", &signedness)) {
GST_DEBUG_OBJECT (avimux,
"broken caps, width/depth/signed field missing");
goto refuse_caps;
}
/* no clear place to put different values for these while keeping to spec */
if (width != depth) {
GST_DEBUG_OBJECT (avimux, "width must be same as depth!");
goto refuse_caps;
}
/* because that's the way the caps will be recreated from riff data */
if ((width == 8 && signedness) || (width == 16 && !signedness)) {
GST_DEBUG_OBJECT (avimux,
"8-bit PCM must be unsigned, 16-bit PCM signed");
goto refuse_caps;
}
avipad->auds.blockalign = width;
avipad->auds.size = (width == 8) ? 8 : depth;
/* set some more info straight */
avipad->auds.blockalign /= 8;
avipad->auds.blockalign *= avipad->auds.channels;

View file

@ -97,7 +97,7 @@
* <refsect2>
* <title>Example pipelines</title>
* |[
* gst-launch v4l2src num-buffers=500 ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! qtmux ! filesink location=video.mov
* gst-launch v4l2src num-buffers=500 ! video/x-raw,width=320,height=240 ! ffmpegcolorspace ! qtmux ! filesink location=video.mov
* ]|
* Records a video stream captured from a v4l2 device and muxes it into a qt file.
* </refsect2>

View file

@ -5256,7 +5256,7 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl)
/* sync sample atom */
stream->stps_present = FALSE;
if ((stream->stss_present =
! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stss,
!!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stss,
&stream->stss) ? TRUE : FALSE) == TRUE) {
/* copy atom data into a new buffer for later use */
stream->stss.data = g_memdup (stream->stss.data, stream->stss.size);
@ -5274,7 +5274,7 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl)
/* partial sync sample atom */
if ((stream->stps_present =
! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stps,
!!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stps,
&stream->stps) ? TRUE : FALSE) == TRUE) {
/* copy atom data into a new buffer for later use */
stream->stps.data = g_memdup (stream->stps.data, stream->stps.size);
@ -5393,7 +5393,7 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl)
/* composition time-to-sample */
if ((stream->ctts_present =
! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_ctts,
!!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_ctts,
&stream->ctts) ? TRUE : FALSE) == TRUE) {
/* copy atom data into a new buffer for later use */
stream->ctts.data = g_memdup (stream->ctts.data, stream->ctts.size);
@ -9382,24 +9382,24 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
case GST_MAKE_FOURCC ('f', 'l', '6', '4'):
_codec ("Raw 64-bit floating-point audio");
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "F64_BE", NULL);
"format", G_TYPE_STRING, "F64BE", NULL);
break;
case GST_MAKE_FOURCC ('f', 'l', '3', '2'):
_codec ("Raw 32-bit floating-point audio");
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "F32_BE", NULL);
"format", G_TYPE_STRING, "F32BE", NULL);
break;
case FOURCC_in24:
_codec ("Raw 24-bit PCM audio");
/* we assume BIG ENDIAN, an enda box will tell us to change this to little
* endian later */
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S24_3BE", NULL);
"format", G_TYPE_STRING, "S24BE", NULL);
break;
case GST_MAKE_FOURCC ('i', 'n', '3', '2'):
_codec ("Raw 32-bit PCM audio");
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S32_BE", NULL);
"format", G_TYPE_STRING, "S32BE", NULL);
break;
case GST_MAKE_FOURCC ('u', 'l', 'a', 'w'):
_codec ("Mu-law audio");

View file

@ -24,9 +24,9 @@
#include "alaw-decode.h"
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define INT_FORMAT "S16_LE"
#define INT_FORMAT "S16LE"
#else
#define INT_FORMAT "S16_BE"
#define INT_FORMAT "S16BE"
#endif
GstStaticPadTemplate alaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",

View file

@ -31,9 +31,9 @@
#include "mulaw-conversion.h"
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define INT_FORMAT "S16_LE"
#define INT_FORMAT "S16LE"
#else
#define INT_FORMAT "S16_BE"
#define INT_FORMAT "S16BE"
#endif
extern GstStaticPadTemplate mulaw_dec_src_factory;

View file

@ -23,9 +23,9 @@
#include "mulaw-decode.h"
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define INT_FORMAT "S16_LE"
#define INT_FORMAT "S16LE"
#else
#define INT_FORMAT "S16_BE"
#define INT_FORMAT "S16BE"
#endif
GstStaticPadTemplate mulaw_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",

View file

@ -111,9 +111,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_spectrum_debug);
/* elementfactory information */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
# define FORMATS "{ S16_LE, S24_3LE, S32_LE, F32_LE, F64_LE }"
# define FORMATS "{ S16LE, S24LE, S32LE, F32LE, F64LE }"
#else
# define FORMATS "{ S16_BE, S24_3BE, S32_BE, F32_BE, F64_BE }"
# define FORMATS "{ S16BE, S24BE, S32BE, F32BE, F64BE }"
#endif
#define ALLOWED_CAPS \
@ -626,7 +626,7 @@ gst_spectrum_setup (GstAudioFilter * base, const GstAudioInfo * info)
input_data =
multi_channel ? input_data_int16_max : input_data_mixed_int16_max;
break;
case GST_AUDIO_FORMAT_S24_3:
case GST_AUDIO_FORMAT_S24:
input_data =
multi_channel ? input_data_int24_max : input_data_mixed_int24_max;
break;

View file

@ -1743,7 +1743,7 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
if (wav->caps) {
s = gst_caps_get_structure (wav->caps, 0);
if (s && gst_structure_has_name (s, "audio/x-raw-int") && buf != NULL) {
if (s && gst_structure_has_name (s, "audio/x-raw") && buf != NULL) {
GstTypeFindProbability prob;
GstCaps *tf_caps;