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.

97 lines
2.5KB

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