Hi!
I am currently developing a MrSid reader to our program and our Sid Reader based on the UsingCInterface.c example. The reader reads the sid image from block to block and I copy the buffers to our buffers to be used in our program.
I use the ltic_decode function with the following syntax:
ltic_decode(mSidImage, b->x1, b->y1, b->x2, b->y2, (1.0 / (1 << b->level)), (void**)rgbBuffer);
The "b"-s are the blocks. x1 and y1 defines the upper left corner and x2, y2 the lower right corner.
The values of the bounds are:
(0, 256), (256, 480)
(256, 256), (512, 480)
(512, 256), (640, 480),
(0, 0), (256, 256),
(256, 0), (512, 256),
(512, 0), (640, 256),
I think it is correct. The way we allocate memory to the buffer is the following:
dtBYTE *rgbBuffer[3];
for(i=0; i < mBandNum; i++)
{
rgbBuffer[i]=(dtBYTE*)dtMalloc(app->mRasterBlockSize * app->mRasterBlockSize);
if(rgbBuffer[i]==0) return 0;
}
(The app->mRasterBlockSize is 256.)
We copy the buffer in the following lines:
for(int y=0, pos=0; y < app->mRasterBlockSize; y++)
{ for(int x=0; x < app->mRasterBlockSize; x++,pos++)
{ for(i=0; i < mBandNum; i++)
{ *p++ = rgbBuffer[i][pos];
}
}
}
I think it is correct too.
But the program only shows the starting block on the screen:
The one with the (0, 0), (256, 256) coordinates.
Of course we call this function for every blocks.
(For example if I call the ltic_decode function with the
ltic_decode(mSidImage, 0, 0, 256, 256, (1.0 / (1 << b->level)), (void**)rgbBuffer); parameters, it will show the first MrSid block in every screen blocks. )
The interesting thing is, if I call the ltic_decode for example a block from (100, 100) to (356, 356) it freezes. (The reading.) So I do not know even if the function is correct in every aspect or if I use it correctly.
I do not know why it does not work. Can anybody help me with this?
reading MrSid to buffers using the ltic_api.h
Moderator: jskiffington
6 posts
• Page 1 of 1
A few things:
(1) What is "(1.0 / (1 << b->level)" (specifically, what is the value of b->level)?
(2) Are you checking the returned status code from the decode() call?
(3) Can you turn this into a simple, complete program that reproduces the file?
(4) What version of the SDK and what platform are you using?
(5) Does the error happen with all .sid files you've tried or just one?
-mpg
(1) What is "(1.0 / (1 << b->level)" (specifically, what is the value of b->level)?
(2) Are you checking the returned status code from the decode() call?
(3) Can you turn this into a simple, complete program that reproduces the file?
(4) What version of the SDK and what platform are you using?
(5) Does the error happen with all .sid files you've tried or just one?
-mpg
- mpg
- Posts: 29
- Joined: Thu Jan 24, 2008 1:50 pm
- Location: LizardTech
Hi!
Thank you for the fast reply.
(1) b->level is similar in our program to the magnitude in yours. Except it goes from 0 and what is 1 in your program it is 0 in ours and what is 2 in your program it is 1 in ours, etc...
So, if you check it it will work correctly. But it can not be a problem, I changed the magnitude to 1 in the function call for test purposes and it produces the same error.
(2) That's right. When I checked it with your -(LT_SUCCESS(sts)); syntax, it exits the program except the
sts = ltic_decode(mSidImage, 0, 0, 256, 256, 1, (void**)rgbBuffer);
case
so the
sts = ltic_decode(mSidImage, 256, 0, 512, 256, 1, (void**)rgbBuffer);
sts = ltic_decode(mSidImage, 512, 0, 640, 256, 1, (void**)rgbBuffer);
... etc
exits from the program.
I thought maybe the size of the rgbBuffer is not right, because the rgbBuffer is bigger in the case of (512, 0), (640, 256). But it can not be a problem in the case of (256, 0), (512, 256) because it has the same size as the (0, 0), (256, 256).
(3) Sadly we do not have the resources to turn it in to a simple but complete program.
(4) I am using Windows Vista Business with Service Pack 1 and the SDK version is 7.0.0.2167 for win32-vc8 Platform. It is a release version.
(5) It happens with all the .sid files.
Thank you for the fast reply.
(1) b->level is similar in our program to the magnitude in yours. Except it goes from 0 and what is 1 in your program it is 0 in ours and what is 2 in your program it is 1 in ours, etc...
So, if you check it it will work correctly. But it can not be a problem, I changed the magnitude to 1 in the function call for test purposes and it produces the same error.
(2) That's right. When I checked it with your -(LT_SUCCESS(sts)); syntax, it exits the program except the
sts = ltic_decode(mSidImage, 0, 0, 256, 256, 1, (void**)rgbBuffer);
case
so the
sts = ltic_decode(mSidImage, 256, 0, 512, 256, 1, (void**)rgbBuffer);
sts = ltic_decode(mSidImage, 512, 0, 640, 256, 1, (void**)rgbBuffer);
... etc
exits from the program.
I thought maybe the size of the rgbBuffer is not right, because the rgbBuffer is bigger in the case of (512, 0), (640, 256). But it can not be a problem in the case of (256, 0), (512, 256) because it has the same size as the (0, 0), (256, 256).
(3) Sadly we do not have the resources to turn it in to a simple but complete program.
(4) I am using Windows Vista Business with Service Pack 1 and the SDK version is 7.0.0.2167 for win32-vc8 Platform. It is a release version.
(5) It happens with all the .sid files.
- gerjak.balazs
- Posts: 4
- Joined: Tue Dec 01, 2009 5:56 am
Well, i found one of the problems. I used the
ltic_decode function as the third and the fourth parameter were not width and height but the coordinates of the lower right corner. I corrected the code.
Still, when I call the
sts = ltic_decode(mSidImage, 512, 256, 128, 224, 1, (void**)rgbBuffer);
and the
sts = ltic_decode(mSidImage, 512, 0, 128, 224, 1, (void**)rgbBuffer);
it causes problems. So basically the right side of the picture is messes up. like this two blocks would be like this: the lower half of the block (when I write block I mean one part in the right side, for example the upper right part (512, 0), (640, 256)) is correct, but it is in the upper half of the block and the lower half of the block contains a lots of little pictures from the center of the picture. Is it a porblem, if the height is width is just 128 and the height is 224? (Just half of the block is correct and its width and height similar to each other, so this is why I think this.)
ltic_decode function as the third and the fourth parameter were not width and height but the coordinates of the lower right corner. I corrected the code.
Still, when I call the
sts = ltic_decode(mSidImage, 512, 256, 128, 224, 1, (void**)rgbBuffer);
and the
sts = ltic_decode(mSidImage, 512, 0, 128, 224, 1, (void**)rgbBuffer);
it causes problems. So basically the right side of the picture is messes up. like this two blocks would be like this: the lower half of the block (when I write block I mean one part in the right side, for example the upper right part (512, 0), (640, 256)) is correct, but it is in the upper half of the block and the lower half of the block contains a lots of little pictures from the center of the picture. Is it a porblem, if the height is width is just 128 and the height is 224? (Just half of the block is correct and its width and height similar to each other, so this is why I think this.)
- gerjak.balazs
- Posts: 4
- Joined: Tue Dec 01, 2009 5:56 am
Of course I changed the memory allocation to this:
for(i=0; i < mBandNum; i++)
{
rgbBuffer[i]=(dtBYTE*)dtMalloc(width * height);
if(rgbBuffer[i]==0) return 0;
}
and the buffer copy to this:
for(int y=0, pos=0; y < width; y++)
{ for(int x=0; x < height; x++,pos++)
{ for(i=0; i < mBandNum; i++)
{ *p++ = rgbBuffer[i][pos];
}
}
}
The - does not exits from the program.
for(i=0; i < mBandNum; i++)
{
rgbBuffer[i]=(dtBYTE*)dtMalloc(width * height);
if(rgbBuffer[i]==0) return 0;
}
and the buffer copy to this:
for(int y=0, pos=0; y < width; y++)
{ for(int x=0; x < height; x++,pos++)
{ for(i=0; i < mBandNum; i++)
{ *p++ = rgbBuffer[i][pos];
}
}
}
The - does not exits from the program.
- gerjak.balazs
- Posts: 4
- Joined: Tue Dec 01, 2009 5:56 am
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: Google [Bot] and 1 guest
- Forum index
- The team • Delete all board cookies • All times are UTC - 7 hours
