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.

101 lines
2.9KB

  1. /*
  2. * Copyright (c) 2002-2014 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 FFmpeg.
  8. *
  9. * FFmpeg 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. * FFmpeg 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 FFmpeg; 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. #include "lossless_videodsp.h"
  37. #define VLC_BITS 12
  38. #define MAX_BITS 16
  39. #define MAX_N (1<<MAX_BITS)
  40. #define MAX_VLC_N 16384
  41. typedef enum Predictor {
  42. LEFT = 0,
  43. PLANE,
  44. MEDIAN,
  45. } Predictor;
  46. typedef struct HYuvContext {
  47. AVClass *class;
  48. AVCodecContext *avctx;
  49. Predictor predictor;
  50. GetBitContext gb;
  51. PutBitContext pb;
  52. int interlaced;
  53. int decorrelate;
  54. int bitstream_bpp;
  55. int version;
  56. int yuy2; //use yuy2 instead of 422P
  57. int bgr32; //use bgr32 instead of bgr24
  58. int bps;
  59. int n; // 1<<bps
  60. int vlc_n; // number of vlc codes (FFMIN(1<<bps, MAX_VLC_N))
  61. int alpha;
  62. int chroma;
  63. int yuv;
  64. int chroma_h_shift;
  65. int chroma_v_shift;
  66. int width, height;
  67. int flags;
  68. int context;
  69. int picture_number;
  70. int last_slice_end;
  71. uint8_t *temp[3];
  72. uint16_t *temp16[3]; ///< identical to temp but 16bit type
  73. uint64_t stats[4][MAX_VLC_N];
  74. uint8_t len[4][MAX_VLC_N];
  75. uint32_t bits[4][MAX_VLC_N];
  76. uint32_t pix_bgr_map[1<<VLC_BITS];
  77. VLC vlc[8]; //Y,U,V,A,YY,YU,YV,AA
  78. uint8_t *bitstream_buffer;
  79. unsigned int bitstream_buffer_size;
  80. BswapDSPContext bdsp;
  81. HuffYUVDSPContext hdsp;
  82. HuffYUVEncDSPContext hencdsp;
  83. LLVidDSPContext llviddsp;
  84. int non_determ; // non-deterministic, multi-threaded encoder allowed
  85. } HYuvContext;
  86. void ff_huffyuv_common_init(AVCodecContext *s);
  87. void ff_huffyuv_common_end(HYuvContext *s);
  88. int ff_huffyuv_alloc_temp(HYuvContext *s);
  89. int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n);
  90. #endif /* AVCODEC_HUFFYUV_H */