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.

67 lines
1.0 KiB

  1. /*
  2. * blkinit.c
  3. *
  4. * Block outputting initialisation
  5. */
  6. #include "encoder.h"
  7. /*
  8. * Create lookup table for MP_SLOT() macro
  9. */
  10. void create_slot_lookup_table(t_encoder_context *context)
  11. {
  12. int j;
  13. int p;
  14. int elements_to_init;
  15. byte slotnum;
  16. context->enc_slot_table[0] = 0;
  17. context->enc_slot_table[1] = 1;
  18. context->enc_slot_table[2] = 2;
  19. context->enc_slot_table[3] = 3;
  20. elements_to_init = 2;
  21. slotnum = 4;
  22. p = 4;
  23. do
  24. {
  25. for (j = elements_to_init; j > 0; j--)
  26. context->enc_slot_table[p++] = slotnum;
  27. slotnum++;
  28. for (j = elements_to_init; j > 0; j--)
  29. context->enc_slot_table[p++] = slotnum;
  30. slotnum++;
  31. elements_to_init <<= 1;
  32. } while (p < 1024);
  33. }
  34. /*
  35. * Create lookup table for figuring out how many
  36. * ones there are in a given byte.
  37. */
  38. void create_ones_table(t_encoder_context *context)
  39. {
  40. int i, j;
  41. byte ones;
  42. for (i = 0; i < 256; i++)
  43. {
  44. ones = 0;
  45. for (j = i; j; j >>= 1)
  46. {
  47. if (j & 1)
  48. ones++;
  49. }
  50. context->enc_ones[i] = ones;
  51. }
  52. }