2012-03-28 13:07:42 +02:00
|
|
|
// Copyright 2012 Google Inc. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// This code is licensed under the same terms as WebM:
|
|
|
|
// Software License Agreement: http://www.webmproject.org/license/software/
|
|
|
|
// Additional IP Rights Grant: http://www.webmproject.org/license/additional/
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Lossless encoder: internal header.
|
|
|
|
//
|
|
|
|
// Author: Vikas Arora(vikaas.arora@gmail.com)
|
|
|
|
|
|
|
|
#ifndef WEBP_ENC_VP8LI_H_
|
|
|
|
#define WEBP_ENC_VP8LI_H_
|
|
|
|
|
2012-04-11 11:52:13 +02:00
|
|
|
#ifdef USE_LOSSLESS_ENCODER
|
|
|
|
|
2012-04-10 09:00:36 +02:00
|
|
|
#include "./histogram.h"
|
2012-03-28 13:07:42 +02:00
|
|
|
#include "../webp/encode.h"
|
|
|
|
#include "../utils/bit_writer.h"
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// TODO(vikasa): factorize these with ones used in lossless decoder.
|
|
|
|
#define TAG_SIZE 4
|
|
|
|
#define CHUNK_HEADER_SIZE 8
|
|
|
|
#define RIFF_HEADER_SIZE 12
|
|
|
|
#define HEADER_SIZE (RIFF_HEADER_SIZE + CHUNK_HEADER_SIZE)
|
|
|
|
#define SIGNATURE_SIZE 1
|
|
|
|
#define LOSSLESS_MAGIC_BYTE 0x64
|
|
|
|
|
2012-04-10 09:00:36 +02:00
|
|
|
#define MAX_PALETTE_SIZE 256
|
|
|
|
#define PALETTE_KEY_RIGHT_SHIFT 22 // Key for 1K buffer.
|
|
|
|
|
2012-03-28 13:07:42 +02:00
|
|
|
typedef struct {
|
|
|
|
const WebPConfig* config_; // user configuration and parameters
|
2012-04-10 09:00:36 +02:00
|
|
|
WebPPicture* pic_; // input picture.
|
|
|
|
|
|
|
|
uint32_t* argb_; // Transformed argb image data.
|
2012-04-13 09:01:11 +02:00
|
|
|
uint32_t* argb_scratch_; // Scratch memory for current and top row.
|
|
|
|
// (used for prediction).
|
2012-04-10 09:00:36 +02:00
|
|
|
uint32_t* transform_data_; // Scratch memory for transform data.
|
2012-04-11 06:20:16 +02:00
|
|
|
int current_width_; // Corresponds to packed image width.
|
2012-03-28 13:07:42 +02:00
|
|
|
|
|
|
|
// Encoding parameters derived from quality parameter.
|
|
|
|
int use_lz77_;
|
|
|
|
int palette_bits_;
|
|
|
|
int histo_bits_;
|
|
|
|
int transform_bits_;
|
|
|
|
|
|
|
|
// Encoding parameters derived from image characteristics.
|
|
|
|
int use_cross_color_;
|
2012-04-10 09:00:36 +02:00
|
|
|
int use_predict_;
|
|
|
|
int use_palette_;
|
|
|
|
int palette_size_;
|
|
|
|
uint32_t palette_[MAX_PALETTE_SIZE];
|
2012-03-28 13:07:42 +02:00
|
|
|
} VP8LEncoder;
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// internal functions. Not public.
|
|
|
|
|
|
|
|
// in vp8l.c
|
|
|
|
|
|
|
|
// Encodes the picture.
|
|
|
|
// Returns 0 if config or picture is NULL or picture doesn't have valid argb
|
|
|
|
// input.
|
|
|
|
int VP8LEncodeImage(const WebPConfig* const config,
|
|
|
|
WebPPicture* const picture);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2012-04-11 11:52:13 +02:00
|
|
|
#endif
|
|
|
|
|
2012-03-28 13:07:42 +02:00
|
|
|
#endif /* WEBP_ENC_VP8LI_H_ */
|