[Hugo Ferreira][Positronic Dreams][Stick Soldiers]
"Redundant book title: "Windows For Dummies".
"Camouflage condoms: So they won''t see you coming".
🔒 Locked
Run Length Encoding
Advertisement
Original Post
How do we find sequences of repeating characters
inside a file, is there a specialized algorithm
for this purpose? (its obvious how to find them,
but is there a good algo for this purpose?)
I would like a link or an explanation, if possible,
thanks all,
no wisdom?
[Hugo Ferreira][Positronic Dreams][Stick Soldiers]
"Redundant book title: "Windows For Dummies".
"Camouflage condoms: So they won''t see you coming".
I jsut so happen to have made a RLE program on the weekend 
Basically you look through each byte and cound the length of the run by looking at all the bytes after that and stopping when it is different. If it is more than 2 bytes, add a ''run'' packet with the length followed by the byte. If the run is too short put a ''raw'' packet that just tells it to copy x number of bytes directly. Read the document on TGA file format on wotsits'' site, it had a good description on how the packets work and how to decode it
Im afraid you will have to make your own algorythm though
good luck!
Basically you look through each byte and cound the length of the run by looking at all the bytes after that and stopping when it is different. If it is more than 2 bytes, add a ''run'' packet with the length followed by the byte. If the run is too short put a ''raw'' packet that just tells it to copy x number of bytes directly. Read the document on TGA file format on wotsits'' site, it had a good description on how the packets work and how to decode it
Im afraid you will have to make your own algorythm though
Maybe I don''t understand your question, but you are going to have to scan trought the file at least ONCE, so why not just test if the current character is the same as the last one.
If so increment a repeat counter for that character.
This is about as simple as its going to get!
In other words there''s no ''trick'' that you''re missing.
If so increment a repeat counter for that character.
This is about as simple as its going to get!
In other words there''s no ''trick'' that you''re missing.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement