gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
gl2gif.cpp File Reference
#include "MallocUtils.h"
#include "gl2gif.h"
#include <ctype.h>
Include dependency graph for gl2gif.cpp:

Go to the source code of this file.

Classes

struct  box
 

Macros

#define HASH_SIZE   20023
 
#define ppm_hashpixel(p)   (((int)(p)&0x7fffffff) % HASH_SIZE)
 
#define LARGE_LUM
 
#define REP_AVERAGE_PIXELS
 
#define BITS   12
 
#define HSIZE   5003 /* 80% occupancy */
 
#define TRUE   1
 
#define FALSE   0
 
#define ARGVAL()   (*++(*argv) || (--argc && *++argv))
 
#define MAXCODE(n_bits)   (((code_int)1 << (n_bits)) - 1)
 
#define HashTabOf(i)   htab[i]
 
#define CodeTabOf(i)   codetab[i]
 
#define tab_prefixof(i)   CodeTabOf(i)
 
#define tab_suffixof(i)   ((char_type *)(htab))[i]
 
#define de_stack   ((char_type *)&tab_suffixof((code_int)1 << BITS))
 
#define FS_SCALE   1024
 
#define MAXCOL2   32767
 

Typedefs

typedef colorhist_list * colorhash_table
 
typedef struct boxbox_vector
 
typedef unsigned char char_type
 
typedef int(* ifunptr) (int, int)
 

Functions

static colorhash_table ppm_alloccolorhash ()
 
static void ppm_freecolorhash (colorhash_table cht)
 
static colorhash_table ppm_computecolorhash (pixel **const pixels, const int cols, const int rows, const int maxcolors, int *const colorsP)
 
static int ppm_addtocolorhash (colorhash_table cht, const pixel *const colorP, const int value)
 
static colorhist_vector ppm_colorhashtocolorhist (const colorhash_table cht, const int maxcolors)
 
static colorhash_table ppm_colorhisttocolorhash (const colorhist_vector chv, const int colors)
 
static colorhist_vector ppm_computecolorhist (pixel **const pixels, const int cols, const int rows, const int maxcolors, int *const colorsP)
 
static int ppm_lookupcolor (const colorhash_table cht, const pixel *const colorP)
 
static void ppm_freecolorhist (colorhist_vector chv)
 
static int colorstobpp (int colors)
 
static int sqr (int x)
 
static int closestcolor (pixel color)
 
static int GetPixel (int x, int y)
 
static int redcompare (const void *ch1, const void *ch2)
 
static int greencompare (const void *ch1, const void *ch2)
 
static int bluecompare (const void *ch1, const void *ch2)
 
static int sumcompare (const void *b1, const void *b2)
 
static colorhist_vector mediancut (colorhist_vector chv, int colors, int sum, pixval maxval, int newcolors)
 
static void char_init ()
 
static void flush_char ()
 
static void char_out (int c)
 
static void BumpPixel ()
 
static int GIFNextPixel (ifunptr getpixel)
 
static void output (code_int code)
 
static void cl_hash (count_int hsize)
 
static void cl_block ()
 
static void compress (int init_bits, FILE *outfile, ifunptr ReadValue)
 
static void Putword (int w, FILE *fp)
 
static void GIFEncode (FILE *fp, int GWidth, int GHeight, int GInterlace, int Background, int Transparent, int BitsPerPixel, int Red[], int Green[], int Blue[], ifunptr GetPixel)
 
void create_gif (FILE *outfile, PixelBuffer *buffer, int dither, int sort, int interlace, int transparency)
 

Variables

static int static_red [MAX_GIFCOLORS]
 
static int static_green [MAX_GIFCOLORS]
 
static int static_blue [MAX_GIFCOLORS]
 
static int static_perm [MAX_GIFCOLORS]
 
static int static_permi [MAX_GIFCOLORS]
 
static int static_nbcolors
 
static pixel ** static_pixels
 
static colorhash_table static_cht
 
static int g_init_bits
 
static FILE * g_outfile
 
static int Width
 
static int Height
 
static int curx
 
static int cury
 
static long CountDown
 
static int Pass = 0
 
static int Interlace
 
static int n_bits
 
static int maxbits = BITS
 
static code_int maxcode
 
static code_int maxmaxcode = (code_int)1 << BITS
 
static count_int htab [HSIZE]
 
static unsigned short codetab [HSIZE]
 
static code_int hsize = HSIZE
 
static code_int free_ent = 0
 
static int clear_flg = 0
 
static long int in_count = 1
 
static long int out_count = 0
 
static int ClearCode
 
static int EOFCode
 
static int a_count
 
static char accum [256]
 
static unsigned long cur_accum = 0
 
static int cur_bits = 0
 
static unsigned long masks []
 

Macro Definition Documentation

◆ ARGVAL

#define ARGVAL ( )    (*++(*argv) || (--argc && *++argv))

Definition at line 571 of file gl2gif.cpp.

◆ BITS

#define BITS   12

Definition at line 553 of file gl2gif.cpp.

◆ CodeTabOf

#define CodeTabOf (   i)    codetab[i]

Definition at line 584 of file gl2gif.cpp.

◆ de_stack

#define de_stack   ((char_type *)&tab_suffixof((code_int)1 << BITS))

Definition at line 599 of file gl2gif.cpp.

◆ FALSE

#define FALSE   0

Definition at line 556 of file gl2gif.cpp.

◆ FS_SCALE

#define FS_SCALE   1024

Definition at line 1108 of file gl2gif.cpp.

◆ HASH_SIZE

#define HASH_SIZE   20023

Definition at line 54 of file gl2gif.cpp.

◆ HashTabOf

#define HashTabOf (   i)    htab[i]

Definition at line 583 of file gl2gif.cpp.

◆ HSIZE

#define HSIZE   5003 /* 80% occupancy */

Definition at line 554 of file gl2gif.cpp.

◆ LARGE_LUM

#define LARGE_LUM

Definition at line 305 of file gl2gif.cpp.

◆ MAXCODE

#define MAXCODE (   n_bits)    (((code_int)1 << (n_bits)) - 1)

Definition at line 579 of file gl2gif.cpp.

◆ MAXCOL2

#define MAXCOL2   32767

Definition at line 1109 of file gl2gif.cpp.

◆ ppm_hashpixel

#define ppm_hashpixel (   p)    (((int)(p)&0x7fffffff) % HASH_SIZE)

Definition at line 55 of file gl2gif.cpp.

◆ REP_AVERAGE_PIXELS

#define REP_AVERAGE_PIXELS

Definition at line 309 of file gl2gif.cpp.

◆ tab_prefixof

#define tab_prefixof (   i)    CodeTabOf(i)

Definition at line 597 of file gl2gif.cpp.

◆ tab_suffixof

#define tab_suffixof (   i)    ((char_type *)(htab))[i]

Definition at line 598 of file gl2gif.cpp.

◆ TRUE

#define TRUE   1

Definition at line 555 of file gl2gif.cpp.

Typedef Documentation

◆ box_vector

typedef struct box* box_vector

Definition at line 310 of file gl2gif.cpp.

◆ char_type

typedef unsigned char char_type

Definition at line 557 of file gl2gif.cpp.

◆ colorhash_table

typedef colorhist_list* colorhash_table

Definition at line 73 of file gl2gif.cpp.

◆ ifunptr

typedef int(* ifunptr) (int, int)

Definition at line 558 of file gl2gif.cpp.

Function Documentation

◆ bluecompare()

static int bluecompare ( const void *  ch1,
const void *  ch2 
)
static

Definition at line 329 of file gl2gif.cpp.

Referenced by mediancut().

Here is the caller graph for this function:

◆ BumpPixel()

static void BumpPixel ( )
static

Definition at line 654 of file gl2gif.cpp.

Referenced by GIFNextPixel().

Here is the caller graph for this function:

◆ char_init()

static void char_init ( )
static

Definition at line 621 of file gl2gif.cpp.

Referenced by compress().

Here is the caller graph for this function:

◆ char_out()

static void char_out ( int  c)
static

Definition at line 644 of file gl2gif.cpp.

Referenced by output().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cl_block()

static void cl_block ( )
static

Definition at line 846 of file gl2gif.cpp.

Referenced by compress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cl_hash()

static void cl_hash ( count_int  hsize)
static

Definition at line 812 of file gl2gif.cpp.

Referenced by cl_block(), and compress().

Here is the caller graph for this function:

◆ closestcolor()

static int closestcolor ( pixel  color)
static

Definition at line 268 of file gl2gif.cpp.

Referenced by create_gif(), and GetPixel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ colorstobpp()

static int colorstobpp ( int  colors)
static

Definition at line 238 of file gl2gif.cpp.

Referenced by create_gif().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compress()

static void compress ( int  init_bits,
FILE *  outfile,
ifunptr  ReadValue 
)
static

Definition at line 856 of file gl2gif.cpp.

Referenced by GIFEncode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_gif()

void create_gif ( FILE *  outfile,
PixelBuffer buffer,
int  dither,
int  sort,
int  interlace,
int  transparency 
)

Definition at line 1110 of file gl2gif.cpp.

Referenced by CreateOutputFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush_char()

static void flush_char ( )
static

Definition at line 631 of file gl2gif.cpp.

Referenced by char_out(), and output().

Here is the caller graph for this function:

◆ GetPixel()

static int GetPixel ( int  x,
int  y 
)
static

Definition at line 289 of file gl2gif.cpp.

Referenced by create_gif(), and GIFEncode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GIFEncode()

static void GIFEncode ( FILE *  fp,
int  GWidth,
int  GHeight,
int  GInterlace,
int  Background,
int  Transparent,
int  BitsPerPixel,
int  Red[],
int  Green[],
int  Blue[],
ifunptr  GetPixel 
)
static

Definition at line 948 of file gl2gif.cpp.

Referenced by create_gif().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GIFNextPixel()

static int GIFNextPixel ( ifunptr  getpixel)
static

Definition at line 706 of file gl2gif.cpp.

Referenced by compress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ greencompare()

static int greencompare ( const void *  ch1,
const void *  ch2 
)
static

Definition at line 323 of file gl2gif.cpp.

Referenced by mediancut().

Here is the caller graph for this function:

◆ mediancut()

static colorhist_vector mediancut ( colorhist_vector  chv,
int  colors,
int  sum,
pixval  maxval,
int  newcolors 
)
static

Definition at line 346 of file gl2gif.cpp.

Referenced by create_gif().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ output()

static void output ( code_int  code)
static

Definition at line 743 of file gl2gif.cpp.

Referenced by cl_block(), compress(), Octree_SearchAll(), and GMSH_SpanningTreePlugin::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_addtocolorhash()

static int ppm_addtocolorhash ( colorhash_table  cht,
const pixel *const  colorP,
const int  value 
)
static

Definition at line 145 of file gl2gif.cpp.

Referenced by closestcolor(), and create_gif().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_alloccolorhash()

static colorhash_table ppm_alloccolorhash ( )
static

Definition at line 83 of file gl2gif.cpp.

Referenced by create_gif(), ppm_colorhisttocolorhash(), and ppm_computecolorhash().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_colorhashtocolorhist()

static colorhist_vector ppm_colorhashtocolorhist ( const colorhash_table  cht,
const int  maxcolors 
)
static

Definition at line 160 of file gl2gif.cpp.

Referenced by ppm_computecolorhist().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_colorhisttocolorhash()

static colorhash_table ppm_colorhisttocolorhash ( const colorhist_vector  chv,
const int  colors 
)
static

Definition at line 182 of file gl2gif.cpp.

Referenced by create_gif().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_computecolorhash()

static colorhash_table ppm_computecolorhash ( pixel **const  pixels,
const int  cols,
const int  rows,
const int  maxcolors,
int *const  colorsP 
)
static

Definition at line 108 of file gl2gif.cpp.

Referenced by ppm_computecolorhist().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_computecolorhist()

static colorhist_vector ppm_computecolorhist ( pixel **const  pixels,
const int  cols,
const int  rows,
const int  maxcolors,
int *const  colorsP 
)
static

Definition at line 209 of file gl2gif.cpp.

Referenced by create_gif().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_freecolorhash()

static void ppm_freecolorhash ( colorhash_table  cht)
static

Definition at line 95 of file gl2gif.cpp.

Referenced by create_gif(), ppm_computecolorhash(), and ppm_computecolorhist().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_freecolorhist()

static void ppm_freecolorhist ( colorhist_vector  chv)
static

Definition at line 236 of file gl2gif.cpp.

Referenced by create_gif().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ppm_lookupcolor()

static int ppm_lookupcolor ( const colorhash_table  cht,
const pixel *const  colorP 
)
static

Definition at line 224 of file gl2gif.cpp.

Referenced by create_gif(), and GetPixel().

Here is the caller graph for this function:

◆ Putword()

static void Putword ( int  w,
FILE *  fp 
)
static

Definition at line 942 of file gl2gif.cpp.

Referenced by GIFEncode().

Here is the caller graph for this function:

◆ redcompare()

static int redcompare ( const void *  ch1,
const void *  ch2 
)
static

Definition at line 317 of file gl2gif.cpp.

Referenced by mediancut().

Here is the caller graph for this function:

◆ sqr()

static int sqr ( int  x)
static

Definition at line 266 of file gl2gif.cpp.

Referenced by closestcolor(), JacobianBasis::getMetricMinAndGradients(), insertVerticesInRegion(), MeshDelaunayVolume(), and STensor3::norm2().

Here is the caller graph for this function:

◆ sumcompare()

static int sumcompare ( const void *  b1,
const void *  b2 
)
static

Definition at line 335 of file gl2gif.cpp.

Referenced by mediancut().

Here is the caller graph for this function:

Variable Documentation

◆ a_count

int a_count
static

◆ accum

char accum[256]
static

Definition at line 626 of file gl2gif.cpp.

Referenced by char_out(), and flush_char().

◆ clear_flg

int clear_flg = 0
static

Definition at line 606 of file gl2gif.cpp.

Referenced by cl_block(), compress(), and output().

◆ ClearCode

int ClearCode
static

Definition at line 610 of file gl2gif.cpp.

Referenced by cl_block(), and compress().

◆ codetab

unsigned short codetab[HSIZE]
static

Definition at line 581 of file gl2gif.cpp.

◆ CountDown

long CountDown
static

Definition at line 564 of file gl2gif.cpp.

Referenced by GIFEncode(), and GIFNextPixel().

◆ cur_accum

unsigned long cur_accum = 0
static

Definition at line 736 of file gl2gif.cpp.

Referenced by GIFEncode(), and output().

◆ cur_bits

int cur_bits = 0
static

Definition at line 737 of file gl2gif.cpp.

Referenced by GIFEncode(), and output().

◆ curx

int curx
static

Definition at line 563 of file gl2gif.cpp.

Referenced by BumpPixel(), GIFEncode(), and GIFNextPixel().

◆ cury

int cury
static

Definition at line 563 of file gl2gif.cpp.

Referenced by BumpPixel(), GIFEncode(), and GIFNextPixel().

◆ EOFCode

int EOFCode
static

Definition at line 611 of file gl2gif.cpp.

Referenced by compress(), and output().

◆ free_ent

code_int free_ent = 0
static

Definition at line 600 of file gl2gif.cpp.

Referenced by cl_block(), compress(), GIFEncode(), and output().

◆ g_init_bits

int g_init_bits
static

Definition at line 560 of file gl2gif.cpp.

Referenced by compress(), and output().

◆ g_outfile

FILE* g_outfile
static

Definition at line 561 of file gl2gif.cpp.

Referenced by compress(), flush_char(), and output().

◆ Height

int Height
static

Definition at line 562 of file gl2gif.cpp.

Referenced by BumpPixel(), and GIFEncode().

◆ hsize

code_int hsize = HSIZE
static

Definition at line 585 of file gl2gif.cpp.

Referenced by cl_block(), cl_hash(), and compress().

◆ htab

count_int htab[HSIZE]
static

Definition at line 580 of file gl2gif.cpp.

Referenced by cl_hash().

◆ in_count

long int in_count = 1
static

Definition at line 608 of file gl2gif.cpp.

Referenced by compress().

◆ Interlace

int Interlace
static

Definition at line 566 of file gl2gif.cpp.

Referenced by BumpPixel(), and GIFEncode().

◆ masks

unsigned long masks[]
static
Initial value:
= {0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F,
0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF,
0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF}

Definition at line 739 of file gl2gif.cpp.

Referenced by output().

◆ maxbits

int maxbits = BITS
static

Definition at line 573 of file gl2gif.cpp.

Referenced by compress(), and output().

◆ maxcode

code_int maxcode
static

Definition at line 574 of file gl2gif.cpp.

Referenced by compress(), and output().

◆ maxmaxcode

code_int maxmaxcode = (code_int)1 << BITS
static

Definition at line 575 of file gl2gif.cpp.

Referenced by compress(), and output().

◆ n_bits

int n_bits
static

Definition at line 572 of file gl2gif.cpp.

Referenced by compress(), and output().

◆ out_count

long int out_count = 0
static

Definition at line 609 of file gl2gif.cpp.

Referenced by compress().

◆ Pass

int Pass = 0
static

Definition at line 565 of file gl2gif.cpp.

Referenced by BumpPixel(), and GIFEncode().

◆ static_blue

int static_blue[MAX_GIFCOLORS]
static

Definition at line 77 of file gl2gif.cpp.

Referenced by closestcolor(), and create_gif().

◆ static_cht

colorhash_table static_cht
static

Definition at line 81 of file gl2gif.cpp.

Referenced by closestcolor(), create_gif(), and GetPixel().

◆ static_green

int static_green[MAX_GIFCOLORS]
static

Definition at line 76 of file gl2gif.cpp.

Referenced by closestcolor(), and create_gif().

◆ static_nbcolors

int static_nbcolors
static

Definition at line 79 of file gl2gif.cpp.

Referenced by closestcolor(), and create_gif().

◆ static_perm

int static_perm[MAX_GIFCOLORS]
static

Definition at line 78 of file gl2gif.cpp.

Referenced by create_gif(), and GetPixel().

◆ static_permi

int static_permi[MAX_GIFCOLORS]
static

Definition at line 78 of file gl2gif.cpp.

Referenced by closestcolor(), and create_gif().

◆ static_pixels

pixel** static_pixels
static

Definition at line 80 of file gl2gif.cpp.

Referenced by create_gif(), and GetPixel().

◆ static_red

int static_red[MAX_GIFCOLORS]
static

Definition at line 75 of file gl2gif.cpp.

Referenced by closestcolor(), and create_gif().

◆ Width

int Width
static

Definition at line 562 of file gl2gif.cpp.

Referenced by BumpPixel(), and GIFEncode().