From: Sebastian Dröge Date: Thu, 26 Aug 2010 17:16:18 +0000 (+0200) Subject: audioconvert: Use the ORC double support X-Git-Tag: 1.19.3~511^2~8113 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24831973c075a9ad17198504e16b890d3a83b445;p=platform%2Fupstream%2Fgstreamer.git audioconvert: Use the ORC double support --- diff --git a/gst/audioconvert/audioconvert.c b/gst/audioconvert/audioconvert.c index 7924224..c49322e 100644 --- a/gst/audioconvert/audioconvert.c +++ b/gst/audioconvert/audioconvert.c @@ -43,6 +43,20 @@ #define orc_audio_convert_unpack_s32_be orc_audio_convert_unpack_s32_swap #define orc_audio_convert_unpack_float_le orc_audio_convert_unpack_float_s32 #define orc_audio_convert_unpack_float_be orc_audio_convert_unpack_float_s32_swap +#define orc_audio_convert_unpack_float_hq_le orc_audio_convert_unpack_float_double +#define orc_audio_convert_unpack_float_hq_be orc_audio_convert_unpack_float_double_swap +#define orc_audio_convert_unpack_double_hq_le orc_audio_convert_unpack_double_double +#define orc_audio_convert_unpack_double_hq_be orc_audio_convert_unpack_double_double_swap +#define orc_audio_convert_unpack_u8_float orc_audio_convert_unpack_u8_double +#define orc_audio_convert_unpack_u16_le_float orc_audio_convert_unpack_u16_double +#define orc_audio_convert_unpack_u16_be_float orc_audio_convert_unpack_u16_double_swap +#define orc_audio_convert_unpack_u32_le_float orc_audio_convert_unpack_u32_double +#define orc_audio_convert_unpack_u32_be_float orc_audio_convert_unpack_u32_double_swap +#define orc_audio_convert_unpack_s8_float orc_audio_convert_unpack_s8_double +#define orc_audio_convert_unpack_s16_le_float orc_audio_convert_unpack_s16_double +#define orc_audio_convert_unpack_s16_be_float orc_audio_convert_unpack_s16_double_swap +#define orc_audio_convert_unpack_s32_le_float orc_audio_convert_unpack_s32_double +#define orc_audio_convert_unpack_s32_be_float orc_audio_convert_unpack_s32_double_swap #define orc_audio_convert_pack_u16_le orc_audio_convert_pack_u16 #define orc_audio_convert_pack_u16_be orc_audio_convert_pack_u16_swap #define orc_audio_convert_pack_s16_le orc_audio_convert_pack_s16 @@ -53,6 +67,13 @@ #define orc_audio_convert_pack_s32_be orc_audio_convert_pack_s32_swap #define orc_audio_convert_pack_float_le orc_audio_convert_pack_s32_float #define orc_audio_convert_pack_float_be orc_audio_convert_pack_s32_float_swap +#define orc_audio_convert_pack_float_hq_le orc_audio_convert_pack_double_float +#define orc_audio_convert_pack_float_hq_be orc_audio_convert_pack_double_float_swap +#define orc_audio_convert_pack_s8_float orc_audio_convert_pack_double_s8 +#define orc_audio_convert_pack_s16_le_float orc_audio_convert_pack_double_s16 +#define orc_audio_convert_pack_s16_be_float orc_audio_convert_pack_double_s16_swap +#define orc_audio_convert_pack_s32_le_float orc_audio_convert_pack_double_s32 +#define orc_audio_convert_pack_s32_be_float orc_audio_convert_pack_double_s32_swap #else #define orc_audio_convert_unpack_u16_be orc_audio_convert_unpack_u16 #define orc_audio_convert_unpack_u16_le orc_audio_convert_unpack_u16_swap @@ -64,6 +85,20 @@ #define orc_audio_convert_unpack_s32_le orc_audio_convert_unpack_s32_swap #define orc_audio_convert_unpack_float_be orc_audio_convert_unpack_float_s32 #define orc_audio_convert_unpack_float_le orc_audio_convert_unpack_float_s32_swap +#define orc_audio_convert_unpack_float_hq_be orc_audio_convert_unpack_float_double +#define orc_audio_convert_unpack_float_hq_le orc_audio_convert_unpack_float_double_swap +#define orc_audio_convert_unpack_double_hq_be orc_audio_convert_unpack_double_double +#define orc_audio_convert_unpack_double_hq_le orc_audio_convert_unpack_double_double_swap +#define orc_audio_convert_unpack_u8_float orc_audio_convert_unpack_u8_double +#define orc_audio_convert_unpack_u16_be_float orc_audio_convert_unpack_u16_double +#define orc_audio_convert_unpack_u16_le_float orc_audio_convert_unpack_u16_double_swap +#define orc_audio_convert_unpack_u32_be_float orc_audio_convert_unpack_u32_double +#define orc_audio_convert_unpack_u32_le_float orc_audio_convert_unpack_u32_double_swap +#define orc_audio_convert_unpack_s8_float orc_audio_convert_unpack_s8_double +#define orc_audio_convert_unpack_s16_be_float orc_audio_convert_unpack_s16_double +#define orc_audio_convert_unpack_s16_le_float orc_audio_convert_unpack_s16_double_swap +#define orc_audio_convert_unpack_s32_be_float orc_audio_convert_unpack_s32_double +#define orc_audio_convert_unpack_s32_le_float orc_audio_convert_unpack_s32_double_swap #define orc_audio_convert_pack_u16_be orc_audio_convert_pack_u16 #define orc_audio_convert_pack_u16_le orc_audio_convert_pack_u16_swap #define orc_audio_convert_pack_s16_be orc_audio_convert_pack_s16 @@ -74,6 +109,13 @@ #define orc_audio_convert_pack_s32_le orc_audio_convert_pack_s32_swap #define orc_audio_convert_pack_float_be orc_audio_convert_pack_s32_float #define orc_audio_convert_pack_float_le orc_audio_convert_pack_s32_float_swap +#define orc_audio_convert_pack_float_hq_be orc_audio_convert_pack_double_float +#define orc_audio_convert_pack_float_hq_le orc_audio_convert_pack_double_float_swap +#define orc_audio_convert_pack_s8_float orc_audio_convert_pack_double_s8 +#define orc_audio_convert_pack_s16_be_float orc_audio_convert_pack_double_s16 +#define orc_audio_convert_pack_s16_le_float orc_audio_convert_pack_double_s16_swap +#define orc_audio_convert_pack_s32_be_float orc_audio_convert_pack_double_s32 +#define orc_audio_convert_pack_s32_le_float orc_audio_convert_pack_double_s32_swap #endif /* sign bit in the intermediate format */ @@ -140,6 +182,15 @@ MAKE_UNPACK_FUNC_NAME (name) (type * src, gdouble * dst, gint s, \ *dst++ = (gdouble) FUNC (*src++); \ } +/* unpack from float to float 64 (double) with orc */ +#define MAKE_UNPACK_FUNC_ORC_FF(name, type, FUNC) \ +static void \ +MAKE_UNPACK_FUNC_NAME (name) (type * src, gdouble * dst, gint s, \ + gint count) \ +{ \ + MAKE_ORC_UNPACK_FUNC_NAME (name) ((gdouble *) dst, src, count); \ +} + /* unpack from int to float 64 (double) */ #define MAKE_UNPACK_FUNC_IF(name, stride, sign, READ_FUNC) \ static void \ @@ -154,6 +205,14 @@ MAKE_UNPACK_FUNC_NAME (name) (guint8 * src, gdouble * dst, gint scale, \ } \ } +#define MAKE_UNPACK_FUNC_ORC_IF(name, stride, sign, READ_FUNC) \ +static void \ +MAKE_UNPACK_FUNC_NAME (name) (guint8 *src, gdouble *dst, \ + gint scale, gint count) \ +{ \ + MAKE_ORC_UNPACK_FUNC_NAME (name) (dst, src, scale, count); \ +} + #define READ8(p) GST_READ_UINT8(p) #define READ16_FROM_LE(p) GST_READ_UINT16_LE (p) #define READ16_FROM_BE(p) GST_READ_UINT16_BE (p) @@ -182,24 +241,24 @@ MAKE_UNPACK_FUNC_ORC_FI (float_le, gfloat, GFLOAT_FROM_LE); MAKE_UNPACK_FUNC_ORC_FI (float_be, gfloat, GFLOAT_FROM_BE); MAKE_UNPACK_FUNC_FI (double_le, gdouble, GDOUBLE_FROM_LE); MAKE_UNPACK_FUNC_FI (double_be, gdouble, GDOUBLE_FROM_BE); -MAKE_UNPACK_FUNC_FF (float_hq_le, gfloat, GFLOAT_FROM_LE); -MAKE_UNPACK_FUNC_FF (float_hq_be, gfloat, GFLOAT_FROM_BE); -MAKE_UNPACK_FUNC_FF (double_hq_le, gdouble, GDOUBLE_FROM_LE); -MAKE_UNPACK_FUNC_FF (double_hq_be, gdouble, GDOUBLE_FROM_BE); -MAKE_UNPACK_FUNC_IF (u8_float, 1, SIGNED, READ8); -MAKE_UNPACK_FUNC_IF (s8_float, 1, 0, READ8); -MAKE_UNPACK_FUNC_IF (u16_le_float, 2, SIGNED, READ16_FROM_LE); -MAKE_UNPACK_FUNC_IF (s16_le_float, 2, 0, READ16_FROM_LE); -MAKE_UNPACK_FUNC_IF (u16_be_float, 2, SIGNED, READ16_FROM_BE); -MAKE_UNPACK_FUNC_IF (s16_be_float, 2, 0, READ16_FROM_BE); +MAKE_UNPACK_FUNC_ORC_FF (float_hq_le, gfloat, GFLOAT_FROM_LE); +MAKE_UNPACK_FUNC_ORC_FF (float_hq_be, gfloat, GFLOAT_FROM_BE); +MAKE_UNPACK_FUNC_ORC_FF (double_hq_le, gdouble, GDOUBLE_FROM_LE); +MAKE_UNPACK_FUNC_ORC_FF (double_hq_be, gdouble, GDOUBLE_FROM_BE); +MAKE_UNPACK_FUNC_ORC_IF (u8_float, 1, SIGNED, READ8); +MAKE_UNPACK_FUNC_ORC_IF (s8_float, 1, 0, READ8); +MAKE_UNPACK_FUNC_ORC_IF (u16_le_float, 2, SIGNED, READ16_FROM_LE); +MAKE_UNPACK_FUNC_ORC_IF (s16_le_float, 2, 0, READ16_FROM_LE); +MAKE_UNPACK_FUNC_ORC_IF (u16_be_float, 2, SIGNED, READ16_FROM_BE); +MAKE_UNPACK_FUNC_ORC_IF (s16_be_float, 2, 0, READ16_FROM_BE); MAKE_UNPACK_FUNC_IF (u24_le_float, 3, SIGNED, READ24_FROM_LE); MAKE_UNPACK_FUNC_IF (s24_le_float, 3, 0, READ24_FROM_LE); MAKE_UNPACK_FUNC_IF (u24_be_float, 3, SIGNED, READ24_FROM_BE); MAKE_UNPACK_FUNC_IF (s24_be_float, 3, 0, READ24_FROM_BE); -MAKE_UNPACK_FUNC_IF (u32_le_float, 4, SIGNED, READ32_FROM_LE); -MAKE_UNPACK_FUNC_IF (s32_le_float, 4, 0, READ32_FROM_LE); -MAKE_UNPACK_FUNC_IF (u32_be_float, 4, SIGNED, READ32_FROM_BE); -MAKE_UNPACK_FUNC_IF (s32_be_float, 4, 0, READ32_FROM_BE); +MAKE_UNPACK_FUNC_ORC_IF (u32_le_float, 4, SIGNED, READ32_FROM_LE); +MAKE_UNPACK_FUNC_ORC_IF (s32_le_float, 4, 0, READ32_FROM_LE); +MAKE_UNPACK_FUNC_ORC_IF (u32_be_float, 4, SIGNED, READ32_FROM_BE); +MAKE_UNPACK_FUNC_ORC_IF (s32_be_float, 4, 0, READ32_FROM_BE); /* One of the double_hq_* functions generated above is ineffecient, but it's * never used anyway. The same is true for one of the s32_* functions. */ @@ -276,6 +335,15 @@ MAKE_PACK_FUNC_NAME (name) (gdouble * src, type * dst, gint s, \ *dst++ = FUNC ((type) (*src++)); \ } +/* pack from float 64 (double) to float with orc */ +#define MAKE_PACK_FUNC_ORC_FF(name, type, FUNC) \ +static void \ +MAKE_PACK_FUNC_NAME (name) (gdouble * src, type * dst, gint s, \ + gint count) \ +{ \ + MAKE_PACK_FUNC_NAME_ORC (name) (dst, src, count); \ +} + /* pack from float 64 (double) to signed int. * the floats are already in the correct range. Only a cast is needed. */ @@ -312,6 +380,17 @@ MAKE_PACK_FUNC_NAME (name) (gdouble * src, guint8 * dst, gint scale, \ } \ } +/* pack from float 64 (double) to signed int with orc. + * the floats are already in the correct range. Only a cast is needed. + */ +#define MAKE_PACK_FUNC_ORC_FI_S(name, stride, WRITE_FUNC) \ +static void \ +MAKE_PACK_FUNC_NAME (name) (gdouble * src, guint8 * dst, gint scale, \ + gint count) \ +{ \ + MAKE_PACK_FUNC_NAME_ORC (name) (dst, src, scale, count); \ +} + #define WRITE8(p, v) GST_WRITE_UINT8 (p, v) #define WRITE16_TO_LE(p,v) GST_WRITE_UINT16_LE (p, (guint16)(v)) #define WRITE16_TO_BE(p,v) GST_WRITE_UINT16_BE (p, (guint16)(v)) @@ -338,22 +417,22 @@ MAKE_PACK_FUNC_ORC_IF (float_le, gfloat, GFLOAT_TO_LE); MAKE_PACK_FUNC_ORC_IF (float_be, gfloat, GFLOAT_TO_BE); MAKE_PACK_FUNC_IF (double_le, gdouble, GDOUBLE_TO_LE); MAKE_PACK_FUNC_IF (double_be, gdouble, GDOUBLE_TO_BE); -MAKE_PACK_FUNC_FF (float_hq_le, gfloat, GFLOAT_TO_LE); -MAKE_PACK_FUNC_FF (float_hq_be, gfloat, GFLOAT_TO_BE); +MAKE_PACK_FUNC_ORC_FF (float_hq_le, gfloat, GFLOAT_TO_LE); +MAKE_PACK_FUNC_ORC_FF (float_hq_be, gfloat, GFLOAT_TO_BE); MAKE_PACK_FUNC_FI_U (u8_float, 1, WRITE8); -MAKE_PACK_FUNC_FI_S (s8_float, 1, WRITE8); +MAKE_PACK_FUNC_ORC_FI_S (s8_float, 1, WRITE8); MAKE_PACK_FUNC_FI_U (u16_le_float, 2, WRITE16_TO_LE); -MAKE_PACK_FUNC_FI_S (s16_le_float, 2, WRITE16_TO_LE); +MAKE_PACK_FUNC_ORC_FI_S (s16_le_float, 2, WRITE16_TO_LE); MAKE_PACK_FUNC_FI_U (u16_be_float, 2, WRITE16_TO_BE); -MAKE_PACK_FUNC_FI_S (s16_be_float, 2, WRITE16_TO_BE); +MAKE_PACK_FUNC_ORC_FI_S (s16_be_float, 2, WRITE16_TO_BE); MAKE_PACK_FUNC_FI_U (u24_le_float, 3, WRITE24_TO_LE); MAKE_PACK_FUNC_FI_S (s24_le_float, 3, WRITE24_TO_LE); MAKE_PACK_FUNC_FI_U (u24_be_float, 3, WRITE24_TO_BE); MAKE_PACK_FUNC_FI_S (s24_be_float, 3, WRITE24_TO_BE); MAKE_PACK_FUNC_FI_U (u32_le_float, 4, WRITE32_TO_LE); -MAKE_PACK_FUNC_FI_S (s32_le_float, 4, WRITE32_TO_LE); +MAKE_PACK_FUNC_ORC_FI_S (s32_le_float, 4, WRITE32_TO_LE); MAKE_PACK_FUNC_FI_U (u32_be_float, 4, WRITE32_TO_BE); -MAKE_PACK_FUNC_FI_S (s32_be_float, 4, WRITE32_TO_BE); +MAKE_PACK_FUNC_ORC_FI_S (s32_be_float, 4, WRITE32_TO_BE); /* For double_hq, packing and unpacking is the same, so we reuse the unpacking * functions here. */ diff --git a/gst/audioconvert/gstaudioconvertorc.orc b/gst/audioconvert/gstaudioconvertorc.orc index a78718e..ac6b660 100644 --- a/gst/audioconvert/gstaudioconvertorc.orc +++ b/gst/audioconvert/gstaudioconvertorc.orc @@ -159,6 +159,148 @@ andnl t4, t4, t3 # 0x80000000 + ~0 = 0x7fffffff addl d1, t2, t4 +.function orc_audio_convert_unpack_float_double +.dest 8 d1 gdouble +.source 4 s1 gfloat + +convfd d1, s1 + +.function orc_audio_convert_unpack_float_double_swap +.dest 8 d1 gdouble +.source 4 s1 gfloat +.temp 4 t1 + +swapl t1, s1 +convfd d1, t1 + +.function orc_audio_convert_unpack_double_double +.dest 8 d1 gdouble +.source 8 s1 gdouble + +copyq d1, s1 + +.function orc_audio_convert_unpack_double_double_swap +.dest 8 d1 gdouble +.source 8 s1 gdouble + +swapq d1, s1 + +.function orc_audio_convert_unpack_u8_double +.dest 8 d1 gdouble +.source 1 s1 guint8 +.param 4 p1 +.const 4 c1 0x80000000 +.temp 2 t2 +.temp 4 t3 + +convubw t2, s1 +convuwl t3, t2 +shll t3, t3, p1 +xorl t3, t3, c1 +convld d1, t3 + +.function orc_audio_convert_unpack_s8_double +.dest 8 d1 gdouble +.source 1 s1 guint8 +.param 4 p1 +.temp 2 t2 +.temp 4 t3 + +convubw t2, s1 +convuwl t3, t2 +shll t3, t3, p1 +convld d1, t3 + +.function orc_audio_convert_unpack_u16_double +.dest 8 d1 gdouble +.source 2 s1 guint8 +.param 4 p1 +.const 4 c1 0x80000000 +.temp 4 t2 + +convuwl t2, s1 +shll t2, t2, p1 +xorl t2, t2, c1 +convld d1, t2 + +.function orc_audio_convert_unpack_s16_double +.dest 8 d1 gdouble +.source 2 s1 guint8 +.param 4 p1 +.temp 4 t2 + +convuwl t2, s1 +shll t2, t2, p1 +convld d1, t2 + +.function orc_audio_convert_unpack_u16_double_swap +.dest 8 d1 gdouble +.source 2 s1 guint8 +.param 4 p1 +.const 4 c1 0x80000000 +.temp 2 t1 +.temp 4 t2 + +swapw t1, s1 +convuwl t2, t1 +shll t2, t2, p1 +xorl t2, t2, c1 +convld d1, t2 + +.function orc_audio_convert_unpack_s16_double_swap +.dest 8 d1 gdouble +.source 2 s1 guint8 +.param 4 p1 +.temp 2 t1 +.temp 4 t2 + +swapw t1, s1 +convuwl t2, t1 +shll t2, t2, p1 +convld d1, t2 + +.function orc_audio_convert_unpack_u32_double +.dest 8 d1 gdouble +.source 4 s1 guint8 +.param 4 p1 +.const 4 c1 0x80000000 +.temp 4 t1 + +shll t1, s1, p1 +xorl t1, t1, c1 +convld d1, t1 + +.function orc_audio_convert_unpack_s32_double +.dest 8 d1 gdouble +.source 4 s1 guint8 +.param 4 p1 +.temp 4 t1 + +shll t1, s1, p1 +convld d1, t1 + +.function orc_audio_convert_unpack_u32_double_swap +.dest 8 d1 gdouble +.source 4 s1 guint8 +.param 4 p1 +.const 4 c1 0x80000000 +.temp 4 t1 + +swapl t1, s1 +shll t1, t1, p1 +xorl t1, t1, c1 +convld d1, t1 + +.function orc_audio_convert_unpack_s32_double_swap +.dest 8 d1 gdouble +.source 4 s1 guint8 +.param 4 p1 +.temp 4 t1 + +swapl t1, s1 +shll t1, t1, p1 +convld d1, t1 + .function orc_audio_convert_pack_u8 .dest 1 d1 guint8 .source 4 s1 gint32 @@ -295,3 +437,70 @@ convlf t1, s1 divf t1, t1, 0x4F000000 swapl d1, t1 +.function orc_audio_convert_pack_double_float +.dest 4 d1 gfloat +.source 8 s1 gdouble + +convdf d1, s1 + +.function orc_audio_convert_pack_double_float_swap +.dest 4 d1 gfloat +.source 8 s1 gdouble +.temp 4 t1 + +convdf t1, s1 +swapl d1, t1 + +.function orc_audio_convert_pack_double_s8 +.dest 1 d1 guint8 +.source 8 s1 gdouble +.param 4 p1 +.temp 4 t1 +.temp 2 t2 + +convdl t1, s1 +shrsl t1, t1, p1 +convlw t2, t1 +convwb d1, t2 + +.function orc_audio_convert_pack_double_s16 +.dest 2 d1 guint8 +.source 8 s1 gdouble +.param 4 p1 +.temp 4 t1 + +convdl t1, s1 +shrsl t1, t1, p1 +convlw d1, t1 + +.function orc_audio_convert_pack_double_s16_swap +.dest 2 d1 guint8 +.source 8 s1 gdouble +.param 4 p1 +.temp 4 t1 +.temp 2 t2 + +convdl t1, s1 +shrsl t1, t1, p1 +convlw t2, t1 +swapw d1, t2 + +.function orc_audio_convert_pack_double_s32 +.dest 4 d1 guint8 +.source 8 s1 gdouble +.param 4 p1 +.temp 4 t1 + +convdl t1, s1 +shrsl d1, t1, p1 + +.function orc_audio_convert_pack_double_s32_swap +.dest 4 d1 guint8 +.source 8 s1 gdouble +.param 4 p1 +.temp 4 t1 + +convdl t1, s1 +shrsl t1, t1, p1 +swapl d1, t1 +