mirror of
https://github.com/webmproject/libwebp.git
synced 2025-08-31 08:12:09 +02:00
apply clang-format
(Debian clang-format version 19.1.7 (3+build4)) with `--style=Google`. Manual changes: * clang-format disabled around macros with stringification (mostly assembly) * some inline assembly strings were adjusted to avoid awkward line breaks * trailing commas, `//` or suffixes (`ull`) added to help array formatting * thread_utils.c: parameter comments were changed to the more common /*...=*/ style to improve formatting The automatically generated code under swig/ was skipped. Bug: 433996651 Change-Id: Iea3f24160d78d2a2653971cdf13fa932e47ff1b3
This commit is contained in:
@@ -12,14 +12,15 @@
|
||||
// Author: Skal (pascal.massimino@gmail.com)
|
||||
// Vikas Arora (vikaas.arora@gmail.com)
|
||||
|
||||
#include "src/utils/bit_writer_utils.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> // for memcpy()
|
||||
#include <string.h> // for memcpy()
|
||||
|
||||
#include "src/utils/bit_writer_utils.h"
|
||||
#include "src/webp/types.h"
|
||||
#include "src/utils/endian_inl_utils.h"
|
||||
#include "src/utils/utils.h"
|
||||
#include "src/webp/types.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VP8BitWriter
|
||||
@@ -74,7 +75,7 @@ static void Flush(VP8BitWriter* const bw) {
|
||||
bw->buf[pos++] = bits & 0xff;
|
||||
bw->pos = pos;
|
||||
} else {
|
||||
bw->run++; // delay writing of bytes 0xff, pending eventual carry.
|
||||
bw->run++; // delay writing of bytes 0xff, pending eventual carry.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,29 +83,24 @@ static void Flush(VP8BitWriter* const bw) {
|
||||
// renormalization
|
||||
|
||||
static const uint8_t kNorm[128] = { // renorm_sizes[i] = 8 - log2(i)
|
||||
7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0
|
||||
};
|
||||
7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
|
||||
|
||||
// range = ((range + 1) << kVP8Log2Range[range]) - 1
|
||||
static const uint8_t kNewRange[128] = {
|
||||
127, 127, 191, 127, 159, 191, 223, 127, 143, 159, 175, 191, 207, 223, 239,
|
||||
127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 231, 239,
|
||||
247, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179,
|
||||
183, 187, 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239,
|
||||
243, 247, 251, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149,
|
||||
151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179,
|
||||
181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209,
|
||||
211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
|
||||
241, 243, 245, 247, 249, 251, 253, 127
|
||||
};
|
||||
127, 127, 191, 127, 159, 191, 223, 127, 143, 159, 175, 191, 207, 223, 239,
|
||||
127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 231, 239,
|
||||
247, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179,
|
||||
183, 187, 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239,
|
||||
243, 247, 251, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149,
|
||||
151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179,
|
||||
181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209,
|
||||
211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
|
||||
241, 243, 245, 247, 249, 251, 253, 127};
|
||||
|
||||
int VP8PutBit(VP8BitWriter* const bw, int bit, int prob) {
|
||||
const int split = (bw->range * prob) >> 8;
|
||||
@@ -114,7 +110,7 @@ int VP8PutBit(VP8BitWriter* const bw, int bit, int prob) {
|
||||
} else {
|
||||
bw->range = split;
|
||||
}
|
||||
if (bw->range < 127) { // emit 'shift' bits out and renormalize
|
||||
if (bw->range < 127) { // emit 'shift' bits out and renormalize
|
||||
const int shift = kNorm[bw->range];
|
||||
bw->range = kNewRange[bw->range];
|
||||
bw->value <<= shift;
|
||||
@@ -161,28 +157,28 @@ void VP8PutSignedBits(VP8BitWriter* const bw, int value, int nb_bits) {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int VP8BitWriterInit(VP8BitWriter* const bw, size_t expected_size) {
|
||||
bw->range = 255 - 1;
|
||||
bw->value = 0;
|
||||
bw->run = 0;
|
||||
bw->range = 255 - 1;
|
||||
bw->value = 0;
|
||||
bw->run = 0;
|
||||
bw->nb_bits = -8;
|
||||
bw->pos = 0;
|
||||
bw->pos = 0;
|
||||
bw->max_pos = 0;
|
||||
bw->error = 0;
|
||||
bw->buf = NULL;
|
||||
bw->error = 0;
|
||||
bw->buf = NULL;
|
||||
return (expected_size > 0) ? BitWriterResize(bw, expected_size) : 1;
|
||||
}
|
||||
|
||||
uint8_t* VP8BitWriterFinish(VP8BitWriter* const bw) {
|
||||
VP8PutBits(bw, 0, 9 - bw->nb_bits);
|
||||
bw->nb_bits = 0; // pad with zeroes
|
||||
bw->nb_bits = 0; // pad with zeroes
|
||||
Flush(bw);
|
||||
return bw->buf;
|
||||
}
|
||||
|
||||
int VP8BitWriterAppend(VP8BitWriter* const bw,
|
||||
const uint8_t* data, size_t size) {
|
||||
int VP8BitWriterAppend(VP8BitWriter* const bw, const uint8_t* data,
|
||||
size_t size) {
|
||||
assert(data != NULL);
|
||||
if (bw->nb_bits != -8) return 0; // Flush() must have been called
|
||||
if (bw->nb_bits != -8) return 0; // Flush() must have been called
|
||||
if (!BitWriterResize(bw, size)) return 0;
|
||||
memcpy(bw->buf + bw->pos, data, size);
|
||||
bw->pos += size;
|
||||
@@ -201,7 +197,7 @@ void VP8BitWriterWipeOut(VP8BitWriter* const bw) {
|
||||
|
||||
// This is the minimum amount of size the memory buffer is guaranteed to grow
|
||||
// when extra space is needed.
|
||||
#define MIN_EXTRA_SIZE (32768ULL)
|
||||
#define MIN_EXTRA_SIZE (32768ULL)
|
||||
|
||||
// Returns 1 on success.
|
||||
static int VP8LBitWriterResize(VP8LBitWriter* const bw, size_t extra_size) {
|
||||
|
Reference in New Issue
Block a user