more audio caps porting

This commit is contained in:
Wim Taymans 2011-08-19 17:41:22 +02:00
parent f870178234
commit 8023f49d19
5 changed files with 67 additions and 91 deletions

View file

@ -17,7 +17,7 @@
#include "gstalsa.h"
#include <gst/audio/multichannel.h>
#include <gst/audio/audio.h>
static GstCaps *
gst_alsa_detect_rates (GstObject * obj, snd_pcm_hw_params_t * hw_params,
@ -117,18 +117,30 @@ gst_alsa_detect_formats (GstObject * obj, snd_pcm_hw_params_t * hw_params,
for (i = 0; i < gst_caps_get_size (in_caps); ++i) {
GstStructure *scopy;
const gchar *str;
GstAudioFormat format;
const GstAudioFormatInfo *finfo;
gint w, width = 0, depth = 0;
s = gst_caps_get_structure (in_caps, i);
if (!gst_structure_has_name (s, "audio/x-raw-int")) {
GST_WARNING_OBJECT (obj, "skipping non-int format");
if (!gst_structure_has_name (s, "audio/x-raw")) {
GST_WARNING_OBJECT (obj, "skipping non-raw format");
continue;
}
if (!gst_structure_get_int (s, "width", &width) ||
!gst_structure_get_int (s, "depth", &depth))
str = gst_structure_get_string (s, "format");
if (str == NULL)
continue;
if (width == 0 || (width % 8) != 0)
continue; /* Only full byte widths are valid */
format = gst_audio_format_from_string (str);
if (format == GST_AUDIO_FORMAT_UNKNOWN)
continue;
finfo = gst_audio_format_get_info (format);
width = GST_AUDIO_FORMAT_INFO_WIDTH (finfo);
depth = GST_AUDIO_FORMAT_INFO_DEPTH (finfo);
for (w = 0; w < G_N_ELEMENTS (pcmformats); w++)
if (pcmformats[w].width == width && pcmformats[w].depth == depth)
break;
@ -137,22 +149,17 @@ gst_alsa_detect_formats (GstObject * obj, snd_pcm_hw_params_t * hw_params,
if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat) &&
snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) {
/* template contains { true, false } or just one, leave it as it is */
scopy = gst_structure_copy (s);
} else if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat)) {
scopy = gst_structure_copy (s);
gst_structure_set (scopy, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
/* FIXME, remove unsigned version */
} else if (snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) {
scopy = gst_structure_copy (s);
gst_structure_set (scopy, "signed", G_TYPE_BOOLEAN, FALSE, NULL);
/* FIXME, remove signed version */
} else {
scopy = NULL;
}
if (scopy) {
if (width > 8) {
/* TODO: proper endianness detection, for now it's CPU endianness only */
gst_structure_set (scopy, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
}
gst_caps_append_structure (caps, scopy);
}
}

View file

@ -1565,56 +1565,36 @@ setup_pcm_mapper (GstOggStream * pad, ogg_packet * packet)
switch (format) {
case OGGPCM_FMT_S8:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 8,
"width", G_TYPE_INT, 8, "signed", G_TYPE_BOOLEAN, TRUE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S8", NULL);
break;
case OGGPCM_FMT_U8:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 8,
"width", G_TYPE_INT, 8, "signed", G_TYPE_BOOLEAN, FALSE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "U8", NULL);
break;
case OGGPCM_FMT_S16_LE:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 16,
"width", G_TYPE_INT, 16,
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S16_LE", NULL);
break;
case OGGPCM_FMT_S16_BE:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 16,
"width", G_TYPE_INT, 16,
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S16_BE", NULL);
break;
case OGGPCM_FMT_S24_LE:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 24,
"width", G_TYPE_INT, 24,
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S24_3LE", NULL);
break;
case OGGPCM_FMT_S24_BE:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 24,
"width", G_TYPE_INT, 24,
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S24_3BE", NULL);
break;
case OGGPCM_FMT_S32_LE:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 32,
"width", G_TYPE_INT, 32,
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S32_LE", NULL);
break;
case OGGPCM_FMT_S32_BE:
caps = gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 32,
"width", G_TYPE_INT, 32,
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S32_BE", NULL);
break;
case OGGPCM_FMT_ULAW:
caps = gst_caps_new_simple ("audio/x-mulaw", NULL);
@ -1623,30 +1603,26 @@ setup_pcm_mapper (GstOggStream * pad, ogg_packet * packet)
caps = gst_caps_new_simple ("audio/x-alaw", NULL);
break;
case OGGPCM_FMT_FLT32_LE:
caps = gst_caps_new_simple ("audio/x-raw-float",
"width", G_TYPE_INT, 32,
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "F32_LE", NULL);
break;
case OGGPCM_FMT_FLT32_BE:
caps = gst_caps_new_simple ("audio/x-raw-float",
"width", G_TYPE_INT, 32,
"endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "F32_BE", NULL);
break;
case OGGPCM_FMT_FLT64_LE:
caps = gst_caps_new_simple ("audio/x-raw-float",
"width", G_TYPE_INT, 64,
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "F64_LE", NULL);
break;
case OGGPCM_FMT_FLT64_BE:
caps = gst_caps_new_simple ("audio/x-raw-float",
"width", G_TYPE_INT, 64,
"endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "F64_BE", NULL);
break;
default:
return FALSE;
}
gst_caps_set_simple (caps, "audio/x-raw-int",
gst_caps_set_simple (caps,
"rate", G_TYPE_INT, pad->granulerate_n,
"channels", G_TYPE_INT, channels, NULL);
pad->caps = caps;
@ -1862,7 +1838,7 @@ const GstOggMap mappers[] = {
},
{
"PCM ", 8, 0,
"audio/x-raw-int",
"audio/x-raw",
setup_pcm_mapper,
NULL,
NULL,

View file

@ -63,10 +63,9 @@ static GstStaticPadTemplate vorbis_enc_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-float, "
"rate = (int) [ 1, 200000 ], "
"channels = (int) [ 1, 256 ], " "endianness = (int) BYTE_ORDER, "
"width = (int) 32")
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F32) ", "
"rate = (int) [ 1, 200000 ], " "channels = (int) [ 1, 256 ]")
);
static GstStaticPadTemplate vorbis_enc_src_factory =
@ -223,17 +222,15 @@ gst_vorbis_enc_generate_sink_caps (void)
GstCaps *caps = gst_caps_new_empty ();
int i, c;
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float",
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"rate", GST_TYPE_INT_RANGE, 1, 200000,
"channels", G_TYPE_INT, 1,
"endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
NULL));
"channels", G_TYPE_INT, 1, NULL));
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float",
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"rate", GST_TYPE_INT_RANGE, 1, 200000,
"channels", G_TYPE_INT, 2,
"endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
NULL));
"channels", G_TYPE_INT, 2, NULL));
for (i = 3; i <= 8; i++) {
GValue chanpos = { 0 };
@ -249,21 +246,19 @@ gst_vorbis_enc_generate_sink_caps (void)
}
g_value_unset (&pos);
structure = gst_structure_new ("audio/x-raw-float",
"rate", GST_TYPE_INT_RANGE, 1, 200000,
"channels", G_TYPE_INT, i,
"endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, NULL);
structure = gst_structure_new ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"rate", GST_TYPE_INT_RANGE, 1, 200000, "channels", G_TYPE_INT, i, NULL);
gst_structure_set_value (structure, "channel-positions", &chanpos);
g_value_unset (&chanpos);
gst_caps_append_structure (caps, structure);
}
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float",
gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw",
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
"rate", GST_TYPE_INT_RANGE, 1, 200000,
"channels", GST_TYPE_INT_RANGE, 9, 256,
"endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32,
NULL));
"channels", GST_TYPE_INT_RANGE, 9, 256, NULL));
return caps;
}

View file

@ -41,12 +41,12 @@ main (gint argc, gchar ** argv)
} tests[] = {
/* stereo => mono */
{
"audio/x-raw-int, channels=2", "audio/x-raw-int, channels=1", { {
"audio/x-raw, channels=2", "audio/x-raw, channels=1", { {
0.5,}, {
0.5,},}},
/* mono => stereo */
{
"audio/x-raw-int, channels=1", "audio/x-raw-int, channels=2", { {
"audio/x-raw, channels=1", "audio/x-raw, channels=2", { {
1, 1,},}}
};

View file

@ -231,8 +231,7 @@ struct _StreamGroup
#define DEFAULT_RAW_CAPS \
"video/x-raw; " \
"audio/x-raw-int; " \
"audio/x-raw-float; " \
"audio/x-raw; " \
"text/plain; " \
"text/x-pango-markup; " \
"video/x-dvd-subpicture; " \
@ -482,8 +481,7 @@ gst_encode_bin_init (GstEncodeBin * encode_bin)
GST_RANK_MARGINAL);
encode_bin->raw_video_caps = gst_caps_from_string ("video/x-raw");
encode_bin->raw_audio_caps =
gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
encode_bin->raw_audio_caps = gst_caps_from_string ("audio/x-raw");
/* encode_bin->raw_text_caps = */
/* gst_caps_from_string ("text/plain;text/x-pango-markup"); */
@ -1264,7 +1262,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
/* FIXME : Once we have properties for specific converters, use those */
if (GST_IS_ENCODING_VIDEO_PROFILE (sprof)) {
const gboolean native_video =
!!(ebin->flags & GST_ENC_FLAG_NO_VIDEO_CONVERSION);
! !(ebin->flags & GST_ENC_FLAG_NO_VIDEO_CONVERSION);
GstElement *cspace = NULL, *scale, *vrate, *cspace2 = NULL;
GST_LOG ("Adding conversion elements for video stream");