void output_code_backup (OrcProgram *p, FILE *output) { fprintf(output, "static void\n"); if (compat < ORC_VERSION(0,4,7,1)) { fprintf(output, "_backup_%s (OrcExecutor * ex)\n", p->name); } else { fprintf(output, "_backup_%s (OrcExecutor * ORC_RESTRICT ex)\n", p->name); } fprintf(output, "{\n"); { OrcCompileResult result; result = orc_program_compile_full (p, orc_target_get_by_name("c"), ORC_TARGET_C_BARE); if (ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { fprintf(output, "%s\n", orc_program_get_asm_code (p)); } else { fprintf(stderr, "Failed to compile backup code for '%s'\n", p->name); error = TRUE; } } fprintf(output, "}\n"); fprintf(output, "\n"); }
static void gst_dtsdec_class_init (GstDtsDecClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; GstAudioDecoderClass *gstbase_class; guint cpuflags; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; gstbase_class = (GstAudioDecoderClass *) klass; gobject_class->set_property = gst_dtsdec_set_property; gobject_class->get_property = gst_dtsdec_get_property; gst_element_class_add_static_pad_template (gstelement_class, &sink_factory); gst_element_class_add_static_pad_template (gstelement_class, &src_factory); gst_element_class_set_static_metadata (gstelement_class, "DTS audio decoder", "Codec/Decoder/Audio", "Decodes DTS audio streams", "Jan Schmidt <*****@*****.**>, " "Ronald Bultje <*****@*****.**>"); gstbase_class->start = GST_DEBUG_FUNCPTR (gst_dtsdec_start); gstbase_class->stop = GST_DEBUG_FUNCPTR (gst_dtsdec_stop); gstbase_class->set_format = GST_DEBUG_FUNCPTR (gst_dtsdec_set_format); gstbase_class->parse = GST_DEBUG_FUNCPTR (gst_dtsdec_parse); gstbase_class->handle_frame = GST_DEBUG_FUNCPTR (gst_dtsdec_handle_frame); /** * GstDtsDec::drc * * Set to true to apply the recommended DTS dynamic range compression * to the audio stream. Dynamic range compression makes loud sounds * softer and soft sounds louder, so you can more easily listen * to the stream without disturbing other people. */ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DRC, g_param_spec_boolean ("drc", "Dynamic Range Compression", "Use Dynamic Range Compression", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); klass->dts_cpuflags = 0; #if HAVE_ORC cpuflags = orc_target_get_default_flags (orc_target_get_by_name ("mmx")); if (cpuflags & ORC_TARGET_MMX_MMX) klass->dts_cpuflags |= MM_ACCEL_X86_MMX; if (cpuflags & ORC_TARGET_MMX_3DNOW) klass->dts_cpuflags |= MM_ACCEL_X86_3DNOW; if (cpuflags & ORC_TARGET_MMX_MMXEXT) klass->dts_cpuflags |= MM_ACCEL_X86_MMXEXT; #else cpuflags = 0; klass->dts_cpuflags = 0; #endif GST_LOG ("CPU flags: dts=%08x, orc=%08x", klass->dts_cpuflags, cpuflags); }
const char * orc_target_get_asm_preamble (const char *target) { OrcTarget *t; t = orc_target_get_by_name (target); if (t == NULL) return ""; return orc_target_get_preamble (t); }
static void change_context (GstPostProc * postproc, gint width, gint height) { guint mmx_flags; guint altivec_flags; gint ppflags; GST_DEBUG_OBJECT (postproc, "change_context, width:%d, height:%d", width, height); if ((width != postproc->width) && (height != postproc->height)) { if (postproc->context) pp_free_context (postproc->context); #ifdef HAVE_ORC mmx_flags = orc_target_get_default_flags (orc_target_get_by_name ("mmx")); altivec_flags = orc_target_get_default_flags (orc_target_get_by_name ("altivec")); ppflags = (mmx_flags & ORC_TARGET_MMX_MMX ? PP_CPU_CAPS_MMX : 0) | (mmx_flags & ORC_TARGET_MMX_MMXEXT ? PP_CPU_CAPS_MMX2 : 0) | (mmx_flags & ORC_TARGET_MMX_3DNOW ? PP_CPU_CAPS_3DNOW : 0) | (altivec_flags & ORC_TARGET_ALTIVEC_ALTIVEC ? PP_CPU_CAPS_ALTIVEC : 0); #else mmx_flags = 0; altivec_flags = 0; ppflags = 0; #endif postproc->context = pp_get_context (width, height, PP_FORMAT_420 | ppflags); postproc->width = width; postproc->height = height; postproc->ystride = ROUND_UP_4 (width); postproc->ustride = ROUND_UP_8 (width) / 2; postproc->vstride = ROUND_UP_8 (postproc->ystride) / 2; postproc->ysize = postproc->ystride * ROUND_UP_2 (height); postproc->usize = postproc->ustride * ROUND_UP_2 (height) / 2; postproc->vsize = postproc->vstride * ROUND_UP_2 (height) / 2; GST_DEBUG_OBJECT (postproc, "new strides are (YUV) : %d %d %d", postproc->ystride, postproc->ustride, postproc->vstride); } }
static void gst_deinterlace_method_greedy_l_class_init (GstDeinterlaceMethodGreedyLClass * klass) { GstDeinterlaceMethodClass *dim_class = (GstDeinterlaceMethodClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass; #ifdef BUILD_X86_ASM guint cpu_flags = orc_target_get_default_flags (orc_target_get_by_name ("mmx")); #endif gobject_class->set_property = gst_deinterlace_method_greedy_l_set_property; gobject_class->get_property = gst_deinterlace_method_greedy_l_get_property; g_object_class_install_property (gobject_class, PROP_MAX_COMB, g_param_spec_uint ("max-comb", "Max comb", "Max Comb", 0, 255, 15, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) ); dim_class->fields_required = 4; dim_class->name = "Motion Adaptive: Simple Detection"; dim_class->nick = "greedyl"; dim_class->latency = 1; dim_class->deinterlace_frame_yuy2 = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_yvyu = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_uyvy = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_y444 = deinterlace_frame_di_greedy_planar; dim_class->deinterlace_frame_y42b = deinterlace_frame_di_greedy_planar; dim_class->deinterlace_frame_i420 = deinterlace_frame_di_greedy_planar; dim_class->deinterlace_frame_yv12 = deinterlace_frame_di_greedy_planar; dim_class->deinterlace_frame_y41b = deinterlace_frame_di_greedy_planar; dim_class->deinterlace_frame_ayuv = deinterlace_frame_di_greedy_planar; dim_class->deinterlace_frame_argb = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_rgba = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_abgr = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_bgra = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_rgb = deinterlace_frame_di_greedy_packed; dim_class->deinterlace_frame_bgr = deinterlace_frame_di_greedy_packed; #ifdef BUILD_X86_ASM if (cpu_flags & ORC_TARGET_MMX_MMXEXT) { klass->scanline = deinterlace_greedy_scanline_mmxext; } else if (cpu_flags & ORC_TARGET_MMX_MMX) { klass->scanline = deinterlace_greedy_scanline_mmx; } else { klass->scanline = deinterlace_greedy_scanline_c; } #else klass->scanline = deinterlace_greedy_scanline_c; #endif }
void output_code_no_orc (OrcProgram *p, FILE *output) { fprintf(output, "void\n"); output_prototype (p, output); fprintf(output, "{\n"); { OrcCompileResult result; result = orc_program_compile_full (p, orc_target_get_by_name("c"), ORC_TARGET_C_BARE | ORC_TARGET_C_NOEXEC); if (ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { fprintf(output, "%s\n", orc_program_get_asm_code (p)); } else { fprintf(stderr, "Failed to compile no orc for '%s'\n", p->name); error = TRUE; } } fprintf(output, "}\n"); fprintf(output, "\n"); }
int main (int argc, char *argv[]) { char *code; int i; char *output_file = NULL; char *input_file = NULL; char *include_file = NULL; char *compat_version = VERSION; FILE *output; OrcParseError **errors = NULL; int n_errors = 0; orc_init (); for(i=1;i<argc;i++) { if (strcmp(argv[i], "--header") == 0) { mode = MODE_HEADER; } else if (strcmp(argv[i], "--implementation") == 0) { mode = MODE_IMPL; } else if (strcmp(argv[i], "--test") == 0) { mode = MODE_TEST; } else if (strcmp(argv[i], "--assembly") == 0) { mode = MODE_ASSEMBLY; } else if (strcmp(argv[i], "--parse-only") == 0) { mode = MODE_PARSE; } else if (strcmp(argv[i], "--include") == 0) { if (i+1 < argc) { include_file = argv[i+1]; i++; } else { help(); } } else if (strcmp (argv[i], "--output") == 0 || strcmp(argv[i], "-o") == 0) { if (i+1 < argc) { output_file = argv[i+1]; i++; } else { help(); } } else if (strcmp(argv[i], "--target") == 0 || strcmp(argv[i], "-t") == 0) { if (i+1 < argc) { target = argv[i+1]; i++; } else { help(); } } else if (strcmp(argv[i], "--inline") == 0) { use_inline = TRUE; } else if (strcmp(argv[i], "--no-inline") == 0) { use_inline = FALSE; } else if (strcmp(argv[i], "--internal") == 0) { use_internal = TRUE; } else if (strcmp(argv[i], "--no-internal") == 0) { use_internal = FALSE; } else if (strcmp(argv[i], "--init-function") == 0) { if (i+1 < argc) { init_function = argv[i+1]; i++; } else { help(); } } else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { help (); } else if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) { verbose = 1; } else if (strcmp(argv[i], "--version") == 0) { fprintf(stderr, "Orc Compiler " PACKAGE_VERSION "\n"); exit (0); } else if (strcmp(argv[i], "--compat") == 0) { if (i+1 < argc) { compat_version = argv[i+1]; i++; } else { help(); } } else if (strcmp(argv[i], "--lazy-init") == 0) { use_lazy_init = TRUE; } else if (strcmp(argv[i], "--no-backup") == 0) { use_backup = FALSE; } else if (strncmp(argv[i], "-", 1) == 0) { fprintf(stderr, "Unknown option: %s\n", argv[i]); exit (1); } else { if (input_file == NULL) { input_file = argv[i]; } else { fprintf(stderr, "More than one input file specified: %s\n", argv[i]); exit (1); } } } if (input_file == NULL) { fprintf(stderr, "No input file specified\n"); exit (1); } if (mode == MODE_ASSEMBLY && orc_target_get_by_name (target) == NULL) { fprintf(stderr, "Unknown target \"%s\"\n", target); exit (1); } if (compat_version) { int major, minor, micro, nano = 0; int n; n = sscanf (compat_version, "%d.%d.%d.%d", &major, &minor, µ, &nano); if (n < 3) { fprintf(stderr, "Unknown version \"%s\"\n", compat_version); exit (1); } compat = ORC_VERSION(major,minor,micro,nano); if (compat < ORC_VERSION(0,4,5,0)) { fprintf(stderr, "Compatibility version \"%s\" not supported. Minimum 0.4.5\n", compat_version); exit (1); } } if (compat >= ORC_VERSION(0,4,11,1)) { use_code = TRUE; } if (output_file == NULL) { switch (mode) { case MODE_IMPL: output_file = "out.c"; break; case MODE_HEADER: output_file = "out.h"; break; case MODE_TEST: output_file = "out_test.c"; break; case MODE_ASSEMBLY: output_file = "out.s"; break; } } code = read_file (input_file); if (!code) { fprintf(stderr, "Could not read input file: %s\n", input_file); exit(1); } orc_parse_code (code, &programs, &n_programs, &errors, &n_errors); if (n_errors > 0) { int i; for (i=0;i<n_errors;i++) { fprintf(stderr, "%s @ %i: error: %s\n", errors[i]->source, errors[i]->line_number, errors[i]->text); } exit (1); } if (programs == NULL) { if (verbose) { fprintf(stderr, "no programs found\n"); } exit(1); } if (verbose) { fprintf(stderr, "%i program%s parsed\n", n_programs, (n_programs > 1) ?"s" :""); } if (mode == MODE_PARSE) { exit (0); } if (init_function == NULL) { init_function = orc_parse_get_init_function (programs[0]); } if (init_function == NULL) { use_lazy_init = TRUE; } output = fopen (output_file, "w"); if (!output) { fprintf(stderr, "Could not write output file: %s\n", output_file); exit(1); } fprintf(output, "\n"); fprintf(output, "/* autogenerated from %s */\n", my_basename(input_file)); fprintf(output, "\n"); if (mode == MODE_IMPL) { fprintf(output, "#ifdef HAVE_CONFIG_H\n"); fprintf(output, "#include \"config.h\"\n"); fprintf(output, "#endif\n"); if (include_file) { fprintf(output, "#include <%s>\n", include_file); } fprintf(output, "\n"); fprintf(output, "%s", orc_target_c_get_typedefs ()); fprintf(output, "\n"); fprintf(output, "#ifndef DISABLE_ORC\n"); fprintf(output, "#include <orc/orc.h>\n"); fprintf(output, "#endif\n"); for(i=0;i<n_programs;i++){ output_code_header (programs[i], output); } if (init_function) { fprintf(output, "\n"); fprintf(output, "void %s (void);\n", init_function); } fprintf(output, "\n"); fprintf(output, "%s", orc_target_get_asm_preamble ("c")); fprintf(output, "\n"); for(i=0;i<n_programs;i++){ output_code (programs[i], output); } fprintf(output, "\n"); if (init_function) { output_init_function (output); fprintf(output, "\n"); } } else if (mode == MODE_HEADER) { char *barrier = get_barrier (output_file); fprintf(output, "#ifndef _%s_\n", barrier); fprintf(output, "#define _%s_\n", barrier); free (barrier); fprintf(output, "\n"); if (include_file) { fprintf(output, "#include <%s>\n", include_file); } fprintf(output, "\n"); fprintf(output, "#ifdef __cplusplus\n"); fprintf(output, "extern \"C\" {\n"); fprintf(output, "#endif\n"); fprintf(output, "\n"); if (init_function) { fprintf(output, "void %s (void);\n", init_function); fprintf(output, "\n"); } fprintf(output, "\n"); if (!use_inline) { fprintf(output, "\n"); fprintf(output, "%s", orc_target_c_get_typedefs ()); for(i=0;i<n_programs;i++){ output_code_header (programs[i], output); } } else { fprintf(output, "\n"); fprintf(output, "#include <orc/orc.h>\n"); fprintf(output, "\n"); for(i=0;i<n_programs;i++){ output_code_execute (programs[i], output, TRUE); } } fprintf(output, "\n"); fprintf(output, "#ifdef __cplusplus\n"); fprintf(output, "}\n"); fprintf(output, "#endif\n"); fprintf(output, "\n"); fprintf(output, "#endif\n"); fprintf(output, "\n"); } else if (mode == MODE_TEST) { fprintf(output, "#include <stdio.h>\n"); fprintf(output, "#include <string.h>\n"); fprintf(output, "#include <stdlib.h>\n"); fprintf(output, "#include <math.h>\n"); if (include_file) { fprintf(output, "#include <%s>\n", include_file); } fprintf(output, "\n"); fprintf(output, "%s", orc_target_c_get_typedefs ()); fprintf(output, "#include <orc/orc.h>\n"); fprintf(output, "#include <orc-test/orctest.h>\n"); fprintf(output, "%s", orc_target_get_asm_preamble ("c")); fprintf(output, "\n"); if (use_backup) { for(i=0;i<n_programs;i++){ fprintf(output, "/* %s */\n", programs[i]->name); output_code_backup (programs[i], output); } } fprintf(output, "\n"); fprintf(output, "static int quiet = 0;\n"); fprintf(output, "static int benchmark = 0;\n"); fprintf(output, "\n"); fprintf(output, "static void help (const char *argv0)\n"); fprintf(output, "{\n"); fprintf(output, " fprintf(stderr, \"Usage:\\n\");\n"); fprintf(output, " fprintf(stderr, \" %%s [OPTION]\\n\", argv0);\n"); fprintf(output, " fprintf(stderr, \"Help Options:\\n\");\n"); fprintf(output, " fprintf(stderr, \" -h, --help Show help options\\n\");\n"); fprintf(output, " fprintf(stderr, \"Application Options:\\n\");\n"); fprintf(output, " fprintf(stderr, \" -b, --benchmark Run benchmark and show results\\n\");\n"); fprintf(output, " fprintf(stderr, \" -q, --quiet Don't output anything except on failures\\n\");\n"); fprintf(output, "\n"); fprintf(output, " exit(0);\n"); fprintf(output, "}\n"); fprintf(output, "\n"); fprintf(output, "int\n"); fprintf(output, "main (int argc, char *argv[])\n"); fprintf(output, "{\n"); fprintf(output, " int error = FALSE;\n"); fprintf(output, " int i;\n"); fprintf(output, "\n"); fprintf(output, " orc_test_init ();\n"); fprintf(output, "\n"); fprintf(output, " for(i=1;i<argc;i++) {\n"); fprintf(output, " if (strcmp(argv[i], \"--help\") == 0 ||\n"); fprintf(output, " strcmp(argv[i], \"-h\") == 0) {\n"); fprintf(output, " help(argv[0]);\n"); fprintf(output, " } else if (strcmp(argv[i], \"--quiet\") == 0 ||\n"); fprintf(output, " strcmp(argv[i], \"-q\") == 0) {\n"); fprintf(output, " quiet = 1;\n"); fprintf(output, " benchmark = 0;\n"); fprintf(output, " } else if (strcmp(argv[i], \"--benchmark\") == 0 ||\n"); fprintf(output, " strcmp(argv[i], \"-b\") == 0) {\n"); fprintf(output, " benchmark = 1;\n"); fprintf(output, " quiet = 0;\n"); fprintf(output, " }\n"); fprintf(output, " }\n"); fprintf(output, "\n"); for(i=0;i<n_programs;i++){ output_code_test (programs[i], output); } fprintf(output, "\n"); fprintf(output, " if (error) {\n"); fprintf(output, " return 1;\n"); fprintf(output, " };\n"); fprintf(output, " return 0;\n"); fprintf(output, "}\n"); } else if (mode == MODE_ASSEMBLY) { fprintf(output, "%s", orc_target_get_asm_preamble (target)); for(i=0;i<n_programs;i++){ output_code_assembly (programs[i], output); } } fclose (output); if (error) { remove (output_file); exit(1); } return 0; }
static void gst_deinterlace_method_greedy_h_class_init (GstDeinterlaceMethodGreedyHClass * klass) { GstDeinterlaceMethodClass *dim_class = (GstDeinterlaceMethodClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass; #ifdef BUILD_X86_ASM guint cpu_flags = orc_target_get_default_flags (orc_target_get_by_name ("mmx")); #endif gobject_class->set_property = gst_deinterlace_method_greedy_h_set_property; gobject_class->get_property = gst_deinterlace_method_greedy_h_get_property; g_object_class_install_property (gobject_class, PROP_MAX_COMB, g_param_spec_uint ("max-comb", "Max comb", "Max Comb", 0, 255, 5, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) ); g_object_class_install_property (gobject_class, PROP_MOTION_THRESHOLD, g_param_spec_uint ("motion-threshold", "Motion Threshold", "Motion Threshold", 0, 255, 25, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) ); g_object_class_install_property (gobject_class, PROP_MOTION_SENSE, g_param_spec_uint ("motion-sense", "Motion Sense", "Motion Sense", 0, 255, 30, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) ); dim_class->fields_required = 4; dim_class->name = "Motion Adaptive: Advanced Detection"; dim_class->nick = "greedyh"; dim_class->latency = 1; dim_class->deinterlace_frame_yuy2 = deinterlace_frame_di_greedyh_packed; dim_class->deinterlace_frame_yvyu = deinterlace_frame_di_greedyh_packed; dim_class->deinterlace_frame_uyvy = deinterlace_frame_di_greedyh_packed; dim_class->deinterlace_frame_ayuv = deinterlace_frame_di_greedyh_packed; dim_class->deinterlace_frame_y444 = deinterlace_frame_di_greedyh_planar; dim_class->deinterlace_frame_i420 = deinterlace_frame_di_greedyh_planar; dim_class->deinterlace_frame_yv12 = deinterlace_frame_di_greedyh_planar; dim_class->deinterlace_frame_y42b = deinterlace_frame_di_greedyh_planar; dim_class->deinterlace_frame_y41b = deinterlace_frame_di_greedyh_planar; #ifdef BUILD_X86_ASM if (cpu_flags & ORC_TARGET_MMX_MMXEXT) { klass->scanline_yuy2 = greedyh_scanline_MMXEXT_yuy2; klass->scanline_uyvy = greedyh_scanline_MMXEXT_uyvy; } else if (cpu_flags & ORC_TARGET_MMX_3DNOW) { klass->scanline_yuy2 = greedyh_scanline_3DNOW_yuy2; klass->scanline_uyvy = greedyh_scanline_3DNOW_uyvy; } else if (cpu_flags & ORC_TARGET_MMX_MMX) { klass->scanline_yuy2 = greedyh_scanline_MMX_yuy2; klass->scanline_uyvy = greedyh_scanline_MMX_uyvy; } else { klass->scanline_yuy2 = greedyh_scanline_C_yuy2; klass->scanline_uyvy = greedyh_scanline_C_uyvy; } #else klass->scanline_yuy2 = greedyh_scanline_C_yuy2; klass->scanline_uyvy = greedyh_scanline_C_uyvy; #endif /* TODO: MMX implementation of these two */ klass->scanline_ayuv = greedyh_scanline_C_ayuv; klass->scanline_planar_y = greedyh_scanline_C_planar_y; klass->scanline_planar_uv = greedyh_scanline_C_planar_uv; }
double orc_test_performance_full (OrcProgram *program, int flags, const char *target_name) { OrcExecutor *ex; int n; int m; OrcArray *dest_exec[4] = { NULL, NULL, NULL, NULL }; OrcArray *dest_emul[4] = { NULL, NULL, NULL, NULL }; OrcArray *src[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; int i, j; OrcCompileResult result; OrcProfile prof; double ave, std; OrcTarget *target; int misalignment; ORC_DEBUG ("got here"); target = orc_target_get_by_name (target_name); if (!(flags & ORC_TEST_FLAGS_BACKUP)) { unsigned int flags; flags = orc_target_get_default_flags (target); result = orc_program_compile_full (program, target, flags); if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { //printf("compile failed\n"); orc_program_reset (program); return 0; } } if (program->constant_n > 0) { n = program->constant_n; } else { //n = 64 + (orc_random(&rand_context)&0xf); n = 1000; } ex = orc_executor_new (program); orc_executor_set_n (ex, n); if (program->is_2d) { if (program->constant_m > 0) { m = program->constant_m; } else { m = 8 + (orc_random(&rand_context)&0xf); } } else { m = 1; } orc_executor_set_m (ex, m); ORC_DEBUG("size %d %d", ex->n, ex->params[ORC_VAR_A1]); misalignment = 0; for(i=0;i<ORC_N_VARIABLES;i++){ if (program->vars[i].name == NULL) continue; if (program->vars[i].vartype == ORC_VAR_TYPE_SRC) { src[i-ORC_VAR_S1] = orc_array_new (n, m, program->vars[i].size, misalignment); orc_array_set_random (src[i-ORC_VAR_S1], &rand_context); misalignment++; } else if (program->vars[i].vartype == ORC_VAR_TYPE_DEST) { dest_exec[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size, misalignment); orc_array_set_pattern (dest_exec[i], ORC_OOB_VALUE); dest_emul[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size, misalignment); orc_array_set_pattern (dest_emul[i], ORC_OOB_VALUE); misalignment++; } else if (program->vars[i].vartype == ORC_VAR_TYPE_PARAM) { orc_executor_set_param (ex, i, 2); } } ORC_DEBUG ("running"); orc_profile_init (&prof); for(i=0;i<10;i++){ orc_executor_set_n (ex, n); orc_executor_set_m (ex, m); for(j=0;j<ORC_N_VARIABLES;j++){ if (program->vars[j].vartype == ORC_VAR_TYPE_DEST) { orc_executor_set_array (ex, j, dest_exec[j-ORC_VAR_D1]->data); orc_executor_set_stride (ex, j, dest_exec[j-ORC_VAR_D1]->stride); } if (program->vars[j].vartype == ORC_VAR_TYPE_SRC) { orc_executor_set_array (ex, j, src[j-ORC_VAR_S1]->data); orc_executor_set_stride (ex, j, src[j-ORC_VAR_S1]->stride); } } if (flags & ORC_TEST_FLAGS_BACKUP) { orc_profile_start (&prof); orc_executor_run_backup (ex); orc_profile_stop (&prof); } else if (flags & ORC_TEST_FLAGS_EMULATE) { orc_profile_start (&prof); orc_executor_emulate (ex); orc_profile_stop (&prof); } else { orc_profile_start (&prof); orc_executor_run (ex); orc_profile_stop (&prof); } } ORC_DEBUG ("done running"); orc_profile_get_ave_std (&prof, &ave, &std); for(i=0;i<4;i++){ if (dest_exec[i]) orc_array_free (dest_exec[i]); if (dest_emul[i]) orc_array_free (dest_emul[i]); } for(i=0;i<8;i++){ if (src[i]) orc_array_free (src[i]); } orc_executor_free (ex); orc_program_reset (program); return ave/(n*m); }
OrcTestResult orc_test_gcc_compile_c64x (OrcProgram *p) { char cmd[300]; char *base; char source_filename[100]; char obj_filename[100]; char dis_filename[100]; char dump_filename[100]; char dump_dis_filename[100]; int ret; FILE *file; OrcCompileResult result; OrcTarget *target; unsigned int flags; base = "temp-orc-test"; sprintf(source_filename, "%s-source.s", base); sprintf(obj_filename, "%s-source.obj", base); sprintf(dis_filename, "%s-source.dis", base); sprintf(dump_filename, "%s-dump.bin", base); sprintf(dump_dis_filename, "%s-dump.dis", base); target = orc_target_get_by_name ("c64x"); flags = orc_target_get_default_flags (target); result = orc_program_compile_full (p, target, flags); if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { return ORC_TEST_INDETERMINATE; } fflush (stdout); file = fopen (source_filename, "w"); fprintf(file, "%s", orc_program_get_asm_code (p)); fclose (file); file = fopen (dump_filename, "w"); ret = fwrite(p->orccode->code, p->orccode->code_size, 1, file); fclose (file); sprintf (cmd, C64X_PREFIX "cl6x -mv=6400+ " "-c %s", source_filename); ret = system (cmd); if (ret != 0) { ORC_ERROR ("compiler failed"); //printf("%s\n", orc_program_get_asm_code (p)); return ORC_TEST_INDETERMINATE; } sprintf (cmd, C64X_PREFIX "dis6x %s >%s", obj_filename, dis_filename); ret = system (cmd); if (ret != 0) { ORC_ERROR ("objdump failed"); return ORC_TEST_INDETERMINATE; } #if 0 sprintf (cmd, C64X_PREFIX "objcopy -I binary " "-O elf32-littlearm -B arm " "--rename-section .data=.text " "--redefine-sym _binary_temp_orc_test_dump_bin_start=%s " "%s %s", p->name, dump_filename, obj_filename); ret = system (cmd); if (ret != 0) { printf("objcopy failed\n"); return ORC_TEST_FAILED; } #endif #if 0 sprintf (cmd, C64X_PREFIX "dis6x %s >%s", dump_filename, dump_dis_filename); ret = system (cmd); if (ret != 0) { printf("objdump failed\n"); return ORC_TEST_FAILED; } sprintf (cmd, "diff -u %s %s", dis_filename, dump_dis_filename); ret = system (cmd); if (ret != 0) { printf("diff failed\n"); return ORC_TEST_FAILED; } #endif remove (source_filename); remove (obj_filename); remove (dis_filename); remove (dump_filename); remove (dump_dis_filename); return ORC_TEST_OK; }
OrcTestResult orc_test_gcc_compile_neon (OrcProgram *p) { char cmd[300]; char *base; char source_filename[100]; char obj_filename[100]; char dis_filename[100]; char dump_filename[100]; char dump_dis_filename[100]; int ret; FILE *file; OrcCompileResult result; OrcTarget *target; unsigned int flags; base = "temp-orc-test"; sprintf(source_filename, "%s-source.s", base); sprintf(obj_filename, "%s.o", base); sprintf(dis_filename, "%s-source.dis", base); sprintf(dump_filename, "%s-dump.bin", base); sprintf(dump_dis_filename, "%s-dump.dis", base); target = orc_target_get_by_name ("neon"); flags = orc_target_get_default_flags (target); flags |= ORC_TARGET_CLEAN_COMPILE; result = orc_program_compile_full (p, target, flags); if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { return ORC_TEST_INDETERMINATE; } fflush (stdout); file = fopen (source_filename, "w"); fprintf(file, "%s", orc_program_get_asm_code (p)); fclose (file); file = fopen (dump_filename, "w"); ret = fwrite(p->orccode->code, p->orccode->code_size, 1, file); fclose (file); sprintf (cmd, PREFIX "gcc -march=armv6t2 -mcpu=cortex-a8 -mfpu=neon -Wall " "-c %s -o %s", source_filename, obj_filename); ret = system (cmd); if (ret != 0) { ORC_ERROR ("arm gcc failed"); return ORC_TEST_INDETERMINATE; } sprintf (cmd, PREFIX "objdump -dr %s >%s", obj_filename, dis_filename); ret = system (cmd); if (ret != 0) { ORC_ERROR ("objdump failed"); return ORC_TEST_INDETERMINATE; } sprintf (cmd, PREFIX "objcopy -I binary " "-O elf32-littlearm -B arm " "--rename-section .data=.text " "--redefine-sym _binary_temp_orc_test_dump_bin_start=%s " "%s %s", p->name, dump_filename, obj_filename); ret = system (cmd); if (ret != 0) { printf("objcopy failed\n"); return ORC_TEST_INDETERMINATE; } sprintf (cmd, PREFIX "objdump -Dr %s >%s", obj_filename, dump_dis_filename); ret = system (cmd); if (ret != 0) { printf("objdump failed\n"); return ORC_TEST_INDETERMINATE; } sprintf (cmd, "diff -u %s %s", dis_filename, dump_dis_filename); ret = system (cmd); if (ret != 0) { printf("diff failed\n"); return ORC_TEST_FAILED; } remove (source_filename); remove (obj_filename); remove (dis_filename); remove (dump_filename); remove (dump_dis_filename); return ORC_TEST_OK; }
static gboolean gst_ffmpegscale_set_caps(GstBaseTransform* trans, GstCaps* incaps, GstCaps* outcaps) { GstFFMpegScale* scale = GST_FFMPEGSCALE(trans); guint mmx_flags, altivec_flags, sse_flags; gint swsflags; gboolean ok; g_return_val_if_fail(scale->method < G_N_ELEMENTS(gst_ffmpegscale_method_flags), FALSE); if (scale->ctx) { sws_freeContext(scale->ctx); scale->ctx = NULL; } scale->borders_h = 0; scale->borders_w = 0; ok = gst_video_format_parse_caps(incaps, &scale->in_format, &scale->in_width, &scale->in_height); ok &= gst_video_format_parse_caps(outcaps, &scale->out_format, &scale->out_width, &scale->out_height); scale->in_pixfmt = gst_ffmpeg_caps_to_pixfmt(incaps); scale->out_pixfmt = gst_ffmpeg_caps_to_pixfmt(outcaps); if (!ok || scale->in_pixfmt == PIX_FMT_NONE || scale->out_pixfmt == PIX_FMT_NONE || scale->in_format == GST_VIDEO_FORMAT_UNKNOWN || scale->out_format == GST_VIDEO_FORMAT_UNKNOWN) { goto refuse_caps; } GST_DEBUG_OBJECT(scale, "format %d => %d, from=%dx%d -> to=%dx%d", scale->in_format, scale->out_format, scale->in_width, scale->in_height, scale->out_width, scale->out_height); gst_ffmpegscale_fill_info(scale, scale->in_format, scale->in_width, scale->in_height, scale->in_stride, scale->in_offset); gst_ffmpegscale_fill_info(scale, scale->out_format, scale->out_width, scale->out_height, scale->out_stride, scale->out_offset); #ifdef HAVE_ORC mmx_flags = orc_target_get_default_flags(orc_target_get_by_name("mmx")); altivec_flags = orc_target_get_default_flags(orc_target_get_by_name("altivec")); sse_flags = orc_target_get_default_flags(orc_target_get_by_name("sse")); swsflags = (mmx_flags & ORC_TARGET_MMX_MMX ? SWS_CPU_CAPS_MMX : 0) | (mmx_flags & ORC_TARGET_MMX_MMXEXT ? SWS_CPU_CAPS_MMX2 : 0) | (mmx_flags & ORC_TARGET_MMX_3DNOW ? SWS_CPU_CAPS_3DNOW : 0) | (altivec_flags & ORC_TARGET_ALTIVEC_ALTIVEC ? SWS_CPU_CAPS_ALTIVEC : 0) | (sse_flags & ORC_TARGET_SSE_SSE2 ? SWS_CPU_CAPS_SSE2 : 0); #else mmx_flags = 0; altivec_flags = 0; swsflags = 0; #endif if (scale->add_borders && scale->in_width > 0 && scale->in_height > 0 && scale->out_height > 0 && scale->out_width > 0) { gfloat ratio = scale->in_width * 1.0f / scale->in_height; gint ratio_width = (gint)(scale->out_height * ratio); if (ratio_width > scale->out_width) { gint ratio_height = (gint)(scale->out_width / ratio); scale->ctx = sws_getContext(scale->in_width, scale->in_height, scale->in_pixfmt, scale->out_width, ratio_height, scale->out_pixfmt, swsflags | gst_ffmpegscale_method_flags[scale->method], NULL, NULL, NULL); if (ratio_height != scale->out_height) { gint rows = 0; scale->borders_h = scale->out_height - ratio_height; rows = scale->borders_h / 2; if (rows > 0) { gst_video_format_add_top_border(scale->out_format, rows, scale->out_offset, scale->out_stride); } } } else { if (ratio_width != scale->out_width) { gint cols = 0; scale->borders_w = scale->out_width - ratio_width; cols = scale->borders_w / 2; if (cols > 0) { int i = 0; for (i = 0; i < 3; i ++) { scale->out_offset[i] += cols * scale->out_stride[i] / scale->out_width; } } } scale->ctx = sws_getContext(scale->in_width, scale->in_height, scale->in_pixfmt, ratio_width, scale->out_height, scale->out_pixfmt, swsflags | gst_ffmpegscale_method_flags[scale->method], NULL, NULL, NULL); } } else { scale->ctx = sws_getContext(scale->in_width, scale->in_height, scale->in_pixfmt, scale->out_width, scale->out_height, scale->out_pixfmt, swsflags | gst_ffmpegscale_method_flags[scale->method], NULL, NULL, NULL); } if (!scale->ctx) { goto setup_failed; } return TRUE; /* ERRORS */ setup_failed: { GST_ELEMENT_ERROR(trans, LIBRARY, INIT, (NULL), (NULL)); return FALSE; } refuse_caps: { GST_DEBUG_OBJECT(trans, "refused caps %" GST_PTR_FORMAT, incaps); return FALSE; } }
static gboolean gst_ffmpegscale_set_caps (GstBaseTransform * trans, GstCaps * incaps, GstCaps * outcaps) { GstFFMpegScale *scale = GST_FFMPEGSCALE (trans); #ifdef HAVE_ORC guint mmx_flags, altivec_flags; #endif gint swsflags; gboolean ok; g_return_val_if_fail (scale->method < G_N_ELEMENTS (gst_ffmpegscale_method_flags), FALSE); if (scale->ctx) { sws_freeContext (scale->ctx); scale->ctx = NULL; } ok = gst_video_info_from_caps (&scale->in_info, incaps); ok &= gst_video_info_from_caps (&scale->out_info, outcaps); scale->in_pixfmt = gst_ffmpeg_caps_to_pixfmt (incaps); scale->out_pixfmt = gst_ffmpeg_caps_to_pixfmt (outcaps); if (!ok || scale->in_pixfmt == AV_PIX_FMT_NONE || scale->out_pixfmt == AV_PIX_FMT_NONE || GST_VIDEO_INFO_FORMAT (&scale->in_info) == GST_VIDEO_FORMAT_UNKNOWN || GST_VIDEO_INFO_FORMAT (&scale->out_info) == GST_VIDEO_FORMAT_UNKNOWN) goto refuse_caps; GST_DEBUG_OBJECT (scale, "format %d => %d, from=%dx%d -> to=%dx%d", GST_VIDEO_INFO_FORMAT (&scale->in_info), GST_VIDEO_INFO_FORMAT (&scale->out_info), GST_VIDEO_INFO_WIDTH (&scale->in_info), GST_VIDEO_INFO_HEIGHT (&scale->in_info), GST_VIDEO_INFO_WIDTH (&scale->out_info), GST_VIDEO_INFO_HEIGHT (&scale->out_info)); #ifdef HAVE_ORC mmx_flags = orc_target_get_default_flags (orc_target_get_by_name ("mmx")); altivec_flags = orc_target_get_default_flags (orc_target_get_by_name ("altivec")); swsflags = (mmx_flags & ORC_TARGET_MMX_MMX ? SWS_CPU_CAPS_MMX : 0) | (mmx_flags & ORC_TARGET_MMX_MMXEXT ? SWS_CPU_CAPS_MMX2 : 0) | (mmx_flags & ORC_TARGET_MMX_3DNOW ? SWS_CPU_CAPS_3DNOW : 0) | (altivec_flags & ORC_TARGET_ALTIVEC_ALTIVEC ? SWS_CPU_CAPS_ALTIVEC : 0); #else swsflags = 0; #endif scale->ctx = sws_getContext (scale->in_info.width, scale->in_info.height, scale->in_pixfmt, scale->out_info.width, scale->out_info.height, scale->out_pixfmt, swsflags | gst_ffmpegscale_method_flags[scale->method], NULL, NULL, NULL); if (!scale->ctx) goto setup_failed; return TRUE; /* ERRORS */ setup_failed: { GST_ELEMENT_ERROR (trans, LIBRARY, INIT, (NULL), (NULL)); return FALSE; } refuse_caps: { GST_DEBUG_OBJECT (trans, "refused caps %" GST_PTR_FORMAT, incaps); return FALSE; } }
void show (OrcProgram *program) { OrcCompileResult result; OrcTarget *target; const char *target_name; unsigned int target_flags; int n, m; OrcExecutor *ex; OrcArray *dest[4] = { NULL, NULL, NULL, NULL }; OrcArray *src[8] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; int i,j; OrcRandomContext rand_context = { 0 }; target_name = NULL; target = orc_target_get_by_name (target_name); target_flags = orc_target_get_default_flags (target); result = orc_program_compile_full (program, target, target_flags); if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL(result)) { printf("%s: compile failed\n", program->name); return; } printf("%s:\n", program->name); if (program->constant_n > 0) { n = program->constant_n; } else { n = array_n; } ex = orc_executor_new (program); orc_executor_set_n (ex, n); if (program->is_2d) { if (program->constant_m > 0) { m = program->constant_m; } else { m = 2; } } else { m = 1; } orc_executor_set_m (ex, m); for(i=0;i<ORC_N_VARIABLES;i++){ if (program->vars[i].name == NULL) continue; if (program->vars[i].vartype == ORC_VAR_TYPE_SRC) { src[i-ORC_VAR_S1] = orc_array_new (n, m, program->vars[i].size, 0); orc_array_set_random (src[i-ORC_VAR_S1], &rand_context); } else if (program->vars[i].vartype == ORC_VAR_TYPE_DEST) { dest[i-ORC_VAR_D1] = orc_array_new (n, m, program->vars[i].size, 0); orc_array_set_pattern (dest[i], ORC_OOB_VALUE); } else if (program->vars[i].vartype == ORC_VAR_TYPE_PARAM) { switch (program->vars[i].param_type) { case ORC_PARAM_TYPE_INT: orc_executor_set_param (ex, i, 2); break; case ORC_PARAM_TYPE_FLOAT: orc_executor_set_param_float (ex, i, 2.0); break; case ORC_PARAM_TYPE_INT64: orc_executor_set_param_int64 (ex, i, 2); break; case ORC_PARAM_TYPE_DOUBLE: orc_executor_set_param_double (ex, i, 2.0); break; default: ORC_ASSERT(0); } } } orc_executor_set_n (ex, n); orc_executor_set_m (ex, m); for(j=0;j<ORC_N_VARIABLES;j++){ if (program->vars[j].vartype == ORC_VAR_TYPE_DEST) { orc_executor_set_array (ex, j, dest[j-ORC_VAR_D1]->data); orc_executor_set_stride (ex, j, dest[j-ORC_VAR_D1]->stride); } if (program->vars[j].vartype == ORC_VAR_TYPE_SRC) { orc_executor_set_array (ex, j, src[j-ORC_VAR_S1]->data); orc_executor_set_stride (ex, j, src[j-ORC_VAR_S1]->stride); } } orc_executor_run (ex); { int i,j; for(j=0;j<m;j++){ for(i=0;i<n;i++){ int l; printf("%2d %2d:", i, j); for(l=ORC_VAR_S1;l<ORC_VAR_S1+8;l++){ if (program->vars[l].size > 0) { switch (format) { case FORMAT_FLOAT: print_array_val_float (src[l-ORC_VAR_S1], i, j); break; case FORMAT_HEX: print_array_val_hex (src[l-ORC_VAR_S1], i, j); break; case FORMAT_SIGNED: print_array_val_signed (src[l-ORC_VAR_S1], i, j); break; case FORMAT_UNSIGNED: print_array_val_unsigned (src[l-ORC_VAR_S1], i, j); break; } } } printf(" ->"); for(l=ORC_VAR_D1;l<ORC_VAR_D1+4;l++){ if (program->vars[l].size > 0) { switch (format) { case FORMAT_FLOAT: print_array_val_float (dest[l-ORC_VAR_D1], i, j); break; case FORMAT_HEX: print_array_val_hex (dest[l-ORC_VAR_D1], i, j); break; case FORMAT_SIGNED: print_array_val_signed (dest[l-ORC_VAR_D1], i, j); break; case FORMAT_UNSIGNED: print_array_val_unsigned (dest[l-ORC_VAR_D1], i, j); break; } } } printf("\n"); } } } for(i=0;i<4;i++){ if (dest[i]) orc_array_free (dest[i]); } for(i=0;i<8;i++){ if (src[i]) orc_array_free (src[i]); } orc_executor_free (ex); }
static void gst_a52dec_class_init (GstA52DecClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; GstAudioDecoderClass *gstbase_class; guint cpuflags = 0; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; gstbase_class = (GstAudioDecoderClass *) klass; gobject_class->set_property = gst_a52dec_set_property; gobject_class->get_property = gst_a52dec_get_property; gstbase_class->start = GST_DEBUG_FUNCPTR (gst_a52dec_start); gstbase_class->stop = GST_DEBUG_FUNCPTR (gst_a52dec_stop); gstbase_class->set_format = GST_DEBUG_FUNCPTR (gst_a52dec_set_format); gstbase_class->parse = GST_DEBUG_FUNCPTR (gst_a52dec_parse); gstbase_class->handle_frame = GST_DEBUG_FUNCPTR (gst_a52dec_handle_frame); /** * GstA52Dec::drc * * Set to true to apply the recommended Dolby Digital dynamic range compression * to the audio stream. Dynamic range compression makes loud sounds * softer and soft sounds louder, so you can more easily listen * to the stream without disturbing other people. */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DRC, g_param_spec_boolean ("drc", "Dynamic Range Compression", "Use Dynamic Range Compression", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * GstA52Dec::mode * * Force a particular output channel configuration from the decoder. By default, * the channel downmix (if any) is chosen automatically based on the downstream * capabilities of the pipeline. */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE, g_param_spec_enum ("mode", "Decoder Mode", "Decoding Mode (default 3f2r)", GST_TYPE_A52DEC_MODE, A52_3F2R, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * GstA52Dec::lfe * * Whether to output the LFE (Low Frequency Emitter) channel of the audio stream. */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LFE, g_param_spec_boolean ("lfe", "LFE", "LFE", TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&sink_factory)); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&src_factory)); gst_element_class_set_static_metadata (gstelement_class, "ATSC A/52 audio decoder", "Codec/Decoder/Audio", "Decodes ATSC A/52 encoded audio streams", "David I. Lehn <*****@*****.**>"); GST_DEBUG_CATEGORY_INIT (a52dec_debug, "a52dec", 0, "AC3/A52 software decoder"); /* If no CPU instruction based acceleration is available, end up using the * generic software djbfft based one when available in the used liba52 */ #ifdef MM_ACCEL_DJBFFT klass->a52_cpuflags = MM_ACCEL_DJBFFT; #elif defined(A52_ACCEL_DETECT) klass->a52_cpuflags = A52_ACCEL_DETECT; #else klass->a52_cpuflags = 0; #endif #if HAVE_ORC && !defined(A52_ACCEL_DETECT) cpuflags = orc_target_get_default_flags (orc_target_get_by_name ("mmx")); if (cpuflags & ORC_TARGET_MMX_MMX) klass->a52_cpuflags |= MM_ACCEL_X86_MMX; if (cpuflags & ORC_TARGET_MMX_3DNOW) klass->a52_cpuflags |= MM_ACCEL_X86_3DNOW; if (cpuflags & ORC_TARGET_MMX_MMXEXT) klass->a52_cpuflags |= MM_ACCEL_X86_MMXEXT; #endif GST_LOG ("CPU flags: a52=%08x, orc=%08x", klass->a52_cpuflags, cpuflags); }