示例#1
0
文件: mu-config.c 项目: antono/mu
static void
set_group_find_defaults (MuConfig *opts)
{
	/* note, when no fields are specified, we use
	 * date-from-subject, and sort descending by date. If fields
	 * *are* specified, we sort in ascending order. */
	if (!opts->fields) {
		opts->fields = "d f s";
		if (!opts->sortfield)
			opts->sortfield = "d";
	}

	if (!opts->formatstr) /* by default, use plain output */
		opts->format = MU_CONFIG_FORMAT_PLAIN;
	else
		opts->format =
			get_output_format (opts->formatstr);

	if (opts->linksdir) {
		gchar *old = opts->linksdir;
		opts->linksdir = mu_util_dir_expand(opts->linksdir);
		if (!opts->linksdir)	/* we'll check the dir later */
			opts->linksdir = old;
		else
			g_free(old);
	}
}
示例#2
0
static void
set_group_view_defaults (void)
{
	if (!MU_CONFIG.formatstr) /* by default, use plain output */
		MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
	else
		MU_CONFIG.format  = get_output_format (MU_CONFIG.formatstr);
}
示例#3
0
void as3_get_output_format()
{
    char *o_format = (char*) get_output_format();

    AS3_DeclareVar(outputFormat, String);
    AS3_CopyCStringToVar(outputFormat, o_format, strlen(o_format));
    AS3_ReturnAS3Var(outputFormat);
}
示例#4
0
文件: mu-config.c 项目: antono/mu
static void
set_group_view_defaults (MuConfig *opts)
{
	if (!opts->formatstr) /* by default, use plain output */
		opts->format = MU_CONFIG_FORMAT_PLAIN;
	else
		opts->format  = get_output_format (opts->formatstr);
}
示例#5
0
static void
set_group_find_defaults (void)
{
	/* note, when no fields are specified, we use
	 * date-from-subject, and sort descending by date. If fields
	 * *are* specified, we sort in ascending order. */
	if (!MU_CONFIG.fields) {
		MU_CONFIG.fields = "d f s";
		if (!MU_CONFIG.sortfield)
			MU_CONFIG.sortfield = "d";
	}

	if (!MU_CONFIG.formatstr) /* by default, use plain output */
		MU_CONFIG.format = MU_CONFIG_FORMAT_PLAIN;
	else
		MU_CONFIG.format =
			get_output_format (MU_CONFIG.formatstr);
}
示例#6
0
bool udpipe_service::handle_rest_process(microrestd::rest_request& req) {
  string error;
  auto rest_id = get_rest_model_id(req);
  auto model = load_rest_model(rest_id, error);
  if (!model) return req.respond_error(error);

  auto& data = get_data(req, error); if (!error.empty()) return req.respond_error(error);
  bool tokenizer = false;
  unique_ptr<input_format> input(get_input_format(req, model, tokenizer, error)); if (!input) return req.respond_error(error);
  auto& tagger = get_tagger(req, model, error); if (!error.empty()) return req.respond_error(error);
  auto& parser = get_parser(req, model, error); if (!error.empty()) return req.respond_error(error);
  unique_ptr<output_format> output(get_output_format(req, error)); if (!output) return req.respond_error(error);

  // Try loading the input if tokenizer is not used
  if (!tokenizer) {
    input->set_text(data);
    sentence s;
    while (input->next_sentence(s, error)) {}
    if (!error.empty())
      return req.respond_error(error.insert(0, "Cannot read input data: ").append("\n"));
  }

  input->set_text(data);
  class generator : public rest_response_generator {
   public:
    generator(const model_info* model, input_format* input, const string& tagger, const string& parser, output_format* output)
        : rest_response_generator(model), input(input), tagger(tagger), parser(parser), output(output) {}

    bool generate() {
      if (!input->next_sentence(s, error)) {
        output->finish_document(os);
        json.value(os.str(), true);
        os.str(string());

        json.finish(true);

        return false;
      }

      if (tagger != "none")
        model->model->tag(s, tagger, error);
      if (parser != "none")
        model->model->parse(s, parser, error);

      output->write_sentence(s, os);
      json.value(os.str(), true);
      os.str(string());

      return true;
    }

   private:
    sentence s;
    string error;
    ostringstream os;
    unique_ptr<input_format> input;
    const string& tagger;
    const string& parser;
    unique_ptr<output_format> output;
  };
  return req.respond(generator::mime, new generator(model, input.release(), tagger, parser, output.release()));
}
示例#7
0
/*for decoder input processing
    1. output window should 1:1 as source frame size
    2. keep the frame ratio
    3. input format should be YUV420 , output format should be YUV444
*/
int vm_ge2d_pre_process(vframe_t* vf, ge2d_context_t *context,config_para_ex_t* ge2d_config)
{
	int ret;
	int src_top ,src_left ,src_width, src_height;
    canvas_t cs0,cs1,cs2,cd;
    int current_mirror = camera_mirror_flag;
    display_frame_t input_frame={0};
    ret = get_input_frame(&input_frame , vf);
	src_top =     input_frame.content_top   ;
	src_left =    input_frame.content_left  ;
	src_width =   input_frame.content_width ;
	src_height =  input_frame.content_height;
	if(test_zoom){
		test_zoom = 0;
		printk("top is %d , left is %d , width is %d , height is %d\n",input_frame.content_top ,input_frame.content_left,input_frame.content_width,input_frame.content_height);
	}
    /* data operating. */ 
    ge2d_config->alu_const_color= 0;//0x000000ff;
    ge2d_config->bitmask_en  = 0;
    ge2d_config->src1_gb_alpha = 0;//0xff;
    ge2d_config->dst_xy_swap = 0;

    canvas_read(vf->canvas0Addr&0xff,&cs0);
    canvas_read((vf->canvas0Addr>>8)&0xff,&cs1);
    canvas_read((vf->canvas0Addr>>16)&0xff,&cs2);
    ge2d_config->src_planes[0].addr = cs0.addr;
    ge2d_config->src_planes[0].w = cs0.width;
    ge2d_config->src_planes[0].h = cs0.height;
    ge2d_config->src_planes[1].addr = cs1.addr;
    ge2d_config->src_planes[1].w = cs1.width;
    ge2d_config->src_planes[1].h = cs1.height;
    ge2d_config->src_planes[2].addr = cs2.addr;
    ge2d_config->src_planes[2].w = cs2.width;
    ge2d_config->src_planes[2].h = cs2.height;
    canvas_read(output_para.index&0xff,&cd);
    ge2d_config->dst_planes[0].addr = cd.addr;
    ge2d_config->dst_planes[0].w = cd.width;
    ge2d_config->dst_planes[0].h = cd.height;
    ge2d_config->src_key.key_enable = 0;
    ge2d_config->src_key.key_mask = 0;
    ge2d_config->src_key.key_mode = 0;
    ge2d_config->src_para.canvas_index=vf->canvas0Addr;
    ge2d_config->src_para.mem_type = CANVAS_TYPE_INVALID;
    ge2d_config->src_para.format = get_input_format(vf);
    ge2d_config->src_para.fill_color_en = 0;
    ge2d_config->src_para.fill_mode = 0;
    ge2d_config->src_para.x_rev = 0;
    ge2d_config->src_para.y_rev = 0;
    ge2d_config->src_para.color = 0xffffffff;
    ge2d_config->src_para.top = 0;
    ge2d_config->src_para.left = 0;
    ge2d_config->src_para.width = vf->width;
    ge2d_config->src_para.height = vf->height;
//    printk("vf_width is %d , vf_height is %d \n",vf->width ,vf->height);
    ge2d_config->src2_para.mem_type = CANVAS_TYPE_INVALID;
    ge2d_config->dst_para.canvas_index=output_para.index&0xff;
    ge2d_config->dst_para.mem_type = CANVAS_TYPE_INVALID;
    ge2d_config->dst_para.format = get_output_format(output_para.v4l2_format)|GE2D_LITTLE_ENDIAN;     
    
  
    ge2d_config->dst_para.fill_color_en = 0;
    ge2d_config->dst_para.fill_mode = 0;
    ge2d_config->dst_para.x_rev = 0;
    ge2d_config->dst_para.y_rev = 0;
    ge2d_config->dst_para.color = 0;
    ge2d_config->dst_para.top = 0;
    ge2d_config->dst_para.left = 0;
    ge2d_config->dst_para.width = output_para.width;
    ge2d_config->dst_para.height = output_para.height;

    if(current_mirror==1){
        ge2d_config->dst_para.x_rev = 1;
        ge2d_config->dst_para.y_rev = 0;
    }else if(current_mirror==2){
        ge2d_config->dst_para.x_rev = 0;
        ge2d_config->dst_para.y_rev = 1;
    }else{
        ge2d_config->dst_para.x_rev = 0;
        ge2d_config->dst_para.y_rev = 0;
    }

//    printk("output_width is %d , output_height is %d \n",output_para.width ,output_para.height);
    if(ge2d_context_config_ex(context,ge2d_config)<0) {
        printk("++ge2d configing error.\n");
        return -1;
    }              
    stretchblt_noalpha(context,src_left ,src_top ,src_width, src_height,0,0,output_para.width,output_para.height);
    
    /* for cr of  yuv420p or yuv420sp. */
    if(output_para.v4l2_format==V4L2_PIX_FMT_YUV420) {
		/* for cb. */
		canvas_read((output_para.index>>8)&0xff,&cd);
		ge2d_config->dst_planes[0].addr = cd.addr;
		ge2d_config->dst_planes[0].w = cd.width;
		ge2d_config->dst_planes[0].h = cd.height;
		ge2d_config->dst_para.canvas_index=(output_para.index>>8)&0xff;
		ge2d_config->dst_para.format=GE2D_FORMAT_S8_CB|GE2D_LITTLE_ENDIAN;
		ge2d_config->dst_para.width = output_para.width/2;
		ge2d_config->dst_para.height = output_para.height/2;

                if(current_mirror==1){
                    ge2d_config->dst_para.x_rev = 1;
                    ge2d_config->dst_para.y_rev = 0;
                }else if(current_mirror==2){
                    ge2d_config->dst_para.x_rev = 0;
                    ge2d_config->dst_para.y_rev = 1;
                }else{
                    ge2d_config->dst_para.x_rev = 0;
                    ge2d_config->dst_para.y_rev = 0;
                }

		if(ge2d_context_config_ex(context,ge2d_config)<0) {
			printk("++ge2d configing error.\n");
			return -1;
		}
		stretchblt_noalpha(context,src_left ,src_top ,src_width, src_height,0,0,ge2d_config->dst_para.width,ge2d_config->dst_para.height);
	} else if (output_para.v4l2_format==V4L2_PIX_FMT_NV12||
示例#8
0
int generate_map(const Bitmap *in, FILE *outgfx, FILE *outmap,
int x, int y, int width, int height, int order) {
   // ...
   if (width <= 0 || height <= 0)
      return ERR_PARSE;

   // To store the mappings
   uint16_t *mappings = (uint16_t *) malloc(sizeof(uint16_t) *
      width * height);
   if (mappings == NULL)
      return ERR_NOMEMORY;

   // To store each tile
   Tile *tiles = NULL;
   uint16_t num_tiles = 0;

   // To store the tile we're just checking
   Tile curr_tile;

   // Use a mask to filter out bits we don't care about depending on the
   // format (this is used to ensure palette indices in 1bpp are treated
   // as normally expected)
   uint32_t mask = (get_output_format() == FORMAT_1BPP) ?
      0x11111111 : 0xFFFFFFFF;

   // Scan all tiles in the tilemap
   int limit1 = order ? height : width;
   int limit2 = order ? width : height;

   for (int pos2 = 0; pos2 < limit2; pos2++)
   for (int pos1 = 0; pos1 < limit1; pos1++) {
      // Retrieve tile
      if (order)
         get_tile(in, &curr_tile, x + (pos2 << 3), y + (pos1 << 3));
      else
         get_tile(in, &curr_tile, x + (pos1 << 3), y + (pos2 << 3));

      for (unsigned i = 0; i < 8; i++) {
         curr_tile.normal[i] &= mask;
         curr_tile.flipped[i] &= mask;
      }

      // Where we store the ID of this tile
      uint16_t this_id = num_tiles;

      // Compare against all other tiles
      uint16_t match = 0;
      for (; match < num_tiles; match++) {
         // To make code more readable
         Tile *other = &tiles[match];

         // Is it this tile, non flipped?
         if (curr_tile.normal[0] == other->normal[0] &&
             curr_tile.normal[1] == other->normal[1] &&
             curr_tile.normal[2] == other->normal[2] &&
             curr_tile.normal[3] == other->normal[3] &&
             curr_tile.normal[4] == other->normal[4] &&
             curr_tile.normal[5] == other->normal[5] &&
             curr_tile.normal[6] == other->normal[6] &&
             curr_tile.normal[7] == other->normal[7])
         {
            this_id = match;
            break;
         }

         // Is it this tile, flipped horizontally?
         if (curr_tile.normal[0] == other->flipped[0] &&
             curr_tile.normal[1] == other->flipped[1] &&
             curr_tile.normal[2] == other->flipped[2] &&
             curr_tile.normal[3] == other->flipped[3] &&
             curr_tile.normal[4] == other->flipped[4] &&
             curr_tile.normal[5] == other->flipped[5] &&
             curr_tile.normal[6] == other->flipped[6] &&
             curr_tile.normal[7] == other->flipped[7])
         {
            this_id = match | 0x0800;
            break;
         }

         // Is it this tile, flipped vertically?
         if (curr_tile.normal[0] == other->normal[7] &&
             curr_tile.normal[1] == other->normal[6] &&
             curr_tile.normal[2] == other->normal[5] &&
             curr_tile.normal[3] == other->normal[4] &&
             curr_tile.normal[4] == other->normal[3] &&
             curr_tile.normal[5] == other->normal[2] &&
             curr_tile.normal[6] == other->normal[1] &&
             curr_tile.normal[7] == other->normal[0])
         {
            this_id = match | 0x1000;
            break;
         }

         // Is it this tile, flipped both ways?
         if (curr_tile.normal[0] == other->flipped[7] &&
             curr_tile.normal[1] == other->flipped[6] &&
             curr_tile.normal[2] == other->flipped[5] &&
             curr_tile.normal[3] == other->flipped[4] &&
             curr_tile.normal[4] == other->flipped[3] &&
             curr_tile.normal[5] == other->flipped[2] &&
             curr_tile.normal[6] == other->flipped[1] &&
             curr_tile.normal[7] == other->flipped[0])
         {
            this_id = match | 0x1800;
            break;
         }
      }

      // Unique tile?
      if (match == num_tiles) {
         // Increment tile count
         num_tiles++;
         if (num_tiles > 0x0800) {
            free(tiles);
            free(mappings);
            return ERR_MANYTILES;
         }

         // Allocate memory for new tile
         tiles = (Tile *) realloc(tiles, sizeof(Tile) * num_tiles);
         if (tiles == NULL) {
            free(tiles);
            free(mappings);
            return ERR_NOMEMORY;
         }

         // Store tile in the list
         memcpy(&tiles[num_tiles - 1], &curr_tile, sizeof(Tile));
      }

      // Add palette and priority
      this_id |= curr_tile.flags << 13;

      // Write tile in the mappings
      mappings[pos2 * limit1 + pos1] = this_id;
   }

   // Write all the tiles
   for (size_t i = 0; i < num_tiles; i++) {
      for (unsigned row = 0; row < 8; row++) {
         // 4bpp format?
         if (get_output_format() == FORMAT_4BPP) {
            // Split each row into bytes
            // We need to do this due to endianess shenanigans :P
            uint8_t buffer[4];
            buffer[0] = tiles[i].normal[row] >> 24;
            buffer[1] = tiles[i].normal[row] >> 16;
            buffer[2] = tiles[i].normal[row] >> 8;
            buffer[3] = tiles[i].normal[row];

            // Write row into file
            if (fwrite(buffer, 1, 4, outgfx) < 4) {
               free(tiles);
               free(mappings);
               return ERR_CANTWRITEGFX;
            }
         }

         // 1bpp format?
         else {
            // Each row is just one byte, but so far we've been storing the
            // tiles as 4bpp to make our life easier, so we need to convert
            // it to 1bpp first
            uint8_t buffer =
               (tiles[i].normal[row] & 0x10000000 ? 0x80 : 0x00) |
               (tiles[i].normal[row] & 0x01000000 ? 0x40 : 0x00) |
               (tiles[i].normal[row] & 0x00100000 ? 0x20 : 0x00) |
               (tiles[i].normal[row] & 0x00010000 ? 0x10 : 0x00) |
               (tiles[i].normal[row] & 0x00001000 ? 0x08 : 0x00) |
               (tiles[i].normal[row] & 0x00000100 ? 0x04 : 0x00) |
               (tiles[i].normal[row] & 0x00000010 ? 0x02 : 0x00) |
               (tiles[i].normal[row] & 0x00000001 ? 0x01 : 0x00);

            // Write row into file
            if (fwrite(&buffer, 1, 1, outgfx) < 1) {
               free(tiles);
               free(mappings);
               return ERR_CANTWRITEGFX;
            }
         }
      }
示例#9
0
int inject_message(lua_State* lua)
{
    static const char* default_type = "txt";
    static const char* default_name = "";
    void* luserdata = lua_touserdata(lua, lua_upvalueindex(1));
    if (NULL == luserdata) {
        luaL_error(lua, "inject_message() invalid lightuserdata");
    }
    lua_sandbox* lsb = (lua_sandbox*)luserdata;

    void* ud = NULL;
    const char* type = default_type;
    const char* name = default_name;
    switch (lua_gettop(lua)) {
    case 0:
        break;
    case 2:
        name = luaL_checkstring(lua, 2);
        // fallthru
    case 1:
        switch (lua_type(lua, 1)) {
        case LUA_TSTRING:
            type = lua_tostring(lua, 1);
            if (strlen(type) == 0) type = default_type;
            break;
        case LUA_TTABLE:
            type = "";
            if (serialize_table_as_pb(lsb) != 0) {
                luaL_error(lua, "inject_message() cound not encode protobuf - %s",
                           lsb->m_error_message);
            }
            break;
        case LUA_TUSERDATA:
            ud = lua_touserdata(lua, 1);
            if (heka_circular_buffer == userdata_type(lua, ud, 1)) {
                circular_buffer* cb = (circular_buffer*)ud;
                type = get_output_format(cb);
                lsb->m_output.m_pos = 0;
                if (output_circular_buffer(lua, cb, &lsb->m_output)) {
                    luaL_error(lua, lsb->m_error_message);
                }
            } else {
                luaL_typerror(lua, 1, "circular_buffer");
            }
            break;
        default:
            luaL_typerror(lua, 1, "string, table, or circular_buffer");
            break;
        }
        break;
    default:
        luaL_error(lua, "inject_message() takes a maximum of 2 arguments");
        break;
    }

    if (lsb->m_output.m_pos != 0) {
        update_output_stats(lsb);
        if (lsb->m_usage[USAGE_TYPE_OUTPUT][USAGE_STAT_CURRENT]
            > lsb->m_usage[USAGE_TYPE_OUTPUT][USAGE_STAT_LIMIT]) {
            if (lsb->m_error_message[0] == 0) {
                luaL_error(lua, "output_limit exceeded");
            }
            luaL_error(lua, lsb->m_error_message);
        }
        int result = go_lua_inject_message(lsb->m_go,
                                           lsb->m_output.m_data,
                                           (int)(lsb->m_output.m_pos),
                                           (char*)type,
                                           (char*)name);
        lsb->m_output.m_pos = 0;
        if (result != 0) {
            luaL_error(lua, "inject_message() exceeded MaxMsgLoops");
        }
    }
    return 0;
}
示例#10
0
int main(int argc, const char* argv[])
{
    poptContext opt_con;       /* context for parsing command-line options */
    int rc;

    /* Command line arguments. */
    static struct poptOption cli_options[] = {
        { "gradation", 'G',
          POPT_ARG_DOUBLE | POPT_ARGFLAG_SHOW_DEFAULT,
          &ls2_backend_steps, 0,
          "number of gradation steps, 0 is unlimited", "steps" },
        { "output-average", 'o',
          POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT,
          &(output[AVERAGE_ERROR]), 0,
          "name of the average error output image file", "file name" },
        { "output-maximum", 'M',
          POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT,
          &(output[MAXIMUM_ERROR]), 0,
          "name of the maximum error output image file", "file name" },
        { "output-minimum", 'm',
          POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT,
          &(output[MINIMUM_ERROR]), 0,
          "name of the minimum error output image file", "file name" },
        { "output-variance", 's',
          POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT, &(output[STANDARD_DEVIATION]), 0,
          "name of the output image file of the standard deviation", "file name" },
        { "output-rmse", 'p',
          POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT,
          &(output[ROOT_MEAN_SQUARED_ERROR]), 0,
          "name of the root mean squared error output image", "file name" },
        { "output-success", 'S',
          POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT,
          &(output[FAILURES]), 0,
          "name of the failure rate output image file", "file name" },
        { "output-phase", 'z',
          POPT_ARG_STRING | POPT_ARGFLAG_SHOW_DEFAULT,
          &(output[AVERAGE_X_ERROR]), 0,
          "name of the phase portrait output image", "file name" },
        { "stride", 'S',
          POPT_ARG_INT | POPT_ARGFLAG_SHOW_DEFAULT,
          &stride, 0,
          "stride of the phase portrait", "steps" },
        { "inverted", 'i', POPT_ARG_STRING, &inverted, 0,
          "name of the inverted density file", "file name" },
        { "maximum", 0,
          POPT_ARG_LONG | POPT_ARGFLAG_SHOW_DEFAULT,
          &runs, 0,
          "maximum frequency in inverted image", "runs" },
        POPT_AUTOHELP
        POPT_TABLEEND
    };

    output_format = "png";

    opt_con = poptGetContext(NULL, argc, argv, cli_options, 0);
    poptSetOtherOptionHelp(opt_con, "[OPTIONS] file.h5");

    // Check for sufficient number of command line arguments
    if (argc < 2) {
        poptPrintUsage(opt_con, stderr, 0);
        poptFreeContext(opt_con);
        exit(EXIT_FAILURE);
    }

    // Parse the command line arguments.
    while ((rc = poptGetNextOpt(opt_con)) >= 0) {
        switch (rc) {
        default:
            break;
        }
    }

    if (rc < -1) {
        /* an error occurred during option processing */
        fprintf(stderr, "%s: %s\n",
                poptBadOption(opt_con, POPT_BADOPTION_NOALIAS),
                poptStrerror(rc));
        poptFreeContext(opt_con);
        exit(EXIT_FAILURE);
    }

    // Handle the left-over arguments.
    if (poptPeekArg(opt_con) != NULL) {
        input_hdf5 = poptGetArg(opt_con);
    }

    if (poptPeekArg(opt_con) != NULL) {
        fprintf(stderr, "warning: too many arguments, some were ignored.\n");
    }

    ls2_output_format_t format = get_output_format(output_format);

    vector2 *anchors;
    size_t no_anchors;
    uint16_t height, width;

    // calculate average
    if (inverted == NULL) {
        for (ls2_output_variant var = 0; var < NUM_VARIANTS; var++) {
            if (output[var] != NULL && *(output[var]) != '\0') {
                if (var == AVERAGE_Y_ERROR)
                    continue;
                if (var == AVERAGE_X_ERROR) {
                    float *dx, *dy;
                    ls2_hdf5_read_locbased(input_hdf5, AVERAGE_X_ERROR,
                                           &anchors, &no_anchors, &dx,
                                           &width, &height);
                    ls2_hdf5_read_locbased(input_hdf5, AVERAGE_Y_ERROR,
                                           NULL, NULL, &dy,
                                           &width, &height);
                    ls2_cairo_write_pdf_phase_portrait(output[var], anchors,
						       no_anchors, dx, dy, width,
						       height, (uint16_t) stride);
                    free(dx);
                    free(dy);
                } else {
                    float *results;

	            ls2_hdf5_read_locbased(input_hdf5, var, &anchors, &no_anchors,
				           &results, &width, &height);
	            float mu, sigma, min, max;
	            ls2_statistics(results, (size_t) width * height,
			           &mu, &sigma, &min, &max);
	            fprintf(stdout, "MAE = %f, sdev = %f, min = %f, max = %f\n",
		            mu, sigma, min, max);
		    if (var != FAILURES)
			ls2_write_locbased(format, output[var], anchors, no_anchors,
					   results, width, height);
 		    else
			ls2_write_density(format, output[var], anchors, no_anchors,
					  results, width, height);		      
                    free(results);
                }
                // clean-ups.
                free(anchors);
            }
        }
    } else if (*inverted != '\0') { //Reading an inverted image
        float tag_x, tag_y;
        double center_x, center_y;
        uint64_t *result;
        ls2_hdf5_read_inverted(input_hdf5, &tag_x, &tag_y, &anchors, &no_anchors,
			       &result, &width, &height, &center_x, &center_y);
        uint64_t maximum = 0;
        for (int i = 0; i < width * height; i++)
            maximum = MAX(result[i], maximum);
        fprintf(stdout, "Actual maximum: %" PRIu64 ", used maximum: %" PRIu64 "\n",
                maximum, ((runs == 0) ? maximum : (uint64_t) runs));
	ls2_write_inverted(format, inverted, (uint64_t) runs, tag_x, tag_y, anchors, no_anchors,
			   result, width, height, (float) center_x, (float) center_y);
        free(result);
        free(anchors);
    }
    poptFreeContext(opt_con);
    exit(EXIT_SUCCESS);
}