mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
create a separate libwebpdsp under src/dsp
Gathers all DSP-related function (and SSE2 implementations). Clean-up some unwanted symbolic dependencies so that webp_encode, webp_decode and webp_dsp are truly independent libraries. + opportunistic clean-up: * remove unneeded VP8DspInitTables(), now integrated in VP8DspInit() * make consistent use of VP8GetCPUInfo() in the various DspInit() funcs * change OUT macro to DST
This commit is contained in:
committed by
James Zern
parent
ebeb412aa5
commit
e06ac0887f
@ -1,9 +1,10 @@
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
libwebpencode_la_SOURCES = analysis.c bit_writer.c bit_writer.h \
|
||||
config.c cost.c cost.h dsp.c dsp_sse2.c filter.c \
|
||||
frame.c iterator.c picture.c quant.c \
|
||||
syntax.c tree.c vp8enci.h webpenc.c alpha.c layer.c
|
||||
config.c cost.c cost.h filter.c \
|
||||
frame.c iterator.c picture.c quant.c \
|
||||
syntax.c tree.c vp8enci.h webpenc.c alpha.c \
|
||||
layer.c
|
||||
libwebpencode_la_LDFLAGS = -version-info 0:0:0 -lm
|
||||
libwebpencode_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE)
|
||||
libwebpencodeinclude_HEADERS = ../webp/encode.h ../webp/types.h
|
||||
@ -11,6 +12,3 @@ libwebpencodeincludedir = $(includedir)/webp
|
||||
|
||||
noinst_HEADERS = cost.h bit_writer.h vp8enci.h
|
||||
noinst_LTLIBRARIES = libwebpencode.la
|
||||
# uncomment the following line (and comment the above) if you want
|
||||
# to install libwebpencode library.
|
||||
#lib_LTLIBRARIES = libwebpencode.la
|
||||
|
@ -39,7 +39,7 @@ static inline int clip(int v, int m, int M) {
|
||||
return v < m ? m : v > M ? M : v;
|
||||
}
|
||||
|
||||
const uint8_t VP8Zigzag[16] = {
|
||||
static const uint8_t kZigzag[16] = {
|
||||
0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
|
||||
};
|
||||
|
||||
@ -143,7 +143,7 @@ static int ExpandMatrix(VP8Matrix* const m, int type) {
|
||||
m->q_[i] = m->q_[1];
|
||||
}
|
||||
for (i = 0; i < 16; ++i) {
|
||||
const int j = VP8Zigzag[i];
|
||||
const int j = kZigzag[i];
|
||||
const int bias = kBiasMatrices[type][j];
|
||||
m->iq_[j] = (1 << QFIX) / m->q_[j];
|
||||
m->bias_[j] = BIAS(bias);
|
||||
@ -440,7 +440,7 @@ static int TrellisQuantizeBlock(const VP8EncIterator* const it,
|
||||
// compute maximal distortion.
|
||||
max_error = 0;
|
||||
for (n = first; n < 16; ++n) {
|
||||
const int j = VP8Zigzag[n];
|
||||
const int j = kZigzag[n];
|
||||
const int err = in[j] * in[j];
|
||||
max_error += kWeightTrellis[j] * err;
|
||||
if (err > thresh) last = n;
|
||||
@ -464,7 +464,7 @@ static int TrellisQuantizeBlock(const VP8EncIterator* const it,
|
||||
|
||||
// traverse trellis.
|
||||
for (n = first; n <= last; ++n) {
|
||||
const int j = VP8Zigzag[n];
|
||||
const int j = kZigzag[n];
|
||||
const int Q = mtx->q_[j];
|
||||
const int iQ = mtx->iq_[j];
|
||||
const int B = BIAS(0x00); // neutral bias
|
||||
@ -560,7 +560,7 @@ static int TrellisQuantizeBlock(const VP8EncIterator* const it,
|
||||
|
||||
for (; n >= first; --n) {
|
||||
const Node* const node = &NODE(n, best_node);
|
||||
const int j = VP8Zigzag[n];
|
||||
const int j = kZigzag[n];
|
||||
out[n] = node->sign ? -node->level : node->level;
|
||||
nz |= (node->level != 0);
|
||||
in[j] = out[n] * mtx->q_[j];
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "string.h" // for memcpy()
|
||||
#include "../webp/encode.h"
|
||||
#include "../dsp/dsp.h"
|
||||
#include "bit_writer.h"
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
@ -211,7 +212,7 @@ typedef struct {
|
||||
uint8_t alpha_; // quantization-susceptibility
|
||||
} VP8MBInfo;
|
||||
|
||||
typedef struct {
|
||||
typedef struct VP8Matrix {
|
||||
uint16_t q_[16]; // quantizer steps
|
||||
uint16_t iq_[16]; // reciprocals, fixed point.
|
||||
uint16_t bias_[16]; // rounding bias
|
||||
@ -421,12 +422,8 @@ int VP8StatLoop(VP8Encoder* const enc);
|
||||
// in webpenc.c
|
||||
// Assign an error code to a picture. Return false for convenience.
|
||||
int WebPEncodingSetError(WebPPicture* const pic, WebPEncodingError error);
|
||||
|
||||
// in analysis.c
|
||||
// Compute susceptibility based on DCT-coeff histograms:
|
||||
// the higher, the "easier" the macroblock is to compress.
|
||||
typedef int (*VP8CHisto)(const uint8_t* ref, const uint8_t* pred,
|
||||
int start_block, int end_block);
|
||||
extern VP8CHisto VP8CollectHistogram;
|
||||
// Main analysis loop. Decides the segmentations and complexity.
|
||||
// Assigns a first guess for Intra16 and uvmode_ prediction modes.
|
||||
int VP8EncAnalyze(VP8Encoder* const enc);
|
||||
@ -449,54 +446,6 @@ void VP8EncCodeLayerBlock(VP8EncIterator* it); // code one more macroblock
|
||||
int VP8EncFinishLayer(VP8Encoder* const enc); // finalize coding
|
||||
void VP8EncDeleteLayer(VP8Encoder* enc); // reclaim memory
|
||||
|
||||
// in dsp.c
|
||||
int VP8GetAlpha(const int histo[MAX_COEFF_THRESH + 1]);
|
||||
|
||||
// Transforms
|
||||
// VP8Idct: Does one of two inverse transforms. If do_two is set, the transforms
|
||||
// will be done for (ref, in, dst) and (ref + 4, in + 16, dst + 4).
|
||||
typedef void (*VP8Idct)(const uint8_t* ref, const int16_t* in, uint8_t* dst,
|
||||
int do_two);
|
||||
typedef void (*VP8Fdct)(const uint8_t* src, const uint8_t* ref, int16_t* out);
|
||||
typedef void (*VP8WHT)(const int16_t* in, int16_t* out);
|
||||
extern VP8Idct VP8ITransform;
|
||||
extern VP8Fdct VP8FTransform;
|
||||
extern VP8WHT VP8ITransformWHT;
|
||||
extern VP8WHT VP8FTransformWHT;
|
||||
// Predictions
|
||||
// *dst is the destination block. *top, *top_right and *left can be NULL.
|
||||
typedef void (*VP8IntraPreds)(uint8_t *dst, const uint8_t* left,
|
||||
const uint8_t* top);
|
||||
typedef void (*VP8Intra4Preds)(uint8_t *dst, const uint8_t* top);
|
||||
extern VP8Intra4Preds VP8EncPredLuma4;
|
||||
extern VP8IntraPreds VP8EncPredLuma16;
|
||||
extern VP8IntraPreds VP8EncPredChroma8;
|
||||
|
||||
typedef int (*VP8Metric)(const uint8_t* pix, const uint8_t* ref);
|
||||
extern VP8Metric VP8SSE16x16, VP8SSE16x8, VP8SSE8x8, VP8SSE4x4;
|
||||
typedef int (*VP8WMetric)(const uint8_t* pix, const uint8_t* ref,
|
||||
const uint16_t* const weights);
|
||||
extern VP8WMetric VP8TDisto4x4, VP8TDisto16x16;
|
||||
|
||||
typedef void (*VP8BlockCopy)(const uint8_t* src, uint8_t* dst);
|
||||
extern VP8BlockCopy VP8Copy4x4;
|
||||
extern VP8BlockCopy VP8Copy8x8;
|
||||
extern VP8BlockCopy VP8Copy16x16;
|
||||
// Quantization
|
||||
typedef int (*VP8QuantizeBlock)(int16_t in[16], int16_t out[16],
|
||||
int n, const VP8Matrix* const mtx);
|
||||
extern VP8QuantizeBlock VP8EncQuantizeBlock;
|
||||
|
||||
typedef enum {
|
||||
kSSE2,
|
||||
kSSE3
|
||||
} CPUFeature;
|
||||
// returns true if the CPU supports the feature.
|
||||
typedef int (*VP8CPUInfo)(CPUFeature feature);
|
||||
extern VP8CPUInfo VP8EncGetCPUInfo;
|
||||
|
||||
void VP8EncDspInit(void); // must be called before using any of the above
|
||||
|
||||
// in filter.c
|
||||
extern void VP8InitFilter(VP8EncIterator* const it);
|
||||
extern void VP8StoreFilterStats(VP8EncIterator* const it);
|
||||
|
Reference in New Issue
Block a user