-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First 5 bytes are "zeroed" out #3
Comments
@ryanjpearson I will have a look later this week... |
The PNG code makes it a bit harder to find the root cause. Could you first change your example C code to test the decompression of (EDIT):
which should result in:
|
Here's a simpler implemenation using the test case you provided. Thanks! |
I assume you verified that the first 5 bytes are still damaged (0) and the rest of the output is ok? |
Regarding the test data, why don't you just use (EDIT corrected wrong escapes):
In
Has the clock edge reversed, try changing this to:
Let me know if that makes a difference. If not I'll have a look at the rest of the code. Could you also tell me a bit more of your use case? Why are you driving/testing the decompress logic from C code? That will be very slow, just using the processor and a software implementation would have the same or higher speed.
|
Thanks for the suggestion! I'm away from the hardware for 2 weeks, but I will give it a shot then. Isn't the string you provided an ascii representation of the data? I used binascii.b2a_hex in python to convert it to the bytes in the code. I wasn't sure of any C functions that would convert "/x95" to just a char with value of 0x95. I'm new to that notation, and I thought it was python specific. I wasn't certain the micro-controller I'm using would have the memory needed for inflate. I may move more functionality to the FPGA, but I first wanted to verify I was able to interface to the inflate logic correctly. |
There is indeed an issue with 4 (3 reported by the compiler because it exceeds the 0-255 range) of the encoded bytes:
eg Corrected:
|
I used your suggestion and fixed a couple of mistakes in the decompress.txt. Attached is the latest. The output has bytes 0 through 18, 26, and 40 "zeroed" out. The rest of the bytes are what they should be. |
What happens if you do 2 clock ticks around line 100:
|
That made the problem go away! Thank you! |
That's good news! You will probably only need the extra tick when
|
Now, I'm trying to push through a deflate block of size 705 bytes. o_iprogress is stalling at 481, meaning I'm only able to write 513 bytes. This number is interesting (481 = 512 - 32 + 1). Any suggestions? Thanks! |
The standard input buffer is 512 bytes and cyclic. 32 bytes are reserved for look back when compressing (could also apply when decompressing). So if you are feeding data to decompress and it does not fit completely in the input buffer, you should also start the decompression and read the result so that the input buffer is emptied and you can reuse it in a cyclic way (after writing slot 511, continue with slot 0). See the test code around: Line 159 in 9a561a6
|
Following the example of test_deflate.py, I believe I start decompression at the beginning of the process. And I have an analogous check on i_progress. If you're able to take a look, I attached a zip file with the small png I'm testing with. And there's a binary file with just the compressed block that's inside the png. The compress block has a size of 705 bytes. It should inflate to a size of 5656 bytes (100x56 PNG 8-bit with 1 filter byte per line. 101*56=5656). Thanks! |
Can you print Both Progress indicators should start progressing after a number of clock cycles |
Here you go! It prints each time I'm able to write a byte to i_data and CompressedWriteCount increments. Thanks |
Your output ends with:
That looks good! I expect that at the end of your log you are no longer repeatedly calling That is needed in order to advance |
Also note You have just written byte 513, do you store this byte at slot |
It is still repeatedly calling DeflateClockStrobe() after that. It's only printing when it's able to write a byte ( meaning ((int)GetIProgress() > CompressedWriteCount - MAXW)). And the write addresses do wrap around back to zero since the register is 9 bits. Byte 513 is written to address 1. |
Another thing: the o_done bit goes high after byte 449 is written ( I think it was 449, I'll confirm tomorrow). I was under the belief that png contains just one deflate block, but I think that is false now. So, it may be that deflate is working fine, and I just need to start a new block. I will check this tomorrow. My apologies for reporting an error if this is the case. |
is different from the Python code. You switch to Line 169 in 9a561a6
|
Ah thanks, I will correct this. |
|
If the end of a block is reached and there are more blocks, do I need to start a new decompression and write STARTD to i_mode again? Or do I just keep writing in the compressed data? |
That should work, it does handle multiple blocks in a stream. I do not think that your issue is related to blocks, it is somehow related to writing input byte You could increase the buffersize to 1024 and it will most likely stop at position 1025.
This made no difference? |
|
I also noticed that my cwindow size was wrong, I had it set to 32 in my code. Since I had Compress = False and Lowlut = False, the CWINDOW size should be 256. I made this fix in the code, and it did not seem to matter. It still stalls after writing the 513th byte to address 0. |
Hi, I set up deflate.py with a 32768 OBSIZE and COMPRESS = False. I wrote C code based on test_deflate.py. When it runs, the first 5 bytes that are output on o_byte are zeroed out, but after that, the bytes look correct. The bytes are not coming out shifted. Byte 5 is what byte 5 is supposed to be, when I compared the output with the output of a software inflate function. The code is attached, thanks for any suggestions! (I'm particular wondering if there's an issue in InitDecompress, WriteDecompress, ReadDecompress, or DeflateClockStrobe functions.)
decompress.txt
The text was updated successfully, but these errors were encountered: