Browse Source

compiles and runs on linux, segfaults as expected

refactor
suhrke 5 years ago
parent
commit
05c02addc5
  1. 14
      source/Decoder.cpp
  2. 9
      source/Decoder.h
  3. 4
      source/Printer.cpp
  4. 18
      source/main.cpp

14
source/Decoder.cpp

@ -267,7 +267,7 @@ static int Recognizebits(t_data *result,uchar grid[NDOT][NDOT], @@ -267,7 +267,7 @@ static int Recognizebits(t_data *result,uchar grid[NDOT][NDOT],
// Determines rough grid position.
static void Getgridposition(t_procdata *pdata) {
void Getgridposition(t_procdata *pdata) {
int i,j,nx,ny,stepx,stepy,sizex,sizey;
int c,cmin,cmax,distrx[256],distry[256],limit;
uchar *data,*pd;
@ -332,7 +332,7 @@ static void Getgridposition(t_procdata *pdata) { @@ -332,7 +332,7 @@ static void Getgridposition(t_procdata *pdata) {
// Selects search range, determines grid intensity and estimates sharpness.
static void Getgridintensity(t_procdata *pdata) {
void Getgridintensity(t_procdata *pdata) {
int i,j,sizex,sizey,centerx,centery,dx,dy,n;
int searchx0,searchy0,searchx1,searchy1;
int distrc[256],distrd[256],cmean,cmin,cmax,limit,sum,contrast;
@ -401,7 +401,7 @@ static void Getgridintensity(t_procdata *pdata) { @@ -401,7 +401,7 @@ static void Getgridintensity(t_procdata *pdata) {
// Find angle and step of vertical grid lines.
static void Getxangle(t_procdata *pdata) {
void Getxangle(t_procdata *pdata) {
int i,j,a,x,y,x0,y0,dx,dy,sizex;
int h[NHYST],nh[NHYST],ystep;
uchar *data,*pd;
@ -467,7 +467,7 @@ static void Getxangle(t_procdata *pdata) { @@ -467,7 +467,7 @@ static void Getxangle(t_procdata *pdata) {
// Find angle and step of horizontal grid lines. Very similar to Getxangle().
static void Getyangle(t_procdata *pdata) {
void Getyangle(t_procdata *pdata) {
int i,j,a,x,y,x0,y0,dx,dy,sizex,sizey;
int h[NHYST],nh[NHYST],xstep;
uchar *data,*pd;
@ -532,7 +532,7 @@ static void Getyangle(t_procdata *pdata) { @@ -532,7 +532,7 @@ static void Getyangle(t_procdata *pdata) {
// Prepare data and allocate memory for data decoding.
static void Preparefordecoding(t_procdata *pdata) {
void Preparefordecoding(t_procdata *pdata) {
int sizex,sizey,dx,dy;
float xstep,ystep,border,sharpfactor,shift,maxxshift,maxyshift,dotsize;
// Get frequently used variables.
@ -839,7 +839,7 @@ int Decodeblock(t_procdata *pdata,int posx,int posy,t_data *result) { @@ -839,7 +839,7 @@ int Decodeblock(t_procdata *pdata,int posx,int posy,t_data *result) {
static void Decodenextblock(t_procdata *pdata) {
void Decodenextblock(t_procdata *pdata) {
int answer,ngroup,percent;
char s[TEXTLEN];
t_data result;
@ -913,7 +913,7 @@ finish: @@ -913,7 +913,7 @@ finish:
// Passes gathered data to file processor and frees resources allocated by call
// to Preparefordecoding().
static void Finishdecoding(t_procdata *pdata) {
void Finishdecoding(t_procdata *pdata) {
int i,fileindex;
// Pass gathered data to file processor.
if (pdata->superblock.addr==0)

9
source/Decoder.h

@ -73,7 +73,14 @@ extern int orientation; // Orientation of bitmap (-1: unknown) @@ -73,7 +73,14 @@ extern int orientation; // Orientation of bitmap (-1: unknown)
//unique
extern t_procdata procdata; // Descriptor of processed data
void Nextdataprocessingstep(t_procdata *pdata);
//void Nextdataprocessingstep(t_procdata *pdata);
void Getgridposition(t_procdata *pdata);
void Getgridintensity(t_procdata *pdata);
void Getxangle(t_procdata *pdata);
void Getyangle(t_procdata *pdata);
void Preparefordecoding(t_procdata *pdata);
void Decodenextblock(t_procdata *pdata);
void Finishdecoding(t_procdata *pdata);
void Freeprocdata(t_procdata *pdata);
void Startbitmapdecoding(t_procdata *pdata,uchar *data,int sizex,int sizey);
void Stopbitmapdecoding(t_procdata *pdata);

4
source/Printer.cpp

@ -528,7 +528,7 @@ void Initializeprinting(t_printdata *print) { @@ -528,7 +528,7 @@ void Initializeprinting(t_printdata *print) {
void Stopprinting(t_printdata *print) {
// close input flie.
if (print -> hfile != NULL) {
fclose(hfile);
fclose(print->hfile);
}
// deallocate memory
if (print -> buf != NULL) {
@ -547,7 +547,7 @@ void Stopprinting(t_printdata *print) { @@ -547,7 +547,7 @@ void Stopprinting(t_printdata *print) {
print -> step = 0;
}
static void Preparefiletoprint(t_printdata *print) {
void Preparefiletoprint(t_printdata *print) {
;
}

18
source/main.cpp

@ -158,12 +158,20 @@ int main(int argc, char ** argv) { @@ -158,12 +158,20 @@ int main(int argc, char ** argv) {
// Verify the input file has valid bitmap header
//!!!
// procdata.step drives control flow, value of 0 starts encoding
do {
Nextdataprocessingstep(&procdata);
} while (procdata.step != 0);
// Get attributes of the inputted bitmap
Getgridposition(&procdata);
Getgridintensity(&procdata);
Getxangle(&procdata);
Getyangle(&procdata);
// Get more attributes and allocate memory for decoding
Preparefordecoding(&procdata);
// Decode block by block until step changes
int currStep = procdata.step;
while ( procdata.step == currStep ) {
Decodenextblock(&procdata);
}
Finishdecoding(&procdata);
//!!!
}
Freeprocdata(&procdata);

Loading…
Cancel
Save