Errors in my code!! was no errors in other compilers, Topic is solved

All technical discussions and projects around startKIT
Post Reply
NabeelLass
New User
Posts: 3
Joined: Mon Mar 14, 2016 6:27 pm

Errors in my code!! was no errors in other compilers,

Post by NabeelLass »

Hello,
I wrote a program for decompressing the image using IDCT code. It working fine with other C compiler programs but I got 4 errors when I start using XMOS studio.
errors are attached.
Is there any one can help?

Code: Select all

#include <stdio.h>
#include "math.h"
#include <xs1.h>

int i,j,k,l,n,p,t,f;
int r=0,c=0;
int ROWS=8;
int COLS=8;

void mul_func(double idctmtrx[ROWS][COLS], double array[ROWS][COLS],double multip1 [ROWS][COLS])
{
    int t,n,f;
    double multip[8][8]={};
    // multip1=multip;
    for (t=0;t<ROWS;t++)
for (n=0;n<COLS;n++)
for (f=0;f<COLS;f++)
    multip[n][t]+=idctmtrx[t][f]*array[f][n];

    for (t=0;t<ROWS;t++)
for (n=0;n<COLS;n++)
for (f=0;f<COLS;f++)
    multip1[n][t]+=idctmtrx[t][f]*multip[f][n];


}


int main() {
    double uncomp_mtrx[64][64]={0}; // decompress image to 64X64 pixel
    double multip1[8][8]={};
    double blk8[8][8]={};
    int blk_size1=0,blk_size2=0;
    int z,y;
    // IDCT block matrix
    double idctmtrx[8][8]={
    {0.3536, 0.4904, 0.4619,  0.4157, 0.3536,  0.2778, 0.1913, 0.0975},
    {0.3536, 0.4157, 0.1913, -0.0975,-0.3536, -0.4904,-0.4619,-0.2778},
    {0.3536, 0.2778,-0.1913, -0.4904,-0.3536,  0.0975, 0.4619, 0.4157},
    {0.3536, 0.0975,-0.4619, -0.2778, 0.3536,  0.4157,-0.1913,-0.4904},
    {0.3536,-0.0975,-0.4619,  0.2778, 0.3536, -0.4157,-0.1913, 0.4904},
    {0.3536,-0.2778,-0.1913,  0.4904,-0.3536, -0.0975, 0.4619,-0.4157},
    {0.3536,-0.4157, 0.1913,  0.0975,-0.3536,  0.4904,-0.4619, 0.2778},
    {0.3536,-0.4904, 0.4619, -0.4157, 0.3536, -0.2778, 0.1913,-0.0975},
    };

    // compressed image
double comp_img[24][24] = {
{3.3470538,-0.094712868,0.25273126,3.6084824,0.15095724,-0.055509154,3.09445,0.68629611,-0.12379481,2.842386,0.28898185,0.26562953,3.3004777,-0.8179518,0.32175267,4.584446,0.086723112,0.46481633,5.2372866,-0.083573446,-0.32129845,5.6621213,-0.27931619,0.37793508},
{-0.19208243,-0.097699828,0.2030694,0.12425214,0.059697174,-0.094127119,0.085711189,0.040745653,0.13904423,0.27481321,0.26884827,-0.82663995,0.86935097,-0.40145341,-1.0581354,0.00052765,-0.92857081,0.34391484,0.49889696,0.19950747,0.38039401,0.27952874,-0.021741342,-0.022436162},
{0.061739117,-0.20323133,0.18832077,0.23751786,0.091968693,-0.003471562,0.081204675,0.091851965,-0.076017603,-0.28260159,-0.37883875,0.40010688,0.20342742,1.034499,-0.20376796,-0.080312222,-0.19634812,-0.24929807,-0.34115577,0.21627252,-0.003757093,-0.11583321,0.20279311,0.20371601},
{3.9202402,-0.44022712,0.011885506,4.132678,0.27880225,0.085377537,3.0655844,0.66686815,-0.58259028,1.5382711,-0.53064257,0.37483916,2.2563033,0.12689871,0.3706156,2.7771628,0.27716658,0.041137002,2.197288,-0.14807808,-0.14506739,4.8927431,-1.1259537,-0.018860556},
{0.11248377,0.19158313,0.079900302,-0.2931782,-0.11989895,0.20550691,-0.006182689,-0.05865749,0.12756908,0.65935582,-0.36414611,0.11955509,0.075121328,0.74978167,0.37584054,1.1287222,-0.73995954,-0.28505799,1.5518544,-0.23785785,0.046177465,0.92624515,0.447905,0.53290778},
{-0.53374583,-0.10902599,0.055229433,0.36022031,-0.14268099,-0.31254736,0.23769115,0.18486732,-0.023071203,0.0489638,0.18823409,-0.078278489,0.31184095,0.038604915,0.10725452,1.6111593,0.45602727,0.009375028,0.57195449,0.29633319,-0.35819891,-0.60984981,-0.04632606,0.18012618},
{1.9149152,-0.40011364,-0.26158947,2.7762854,-0.3320353,0.01420952,3.4291499,0.10700842,-0.38801771,3.1744943,-1.6361898,-0.11696515,4.1045957,1.6571881,-0.6541636,2.2758608,0.73265153,0.08803983,1.9762167,-0.28904611,0.21548826,2.9456291,-0.49863252,0.41851053},
{0.22593647,0.14517468,0.092974506,0.41127723,-0.16420192,0.023760661,0.56000322,0.10371089,-0.26609319,-0.54294628,0.43636703,-0.23028144,-0.67622292,0.230002,-0.13936922,-0.13203338,0.098710299,-0.47188771,0.43383616,-0.070784092,-0.24134667,0.035043366,-0.69182289,-0.42663941},
{0.001553027,-0.023144126,0.03305326,0.16509256,-0.098958276,0.018005839,0.28096879,-0.17146382,0.095775925,-0.44198704,0.13703653,0.4494566,-0.28012335,-0.40976486,0.2042011,0.53234154,0.45423809,-0.36137336,0.25170222,-0.094524562,-0.18585712,-0.029339217,-0.32542747,-0.026321918},
{2.3845048,0.72848088,0.56497604,2.1498578,-0.18368268,0.032603025,3.0208459,-0.27514777,-0.000227862,4.4640517,-0.55995321,0.040121481,4.9263453,1.0484012,-0.71558672,1.4035064,0.25993982,0.24268298,3.059586,-0.78912967,-0.31046388,2.5489435,-0.54571754,1.2017484},
{-0.702811,-0.96778232,-0.047879182,0.00592481,0.052387051,-0.031000324,-0.34991762,0.017904118,0.062779985,-0.3769806,0.15134495,-0.090815209,-0.22894765,-0.4122225,0.51423538,0.031851985,-0.074301735,-0.15593001,-1.5582075,0.40182209,0.48959327,0.098210528,0.19828208,-0.15587333},
{0.062845185,-0.078650914,-0.57999408,0.032892227,0.008859133,0.007634499,-0.028953522,0.10908994,-0.030106619,-0.46917209,-0.063264355,0.16246304,-0.068934388,-0.13206372,0.33067849,0.046593145,-8.16E-05,-0.072171718,0.94016445,-0.27214286,-0.094434738,-0.14989318,0.32604212,0.008384071},
{4.418869,0.37468639,-0.50803655,2.0865114,-0.089661606,0.18578994,2.6663182,-0.025568193,-0.27765381,3.5883377,-0.29933184,-0.11242808,5.0179887,-0.48688155,-0.16906795,4.9513717,-0.16122456,-0.32081231,2.8737564,0.86623573,0.086301528,1.8691729,-1.2017239,0.97137022},
{-0.23744848,0.8038317,-0.42282906,0.009765254,-0.16001953,-0.34465525,0.46378317,-0.11440177,-0.18668982,0.46354896,0.19718754,0.046920571,0.79770738,0.26155156,-0.085302144,-0.003983678,-0.90704072,-0.015930515,1.9156351,0.3818112,-0.21438518,-0.000697535,-0.13340761,-0.12621401},
{-0.22130214,0.22722442,-0.008814971,0.11783837,0.22023007,0.33577302,0.038986251,-0.022587879,0.031232696,0.010561876,-0.10875951,0.10153386,-0.1881381,0.14235678,0.12693377,-1.0590429,0.00725466,-0.061639089,0.70910817,-0.48465043,-0.41697085,0.094322689,0.15582457,-0.1110899},
{3.9836762,-0.4058277,-0.11615127,3.1837327,1.2631387,0.10794547,1.5100882,0.23088662,0.000413342,3.5920625,-0.68196207,-0.14374709,4.3448505,-0.058310658,0.14449485,4.9507947,0.17678712,-0.15575467,2.8542051,1.384485,-0.1558778,1.8671432,-1.2031931,0.99124533},
{0.26548994,0.075638913,0.14963751,-0.53590298,0.12430599,0.76039314,0.099127062,-0.029918218,0.016241787,0.31713983,0.48760098,0.077563912,-0.67132407,0.22634323,0.061706007,-1.0809816,0.28162587,-0.45617059,-1.4128972,-0.97122937,0.34545898,0.31390685,-0.14635791,-0.030019086},
{-0.030583138,-0.11005644,-0.081645705,-0.047020681,-0.20340177,0.094265118,0.12263125,-0.069271088,0.033894565,-0.32218581,0.001184922,0.15783708,0.039079219,-0.14939117,0.06122341,-0.05514846,0.22262162,-0.23545742,0.00101099,-0.20583639,-0.31575647,0.095310703,-0.037229352,-0.12599739},
{3.2022686,-0.63268423,0.19270314,4.0806141,0.32238656,-0.45573723,1.857892,0.00248421,-0.052427005,2.4310677,-0.76769507,0.17695771,4.4239421,-0.36302653,-0.06045863,4.5789628,0.16437602,0.095309578,3.8420918,0.82236218,-1.1691427,1.3372313,-1.0678653,1.2854097},
{0.001627501,-0.3236416,-0.58819473,-0.018147279,0.20327438,-0.23714688,-0.15212207,0.066795252,-0.005804491,0.39228001,-0.68809807,-0.00048578,1.2355145,-0.037923582,0.033200569,1.3008201,-0.059270654,0.095682859,0.40852794,0.72726434,0.096561946,0.07317578,-0.10147115,-0.007007},
{0.17088853,0.26701763,0.23399484,-0.048530739,0.03956303,-0.014696018,-0.048037298,-0.000338397,-0.002289516,0.20280443,0.039132018,-0.26410565,-0.53306103,0.01552926,0.16422476,0.10426731,-0.32873487,-0.029664977,-0.000285063,0.070361845,0.28228807,0.053761952,-0.058500402,-0.024498645},
{4.5531206,1.5585341,1.2898436,3.7015553,0.26688996,-0.24144319,2.7451618,-0.43613154,-0.22722086,3.498709,-0.16812035,0.035476167,4.2358046,-0.17745531,-0.055355527,4.3159051,0.081624255,-0.015943175,3.6150458,0.31919819,-0.31119356,2.047811,-0.96460658,1.0231944},
{-0.81351352,-0.25856924,0.53119177,-0.22505969,-0.066413879,0.072039723,-0.99766046,0.15082817,0.062149797,-1.1884278,0.040068254,-0.031309377,-1.0360419,-0.17479603,0.01551294,-0.61801434,-0.090652049,-0.001599692,-0.24282821,-0.037032794,-0.2947647,-1.0269327,-0.12895177,0.23779993},
{0.44132787,-0.47892785,-0.25573349,0.72968113,-0.12139723,0.056969482,0.90966368,0.13353176,0.062796786,0.62848222,0.036948454,0.030102085,0.55697387,0.054902378,-0.015367433,0.42337403,-0.039186701,0.04784013,0.56255829,-0.1402034,0.18542099,0.98350847,0.18657202,-0.091797993}
};

for (i=0;i<22;i+=3)
{
for (j=0;j<22;j+=3)
{
    r=0;
    c=0;
    double blk8[8][8]={};
    for (k=i;k<i+3;k++)
    {
    for (l=j;l<j+3;l++)
       {
        blk8[r][c]=comp_img[k][l];
        c++;
        }

        c=0;
        r++;
     }

    mul_func(idctmtrx,blk8,multip1);
for (z=0;z<8;z++)
for (y=0;y<8;y++)
{
    //printf("%d %d %d",z+blk_size1,y+blk_size2,j);
    //getchar();

uncomp_mtrx[z+blk_size1][y+blk_size2]=multip1[z][y];
}
    /*
    // display this step
for (t=0;t<64;t++)
{
for (n=0;n<64;n++)
printf("%f ",uncomp_mtrx[t][n]);
printf("\n");
}  */
//printf("\n");

for (t=0;t<8;t++)
for (n=0;n<8;n++)
multip1[t][n]=0;


blk_size2+=8;

//getchar();

} // end of j
blk_size1=blk_size1+8;
blk_size2=0;
} // end of i

// display this step
for (t=0;t<64;t++)
{
for (n=0;n<64;n++)
printf("%f ",uncomp_mtrx[t][n]);
printf("\n");
}
printf("\n");

 return 0; } // end of main


Thanks

Sam
Attachments
errors.jpg
(327.68 KiB) Not downloaded yet
errors.jpg
(327.68 KiB) Not downloaded yet


View Solution
User avatar
ccrome
Active Member
Posts: 62
Joined: Wed Sep 23, 2015 1:15 am

Post by ccrome »

This one's straight forward:

change

Code: Select all

int ROWS=8;
int COLS=8;
to

Code: Select all

#define ROWS 8
#define COLS 8
You array sizes in functions must be constants, they can't be 'int'.

-caleb
User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Put that code in a C file, these restrictions only apply to XC code
NabeelLass
New User
Posts: 3
Joined: Mon Mar 14, 2016 6:27 pm

Post by NabeelLass »

Great!!
Only replacing

Code: Select all

int ROWS=8;
int COLS=8;
with

Code: Select all

#define ROWS 8
#define COLS 8
is solved the problem.
Thank you to you all
Post Reply