From e2f6b85fd9faa8136881712a5fb67a08df7e0f28 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 4 Jun 2020 16:40:44 +0200 Subject: [PATCH] audio: sort formats by quality Will ensure that we pick the "best" format when negotiating caps. Fix #649 Part-of: --- gst-libs/gst/audio/audio-format.h | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/audio/audio-format.h b/gst-libs/gst/audio/audio-format.h index b917d15..ccad5cf 100644 --- a/gst-libs/gst/audio/audio-format.h +++ b/gst-libs/gst/audio/audio-format.h @@ -326,15 +326,32 @@ void gst_audio_format_fill_silence (const GstAudioFormatInfo *info * GST_AUDIO_FORMATS_ALL: * * List of all audio formats, for use in template caps strings. + * + * Formats are sorted by decreasing "quality", using these criteria by priority: + * - depth + * - width + * - Float > Signed > Unsigned + * - native endianness preferred */ -#define GST_AUDIO_FORMATS_ALL "{ S8, U8, " \ - "S16LE, S16BE, U16LE, U16BE, " \ +#if G_BYTE_ORDER == G_BIG_ENDIAN +#define GST_AUDIO_FORMATS_ALL "{ F64BE, F64LE, " \ + "F32BE, F32LE, S32BE, S32LE, U32BE, U32LE, " \ + "S24_32BE, S24_32LE, U24_32BE, U24_32LE, " \ + "S24BE, S24LE, U24BE, U24LE, " \ + "S20BE, S20LE, U20BE, U20LE, " \ + "S18BE, S18LE, U18BE, U18LE, " \ + "S16BE, S16LE, U16BE, U16LE, " \ + "S8,U8 }" +#elif G_BYTE_ORDER == G_LITTLE_ENDIAN +#define GST_AUDIO_FORMATS_ALL "{ F64LE, F64BE, " \ + "F32LE, F32BE, S32LE, S32BE, U32LE, U32BE, " \ "S24_32LE, S24_32BE, U24_32LE, U24_32BE, " \ - "S32LE, S32BE, U32LE, U32BE, " \ "S24LE, S24BE, U24LE, U24BE, " \ "S20LE, S20BE, U20LE, U20BE, " \ "S18LE, S18BE, U18LE, U18BE, " \ - "F32LE, F32BE, F64LE, F64BE }" + "S16LE, S16BE, U16LE, U16BE, " \ + "S8, U8 }" +#endif GST_AUDIO_API const GstAudioFormat * gst_audio_formats_raw (guint * len); -- 2.7.4