#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <orc/orc.h>
#include <orc/orcprogram.h>
"t13", "t14", "t15", "t16"
};
+static void
+get_varname (char *s, OrcCompiler *compiler, int var)
+{
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ sprintf(s, "ex->arrays[%d]", var);
+ } else {
+ strcpy (s, varnames[var]);
+ }
+}
+
+static void
+get_varname_stride (char *s, OrcCompiler *compiler, int var)
+{
+ if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
+ sprintf(s, "ex->params[%d]", var);
+ } else {
+ sprintf(s, "%s_stride", varnames[var]);
+ }
+}
+
void
orc_compiler_c_assemble (OrcCompiler *compiler)
{
if (var->name == NULL) continue;
switch (var->vartype) {
case ORC_VAR_TYPE_SRC:
- if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
- ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(ex->arrays[%d], ex->params[%d] * j);\n",
- i, i, i);
- } else {
- ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(%s, %s_stride * j);\n",
- i, varnames[i], varnames[i]);
+ {
+ char s1[20], s2[20];
+ get_varname(s1, compiler, i);
+ get_varname_stride(s2, compiler, i);
+ switch (var->sampling_type) {
+ case ORC_SAMPLE_REGULAR:
+ ORC_ASM_CODE(compiler,
+ " var%d = ORC_PTR_OFFSET(%s, %s * j);\n",
+ i, s1, s2);
+ break;
+ case ORC_SAMPLE_TRANSPOSED:
+ ORC_ASM_CODE(compiler,
+ " var%d = ORC_PTR_OFFSET(%s, %d * j);\n",
+ i, s1, var->size);
+ break;
+ case ORC_SAMPLE_NEAREST:
+ case ORC_SAMPLE_BILINEAR:
+ case ORC_SAMPLE_FOUR_TAP:
+ ORC_ASM_CODE(compiler,
+ " var%d = ORC_PTR_OFFSET(%s, %s * j);\n",
+ i, s1, s2);
+ break;
+ default:
+ ORC_COMPILER_ERROR(compiler, "eeek");
+ }
}
break;
case ORC_VAR_TYPE_DEST:
- if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
- ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(ex->arrays[%d], ex->params[%d] * j);\n",
- i, i, i);
- } else {
- ORC_ASM_CODE(compiler," var%d = ORC_PTR_OFFSET(%s, %s_stride * j);\n",
- i, varnames[i], varnames[i]);
+ {
+ char s1[20], s2[20];
+ get_varname(s1, compiler, i),
+ get_varname_stride(s2, compiler, i),
+ ORC_ASM_CODE(compiler,
+ " var%d = ORC_PTR_OFFSET(%s, %s * j);\n",
+ i, s1, s2);
}
break;
default:
} else {
for(i=0;i<ORC_N_VARIABLES;i++){
OrcVariable *var = compiler->vars + i;
+ char s[20];
if (var->name == NULL) continue;
+ get_varname(s, compiler, i);
switch (var->vartype) {
case ORC_VAR_TYPE_SRC:
- if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
- ORC_ASM_CODE(compiler," var%d = ex->arrays[%d];\n", i, i);
- } else {
- ORC_ASM_CODE(compiler," var%d = (void *)%s;\n", i, varnames[i]);
- }
+ ORC_ASM_CODE(compiler," var%d = %s;\n", i, s);
break;
case ORC_VAR_TYPE_DEST:
- if (!(compiler->target_flags & ORC_TARGET_C_NOEXEC)) {
- ORC_ASM_CODE(compiler," var%d = ex->arrays[%d];\n", i, i);
- } else {
- ORC_ASM_CODE(compiler," var%d = (void *)%s;\n", i, varnames[i]);
- }
+ ORC_ASM_CODE(compiler," var%d = %s;\n", i, s);
break;
default:
break;
sprintf(name, "var%d", var);
break;
case ORC_VAR_TYPE_SRC:
+ switch(p->vars[var].sampling_type) {
+ case ORC_SAMPLE_REGULAR:
+ sprintf(name, "var%d[i]", var);
+ break;
+ case ORC_SAMPLE_TRANSPOSED:
+ {
+ char s2[20];
+ get_varname_stride(s2, p, var);
+ sprintf(name, "ORC_PTR_OFFSET(var%d, %s * i)", var, s2);
+ }
+ break;
+ case ORC_SAMPLE_NEAREST:
+ case ORC_SAMPLE_BILINEAR:
+ case ORC_SAMPLE_FOUR_TAP:
+ sprintf(name, "var%d[i]", var);
+ break;
+ default:
+ ORC_COMPILER_ERROR(p, "eeek");
+ break;
+ }
+ break;
case ORC_VAR_TYPE_DEST:
sprintf(name, "var%d[i]", var);
break;
ORC_CONST_SPLAT_L,
};
+enum {
+ ORC_SAMPLE_REGULAR = 0,
+ ORC_SAMPLE_TRANSPOSED,
+ ORC_SAMPLE_NEAREST,
+ ORC_SAMPLE_BILINEAR,
+ ORC_SAMPLE_FOUR_TAP
+};
+
typedef enum {
ORC_COMPILE_RESULT_OK = 0,
int ptr_offset;
int mask_alloc;
int aligned_data;
+ int sampling_type;
};
/**
/* m is stored in params[ORC_VAR_A1] */
/* m_index is stored in params[ORC_VAR_A2] */
/* elapsed time is stored in params[ORC_VAR_A3] */
+ /* source resampling parameters are in params[ORC_VAR_C1..C8] */
};
/* the alternate view of OrcExecutor */
int m;
int m_index;
int time;
- int unused2[ORC_VAR_P1-ORC_VAR_A4];
+ int unused2;
+ int src_resample[8];
int params[ORC_VAR_T1-ORC_VAR_P1];
int unused3[ORC_N_VARIABLES - ORC_VAR_T1];
int accumulators[4];
int orc_program_add_parameter (OrcProgram *program, int size, const char *name);
int orc_program_add_accumulator (OrcProgram *program, int size, const char *name);
void orc_program_set_type_name (OrcProgram *program, int var, const char *type_name);
+void orc_program_set_sampling_type (OrcProgram *program, int var, int sampling_type);
OrcExecutor * orc_executor_new (OrcProgram *program);
void orc_executor_free (OrcExecutor *ex);