void bitmap_set_range(struct bitmap *bitmap, size_t start, size_t length) { assert(bitmap != NULL); assert(bitmap->entry_count < start); assert(bitmap->entry_count < start + length); bitmap->map[bitmap_index(start)] = (bitmap_bit(start) - 1) | bitmap_bit(start); bitmap->map[bitmap_index(start + length)] = ~(bitmap_bit(start + length) - 1); for (size_t i = bitmap_index(start) + 1; i < bitmap_index(start + length) - 1; ++i) { bitmap->map[i] = ~0; } }
enum status bitmap_get_index(struct bitmap *bitmap, size_t *entry) { assert(bitmap != NULL); for (size_t i = bitmap_index(bitmap->last_free); i < bitmap_index(bitmap->entry_count); ++i) { if (bitmap->map[i] != ~0ul) { size_t entry_bit = log2(bitmap->map[i]); *entry = (i << sizeof(unsigned long)) + entry_bit; bitmap->map[i] |= 1 << entry_bit; return Ok; } } for (size_t i = 0; i < bitmap_index(bitmap->last_free); ++i) { if (bitmap->map[i] != ~0ul) { size_t entry_bit = log2(bitmap->map[i]); *entry = (i << sizeof(unsigned long)) + entry_bit; bitmap->map[i] |= 1 << entry_bit; return Ok; } } return Error_Full; }
/* This is a generic rendering function. It works for all signal styles. * The input always looks like one big PCM sample; if the input is really * a spectrum, then it will have been transformed by blurk_render_pcm() * into 256 PCM samples, with 20000 meaning "no sound" and smaller/negative * values representing a lot of sound. This particular transformation was * chosen simply because the normal PCM plotter can then produce a nice-looking * spectrum graph. * * This function supports a variety of ways to plot the [pseudo-]PCM samples. * In addition to the usual line graph, it can also mirror the line graph or * produce a "bead" graph by passing the data off to render_bead(). * The decision of how to plot is based on the value of "variation". */ static void update_image(gint32 loudness, gint ndata, gint16 *data) { gint i, y, thick, quiet, center; gint beat; guchar *img; gint width, height, bpl; #if 0 /* If events are pending, then skip this frame */ if (gdk_events_pending()) return; #endif /* If we completed a resize operation a few seconds ago, then save the * new size now. */ if (savewhen != 0L && time(NULL) >= savewhen) { //config_write(FALSE, NULL, NULL); savewhen = 0L; } /* If we're supposed to be in fullscreen mode, and aren't, then * toggle fullscreen mode now. */ #if 0 if (config.fullscreen_desired && !fullscreen_method) blursk_fullscreen(FALSE); #endif /* Detect whether this is a beat, and choose a line thickness */ beat = detect_beat(loudness, &thick, &quiet); /* If quiet, then maybe choose a new preset */ //if (quiet) //preset_quiet(); /* Perform the blurring. This also affects whether the center of the * signal will be moved lower in the window. */ center = img_height/2 + blur(beat, quiet); /* Perform the fade or solid flash */ if (beat && !strcmp(config.flash_style, "Full flash")) i = 60; else { switch (config.fade_speed[0]) { case 'S': i = -1; break; /* Slow */ case 'M': i = -3; break; /* Medium */ case 'F': i = -9; break; /* Fast */ default: i = 0; /* None */ } } if (i != 0) loopfade(i); /* special processing for "Invert" & bitmap logo flashes */ if (beat) { if (!strcmp(config.flash_style, "Invert flash")) img_invert(); else if ((i = bitmap_index(config.flash_style)) >= 0) bitmap_flash(i); } /* Maybe change hue on beats */ if (beat) color_beat(); /* Add the signal data to the image */ render(thick, center, ndata, data); /* Add floaters */ drawfloaters(beat); /* shift the "ripple effect" from one frame to another */ img_rippleshift += 3; /* cyclic, since img_rippleshift is a guchar */ /* Apply the overall effect, if any */ if (!strcmp(config.overall_effect, "Bump effect")) { img = img_bump(&width, &height, &bpl); } else if (!strcmp(config.overall_effect, "Anti-fade effect")) { img = img_travel(&width, &height, &bpl); } else if (!strcmp(config.overall_effect, "Ripple effect")) { img = img_ripple(&width, &height, &bpl); } else /* "Normal effect" */ { img = img_expand(&width, &height, &bpl); } /* show info about the track */ img = show_info(img, height, bpl); /* Allow the background color to change */ color_bg(ndata, data); /* Copy the image into the window. This also converts from * 8-bits to 16/24/32 if necessary. */ #if 0 GDK_THREADS_ENTER(); #if HAVE_XV if (!xv_putimg(img, width, height, bpl)) #endif gdk_draw_indexed_image(area->window, area->style->white_gc, 0, 0, width, height, GDK_RGB_DITHER_NONE, img, bpl, color_map); GDK_THREADS_LEAVE(); #endif /* Convert colors */ uint32* pDst = (uint32*)blursk_bitmap->LockRaster(); uint8* pSrc = img; for( y = 0; y < height; y++ ) { for( i = 0; i < width; i++ ) { *pDst++ = color_map[*pSrc++]; } pSrc += bpl - width; } blursk_view->DrawBitmap( blursk_bitmap, blursk_bitmap->GetBounds(), blursk_bitmap->GetBounds() ); blursk_view->Flush(); }
void bitmap_clear(struct bitmap *bitmap, size_t entry) { assert(bitmap != NULL); assert(bitmap->entry_count < entry); bitmap->last_free = entry; bitmap->map[bitmap_index(entry)] &= ~bitmap_bit(entry); }
void bitmap_set(struct bitmap *bitmap, size_t entry) { assert(bitmap != NULL); assert(bitmap->entry_count < entry); bitmap->map[bitmap_index(entry)] |= bitmap_bit(entry); }
bool bitmap_is_set(struct bitmap *bitmap, size_t entry) { assert(bitmap != NULL); assert(bitmap->entry_count < entry); return bitmap->map[bitmap_index(entry)] & ~bitmap_bit(entry); }
/* This is a generic rendering function. It works for all signal styles. * The input always looks like one big PCM sample; if the input is really * a spectrum, then it will have been transformed by blurk_render_pcm() * into 256 PCM samples, with 20000 meaning "no sound" and smaller/negative * values representing a lot of sound. This particular transformation was * chosen simply because the normal PCM plotter can then produce a nice-looking * spectrum graph. * * This function supports a variety of ways to plot the [pseudo-]PCM samples. * In addition to the usual line graph, it can also mirror the line graph or * produce a "bead" graph by passing the data off to render_bead(). * The decision of how to plot is based on the value of "variation". */ static void update_image(BlurskPrivate *priv, int32_t loudness, int ndata, int16_t *data) { int i, thick, quiet, center; int beat; int width, height, bpl; /* Detect whether this is a beat, and choose a line thickness */ beat = detect_beat(loudness, &thick, &quiet); /* Perform the blurring. This also affects whether the center of the * signal will be moved lower in the window. */ center = img_height/2 + blur(priv, beat, quiet); /* Perform the fade or solid flash */ if (beat && !strcmp(config.flash_style, "Full flash")) i = 60; else { switch (config.fade_speed[0]) { case 'S': i = -1; break; /* Slow */ case 'M': i = -3; break; /* Medium */ case 'F': i = -9; break; /* Fast */ case 'N': default: i = 0; /* None */ } } if (i != 0) loopfade(i); /* special processing for "Invert" & bitmap logo flashes */ if (beat) { if (!strcmp(config.flash_style, "Invert flash")) img_invert(); else if ((i = bitmap_index(config.flash_style)) >= 0) bitmap_flash(i); } /* Maybe change hue on beats */ if (beat) color_beat(priv); /* Add the signal data to the image */ render(thick, center, ndata, data); /* Add floaters */ drawfloaters(beat); /* shift the "ripple effect" from one frame to another */ img_rippleshift += 3; /* cyclic, since img_rippleshift is a unsigned char */ /* Apply the overall effect, if any */ if (!strcmp(config.overall_effect, "Bump effect")) { priv->rgb_buf = img_bump(&width, &height, &bpl); } else if (!strcmp(config.overall_effect, "Anti-fade effect")) { priv->rgb_buf = img_travel(&width, &height, &bpl); } else if (!strcmp(config.overall_effect, "Ripple effect")) { priv->rgb_buf = img_ripple(&width, &height, &bpl); } else /* "Normal effect" */ { priv->rgb_buf = img_expand(&width, &height, &bpl); } priv->rgb_buf = show_info(priv->rgb_buf, height, bpl); /* Allow the background color to change */ color_bg(priv, ndata, data); }
static int writepage(struct page_data *pg) { struct page_data_kdump *pgkdump = pg->priv; struct page_desc pd; unsigned long pdidx; unsigned char *buf; size_t buflen; uint32_t flags; flags = pgkdump->flags; if (pg->len && (pgkdump->compress == compress_yes || (pgkdump->compress == compress_auto && compression != COMPRESS_NONE))) { buflen = compresspage(pg, &flags); if (!buflen) return TEST_ERR; buf = pgkdump->cbuf; if (pgkdump->compress == compress_auto) { if (buflen >= pg->len) { buflen = pg->len; buf = pg->buf; flags &= ~DUMP_DH_COMPRESSED; } } } else { buflen = pg->len; buf = pg->buf; } pd.offset = htodump64(be, dataoff); pd.size = htodump32(be, buflen + pgkdump->skip); pd.flags = htodump32(be, flags); pd.page_flags = htodump64(be, 0); pdidx = bitmap_index(bitmap2, pgkdump->addr / block_size); if (fseek(pgkdump->f, pdoff + pdidx * sizeof pd, SEEK_SET) != 0) { perror("seek page desc"); return TEST_ERR; } if (fwrite(&pd, sizeof pd, 1, pgkdump->f) != 1) { perror("write page desc"); return TEST_ERR; } if (fseek(pgkdump->f, dataoff, SEEK_SET) != 0) { perror("seek page data"); return TEST_ERR; } if (fwrite(buf, 1, buflen, pgkdump->f) != buflen) { perror("write page data"); return TEST_ERR; } dataoff += buflen; if (pgkdump->skip && fseek(pgkdump->f, pgkdump->skip, SEEK_CUR) != 0) { perror("skip page data"); return TEST_ERR; } return TEST_OK; }