ref: 00a203b7bc735e20a5d0a0cc6857983c859d077e
parent: a3df343cda2b6f3d554138ce5dae831e2f946d0c
author: Ronald S. Bultje <[email protected]>
date: Tue Sep 8 10:33:17 EDT 2015
vp10: move coding of tx_mode element to the non-arithcoded header. See issue 1040 point 3. Change-Id: If051b92c24a34d6a39861fb7d7180c5ca32f3d82
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -81,6 +81,11 @@
return data > max ? max : data;
}
+#if CONFIG_MISC_FIXES
+static TX_MODE read_tx_mode(struct vpx_read_bit_buffer *rb) {
+ return vpx_rb_read_bit(rb) ? TX_MODE_SELECT : vpx_rb_read_literal(rb, 2);
+}
+#else
static TX_MODE read_tx_mode(vpx_reader *r) {
TX_MODE tx_mode = vpx_read_literal(r, 2);
if (tx_mode == ALLOW_32X32)
@@ -87,6 +92,7 @@
tx_mode += vpx_read_bit(r);
return tx_mode;
}
+#endif
static void read_tx_mode_probs(struct tx_probs *tx_probs, vpx_reader *r) {
int i, j;
@@ -1787,6 +1793,9 @@
static size_t read_uncompressed_header(VP10Decoder *pbi,
struct vpx_read_bit_buffer *rb) {
VP10_COMMON *const cm = &pbi->common;
+#if CONFIG_MISC_FIXES
+ MACROBLOCKD *const xd = &pbi->mb;
+#endif
BufferPool *const pool = cm->buffer_pool;
RefCntBuffer *const frame_bufs = pool->frame_bufs;
int i, mask, ref_index = 0;
@@ -2011,6 +2020,9 @@
setup_quantization(cm, &pbi->mb, rb);
setup_segmentation(cm, rb);
setup_segmentation_dequant(cm);
+#if CONFIG_MISC_FIXES
+ cm->tx_mode = xd->lossless ? ONLY_4X4 : read_tx_mode(rb);
+#endif
setup_tile_info(cm, rb);
sz = vpx_rb_read_literal(rb, 16);
@@ -2025,7 +2037,9 @@
static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data,
size_t partition_size) {
VP10_COMMON *const cm = &pbi->common;
+#if !CONFIG_MISC_FIXES
MACROBLOCKD *const xd = &pbi->mb;
+#endif
FRAME_CONTEXT *const fc = cm->fc;
vpx_reader r;
int k;
@@ -2035,7 +2049,9 @@
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate bool decoder 0");
+#if !CONFIG_MISC_FIXES
cm->tx_mode = xd->lossless ? ONLY_4X4 : read_tx_mode(&r);
+#endif
if (cm->tx_mode == TX_MODE_SELECT)
read_tx_mode_probs(&fc->tx_probs, &r);
read_coef_probs(fc, cm->tx_mode, &r);
--- a/vp10/encoder/bitstream.c
+++ b/vp10/encoder/bitstream.c
@@ -818,8 +818,17 @@
}
}
-static void encode_txfm_probs(VP10_COMMON *cm, vpx_writer *w,
+#if CONFIG_MISC_FIXES
+static void write_txfm_mode(TX_MODE mode, struct vpx_write_bit_buffer *wb) {
+ vpx_wb_write_bit(wb, mode == TX_MODE_SELECT);
+ if (mode != TX_MODE_SELECT)
+ vpx_wb_write_literal(wb, mode, 2);
+}
+#endif
+
+static void update_txfm_probs(VP10_COMMON *cm, vpx_writer *w,
FRAME_COUNTS *counts) {
+#if !CONFIG_MISC_FIXES
// Mode
vpx_write_literal(w, VPXMIN(cm->tx_mode, ALLOW_32X32), 2);
if (cm->tx_mode >= ALLOW_32X32)
@@ -826,6 +835,8 @@
vpx_write_bit(w, cm->tx_mode == TX_MODE_SELECT);
// Probabilities
+#endif
+
if (cm->tx_mode == TX_MODE_SELECT) {
int i, j;
unsigned int ct_8x8p[TX_SIZES - 3][2];
@@ -1154,6 +1165,12 @@
encode_loopfilter(&cm->lf, wb);
encode_quantization(cm, wb);
encode_segmentation(cm, xd, wb);
+#if CONFIG_MISC_FIXES
+ if (xd->lossless)
+ cm->tx_mode = TX_4X4;
+ else
+ write_txfm_mode(cm->tx_mode, wb);
+#endif
write_tile_info(cm, wb);
}
@@ -1160,7 +1177,6 @@
static size_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
VP10_COMMON *const cm = &cpi->common;
- MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
FRAME_CONTEXT *const fc = cm->fc;
FRAME_COUNTS *counts = cpi->td.counts;
vpx_writer header_bc;
@@ -1167,11 +1183,14 @@
vpx_start_encode(&header_bc, data);
- if (xd->lossless)
- cm->tx_mode = ONLY_4X4;
+#if !CONFIG_MISC_FIXES
+ if (cpi->td.mb.e_mbd.lossless)
+ cm->tx_mode = TX_4X4;
else
- encode_txfm_probs(cm, &header_bc, counts);
-
+ update_txfm_probs(cm, &header_bc, counts);
+#else
+ update_txfm_probs(cm, &header_bc, counts);
+#endif
update_coef_probs(cpi, &header_bc);
update_skip_probs(cm, &header_bc, counts);