15a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// Copyright 2012 Google Inc. All Rights Reserved.
25a50414796e9a458925c7a13a15055d02406bf43Vikas Arora//
35a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// This code is licensed under the same terms as WebM:
45a50414796e9a458925c7a13a15055d02406bf43Vikas Arora//  Software License Agreement:  http://www.webmproject.org/license/software/
55a50414796e9a458925c7a13a15055d02406bf43Vikas Arora//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
65a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// -----------------------------------------------------------------------------
75a50414796e9a458925c7a13a15055d02406bf43Vikas Arora//
85a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// Lossless encoder: internal header.
95a50414796e9a458925c7a13a15055d02406bf43Vikas Arora//
105a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// Author: Vikas Arora (vikaas.arora@gmail.com)
115a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
125a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#ifndef WEBP_ENC_VP8LI_H_
135a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#define WEBP_ENC_VP8LI_H_
145a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
155a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#include "./histogram.h"
165a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#include "../utils/bit_writer.h"
175a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#include "webp/encode.h"
185a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#include "webp/format_constants.h"
195a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
205a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#if defined(__cplusplus) || defined(c_plusplus)
215a50414796e9a458925c7a13a15055d02406bf43Vikas Aroraextern "C" {
225a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#endif
235a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
245a50414796e9a458925c7a13a15055d02406bf43Vikas Aroratypedef struct {
255a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  const WebPConfig* config_;    // user configuration and parameters
265a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  const WebPPicture* pic_;      // input picture.
275a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
285a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  uint32_t* argb_;              // Transformed argb image data.
295a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  uint32_t* argb_scratch_;      // Scratch memory for argb rows
305a50414796e9a458925c7a13a15055d02406bf43Vikas Arora                                // (used for prediction).
315a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  uint32_t* transform_data_;    // Scratch memory for transform data.
325a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int       current_width_;     // Corresponds to packed image width.
335a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
345a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  // Encoding parameters derived from quality parameter.
355a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int histo_bits_;
365a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int transform_bits_;
375a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int cache_bits_;        // If equal to 0, don't use color cache.
385a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
395a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  // Encoding parameters derived from image characteristics.
405a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int use_cross_color_;
415a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int use_subtract_green_;
425a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int use_predict_;
435a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int use_palette_;
445a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  int palette_size_;
455a50414796e9a458925c7a13a15055d02406bf43Vikas Arora  uint32_t palette_[MAX_PALETTE_SIZE];
465a50414796e9a458925c7a13a15055d02406bf43Vikas Arora} VP8LEncoder;
475a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
485a50414796e9a458925c7a13a15055d02406bf43Vikas Arora//------------------------------------------------------------------------------
495a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// internal functions. Not public.
505a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
515a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// Encodes the picture.
525a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// Returns 0 if config or picture is NULL or picture doesn't have valid argb
535a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// input.
545a50414796e9a458925c7a13a15055d02406bf43Vikas Aroraint VP8LEncodeImage(const WebPConfig* const config,
555a50414796e9a458925c7a13a15055d02406bf43Vikas Arora                    const WebPPicture* const picture);
565a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
575a50414796e9a458925c7a13a15055d02406bf43Vikas Arora// Encodes the main image stream using the supplied bit writer.
585a50414796e9a458925c7a13a15055d02406bf43Vikas AroraWebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
595a50414796e9a458925c7a13a15055d02406bf43Vikas Arora                                   const WebPPicture* const picture,
605a50414796e9a458925c7a13a15055d02406bf43Vikas Arora                                   VP8LBitWriter* const bw);
615a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
625a50414796e9a458925c7a13a15055d02406bf43Vikas Arora//------------------------------------------------------------------------------
635a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
645a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#if defined(__cplusplus) || defined(c_plusplus)
655a50414796e9a458925c7a13a15055d02406bf43Vikas Arora}    // extern "C"
665a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#endif
675a50414796e9a458925c7a13a15055d02406bf43Vikas Arora
685a50414796e9a458925c7a13a15055d02406bf43Vikas Arora#endif  /* WEBP_ENC_VP8LI_H_ */
69