void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row, png_const_bytep prev) { /* The Avg filter predicts each pixel as the (truncated) average of a and b. * There's no pixel to the left of the first pixel. Luckily, it's * predicted to be half of the pixel above it. So again, this works * perfectly with our loop if we make sure a starts at zero. */ png_size_t rb; const __m128i zero = _mm_setzero_si128(); __m128i b; __m128i a, d = zero; png_debug(1, "in png_read_filter_row_avg3_sse2"); rb = row_info->rowbytes; while (rb >= 4) { __m128i avg; b = load4(prev); a = d; d = load4(row ); /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */ avg = _mm_avg_epu8(a,b); /* ...but we can fix it up by subtracting off 1 if it rounded up. */ avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b), _mm_set1_epi8(1))); d = _mm_add_epi8(d, avg); store3(row, d); prev += 3; row += 3; rb -= 3; } if (rb > 0) { __m128i avg; b = load3(prev); a = d; d = load3(row ); /* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */ avg = _mm_avg_epu8(a,b); /* ...but we can fix it up by subtracting off 1 if it rounded up. */ avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b), _mm_set1_epi8(1))); d = _mm_add_epi8(d, avg); store3(row, d); prev += 3; row += 3; rb -= 3; } }
void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row, png_const_bytep prev) { /* The Sub filter predicts each pixel as the previous pixel, a. * There is no pixel to the left of the first pixel. It's encoded directly. * That works with our main loop if we just say that left pixel was zero. */ png_size_t rb; __m128i a, d = _mm_setzero_si128(); png_debug(1, "in png_read_filter_row_sub3_sse2"); rb = row_info->rowbytes; while (rb >= 4) { a = d; d = load4(row); d = _mm_add_epi8(d, a); store3(row, d); row += 3; rb -= 3; } if (rb > 0) { a = d; d = load3(row); d = _mm_add_epi8(d, a); store3(row, d); row += 3; rb -= 3; } PNG_UNUSED(prev) }
CLoadPlayersWidget::CLoadPlayersWidget( QWidget* parent) : QWidget(parent) { for(int i = 0; i < 4; i++) labels[i].setText(QString("Player %1 :").arg(i+1)); labels[Cyan].setStyleSheet("QLabel {color : darkcyan}"); labels[Magenta].setStyleSheet("QLabel {color : darkmagenta}"); labels[Yellow].setStyleSheet("QLabel {color : orange}"); labels[Red].setStyleSheet(" QLabel {color : red}"); QGridLayout *lOut = new QGridLayout(this); this->setLayout(lOut); for(int i = 0; i < 4; i++) { lOut->addWidget(&labels[i],(i+1)*2-1,1); cBoxes[i].setChecked(false); buttons[i].setDisabled(true); buttons[i].setText("Browse"); lOut->addWidget(&cBoxes[i],(i+1)*2-1,0); lOut->addWidget(&buttons[i],(i+1)*2-1,2); compileButt[i] = new QPushButton("Compile !"); compileButt[i]->setDisabled(true); lOut->addWidget(compileButt[i],(i+1)*2-1,3); activeLabels[i] = new QLabel("Disabled"); lOut->addWidget(activeLabels[i],(i+1)*2,1); } for(int i = 0; i < 4; i++) connect(&cBoxes[i],SIGNAL(clicked(bool)),&buttons[i],SLOT(setEnabled(bool))); connect(&buttons[0], SIGNAL(clicked()), this, SLOT(load1())); connect(&buttons[1], SIGNAL(clicked()), this, SLOT(load2())); connect(&buttons[2], SIGNAL(clicked()), this, SLOT(load3())); connect(&buttons[3], SIGNAL(clicked()), this, SLOT(load4())); }
int main(int argc, char * argv[]) { int a = 1, b = 2, z1 = 3, z2 = 4, z3 = 5; void *handle0, *handle1; char *error; if (argc == 3) { a = atoi(argv[1]); b = atoi(argv[2]); } DynamicLoader load0("./closure_callee0"); DynamicLoader load1("./closure_callee1"); DynamicLoader load2("./closure_callee2"); DynamicLoader load3("./closure_callee3"); std::function<int (int)> init_0 = load0.load<int (int)>("callee_init"); std::function<int (int, int&, int*)> init_1 = load1.load<int (int, int&, int*)>("callee_init"); std::function<int (int, int&, int*)> init_3 = load3.load<int (int, int&, int*)>("create_callee"); std::function<int (void)> del_3 = load3.load<int (void)>("destroy_callee"); std::function<int (int, int)> callee_0 = load0.load<int (int, int)>("callee"); std::function<int (int, int)> callee_1 = load1.load<int (int, int)>("callee"); std::function<int (int, int)> callee_3 = load3.load<int (int, int)>("lam"); typedef std::function<int (int, int)> T_lam; std::function<int (T_lam, int, int)> callee_2 = load2.load<int (T_lam, int, int)>("callee"); init_0(z1); init_1(z1, z2, &z3); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); init_3(z1, z2, &z3); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); callee_0(a, b); callee_1(a, b); // callee_3(a, b); callee_2(callee_0, a, b); callee_2(callee_1, a, b); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); callee_2(callee_3, a, b); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); del_3(); load0.close(); load1.close(); load2.close(); load3.close(); return 0; }
//THE START OF MOD 1 CODE void project3() { output = fopen("output.txt", "w"); initArray(); //printf("It initialized the arrays\n"); load3(); //testFunction(); format2(); while(1==1) { fetch(); execute(); } }
void save_and_load3( boost::shared_ptr<A>& first, boost::shared_ptr<A>& second, boost::weak_ptr<A>& third ){ const char * testfile = boost::archive::tmpnam(NULL); BOOST_REQUIRE(NULL != testfile); save3(testfile, first, second, third); // Clear the pointers, thereby destroying the objects they contain first.reset(); second.reset(); third.reset(); load3(testfile, first, second, third); BOOST_CHECK(first == second); BOOST_CHECK(first == third.lock()); std::remove(testfile); }
void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row, png_const_bytep prev) { /* Paeth tries to predict pixel d using the pixel to the left of it, a, * and two pixels from the previous row, b and c: * prev: c b * row: a d * The Paeth function predicts d to be whichever of a, b, or c is nearest to * p=a+b-c. * * The first pixel has no left context, and so uses an Up filter, p = b. * This works naturally with our main loop's p = a+b-c if we force a and c * to zero. * Here we zero b and d, which become c and a respectively at the start of * the loop. */ png_size_t rb; const __m128i zero = _mm_setzero_si128(); __m128i c, b = zero, a, d = zero; png_debug(1, "in png_read_filter_row_paeth3_sse2"); rb = row_info->rowbytes; while (rb >= 4) { /* It's easiest to do this math (particularly, deal with pc) with 16-bit * intermediates. */ __m128i pa,pb,pc,smallest,nearest; c = b; b = _mm_unpacklo_epi8(load4(prev), zero); a = d; d = _mm_unpacklo_epi8(load4(row ), zero); /* (p-a) == (a+b-c - a) == (b-c) */ pa = _mm_sub_epi16(b,c); /* (p-b) == (a+b-c - b) == (a-c) */ pb = _mm_sub_epi16(a,c); /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */ pc = _mm_add_epi16(pa,pb); pa = abs_i16(pa); /* |p-a| */ pb = abs_i16(pb); /* |p-b| */ pc = abs_i16(pc); /* |p-c| */ smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb)); /* Paeth breaks ties favoring a over b over c. */ nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a, if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c)); /* Note `_epi8`: we need addition to wrap modulo 255. */ d = _mm_add_epi8(d, nearest); store3(row, _mm_packus_epi16(d,d)); prev += 3; row += 3; rb -= 3; } if (rb > 0) { /* It's easiest to do this math (particularly, deal with pc) with 16-bit * intermediates. */ __m128i pa,pb,pc,smallest,nearest; c = b; b = _mm_unpacklo_epi8(load3(prev), zero); a = d; d = _mm_unpacklo_epi8(load3(row ), zero); /* (p-a) == (a+b-c - a) == (b-c) */ pa = _mm_sub_epi16(b,c); /* (p-b) == (a+b-c - b) == (a-c) */ pb = _mm_sub_epi16(a,c); /* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */ pc = _mm_add_epi16(pa,pb); pa = abs_i16(pa); /* |p-a| */ pb = abs_i16(pb); /* |p-b| */ pc = abs_i16(pc); /* |p-c| */ smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb)); /* Paeth breaks ties favoring a over b over c. */ nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a, if_then_else(_mm_cmpeq_epi16(smallest, pb), b, c)); /* Note `_epi8`: we need addition to wrap modulo 255. */ d = _mm_add_epi8(d, nearest); store3(row, _mm_packus_epi16(d,d)); prev += 3; row += 3; rb -= 3; } }