Hello,
I'm working on video stabilisation project on dm6437.
It's my MsC final project.I progress my code example based on phase correlation.
I have to do two dimensional fft on image row by row than column by column. And I select 256 *256 region from image.
I defined global variables just like this:
# define N 256
#pragma DATA_ALIGN(x_16x16, 128);
int x_16x16[900000];
#pragma DATA_ALIGN(y_16x16, 128);
int y_16x16[900000];
#pragma DATA_ALIGN(y2_16x16, 128);
int y2_16x16[900000];
#pragma DATA_ALIGN(w_16x16, 128);
short w_16x16 [2 * N * N];
#pragma DATA_ALIGN(w2_16x16, 8);
short w2_16x16 [2 * N];
#pragma DATA_ALIGN(line, 128);
int line [N];
#pragma DATA_ALIGN(lineIn, 128);
int lineIn [2 * N];
#pragma DATA_ALIGN(lineOut, 128);
int lineOut [2 * N];
#pragma DATA_ALIGN(lineIn2, 128);
int lineIn2 [2 * N];
#pragma DATA_ALIGN(lineOut2, 128);
int lineOut2 [2 * N];
#pragma DATA_ALIGN(FFTOut, 128);
int FFTOut [900000];
I write fft function like this:
void fft(void* currentFrame,int yRows, int xPixels)
{
int i = 0, j = 0;
int y = 0,t=0;
int *xp;
int FFTSize = N * N;
float scale = 8;
xPixels = 4;
gen_twiddle_fft16x32(w_16x16, N);
//fftrow
for(i = 0; i < 2 * N * N ; i++)
{
if(i % 2 == 0)
{
x_16x16[i] = *( ( ( int *)currentFrame ) + i ) ; ;
}
else
x_16x16[i] = 0;
}
for(i = 0; i < 2 * FFTSize; i += 2 * N)
{
DSP_blk_move((short *)(x_16x16 + i),(short *)(lineIn), 4 * N );
DSP_fft16x32(w_16x16, N, lineIn, lineOut);
// Scaled fft out
/* for(j=0;j<(2 * N);j++)
{lineOut[j]=lineOut[j]/512;}*/
DSP_blk_move((short *)(lineOut),(short *)(y_16x16 + i), 4 * N );
}
//fftcolumn
DSP_mat_trans2(y_16x16,256, 256 , y2_16x16);
for(i = 0; i < 2 * FFTSize; i += 2 * N)
{
DSP_blk_move((short *)(y2_16x16 + i),(short *)(lineIn), 4 * N );
DSP_fft16x32(w_16x16, N, lineIn, lineOut);
//Scaled fft out
/* for(j=0;j<(2 * N);j++)
{lineOut[j]=lineOut[j]/20;}*/
DSP_blk_move((short *)(lineOut),(short *)(FFTOut + i), 4 * N );
}
DSP_mat_trans2(FFTOut, 256, 256 , y2_16x16);
}
// Transpose function
void DSP_mat_trans2(int *x, int rows, int columns, int *r)
{
int i , j, y = 0;
for(i = 0; i < 2 * N ; i++)
{
if(i % 2 == 0)
{
for(j = 0; j < 2 * N * N; j+= 2 * N)
{
r[y] = *( ( (int *)x ) + i + j) ;
r[y + 1] = *( ( (int *)x ) + i + j + 1);
y+=2;
}
}
}
}
I scaled lineOut and LineIn outs by a lot of number.But it never work.How can I overcome of this problem?I spent a lot of time unfortunately. Or I wrote more effective code.Could you help me please?Best Regards..