2014-02-10 02:10:30 +01:00
|
|
|
// Copyright 2012 Google Inc. All Rights Reserved.
|
|
|
|
//
|
2014-02-11 02:37:07 +01:00
|
|
|
// 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/
|
2014-02-10 02:10:30 +01:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Image transforms and color space conversion methods for lossless decoder.
|
|
|
|
//
|
|
|
|
// Authors: Vikas Arora (vikaas.arora@gmail.com)
|
|
|
|
// Jyrki Alakuijala (jyrki@google.com)
|
|
|
|
|
|
|
|
#ifndef WEBP_DSP_LOSSLESS_H_
|
|
|
|
#define WEBP_DSP_LOSSLESS_H_
|
|
|
|
|
2014-09-14 21:26:31 +02:00
|
|
|
#include "../types.h"
|
|
|
|
#include "../decode.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2014-02-11 02:37:07 +01:00
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
2014-02-10 02:10:30 +01:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Image transforms.
|
|
|
|
|
|
|
|
struct VP8LTransform; // Defined in dec/vp8li.h.
|
|
|
|
|
|
|
|
// Performs inverse transform of data given transform information, start and end
|
|
|
|
// rows. Transform will be applied to rows [row_start, row_end[.
|
|
|
|
// The *in and *out pointers refer to source and destination data respectively
|
|
|
|
// corresponding to the intermediate row (row_start).
|
|
|
|
void VP8LInverseTransform(const struct VP8LTransform* const transform,
|
|
|
|
int row_start, int row_end,
|
|
|
|
const uint32_t* const in, uint32_t* const out);
|
|
|
|
|
2014-02-11 02:37:07 +01:00
|
|
|
// Subtracts green from blue and red channels.
|
|
|
|
void VP8LSubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixs);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void VP8LResidualImage(int width, int height, int bits,
|
|
|
|
uint32_t* const argb, uint32_t* const argb_scratch,
|
|
|
|
uint32_t* const image);
|
|
|
|
|
|
|
|
void VP8LColorSpaceTransform(int width, int height, int bits, int step,
|
|
|
|
uint32_t* const argb, uint32_t* image);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Color space conversion.
|
|
|
|
|
|
|
|
// Converts from BGRA to other color spaces.
|
|
|
|
void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,
|
|
|
|
WEBP_CSP_MODE out_colorspace, uint8_t* const rgba);
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Misc methods.
|
|
|
|
|
|
|
|
// Computes sampled size of 'size' when sampling using 'sampling bits'.
|
|
|
|
static WEBP_INLINE uint32_t VP8LSubSampleSize(uint32_t size,
|
|
|
|
uint32_t sampling_bits) {
|
|
|
|
return (size + (1 << sampling_bits) - 1) >> sampling_bits;
|
|
|
|
}
|
|
|
|
|
2014-02-11 02:37:07 +01:00
|
|
|
// Faster logarithm for integers, with the property of log2(0) == 0.
|
|
|
|
float VP8LFastLog2(int v);
|
2014-02-10 02:10:30 +01:00
|
|
|
// Fast calculation of v * log2(v) for integer input.
|
2014-02-11 02:37:07 +01:00
|
|
|
static WEBP_INLINE float VP8LFastSLog2(int v) { return VP8LFastLog2(v) * v; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
// In-place difference of each component with mod 256.
|
|
|
|
static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
|
|
|
|
const uint32_t alpha_and_green =
|
|
|
|
0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u);
|
|
|
|
const uint32_t red_and_blue =
|
|
|
|
0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu);
|
|
|
|
return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2014-02-11 02:37:07 +01:00
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
2014-02-10 02:10:30 +01:00
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // WEBP_DSP_LOSSLESS_H_
|