riff: port to new audio caps

This commit is contained in:
Wim Taymans 2011-08-19 16:01:08 +02:00
parent 7db6fa37b4
commit 5e90085ca2

View File

@ -26,7 +26,7 @@
#include "riff-ids.h" #include "riff-ids.h"
#include "riff-media.h" #include "riff-media.h"
#include <gst/audio/multichannel.h> #include <gst/audio/audio.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -1132,6 +1132,7 @@ gst_riff_create_audio_caps (guint16 codec_id,
gint ba = strf->blockalign; gint ba = strf->blockalign;
gint ch = strf->channels; gint ch = strf->channels;
gint wd, ws; gint wd, ws;
GstAudioFormat format;
/* If we have an empty blockalign, we take the width contained in /* If we have an empty blockalign, we take the width contained in
* strf->size */ * strf->size */
@ -1152,11 +1153,11 @@ gst_riff_create_audio_caps (guint16 codec_id,
/* For reference, the actual depth is in strf->size */ /* For reference, the actual depth is in strf->size */
ws = wd; ws = wd;
caps = gst_caps_new_simple ("audio/x-raw-int", format = gst_audio_format_build_int (wd != 8, G_LITTLE_ENDIAN, wd, ws);
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"channels", G_TYPE_INT, ch, caps = gst_caps_new_simple ("audio/x-raw",
"width", G_TYPE_INT, wd, "format", G_TYPE_STRING, gst_audio_format_to_string (format),
"depth", G_TYPE_INT, ws, "signed", G_TYPE_BOOLEAN, wd != 8, NULL); "channels", G_TYPE_INT, ch, NULL);
/* Add default channel layout. In theory this should be done /* Add default channel layout. In theory this should be done
* for 1 and 2 channels too but apparently breaks too many * for 1 and 2 channels too but apparently breaks too many
@ -1172,10 +1173,9 @@ gst_riff_create_audio_caps (guint16 codec_id,
} }
} else { } else {
/* FIXME: this is pretty useless - we need fixed caps */ /* FIXME: this is pretty useless - we need fixed caps */
caps = gst_caps_from_string ("audio/x-raw-int, " caps = gst_caps_from_string ("audio/x-raw, "
"endianness = (int) LITTLE_ENDIAN, " "format = (string) { S8, U8, S16_LE, U16_LE, S24_LE, "
"signed = (boolean) { true, false }, " "U24_LE, S32_LE, U32_LE }");
"width = (int) { 8, 16, 24, 32 }, " "depth = (int) [ 1, 32 ]");
} }
if (codec_name && strf) if (codec_name && strf)
*codec_name = g_strdup_printf ("Uncompressed %d-bit PCM audio", *codec_name = g_strdup_printf ("Uncompressed %d-bit PCM audio",
@ -1199,9 +1199,9 @@ gst_riff_create_audio_caps (guint16 codec_id,
gint ch = strf->channels; gint ch = strf->channels;
gint wd = ba * 8 / ch; gint wd = ba * 8 / ch;
caps = gst_caps_new_simple ("audio/x-raw-float", caps = gst_caps_new_simple ("audio/x-raw",
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN, "format", G_TYPE_STRING, wd == 64 ? "F64_LE" : "F32_LE",
"channels", G_TYPE_INT, ch, "width", G_TYPE_INT, wd, NULL); "channels", G_TYPE_INT, ch, NULL);
/* Add default channel layout. In theory this should be done /* Add default channel layout. In theory this should be done
* for 1 and 2 channels too but apparently breaks too many * for 1 and 2 channels too but apparently breaks too many
@ -1217,8 +1217,8 @@ gst_riff_create_audio_caps (guint16 codec_id,
} }
} else { } else {
/* FIXME: this is pretty useless - we need fixed caps */ /* FIXME: this is pretty useless - we need fixed caps */
caps = gst_caps_from_string ("audio/x-raw-float, " caps = gst_caps_from_string ("audio/x-raw, "
"endianness = (int) LITTLE_ENDIAN, " "width = (int) { 32, 64 }"); "format = (string) { F32_LE, F64_LE }");
} }
if (codec_name && strf) if (codec_name && strf)
*codec_name = g_strdup_printf ("Uncompressed %d-bit IEEE float audio", *codec_name = g_strdup_printf ("Uncompressed %d-bit IEEE float audio",
@ -1503,6 +1503,7 @@ gst_riff_create_audio_caps (guint16 codec_id,
gint ba = strf->blockalign; gint ba = strf->blockalign;
gint wd = ba * 8 / strf->channels; gint wd = ba * 8 / strf->channels;
gint ws; gint ws;
GstAudioFormat format;
/* in riff, the depth is stored in the size field but it just /* in riff, the depth is stored in the size field but it just
* means that the _least_ significant bits are cleared. We can * means that the _least_ significant bits are cleared. We can
@ -1514,13 +1515,13 @@ gst_riff_create_audio_caps (guint16 codec_id,
* if (valid_bits_per_sample != 0) * if (valid_bits_per_sample != 0)
* ws = valid_bits_per_sample; */ * ws = valid_bits_per_sample; */
caps = gst_caps_new_simple ("audio/x-raw-int", format =
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN, gst_audio_format_build_int (wd != 8, G_LITTLE_ENDIAN, wd, ws);
caps = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, gst_audio_format_to_string (format),
"channels", G_TYPE_INT, strf->channels, "channels", G_TYPE_INT, strf->channels,
"width", G_TYPE_INT, wd, "rate", G_TYPE_INT, strf->rate, NULL);
"depth", G_TYPE_INT, ws,
"rate", G_TYPE_INT, strf->rate,
"signed", G_TYPE_BOOLEAN, wd != 8, NULL);
/* If channel_mask == 0 and channels > 2 let's /* If channel_mask == 0 and channels > 2 let's
* assume default layout as some wav files don't have the * assume default layout as some wav files don't have the
@ -1549,10 +1550,10 @@ gst_riff_create_audio_caps (guint16 codec_id,
gint ba = strf->blockalign; gint ba = strf->blockalign;
gint wd = ba * 8 / strf->channels; gint wd = ba * 8 / strf->channels;
caps = gst_caps_new_simple ("audio/x-raw-float", caps = gst_caps_new_simple ("audio/x-raw",
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN, "format", G_TYPE_STRING, wd == 32 ? "F32_LE" : "F64_LE",
"channels", G_TYPE_INT, strf->channels, "channels", G_TYPE_INT, strf->channels,
"width", G_TYPE_INT, wd, "rate", G_TYPE_INT, strf->rate, NULL); "rate", G_TYPE_INT, strf->rate, NULL);
/* If channel_mask == 0 and channels > 2 let's /* If channel_mask == 0 and channels > 2 let's
* assume default layout as some wav files don't have the * assume default layout as some wav files don't have the