mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 22:28:22 +01:00
Code cleanup
* match param names Change-Id: Ib75197a3c6bcc735049c6724dce6c240684108ae
This commit is contained in:
parent
8f0d41aac0
commit
06c1e72e71
@ -1171,13 +1171,15 @@ static void RemoveEmptyHistograms(VP8LHistogramSet* const image_histo) {
|
|||||||
int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
||||||
const VP8LBackwardRefs* const refs,
|
const VP8LBackwardRefs* const refs,
|
||||||
int quality, int low_effort,
|
int quality, int low_effort,
|
||||||
int histo_bits, int cache_bits,
|
int histogram_bits, int cache_bits,
|
||||||
VP8LHistogramSet* const image_histo,
|
VP8LHistogramSet* const image_histo,
|
||||||
VP8LHistogram* const tmp_histo,
|
VP8LHistogram* const tmp_histo,
|
||||||
uint16_t* const histogram_symbols) {
|
uint16_t* const histogram_symbols) {
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
const int histo_xsize = histo_bits ? VP8LSubSampleSize(xsize, histo_bits) : 1;
|
const int histo_xsize =
|
||||||
const int histo_ysize = histo_bits ? VP8LSubSampleSize(ysize, histo_bits) : 1;
|
histogram_bits ? VP8LSubSampleSize(xsize, histogram_bits) : 1;
|
||||||
|
const int histo_ysize =
|
||||||
|
histogram_bits ? VP8LSubSampleSize(ysize, histogram_bits) : 1;
|
||||||
const int image_histo_raw_size = histo_xsize * histo_ysize;
|
const int image_histo_raw_size = histo_xsize * histo_ysize;
|
||||||
VP8LHistogramSet* const orig_histo =
|
VP8LHistogramSet* const orig_histo =
|
||||||
VP8LAllocateHistogramSet(image_histo_raw_size, cache_bits);
|
VP8LAllocateHistogramSet(image_histo_raw_size, cache_bits);
|
||||||
@ -1193,7 +1195,7 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
|||||||
if (orig_histo == NULL || map_tmp == NULL) goto Error;
|
if (orig_histo == NULL || map_tmp == NULL) goto Error;
|
||||||
|
|
||||||
// Construct the histograms from backward references.
|
// Construct the histograms from backward references.
|
||||||
HistogramBuild(xsize, histo_bits, refs, orig_histo);
|
HistogramBuild(xsize, histogram_bits, refs, orig_histo);
|
||||||
// Copies the histograms and computes its bit_cost.
|
// Copies the histograms and computes its bit_cost.
|
||||||
// histogram_symbols is optimized
|
// histogram_symbols is optimized
|
||||||
HistogramCopyAndAnalyze(orig_histo, image_histo, &num_used,
|
HistogramCopyAndAnalyze(orig_histo, image_histo, &num_used,
|
||||||
|
@ -64,8 +64,8 @@ void VP8LHistogramCreate(VP8LHistogram* const p,
|
|||||||
const VP8LBackwardRefs* const refs,
|
const VP8LBackwardRefs* const refs,
|
||||||
int palette_code_bits);
|
int palette_code_bits);
|
||||||
|
|
||||||
// Return the size of the histogram for a given palette_code_bits.
|
// Return the size of the histogram for a given cache_bits.
|
||||||
int VP8LGetHistogramSize(int palette_code_bits);
|
int VP8LGetHistogramSize(int cache_bits);
|
||||||
|
|
||||||
// Set the palette_code_bits and reset the stats.
|
// Set the palette_code_bits and reset the stats.
|
||||||
// If init_arrays is true, the arrays are also filled with 0's.
|
// If init_arrays is true, the arrays are also filled with 0's.
|
||||||
@ -110,7 +110,7 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
|||||||
const VP8LBackwardRefs* const refs,
|
const VP8LBackwardRefs* const refs,
|
||||||
int quality, int low_effort,
|
int quality, int low_effort,
|
||||||
int histogram_bits, int cache_bits,
|
int histogram_bits, int cache_bits,
|
||||||
VP8LHistogramSet* const image_in,
|
VP8LHistogramSet* const image_histo,
|
||||||
VP8LHistogram* const tmp_histo,
|
VP8LHistogram* const tmp_histo,
|
||||||
uint16_t* const histogram_symbols);
|
uint16_t* const histogram_symbols);
|
||||||
|
|
||||||
|
@ -286,8 +286,7 @@ int VP8IteratorNext(VP8EncIterator* const it);
|
|||||||
// save the yuv_out_ boundary values to top_/left_ arrays for next iterations.
|
// save the yuv_out_ boundary values to top_/left_ arrays for next iterations.
|
||||||
void VP8IteratorSaveBoundary(VP8EncIterator* const it);
|
void VP8IteratorSaveBoundary(VP8EncIterator* const it);
|
||||||
// Report progression based on macroblock rows. Return 0 for user-abort request.
|
// Report progression based on macroblock rows. Return 0 for user-abort request.
|
||||||
int VP8IteratorProgress(const VP8EncIterator* const it,
|
int VP8IteratorProgress(const VP8EncIterator* const it, int delta);
|
||||||
int final_delta_percent);
|
|
||||||
// Intra4x4 iterations
|
// Intra4x4 iterations
|
||||||
void VP8IteratorStartI4(VP8EncIterator* const it);
|
void VP8IteratorStartI4(VP8EncIterator* const it);
|
||||||
// returns true if not done.
|
// returns true if not done.
|
||||||
|
@ -20,22 +20,22 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// VP8LColorCache.
|
// VP8LColorCache.
|
||||||
|
|
||||||
int VP8LColorCacheInit(VP8LColorCache* const cc, int hash_bits) {
|
int VP8LColorCacheInit(VP8LColorCache* const color_cache, int hash_bits) {
|
||||||
const int hash_size = 1 << hash_bits;
|
const int hash_size = 1 << hash_bits;
|
||||||
assert(cc != NULL);
|
assert(color_cache != NULL);
|
||||||
assert(hash_bits > 0);
|
assert(hash_bits > 0);
|
||||||
cc->colors_ = (uint32_t*)WebPSafeCalloc((uint64_t)hash_size,
|
color_cache->colors_ = (uint32_t*)WebPSafeCalloc(
|
||||||
sizeof(*cc->colors_));
|
(uint64_t)hash_size, sizeof(*color_cache->colors_));
|
||||||
if (cc->colors_ == NULL) return 0;
|
if (color_cache->colors_ == NULL) return 0;
|
||||||
cc->hash_shift_ = 32 - hash_bits;
|
color_cache->hash_shift_ = 32 - hash_bits;
|
||||||
cc->hash_bits_ = hash_bits;
|
color_cache->hash_bits_ = hash_bits;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VP8LColorCacheClear(VP8LColorCache* const cc) {
|
void VP8LColorCacheClear(VP8LColorCache* const color_cache) {
|
||||||
if (cc != NULL) {
|
if (color_cache != NULL) {
|
||||||
WebPSafeFree(cc->colors_);
|
WebPSafeFree(color_cache->colors_);
|
||||||
cc->colors_ = NULL;
|
color_cache->colors_ = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,8 +404,7 @@ static void ConvertBitDepthsToSymbols(HuffmanTreeCode* const tree) {
|
|||||||
// Main entry point
|
// Main entry point
|
||||||
|
|
||||||
void VP8LCreateHuffmanTree(uint32_t* const histogram, int tree_depth_limit,
|
void VP8LCreateHuffmanTree(uint32_t* const histogram, int tree_depth_limit,
|
||||||
uint8_t* const buf_rle,
|
uint8_t* const buf_rle, HuffmanTree* const huff_tree,
|
||||||
HuffmanTree* const huff_tree,
|
|
||||||
HuffmanTreeCode* const huff_code) {
|
HuffmanTreeCode* const huff_code) {
|
||||||
const int num_symbols = huff_code->num_symbols;
|
const int num_symbols = huff_code->num_symbols;
|
||||||
memset(buf_rle, 0, num_symbols * sizeof(*buf_rle));
|
memset(buf_rle, 0, num_symbols * sizeof(*buf_rle));
|
||||||
|
@ -51,7 +51,7 @@ int VP8LCreateCompressedHuffmanTree(const HuffmanTreeCode* const tree,
|
|||||||
// huffman code tree.
|
// huffman code tree.
|
||||||
void VP8LCreateHuffmanTree(uint32_t* const histogram, int tree_depth_limit,
|
void VP8LCreateHuffmanTree(uint32_t* const histogram, int tree_depth_limit,
|
||||||
uint8_t* const buf_rle, HuffmanTree* const huff_tree,
|
uint8_t* const buf_rle, HuffmanTree* const huff_tree,
|
||||||
HuffmanTreeCode* const tree);
|
HuffmanTreeCode* const huff_code);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -107,31 +107,34 @@ int WebPRescalerGetScaledDimensions(int src_width, int src_height,
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// all-in-one calls
|
// all-in-one calls
|
||||||
|
|
||||||
int WebPRescaleNeededLines(const WebPRescaler* const wrk, int max_num_lines) {
|
int WebPRescaleNeededLines(const WebPRescaler* const rescaler,
|
||||||
const int num_lines = (wrk->y_accum + wrk->y_sub - 1) / wrk->y_sub;
|
int max_num_lines) {
|
||||||
|
const int num_lines =
|
||||||
|
(rescaler->y_accum + rescaler->y_sub - 1) / rescaler->y_sub;
|
||||||
return (num_lines > max_num_lines) ? max_num_lines : num_lines;
|
return (num_lines > max_num_lines) ? max_num_lines : num_lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WebPRescalerImport(WebPRescaler* const wrk, int num_lines,
|
int WebPRescalerImport(WebPRescaler* const rescaler, int num_lines,
|
||||||
const uint8_t* src, int src_stride) {
|
const uint8_t* src, int src_stride) {
|
||||||
int total_imported = 0;
|
int total_imported = 0;
|
||||||
while (total_imported < num_lines && !WebPRescalerHasPendingOutput(wrk)) {
|
while (total_imported < num_lines &&
|
||||||
if (wrk->y_expand) {
|
!WebPRescalerHasPendingOutput(rescaler)) {
|
||||||
rescaler_t* const tmp = wrk->irow;
|
if (rescaler->y_expand) {
|
||||||
wrk->irow = wrk->frow;
|
rescaler_t* const tmp = rescaler->irow;
|
||||||
wrk->frow = tmp;
|
rescaler->irow = rescaler->frow;
|
||||||
|
rescaler->frow = tmp;
|
||||||
}
|
}
|
||||||
WebPRescalerImportRow(wrk, src);
|
WebPRescalerImportRow(rescaler, src);
|
||||||
if (!wrk->y_expand) { // Accumulate the contribution of the new row.
|
if (!rescaler->y_expand) { // Accumulate the contribution of the new row.
|
||||||
int x;
|
int x;
|
||||||
for (x = 0; x < wrk->num_channels * wrk->dst_width; ++x) {
|
for (x = 0; x < rescaler->num_channels * rescaler->dst_width; ++x) {
|
||||||
wrk->irow[x] += wrk->frow[x];
|
rescaler->irow[x] += rescaler->frow[x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++wrk->src_y;
|
++rescaler->src_y;
|
||||||
src += src_stride;
|
src += src_stride;
|
||||||
++total_imported;
|
++total_imported;
|
||||||
wrk->y_accum -= wrk->y_sub;
|
rescaler->y_accum -= rescaler->y_sub;
|
||||||
}
|
}
|
||||||
return total_imported;
|
return total_imported;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user