vp8li_enc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright 2012 Google Inc. All Rights Reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style license
  4. // that can be found in the COPYING file in the root of the source
  5. // tree. An additional intellectual property rights grant can be found
  6. // in the file PATENTS. All contributing project authors may
  7. // be found in the AUTHORS file in the root of the source tree.
  8. // -----------------------------------------------------------------------------
  9. //
  10. // Lossless encoder: internal header.
  11. //
  12. // Author: Vikas Arora (vikaas.arora@gmail.com)
  13. #ifndef WEBP_ENC_VP8LI_H_
  14. #define WEBP_ENC_VP8LI_H_
  15. #include "./backward_references_enc.h"
  16. #include "./histogram_enc.h"
  17. #include "../utils/bit_writer_utils.h"
  18. #include "../webp/encode.h"
  19. #include "../webp/format_constants.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. // maximum value of transform_bits_ in VP8LEncoder.
  24. #define MAX_TRANSFORM_BITS 6
  25. typedef struct {
  26. const WebPConfig* config_; // user configuration and parameters
  27. const WebPPicture* pic_; // input picture.
  28. uint32_t* argb_; // Transformed argb image data.
  29. uint32_t* argb_scratch_; // Scratch memory for argb rows
  30. // (used for prediction).
  31. uint32_t* transform_data_; // Scratch memory for transform data.
  32. uint32_t* transform_mem_; // Currently allocated memory.
  33. size_t transform_mem_size_; // Currently allocated memory size.
  34. int current_width_; // Corresponds to packed image width.
  35. // Encoding parameters derived from quality parameter.
  36. int histo_bits_;
  37. int transform_bits_; // <= MAX_TRANSFORM_BITS.
  38. int cache_bits_; // If equal to 0, don't use color cache.
  39. // Encoding parameters derived from image characteristics.
  40. int use_cross_color_;
  41. int use_subtract_green_;
  42. int use_predict_;
  43. int use_palette_;
  44. int palette_size_;
  45. uint32_t palette_[MAX_PALETTE_SIZE];
  46. // Some 'scratch' (potentially large) objects.
  47. struct VP8LBackwardRefs refs_[2]; // Backward Refs array corresponding to
  48. // LZ77 & RLE coding.
  49. VP8LHashChain hash_chain_; // HashChain data for constructing
  50. // backward references.
  51. } VP8LEncoder;
  52. //------------------------------------------------------------------------------
  53. // internal functions. Not public.
  54. // Encodes the picture.
  55. // Returns 0 if config or picture is NULL or picture doesn't have valid argb
  56. // input.
  57. int VP8LEncodeImage(const WebPConfig* const config,
  58. const WebPPicture* const picture);
  59. // Encodes the main image stream using the supplied bit writer.
  60. // If 'use_cache' is false, disables the use of color cache.
  61. WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
  62. const WebPPicture* const picture,
  63. VP8LBitWriter* const bw, int use_cache);
  64. //------------------------------------------------------------------------------
  65. // Image transforms in predictor.c.
  66. void VP8LResidualImage(int width, int height, int bits, int low_effort,
  67. uint32_t* const argb, uint32_t* const argb_scratch,
  68. uint32_t* const image, int near_lossless, int exact,
  69. int used_subtract_green);
  70. void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
  71. uint32_t* const argb, uint32_t* image);
  72. //------------------------------------------------------------------------------
  73. #ifdef __cplusplus
  74. } // extern "C"
  75. #endif
  76. #endif /* WEBP_ENC_VP8LI_H_ */