Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.5 KiB

  1. /*
  2. * d16uncmp.c
  3. *
  4. * Decoding uncompressed blocks
  5. */
  6. #include "decoder.h"
  7. int NEAR decode_uncompressed_block(
  8. t_decoder_context * context,
  9. long bufpos,
  10. int amount_to_decode /* yes, it will equal 32768 */
  11. )
  12. {
  13. byte *p;
  14. p = context->dec_input_curpos;
  15. /*
  16. * Since this is a DO loop, we predecrement amount_to_decode,
  17. * so it's ok for it to come in with a value of 32768
  18. */
  19. do
  20. {
  21. if (p >= context->dec_end_input_pos)
  22. return -1;
  23. context->DComp_Token_Literal(
  24. context,
  25. *p++
  26. );
  27. } while (--amount_to_decode > 0);
  28. context->dec_input_curpos = p;
  29. return 0;
  30. }
  31. bool NEAR handle_beginning_of_uncompressed_block(t_decoder_context *context)
  32. {
  33. int i;
  34. /*
  35. * we want to read the 16 bits already in bitbuf, so backtrack
  36. * the input pointer by 2 bytes
  37. */
  38. context->dec_input_curpos -= 2;
  39. if (context->dec_input_curpos + 4 >= context->dec_end_input_pos)
  40. return false;
  41. /*
  42. * update LRU repeated offset list
  43. */
  44. for (i = 0; i < NUM_REPEATED_OFFSETS; i++)
  45. {
  46. context->dec_last_matchpos_offset[i] =
  47. ((ulong) *( (byte *) context->dec_input_curpos) ) |
  48. ((ulong) *( ((byte *) context->dec_input_curpos) + 1) << 8) |
  49. ((ulong) *( ((byte *) context->dec_input_curpos) + 2) << 16) |
  50. ((ulong) *( ((byte *) context->dec_input_curpos) + 3) << 24);
  51. context->dec_input_curpos += 4; /* increment by 4 bytes */
  52. }
  53. return true;
  54. }