#include <inttypes.h>
#include "avcodec.h"
-#include "get_bits.h"
+#include "bitstream.h"
#include "mathops.h"
#include "huffyuvdsp.h"
#include "lagarithrac.h"
} LagarithContext;
/**
- * Compute the 52bit mantissa of 1/(double)denom.
+ * Compute the 52-bit mantissa of 1/(double)denom.
* This crazy format uses floats in an entropy coder and we have to match x86
* rounding exactly, thus ordinary floats aren't portable enough.
* @param denom denominator
- * @return 52bit mantissa
+ * @return 52-bit mantissa
* @see softfloat_mul
*/
static uint64_t softfloat_reciprocal(uint32_t denom)
/**
* (uint32_t)(x*f), where f has the given mantissa, and exponent 0
* Used in combination with softfloat_reciprocal computes x/(double)denom.
- * @param x 32bit integer factor
+ * @param x 32-bit integer factor
* @param mantissa mantissa of f with exponent 0
- * @return 32bit integer value (x*f)
+ * @return 32-bit integer value (x*f)
* @see softfloat_reciprocal
*/
static uint32_t softfloat_mul(uint32_t x, uint64_t mantissa)
return (x << 1) ^ (x >> 7);
}
-static int lag_decode_prob(GetBitContext *gb, uint32_t *value)
+static int lag_decode_prob(BitstreamContext *bc, uint32_t *value)
{
static const uint8_t series[] = { 1, 2, 3, 5, 8, 13, 21 };
int i;
if (prevbit && bit)
break;
prevbit = bit;
- bit = get_bits1(gb);
+ bit = bitstream_read_bit(bc);
if (bit && !prevbit)
bits += series[i];
}
return 0;
}
- val = get_bits_long(gb, bits);
+ val = bitstream_read(bc, bits);
val |= 1 << bits;
*value = val - 1;
return 0;
}
-static int lag_read_prob_header(lag_rac *rac, GetBitContext *gb)
+static int lag_read_prob_header(lag_rac *rac, BitstreamContext *bc)
{
int i, j, scale_factor;
unsigned prob, cumulative_target;
rac->prob[257] = UINT_MAX;
/* Read probabilities from bitstream */
for (i = 1; i < 257; i++) {
- if (lag_decode_prob(gb, &rac->prob[i]) < 0) {
+ if (lag_decode_prob(bc, &rac->prob[i]) < 0) {
av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability encountered.\n");
return -1;
}
}
cumul_prob += rac->prob[i];
if (!rac->prob[i]) {
- if (lag_decode_prob(gb, &prob)) {
+ if (lag_decode_prob(bc, &prob)) {
av_log(rac->avctx, AV_LOG_ERROR, "Invalid probability run encountered.\n");
return -1;
}
int *left_top)
{
/* This is almost identical to add_hfyu_median_pred in huffyuvdsp.h.
- * However the &0xFF on the gradient predictor yealds incorrect output
+ * However the &0xFF on the gradient predictor yields incorrect output
* for lagarith.
*/
int i;
uint32_t length;
uint32_t offset = 1;
int esc_count = src[0];
- GetBitContext gb;
+ BitstreamContext bc;
lag_rac rac;
const uint8_t *src_end = src + src_size;
offset += 4;
}
- init_get_bits(&gb, src + offset, src_size * 8);
+ bitstream_init(&bc, src + offset, src_size * 8);
- if (lag_read_prob_header(&rac, &gb) < 0)
+ if (lag_read_prob_header(&rac, &bc) < 0)
return -1;
- ff_lag_rac_init(&rac, &gb, length - stride);
+ ff_lag_rac_init(&rac, &bc, length - stride);
for (i = 0; i < height; i++)
read += lag_decode_line(l, &rac, dst + (i * stride), width,