PackMemory with result=0
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Tomio.
The following code works well with filesizes up to 1.1MB, but 1.3 and more produces result=0.
AllocateMemory seems to work. I have win98 and 224MB Ram.
Does someone can explain this?
.....
.....
If ReadFile(vvfn, in$)
UseFile(vvfn)
olen = Lof()
If olen 0
If AllocateMemory(vvm1, olen, 0) And AllocateMemory(vvm2, olen+vvdoff+8, 0)
ReadData(UseMemory(vvm1), olen)
dlen = PackMemory(UseMemory(vvm1), UseMemory(vvm2), olen)
CloseFile(vvfn)
FreeMemory(vvm1): UseMemory(vvm2)
OpenFile(vvfn,out$)
If dlen
.....
.....
Thank you for help
../tomio
The following code works well with filesizes up to 1.1MB, but 1.3 and more produces result=0.
AllocateMemory seems to work. I have win98 and 224MB Ram.
Does someone can explain this?
.....
.....
If ReadFile(vvfn, in$)
UseFile(vvfn)
olen = Lof()
If olen 0
If AllocateMemory(vvm1, olen, 0) And AllocateMemory(vvm2, olen+vvdoff+8, 0)
ReadData(UseMemory(vvm1), olen)
dlen = PackMemory(UseMemory(vvm1), UseMemory(vvm2), olen)
CloseFile(vvfn)
FreeMemory(vvm1): UseMemory(vvm2)
OpenFile(vvfn,out$)
If dlen
.....
.....
Thank you for help
../tomio
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Tomio.
These are wav-files.
No problem to compress bmp-files of size up to 2.5MB at least.
If you still want one of these files, let me know. But probably it's no longer necessary.
Thank you for the hint.../tomio
I think you are right.Originally posted by fred
Result = 0 is may be due to the fact than you file can not be compressed. Can let me have access to one of this file which doesn't compress ?
Fred - AlphaSND
These are wav-files.
No problem to compress bmp-files of size up to 2.5MB at least.
If you still want one of these files, let me know. But probably it's no longer necessary.
Thank you for the hint.../tomio
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Hi Tomio,
just try to pack each of your files with ZIP for example... so you may see if it would be possible to pack it a lot nor not... If ZIP will reduce the size a lot, the PackLib should manage this too!?
greetz
MrVainSCL! aka Thorsten
PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
Hi Tomio,
just try to pack each of your files with ZIP for example... so you may see if it would be possible to pack it a lot nor not... If ZIP will reduce the size a lot, the PackLib should manage this too!?
greetz
MrVainSCL! aka Thorsten
PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tranquil.
Possible your packed data is larger then the uncompressed due to the fact that wave is very hard to compress. Try to allocate more memory to the destination buffer, possible at works then!?
Mike
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
Possible your packed data is larger then the uncompressed due to the fact that wave is very hard to compress. Try to allocate more memory to the destination buffer, possible at works then!?
Mike
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
I think the compression algo Fred is using stops the compression if the compressed data grow larger than the original data, that's the way i would have coded the algo anyway. It's no point using a compressed version that's bloated when the original version is smaler, unless you want to prevent someone to easily use your sound data.Originally posted by tranquil
Possible your packed data is larger then the uncompressed due to the fact that wave is very hard to compress. Try to allocate more memory to the destination buffer, possible at works then!?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Tomio.
The wav file has size 4690 KB.
zip can compress it and the result is 5% smaller.
I doubled the destination memory size, but PackMemory still ends with =0.
> unless you want to prevent someone to easily use your sound data.
That's it.
../tomio
The wav file has size 4690 KB.
zip can compress it and the result is 5% smaller.
I doubled the destination memory size, but PackMemory still ends with =0.
> unless you want to prevent someone to easily use your sound data.
That's it.
../tomio
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
> zip can compress it and the result is 5% smaller.
I have found that the PB compression algorithm more often than not produce worse results than winzip and winrar does. Audio data is generaly hard to compress much, if any at all, unless you use a compression method that has been developed for that particular purpose, then i guess you could make the audio data 5%-15% smaler(just guessing numbers now, don't hold me to it).
>> unless you want to prevent someone to easily use your sound data.
>That's it.
You could just scramble it with a small key using bitwise xor, that would prevent the not-so-persistent people to rip your stuff.
> zip can compress it and the result is 5% smaller.
I have found that the PB compression algorithm more often than not produce worse results than winzip and winrar does. Audio data is generaly hard to compress much, if any at all, unless you use a compression method that has been developed for that particular purpose, then i guess you could make the audio data 5%-15% smaler(just guessing numbers now, don't hold me to it).
>> unless you want to prevent someone to easily use your sound data.
>That's it.
You could just scramble it with a small key using bitwise xor, that would prevent the not-so-persistent people to rip your stuff.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
I packed succesfully exe files with >15MB without problems (you have to wait a while...).
This Information should be in the help file!
Have a nice day...
Franco
I packed succesfully exe files with >15MB without problems (you have to wait a while...).
Such an explanation would make sense why if you try to pack a zip file it's not working at all.Originally posted by Pupil
I think the compression algo Fred is using stops the compression if the compressed data grow larger than the original data, that's the way i would have coded the algo anyway. It's no point using a compressed version that's bloated when the original version is smaler, unless you want to prevent someone to easily use your sound data.
This Information should be in the help file!
Have a nice day...
Franco
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> wave is very hard to compress
Using Winzip, I have 4 x wav files (all 8 bit, mono, 11khz) that are
all compressed by 78%. For example: One of them is a 661558-byte wav,
compressed into the zip archive into only 138822 bytes. I'd say that's
a GREAT compression ratio...
> wave is very hard to compress
all compressed by 78%. For example: One of them is a 661558-byte wav,
compressed into the zip archive into only 138822 bytes. I'd say that's
a GREAT compression ratio...
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
I think that if you up the bits and up the sample rate i think you get data that is similar to white noise, which is uncompressable(obviously it depend heavily on what you've sampled, if you've recorded 1 minute of silence you would get very god compression ratio).Originally posted by PB
> wave is very hard to compress
Using Winzip, I have 4 x wav files (all 8 bit, mono, 11khz) that are
all compressed by 78%. For example: One of them is a 661558-byte wav,
compressed into the zip archive into only 138822 bytes. I'd say that's
a GREAT compression ratio...
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TheBeck.
Sample rate has nothing to do with it. it's all about how repetitive the data is. If you compress a wav file that was recorded from a microphone then it will have noise in it witch is very hard to compress. If you compress a wav file that was generated by a computer synthesizer software or text to speech software then you will get a very good compression rate due to all the repetitive data. Try running your wave through background noise cancellation software and you may get better results.
Sample rate has nothing to do with it. it's all about how repetitive the data is. If you compress a wav file that was recorded from a microphone then it will have noise in it witch is very hard to compress. If you compress a wav file that was generated by a computer synthesizer software or text to speech software then you will get a very good compression rate due to all the repetitive data. Try running your wave through background noise cancellation software and you may get better results.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm