00001
00002
00003
00004
00005
00006
00007
00008
00013 #ifndef _BLT_PCM_H_
00014 #define _BLT_PCM_H_
00015
00016
00017
00018
00019 #include "Atomix.h"
00020 #include "BltConfig.h"
00021 #include "BltDefs.h"
00022 #include "BltTypes.h"
00023 #include "BltErrors.h"
00024 #include "BltMedia.h"
00025 #include "BltMediaPacket.h"
00026 #include "BltCore.h"
00027
00028
00029
00030
00031 typedef struct {
00032 BLT_MediaType base;
00033 BLT_UInt32 sample_rate;
00034 BLT_UInt16 channel_count;
00035 BLT_UInt8 bits_per_sample;
00036 BLT_UInt8 sample_format;
00037 BLT_UInt32 channel_mask;
00038 } BLT_PcmMediaType;
00039
00040
00041
00042
00043 #define BLT_PCM_MEDIA_TYPE_EXTENSION_CLEAR(_e) \
00044 do { \
00045 _e.sample_rate = 0; \
00046 _e.channel_count = 0; \
00047 _e.bits_per_sample = 0; \
00048 _e.sample_format = 0; \
00049 } while(0);
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #define BLT_PCM_SAMPLE_FORMAT_NONE 0
00061
00062 #define BLT_PCM_SAMPLE_FORMAT_SIGNED_INT_BE 1
00063 #define BLT_PCM_SAMPLE_FORMAT_SIGNED_INT_LE 2
00064 #define BLT_PCM_SAMPLE_FORMAT_UNSIGNED_INT_BE 3
00065 #define BLT_PCM_SAMPLE_FORMAT_UNSIGNED_INT_LE 4
00066 #define BLT_PCM_SAMPLE_FORMAT_FLOAT_BE 5
00067 #define BLT_PCM_SAMPLE_FORMAT_FLOAT_LE 6
00068
00069 #if BLT_CONFIG_CPU_BYTE_ORDER == BLT_CPU_BIG_ENDIAN
00070 #define BLT_PCM_SAMPLE_FORMAT_SIGNED_INT_NE BLT_PCM_SAMPLE_FORMAT_SIGNED_INT_BE
00071 #define BLT_PCM_SAMPLE_FORMAT_UNSIGNED_INT_NE BLT_PCM_SAMPLE_FORMAT_UNSIGNED_INT_BE
00072 #define BLT_PCM_SAMPLE_FORMAT_FLOAT_NE BLT_PCM_SAMPLE_FORMAT_FLOAT_BE
00073 #else
00074 #define BLT_PCM_SAMPLE_FORMAT_SIGNED_INT_NE BLT_PCM_SAMPLE_FORMAT_SIGNED_INT_LE
00075 #define BLT_PCM_SAMPLE_FORMAT_UNSIGNED_INT_NE BLT_PCM_SAMPLE_FORMAT_UNSIGNED_INT_LE
00076 #define BLT_PCM_SAMPLE_FORMAT_FLOAT_NE BLT_PCM_SAMPLE_FORMAT_FLOAT_LE
00077 #endif
00078
00079
00080 #define BLT_PCM_SPEAKER_FRONT_LEFT (1 )
00081 #define BLT_PCM_SPEAKER_FRONT_RIGHT (1<< 1)
00082 #define BLT_PCM_SPEAKER_FRONT_CENTER (1<< 2)
00083 #define BLT_PCM_SPEAKER_LOW_FREQUENCY (1<< 3)
00084 #define BLT_PCM_SPEAKER_BACK_LEFT (1<< 4)
00085 #define BLT_PCM_SPEAKER_BACK_RIGHT (1<< 5)
00086 #define BLT_PCM_SPEAKER_FRONT_LEFT_OF_CENTER (1<< 6)
00087 #define BLT_PCM_SPEAKER_FRONT_RIGHT_OF_CENTER (1<< 7)
00088 #define BLT_PCM_SPEAKER_BACK_CENTER (1<< 8)
00089 #define BLT_PCM_SPEAKER_SIDE_LEFT (1<< 9)
00090 #define BLT_PCM_SPEAKER_SIDE_RIGHT (1<<10)
00091 #define BLT_PCM_SPEAKER_TOP_CENTER (1<<11)
00092 #define BLT_PCM_SPEAKER_TOP_FRONT_LEFT (1<<12)
00093 #define BLT_PCM_SPEAKER_TOP_FRONT_CENTER (1<<13)
00094 #define BLT_PCM_SPEAKER_TOP_FRONT_RIGHT (1<<14)
00095 #define BLT_PCM_SPEAKER_TOP_BACK_LEFT (1<<15)
00096 #define BLT_PCM_SPEAKER_TOP_BACK_CENTER (1<<16)
00097 #define BLT_PCM_SPEAKER_TOP_BACK_RIGHT (1<<17)
00098
00099
00100 #define BLT_CHANNEL_MASK_MONO (BLT_PCM_SPEAKER_FRONT_CENTER)
00101 #define BLT_CHANNEL_MASK_STEREO (BLT_PCM_SPEAKER_FRONT_LEFT | BLT_PCM_SPEAKER_FRONT_RIGHT)
00102 #define BLT_CHANNEL_MASK_QUAD (BLT_PCM_SPEAKER_FRONT_LEFT | BLT_PCM_SPEAKER_FRONT_RIGHT | \
00103 BLT_PCM_SPEAKER_BACK_LEFT | BLT_PCM_SPEAKER_BACK_RIGHT)
00104 #define BLT_CHANNEL_MASK_SURROUND (BLT_PCM_SPEAKER_FRONT_LEFT | BLT_PCM_SPEAKER_FRONT_RIGHT | \
00105 BLT_PCM_SPEAKER_FRONT_CENTER | BLT_PCM_SPEAKER_BACK_CENTER)
00106 #define BLT_CHANNEL_MASK_5POINT1 (BLT_PCM_SPEAKER_FRONT_LEFT | BLT_PCM_SPEAKER_FRONT_RIGHT | \
00107 BLT_PCM_SPEAKER_FRONT_CENTER | BLT_PCM_SPEAKER_LOW_FREQUENCY | \
00108 BLT_PCM_SPEAKER_BACK_LEFT | BLT_PCM_SPEAKER_BACK_RIGHT)
00109 #define BLT_CHANNEL_MASK_7POINT1 (BLT_PCM_SPEAKER_FRONT_LEFT | BLT_PCM_SPEAKER_FRONT_RIGHT | \
00110 BLT_PCM_SPEAKER_FRONT_CENTER | BLT_PCM_SPEAKER_LOW_FREQUENCY | \
00111 BLT_PCM_SPEAKER_BACK_LEFT | BLT_PCM_SPEAKER_BACK_RIGHT | \
00112 BLT_PCM_SPEAKER_FRONT_LEFT_OF_CENTER | BLT_PCM_SPEAKER_FRONT_RIGHT_OF_CENTER)
00113 #define BLT_CHANNEL_MASK_5POINT1_SURROUND (BLT_PCM_SPEAKER_FRONT_LEFT | BLT_PCM_SPEAKER_FRONT_RIGHT | \
00114 BLT_PCM_SPEAKER_FRONT_CENTER | BLT_PCM_SPEAKER_LOW_FREQUENCY | \
00115 BLT_PCM_SPEAKER_SIDE_LEFT | BLT_PCM_SPEAKER_SIDE_RIGHT)
00116 #define BLT_CHANNEL_MASK_7POINT1_SURROUND (BLT_PCM_SPEAKER_FRONT_LEFT | BLT_PCM_SPEAKER_FRONT_RIGHT | \
00117 BLT_PCM_SPEAKER_FRONT_CENTER | BLT_PCM_SPEAKER_LOW_FREQUENCY | \
00118 BLT_PCM_SPEAKER_BACK_LEFT | BLT_PCM_SPEAKER_BACK_RIGHT | \
00119 BLT_PCM_SPEAKER_SIDE_LEFT | BLT_PCM_SPEAKER_SIDE_RIGHT)
00120
00121
00122
00123
00124
00125 extern const BLT_MediaType BLT_GenericPcmMediaType;
00126
00127
00128
00129
00130 #ifdef __cplusplus
00131 extern "C" {
00132 #endif
00133
00134 extern void
00135 BLT_PcmMediaType_Init(BLT_PcmMediaType* media_type);
00136
00137 extern BLT_Boolean
00138 BLT_Pcm_CanConvert(const BLT_MediaType* from, const BLT_MediaType* to);
00139
00140 extern BLT_Result
00141 BLT_Pcm_ConvertMediaPacket(BLT_Core* core,
00142 BLT_MediaPacket* in_packet,
00143 BLT_PcmMediaType* out_type,
00144 BLT_MediaPacket** out_packet);
00145
00146 #ifdef __cplusplus
00147 }
00148 #endif
00149
00150 #endif