audio: add flag to mark possible unpack formats

Make a new flag to mark formats that can be used in pack and unpack functions.
Mark S32NE and F64NE as those unpack formats
This commit is contained in:
Wim Taymans 2012-06-08 12:26:08 +02:00
parent 233622437f
commit 8e393d898a
2 changed files with 30 additions and 10 deletions

View file

@ -26,7 +26,10 @@
#include "audio-format.h" #include "audio-format.h"
#define SINT (GST_AUDIO_FORMAT_FLAG_INTEGER | GST_AUDIO_FORMAT_FLAG_SIGNED) #define SINT (GST_AUDIO_FORMAT_FLAG_INTEGER | GST_AUDIO_FORMAT_FLAG_SIGNED)
#define SINT_PACK (SINT | GST_AUDIO_FORMAT_FLAG_UNPACK)
#define UINT (GST_AUDIO_FORMAT_FLAG_INTEGER) #define UINT (GST_AUDIO_FORMAT_FLAG_INTEGER)
#define FLOAT (GST_AUDIO_FORMAT_FLAG_FLOAT)
#define FLOAT_PACK (FLOAT | GST_AUDIO_FORMAT_FLAG_UNPACK)
#define MAKE_FORMAT(str,desc,flags,end,width,depth,silent) \ #define MAKE_FORMAT(str,desc,flags,end,width,depth,silent) \
{ GST_AUDIO_FORMAT_ ##str, G_STRINGIFY(str), desc, flags, end, width, depth, silent } { GST_AUDIO_FORMAT_ ##str, G_STRINGIFY(str), desc, flags, end, width, depth, silent }
@ -72,10 +75,19 @@ static GstAudioFormatInfo formats[] = {
MAKE_FORMAT (U24_32BE, "24-bit unsigned PCM audio", UINT, G_BIG_ENDIAN, 32, MAKE_FORMAT (U24_32BE, "24-bit unsigned PCM audio", UINT, G_BIG_ENDIAN, 32,
24, SILENT_U24_32BE), 24, SILENT_U24_32BE),
/* 32 bit */ /* 32 bit */
MAKE_FORMAT (S32LE, "32-bit signed PCM audio", SINT, G_LITTLE_ENDIAN, 32, 32, #if G_BYTE_ORDER == G_LITTLE_ENDIAN
MAKE_FORMAT (S32LE, "32-bit signed PCM audio", SINT_PACK, G_LITTLE_ENDIAN, 32,
32,
SILENT_0), SILENT_0),
MAKE_FORMAT (S32BE, "32-bit signed PCM audio", SINT, G_BIG_ENDIAN, 32, 32, MAKE_FORMAT (S32BE, "32-bit signed PCM audio", SINT, G_BIG_ENDIAN, 32, 32,
SILENT_0), SILENT_0),
#else
MAKE_FORMAT (S32LE, "32-bit signed PCM audio", SINT, G_LITTLE_ENDIAN, 32, 32,
SILENT_0),
MAKE_FORMAT (S32BE, "32-bit signed PCM audio", SINT_PACK, G_BIG_ENDIAN, 32,
32,
SILENT_0),
#endif
MAKE_FORMAT (U32LE, "32-bit unsigned PCM audio", UINT, G_LITTLE_ENDIAN, 32, MAKE_FORMAT (U32LE, "32-bit unsigned PCM audio", UINT, G_LITTLE_ENDIAN, 32,
32, SILENT_U32LE), 32, SILENT_U32LE),
MAKE_FORMAT (U32BE, "32-bit unsigned PCM audio", UINT, G_BIG_ENDIAN, 32, 32, MAKE_FORMAT (U32BE, "32-bit unsigned PCM audio", UINT, G_BIG_ENDIAN, 32, 32,
@ -109,17 +121,20 @@ static GstAudioFormatInfo formats[] = {
SILENT_U18BE), SILENT_U18BE),
/* float */ /* float */
MAKE_FORMAT (F32LE, "32-bit floating-point audio", MAKE_FORMAT (F32LE, "32-bit floating-point audio",
GST_AUDIO_FORMAT_FLAG_FLOAT, G_LITTLE_ENDIAN, 32, 32, GST_AUDIO_FORMAT_FLAG_FLOAT, G_LITTLE_ENDIAN, 32, 32, SILENT_0),
SILENT_0),
MAKE_FORMAT (F32BE, "32-bit floating-point audio", MAKE_FORMAT (F32BE, "32-bit floating-point audio",
GST_AUDIO_FORMAT_FLAG_FLOAT, G_BIG_ENDIAN, 32, 32, GST_AUDIO_FORMAT_FLAG_FLOAT, G_BIG_ENDIAN, 32, 32, SILENT_0),
SILENT_0), #if G_BYTE_ORDER == G_LITTLE_ENDIAN
MAKE_FORMAT (F64LE, "64-bit floating-point audio", MAKE_FORMAT (F64LE, "64-bit floating-point audio",
GST_AUDIO_FORMAT_FLAG_FLOAT, G_LITTLE_ENDIAN, 64, 64, FLOAT_PACK, G_LITTLE_ENDIAN, 64, 64, SILENT_0),
SILENT_0),
MAKE_FORMAT (F64BE, "64-bit floating-point audio", MAKE_FORMAT (F64BE, "64-bit floating-point audio",
GST_AUDIO_FORMAT_FLAG_FLOAT, G_BIG_ENDIAN, 64, 64, FLOAT, G_BIG_ENDIAN, 64, 64, SILENT_0)
SILENT_0) #else
MAKE_FORMAT (F64LE, "64-bit floating-point audio",
FLOAT, G_LITTLE_ENDIAN, 64, 64, SILENT_0),
MAKE_FORMAT (F64BE, "64-bit floating-point audio",
FLOAT_PACK, G_BIG_ENDIAN, 64, 64, SILENT_0)
#endif
}; };
G_DEFINE_POINTER_TYPE (GstAudioFormatInfo, gst_audio_format_info); G_DEFINE_POINTER_TYPE (GstAudioFormatInfo, gst_audio_format_info);

View file

@ -30,8 +30,10 @@ G_BEGIN_DECLS
#if G_BYTE_ORDER == G_BIG_ENDIAN #if G_BYTE_ORDER == G_BIG_ENDIAN
#define _GST_AUDIO_FORMAT_NE(fmt) GST_AUDIO_FORMAT_ ## fmt ## BE #define _GST_AUDIO_FORMAT_NE(fmt) GST_AUDIO_FORMAT_ ## fmt ## BE
#define _GST_AUDIO_FORMAT_OE(fmt) GST_AUDIO_FORMAT_ ## fmt ## LE
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN #elif G_BYTE_ORDER == G_LITTLE_ENDIAN
#define _GST_AUDIO_FORMAT_NE(fmt) GST_AUDIO_FORMAT_ ## fmt ## LE #define _GST_AUDIO_FORMAT_NE(fmt) GST_AUDIO_FORMAT_ ## fmt ## LE
#define _GST_AUDIO_FORMAT_OE(fmt) GST_AUDIO_FORMAT_ ## fmt ## BE
#endif #endif
/** /**
@ -152,6 +154,8 @@ typedef struct _GstAudioFormatInfo GstAudioFormatInfo;
* @GST_AUDIO_FORMAT_FLAG_FLOAT: float samples * @GST_AUDIO_FORMAT_FLAG_FLOAT: float samples
* @GST_AUDIO_FORMAT_FLAG_SIGNED: signed samples * @GST_AUDIO_FORMAT_FLAG_SIGNED: signed samples
* @GST_AUDIO_FORMAT_FLAG_COMPLEX: complex layout * @GST_AUDIO_FORMAT_FLAG_COMPLEX: complex layout
* @GST_AUDIO_FORMAT_FLAG_UNPACK: the format can be used in
* #GstAudioFormatUnpack and #GstAudioFormatPack functions
* *
* The different audio flags that a format info can have. * The different audio flags that a format info can have.
*/ */
@ -160,7 +164,8 @@ typedef enum
GST_AUDIO_FORMAT_FLAG_INTEGER = (1 << 0), GST_AUDIO_FORMAT_FLAG_INTEGER = (1 << 0),
GST_AUDIO_FORMAT_FLAG_FLOAT = (1 << 1), GST_AUDIO_FORMAT_FLAG_FLOAT = (1 << 1),
GST_AUDIO_FORMAT_FLAG_SIGNED = (1 << 2), GST_AUDIO_FORMAT_FLAG_SIGNED = (1 << 2),
GST_AUDIO_FORMAT_FLAG_COMPLEX = (1 << 4) GST_AUDIO_FORMAT_FLAG_COMPLEX = (1 << 4),
GST_AUDIO_FORMAT_FLAG_UNPACK = (1 << 5)
} GstAudioFormatFlags; } GstAudioFormatFlags;
/** /**