/* * Common interrupt handler. */ void interrupt_handler(void) { uint32_t bits; int vector, old_ipl, new_ipl; /* Get interrupt source */ bits = ICU_IRQSTS; for (vector = 0; vector < NIRQS; vector++) { if (bits & (uint32_t)(1 << vector)) break; } if (vector == NIRQS) goto out; /* Adjust interrupt level */ old_ipl = irq_level; new_ipl = ipl_table[vector]; if (new_ipl > old_ipl) /* Ignore spurious interrupt */ irq_level = new_ipl; update_mask(); /* Dispatch interrupt */ interrupt_enable(); irq_handler(vector); interrupt_disable(); /* Restore interrupt level */ irq_level = old_ipl; update_mask(); out: return; }
/* * Mask interrupt in ICU for specified irq. * Interrupt must be disabled when this routine is called. */ void interrupt_mask(int vector) { int i, level; u_int mask = (uint16_t)~(1 << vector); level = ipl_table[vector]; for (i = 0; i < level; i++) mask_table[i] &= mask; ipl_table[vector] = IPL_NONE; update_mask(); }
JNIEXPORT void JNICALL Java_com_iiordanov_aSPICE_SpiceCommunicator_SpiceButtonEvent(JNIEnv * env, jobject obj, jint x, jint y, jint metaState, jint type) { SpiceDisplay* display = global_display; SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); //char buf[60]; //snprintf (buf, 60, "Pointer event: %d at x: %d, y: %d", type, x, y); //__android_log_write(6, "android-io", buf); if (!d->inputs || (x >= 0 && x < d->width && y >= 0 && y < d->height)) { gboolean down = (type & PTRFLAGS_DOWN) != 0; int mouseButton = type &~ PTRFLAGS_DOWN; int newMask = update_mask (mouseButton, down); gint dx; gint dy; switch (d->mouse_mode) { case SPICE_MOUSE_MODE_CLIENT: //__android_log_write(6, "android-io", "spice mouse mode client"); spice_inputs_position(d->inputs, x, y, d->channel_id, newMask); break; case SPICE_MOUSE_MODE_SERVER: //__android_log_write(6, "android-io", "spice mouse mode server"); dx = d->mouse_last_x != -1 ? x - d->mouse_last_x : 0; dy = d->mouse_last_y != -1 ? y - d->mouse_last_y : 0; spice_inputs_motion(d->inputs, dx, dy, newMask); d->mouse_last_x = x; d->mouse_last_y = y; break; default: g_warn_if_reached(); break; } if (mouseButton != SPICE_MOUSE_BUTTON_INVALID) { if (down) { //__android_log_write(6, "android-io", "Button press"); spice_inputs_button_press(d->inputs, mouseButton, newMask); } else { //__android_log_write(6, "android-io", "Button release"); // This sleep is an ugly hack to prevent stuck buttons after a drag/drop gesture. usleep(50000); spice_inputs_button_release(d->inputs, mouseButton, newMask); } } } }
/* * Unmask interrupt in ICU for specified irq. * The interrupt mask table is also updated. * Assumes CPU interrupt is disabled in caller. */ void interrupt_unmask(int vector, int level) { int i; uint32_t unmask = (uint32_t)1 << vector; /* Save level mapping */ ipl_table[vector] = level; /* * Unmask the target interrupt for all * lower interrupt levels. */ for (i = 0; i < level; i++) mask_table[i] |= unmask; update_mask(); }
void dialogMaskChangedCallback(GtkWidget *widget, PlugInVals *vals) { gint value; #ifdef DEBUG g_warning("dialogMaskChangedCallback"); #endif if (GTK_WIDGET_SENSITIVE(widget)) { //if (gtk_widget_get_sensitive(widget)) { if (gimp_int_combo_box_get_active(GIMP_INT_COMBO_BOX(widget),&value)) { vals->mask_drawable_id = value; } else { vals->mask_drawable_id = -1; } } else { vals->mask_drawable_id = gimp_image_get_selection(gimp_drawable_get_image(vals->image_drawable_id)); } update_mask(vals); renderPreview(vals); }
void __startup(multiboot_info_t *multiboot, int magic) { extern char end; char * argv[1] = { 0 }; //dprintf("Welcome to Snowflake Serial Debugging!\r\n"); mem_start = (unsigned long)&end; // set up exception and irq handlers idt_init(); //paging_init(); unmask_irq(0); update_mask(); caml_startup(argv); // caml_startup has finished initialising the OS //dprintf("INFO: Startup completed. Exiting startup thread...\r\n"); }
/******************************************************************************* Implementation *******************************************************************************/ int find_sum(Matrix m, size_t msize, Matrix bmsk, int col) { int sum = 0, max = 0; for(int r=0; r<msize; r++) { if(!bmsk[r][col]) //No mask { update_mask(m, bmsk, col, r, col); int s = 0; if(col < msize-1) s = find_sum(m, msize, bmsk, col+1); if(s + m[r][col] > max) max = s + m[r][col]; remove_mask_i(bmsk, col); } } return max; }
CPLErr JPEG_Codec::CompressJPEG(buf_mgr &dst, buf_mgr &src) #endif { // The cinfo should stay open and reside in the DS, since it can be left initialized // It saves some time because it has the tables initialized struct jpeg_compress_struct cinfo; MRFJPEGStruct sJPEGStruct; struct jpeg_error_mgr sJErr; ILSize sz = img.pagesize; jpeg_destination_mgr jmgr; jmgr.next_output_byte = (JOCTET *)dst.buffer; jmgr.free_in_buffer = dst.size; jmgr.init_destination = init_or_terminate_destination; jmgr.empty_output_buffer = empty_output_buffer; jmgr.term_destination = init_or_terminate_destination; memset(&cinfo, 0, sizeof(cinfo)); // Look at the source of this, some interesting tidbits cinfo.err = jpeg_std_error(&sJErr); sJErr.error_exit = errorExit; sJErr.emit_message = emitMessage; cinfo.client_data = (void *)&(sJPEGStruct); jpeg_create_compress(&cinfo); cinfo.dest = &jmgr; // The page specific info, size and color spaces cinfo.image_width = sz.x; cinfo.image_height = sz.y; cinfo.input_components = sz.c; switch (cinfo.input_components) { case 1:cinfo.in_color_space = JCS_GRAYSCALE; break; case 3:cinfo.in_color_space = JCS_RGB; break; // Stored as YCbCr 4:2:0 by default default: cinfo.in_color_space = JCS_UNKNOWN; // 2, 4-10 bands } // Set all required fields and overwrite the ones we want to change jpeg_set_defaults(&cinfo); // Override certain settings jpeg_set_quality(&cinfo, img.quality, TRUE); cinfo.dct_method = JDCT_FLOAT; // Pretty fast and precise cinfo.optimize_coding = optimize; // Set "OPTIMIZE=TRUE" in OPTIONS, default for 12bit // Do we explicitly turn off the YCC color and downsampling? if (cinfo.in_color_space == JCS_RGB) { if (rgb) { // Stored as RGB jpeg_set_colorspace(&cinfo, JCS_RGB); // Huge files } else if (sameres) { // YCC, somewhat larger files with improved color spatial detail cinfo.comp_info[0].h_samp_factor = 1; cinfo.comp_info[0].v_samp_factor = 1; // Enabling these lines will make the color components use the same tables as Y, even larger file with slightly better color depth detail // cinfo.comp_info[1].quant_tbl_no = 0; // cinfo.comp_info[2].quant_tbl_no = 0; // cinfo.comp_info[1].dc_tbl_no = 0; // cinfo.comp_info[2].dc_tbl_no = 0; // cinfo.comp_info[1].ac_tbl_no = 0; // cinfo.comp_info[2].ac_tbl_no = 0; } } int linesize = cinfo.image_width * cinfo.input_components * ((cinfo.data_precision == 8) ? 1 : 2); JSAMPROW *rowp = (JSAMPROW *)CPLMalloc(sizeof(JSAMPROW)*sz.y); if (!rowp) { CPLError(CE_Failure, CPLE_AppDefined, "MRF: JPEG compression error"); jpeg_destroy_compress(&cinfo); return CE_Failure; } for (int i = 0; i < sz.y; i++) rowp[i] = (JSAMPROW)(src.buffer + i*linesize); if (setjmp(sJPEGStruct.setjmpBuffer)) { CPLError(CE_Failure, CPLE_AppDefined, "MRF: JPEG compression error"); jpeg_destroy_compress(&cinfo); CPLFree(rowp); return CE_Failure; } // Build a bitmaps of the black pixels // If there are any black pixels, write a compressed mask in APP3 "C3Mask" chunk // Mask is initialized to all pixels valid BitMask mask(sz.x, sz.y); storage_manager mbuffer = { CHUNK_NAME, CHUNK_NAME_SIZE }; int nzeros = (cinfo.data_precision == 8) ? update_mask(mask, reinterpret_cast<GByte *>(src.buffer), sz.c) : update_mask(mask, reinterpret_cast<GUInt16 *>(src.buffer), sz.c); // In case we need to build a Zen chunk char *buffer = nullptr; if (nzeros != 0) { // build the Zen chunk mbuffer.size = 2 * mask.size() + CHUNK_NAME_SIZE; buffer = reinterpret_cast<char *>(CPLMalloc(mbuffer.size)); if (!buffer) { jpeg_destroy_compress(&cinfo); CPLFree(rowp); CPLError(CE_Failure, CPLE_OutOfMemory, "MRF: JPEG Zen mask compression"); return CE_Failure; } memcpy(buffer, CHUNK_NAME, CHUNK_NAME_SIZE); mbuffer.buffer = buffer + CHUNK_NAME_SIZE; mbuffer.size -= CHUNK_NAME_SIZE; RLEC3Packer c3; mask.set_packer(&c3); if (!mask.store(&mbuffer)) { CPLError(CE_Failure, CPLE_AppDefined, "MRF: JPEG Zen mask compression"); CPLFree(rowp); CPLFree(buffer); return CE_Failure; } // Change the buffer pointer to include the signature, on output the size is the compressed size mbuffer.buffer = buffer; mbuffer.size += CHUNK_NAME_SIZE; // Check that the size fits in one JPEG chunk if (mbuffer.size + 2 + CHUNK_NAME_SIZE > 65535) { // Should split it in multiple chunks, for now mark this tile as all data and emit a warning CPLError(CE_Warning, CPLE_NotSupported, "MRF: JPEG Zen mask too large"); mbuffer.size = CHUNK_NAME_SIZE; // Write just the signature } } // Everything is ready jpeg_start_compress(&cinfo, TRUE); // Always write the Zen app chunk, App3 jpeg_write_marker(&cinfo, JPEG_APP0 + 3, reinterpret_cast<JOCTET *>(mbuffer.buffer), static_cast<unsigned int>(mbuffer.size)); jpeg_write_scanlines(&cinfo, rowp, sz.y); jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); CPLFree(rowp); CPLFree(buffer); // Safe to call on null // Figure out the size dst.size -= jmgr.free_in_buffer; return CE_None; }