Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108986568
D48421.id149330.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48421.id149330.diff
View Options
diff --git a/sys/dev/sound/pcm/pcm.h b/sys/dev/sound/pcm/pcm.h
--- a/sys/dev/sound/pcm/pcm.h
+++ b/sys/dev/sound/pcm/pcm.h
@@ -99,32 +99,6 @@
#define INTPCM24_T(v) ((intpcm24_t)(v))
#define INTPCM32_T(v) ((intpcm32_t)(v))
-#define PCM_CLAMP_S8(val) \
- (((val) > PCM_S8_MAX) ? PCM_S8_MAX : \
- (((val) < PCM_S8_MIN) ? PCM_S8_MIN : (val)))
-#define PCM_CLAMP_S16(val) \
- (((val) > PCM_S16_MAX) ? PCM_S16_MAX : \
- (((val) < PCM_S16_MIN) ? PCM_S16_MIN : (val)))
-#define PCM_CLAMP_S24(val) \
- (((val) > PCM_S24_MAX) ? PCM_S24_MAX : \
- (((val) < PCM_S24_MIN) ? PCM_S24_MIN : (val)))
-
-#ifdef SND_PCM_64
-#define PCM_CLAMP_S32(val) \
- (((val) > PCM_S32_MAX) ? PCM_S32_MAX : \
- (((val) < PCM_S32_MIN) ? PCM_S32_MIN : (val)))
-#else /* !SND_PCM_64 */
-#define PCM_CLAMP_S32(val) \
- (((val) > PCM_S24_MAX) ? PCM_S32_MAX : \
- (((val) < PCM_S24_MIN) ? PCM_S32_MIN : \
- ((val) << PCM_FXSHIFT)))
-#endif /* SND_PCM_64 */
-
-#define PCM_CLAMP_U8(val) PCM_CLAMP_S8(val)
-#define PCM_CLAMP_U16(val) PCM_CLAMP_S16(val)
-#define PCM_CLAMP_U24(val) PCM_CLAMP_S24(val)
-#define PCM_CLAMP_U32(val) PCM_CLAMP_S32(val)
-
static const struct {
const uint8_t ulaw_to_u8[G711_TABLE_SIZE];
const uint8_t alaw_to_u8[G711_TABLE_SIZE];
@@ -359,4 +333,28 @@
pcm_sample_write(dst, v, fmt);
}
+static __always_inline __unused intpcm_t
+pcm_clamp(intpcm32_t sample, uint32_t fmt)
+{
+ fmt = AFMT_ENCODING(fmt);
+
+ switch (AFMT_BIT(fmt)) {
+ case 8:
+ return ((sample > PCM_S8_MAX) ? PCM_S8_MAX :
+ ((sample < PCM_S8_MIN) ? PCM_S8_MIN : sample));
+ case 16:
+ return ((sample > PCM_S16_MAX) ? PCM_S16_MAX :
+ ((sample < PCM_S16_MIN) ? PCM_S16_MIN : sample));
+ case 24:
+ return ((sample > PCM_S24_MAX) ? PCM_S24_MAX :
+ ((sample < PCM_S24_MIN) ? PCM_S24_MIN : sample));
+ case 32:
+ return ((sample > PCM_S32_MAX) ? PCM_S32_MAX :
+ ((sample < PCM_S32_MIN) ? PCM_S32_MIN : sample));
+ default:
+ printf("%s(): unknown format: 0x%08x\n", __func__, fmt);
+ __assert_unreachable();
+ }
+}
+
#endif /* !_SND_PCM_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 31, 7:55 AM (5 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15838976
Default Alt Text
D48421.id149330.diff (2 KB)
Attached To
Mode
D48421: sound: Turn PCM_CLAMP_* macros into a function
Attached
Detach File
Event Timeline
Log In to Comment