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.

94 lines
2.4KB

  1. /*
  2. * Copyright (c) 2002-2003 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
  5. * the algorithm used
  6. *
  7. * This file is part of Libav.
  8. *
  9. * Libav is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * Libav is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with Libav; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. /**
  24. * @file
  25. * huffyuv codec for libavcodec.
  26. */
  27. #ifndef AVCODEC_HUFFYUV_H
  28. #define AVCODEC_HUFFYUV_H
  29. #include <stdint.h>
  30. #include "avcodec.h"
  31. #include "dsputil.h"
  32. #include "get_bits.h"
  33. #include "huffyuvdsp.h"
  34. #include "put_bits.h"
  35. #define VLC_BITS 11
  36. #if HAVE_BIGENDIAN
  37. #define B 3
  38. #define G 2
  39. #define R 1
  40. #define A 0
  41. #else
  42. #define B 0
  43. #define G 1
  44. #define R 2
  45. #define A 3
  46. #endif
  47. typedef enum Predictor {
  48. LEFT = 0,
  49. PLANE,
  50. MEDIAN,
  51. } Predictor;
  52. typedef struct HYuvContext {
  53. AVCodecContext *avctx;
  54. Predictor predictor;
  55. GetBitContext gb;
  56. PutBitContext pb;
  57. int interlaced;
  58. int decorrelate;
  59. int bitstream_bpp;
  60. int version;
  61. int yuy2; //use yuy2 instead of 422P
  62. int bgr32; //use bgr32 instead of bgr24
  63. int width, height;
  64. int flags;
  65. int context;
  66. int picture_number;
  67. int last_slice_end;
  68. uint8_t *temp[3];
  69. uint64_t stats[3][256];
  70. uint8_t len[3][256];
  71. uint32_t bits[3][256];
  72. uint32_t pix_bgr_map[1<<VLC_BITS];
  73. VLC vlc[6]; //Y,U,V,YY,YU,YV
  74. uint8_t *bitstream_buffer;
  75. unsigned int bitstream_buffer_size;
  76. DSPContext dsp;
  77. HuffYUVDSPContext hdsp;
  78. } HYuvContext;
  79. void ff_huffyuv_common_init(AVCodecContext *s);
  80. void ff_huffyuv_common_end(HYuvContext *s);
  81. int ff_huffyuv_alloc_temp(HYuvContext *s);
  82. int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table);
  83. #endif /* AVCODEC_HUFFYUV_H */