From 3dd26bb9e8ea1f511c7e812a9c0ba827f5390c19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 1 Nov 2015 23:05:10 +0000 Subject: [PATCH] audioconvert: update orc backup code to fix build without orc --- gst/audioconvert/gstaudioconvertorc-dist.c | 276 +++++++++++++++++++++++++++++ gst/audioconvert/gstaudioconvertorc-dist.h | 2 + 2 files changed, 278 insertions(+) diff --git a/gst/audioconvert/gstaudioconvertorc-dist.c b/gst/audioconvert/gstaudioconvertorc-dist.c index 869bc18..66057ac 100644 --- a/gst/audioconvert/gstaudioconvertorc-dist.c +++ b/gst/audioconvert/gstaudioconvertorc-dist.c @@ -99,6 +99,11 @@ void audio_convert_orc_s32_to_double (gdouble * ORC_RESTRICT d1, const gint32 * ORC_RESTRICT s1, int n); void audio_convert_orc_double_to_s32 (gint32 * ORC_RESTRICT d1, const gdouble * ORC_RESTRICT s1, int n); +void audio_convert_orc_int_bias (gint32 * ORC_RESTRICT d1, + const gint32 * ORC_RESTRICT s1, int p1, int p2, int n); +void audio_convert_orc_int_dither (gint32 * ORC_RESTRICT d1, + const gint32 * ORC_RESTRICT s1, const gint32 * ORC_RESTRICT s2, int p1, + int n); /* begin Orc C target preamble */ @@ -454,3 +459,274 @@ audio_convert_orc_double_to_s32 (gint32 * ORC_RESTRICT d1, func (ex); } #endif + + +/* audio_convert_orc_int_bias */ +#ifdef DISABLE_ORC +void +audio_convert_orc_int_bias (gint32 * ORC_RESTRICT d1, + const gint32 * ORC_RESTRICT s1, int p1, int p2, int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var33; + orc_union32 var34; + orc_union32 var35; + orc_union32 var36; + orc_union32 var37; + + ptr0 = (orc_union32 *) d1; + ptr4 = (orc_union32 *) s1; + + /* 1: loadpl */ + var34.i = p1; + /* 3: loadpl */ + var35.i = p2; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 2: addssl */ + var37.i = ORC_CLAMP_SL ((orc_int64) var33.i + (orc_int64) var34.i); + /* 4: andl */ + var36.i = var37.i & var35.i; + /* 5: storel */ + ptr0[i] = var36; + } + +} + +#else +static void +_backup_audio_convert_orc_int_bias (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + orc_union32 var33; + orc_union32 var34; + orc_union32 var35; + orc_union32 var36; + orc_union32 var37; + + ptr0 = (orc_union32 *) ex->arrays[0]; + ptr4 = (orc_union32 *) ex->arrays[4]; + + /* 1: loadpl */ + var34.i = ex->params[24]; + /* 3: loadpl */ + var35.i = ex->params[25]; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 2: addssl */ + var37.i = ORC_CLAMP_SL ((orc_int64) var33.i + (orc_int64) var34.i); + /* 4: andl */ + var36.i = var37.i & var35.i; + /* 5: storel */ + ptr0[i] = var36; + } + +} + +void +audio_convert_orc_int_bias (gint32 * ORC_RESTRICT d1, + const gint32 * ORC_RESTRICT s1, int p1, int p2, int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 26, 97, 117, 100, 105, 111, 95, 99, 111, 110, 118, 101, 114, 116, + 95, 111, 114, 99, 95, 105, 110, 116, 95, 98, 105, 97, 115, 11, 4, 4, + 12, 4, 4, 16, 4, 16, 4, 20, 4, 104, 32, 4, 24, 106, 0, 32, + 25, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_audio_convert_orc_int_bias); +#else + p = orc_program_new (); + orc_program_set_name (p, "audio_convert_orc_int_bias"); + orc_program_set_backup_function (p, _backup_audio_convert_orc_int_bias); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_parameter (p, 4, "p1"); + orc_program_add_parameter (p, 4, "p2"); + orc_program_add_temporary (p, 4, "t1"); + + orc_program_append_2 (p, "addssl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_P1, + ORC_VAR_D1); + orc_program_append_2 (p, "andl", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_P2, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->params[ORC_VAR_P1] = p1; + ex->params[ORC_VAR_P2] = p2; + + func = c->exec; + func (ex); +} +#endif + + +/* audio_convert_orc_int_dither */ +#ifdef DISABLE_ORC +void +audio_convert_orc_int_dither (gint32 * ORC_RESTRICT d1, + const gint32 * ORC_RESTRICT s1, const gint32 * ORC_RESTRICT s2, int p1, + int n) +{ + int i; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + const orc_union32 *ORC_RESTRICT ptr5; + orc_union32 var33; + orc_union32 var34; + orc_union32 var35; + orc_union32 var36; + orc_union32 var37; + + ptr0 = (orc_union32 *) d1; + ptr4 = (orc_union32 *) s1; + ptr5 = (orc_union32 *) s2; + + /* 3: loadpl */ + var35.i = p1; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 1: loadl */ + var34 = ptr5[i]; + /* 2: addssl */ + var37.i = ORC_CLAMP_SL ((orc_int64) var33.i + (orc_int64) var34.i); + /* 4: andl */ + var36.i = var37.i & var35.i; + /* 5: storel */ + ptr0[i] = var36; + } + +} + +#else +static void +_backup_audio_convert_orc_int_dither (OrcExecutor * ORC_RESTRICT ex) +{ + int i; + int n = ex->n; + orc_union32 *ORC_RESTRICT ptr0; + const orc_union32 *ORC_RESTRICT ptr4; + const orc_union32 *ORC_RESTRICT ptr5; + orc_union32 var33; + orc_union32 var34; + orc_union32 var35; + orc_union32 var36; + orc_union32 var37; + + ptr0 = (orc_union32 *) ex->arrays[0]; + ptr4 = (orc_union32 *) ex->arrays[4]; + ptr5 = (orc_union32 *) ex->arrays[5]; + + /* 3: loadpl */ + var35.i = ex->params[24]; + + for (i = 0; i < n; i++) { + /* 0: loadl */ + var33 = ptr4[i]; + /* 1: loadl */ + var34 = ptr5[i]; + /* 2: addssl */ + var37.i = ORC_CLAMP_SL ((orc_int64) var33.i + (orc_int64) var34.i); + /* 4: andl */ + var36.i = var37.i & var35.i; + /* 5: storel */ + ptr0[i] = var36; + } + +} + +void +audio_convert_orc_int_dither (gint32 * ORC_RESTRICT d1, + const gint32 * ORC_RESTRICT s1, const gint32 * ORC_RESTRICT s2, int p1, + int n) +{ + OrcExecutor _ex, *ex = &_ex; + static volatile int p_inited = 0; + static OrcCode *c = 0; + void (*func) (OrcExecutor *); + + if (!p_inited) { + orc_once_mutex_lock (); + if (!p_inited) { + OrcProgram *p; + +#if 1 + static const orc_uint8 bc[] = { + 1, 9, 28, 97, 117, 100, 105, 111, 95, 99, 111, 110, 118, 101, 114, 116, + 95, 111, 114, 99, 95, 105, 110, 116, 95, 100, 105, 116, 104, 101, 114, + 11, + 4, 4, 12, 4, 4, 12, 4, 4, 16, 4, 20, 4, 104, 32, 4, 5, + 106, 0, 32, 24, 2, 0, + }; + p = orc_program_new_from_static_bytecode (bc); + orc_program_set_backup_function (p, _backup_audio_convert_orc_int_dither); +#else + p = orc_program_new (); + orc_program_set_name (p, "audio_convert_orc_int_dither"); + orc_program_set_backup_function (p, _backup_audio_convert_orc_int_dither); + orc_program_add_destination (p, 4, "d1"); + orc_program_add_source (p, 4, "s1"); + orc_program_add_source (p, 4, "s2"); + orc_program_add_parameter (p, 4, "p1"); + orc_program_add_temporary (p, 4, "t1"); + + orc_program_append_2 (p, "addssl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_S2, + ORC_VAR_D1); + orc_program_append_2 (p, "andl", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_P1, + ORC_VAR_D1); +#endif + + orc_program_compile (p); + c = orc_program_take_code (p); + orc_program_free (p); + } + p_inited = TRUE; + orc_once_mutex_unlock (); + } + ex->arrays[ORC_VAR_A2] = c; + ex->program = 0; + + ex->n = n; + ex->arrays[ORC_VAR_D1] = d1; + ex->arrays[ORC_VAR_S1] = (void *) s1; + ex->arrays[ORC_VAR_S2] = (void *) s2; + ex->params[ORC_VAR_P1] = p1; + + func = c->exec; + func (ex); +} +#endif diff --git a/gst/audioconvert/gstaudioconvertorc-dist.h b/gst/audioconvert/gstaudioconvertorc-dist.h index a642e80..27021a2 100644 --- a/gst/audioconvert/gstaudioconvertorc-dist.h +++ b/gst/audioconvert/gstaudioconvertorc-dist.h @@ -82,6 +82,8 @@ typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 void audio_convert_orc_s32_to_double (gdouble * ORC_RESTRICT d1, const gint32 * ORC_RESTRICT s1, int n); void audio_convert_orc_double_to_s32 (gint32 * ORC_RESTRICT d1, const gdouble * ORC_RESTRICT s1, int n); +void audio_convert_orc_int_bias (gint32 * ORC_RESTRICT d1, const gint32 * ORC_RESTRICT s1, int p1, int p2, int n); +void audio_convert_orc_int_dither (gint32 * ORC_RESTRICT d1, const gint32 * ORC_RESTRICT s1, const gint32 * ORC_RESTRICT s2, int p1, int n); #ifdef __cplusplus } -- 2.7.4