Path: blob/master/thirdparty/libwebp/src/enc/vp8li_enc.h
21790 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#endif1920#include <stddef.h>2122// Either WEBP_NEAR_LOSSLESS is defined as 0 in config.h when compiling to23// disable near-lossless, or it is enabled by default.24#ifndef WEBP_NEAR_LOSSLESS25#define WEBP_NEAR_LOSSLESS 126#endif2728#include "src/webp/types.h"29#include "src/enc/backward_references_enc.h"30#include "src/enc/histogram_enc.h"31#include "src/utils/bit_writer_utils.h"32#include "src/webp/encode.h"33#include "src/webp/format_constants.h"3435#ifdef __cplusplus36extern "C" {37#endif3839// maximum value of 'transform_bits' in VP8LEncoder.40#define MAX_TRANSFORM_BITS (MIN_TRANSFORM_BITS + (1 << NUM_TRANSFORM_BITS) - 1)4142typedef enum {43kEncoderNone = 0,44kEncoderARGB,45kEncoderNearLossless,46kEncoderPalette47} VP8LEncoderARGBContent;4849typedef struct {50const WebPConfig* config; // user configuration and parameters51const WebPPicture* pic; // input picture.5253uint32_t* argb; // Transformed argb image data.54VP8LEncoderARGBContent argb_content; // Content type of the argb buffer.55uint32_t* argb_scratch; // Scratch memory for argb rows56// (used for prediction).57uint32_t* transform_data; // Scratch memory for transform data.58uint32_t* transform_mem; // Currently allocated memory.59size_t transform_mem_size; // Currently allocated memory size.6061int current_width; // Corresponds to packed image width.6263// Encoding parameters derived from quality parameter.64int histo_bits;65int predictor_transform_bits; // <= MAX_TRANSFORM_BITS66int cross_color_transform_bits; // <= MAX_TRANSFORM_BITS67int cache_bits; // If equal to 0, don't use color cache.6869// Encoding parameters derived from image characteristics.70int use_cross_color;71int use_subtract_green;72int use_predict;73int use_palette;74int palette_size;75uint32_t palette[MAX_PALETTE_SIZE];76// Sorted version of palette for cache purposes.77uint32_t palette_sorted[MAX_PALETTE_SIZE];7879// Some 'scratch' (potentially large) objects.80struct VP8LBackwardRefs refs[4]; // Backward Refs array for temporaries.81VP8LHashChain hash_chain; // HashChain data for constructing82// backward references.83} VP8LEncoder;8485//------------------------------------------------------------------------------86// internal functions. Not public.8788// Encodes the picture.89// Returns 0 if config or picture is NULL or picture doesn't have valid argb90// input.91int VP8LEncodeImage(const WebPConfig* const config,92const WebPPicture* const picture);9394// Encodes the main image stream using the supplied bit writer.95// Returns false in case of error (stored in picture->error_code).96int VP8LEncodeStream(const WebPConfig* const config,97const WebPPicture* const picture, VP8LBitWriter* const bw);9899#if (WEBP_NEAR_LOSSLESS == 1)100// in near_lossless.c101// Near lossless preprocessing in RGB color-space.102int VP8ApplyNearLossless(const WebPPicture* const picture, int quality,103uint32_t* const argb_dst);104#endif105106//------------------------------------------------------------------------------107// Image transforms in predictor.c.108109// pic and percent are for progress.110// Returns false in case of error (stored in pic->error_code).111int VP8LResidualImage(int width, int height, int min_bits, int max_bits,112int low_effort, uint32_t* const argb,113uint32_t* const argb_scratch, uint32_t* const image,114int near_lossless, int exact, int used_subtract_green,115const WebPPicture* const pic, int percent_range,116int* const percent, int* const best_bits);117118int VP8LColorSpaceTransform(int width, int height, int bits, int quality,119uint32_t* const argb, uint32_t* image,120const WebPPicture* const pic, int percent_range,121int* const percent, int* const best_bits);122123void VP8LOptimizeSampling(uint32_t* const image, int full_width,124int full_height, int bits, int max_bits,125int* best_bits_out);126127//------------------------------------------------------------------------------128129#ifdef __cplusplus130} // extern "C"131#endif132133#endif // WEBP_ENC_VP8LI_ENC_H_134135136