Path: blob/master/3rdparty/libwebp/src/enc/vp8li_enc.h
16344 views
// Copyright 2012 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// Lossless encoder: internal header.10//11// Author: Vikas Arora ([email protected])1213#ifndef WEBP_ENC_VP8LI_ENC_H_14#define WEBP_ENC_VP8LI_ENC_H_1516#ifdef HAVE_CONFIG_H17#include "src/webp/config.h"18#endif19// Either WEBP_NEAR_LOSSLESS is defined as 0 in config.h when compiling to20// disable near-lossless, or it is enabled by default.21#ifndef WEBP_NEAR_LOSSLESS22#define WEBP_NEAR_LOSSLESS 123#endif2425#include "src/enc/backward_references_enc.h"26#include "src/enc/histogram_enc.h"27#include "src/utils/bit_writer_utils.h"28#include "src/webp/encode.h"29#include "src/webp/format_constants.h"3031#ifdef __cplusplus32extern "C" {33#endif3435// maximum value of transform_bits_ in VP8LEncoder.36#define MAX_TRANSFORM_BITS 63738typedef enum {39kEncoderNone = 0,40kEncoderARGB,41kEncoderNearLossless,42kEncoderPalette43} VP8LEncoderARGBContent;4445typedef struct {46const WebPConfig* config_; // user configuration and parameters47const WebPPicture* pic_; // input picture.4849uint32_t* argb_; // Transformed argb image data.50VP8LEncoderARGBContent argb_content_; // Content type of the argb buffer.51uint32_t* argb_scratch_; // Scratch memory for argb rows52// (used for prediction).53uint32_t* transform_data_; // Scratch memory for transform data.54uint32_t* transform_mem_; // Currently allocated memory.55size_t transform_mem_size_; // Currently allocated memory size.5657int current_width_; // Corresponds to packed image width.5859// Encoding parameters derived from quality parameter.60int histo_bits_;61int transform_bits_; // <= MAX_TRANSFORM_BITS.62int cache_bits_; // If equal to 0, don't use color cache.6364// Encoding parameters derived from image characteristics.65int use_cross_color_;66int use_subtract_green_;67int use_predict_;68int use_palette_;69int palette_size_;70uint32_t palette_[MAX_PALETTE_SIZE];7172// Some 'scratch' (potentially large) objects.73struct VP8LBackwardRefs refs_[3]; // Backward Refs array for temporaries.74VP8LHashChain hash_chain_; // HashChain data for constructing75// backward references.76} VP8LEncoder;7778//------------------------------------------------------------------------------79// internal functions. Not public.8081// Encodes the picture.82// Returns 0 if config or picture is NULL or picture doesn't have valid argb83// input.84int VP8LEncodeImage(const WebPConfig* const config,85const WebPPicture* const picture);8687// Encodes the main image stream using the supplied bit writer.88// If 'use_cache' is false, disables the use of color cache.89WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,90const WebPPicture* const picture,91VP8LBitWriter* const bw, int use_cache);9293#if (WEBP_NEAR_LOSSLESS == 1)94// in near_lossless.c95// Near lossless preprocessing in RGB color-space.96int VP8ApplyNearLossless(const WebPPicture* const picture, int quality,97uint32_t* const argb_dst);98#endif99100//------------------------------------------------------------------------------101// Image transforms in predictor.c.102103void VP8LResidualImage(int width, int height, int bits, int low_effort,104uint32_t* const argb, uint32_t* const argb_scratch,105uint32_t* const image, int near_lossless, int exact,106int used_subtract_green);107108void VP8LColorSpaceTransform(int width, int height, int bits, int quality,109uint32_t* const argb, uint32_t* image);110111//------------------------------------------------------------------------------112113#ifdef __cplusplus114} // extern "C"115#endif116117#endif /* WEBP_ENC_VP8LI_ENC_H_ */118119120