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.

84 lines
2.5KB

  1. /*
  2. * Copyright (c) 2012 Konstantin Shishkov
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * Common header for Microsoft Screen 1 and 2
  23. */
  24. #ifndef AVCODEC_MSS12_H
  25. #define AVCODEC_MSS12_H
  26. #include "avcodec.h"
  27. #include "get_bits.h"
  28. #define MODEL_MIN_SYMS 2
  29. #define MODEL_MAX_SYMS 256
  30. #define THRESH_ADAPTIVE -1
  31. #define THRESH_LOW 15
  32. #define THRESH_HIGH 50
  33. typedef struct Model {
  34. int cum_prob[MODEL_MAX_SYMS + 1];
  35. int weights[MODEL_MAX_SYMS + 1];
  36. int idx2sym[MODEL_MAX_SYMS + 1];
  37. int sym2idx[MODEL_MAX_SYMS + 1];
  38. int num_syms;
  39. int thr_weight, threshold;
  40. } Model;
  41. typedef struct ArithCoder {
  42. int low, high, value;
  43. GetBitContext *gb;
  44. int (*get_model_sym)(struct ArithCoder *c, Model *m);
  45. int (*get_number) (struct ArithCoder *c, int n);
  46. } ArithCoder;
  47. typedef struct PixContext {
  48. int cache_size, num_syms;
  49. uint8_t cache[12];
  50. Model cache_model, full_model;
  51. Model sec_models[4][8][4];
  52. } PixContext;
  53. typedef struct MSS12Context {
  54. AVCodecContext *avctx;
  55. uint8_t *pic_start;
  56. int pic_stride;
  57. uint8_t *mask;
  58. int mask_linesize;
  59. uint32_t pal[256];
  60. int free_colours;
  61. int keyframe;
  62. Model intra_region, inter_region;
  63. Model pivot, edge_mode, split_mode;
  64. PixContext intra_pix_ctx, inter_pix_ctx;
  65. int corrupted;
  66. } MSS12Context;
  67. int ff_mss12_decode_rect(MSS12Context *ctx, ArithCoder *acoder,
  68. int x, int y, int width, int height);
  69. void ff_mss12_model_update(Model *m, int val);
  70. void ff_mss12_codec_reset(MSS12Context *ctx);
  71. av_cold int ff_mss12_decode_init(AVCodecContext *avctx, int version);
  72. av_cold int ff_mss12_decode_end(AVCodecContext *avctx);
  73. #endif /* AVCODEC_MSS12_H */