Ejemplo n.º 1
0
int Color3WayMain::handle_opengl()
{
#ifdef HAVE_GL

	get_output()->to_texture();
	get_output()->enable_opengl();

	unsigned int shader = 0;
	const char *shader_stack[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
	int current_shader = 0;
	int aggregate_interpolate = 0;
	int aggregate_gamma = 0;

	get_aggregation(&aggregate_interpolate,
		&aggregate_gamma);

printf("Color3WayMain::handle_opengl %d %d\n", aggregate_interpolate, aggregate_gamma);
	if(aggregate_interpolate)
		INTERPOLATE_COMPILE(shader_stack, current_shader)

	if(aggregate_gamma)
		GAMMA_COMPILE(shader_stack, current_shader, aggregate_interpolate)

	COLORBALANCE_COMPILE(shader_stack, 
		current_shader, 
		aggregate_gamma || aggregate_interpolate)

	shader = VFrame::make_shader(0, 
		shader_stack[0], 
		shader_stack[1], 
		shader_stack[2], 
		shader_stack[3], 
		shader_stack[4], 
		shader_stack[5], 
		shader_stack[6], 
		shader_stack[7], 
		0);

	if(shader > 0)
	{
		glUseProgram(shader);
		glUniform1i(glGetUniformLocation(shader, "tex"), 0);

		if(aggregate_interpolate) INTERPOLATE_UNIFORMS(shader);
		if(aggregate_gamma) GAMMA_UNIFORMS(shader);

		COLORBALANCE_UNIFORMS(shader);

	}

	get_output()->init_screen();
	get_output()->bind_texture(0);
	get_output()->draw_texture();
	glUseProgram(0);
	get_output()->set_opengl_state(VFrame::SCREEN);
#endif
}
Ejemplo n.º 2
0
TEST_P(OperatorsSortTest, MultipleColumnSortIsStableMixedOrder) {
  auto table_wrapper = std::make_shared<TableWrapper>(load_table("resources/test_data/tbl/int_float4.tbl", 2));
  table_wrapper->execute();

  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_float2_sorted_mixed.tbl", 2);

  // we want the output to be sorted after column a and in second place after column b.
  // So first we sort after column b and then after column a.
  auto sort_after_b = std::make_shared<Sort>(table_wrapper, ColumnID{1}, OrderByMode::Descending, 2u);
  sort_after_b->execute();

  auto sort_after_a = std::make_shared<Sort>(sort_after_b, ColumnID{0}, OrderByMode::Ascending, 2u);
  sort_after_a->execute();

  EXPECT_TABLE_EQ_ORDERED(sort_after_a->get_output(), expected_result);
}
Ejemplo n.º 3
0
void pulse_out(int pin, int time)              // pulseOut function definition
{
  /*
  if(st_iodt == 0)
  {
    set_io_dt(CLKFREQ/1000000);
    set_io_timeout(CLKFREQ/4);
  }
  */
  signed long phsVal = -time * st_iodt;
  //int ctr = 0;
  int frq = 1;
  int phs = 0;
  int state = get_output(pin);
  if(state == 1)
  {
    phsVal = -phsVal;
    phs = -1;
    frq = -1;
  }
  if (CTRA == 0)
  {
    PHSA = phs;
    FRQA = frq;
    CTRA = pin;
    CTRA += (4 << 26);
    low(pin);
    PHSA = phsVal;
    while(get_state(pin) != state);
    set_output(pin, state);
    CTRA = 0;
  }
  else if (CTRB == 0)
  {
    PHSA = phs;
    FRQA = frq;
    CTRA = pin;
    CTRA += (4 << 26);
    low(pin);
    PHSA = phsVal;
    while(get_state(pin) != state);
    set_output(pin, state);
    CTRA = 0;
  }
}
Ejemplo n.º 4
0
// Initialize everything
static void init() {
    int error;

    // Open files
    error = create_reader();
    if (error != 0) {
        fprintf(stderr, "%s: %s\n", get_input(), strerror(errno));
        exit(1);
    }

    error = create_writer();
    if (error != 0) {
        fprintf(stderr, "%s: %s\n", get_output(), strerror(errno));
        exit(2);
    }

    // Basic Huffman tree
    init_variables();
}
Ejemplo n.º 5
0
static void pulse_outCtr(int pin, int time)           // pulseOut function definition
{
  /*
  if(st_iodt == 0)
  {
    set_io_dt(CLKFREQ/1000000);
    set_io_timeout(CLKFREQ/4);
  }
  */
  signed long phsVal = -time * st_iodt;
  int ctr = 0;
  int frq = 1;
  int phs = 0;
  int state = get_output(pin);
  if(state == 1)
  {
    phsVal = -phsVal;
    phs = -1;
    frq = -1;
  }
  if(ta == 0 || (dta && (CNT - ta > dta)))
  {
    PHSA = phs;
    FRQA = frq;
    CTRA = pin;
    CTRA += (4 << 26);
    low(pin);
    PHSA = phsVal;
    dta = abs(phsVal);
    ta = CNT;
  }
  else if(tb == 0 || (dtb && (CNT - tb > dtb)))
  {
    PHSB = phs;
    FRQB = frq;
    CTRB = pin;
    CTRB += (4 << 26);
    low(pin);
    PHSB = phsVal;
    dtb = abs(phsVal);
    tb = CNT;
  }
}
Ejemplo n.º 6
0
void InterpolateVideo::average()
{
	VFrame *frame = get_output();
	int w = frame->get_w();
	int h = frame->get_h();

	switch(frame->get_color_model())
	{
		case BC_RGB_FLOAT:
			AVERAGE(float, float, 3, 1);
			break;
		case BC_RGB888:
		case BC_YUV888:
			AVERAGE(unsigned char, int, 3, 0xff);
			break;
		case BC_RGBA_FLOAT:
			AVERAGE(float, float, 4, 1);
			break;
		case BC_RGBA8888:
		case BC_YUVA8888:
			AVERAGE(unsigned char, int, 4, 0xff);
			break;
	}
}
Ejemplo n.º 7
0
int BrightnessMain::handle_opengl()
{
#ifdef HAVE_GL
	static char *brightness_yuvluma_frag = 
		"uniform sampler2D tex;\n"
		"uniform float brightness;\n"
		"uniform float contrast;\n"
		"uniform float offset;\n"
		"void main()\n"
		"{\n"
		"	vec4 yuva = texture2D(tex, gl_TexCoord[0].st);\n"
		"	yuva.r += brightness;\n"
		"	yuva.r = yuva.r * contrast + offset;\n"
		"	gl_FragColor = yuva;\n"
		"}\n";

	static char *brightness_yuv_frag = 
		"uniform sampler2D tex;\n"
		"uniform float brightness;\n"
		"uniform float contrast;\n"
		"uniform float offset;\n"
		"void main()\n"
		"{\n"
		"	vec4 yuva = texture2D(tex, gl_TexCoord[0].st);\n"
		"	yuva.r += brightness;\n"
		"	yuva.rgb *= vec3(contrast, contrast, contrast);\n"
		"	yuva.rgb += vec3(offset, offset, offset);\n"
		"	gl_FragColor = yuva;\n"
		"}\n";

	static char *brightness_rgb_frag =
		"uniform sampler2D tex;\n"
		"uniform float brightness;\n"
		"uniform float contrast;\n"
		"uniform float offset;\n"
		"void main()\n"
		"{\n"
		"	vec4 rgba = texture2D(tex, gl_TexCoord[0].st);\n"
		"	rgba.rgb += vec3(brightness, brightness, brightness);\n"
		"	rgba.rgb *= vec3(contrast, contrast, contrast);\n"
		"	rgba.rgb += vec3(offset, offset, offset);\n"
		"	gl_FragColor = rgba;\n"
		"}\n";

	static char *brightness_rgbluma_frag =
		"uniform sampler2D tex;\n"
		"uniform float brightness;\n"
		"uniform float contrast;\n"
		"uniform float offset;\n"
		"void main()\n"
		"{\n"
 		"	const mat3 yuv_to_rgb_matrix = mat3(\n"
 		"		1,       1,        1, \n"
 		"		0,       -0.34414, 1.77200, \n"
 		"		1.40200, -0.71414, 0);\n"
 		"	const mat3 rgb_to_yuv_matrix = mat3(\n"
 		"		0.29900, -0.16874, 0.50000, \n"
 		"		0.58700, -0.33126, -0.41869, \n"
 		"		0.11400, 0.50000,  -0.08131);\n"
		"	vec4 rgba = texture2D(tex, gl_TexCoord[0].st);\n"
		"	rgba.rgb = rgb_to_yuv_matrix * rgba.rgb;\n"
		"	rgba.r += brightness;\n"
		"	rgba.r = rgba.r * contrast + offset;\n"
		"	rgba.rgb = yuv_to_rgb_matrix * rgba.rgb;\n"
		"	gl_FragColor = rgba;\n"
		"}\n";

	get_output()->to_texture();
	get_output()->enable_opengl();

	unsigned int shader_id = 0;
	switch(get_output()->get_color_model())
	{
		case BC_YUV888:
		case BC_YUVA8888:
			if(config.luma)
				shader_id = VFrame::make_shader(0,
					brightness_yuvluma_frag,
					0);
			else
				shader_id = VFrame::make_shader(0,
					brightness_yuv_frag,
					0);
			break;
		default:
			if(config.luma)
				shader_id = VFrame::make_shader(0,
					brightness_rgbluma_frag,
					0);
			else
				shader_id = VFrame::make_shader(0,
					brightness_rgb_frag,
					0);
			break;
	}


	if(shader_id > 0) 
	{
		glUseProgram(shader_id);
		glUniform1i(glGetUniformLocation(shader_id, "tex"), 0);
		glUniform1f(glGetUniformLocation(shader_id, "brightness"), config.brightness / 100);
		float contrast = (config.contrast < 0) ? 
			(config.contrast + 100) / 100 : 
			(config.contrast + 25) / 25;
		glUniform1f(glGetUniformLocation(shader_id, "contrast"), contrast);
		float offset = 0.5 - contrast / 2;
		glUniform1f(glGetUniformLocation(shader_id, "offset"), offset);
	}

	get_output()->init_screen();
	get_output()->bind_texture(0);

	

	get_output()->draw_texture();
	glUseProgram(0);
	get_output()->set_opengl_state(VFrame::SCREEN);
//printf("BrightnessMain::handle_opengl 100 %x\n", glGetError());
#endif
}
Ejemplo n.º 8
0
int
align (Display *display,
       int argc,
       const char *argv[],
       const char *funcname,
       const char *usage)
{
    RROutput outputid;
    XRROutputInfo *output;
    int ret;
    const char *inputarg;
    int screen;
    const char *pre_script;
    const char *post_script;

    ret = get_screen (display, argc, argv, funcname, usage, &screen);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_argval (argc, argv, "input", funcname, usage, "Virtual core pointer", &inputarg);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_output (display, argc, argv, funcname, usage, &outputid, &output);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_argval (argc, argv, "pre-script", funcname, usage, "", &pre_script);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    ret = get_argval (argc, argv, "post-script", funcname, usage, "", &post_script);
    if (ret == EXIT_FAILURE) {
        return ret;
    }

    if (ret != EXIT_FAILURE) {
        Window root;

        if (verbose) {
            fprintf (stderr, "Output: %s\n", output->name);
        }

        root = RootWindow (display, screen);

        ret = run_script (pre_script);
        if (ret != EXIT_FAILURE) {
            ret = apply_transform (display, root, output->crtc, inputarg);
            if (ret != EXIT_FAILURE) {
                ret = run_script (post_script);
            }
        }
    }

    XRRFreeOutputInfo (output);
    return ret;
}
Ejemplo n.º 9
0
Archivo: driver.c Proyecto: 1m69/xapian
extern int main(int argc, char * argv[]) {

    NEW(options, o);
    if (argc == 1) print_arglist();
    read_options(o, argc, argv);
    {
        symbol * filename = add_s_to_b(0, argv[1]);
        char * file;
        symbol * u = get_input(filename, &file);
        if (u == 0) {
            fprintf(stderr, "Can't open input %s\n", argv[1]);
            exit(1);
        }
        {
            struct tokeniser * t = create_tokeniser(u, file);
            struct analyser * a = create_analyser(t);
            t->widechars = o->widechars;
            t->includes = o->includes;
            a->utf8 = t->utf8 = o->utf8;
            read_program(a);
            if (t->error_count > 0) exit(1);
            if (o->syntax_tree) print_program(a);
            close_tokeniser(t);
            if (!o->syntax_tree) {
                struct generator * g;

                const char * s = o->output_file;
                if (!s) {
                    fprintf(stderr, "Please include the -o option\n");
                    print_arglist();
                    exit(1);
                }
                g = create_generator(a, o);
                if (o->make_lang == LANG_C || o->make_lang == LANG_CPLUSPLUS) {
                    symbol * b = add_s_to_b(0, s);
                    b = add_s_to_b(b, ".h");
                    o->output_h = get_output(b);
                    b[SIZE(b) - 1] = 'c';
                    if (o->make_lang == LANG_CPLUSPLUS) {
                        b = add_s_to_b(b, "c");
                    }
                    o->output_src = get_output(b);
                    lose_b(b);

                    generate_program_c(g);
                    fclose(o->output_src);
                    fclose(o->output_h);
                }
#ifndef DISABLE_JAVA
                if (o->make_lang == LANG_JAVA) {
                    symbol * b = add_s_to_b(0, s);
                    b = add_s_to_b(b, ".java");
                    o->output_src = get_output(b);
                    lose_b(b);
                    generate_program_java(g);
                    fclose(o->output_src);
                }
#endif
#ifndef DISABLE_PYTHON
                if (o->make_lang == LANG_PYTHON) {
                    symbol * b = add_s_to_b(0, s);
                    b = add_s_to_b(b, ".py");
                    o->output_src = get_output(b);
                    lose_b(b);
                    generate_program_python(g);
                    fclose(o->output_src);
                }
#endif
#ifndef DISABLE_JSX
                if (o->make_lang == LANG_JSX) {
                    symbol * b = add_s_to_b(0, s);
                    b = add_s_to_b(b, ".jsx");
                    o->output_src = get_output(b);
                    lose_b(b);
                    generate_program_jsx(g);
                    fclose(o->output_src);
                }
#endif
                close_generator(g);
            }
            close_analyser(a);
        }
        lose_b(u);
        lose_b(filename);
    }
    {   struct include * p = o->includes;
        while (p) {
            struct include * q = p->next;
            lose_b(p->b); FREE(p); p = q;
        }
    }
    FREE(o);
    if (space_count) fprintf(stderr, "%d blocks unfreed\n", space_count);
    return 0;
}
Ejemplo n.º 10
0
void construct_cascade_concord(cassys_tokens_list *list, const char *text_name, int number_of_transducer,
    Encoding encoding_output,int bom_output,int mask_encoding_compatibility_input){

	fprintf(stdout, "Construct cascade concord\n");

	struct snt_files *snt_file = new_snt_files(text_name);

	U_FILE *concord_desc_file = u_fopen_versatile_encoding(encoding_output,bom_output,mask_encoding_compatibility_input, snt_file->concord_ind,U_WRITE);
	if( concord_desc_file == NULL){
		perror("u_fopen\n");
		fprintf(stderr,"Cannot open file %s\n",snt_file->concord_ind);
		exit(1);
	}

	fprintf(stdout, "Concord File %s successfully opened\n",snt_file->concord_ind);

	if (list == NULL) {
		fatal_error("empty text");
	}

	u_fprintf(concord_desc_file,"#M\n");

	cassys_tokens_list *current_pos_in_original_text = list;
	cassys_tokens_list *output=get_output(list,number_of_transducer);
	struct list_ustring *sentence = NULL;
	bool output_detected = false;
	long token_position=0;


	while(current_pos_in_original_text != NULL && output != NULL){
		if(output -> transducer_id == 0){
			if(output_detected){
				int start_position = token_position;
				int last_token_length = 0;
				while(current_pos_in_original_text != output){
					token_position ++;
					last_token_length = u_strlen(current_pos_in_original_text -> token)-1;
					current_pos_in_original_text = current_pos_in_original_text -> next_token;
				}

				// token position pointe sur le token suivant déjà
				int end_position=token_position-1;

				if(sentence == NULL){
					fatal_error("construct_cassys_concordance : Phrase de remplacement vide\n");
				}

				struct list_ustring *iterator = sentence;
				while(iterator -> next != NULL){
					iterator = iterator -> next;
				}

				//display_list_ustring(iterator);


				u_fprintf(concord_desc_file, "%d.0.0 %d.%d.0 ",start_position,end_position,last_token_length);
				//u_fprintf(concord_desc_file, "%d.0.0 %d.0.0 ",start_position,end_position);

				iterator = sentence;
				while(iterator != NULL){
					u_fprintf(concord_desc_file,"%S",iterator->string);
					//u_printf("concord.ind : %S\n",iterator->string);
					iterator = iterator -> next;
				}
				//u_printf("\n");
				u_fprintf(concord_desc_file,"\n");

				current_pos_in_original_text
						= current_pos_in_original_text -> next_token;
				output = get_output(current_pos_in_original_text,
						number_of_transducer);
				token_position++;

				free_list_ustring(sentence);
				sentence = NULL;

				output_detected = false;
			} else {
				current_pos_in_original_text = current_pos_in_original_text -> next_token;
				output = get_output(current_pos_in_original_text,number_of_transducer);
				token_position++;
			}
		}
		else {
			//u_printf("insert new sentence\n");

			sentence = insert_at_end_of_list(output->token, sentence);
			output = output -> next_token;
			output = get_output(output, number_of_transducer);
			output_detected = true;
		}

	}


	u_fclose(concord_desc_file);
	free(snt_file);

}
Ejemplo n.º 11
0
int FlipMain::handle_opengl()
{
#ifdef HAVE_GL
	get_output()->to_texture();
	get_output()->enable_opengl();
	get_output()->init_screen();
	get_output()->bind_texture(0);

	if(config.flip_vertical && !config.flip_horizontal)
	{
		get_output()->draw_texture(0,
			0,
			get_output()->get_w(),
			get_output()->get_h(),
			0,
			get_output()->get_h(),
			get_output()->get_w(),
			0);
	}

	if(config.flip_horizontal && !config.flip_vertical)
	{
		get_output()->draw_texture(0,
			0,
			get_output()->get_w(),
			get_output()->get_h(),
			get_output()->get_w(),
			0,
			0,
			get_output()->get_h());
	}

	if(config.flip_vertical && config.flip_horizontal)
	{
		get_output()->draw_texture(0,
			0,
			get_output()->get_w(),
			get_output()->get_h(),
			get_output()->get_w(),
			get_output()->get_h(),
			0,
			0);
	}

	get_output()->set_opengl_state(VFrame::SCREEN);
#endif
}
Ejemplo n.º 12
0
// PredicateCondition::Like - Containing
TEST_F(OperatorsTableScanStringTest, ScanLikeContaining) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_string_like_containing.tbl", 1);
  auto scan = create_table_scan(_gt_string, ColumnID{1}, PredicateCondition::Like, "%schifffahrtsgesellschaft%");
  scan->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan->get_output(), expected_result);
}
Ejemplo n.º 13
0
bool
app_launcher::get_stderr(vogl::dynamic_string &output, size_t max_output)
{
    return get_output(m_stdout_pipe[1], output, max_output);
}
Ejemplo n.º 14
0
TEST_F(OperatorsProjectionTest, ExecutedOnAllChunks) {
  const auto projection = std::make_shared<opossum::Projection>(table_wrapper_a, expression_vector(add_(a_a, a_b)));
  projection->execute();
  EXPECT_TABLE_EQ_UNORDERED(projection->get_output(),
                            load_table("resources/test_data/tbl/projection/int_float_add.tbl"));
}
Ejemplo n.º 15
0
TEST_F(OperatorsTableScanStringTest, ScanLikeNonStringValue) {
  auto scan = create_table_scan(_gt_string, ColumnID{1}, PredicateCondition::Like, 1234);
  scan->execute();
  EXPECT_EQ(scan->get_output()->row_count(), 1u);
}
Ejemplo n.º 16
0
int HueEffect::handle_opengl()
{
#ifdef HAVE_GL
	const char *yuv_saturation_frag = 
		"uniform sampler2D tex;\n"
		"uniform float s_offset;\n"
		"uniform float v_offset;\n"
		"void main()\n"
		"{\n"
		"	vec4 pixel = texture2D(tex, gl_TexCoord[0].st);\n"
		"	pixel.r *= v_offset;\n"
		"	pixel.gb -= vec2(0.5, 0.5);\n"
		"	pixel.g *= s_offset;\n"
		"	pixel.b *= s_offset;\n"
		"	pixel.gb += vec2(0.5, 0.5);\n"
		"	gl_FragColor = pixel;\n"
		"}\n";


	const char *yuv_frag = 
		"uniform sampler2D tex;\n"
		"uniform float h_offset;\n"
		"uniform float s_offset;\n"
		"uniform float v_offset;\n"
		"void main()\n"
		"{\n"
		"	vec4 pixel = texture2D(tex, gl_TexCoord[0].st);\n"
			YUV_TO_RGB_FRAG("pixel")
			RGB_TO_HSV_FRAG("pixel")
		"	pixel.r += h_offset;\n"
		"	pixel.g *= s_offset;\n"
		"	pixel.b *= v_offset;\n"
		"	if(pixel.r >= 360.0) pixel.r -= 360.0;\n"
		"	if(pixel.r < 0.0) pixel.r += 360.0;\n"
			HSV_TO_RGB_FRAG("pixel")
			RGB_TO_YUV_FRAG("pixel")
		"	gl_FragColor = pixel;\n"
		"}\n";

	const char *rgb_frag = 
		"uniform sampler2D tex;\n"
		"uniform float h_offset;\n"
		"uniform float s_offset;\n"
		"uniform float v_offset;\n"
		"void main()\n"
		"{\n"
		"	vec4 pixel = texture2D(tex, gl_TexCoord[0].st);\n"
			RGB_TO_HSV_FRAG("pixel")
		"	pixel.r += h_offset;\n"
		"	pixel.g *= s_offset;\n"
		"	pixel.b *= v_offset;\n"
		"	if(pixel.r >= 360.0) pixel.r -= 360.0;\n"
		"	if(pixel.r < 0.0) pixel.r += 360.0;\n"
			HSV_TO_RGB_FRAG("pixel")
		"	gl_FragColor = pixel;\n"
		"}\n";


	get_output()->to_texture();
	get_output()->enable_opengl();

	unsigned int frag_shader = 0;
	switch(get_output()->get_color_model())
	{
		case BC_YUV888:
		case BC_YUVA8888:
// This is a lousy approximation but good enough for the masker.
			if(EQUIV(config.hue, 0))
				frag_shader = VFrame::make_shader(0,
					yuv_saturation_frag,
					0);
			else
				frag_shader = VFrame::make_shader(0,
					yuv_frag,
					0);
			break;
		default:
			frag_shader = VFrame::make_shader(0,
				rgb_frag,
				0);
			break;
	}


	if(frag_shader > 0) 
	{
		glUseProgram(frag_shader);
		glUniform1i(glGetUniformLocation(frag_shader, "tex"), 0);
		glUniform1f(glGetUniformLocation(frag_shader, "h_offset"), config.hue);
		glUniform1f(glGetUniformLocation(frag_shader, "s_offset"), 
			((float)config.saturation - MINSATURATION) / MAXSATURATION);
		glUniform1f(glGetUniformLocation(frag_shader, "v_offset"), 
			((float)config.value - MINVALUE) / MAXVALUE);
	}

	get_output()->init_screen();
	get_output()->bind_texture(0);
	get_output()->draw_texture();
	glUseProgram(0);
	get_output()->set_opengl_state(VFrame::SCREEN);
#endif
	return 0;
}
Ejemplo n.º 17
0
int ChromaKeyHSV::handle_opengl()
{
#ifdef HAVE_GL
// For macro
	ChromaKeyHSV *plugin = this;
	OUTER_VARIABLES

	static const char *yuv_shader = 
		"const vec3 black = vec3(0.0, 0.5, 0.5);\n"
		"\n"
		"vec4 yuv_to_rgb(vec4 color)\n"
		"{\n"
			YUV_TO_RGB_FRAG("color")
		"	return color;\n"
		"}\n"
		"\n"
		"vec4 rgb_to_yuv(vec4 color)\n"
		"{\n"
			RGB_TO_YUV_FRAG("color")
		"	return color;\n"
		"}\n";

	static const char *rgb_shader = 
		"const vec3 black = vec3(0.0, 0.0, 0.0);\n"
		"\n"
		"vec4 yuv_to_rgb(vec4 color)\n"
		"{\n"
		"	return color;\n"
		"}\n"
		"vec4 rgb_to_yuv(vec4 color)\n"
		"{\n"
		"	return color;\n"
		"}\n";

	static const char *hsv_shader = 
		"vec4 rgb_to_hsv(vec4 color)\n"
		"{\n"
			RGB_TO_HSV_FRAG("color")
		"	return color;\n"
		"}\n"
		"\n"
		"vec4 hsv_to_rgb(vec4 color)\n"
		"{\n"
			HSV_TO_RGB_FRAG("color")
		"	return color;\n"
		"}\n"
		"\n";

	static const char *show_rgbmask_shader = 
		"vec4 show_mask(vec4 color, vec4 color2)\n"
		"{\n"
		"	return vec4(1.0, 1.0, 1.0, min(color.a, color2.a));"
		"}\n";

	static const char *show_yuvmask_shader = 
		"vec4 show_mask(vec4 color, vec4 color2)\n"
		"{\n"
		"	return vec4(1.0, 0.5, 0.5, min(color.a, color2.a));"
		"}\n";

	static const char *nomask_shader = 
		"vec4 show_mask(vec4 color, vec4 color2)\n"
		"{\n"
		"	return vec4(color.rgb, min(color.a, color2.a));"
		"}\n";

	extern unsigned char _binary_chromakey_sl_start[];
	static const char *shader = (char*)_binary_chromakey_sl_start;

	get_output()->to_texture();
	get_output()->enable_opengl();
	get_output()->init_screen();

	const char* shader_stack[] = { 0, 0, 0, 0, 0 };

	switch(get_output()->get_color_model())
	{
		case BC_YUV888:
		case BC_YUVA8888:
			shader_stack[0] = yuv_shader;
			shader_stack[1] = hsv_shader;
			if(config.show_mask) 
				shader_stack[2] = show_yuvmask_shader;
			else
				shader_stack[2] = nomask_shader;
			shader_stack[3] = shader;
			break;

		default:
			shader_stack[0] = rgb_shader;
			shader_stack[1] = hsv_shader;
			if(config.show_mask) 
				shader_stack[2] = show_rgbmask_shader;
			else
				shader_stack[2] = nomask_shader;
			shader_stack[3] = shader;
			break;
	}


	unsigned int frag = VFrame::make_shader(0, 
		shader_stack[0], 
		shader_stack[1], 
		shader_stack[2], 
		shader_stack[3], 
		0);

	if(frag)
	{
		glUseProgram(frag);
		glUniform1i(glGetUniformLocation(frag, "tex"), 0);
		glUniform1f(glGetUniformLocation(frag, "red"), red);
		glUniform1f(glGetUniformLocation(frag, "green"), green);
		glUniform1f(glGetUniformLocation(frag, "blue"), blue);
		glUniform1f(glGetUniformLocation(frag, "in_slope"), in_slope);
		glUniform1f(glGetUniformLocation(frag, "out_slope"), out_slope);
		glUniform1f(glGetUniformLocation(frag, "tolerance"), tolerance);
		glUniform1f(glGetUniformLocation(frag, "tolerance_in"), tolerance_in);
		glUniform1f(glGetUniformLocation(frag, "tolerance_out"), tolerance_out);
		glUniform1f(glGetUniformLocation(frag, "sat"), sat);
		glUniform1f(glGetUniformLocation(frag, "min_s"), min_s);
		glUniform1f(glGetUniformLocation(frag, "min_s_in"), min_s_in);
		glUniform1f(glGetUniformLocation(frag, "min_s_out"), min_s_out);
		glUniform1f(glGetUniformLocation(frag, "min_v"), min_v);
		glUniform1f(glGetUniformLocation(frag, "min_v_in"), min_v_in);
		glUniform1f(glGetUniformLocation(frag, "min_v_out"), min_v_out);
		glUniform1f(glGetUniformLocation(frag, "max_v"), max_v);
		glUniform1f(glGetUniformLocation(frag, "max_v_in"), max_v_in);
		glUniform1f(glGetUniformLocation(frag, "max_v_out"), max_v_out);
		glUniform1f(glGetUniformLocation(frag, "spill_threshold"), spill_threshold);
		glUniform1f(glGetUniformLocation(frag, "spill_amount"), spill_amount);
		glUniform1f(glGetUniformLocation(frag, "alpha_offset"), alpha_offset);
		glUniform1f(glGetUniformLocation(frag, "hue_key"), hue_key);
		glUniform1f(glGetUniformLocation(frag, "saturation_key"), saturation_key);
		glUniform1f(glGetUniformLocation(frag, "value_key"), value_key);
	}


	get_output()->bind_texture(0);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	if(BC_CModels::components(get_output()->get_color_model()) == 3)
	{
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		get_output()->clear_pbuffer();
	}
	get_output()->draw_texture();

	glUseProgram(0);
	get_output()->set_opengl_state(VFrame::SCREEN);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glDisable(GL_BLEND);


#endif
	return 0;
}
Ejemplo n.º 18
0
int AudioALSA::flush_device()
{
	if(get_output()) snd_pcm_drain(get_output());
	return 0;
}
Ejemplo n.º 19
0
TEST_P(OperatorsTableScanStringTest, ScanNotLikeEmptyStringOnDict) {
  // wildcard has to be placed at front and/or back of search string
  auto scan = create_table_scan(_gt_string_compressed, ColumnID{1}, PredicateCondition::NotLike, "%");
  scan->execute();
  EXPECT_EQ(scan->get_output()->row_count(), 0u);
}
Ejemplo n.º 20
0
TEST_P(OperatorsTableScanStringTest, ScanLikeNotFoundOnDictSegment) {
  auto scan = create_table_scan(_gt_string_compressed, ColumnID{1}, PredicateCondition::Like, "%not_there%");
  scan->execute();
  EXPECT_EQ(scan->get_output()->row_count(), 0u);
}
Ejemplo n.º 21
0
static int parse_client_line(const int client_socket, char *msg)
{
  char *token;
  
  /* On récupère le premier mot, s'il est vide, on retourne direct  */
  if (!(token = strtok(msg, " ")))
    return MSG_OK;

  /*****************************************************************************
   *                              CMD_QUIT
   ****************************************************************************/
  if (!strcmp(CMD_QUIT, token))
    {
      send_ok(client_socket, DETAIL_RET_QUIT);
      return MSG_QUIT;
    }
  
  /*****************************************************************************  
   *                          CMD_CREATE_PROCESS 
   ****************************************************************************/
  else if (!strcmp(CMD_CREATE_PROCESS, token))
    {
      char *args[MAX_ARGS];
      char **pc = args;

      /* On récup le nom du prog */
      if (!(token = strtok(NULL, " ")))
	{
	  send_failure(client_socket, DETAIL_RET_CREATE_PROCESS_SYNTAX);
	  return MSG_ERR;
	}
      
      /* strtok renvoie un buffer static, on le copie */
      /* *pc = args[0] = nom du programme */
      if (!(*pc++ = strdup(token))) 
	{
	  perror("strdup");
	  return MSG_ERR;
	}
      
      /* La suite devient optionelle, c'est les arguments */
      while ((token = strtok(NULL, " ")))
	{
	  if ((*pc++ = strdup(token)) == NULL)
	    {
	      perror("strdup");
	      return MSG_ERR;
	    }
	}
      
      *pc = NULL;             /* Fin des arguments */
      
      /* On crée le processus */
      pid_t proc = create_process(args[0], args);

      /* Le processus n'a pas pu être créé */
      if (proc == -1) {
	send_failure(client_socket, DETAIL_RET_CREATE_PROCESS_ERROR);
	return MSG_ERR;
      }

      send_ok(client_socket, itoa(proc));
      return MSG_OK;
    }

  /*****************************************************************************  
   *                          CMD_DESTROY_PROCESS 
   ****************************************************************************/
  else if (!strcmp(CMD_DESTROY_PROCESS, token))
    {
      if ((token = strtok(NULL, " ")) == NULL)
	{
	  send_failure(client_socket, DETAIL_RET_DESTROY_PROCESS_SYNTAX);
	  return MSG_ERR;
	}
      
      pid_t process_to_kill = atoi(token);
      
      if (!process_exists(process_to_kill))
	{
	  send_failure(client_socket, DETAIL_RET_UNKNOWN_PROCESS);
	  return MSG_ERR;
	}
      
      destroy_process(process_to_kill);
      send_ok(client_socket, NULL);
      return MSG_OK;
    }

  /*****************************************************************************  
   *                          CMD_SEND_INPUT      
   ****************************************************************************/
  else if (!strcmp(CMD_SEND_INPUT, token))
    {
      char buffer[MESSAGE_BUFFER_SIZE];
      buffer[0] = '\0';
      
      /* On récup le PID */
      if ((token = strtok(NULL, " ")) == NULL)
	{
	  send_failure(client_socket, DETAIL_RET_SEND_INPUT_SYNTAX);
	  return MSG_ERR;
	}
      
      /* Il existe ? */
      pid_t send_to_process = atoi(token);
      if (!process_exists(send_to_process))
	{
	  send_failure(client_socket, DETAIL_RET_UNKNOWN_PROCESS);
	  return MSG_ERR;
	}
      
      /* Il est déjà terminé ? */
      if (get_return_code(send_to_process) != PROCESS_NOT_TERMINATED)
	{
	  send_failure(client_socket, DETAIL_RET_PROCESS_TERMINATED);
	  return MSG_ERR;
	}

      /* Son stdin est ouvert ? */
      if (!input_open(send_to_process))
	{
	  send_failure(client_socket, DETAIL_RET_INPUT_CLOSE);
	  return MSG_ERR;
	}

      /* On récup' le message à envoyer  */
      /* TODO: Prendre la chaîne telle qu'elle, sans splitter puis merger avec un espace */
      while ((token = strtok(NULL, " ")))
	{
	  strcat(buffer, token);
	  strcat(buffer, " ");
	}
      
      /* Si le message est vide, erreur ! */
      if (strlen(buffer) == 0)
	{
	  send_failure(client_socket, DETAIL_RET_SEND_INPUT_SYNTAX);
	  return MSG_ERR;
        }
      
      /* Sinon on envoie ! */
      send_input(send_to_process, buffer);
      send_ok(client_socket, NULL);
      return MSG_OK;
    }


  /*****************************************************************************  
   *                          CMD_CLOSE_INPUT     
   ****************************************************************************/
  else if (!strcmp(CMD_CLOSE_INPUT, token))
    {
      if ((token = strtok(NULL, " ")) == NULL)
	{
	  send_failure(client_socket, DETAIL_RET_CLOSE_INPUT_SYNTAX);
	  return MSG_ERR;
        }
      
      pid_t process_to_close_input = atoi(token);
      if (!process_exists(process_to_close_input))
	{
	  send_failure(client_socket, DETAIL_RET_UNKNOWN_PROCESS);
	  return MSG_ERR;
	}

      close_input(process_to_close_input);
      send_ok(client_socket, NULL);
      return MSG_OK;
    }
  
  /*****************************************************************************  
   *                          CMD_GET_OUTPUT
   ****************************************************************************/
  else if (!strcmp(CMD_GET_OUTPUT, token))
    {
      if ((token = strtok(NULL, " ")) == NULL)
	{
	  send_failure(client_socket, DETAIL_RET_GET_OUTPUT_SYNTAX);
	  return MSG_ERR;
	}
      
      pid_t process_to_get_output = atoi(token);
      if (!process_exists(process_to_get_output))
	{
	  send_failure(client_socket, DETAIL_RET_UNKNOWN_PROCESS);
	  return MSG_ERR;
        }
     
      get_output(client_socket, process_to_get_output);
      send_ok(client_socket, NULL);
      return MSG_OK;
    }


  /*****************************************************************************  
   *                          CMD_GET_ERROR
   ****************************************************************************/
  else if (!strcmp(CMD_GET_ERROR, token))
    {
      if ((token = strtok(NULL, " ")) == NULL)
	{
	  send_failure(client_socket, DETAIL_RET_GET_ERROR_SYNTAX);
	  return MSG_ERR;
        }
      
      pid_t process_to_get_error = atoi(token);
      if (!process_exists(process_to_get_error))
	{
	  send_failure(client_socket, DETAIL_RET_UNKNOWN_PROCESS);
	  return MSG_ERR;
	}
      
      get_error(client_socket, process_to_get_error);
      send_ok(client_socket, NULL);
      return MSG_OK;
    }


  /*****************************************************************************  
   *                          CMD_GET_RETURN_CODE
   ****************************************************************************/
  else if (!strcmp(CMD_GET_RETURN_CODE, token))
    {
      if ((token = strtok(NULL, " ")) == NULL)
	{
	  send_failure(client_socket, DETAIL_RET_GET_RETURN_CODE_SYNTAX);
	  return MSG_ERR;
        }
      
      pid_t process_to_get_ret = atoi(token);
      if (!process_exists(process_to_get_ret))
	{
	  send_failure(client_socket, DETAIL_RET_UNKNOWN_PROCESS);
	  return MSG_ERR;
	}
      
      int ret = get_return_code(process_to_get_ret);
      if (ret == PROCESS_NOT_TERMINATED)
	{
	  send_failure(client_socket, DETAIL_RET_GET_RETURN_CODE_ERROR);
	  return MSG_ERR;
	}
      
      send_ok(client_socket, itoa(ret));
      return MSG_OK;
    }

  /*****************************************************************************  
   *                          CMD_LIST_PROCESS   
   ****************************************************************************/
  else if (!strcmp(CMD_LIST_PROCESS, token))
    {
      list_process(client_socket);
      send_ok(client_socket, NULL);
      return MSG_OK;
    }

  /*****************************************************************************  
   *                          CMD_GET_HELP
   ****************************************************************************/
  else if (!strcmp(CMD_GET_HELP, token))
    {
      send_basic(client_socket, help, strlen(help));
      return MSG_OK;
    }

  /*****************************************************************************  
   *                        COMMANDE INCONNUE
   ****************************************************************************/
  else
    {
      send_failure(client_socket, DETAIL_RET_UNKNOWN_COMMAND);
      return MSG_UNKNOWN_COMMAND;
    }
}
Ejemplo n.º 22
0
int8_t led_get(struct packet_t *packet) {
	uart_putstr_P(PSTR("led_get()\r\n"));
	return set_data_int16(packet,get_output(LED1));
}
Ejemplo n.º 23
0
            void match_orders( std::vector<signed_transaction>& matched,  asset::type quote, asset::type base )
            { try {
               ilog( "match orders.." );
               auto bids = _market_db.get_bids( quote, base );
               auto asks = _market_db.get_asks( quote, base );
               wlog( "asks: ${asks}", ("asks",asks) );
               wlog( "bids: ${bids}", ("bids",bids) );

               fc::optional<trx_output>  ask_change;
               fc::optional<trx_output>  bid_change;
               fc::optional<trx_output>  cover_change;

               address                   bid_payout_address;
               fc::optional<asset>       bid_payout;

               asset                                cover_collat;       
               fc::optional<claim_by_cover_output>  cover_payout;


               signed_transaction market_trx;
               market_trx.timestamp = fc::time_point::now();


               /** asks are sorted from low to high, so we start
                * with the lowest ask, and check to see if there are
                * any bids that are greaterthan or equal to the ask, if
                * there are then either the full bid or full ask will be
                * filled.  If the full bid is filled, then move on to the
                * next bid, and save the leftover ask.  If the left over
                * ask is filled, then move to the next ask.
                *
                * When there are no more pairs that can be matched, exit
                * the loop and any partial payouts are made.  
                */
               auto ask_itr = asks.begin();
               auto bid_itr = bids.rbegin();
               while( ask_itr != asks.end() &&
                      bid_itr != bids.rend() )
               { 
                  trx_output working_ask;
                  trx_output working_bid;

                  if( ask_change ) {  working_ask = *ask_change; }
                  else             {  working_ask = get_output( ask_itr->location );  }

                  if( bid_change ) {  working_bid = *bid_change; }
                  else             {  working_bid = get_output( bid_itr->location);   }

                  claim_by_bid_output bid_claim = working_bid.as<claim_by_bid_output>();

                  if( working_ask.claim_func == claim_by_long )
                  {
                     auto long_claim = working_ask.as<claim_by_long_output>();
                     if( long_claim.ask_price > bid_claim.ask_price )
                     {
                        break; // exit the while loop, no more trades can occur
                     }
                     asset bid_amount = working_bid.get_amount() * bid_claim.ask_price;
                     asset ask_amount = working_ask.get_amount() * long_claim.ask_price;
                     FC_ASSERT( bid_amount.unit == ask_amount.unit );

                     auto  trade_amount = std::min(bid_amount,ask_amount);

                     ilog( "bid amount: ${b} @ ${bp}  ask amount: ${a} @ ${ap}", ("b",bid_amount)("a",ask_amount)("bp",bid_claim.ask_price)("ap",long_claim.ask_price) );

                     asset bid_change_amount   = working_bid.get_amount();
                     bid_change_amount        -= trade_amount * bid_claim.ask_price;
                     ilog( "bid change.. ${c}", ("c",bid_change_amount) );
                     
                     asset ask_change_amount   = working_ask.get_amount();
                     ask_change_amount        -= trade_amount * long_claim.ask_price;
                     ilog( "ask change.. ${c}", ("c",ask_change_amount) );
                      
                     if( ask_change_amount != bid_change_amount  && ask_change_amount != asset(0,working_bid.unit) )
                     {
                       FC_ASSERT( !"At least one of the bid or ask should be completely filled", "", 
                                  ("ask_change_amount",ask_change_amount)("bid_change_amount",bid_change_amount) );
                     }
                     
                     bid_payout_address = bid_claim.pay_address;
                     auto bid_payout_amount  = bid_amount - (bid_change_amount * bid_claim.ask_price);

                     if( bid_payout ) { *bid_payout += bid_payout_amount; }
                     else             { bid_payout   = bid_payout_amount; }

                     if( cover_payout ) 
                     { 
                        cover_payout->payoff_amount += trade_amount.get_rounded_amount();
                        cover_collat                += (trade_amount * long_claim.ask_price)*2;
                     }
                     else
                     {
                        cover_payout                = claim_by_cover_output();
                        cover_payout->owner         = long_claim.pay_address;
                        cover_payout->payoff_unit   = trade_amount.unit;
                        cover_payout->payoff_amount = trade_amount.get_rounded_amount();
                        cover_collat                = (trade_amount * long_claim.ask_price)*2;
                     }

                     if( bid_change_amount != asset(0, working_bid.unit) )
                     {
                        // TODO: accumulate fractional parts, round at the end?....
                        working_bid.amount = bid_change_amount.get_rounded_amount(); 
                        bid_change = working_bid;
                        elog( "we DID NOT fill the bid..." );
                     }
                     else // we have filled the bid!  
                     {
                        elog( "we filled the bid..." );
                        market_trx.inputs.push_back( bid_itr->location );
                        market_trx.outputs.push_back( 
                                trx_output( claim_by_signature_output( bid_claim.pay_address ), bid_payout->get_rounded_asset() ) );
                        bid_change.reset();
                        bid_payout.reset();
                        ++bid_itr;
                     }

                     if( ask_change_amount != asset( 0, working_bid.unit ) )
                     {
                        working_ask.amount = ask_change_amount.get_rounded_amount();
                        ask_change = working_ask;
                     }
                     else // we have filled the ask!
                     {
                        market_trx.inputs.push_back( ask_itr->location );
                        market_trx.outputs.push_back( trx_output( *cover_payout, cover_collat ) );
                        ask_change.reset();
                        cover_payout.reset();
                        ++ask_itr;
                     }
                  }
                  else if( working_ask.claim_func == claim_by_bid )
                  {
                     FC_ASSERT( !"Not Implemented" );
                     claim_by_bid_output ask_claim = working_ask.as<claim_by_bid_output>();
                     if( ask_claim.ask_price > bid_claim.ask_price )
                     {
                        break;
                     }
                     // TODO: implement straight trades..
                  }
                  else
                  {
                     FC_ASSERT( !"Ask must either be a claim by bid or claim by long",
                                "", ("ask", working_ask) );  
                  }

               } // while( ... ) 
               if( ask_change && ask_itr != asks.end()  ) market_trx.inputs.push_back( ask_itr->location );
               if( bid_change && bid_itr != bids.rend() ) market_trx.inputs.push_back( bid_itr->location );
              
               if( ask_change )
               { 
                  ilog( "ask_change: ${ask_change}", ("ask_change",ask_change) ); 
                  market_trx.outputs.push_back( *ask_change ); 
               }
               if( bid_change )
               {
                  ilog( "bid_change: ${bid_change}", ("bid_change",bid_change) ); 
                  market_trx.outputs.push_back( *bid_change ); 
               }
               if( bid_payout ) 
               {
                   ilog( "bid_payout ${payout}", ("payout",bid_payout) );
                   market_trx.outputs.push_back( 
                            trx_output( claim_by_signature_output( bid_payout_address ), *bid_payout ) );
               }
               else
               {
                    wlog ( "NO BID PAYOUT" );
               }
               if( cover_payout ) 
               {
                   ilog( "cover_payout ${payout}", ("payout",cover_payout) );
                   market_trx.outputs.push_back( trx_output( *cover_payout, cover_collat ) );
               }
               wlog( "Market Transaction: ${trx}", ("trx", market_trx) );
               if( market_trx.inputs.size() )
               {
                   FC_ASSERT( market_trx.outputs.size() );
                   matched.push_back(market_trx);
               }

               //ilog( "done match orders.." );
            } FC_RETHROW_EXCEPTIONS( warn, "", ("quote",quote)("base",base) ) }
Ejemplo n.º 24
0
TEST_P(OperatorsTableScanStringTest, ScanLikeEndingOnDictSegment) {
  std::shared_ptr<Table> expected_result = load_table("resources/test_data/tbl/int_string_like_ending.tbl", 1);
  auto scan = create_table_scan(_gt_string_compressed, ColumnID{1}, PredicateCondition::Like, "%gesellschaft");
  scan->execute();
  EXPECT_TABLE_EQ_UNORDERED(scan->get_output(), expected_result);
}
Ejemplo n.º 25
0
size_t
DVDGraph::get_info(char *_buf, size_t _len) const
{
  Speakers spk;
  static const size_t buf_size = 2048;
  char buf[buf_size];
  size_t pos = 0;

  spk = get_input();
  pos += sprintf(buf + pos, "Input format: %s %s %i\n", spk.format_text(), spk.mode_text(), spk.sample_rate);

  spk = user_spk;
  pos += sprintf(buf + pos, "User format: %s %s %i\n", spk.format_text(), spk.mode_text(), spk.sample_rate);

  spk = get_output();
  pos += sprintf(buf + pos, "Output format: %s %s %i\n", spk.format_text(), spk.mode_text(), spk.sample_rate);

  if (use_spdif)
  {
    pos += sprintf(buf + pos, "\nUse SPDIF\n");

    pos += sprintf(buf + pos, "  SPDIF status: ");
    switch (spdif_status)
    {
      case SPDIF_MODE_NONE:        pos += sprintf(buf + pos, "No data\n"); break;
      case SPDIF_MODE_DISABLED:    pos += sprintf(buf + pos, "Disabled "); break;
      case SPDIF_MODE_PASSTHROUGH: pos += sprintf(buf + pos, "SPDIF passthrough\n"); break;
      case SPDIF_MODE_ENCODE:      pos += sprintf(buf + pos, "AC3 encode\n"); break;
      default:                     pos += sprintf(buf + pos, "Unknown\n"); break;
    }

    if (spdif_status == SPDIF_MODE_DISABLED)
    {
      switch (spdif_err)
      {
        case SPDIF_ERR_STEREO_PCM:       pos += sprintf(buf + pos, "(Do not encode stereo PCM)\n"); break;
        case SPDIF_ERR_FORMAT:           pos += sprintf(buf + pos, "(Format is not allowed for passthrough)\n"); break;
        case SPDIF_ERR_SAMPLE_RATE:      pos += sprintf(buf + pos, "(Disallowed sample rate)\n"); break;
        case SPDIF_ERR_SINK:             pos += sprintf(buf + pos, "(SPDIF output is not supported)\n"); break;
        case SPDIF_ERR_ENCODER_DISABLED: pos += sprintf(buf + pos, "(AC3 encoder disabled)\n"); break;
        case SPDIF_ERR_PROC:             pos += sprintf(buf + pos, "(Cannot determine format to encode)\n"); break;
        case SPDIF_ERR_ENCODER:          pos += sprintf(buf + pos, "(Encoder does not support the format given)\n"); break;
        default:                         pos += sprintf(buf + pos, "\n"); break;
      }
    }

    pos += sprintf(buf + pos, "  SPDIF passthrough for:");
    if (spdif_pt & FORMAT_MASK_MPA) pos += sprintf(buf + pos, " MPA");
    if (spdif_pt & FORMAT_MASK_AC3) pos += sprintf(buf + pos, " AC3");
    if (spdif_pt & FORMAT_MASK_DTS) pos += sprintf(buf + pos, " DTS");
    pos += sprintf(buf + pos, spdif_pt? "\n": " -\n");

    if (spdif_encode)
      pos += sprintf(buf + pos, "  Use AC3 encoder (%s)\n",
        spdif_stereo_pt? "do not encode stereo PCM": "encode stereo PCM");
    else
      pos += sprintf(buf + pos, "  Do not use AC3 encoder\n");

    if (spdif_as_pcm)
      pos += sprintf(buf + pos, "  SPDIF as PCM output");

    if (spdif_check_sr)
    {
      if (!spdif_allow_48 && !spdif_allow_44 && !spdif_allow_32)
        pos += sprintf(buf + pos, "  Check SPDIF sample rate: NO ONE SAMPLE RATE ALLOWED!\n");
      else
      {
        pos += sprintf(buf + pos, "  Check SPDIF sample rate (allow:");
        if (spdif_allow_48) pos += sprintf(buf + pos, " 48kHz");
        if (spdif_allow_44) pos += sprintf(buf + pos, " 44.1kHz");
        if (spdif_allow_32) pos += sprintf(buf + pos, " 32kHz");
        pos += sprintf(buf + pos, ")\n");
      }
    }
    else
      pos += sprintf(buf + pos, "  Do not check SPDIF sample rate\n");

    if (query_sink)
      pos += sprintf(buf + pos, "  Query for SPDIF output support\n");
    else
      pos += sprintf(buf + pos, "  Do not query for SPDIF output support\n");
  }

  if (chain_next(node_start) != node_end)
  {
    pos += sprintf(buf + pos, "\nDecoding chain:\n");
    pos += chain_text(buf + pos, buf_size - pos);

    pos += sprintf(buf + pos, "\n\nFilters info (in order of processing):\n\n");
    int node = chain_next(node_start);
    while (node != node_end)
    {
      const char *filter_name = get_name(node);
      if (!filter_name) filter_name = "Unknown filter";
      pos += sprintf(buf + pos, "%s:\n", filter_name);

      switch (node)
      {
      case state_spdif_pt:
        pos += spdifer_pt.get_info(buf + pos, buf_size - pos);
        break;

      case state_decode:
        pos += dec.get_info(buf + pos, buf_size - pos);
        break;

      case state_proc:
      case state_proc_enc:
        pos += proc.get_info(buf + pos, buf_size - pos);
        pos += sprintf(buf + pos, "\n");
        break;

      case state_spdif_enc:
        pos += spdifer_enc.get_info(buf + pos, buf_size - pos);
        break;

      default:
        pos += sprintf(buf + pos, "-\n");
        break;
      }
      pos += sprintf(buf + pos, "\n");
      node = chain_next(node);
    }
  }

  if (pos + 1 > _len) pos = _len - 1;
  memcpy(_buf, buf, pos + 1);
  _buf[pos] = 0;
  return pos;
}
Ejemplo n.º 26
0
int LensMain::process_buffer(VFrame *frame,
	int64_t start_position,
	double frame_rate)
{
	VFrame *input;
	load_configuration();
	
	if(get_use_opengl())
	{
		input = frame;
	}
	else
	{
		input = new_temp(frame->get_w(), frame->get_h(), frame->get_color_model());
	}
	
	read_frame(input, 
		0, 
		start_position, 
		frame_rate,
		get_use_opengl());


	if(get_use_opengl())
	{
		run_opengl();
		return 0;
	}
	else
	{
		if(!engine) engine = new LensEngine(this);
		engine->process_packages();
		if(config.draw_guides)
		{
// Draw center
#define CENTER_H 20
#define CENTER_W 20
#define DRAW_GUIDES(components, type, max) \
{ \
	type **rows = (type**)get_output()->get_rows(); \
	if(center_x >= 0 && center_x < w || \
		center_y >= 0 && center_y < h) \
	{ \
		type *hrow = rows[center_y] + components * (center_x - CENTER_W / 2); \
		for(int i = center_x - CENTER_W / 2; i <= center_x + CENTER_W / 2; i++) \
		{ \
			if(i >= 0 && i < w) \
			{ \
				hrow[0] = max - hrow[0]; \
				hrow[1] = max - hrow[1]; \
				hrow[2] = max - hrow[2]; \
				hrow += components; \
			} \
		} \
 \
		for(int i = center_y - CENTER_W / 2; i <= center_y + CENTER_W / 2; i++) \
		{ \
			if(i >= 0 && i < h) \
			{ \
				type *vrow = rows[i] + center_x * components; \
				vrow[0] = max - vrow[0]; \
				vrow[1] = max - vrow[1]; \
				vrow[2] = max - vrow[2]; \
			} \
		} \
	} \
}

			int w = get_output()->get_w();
			int h = get_output()->get_h();
			int center_x = (int)(config.center_x * w / 100);
			int center_y = (int)(config.center_y * h / 100);
			switch(get_output()->get_color_model())
			{
				case BC_RGB_FLOAT:
					DRAW_GUIDES(3, float, 1.0)
					break;
				case BC_RGBA_FLOAT:
					DRAW_GUIDES(4, float, 1.0)
					break;
				case BC_RGB888:
					DRAW_GUIDES(3, unsigned char, 0xff)
					break;
				case BC_RGBA8888:
					DRAW_GUIDES(4, unsigned char, 0xff)
					break;
				case BC_YUV888:
					DRAW_GUIDES(3, unsigned char, 0xff)
					break;
				case BC_YUVA8888:
					DRAW_GUIDES(4, unsigned char, 0xff)
					break;
			}

		}
	}
Ejemplo n.º 27
0
void
#line 252 "./cwebdir/ctang-w2c.ch"
 phase_two P1H(void){
#line 539 "./cwebdir/ctangle.w"
web_file_open= 0;
cur_line= 1;
/*28:*/
#line 325 "./cwebdir/ctangle.w"

stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info;
cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;

/*:28*/
#line 541 "./cwebdir/ctangle.w"
;
/*43:*/
#line 595 "./cwebdir/ctangle.w"

if(!output_defs_seen)
output_defs();

/*:43*/
#line 542 "./cwebdir/ctangle.w"
;
if(text_info->text_link==0&&cur_out_file==end_output_files){
printf("\n! No program text was specified.");mark_harmless;

}
else{
if(cur_out_file==end_output_files){
if(show_progress)
printf("\nWriting the output file (%s):",C_file_name);
}
else{
if(show_progress){
printf("\nWriting the output files:");

printf(" (%s)",C_file_name);
update_terminal;
}
if(text_info->text_link==0)goto writeloop;
}
while(stack_ptr> stack)get_output();
flush_buffer();
writeloop:/*42:*/
#line 572 "./cwebdir/ctangle.w"

for(an_output_file= end_output_files;an_output_file> cur_out_file;){
an_output_file--;
sprint_section_name(output_file_name,*an_output_file);
fclose(C_file);
C_file= fopen(output_file_name,"w");
if(C_file==0)fatal("! Cannot open output file:",output_file_name);

printf("\n(%s)",output_file_name);update_terminal;
cur_line= 1;
stack_ptr= stack+1;
cur_name= (*an_output_file);
cur_repl= (text_pointer)cur_name->equiv;
cur_byte= cur_repl->tok_start;
cur_end= (cur_repl+1)->tok_start;
while(stack_ptr> stack)get_output();
flush_buffer();
}

/*:42*/
#line 563 "./cwebdir/ctangle.w"
;
if(show_happiness)printf("\nDone.");
}
}
Ejemplo n.º 28
0
int main(){
  // Initialize Winsock
    WSADATA wsaData;
    int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
    if (iResult != NO_ERROR) {
        wprintf(L"WSAStartup function failed with error: %d\n", iResult);
        return 1;
    }
    //----------------------
    // Create a SOCKET for connecting to server
    SOCKET ConnectSocket;
    ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (ConnectSocket == INVALID_SOCKET) {
        wprintf(L"socket function failed with error: %ld\n", WSAGetLastError());
        WSACleanup();
        return 1;
    }
    //----------------------
    // The sockaddr_in structure specifies the address family,
    // IP address, and port of the server to be connected to.
    sockaddr_in clientService;
    clientService.sin_family = AF_INET;
    printf("Enter the IP address to connect to: ");
    string ipAddr;
    getline(cin, ipAddr);
    clientService.sin_addr.s_addr = inet_addr(ipAddr.c_str());
    clientService.sin_port = htons(31000);

    //----------------------
    // Connect to server.
    iResult = connect(ConnectSocket, (SOCKADDR *) & clientService, sizeof (clientService));
    if (iResult == SOCKET_ERROR) {
        wprintf(L"connect function failed with error: %ld\n", WSAGetLastError());
        iResult = closesocket(ConnectSocket);
        if (iResult == SOCKET_ERROR)
            wprintf(L"closesocket function failed with error: %ld\n", WSAGetLastError());
        WSACleanup();
        return 1;
    }

    // Begin talking with Server here.
    char recvBuffer[BUF_SIZE];
    char sendBuffer[BUF_SIZE];
    string userInput;
    string userOpt;

    wprintf(L"Connected to server.\n");
    printf("Accepting data from server\n");

    do {
        print_options();

        printf("\nEnter a command to execute: ");
        memset(&sendBuffer, 0, sizeof(sendBuffer));
        memset(&recvBuffer, 0, sizeof(recvBuffer));
        getline(cin, userOpt);
        strcat(sendBuffer, userOpt.c_str());
        send_data(ConnectSocket, sendBuffer);

        switch(atoi(userOpt.c_str())){
            case 1:{
                get_output(ConnectSocket, recvBuffer).c_str();
                break;
            }
            case 2:{
                printf("Enter the filename: ");
                getline(cin,userInput);
                memset(&sendBuffer, 0, sizeof(sendBuffer));
                strcat(sendBuffer, userInput.c_str());
                //send filename
                send_data(ConnectSocket, sendBuffer);
                //recv file data
                memset(&recvBuffer, 0, sizeof(recvBuffer));
                string data = get_output(ConnectSocket,recvBuffer);

                ofstream myfile;
                myfile.open(userInput.c_str());
                myfile << data;
                break;
            }
            case 3:{
                printf("Enter the filename: ");
                getline(cin,userInput);
                memset(&sendBuffer, 0, sizeof(sendBuffer));
                strcat(sendBuffer, userInput.c_str());
                //send filename
                send_data(ConnectSocket, sendBuffer);
                //Get file data
                dl_file(ConnectSocket, userInput);

                send_data(ConnectSocket, "<END>");

                break;
            }
            case 4:{
                printf("Enter command: ");
                getline(cin,userInput);
                memset(&sendBuffer, 0, sizeof(sendBuffer));
                strcat(sendBuffer, userInput.c_str());
                send_data(ConnectSocket, sendBuffer);
                get_output(ConnectSocket, recvBuffer).c_str();
                break;
            }
            case 5:{
                get_output(ConnectSocket, recvBuffer).c_str();
                break;
            }
            case 6:{
                get_output(ConnectSocket, recvBuffer).c_str();
                break;
            }
            case 7:{
                get_output(ConnectSocket, recvBuffer).c_str();
                break;
            }
        }

    }while (atoi(userOpt.c_str()) != 0);

    // End connection with Server
    wprintf(L"Closing socket connection.\n");
    iResult = closesocket(ConnectSocket);
    if (iResult == SOCKET_ERROR) {
        wprintf(L"closesocket function failed with error: %ld\n", WSAGetLastError());
        WSACleanup();
        return 1;
    }

    WSACleanup();
    return 0;
}
Ejemplo n.º 29
0
            /**
             *  Pushes a new transaction into matched that pairs all bids/asks for a single quote/base pair
             */
            void match_orders( std::vector<signed_transaction>& matched,  asset::type quote, asset::type base )
            { try {
               ilog( "match orders.." );
               auto asks = _market_db.get_asks( quote, base );
               auto bids = _market_db.get_bids( quote, base );
               wlog( "asks: ${asks}", ("asks",asks) );
               wlog( "bids: ${bids}", ("bids",bids) );

               fc::optional<trx_output>             ask_change;    // stores a claim_by_bid or claim_by_long
               fc::optional<trx_output>             bid_change;    // stores a claim_by_bid

               address                              bid_payout_address; // current bid owner
               address                              ask_payout_address;

               signed_transaction market_trx;
               market_trx.timestamp = fc::time_point::now();

               const uint64_t zero = 0ull;
               asset pay_asker( zero, quote );
               asset pay_bidder( zero, base );
               asset loan_amount( zero, quote );
               asset collateral_amount(zero,base);
               asset bidder_change(zero,quote); // except for longs?
               asset asker_change(zero,base);


               /** asks are sorted from low to high, so we start
                * with the lowest ask, and check to see if there are
                * any bids that are greaterthan or equal to the ask, if
                * there are then either the full bid or full ask will be
                * filled.  If the full bid is filled, then move on to the
                * next bid, and save the leftover ask.  If the left over
                * ask is filled, then move to the next ask.
                *
                * When there are no more pairs that can be matched, exit
                * the loop and any partial payouts are made.  
                */
               auto ask_itr = asks.begin();
               auto bid_itr = bids.rbegin();
               trx_output working_ask;
               trx_output working_bid;

               if( ask_itr != asks.end() ) working_ask = get_output( ask_itr->location );
               if( bid_itr != bids.rend() ) working_bid = get_output( bid_itr->location );

               bool has_change = false;

               while( ask_itr != asks.end() && 
                      bid_itr != bids.rend()    )
               { 
                 // asset      working_ask_tmp_amount; // store fractional working ask amounts here..
                  
                  /*
                  if( ask_change ) {  working_ask = *ask_change;                         }
                  else             {  working_ask = get_output( ask_itr->location );  
                                      working_ask_tmp_amount = working_ask.get_amount();  }

                  if( bid_change ) {  working_bid = *bid_change;                      }
                  else             {  working_bid = get_output( bid_itr->location );  }
                  */

                  claim_by_bid_output ask_claim = working_ask.as<claim_by_bid_output>();

                  wlog( "working bid: ${b}", ("b", working_bid ) );
                  wlog( "working ask: ${a}", ("a", working_ask ) );

                  ask_payout_address = ask_claim.pay_address;

                  if( working_bid.claim_func == claim_by_long )
                  {
                     auto long_claim = working_bid.as<claim_by_long_output>();
                     if( long_claim.ask_price < ask_claim.ask_price )
                     {
                        ilog( "\n\n                                  BID ${BID}  >>>>   ASK ${ASK}\n\n", ("BID",long_claim.ask_price)("ASK",ask_claim.ask_price) );
                        break; // exit the while loop, no more trades can occur
                     }
                     has_change = true;
                     bid_payout_address = long_claim.pay_address;

                     // for the purposes of shorts and longs, one asset type is BTS and the other
                     // is one of the BitAssets which I will just call 'usd' for clairty.
                     // The bids are an offer to take a short position which means they have an input
                     // of BTS but are really offering USD to buy BTS... they BTS purchased with this
                     // "new" USD is then placed into the collateral.

                     asset bid_amount_bts = working_bid.get_amount(); // * long_claim.ask_price;
                     asset bid_amount_usd = bid_amount_bts * long_claim.ask_price;

                     asset ask_amount_bts = working_ask.get_amount(); // * long_claim.ask_price;
                     asset ask_amount_usd = ask_amount_bts * ask_claim.ask_price;

                     ilog( "ask_usd ${ask_usd}   bid_usd ${bid_usd}", ("ask_usd",ask_amount_usd)("bid_usd",bid_amount_usd) );
                     ilog( "ask_bts ${ask_bts}   bid_bts ${bid_bts}", ("ask_bts",ask_amount_bts)("bid_bts",bid_amount_bts) );


                     if( ask_amount_usd < bid_amount_usd )
                     { // then we have filled the ask
                         pay_asker         += ask_amount_usd;
                         loan_amount       += ask_amount_usd;
                         collateral_amount += ask_amount_bts +  ask_amount_usd * long_claim.ask_price;
                         ilog( "bid amount bts ${bid_bts}  - ${pay_asker} * ${price} = ${result}",
                               ("bid_bts",bid_amount_bts)("pay_asker",pay_asker)("price",long_claim.ask_price)("result",pay_asker*long_claim.ask_price) );
                         bidder_change     = bid_amount_bts - (ask_amount_usd * long_claim.ask_price);

                        // ask_change.reset();
                         working_ask.amount = 0;
                         // TODO: trunctate here??? 
                         working_bid.amount = bidder_change.get_rounded_amount();
                        // bid_change       = working_bid;

                         market_trx.inputs.push_back( ask_itr->location );
                         if( pay_asker.amount > static_cast<uint64_t>(0ull) )
                            market_trx.outputs.push_back( trx_output( claim_by_signature_output( ask_claim.pay_address ), pay_asker) );
                         pay_asker = asset(static_cast<uint64_t>(0ull),pay_asker.unit);
                         ++ask_itr;
                         if( ask_itr != asks.end() )  working_ask = get_output( ask_itr->location );
                     }
                     else // we have filled the bid (short sell) 
                     {
                         pay_asker         += bid_amount_usd;
                         loan_amount       += bid_amount_usd;
                         collateral_amount += bid_amount_bts + (bid_amount_usd * ask_claim.ask_price);
                         ilog( "ask_amount_bts ${bid_bts}  - ${loan_amount} * ${price} = ${result}",
                               ("bid_bts",ask_amount_bts)("loan_amount",loan_amount)("price",ask_claim.ask_price)("result",loan_amount*ask_claim.ask_price) );
                         asker_change       = ask_amount_bts - (bid_amount_usd* ask_claim.ask_price);

                         working_bid.amount = 0;
                         working_ask.amount     = asker_change.get_rounded_amount();
                        // working_ask_tmp_amount = asker_change;
                         ask_change             = working_ask;

                         market_trx.inputs.push_back( bid_itr->location );
                         market_trx.outputs.push_back( 
                                 trx_output( claim_by_cover_output( loan_amount, long_claim.pay_address ), collateral_amount) );

                         loan_amount       = asset(static_cast<uint64_t>(0ull),loan_amount.unit);
                         collateral_amount = asset();
                         ++bid_itr;
                         if( bid_itr != bids.rend() ) working_bid = get_output( bid_itr->location );

                         if( working_ask.amount < 10 )
                         {
                            market_trx.inputs.push_back( ask_itr->location );
                            ilog( "ASK CLAIM ADDR ${A} amnt ${a}", ("A",ask_claim.pay_address)("a",pay_asker) );
                            if( pay_asker != asset(static_cast<uint64_t>(0ull),pay_asker.unit) )
                            {
                                market_trx.outputs.push_back( trx_output( claim_by_signature_output( ask_claim.pay_address ), pay_asker) );
                            }
                            pay_asker = asset(pay_asker.unit);
                            ++ask_itr;
                            if( ask_itr != asks.end() )  working_ask = get_output( ask_itr->location );
                         }
                     }
                  }
                  else if( working_bid.claim_func == claim_by_bid )
                  {
                     claim_by_bid_output bid_claim = working_bid.as<claim_by_bid_output>();
                     if( bid_claim.ask_price  < ask_claim.ask_price )
                     {
                        break; // exit the while loop, no more trades can occur
                     }
                     has_change = true;
                     bid_payout_address = bid_claim.pay_address;
                     // fort he purposese of long/long trades assets may be of any type, but
                     // we will assume bids are in usd and asks are in bts for naming convention
                     // purposes.
                     
                     asset bid_amount_usd = working_bid.get_amount();
                     asset bid_amount_bts = bid_amount_usd * bid_claim.ask_price;

                     asset ask_amount_bts = working_ask.get_amount();
                     asset ask_amount_usd = ask_amount_bts * ask_claim.ask_price;
                     ilog( "bid in ${b} expected ${e}", ("b",bid_amount_usd)("e",bid_amount_bts) );
                     ilog( "ask in ${a} expected ${e}", ("a",ask_amount_bts)("e",ask_amount_usd) );

                     if( ask_amount_usd.get_rounded_amount() < bid_amount_usd.get_rounded_amount() )
                     { // then we have filled the ask
                        ilog("ilog ${x} < ${y}???", ("x",ask_amount_usd.amount)("y",bid_amount_usd.amount));
                        pay_asker          += ask_amount_usd;
                        ilog(".");
                        auto delta_bidder  = ask_amount_usd * bid_claim.ask_price;
                        pay_bidder         += delta_bidder; 
                        bidder_change      = bid_amount_usd - delta_bidder * bid_claim.ask_price;

                        ask_change.reset();
                        working_ask.amount = 0;
                        working_bid.amount = bidder_change.get_rounded_amount();
                        bid_change = working_bid;

                        market_trx.inputs.push_back( ask_itr->location );
                        ilog( "ASK CLAIM ADDR ${A} amnt ${a}", ("A",ask_claim.pay_address)("a",pay_asker) );
                        ilog( "BID CHANGE ${C}", ("C", working_bid ) );
                        if( pay_asker > asset(static_cast<uint64_t>(0ull),pay_asker.unit) )
                        {
                          market_trx.outputs.push_back( trx_output( claim_by_signature_output( ask_claim.pay_address ), pay_asker) );
                        }
                        pay_asker = asset(pay_asker.unit);
                        ++ask_itr;
                        if( ask_itr != asks.end() )  working_ask = get_output( ask_itr->location );
                     }
                     else // then we have filled the bid or we have filled BOTH
                     {
                        ilog(".");
                        pay_bidder    += bid_amount_bts;
                        ilog(".");
                        auto delta_asker =  bid_amount_bts * ask_claim.ask_price;
                        pay_asker     += delta_asker;

                        working_bid.amount = 0;

                        if( bid_amount_usd.get_rounded_amount() != ask_amount_usd.get_rounded_amount() )
                        {
                           asker_change  = ask_amount_bts -  delta_asker * ask_claim.ask_price;
                           working_ask.amount = asker_change.get_rounded_amount();
                        }
                        else
                        {
                           working_ask.amount = 0;
                        }

                        market_trx.inputs.push_back( bid_itr->location );
                        ilog( "BID CLAIM ADDR ${A} ${a}", ("A",bid_claim.pay_address)("a",pay_bidder) );
                        market_trx.outputs.push_back( trx_output( claim_by_signature_output( bid_claim.pay_address ), pay_bidder) );
                        pay_bidder = asset(static_cast<uint64_t>(0ull),pay_bidder.unit);

                        ++bid_itr;
                        if( bid_itr != bids.rend() ) working_bid = get_output( bid_itr->location );

                        if( working_ask.amount < 10 )
                        {
                           market_trx.inputs.push_back( ask_itr->location );
                           ilog( "ASK CLAIM ADDR ${A} amnt ${a}", ("A",ask_claim.pay_address)("a",pay_asker) );
                           if( pay_asker.amount > 0 )
                              market_trx.outputs.push_back( trx_output( claim_by_signature_output( ask_claim.pay_address ), pay_asker) );
                           pay_asker = asset(static_cast<uint64_t>(0ull),pay_asker.unit);
                           ++ask_itr;
                           if( ask_itr != asks.end() )  working_ask = get_output( ask_itr->location );
                        }
                     }
                  }
                  else
                  {
                     FC_ASSERT( !"Bid must either be a claim by bid or claim by long",
                                "", ("bid", working_bid) );  
                  }
               } // while( ... ) 
               if( has_change && working_ask.amount > 10  )
               {
                  FC_ASSERT( ask_itr != asks.end() );
                  if( pay_asker.amount > 0 )
                  {
                     market_trx.inputs.push_back( ask_itr->location );
                     market_trx.outputs.push_back( working_ask );
                     market_trx.outputs.push_back( trx_output( claim_by_signature_output( ask_payout_address ), pay_asker ) );
                  }
               }
               if( has_change && working_bid.amount > 10 )
               {
                  FC_ASSERT( bid_itr != bids.rend() );
                  if( collateral_amount.amount > 10 )
                  {
                     market_trx.inputs.push_back( bid_itr->location );
                     market_trx.outputs.push_back( working_bid );
                     market_trx.outputs.push_back( trx_output( claim_by_cover_output( loan_amount, bid_payout_address ), collateral_amount) );
                  }
                  else if( working_bid.claim_func == claim_by_bid )
                  {
                     if( pay_bidder.amount > 10 )
                     {
                        market_trx.inputs.push_back( bid_itr->location );
                        market_trx.outputs.push_back( working_bid );
                        market_trx.outputs.push_back( trx_output( claim_by_signature_output( bid_payout_address ), pay_bidder ) );
                     }
                  }
               }
              
               wlog( "Market Transaction: ${trx}", ("trx", market_trx) );
               if( market_trx.inputs.size() )
               {
                   FC_ASSERT( market_trx.outputs.size() );
                   FC_ASSERT( market_trx.inputs.size() );
                   matched.push_back(market_trx);
               }
               //ilog( "done match orders.." );
            } FC_RETHROW_EXCEPTIONS( warn, "", ("quote",quote)("base",base) ) }
static void ult_nn_fc_naive_fixedpoint(
    int16_t* input,
    T_output_type* output,
    int32_t* biases,
    int16_t* kernel,
    uint_least32_t num_input_neurons,
    uint_least32_t num_output_neurons,
    uint_least32_t batch_size,
    uint8_t accumulator_fraction,
    uint8_t output_fraction,
    NN_ACTIVATION_FUNCTION activation)
{
    bool BiasEn = 1;

    uint_least32_t output_size = num_output_neurons * batch_size * sizeof(int32_t);
    int32_t * output32 = (int32_t*)_mm_malloc(output_size, 64);

    const auto acc_shift = accumulator_fraction - output_fraction;

    for (int batchItr = 0; batchItr < batch_size; ++batchItr) 
    {
        for (unsigned int outputNeuronsItr = 0; outputNeuronsItr < num_output_neurons; outputNeuronsItr++)
        {
            if (BiasEn)
                get_output(output32, batch_size, batchItr, outputNeuronsItr) = biases[outputNeuronsItr];
            else
                get_output(output32, batch_size, batchItr, outputNeuronsItr) = 0;
                
            for (unsigned int inputNeuronsItr = 0; inputNeuronsItr < num_input_neurons; inputNeuronsItr++)
            {
                int16_t i = get_input(input, batch_size, batchItr, inputNeuronsItr);
                int16_t w = get_weight(kernel, num_input_neurons, inputNeuronsItr, outputNeuronsItr);
                get_output(output32, batch_size, batchItr, outputNeuronsItr) +=
                        get_input(input, batch_size, batchItr, inputNeuronsItr) * get_weight(kernel, num_input_neurons, inputNeuronsItr, outputNeuronsItr);
            }

            int32_t value = get_output(output32, batch_size, batchItr, outputNeuronsItr);
            switch (activation)
            {
                case NN_ACTIVATION_FUNCTION_RELU:
                    value = std::max(0, value);
                    break;
                case NN_ACTIVATION_FUNCTION_NONE:
                    break;
                default:
                    break;
           }

            if (acc_shift > 0)
            {
                value = value >> acc_shift;
            }
            else
            {
                value = value << -acc_shift;
            }

            //value = std::min(value, 32767);
            //value = std::max(value, -32768);
            get_output(output, batch_size, batchItr, outputNeuronsItr) = (T_output_type)(value);

        }