mlz.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2016 Umair Khan <omerjerk@gmail.com>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_MLZ_H
  21. #define AVCODEC_MLZ_H
  22. #include "get_bits.h"
  23. #define CODE_UNSET -1
  24. #define CODE_BIT_INIT 9
  25. #define DIC_INDEX_INIT 512 // 2^9
  26. #define DIC_INDEX_MAX 32768 // 2^15
  27. #define FLUSH_CODE 256
  28. #define FREEZE_CODE 257
  29. #define FIRST_CODE 258
  30. #define MAX_CODE 32767
  31. #define TABLE_SIZE 35023 // TABLE_SIZE must be a prime number
  32. /** Dictionary structure for mlz decompression
  33. */
  34. typedef struct MLZDict {
  35. int string_code;
  36. int parent_code;
  37. int char_code;
  38. int match_len;
  39. } MLZDict;
  40. /** MLZ data strucure
  41. */
  42. typedef struct MLZ {
  43. int dic_code_bit;
  44. int current_dic_index_max;
  45. unsigned int bump_code;
  46. unsigned int flush_code;
  47. int next_code;
  48. int freeze_flag;
  49. MLZDict* dict;
  50. void* context;
  51. } MLZ;
  52. /** Initialize the dictionary
  53. */
  54. void ff_mlz_init_dict(void* context, MLZ *mlz);
  55. /** Flush the dictionary
  56. */
  57. void ff_mlz_flush_dict(MLZ *dict);
  58. /** Run mlz decompression on the next size bits and the output will be stored in buff
  59. */
  60. int ff_mlz_decompression(MLZ* mlz, GetBitContext* gb, int size, unsigned char *buff);
  61. #endif /*AVCODEC_MLZ_H*/