home *** CD-ROM | disk | FTP | other *** search
/ Der Mediaplex Sampler - Die 6 von Plex / 6_v_plex.zip / 6_v_plex / DISK5 / WIN_12 / IDEPIX2.ZIP / TIFFACS.ZIP / DCMPBLOK.ASM < prev    next >
Assembly Source File  |  1987-10-08  |  3KB  |  109 lines

  1. memM = 1
  2. ?WIN = 0
  3. ?PLM = 0
  4.  
  5. include cmacros.inc
  6.  
  7.     EXTRN    _bytes_processed:dword
  8.  
  9. ;****************************************************************************;
  10. ;                                         ;
  11. ; DECOMPRESS_BLOCK - Decompress a block of raw image data             ;
  12. ;                                         ;
  13. ; The following subroutine is used to decompress one block of image data and ;
  14. ; to save the raw image in a caller supplied destination buffer.         ;
  15. ;                                         ;
  16. ; "C" calling sequence :                                                     ;
  17. ;                                         ;
  18. ;    int    decompress_block();    /* Image block compression routine */;
  19. ;    char    raw_video[];        /* Buffer containing raw image */    ;
  20. ;    char    cdata[];        /* Buffer containing compressed data ;
  21. ;    int    line_length;        /* Length of one scan line */         ;
  22. ;    int    block_length;        /* Number of scan lines in block */  ;
  23. ;       .                                     ;
  24. ;       .                                     ;
  25. ;       .                                     ;
  26. ;    decompress_block (raw_video,cdata,line_length, block_length);         ;
  27. ;                                         ;
  28. ;****************************************************************************;
  29. ;
  30. createSeg    _dcompres_TEXT,dcompres_TEXT,BYTE,PUBLIC,CODE
  31.  
  32. sBegin    dcompres_TEXT
  33.  
  34.     assumes    CS,_dcompres_TEXT
  35.     assumes DS,DATA
  36.  
  37.     PUBLIC    _decompress_block
  38.     PUBLIC    _srcbuff
  39.     PUBLIC  _endbuff
  40.  
  41.     EXTRN    _dcompres:FAR
  42.  
  43. _srcbuff    DW    0
  44.         DW    0
  45. _endbuff    DW    0
  46.  
  47. cProc    decompress_block,<PUBLIC,FAR>,<si,di,es>
  48. parmD    raw_video
  49. parmD    cdata
  50. parmW    line_len
  51. parmD    blocklen
  52. parmD    bytes_in_strip
  53. cBegin    decompress_block
  54.  
  55.     MOV    AX,SEG_raw_video ; load the segment register with
  56.     MOV    ES,AX         ; the segment of the destination
  57.  
  58.     mov    ax,OFF_cdata        ; get the compressed data addr
  59.     mov    cs:_srcbuff,ax        ; and put it away
  60.     mov    ax,SEG_cdata        ; 
  61.     mov    cs:_srcbuff+2,ax        ;
  62.     mov    ax,OFF_bytes_in_strip    ; get the bytes in the strip
  63.                     ; so that we may tell the 
  64.                     ; decompressor when to stop
  65.     add    ax,cs:_srcbuff        ; and put the value in endbuff
  66.     mov    cs:_endbuff,ax    
  67.  
  68.  
  69. ;
  70. ; decompress decompresses one scan line at a time. the huffman code
  71. ; for a scan line may end in the middle of a byte.  If it does, the 
  72. ; algorithm needs to throw the remainder of that byte away before 
  73. ; starting to decompress the next scan line.  The second xor ax,ax
  74. ; does just that.
  75.  
  76. ;
  77. ; Decompress scan lines in block
  78. ;
  79.     XOR    AX,AX            ; No residuals yet
  80.     MOV    WORD PTR ds:_bytes_processed,AX ; initialize byte count
  81.     MOV    WORD PTR ds:_bytes_processed+2,AX
  82. DECOMP_LOOP:
  83.     XOR    AX,AX            ; get rid of the residuals
  84.     MOV    DI,OFF_raw_video    ; Set up param's to compression rtn.
  85.     MOV    CX,line_len        ; move the length of the line to cx
  86.     CALL    _DCOMPRES        ; now decompress the scan line
  87.  
  88. ;1/14/87
  89.                     ; convert the pixels processed
  90.     add    cx,7            ; into bytecount
  91.     shr    cx,1
  92.     shr    cx,1
  93.     shr    cx,1
  94.  
  95.     ADD    WORD PTR ds:_bytes_processed, CX    ; increment byte count
  96.     ADC    WORD PTR ds:_bytes_processed+2, 0
  97.  
  98.     ADD    OFF_raw_video,cx
  99.     DEC    OFF_blocklen
  100.     JNZ    DECOMP_LOOP
  101. EXIT_COMP:
  102.     MOV    AX,WORD PTR ds:_bytes_processed
  103.     MOV    DX,WORD PTR ds:_bytes_processed+2
  104. cEnd    decompress_block
  105.  
  106. sEnd     dcompres_TEXT
  107. END
  108.