Commit 0f29a024 authored by Yaowu Xu's avatar Yaowu Xu

Move vp10-specific functions to vp10 from vpx_dsp

They are used by VP10 only, are now moved to vp10 and made static.

Change-Id: I4a4d4f1ceae1f7143240629bb94f8daf2733879d
parent 4b7043f8
......@@ -76,6 +76,19 @@ static int read_is_valid(const uint8_t *start, size_t len, const uint8_t *end) {
return len != 0 && len <= (size_t)(end - start);
}
static int read_inv_signed_literal(struct vpx_read_bit_buffer *rb,
int bits) {
#if CONFIG_MISC_FIXES
const int nbits = sizeof(unsigned) * 8 - bits - 1;
const unsigned value = vpx_rb_read_literal(rb, bits + 1) << nbits;
return ((int) value) >> nbits;
#else
return vpx_rb_read_signed_literal(rb, bits);
#endif
}
static int decode_unsigned_max(struct vpx_read_bit_buffer *rb, int max) {
const int data = vpx_rb_read_literal(rb, get_unsigned_bits(max));
return data > max ? max : data;
......@@ -1115,17 +1128,17 @@ static void setup_loopfilter(struct loopfilter *lf,
for (i = 0; i < MAX_REF_FRAMES; i++)
if (vpx_rb_read_bit(rb))
lf->ref_deltas[i] = vpx_rb_read_inv_signed_literal(rb, 6);
lf->ref_deltas[i] = read_inv_signed_literal(rb, 6);
for (i = 0; i < MAX_MODE_LF_DELTAS; i++)
if (vpx_rb_read_bit(rb))
lf->mode_deltas[i] = vpx_rb_read_inv_signed_literal(rb, 6);
lf->mode_deltas[i] = read_inv_signed_literal(rb, 6);
}
}
}
static INLINE int read_delta_q(struct vpx_read_bit_buffer *rb) {
return vpx_rb_read_bit(rb) ? vpx_rb_read_inv_signed_literal(rb, 4) : 0;
return vpx_rb_read_bit(rb) ? read_inv_signed_literal(rb, 4) : 0;
}
static void setup_quantization(VP10_COMMON *const cm, MACROBLOCKD *const xd,
......
......@@ -67,6 +67,18 @@ static void write_inter_mode(vpx_writer *w, PREDICTION_MODE mode,
&inter_mode_encodings[INTER_OFFSET(mode)]);
}
static void write_inv_signed_literal(struct vpx_write_bit_buffer *wb,
int data, int bits) {
#if CONFIG_MISC_FIXES
vpx_wb_write_literal(wb, data, bits + 1);
#else
vpx_wb_write_literal(wb, abs(data), bits);
vpx_wb_write_bit(wb, data < 0);
#endif
}
static void encode_unsigned_max(struct vpx_write_bit_buffer *wb,
int data, int max) {
vpx_wb_write_literal(wb, data, get_unsigned_bits(max));
......@@ -776,7 +788,7 @@ static void encode_loopfilter(struct loopfilter *lf,
vpx_wb_write_bit(wb, changed);
if (changed) {
lf->last_ref_deltas[i] = delta;
vpx_wb_write_inv_signed_literal(wb, delta, 6);
write_inv_signed_literal(wb, delta, 6);
}
}
......@@ -786,7 +798,7 @@ static void encode_loopfilter(struct loopfilter *lf,
vpx_wb_write_bit(wb, changed);
if (changed) {
lf->last_mode_deltas[i] = delta;
vpx_wb_write_inv_signed_literal(wb, delta, 6);
write_inv_signed_literal(wb, delta, 6);
}
}
}
......@@ -796,7 +808,7 @@ static void encode_loopfilter(struct loopfilter *lf,
static void write_delta_q(struct vpx_write_bit_buffer *wb, int delta_q) {
if (delta_q != 0) {
vpx_wb_write_bit(wb, 1);
vpx_wb_write_inv_signed_literal(wb, delta_q, 4);
write_inv_signed_literal(wb, delta_q, 4);
} else {
vpx_wb_write_bit(wb, 0);
}
......
......@@ -40,14 +40,3 @@ int vpx_rb_read_signed_literal(struct vpx_read_bit_buffer *rb,
const int value = vpx_rb_read_literal(rb, bits);
return vpx_rb_read_bit(rb) ? -value : value;
}
int vpx_rb_read_inv_signed_literal(struct vpx_read_bit_buffer *rb,
int bits) {
#if CONFIG_MISC_FIXES
const int nbits = sizeof(unsigned) * 8 - bits - 1;
const unsigned value = vpx_rb_read_literal(rb, bits + 1) << nbits;
return ((int) value) >> nbits;
#else
return vpx_rb_read_signed_literal(rb, bits);
#endif
}
......@@ -38,8 +38,6 @@ int vpx_rb_read_literal(struct vpx_read_bit_buffer *rb, int bits);
int vpx_rb_read_signed_literal(struct vpx_read_bit_buffer *rb, int bits);
int vpx_rb_read_inv_signed_literal(struct vpx_read_bit_buffer *rb, int bits);
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -36,13 +36,3 @@ void vpx_wb_write_literal(struct vpx_write_bit_buffer *wb, int data, int bits) {
for (bit = bits - 1; bit >= 0; bit--)
vpx_wb_write_bit(wb, (data >> bit) & 1);
}
void vpx_wb_write_inv_signed_literal(struct vpx_write_bit_buffer *wb,
int data, int bits) {
#if CONFIG_MISC_FIXES
vpx_wb_write_literal(wb, data, bits + 1);
#else
vpx_wb_write_literal(wb, abs(data), bits);
vpx_wb_write_bit(wb, data < 0);
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment