[vlc-devel] commit: Implemented fi32 -> fl32/s16 conversion in format.c. ( Laurent Aimar )
git version control
git at videolan.org
Sat Jan 30 14:06:54 CET 2010
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jan 30 13:49:35 2010 +0100| [97e5f060705b87f0465da8b845d0142470639d54] | committer: Laurent Aimar
Implemented fi32 -> fl32/s16 conversion in format.c.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=97e5f060705b87f0465da8b845d0142470639d54
---
modules/audio_filter/converter/format.c | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/modules/audio_filter/converter/format.c b/modules/audio_filter/converter/format.c
index bc56861..87040a2 100644
--- a/modules/audio_filter/converter/format.c
+++ b/modules/audio_filter/converter/format.c
@@ -356,7 +356,32 @@ static block_t *S32toFl32(filter_t *filter, block_t *b)
*dst++ = (float)(*src++) / 2147483648.0;
return b;
}
-
+static block_t *Fi32toFl32(filter_t *filter, block_t *b)
+{
+ VLC_UNUSED(filter);
+ vlc_fixed_t *src = (vlc_fixed_t *)b->p_buffer;
+ float *dst = (float *)src;
+ for (int i = b->i_buffer / 4; i--;)
+ *dst++ = *src++ / (float)FIXED32_ONE;
+ return b;
+}
+static block_t *Fi32toS16(filter_t *filter, block_t *b)
+{
+ VLC_UNUSED(filter);
+ vlc_fixed_t *src = (vlc_fixed_t *)b->p_buffer;
+ int16_t *dst = (int16_t *)src;
+ for (int i = b->i_buffer / 4; i--;) {
+ const vlc_fixed_t v = *src++;
+ if (v >= FIXED32_ONE)
+ *dst++ = INT16_MAX;
+ else if (v <= -FIXED32_ONE)
+ *dst++ = INT16_MIN;
+ else
+ *dst++ = v >> (32 - FIXED32_FRACBITS);
+ }
+ b->i_buffer /= 2;
+ return b;
+}
/* */
static void X8toX16(block_t *bdst, const block_t *bsrc)
@@ -473,6 +498,8 @@ static const struct {
vlc_fourcc_t dst;
cvt_direct_t convert;
} cvt_directs[] = {
+ { VLC_CODEC_FI32, VLC_CODEC_FL32, Fi32toFl32 },
+ { VLC_CODEC_FI32, VLC_CODEC_S16N, Fi32toS16 },
{ VLC_CODEC_S32N, VLC_CODEC_FL32, S32toFl32 },
{ VLC_CODEC_S24N, VLC_CODEC_S16N, S24toS16 },
More information about the vlc-devel
mailing list