audio: sort formats by quality

Will ensure that we pick the "best" format when negotiating caps.

Fix #649

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/689>
This commit is contained in:
Guillaume Desmottes 2020-06-04 16:40:44 +02:00 committed by GStreamer Merge Bot
parent 1b4ab9f033
commit e2f6b85fd9

View file

@ -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);