Add overwrite functions which do not zero bytes.
In several places bits are overwritten in the bitstream. These
functions avoid zeroing bytes during writing so that this can
happen correctly when the number of bits is not 8*N.
Re-addresses the attempted fix in
133c57c331f3b1806233fbd83db1f5f022b1490a
which broke threaded encoding tests, which relied on re-using
byte buffers.
Change-Id: I682c5e3a7869eac7ad475584db8bf170d47a56c9
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 36e0236..848f73d 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3516,7 +3516,7 @@
uncompressed_hdr_size = aom_wb_bytes_written(wb);
dst = wb->bit_buffer;
comp_hdr_size = write_compressed_header(cpi, dst + uncompressed_hdr_size);
- aom_wb_write_literal(&comp_hdr_len_wb, (int)(comp_hdr_size), 16);
+ aom_wb_overwrite_literal(&comp_hdr_len_wb, (int)(comp_hdr_size), 16);
hdr_size = uncompressed_hdr_size + comp_hdr_size;
total_size += hdr_size;
#endif
@@ -3559,9 +3559,9 @@
uncompressed_hdr_size * sizeof(uint8_t));
// Write the number of tiles in the group into the last uncompressed
// header before the one we've just inserted
- aom_wb_write_literal(&tg_params_wb, tile_idx - tile_count,
- n_log2_tiles);
- aom_wb_write_literal(&tg_params_wb, tile_count - 2, n_log2_tiles);
+ aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
+ n_log2_tiles);
+ aom_wb_overwrite_literal(&tg_params_wb, tile_count - 2, n_log2_tiles);
// Update the pointer to the last TG params
tg_params_wb.bit_offset = saved_offset + 8 * old_total_size;
// Copy compressed header
@@ -3578,9 +3578,9 @@
uncompressed_hdr_size * sizeof(uint8_t));
// Write the number of tiles in the group into the last uncompressed
// header
- aom_wb_write_literal(&tg_params_wb, tile_idx - tile_count,
- n_log2_tiles);
- aom_wb_write_literal(&tg_params_wb, tile_count - 1, n_log2_tiles);
+ aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
+ n_log2_tiles);
+ aom_wb_overwrite_literal(&tg_params_wb, tile_count - 1, n_log2_tiles);
tg_params_wb.bit_offset = saved_offset + 8 * total_size;
// Copy compressed header
memmove(dst + total_size + uncompressed_hdr_size,