diff options
author | Yaowu Xu <yaowu@google.com> | 2015-07-20 21:21:41 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-07-20 21:21:41 +0000 |
commit | 7a63e6446b96d994d19d54165d31ba2fb3b35652 (patch) | |
tree | a9bb87ffd32c4dc91aa3997fb2480bde12777c90 /vp9/encoder | |
parent | f987e64476736160c42ae8dcba160aeb768dcd78 (diff) | |
parent | c5ad31e518ceaffebb055e6a186bcece8c6ced96 (diff) | |
download | libvpx-7a63e6446b96d994d19d54165d31ba2fb3b35652.tar libvpx-7a63e6446b96d994d19d54165d31ba2fb3b35652.tar.gz libvpx-7a63e6446b96d994d19d54165d31ba2fb3b35652.tar.bz2 libvpx-7a63e6446b96d994d19d54165d31ba2fb3b35652.zip |
Merge "Move bit writer files to vpx_dsp/"
Diffstat (limited to 'vp9/encoder')
-rw-r--r-- | vp9/encoder/vp9_bitstream.c | 2 | ||||
-rw-r--r-- | vp9/encoder/vp9_subexp.c | 3 | ||||
-rw-r--r-- | vp9/encoder/vp9_treewriter.h | 2 | ||||
-rw-r--r-- | vp9/encoder/vp9_write_bit_buffer.c | 35 | ||||
-rw-r--r-- | vp9/encoder/vp9_write_bit_buffer.h | 36 | ||||
-rw-r--r-- | vp9/encoder/vp9_writer.c | 34 | ||||
-rw-r--r-- | vp9/encoder/vp9_writer.h | 98 |
7 files changed, 3 insertions, 207 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 4ca4083a6..0ab5e8c85 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -13,6 +13,7 @@ #include <limits.h> #include "vpx/vpx_encoder.h" +#include "vpx_dsp/vp9_write_bit_buffer.h" #include "vpx_mem/vpx_mem.h" #include "vpx_ports/mem_ops.h" @@ -32,7 +33,6 @@ #include "vp9/encoder/vp9_segmentation.h" #include "vp9/encoder/vp9_subexp.h" #include "vp9/encoder/vp9_tokenize.h" -#include "vp9/encoder/vp9_write_bit_buffer.h" static const struct vp9_token intra_mode_encodings[INTRA_MODES] = { {0, 1}, {6, 3}, {28, 5}, {30, 5}, {58, 6}, {59, 6}, {126, 7}, {127, 7}, diff --git a/vp9/encoder/vp9_subexp.c b/vp9/encoder/vp9_subexp.c index b345b162c..7b5202b90 100644 --- a/vp9/encoder/vp9_subexp.c +++ b/vp9/encoder/vp9_subexp.c @@ -7,13 +7,12 @@ * 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 "vp9/common/vp9_common.h" #include "vp9/common/vp9_entropy.h" - #include "vp9/encoder/vp9_cost.h" #include "vp9/encoder/vp9_subexp.h" -#include "vp9/encoder/vp9_writer.h" #define vp9_cost_upd256 ((int)(vp9_cost_one(upd) - vp9_cost_zero(upd))) diff --git a/vp9/encoder/vp9_treewriter.h b/vp9/encoder/vp9_treewriter.h index 4a76d87cd..22f741562 100644 --- 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 "vp9/encoder/vp9_writer.h" +#include "vpx_dsp/vp9_writer.h" #ifdef __cplusplus extern "C" { diff --git a/vp9/encoder/vp9_write_bit_buffer.c b/vp9/encoder/vp9_write_bit_buffer.c deleted file mode 100644 index 6d55e84e8..000000000 --- a/vp9/encoder/vp9_write_bit_buffer.c +++ /dev/null @@ -1,35 +0,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/encoder/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); -} diff --git a/vp9/encoder/vp9_write_bit_buffer.h b/vp9/encoder/vp9_write_bit_buffer.h deleted file mode 100644 index 59f9bbe30..000000000 --- a/vp9/encoder/vp9_write_bit_buffer.h +++ /dev/null @@ -1,36 +0,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_ diff --git a/vp9/encoder/vp9_writer.c b/vp9/encoder/vp9_writer.c deleted file mode 100644 index ff461f218..000000000 --- a/vp9/encoder/vp9_writer.c +++ /dev/null @@ -1,34 +0,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/encoder/vp9_writer.h" -#include "vp9/common/vp9_entropy.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; -} - diff --git a/vp9/encoder/vp9_writer.h b/vp9/encoder/vp9_writer.h deleted file mode 100644 index 4526216e9..000000000 --- a/vp9/encoder/vp9_writer.h +++ /dev/null @@ -1,98 +0,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_ |