ref: 1fcef81cb013299019970ccf0ab37fc04a430014
parent: c5ad31e518ceaffebb055e6a186bcece8c6ced96
author: Yaowu Xu <[email protected]>
date: Mon Jul 20 07:18:57 EDT 2015
Remove vp9_ prefix from bit writer files Change-Id: I07647c7482b9ec498fbad3a9c9901f72b2336500
--- a/test/vp9_boolcoder_test.cc
+++ b/test/vp9_boolcoder_test.cc
@@ -16,7 +16,7 @@
#include "vpx/vpx_integer.h"
#include "vpx_dsp/bitreader.h"
-#include "vpx_dsp/vp9_writer.h"
+#include "vpx_dsp/bitwriter.h"
#include "test/acm_random.h"
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -13,7 +13,7 @@
#include <limits.h>
#include "vpx/vpx_encoder.h"
-#include "vpx_dsp/vp9_write_bit_buffer.h"
+#include "vpx_dsp/bitwriter_buffer.h"
#include "vpx_mem/vpx_mem.h"
#include "vpx_ports/mem_ops.h"
--- a/vp9/encoder/vp9_subexp.c
+++ b/vp9/encoder/vp9_subexp.c
@@ -7,7 +7,7 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "vpx_dsp/vp9_writer.h"
+#include "vpx_dsp/bitwriter.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_entropy.h"
--- a/vp9/encoder/vp9_treewriter.h
+++ b/vp9/encoder/vp9_treewriter.h
@@ -11,7 +11,7 @@
#ifndef VP9_ENCODER_VP9_TREEWRITER_H_
#define VP9_ENCODER_VP9_TREEWRITER_H_
-#include "vpx_dsp/vp9_writer.h"
+#include "vpx_dsp/bitwriter.h"
#ifdef __cplusplus
extern "C" {
--- /dev/null
+++ b/vpx_dsp/bitwriter.c
@@ -1,0 +1,34 @@
+/*
+ * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <assert.h>
+
+#include "./bitwriter.h"
+
+void vp9_start_encode(vp9_writer *br, uint8_t *source) {
+ br->lowvalue = 0;
+ br->range = 255;
+ br->count = -24;
+ br->buffer = source;
+ br->pos = 0;
+ vp9_write_bit(br, 0);
+}
+
+void vp9_stop_encode(vp9_writer *br) {
+ int i;
+
+ for (i = 0; i < 32; i++)
+ vp9_write_bit(br, 0);
+
+ // Ensure there's no ambigous collision with any index marker bytes
+ if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0)
+ br->buffer[br->pos++] = 0;
+}
+
--- /dev/null
+++ b/vpx_dsp/bitwriter.h
@@ -1,0 +1,98 @@
+/*
+ * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef VPX_DSP_BITWRITER_H_
+#define VPX_DSP_BITWRITER_H_
+
+#include "vpx_ports/mem.h"
+
+#include "vpx_dsp/prob.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct vp9_writer {
+ unsigned int lowvalue;
+ unsigned int range;
+ int count;
+ unsigned int pos;
+ uint8_t *buffer;
+} vp9_writer;
+
+void vp9_start_encode(vp9_writer *bc, uint8_t *buffer);
+void vp9_stop_encode(vp9_writer *bc);
+
+static INLINE void vp9_write(vp9_writer *br, int bit, int probability) {
+ unsigned int split;
+ int count = br->count;
+ unsigned int range = br->range;
+ unsigned int lowvalue = br->lowvalue;
+ register unsigned int shift;
+
+ split = 1 + (((range - 1) * probability) >> 8);
+
+ range = split;
+
+ if (bit) {
+ lowvalue += split;
+ range = br->range - split;
+ }
+
+ shift = vp9_norm[range];
+
+ range <<= shift;
+ count += shift;
+
+ if (count >= 0) {
+ int offset = shift - count;
+
+ if ((lowvalue << (offset - 1)) & 0x80000000) {
+ int x = br->pos - 1;
+
+ while (x >= 0 && br->buffer[x] == 0xff) {
+ br->buffer[x] = 0;
+ x--;
+ }
+
+ br->buffer[x] += 1;
+ }
+
+ br->buffer[br->pos++] = (lowvalue >> (24 - offset));
+ lowvalue <<= offset;
+ shift = count;
+ lowvalue &= 0xffffff;
+ count -= 8;
+ }
+
+ lowvalue <<= shift;
+ br->count = count;
+ br->lowvalue = lowvalue;
+ br->range = range;
+}
+
+static INLINE void vp9_write_bit(vp9_writer *w, int bit) {
+ vp9_write(w, bit, 128); // vp9_prob_half
+}
+
+static INLINE void vp9_write_literal(vp9_writer *w, int data, int bits) {
+ int bit;
+
+ for (bit = bits - 1; bit >= 0; bit--)
+ vp9_write_bit(w, 1 & (data >> bit));
+}
+
+#define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // VPX_DSP_BITWRITER_H_
--- /dev/null
+++ b/vpx_dsp/bitwriter_buffer.c
@@ -1,0 +1,36 @@
+/*
+ * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <limits.h>
+
+#include "./bitwriter_buffer.h"
+
+size_t vp9_wb_bytes_written(const struct vp9_write_bit_buffer *wb) {
+ return wb->bit_offset / CHAR_BIT + (wb->bit_offset % CHAR_BIT > 0);
+}
+
+void vp9_wb_write_bit(struct vp9_write_bit_buffer *wb, int bit) {
+ const int off = (int)wb->bit_offset;
+ const int p = off / CHAR_BIT;
+ const int q = CHAR_BIT - 1 - off % CHAR_BIT;
+ if (q == CHAR_BIT -1) {
+ wb->bit_buffer[p] = bit << q;
+ } else {
+ wb->bit_buffer[p] &= ~(1 << q);
+ wb->bit_buffer[p] |= bit << q;
+ }
+ wb->bit_offset = off + 1;
+}
+
+void vp9_wb_write_literal(struct vp9_write_bit_buffer *wb, int data, int bits) {
+ int bit;
+ for (bit = bits - 1; bit >= 0; bit--)
+ vp9_wb_write_bit(wb, (data >> bit) & 1);
+}
--- /dev/null
+++ b/vpx_dsp/bitwriter_buffer.h
@@ -1,0 +1,36 @@
+/*
+ * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef VPX_DSP_BITWRITER_BUFFER_H_
+#define VPX_DSP_BITWRITER_BUFFER_H_
+
+#include "vpx/vpx_integer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct vp9_write_bit_buffer {
+ uint8_t *bit_buffer;
+ size_t bit_offset;
+};
+
+size_t vp9_wb_bytes_written(const struct vp9_write_bit_buffer *wb);
+
+void vp9_wb_write_bit(struct vp9_write_bit_buffer *wb, int bit);
+
+void vp9_wb_write_literal(struct vp9_write_bit_buffer *wb, int data, int bits);
+
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // VPX_DSP_BITWRITER_BUFFER_H_
--- a/vpx_dsp/vp9_write_bit_buffer.c
+++ /dev/null
@@ -1,36 +1,0 @@
-/*
- * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include <limits.h>
-
-#include "./vp9_write_bit_buffer.h"
-
-size_t vp9_wb_bytes_written(const struct vp9_write_bit_buffer *wb) {
- return wb->bit_offset / CHAR_BIT + (wb->bit_offset % CHAR_BIT > 0);
-}
-
-void vp9_wb_write_bit(struct vp9_write_bit_buffer *wb, int bit) {
- const int off = (int)wb->bit_offset;
- const int p = off / CHAR_BIT;
- const int q = CHAR_BIT - 1 - off % CHAR_BIT;
- if (q == CHAR_BIT -1) {
- wb->bit_buffer[p] = bit << q;
- } else {
- wb->bit_buffer[p] &= ~(1 << q);
- wb->bit_buffer[p] |= bit << q;
- }
- wb->bit_offset = off + 1;
-}
-
-void vp9_wb_write_literal(struct vp9_write_bit_buffer *wb, int data, int bits) {
- int bit;
- for (bit = bits - 1; bit >= 0; bit--)
- vp9_wb_write_bit(wb, (data >> bit) & 1);
-}
--- a/vpx_dsp/vp9_write_bit_buffer.h
+++ /dev/null
@@ -1,36 +1,0 @@
-/*
- * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef VP9_ENCODER_VP9_WRITE_BIT_BUFFER_H_
-#define VP9_ENCODER_VP9_WRITE_BIT_BUFFER_H_
-
-#include "vpx/vpx_integer.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct vp9_write_bit_buffer {
- uint8_t *bit_buffer;
- size_t bit_offset;
-};
-
-size_t vp9_wb_bytes_written(const struct vp9_write_bit_buffer *wb);
-
-void vp9_wb_write_bit(struct vp9_write_bit_buffer *wb, int bit);
-
-void vp9_wb_write_literal(struct vp9_write_bit_buffer *wb, int data, int bits);
-
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // VP9_ENCODER_VP9_WRITE_BIT_BUFFER_H_
--- a/vpx_dsp/vp9_writer.c
+++ /dev/null
@@ -1,34 +1,0 @@
-/*
- * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include <assert.h>
-
-#include "./vp9_writer.h"
-
-void vp9_start_encode(vp9_writer *br, uint8_t *source) {
- br->lowvalue = 0;
- br->range = 255;
- br->count = -24;
- br->buffer = source;
- br->pos = 0;
- vp9_write_bit(br, 0);
-}
-
-void vp9_stop_encode(vp9_writer *br) {
- int i;
-
- for (i = 0; i < 32; i++)
- vp9_write_bit(br, 0);
-
- // Ensure there's no ambigous collision with any index marker bytes
- if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0)
- br->buffer[br->pos++] = 0;
-}
-
--- a/vpx_dsp/vp9_writer.h
+++ /dev/null
@@ -1,98 +1,0 @@
-/*
- * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef VP9_ENCODER_VP9_WRITER_H_
-#define VP9_ENCODER_VP9_WRITER_H_
-
-#include "vpx_ports/mem.h"
-
-#include "vpx_dsp/prob.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct vp9_writer {
- unsigned int lowvalue;
- unsigned int range;
- int count;
- unsigned int pos;
- uint8_t *buffer;
-} vp9_writer;
-
-void vp9_start_encode(vp9_writer *bc, uint8_t *buffer);
-void vp9_stop_encode(vp9_writer *bc);
-
-static INLINE void vp9_write(vp9_writer *br, int bit, int probability) {
- unsigned int split;
- int count = br->count;
- unsigned int range = br->range;
- unsigned int lowvalue = br->lowvalue;
- register unsigned int shift;
-
- split = 1 + (((range - 1) * probability) >> 8);
-
- range = split;
-
- if (bit) {
- lowvalue += split;
- range = br->range - split;
- }
-
- shift = vp9_norm[range];
-
- range <<= shift;
- count += shift;
-
- if (count >= 0) {
- int offset = shift - count;
-
- if ((lowvalue << (offset - 1)) & 0x80000000) {
- int x = br->pos - 1;
-
- while (x >= 0 && br->buffer[x] == 0xff) {
- br->buffer[x] = 0;
- x--;
- }
-
- br->buffer[x] += 1;
- }
-
- br->buffer[br->pos++] = (lowvalue >> (24 - offset));
- lowvalue <<= offset;
- shift = count;
- lowvalue &= 0xffffff;
- count -= 8;
- }
-
- lowvalue <<= shift;
- br->count = count;
- br->lowvalue = lowvalue;
- br->range = range;
-}
-
-static INLINE void vp9_write_bit(vp9_writer *w, int bit) {
- vp9_write(w, bit, 128); // vp9_prob_half
-}
-
-static INLINE void vp9_write_literal(vp9_writer *w, int data, int bits) {
- int bit;
-
- for (bit = bits - 1; bit >= 0; bit--)
- vp9_write_bit(w, 1 & (data >> bit));
-}
-
-#define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8)
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // VP9_ENCODER_VP9_WRITER_H_
--- a/vpx_dsp/vpx_dsp.mk
+++ b/vpx_dsp/vpx_dsp.mk
@@ -18,10 +18,10 @@
DSP_SRCS-yes += prob.c
ifeq ($(CONFIG_ENCODERS),yes)
-DSP_SRCS-yes += vp9_writer.h
-DSP_SRCS-yes += vp9_writer.c
-DSP_SRCS-yes += vp9_write_bit_buffer.c
-DSP_SRCS-yes += vp9_write_bit_buffer.h
+DSP_SRCS-yes += bitwriter.h
+DSP_SRCS-yes += bitwriter.c
+DSP_SRCS-yes += bitwriter_buffer.c
+DSP_SRCS-yes += bitwriter_buffer.h
endif
ifeq ($(CONFIG_DECODERS),yes)