Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

aplib decompression

Featured Replies

Posted

Does anyone have a idea on how aplib algo works? This is a derivation of lz78 decompression.

I want to know the meanings of the routines like getbit getgamma and how it is used to read the dictionary.

 

Below is the code

 

==================

aP_depack_asm:
    ; aP_depack_asm(const void *source, void *destination)    _ret$  equ 7*4
    _src$  equ 8*4 + 4
    _dst$  equ 8*4 + 8    pushad    mov    esi, [esp + _src$] ; C calling convention
    mov    edi, [esp + _dst$]    cld
    mov    dl, 80h
    xor    ebx,ebxliteral:
    movsb
    mov    bl, 2
nexttag:
    call   getbit
    jnc    literal    xor    ecx, ecx
    call   getbit
    jnc    codepair
    
    xor    eax, eax
    call   getbit
    jnc    shortmatch
    
    mov    bl, 2
    inc    ecx
    mov    al, 10h
    
  .getmorebits:
    call   getbit
    adc    al, al
    jnc    .getmorebits
    
    jnz    domatch
    
    stosb
    jmp    nexttag
    
codepair:
    call   getgamma_no_ecx
    sub    ecx, ebx
    jnz    normalcodepair
    
    call   getgamma
    jmp    domatch_lastpos
    shortmatch:
    lodsb
    shr    eax, 1
    jz     donedepacking
    
    adc    ecx, ecx
    jmp    domatch_with_2incnormalcodepair:
    xchg   eax, ecx
    dec    eax
    shl    eax, 8
    lodsb
    call   getgamma    cmp    eax, 32000
    jae    domatch_with_2inc
    cmp    ah, 5
    jae    domatch_with_inc
    
    cmp    eax, 7fh
    ja     domatch_new_lastposdomatch_with_2inc:
    inc    ecxdomatch_with_inc:
    inc    ecxdomatch_new_lastpos:
    xchg   eax, ebp
domatch_lastpos:
    mov    eax, ebp    mov    bl, 1domatch:
    push   esi
    mov    esi, edi
    sub    esi, eax
    rep    movsb
    pop    esi
    jmp    nexttaggetbit:
    add    dl, dl
    jnz    .stillbitsleft
    mov    dl, [esi]
    inc    esi
    adc    dl, dl
  .stillbitsleft:
    retgetgamma:
    xor    ecx, ecx
    
getgamma_no_ecx:
    inc    ecx
  .getgammaloop:
    call   getbit
    adc    ecx, ecx
    call   getbit
    jc     .getgammaloop
    
    retdonedepacking:
    sub    edi, [esp + _dst$]
    mov    [esp + _ret$], edi ; return unpacked length in eax    popad    ret
 

:schmoll: wrong section friend.


1) It's not a derivation of LZ78, but LZ77. ;)

2) Once you understand the theory behind data compression, meanings of getbit() and getgamma() will be obvious to you. Check some tutorials or read "The Data Compression Book" (http://forum.eviloctal.com/attachment.php?aid=322 ).

  • Author

1) It's not a derivation of LZ78, but LZ77. ;)

2) Once you understand the theory behind data compression, meanings of getbit() and getgamma() will be obvious to you. Check some tutorials or read "The Data Compression Book" (http://forum.eviloctal.com/attachment.php?aid=322 ).

Hi Kao,

Can you give me some idea on this. I would help me learn a little faster. I went through lz77 and and some reading. Getbit seems to get a flag value from stream 0 or one according to which it is going to decide whether next bytes are literal or codeword(index,length) pair. What does the getgamma ,nexttag used for?

Look at APLib source in C - it's much more readable and has some comments.

getgamma() decodes integer number. APLib uses simple compression scheme to store integers, similar to (but not the same as) http://en.wikipedia.org/wiki/Elias_gamma_coding .

nexttag is just a label for a main loop. :)

  • Author

Look at APLib source in C - it's much more readable and has some comments.

getgamma() decodes integer number. APLib uses simple compression scheme to store integers, similar to (but not the same as) http://en.wikipedia.org/wiki/Elias_gamma_coding .

nexttag is just a label for a main loop. :)

thanks i ll find it out

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.