Skip to content

Commit

Permalink
phase_one_correct always returns value; handle P1 return codes in pos…
Browse files Browse the repository at this point in the history
…tprocessing
  • Loading branch information
alextutubalin committed Aug 28, 2015
1 parent b55228c commit 490ef94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
6 changes: 4 additions & 2 deletions dcraw/dcraw.c
Expand Up @@ -1758,7 +1758,7 @@ int CLASS phase_one_correct()
/* static */ const signed char dir[12][2] =
{ {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0},
{-2,-2}, {-2,2}, {2,-2}, {2,2} };
float poly[8], num, cfrac, frac, mult[2], *yval[2];
float poly[8], num, cfrac, frac, mult[2], *yval[2]={NULL,NULL};
ushort *xval[2];
int qmult_applied = 0, qlin_applied = 0;

Expand Down Expand Up @@ -1988,9 +1988,11 @@ int CLASS phase_one_correct()
}
catch (...)
{
return LIBRAW_CANCELLED_BY_CALLBACK;
if(yval[0]) free(yval[0]);
return LIBRAW_CANCELLED_BY_CALLBACK;
}
#endif
return 0;
}

void CLASS phase_one_load_raw()
Expand Down
6 changes: 4 additions & 2 deletions internal/dcraw_common.cpp
Expand Up @@ -1474,7 +1474,7 @@ int CLASS phase_one_correct()
/* static */ const signed char dir[12][2] =
{ {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0},
{-2,-2}, {-2,2}, {2,-2}, {2,2} };
float poly[8], num, cfrac, frac, mult[2], *yval[2];
float poly[8], num, cfrac, frac, mult[2], *yval[2]={NULL,NULL};
ushort *xval[2];
int qmult_applied = 0, qlin_applied = 0;

Expand Down Expand Up @@ -1704,9 +1704,11 @@ int CLASS phase_one_correct()
}
catch (...)
{
return LIBRAW_CANCELLED_BY_CALLBACK;
if(yval[0]) free(yval[0]);
return LIBRAW_CANCELLED_BY_CALLBACK;
}
#endif
return 0;
}

void CLASS phase_one_load_raw()
Expand Down
20 changes: 16 additions & 4 deletions src/libraw_cxx.cpp
Expand Up @@ -1699,8 +1699,14 @@ int LibRaw::raw2image(void)
if (is_phaseone_compressed())
{
phase_one_allocate_tempbuffer();
phase_one_subtract_black((ushort*)imgdata.rawdata.raw_alloc,imgdata.rawdata.raw_image);
phase_one_correct();
int rc = phase_one_subtract_black((ushort*)imgdata.rawdata.raw_alloc,imgdata.rawdata.raw_image);
if(rc == 0)
rc = phase_one_correct();
if(rc!=0)
{
phase_one_free_tempbuffer();
return rc;
}
}

// free and re-allocate image bitmap
Expand Down Expand Up @@ -1971,8 +1977,14 @@ int LibRaw::raw2image_ex(int do_subtract_black)
if (is_phaseone_compressed())
{
phase_one_allocate_tempbuffer();
phase_one_subtract_black((ushort*)imgdata.rawdata.raw_alloc,imgdata.rawdata.raw_image);
phase_one_correct();
int rc = phase_one_subtract_black((ushort*)imgdata.rawdata.raw_alloc,imgdata.rawdata.raw_image);
if(rc == 0)
rc = phase_one_correct();
if(rc!=0)
{
phase_one_free_tempbuffer();
return rc;
}
}

// process cropping
Expand Down

0 comments on commit 490ef94

Please sign in to comment.