Home | History | Annotate | Download | only in enc
      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 (at) gmail.com)
     13 
     14 #ifndef WEBP_ENC_VP8LI_H_
     15 #define WEBP_ENC_VP8LI_H_
     16 
     17 #include "./backward_references.h"
     18 #include "./histogram.h"
     19 #include "../utils/bit_writer.h"
     20 #include "webp/encode.h"
     21 #include "webp/format_constants.h"
     22 
     23 #ifdef __cplusplus
     24 extern "C" {
     25 #endif
     26 
     27 typedef struct {
     28   const WebPConfig* config_;    // user configuration and parameters
     29   const WebPPicture* pic_;      // input picture.
     30 
     31   uint32_t* argb_;              // Transformed argb image data.
     32   uint32_t* argb_scratch_;      // Scratch memory for argb rows
     33                                 // (used for prediction).
     34   uint32_t* transform_data_;    // Scratch memory for transform data.
     35   int       current_width_;     // Corresponds to packed image width.
     36 
     37   // Encoding parameters derived from quality parameter.
     38   int histo_bits_;
     39   int transform_bits_;
     40   int cache_bits_;        // If equal to 0, don't use color cache.
     41 
     42   // Encoding parameters derived from image characteristics.
     43   int use_cross_color_;
     44   int use_subtract_green_;
     45   int use_predict_;
     46   int use_palette_;
     47   int palette_size_;
     48   uint32_t palette_[MAX_PALETTE_SIZE];
     49 
     50   // Some 'scratch' (potentially large) objects.
     51   struct VP8LBackwardRefs refs_[2];  // Backward Refs array corresponding to
     52                                      // LZ77 & RLE coding.
     53   VP8LHashChain hash_chain_;         // HashChain data for constructing
     54                                      // backward references.
     55 } VP8LEncoder;
     56 
     57 //------------------------------------------------------------------------------
     58 // internal functions. Not public.
     59 
     60 // Encodes the picture.
     61 // Returns 0 if config or picture is NULL or picture doesn't have valid argb
     62 // input.
     63 int VP8LEncodeImage(const WebPConfig* const config,
     64                     const WebPPicture* const picture);
     65 
     66 // Encodes the main image stream using the supplied bit writer.
     67 WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
     68                                    const WebPPicture* const picture,
     69                                    VP8LBitWriter* const bw);
     70 
     71 //------------------------------------------------------------------------------
     72 
     73 #ifdef __cplusplus
     74 }    // extern "C"
     75 #endif
     76 
     77 #endif  /* WEBP_ENC_VP8LI_H_ */
     78