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.

93 lines
2.3KB

  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 "put_bits.h"
  34. #define VLC_BITS 11
  35. #if HAVE_BIGENDIAN
  36. #define B 3
  37. #define G 2
  38. #define R 1
  39. #define A 0
  40. #else
  41. #define B 0
  42. #define G 1
  43. #define R 2
  44. #define A 3
  45. #endif
  46. typedef enum Predictor {
  47. LEFT = 0,
  48. PLANE,
  49. MEDIAN,
  50. } Predictor;
  51. typedef struct HYuvContext {
  52. AVCodecContext *avctx;
  53. Predictor predictor;
  54. GetBitContext gb;
  55. PutBitContext pb;
  56. int interlaced;
  57. int decorrelate;
  58. int bitstream_bpp;
  59. int version;
  60. int yuy2; //use yuy2 instead of 422P
  61. int bgr32; //use bgr32 instead of bgr24
  62. int width, height;
  63. int flags;
  64. int context;
  65. int picture_number;
  66. int last_slice_end;
  67. uint8_t *temp[3];
  68. uint64_t stats[3][256];
  69. uint8_t len[3][256];
  70. uint32_t bits[3][256];
  71. uint32_t pix_bgr_map[1<<VLC_BITS];
  72. VLC vlc[6]; //Y,U,V,YY,YU,YV
  73. AVFrame picture;
  74. uint8_t *bitstream_buffer;
  75. unsigned int bitstream_buffer_size;
  76. DSPContext dsp;
  77. } HYuvContext;
  78. void ff_huffyuv_common_init(AVCodecContext *s);
  79. void ff_huffyuv_common_end(HYuvContext *s);
  80. int ff_huffyuv_alloc_temp(HYuvContext *s);
  81. int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table);
  82. #endif /* AVCODEC_HUFFYUV_H */