This commit is contained in:
Anthony Minessale
2019-09-11 15:51:47 +00:00
committed by Andrey Volk
parent 34fcadbd53
commit ceb051af4e
821 changed files with 89961 additions and 48650 deletions

View File

@@ -9,14 +9,14 @@
*/
/****************************************************************************
*
* Module Title : boolhuff.h
*
* Description : Bool Coder header file.
*
****************************************************************************/
#ifndef VP8_ENCODER_BOOLHUFF_H_
#define VP8_ENCODER_BOOLHUFF_H_
*
* Module Title : boolhuff.h
*
* Description : Bool Coder header file.
*
****************************************************************************/
#ifndef VPX_VP8_ENCODER_BOOLHUFF_H_
#define VPX_VP8_ENCODER_BOOLHUFF_H_
#include "vpx_ports/mem.h"
#include "vpx/internal/vpx_codec_internal.h"
@@ -35,11 +35,11 @@ typedef struct {
struct vpx_internal_error_info *error;
} BOOL_CODER;
extern void vp8_start_encode(BOOL_CODER *bc, unsigned char *buffer,
unsigned char *buffer_end);
void vp8_start_encode(BOOL_CODER *bc, unsigned char *source,
unsigned char *source_end);
extern void vp8_encode_value(BOOL_CODER *br, int data, int bits);
extern void vp8_stop_encode(BOOL_CODER *bc);
void vp8_encode_value(BOOL_CODER *bc, int data, int bits);
void vp8_stop_encode(BOOL_CODER *bc);
extern const unsigned int vp8_prob_cost[256];
DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
@@ -56,23 +56,12 @@ static int validate_buffer(const unsigned char *start, size_t len,
return 0;
}
static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability) {
static void vp8_encode_bool(BOOL_CODER *bc, int bit, int probability) {
unsigned int split;
int count = br->count;
unsigned int range = br->range;
unsigned int lowvalue = br->lowvalue;
register int shift;
#ifdef VP8_ENTROPY_STATS
#if defined(SECTIONBITS_OUTPUT)
if (bit)
Sectionbits[active_section] += vp8_prob_cost[255 - probability];
else
Sectionbits[active_section] += vp8_prob_cost[probability];
#endif
#endif
int count = bc->count;
unsigned int range = bc->range;
unsigned int lowvalue = bc->lowvalue;
int shift;
split = 1 + (((range - 1) * probability) >> 8);
@@ -80,7 +69,7 @@ static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability) {
if (bit) {
lowvalue += split;
range = br->range - split;
range = bc->range - split;
}
shift = vp8_norm[range];
@@ -92,18 +81,18 @@ static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability) {
int offset = shift - count;
if ((lowvalue << (offset - 1)) & 0x80000000) {
int x = br->pos - 1;
int x = bc->pos - 1;
while (x >= 0 && br->buffer[x] == 0xff) {
br->buffer[x] = (unsigned char)0;
while (x >= 0 && bc->buffer[x] == 0xff) {
bc->buffer[x] = (unsigned char)0;
x--;
}
br->buffer[x] += 1;
bc->buffer[x] += 1;
}
validate_buffer(br->buffer + br->pos, 1, br->buffer_end, br->error);
br->buffer[br->pos++] = (lowvalue >> (24 - offset));
validate_buffer(bc->buffer + bc->pos, 1, bc->buffer_end, bc->error);
bc->buffer[bc->pos++] = (lowvalue >> (24 - offset));
lowvalue <<= offset;
shift = count;
@@ -112,13 +101,13 @@ static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability) {
}
lowvalue <<= shift;
br->count = count;
br->lowvalue = lowvalue;
br->range = range;
bc->count = count;
bc->lowvalue = lowvalue;
bc->range = range;
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP8_ENCODER_BOOLHUFF_H_
#endif // VPX_VP8_ENCODER_BOOLHUFF_H_