ans: Move buf_ans_flush to the .c file It is called relatively rarely and doesn't need to be inlined. Change-Id: I4ee7f95548f008f2ee29da807aaca54b9a25aecd
diff --git a/aom_dsp/buf_ans.c b/aom_dsp/buf_ans.c index 1386722..33db080 100644 --- a/aom_dsp/buf_ans.c +++ b/aom_dsp/buf_ans.c
@@ -40,3 +40,20 @@ c->buf = new_buf; c->size = new_size; } + +void aom_buf_ans_flush(struct BufAnsCoder *const c) { + int offset; + for (offset = c->offset - 1; offset >= 0; --offset) { + if (c->buf[offset].method == ANS_METHOD_RANS) { + struct rans_sym sym; + sym.prob = c->buf[offset].prob; + sym.cum_prob = c->buf[offset].val_start; + rans_write(&c->ans, &sym); + } else { + uabs_write(&c->ans, (uint8_t)c->buf[offset].val_start, + (AnsP8)c->buf[offset].prob); + } + } + c->offset = 0; + c->output_bytes += ans_write_end(&c->ans); +}
diff --git a/aom_dsp/buf_ans.h b/aom_dsp/buf_ans.h index 0a1de1a..f670112 100644 --- a/aom_dsp/buf_ans.h +++ b/aom_dsp/buf_ans.h
@@ -52,6 +52,8 @@ void aom_buf_ans_grow(struct BufAnsCoder *c); +void aom_buf_ans_flush(struct BufAnsCoder *const c); + static INLINE void buf_ans_write_init(struct BufAnsCoder *const c, uint8_t *const output_buffer) { c->offset = 0; @@ -83,23 +85,6 @@ ++c->offset; } -static INLINE void buf_ans_flush(struct BufAnsCoder *const c) { - int offset; - for (offset = c->offset - 1; offset >= 0; --offset) { - if (c->buf[offset].method == ANS_METHOD_RANS) { - struct rans_sym sym; - sym.prob = c->buf[offset].prob; - sym.cum_prob = c->buf[offset].val_start; - rans_write(&c->ans, &sym); - } else { - uabs_write(&c->ans, (uint8_t)c->buf[offset].val_start, - (AnsP8)c->buf[offset].prob); - } - } - c->offset = 0; - c->output_bytes += ans_write_end(&c->ans); -} - static INLINE void buf_uabs_write_bit(struct BufAnsCoder *c, int bit) { buf_uabs_write(c, bit, 128); }
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 1bed65c..7817204 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -3536,7 +3536,7 @@ buf_ans_write_init(buf_ans, buf->data + data_offset); write_modes(cpi, &tile_info, buf_ans, &tok, tok_end); assert(tok == tok_end); - buf_ans_flush(buf_ans); + aom_buf_ans_flush(buf_ans); tile_size = buf_ans_write_end(buf_ans); #endif // !CONFIG_ANS @@ -3685,7 +3685,7 @@ buf_ans_write_init(buf_ans, dst + total_size); write_modes(cpi, &tile_info, buf_ans, &tok, tok_end); assert(tok == tok_end); - buf_ans_flush(buf_ans); + aom_buf_ans_flush(buf_ans); tile_size = buf_ans_write_end(buf_ans); #else aom_start_encode(&mode_bc, dst + total_size); @@ -4327,7 +4327,7 @@ #endif #endif #if CONFIG_ANS - buf_ans_flush(header_bc); + aom_buf_ans_flush(header_bc); header_size = buf_ans_write_end(header_bc); assert(header_size <= 0xffff); return header_size;
diff --git a/test/ans_test.cc b/test/ans_test.cc index e3ea14a..4c63352 100644 --- a/test/ans_test.cc +++ b/test/ans_test.cc
@@ -56,7 +56,7 @@ for (PvVec::const_iterator it = pv_vec.begin(); it != pv_vec.end(); ++it) { buf_uabs_write(&a, it->second, 256 - it->first); } - buf_ans_flush(&a); + aom_buf_ans_flush(&a); std::clock_t enc_time = std::clock() - start; int offset = buf_ans_write_end(&a); aom_buf_ans_free(&a); @@ -125,7 +125,7 @@ it != sym_vec.end(); ++it) { buf_rans_write(&a, &tab[*it]); } - buf_ans_flush(&a); + aom_buf_ans_flush(&a); std::clock_t enc_time = std::clock() - start; int offset = buf_ans_write_end(&a); aom_buf_ans_free(&a);