for (i = 0; i < MAX_REF_FRAMES; i++)
if (vpx_rb_read_bit(rb))
- lf->ref_deltas[i] = vpx_rb_read_signed_literal(rb, 6);
+ lf->ref_deltas[i] = vpx_rb_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_signed_literal(rb, 6);
+ lf->mode_deltas[i] = vpx_rb_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_signed_literal(rb, 4) : 0;
+ return vpx_rb_read_bit(rb) ? vpx_rb_read_inv_signed_literal(rb, 4) : 0;
}
static void setup_quantization(VP10_COMMON *const cm, MACROBLOCKD *const xd,
vpx_wb_write_bit(wb, changed);
if (changed) {
lf->last_ref_deltas[i] = delta;
- vpx_wb_write_literal(wb, abs(delta) & 0x3F, 6);
- vpx_wb_write_bit(wb, delta < 0);
+ vpx_wb_write_inv_signed_literal(wb, delta, 6);
}
}
vpx_wb_write_bit(wb, changed);
if (changed) {
lf->last_mode_deltas[i] = delta;
- vpx_wb_write_literal(wb, abs(delta) & 0x3F, 6);
- vpx_wb_write_bit(wb, delta < 0);
+ vpx_wb_write_inv_signed_literal(wb, delta, 6);
}
}
}
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_literal(wb, abs(delta_q), 4);
- vpx_wb_write_bit(wb, delta_q < 0);
+ vpx_wb_write_inv_signed_literal(wb, delta_q, 4);
} else {
vpx_wb_write_bit(wb, 0);
}
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "./vpx_config.h"
#include "./bitreader_buffer.h"
size_t vpx_rb_bytes_read(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
+}
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
*/
#include <limits.h>
+#include <stdlib.h>
+#include "./vpx_config.h"
#include "./bitwriter_buffer.h"
size_t vpx_wb_bytes_written(const struct vpx_write_bit_buffer *wb) {
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
+}
void vpx_wb_write_literal(struct vpx_write_bit_buffer *wb, int data, int bits);
+void vpx_wb_write_inv_signed_literal(struct vpx_write_bit_buffer *wb, int data,
+ int bits);
#ifdef __cplusplus
} // extern "C"