Diff of /resample.c [3af83f] .. [15dc8a]  Maximize  Restore

Switch to unified view

a/resample.c b/resample.c
...
...
804
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
804
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
805
// FS+ start of functions used to compute the pixel tranform from dest to source using linear interpolation
805
// FS+ start of functions used to compute the pixel tranform from dest to source using linear interpolation
806
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
806
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
807
807
808
// computes the source coordinates of a single pixel at position x using the math transforms
808
// computes the source coordinates of a single pixel at position x using the math transforms
809
void ComputePixelCoords( double *ax, double *ay, int *trinum, char *avalid, pt_int32 x, long offset, double w2, double y_d, 
809
void ComputePixelCoords( double *ax, double *ay, int *trinum, char *avalid, uint32_t x, long offset, double w2, double y_d, 
810
                          fDesc *fD, double sw2, double sh2, double min_x, double max_x, double min_y, double max_y ) {
810
                          fDesc *fD, double sw2, double sh2, double min_x, double max_x, double min_y, double max_y ) {
811
    double x_d, Dx, Dy;
811
    double x_d, Dx, Dy;
812
        int tvalid;
812
        int tvalid;
813
813
814
    // Convert destination screen coordinates to cartesian coordinates.         
814
    // Convert destination screen coordinates to cartesian coordinates.         
...
...
835
}
835
}
836
836
837
// fills a part of the arrays with the coordinates in the source image for every pixel
837
// fills a part of the arrays with the coordinates in the source image for every pixel
838
// xl is the left border of the array, xr is the right border. The array values have already been
838
// xl is the left border of the array, xr is the right border. The array values have already been
839
//   computed in xl and xr.
839
//   computed in xl and xr.
840
void ComputePartialRowCoords( double *ax, double *ay, int *trinum, char *avalid, pt_int32 xl, pt_int32 xr, long offset, double w2, double y_d, 
840
void ComputePartialRowCoords( double *ax, double *ay, int *trinum, char *avalid, uint32_t xl, uint32_t xr, long offset, double w2, double y_d, 
841
                          fDesc *fD, double sw2, double sh2, double min_x, double max_x, double min_y, double max_y ) {
841
                          fDesc *fD, double sw2, double sh2, double min_x, double max_x, double min_y, double max_y ) {
842
    pt_int32 xm, idx;
842
    uint32_t xm, idx;
843
    double srcX_lin, srcY_lin;
843
    double srcX_lin, srcY_lin;
844
    double deltaX, deltaY, tmpX, tmpY;
844
    double deltaX, deltaY, tmpX, tmpY;
845
845
846
    ////////////////////////////////////////////
846
    ////////////////////////////////////////////
847
    // maximum estimated error to be accepted: higher values produce a faster execution but a more distorted image
847
    // maximum estimated error to be accepted: higher values produce a faster execution but a more distorted image
...
...
931
931
932
// fills the arrays with the source coords computed using linear interpolation
932
// fills the arrays with the source coords computed using linear interpolation
933
// asize is the number of elements of the arrays
933
// asize is the number of elements of the arrays
934
// the array elements lie in the interval [0, asize], the image elements in [destRect.left, destRect.right]: the offset parameter
934
// the array elements lie in the interval [0, asize], the image elements in [destRect.left, destRect.right]: the offset parameter
935
//   is used for the conversion
935
//   is used for the conversion
936
void ComputeRowCoords( double *ax, double *ay, int *trinum, char *avalid, pt_int32 asize, long offset, double w2, double y_d, 
936
void ComputeRowCoords( double *ax, double *ay, int *trinum, char *avalid, int32_t asize, long offset, double w2, double y_d, 
937
                          fDesc *fD, double sw2, double sh2, double min_x, double max_x, double min_y, double max_y, int STEP_WIDTH) {
937
                          fDesc *fD, double sw2, double sh2, double min_x, double max_x, double min_y, double max_y, int STEP_WIDTH) {
938
938
939
    // STEP_WIDTH is initial distance betwen correctly computed points. The distance will be reduced if needed.
939
    // STEP_WIDTH is initial distance betwen correctly computed points. The distance will be reduced if needed.
940
940
941
    pt_int32 x;
941
    uint32_t x;
942
942
943
    x = 0;
943
    x = 0;
944
    ComputePixelCoords( ax, ay, trinum, avalid, x, offset, w2, y_d, fD, sw2, sh2, min_x, max_x, min_y, max_y );
944
    ComputePixelCoords( ax, ay, trinum, avalid, x, offset, w2, y_d, fD, sw2, sh2, min_x, max_x, min_y, max_y );
945
    x += STEP_WIDTH;
945
    x += STEP_WIDTH;
946
    while( x < asize ) {
946
    while( x < asize ) {
...
...
994
/*This function was added by Kekus Digital on 18/9/2002. 
994
/*This function was added by Kekus Digital on 18/9/2002. 
995
This function takes the parameter 'imageNum' which repesents the 
995
This function takes the parameter 'imageNum' which repesents the 
996
index of the image that has to be converted.*/
996
index of the image that has to be converted.*/
997
void MyTransForm( TrformStr *TrPtr, fDesc *fD, int color, int imageNum)
997
void MyTransForm( TrformStr *TrPtr, fDesc *fD, int color, int imageNum)
998
{
998
{
999
    register pt_int32        x, y;       // Loop through destination image
999
    register uint32_t         x, y;       // Loop through destination image
1000
    register pt_int32        i, k;       // Auxilliary loop variables
1000
    register uint32_t         i, k;       // Auxilliary loop variables
1001
    int             skip = 0;   // Update progress counter
1001
    int             skip = 0;   // Update progress counter
1002
    unsigned char       *dest,*src,*sry;// Source and destination image data
1002
    unsigned char       *dest,*src,*sry;// Source and destination image data
1003
    register unsigned char      *sr;    // Source  image data
1003
    register unsigned char      *sr;    // Source  image data
1004
    char            progressMessage[30];// Message to be displayed by progress reporter
1004
    char            progressMessage[30];// Message to be displayed by progress reporter
1005
    char                    percent[8]; // Number displayed by Progress reporter
1005
    char                    percent[8]; // Number displayed by Progress reporter
...
...
1929
1929
1930
*/
1930
*/
1931
1931
1932
1932
1933
void transForm_aa( TrformStr *TrPtr, fDesc *fD,fDesc *finvD, int color, int imageNum){
1933
void transForm_aa( TrformStr *TrPtr, fDesc *fD,fDesc *finvD, int color, int imageNum){
1934
    register pt_int32     x, y;       // Loop through destination image
1934
    register uint32_t     x, y;       // Loop through destination image
1935
    int             skip = 0;   // Update progress counter
1935
    int             skip = 0;   // Update progress counter
1936
    unsigned char       *dest,*src;// Source and destination image data
1936
    unsigned char       *dest,*src;// Source and destination image data
1937
                                        // Message to be displayed by progress reporter
1937
                                        // Message to be displayed by progress reporter
1938
    char*           progressMessage = "Something is wrong here";
1938
    char*           progressMessage = "Something is wrong here";
1939
    char                    percent[8]; // Number displayed by Progress reporter
1939
    char                    percent[8]; // Number displayed by Progress reporter
...
...
1982
    int ptmod_last=0,ptmod_first=0;
1982
    int ptmod_last=0,ptmod_first=0;
1983
    int ffStackTop=0,ffIsInQueueSize;
1983
    int ffStackTop=0,ffIsInQueueSize;
1984
    ffQueueItem *ffStack;
1984
    ffQueueItem *ffStack;
1985
    int         srcWidth; 
1985
    int         srcWidth; 
1986
    int         srcHeight; 
1986
    int         srcHeight; 
1987
    pt_uint32 *ffIsInQueue;
1987
    uint32_t *ffIsInQueue;
1988
1988
1989
    int ccx,ccy;
1989
    int ccx,ccy;
1990
    double d,sd,ox,oy;
1990
    double d,sd,ox,oy;
1991
    long cp;
1991
    long cp;
1992
1992
...
...
2180
            goto Trform_exit;
2180
            goto Trform_exit;
2181
        }
2181
        }
2182
    }
2182
    }
2183
2183
2184
    // Allocate the memory for the Stack, Floodfill markers and Cache
2184
    // Allocate the memory for the Stack, Floodfill markers and Cache
2185
    invCache=(invCacheItem *) calloc(INV_CACHE_SIZE * sizeof(invCacheItem),1);
2185
    invCache= calloc(INV_CACHE_SIZE * sizeof(invCacheItem),1);
2186
    ffStack=(ffQueueItem *) calloc(FF_STACK_SIZE * sizeof(ffQueueItem),1);
2186
    ffStack= calloc(FF_STACK_SIZE * sizeof(ffQueueItem),1);
2187
    ffIsInQueueSize=(((srcWidth*srcHeight) / 32) + 1);
2187
    ffIsInQueueSize= ((srcWidth*srcHeight) / 32) + 1;
2188
    ffIsInQueue=(pt_uint32 *)  calloc(ffIsInQueueSize * sizeof(pt_uint32),1);
2188
    ffIsInQueue=  calloc(ffIsInQueueSize * sizeof(uint32_t),1);
2189
2189
2190
    for(y=destRect.top; y<destRect.bottom; y++){
2190
    for(y=destRect.top; y<destRect.bottom; y++){
2191
        // Update Progress report and check for cancel every 2%.
2191
        // Update Progress report and check for cancel every 2%.
2192
        skip++;
2192
        skip++;
2193
        if( skip == (int)ceil(TrPtr->dest->height/50.0) ){
2193
        if( skip == (int)ceil(TrPtr->dest->height/50.0) ){
...
...
2280
                int warpover=(TrPtr->src->format==_equirectangular);
2280
                int warpover=(TrPtr->src->format==_equirectangular);
2281
2281
2282
                int bx,by,ex,ey;                                            
2282
                int bx,by,ex,ey;                                            
2283
                double DstX,DstY,rDstX,rDstY;
2283
                double DstX,DstY,rDstX,rDstY;
2284
                double weight,w,rd,gd,bd;
2284
                double weight,w,rd,gd,bd;
2285
                pt_uint32 *ptui;
2285
                uint32_t *ptui;
2286
2286
2287
                bx = (int)(floor(orgDx + sw2));
2287
                bx = (int)(floor(orgDx + sw2));
2288
                ex = (int)(ceil(orgDx + sw2));
2288
                ex = (int)(ceil(orgDx + sw2));
2289
                by = (int)(floor(orgDy + sh2));
2289
                by = (int)(floor(orgDy + sh2));
2290
                ey = (int)(ceil(orgDy + sh2));
2290
                ey = (int)(ceil(orgDy + sh2));