Merge "Fix a enc/dec mismatch under CONFIG_MISC_FIXES"

This commit is contained in:
Yaowu Xu 2015-12-15 16:02:39 +00:00 коммит произвёл Gerrit Code Review
Родитель a5af49331d c7101830a6
Коммит 9232f69b26
3 изменённых файлов: 31 добавлений и 29 удалений

Просмотреть файл

@ -1143,24 +1143,13 @@ static INLINE int read_delta_q(struct vpx_read_bit_buffer *rb) {
vpx_rb_read_inv_signed_literal(rb, CONFIG_MISC_FIXES ? 6 : 4) : 0; vpx_rb_read_inv_signed_literal(rb, CONFIG_MISC_FIXES ? 6 : 4) : 0;
} }
static void setup_quantization(VP10_COMMON *const cm, MACROBLOCKD *const xd, static void setup_quantization(VP10_COMMON *const cm,
struct vpx_read_bit_buffer *rb) { struct vpx_read_bit_buffer *rb) {
int i;
cm->base_qindex = vpx_rb_read_literal(rb, QINDEX_BITS); cm->base_qindex = vpx_rb_read_literal(rb, QINDEX_BITS);
cm->y_dc_delta_q = read_delta_q(rb); cm->y_dc_delta_q = read_delta_q(rb);
cm->uv_dc_delta_q = read_delta_q(rb); cm->uv_dc_delta_q = read_delta_q(rb);
cm->uv_ac_delta_q = read_delta_q(rb); cm->uv_ac_delta_q = read_delta_q(rb);
cm->dequant_bit_depth = cm->bit_depth; cm->dequant_bit_depth = cm->bit_depth;
for (i = 0; i < MAX_SEGMENTS; ++i) {
const int qindex = CONFIG_MISC_FIXES && cm->seg.enabled ?
vp10_get_qindex(&cm->seg, i, cm->base_qindex) :
cm->base_qindex;
xd->lossless[i] = qindex == 0 &&
cm->y_dc_delta_q == 0 &&
cm->uv_dc_delta_q == 0 &&
cm->uv_ac_delta_q == 0;
}
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
xd->bd = (int)cm->bit_depth; xd->bd = (int)cm->bit_depth;
@ -1874,9 +1863,7 @@ static void read_bitdepth_colorspace_sampling(
static size_t read_uncompressed_header(VP10Decoder *pbi, static size_t read_uncompressed_header(VP10Decoder *pbi,
struct vpx_read_bit_buffer *rb) { struct vpx_read_bit_buffer *rb) {
VP10_COMMON *const cm = &pbi->common; VP10_COMMON *const cm = &pbi->common;
#if CONFIG_MISC_FIXES
MACROBLOCKD *const xd = &pbi->mb; MACROBLOCKD *const xd = &pbi->mb;
#endif
BufferPool *const pool = cm->buffer_pool; BufferPool *const pool = cm->buffer_pool;
RefCntBuffer *const frame_bufs = pool->frame_bufs; RefCntBuffer *const frame_bufs = pool->frame_bufs;
int i, mask, ref_index = 0; int i, mask, ref_index = 0;
@ -2104,12 +2091,26 @@ static size_t read_uncompressed_header(VP10Decoder *pbi,
vp10_setup_past_independence(cm); vp10_setup_past_independence(cm);
setup_loopfilter(&cm->lf, rb); setup_loopfilter(&cm->lf, rb);
setup_quantization(cm, &pbi->mb, rb); setup_quantization(cm, rb);
setup_segmentation(cm, rb); setup_segmentation(cm, rb);
{
int i;
for (i = 0; i < MAX_SEGMENTS; ++i) {
const int qindex = CONFIG_MISC_FIXES && cm->seg.enabled ?
vp10_get_qindex(&cm->seg, i, cm->base_qindex) :
cm->base_qindex;
xd->lossless[i] = qindex == 0 &&
cm->y_dc_delta_q == 0 &&
cm->uv_dc_delta_q == 0 &&
cm->uv_ac_delta_q == 0;
}
}
setup_segmentation_dequant(cm); setup_segmentation_dequant(cm);
#if CONFIG_MISC_FIXES #if CONFIG_MISC_FIXES
cm->tx_mode = (!cm->seg.enabled && xd->lossless[0]) ? ONLY_4X4 cm->tx_mode = (xd->lossless[0]) ? ONLY_4X4
: read_tx_mode(rb); : read_tx_mode(rb);
cm->reference_mode = read_frame_reference_mode(cm, rb); cm->reference_mode = read_frame_reference_mode(cm, rb);
#endif #endif

Просмотреть файл

@ -897,18 +897,17 @@ static void write_txfm_mode(TX_MODE mode, struct vpx_write_bit_buffer *wb) {
if (mode != TX_MODE_SELECT) if (mode != TX_MODE_SELECT)
vpx_wb_write_literal(wb, mode, 2); vpx_wb_write_literal(wb, mode, 2);
} }
#else
static void write_txfm_mode(TX_MODE mode, struct vpx_writer *wb) {
vpx_write_literal(wb, VPXMIN(mode, ALLOW_32X32), 2);
if (mode >= ALLOW_32X32)
vpx_write_bit(wb, mode == TX_MODE_SELECT);
}
#endif #endif
static void update_txfm_probs(VP10_COMMON *cm, vpx_writer *w, static void update_txfm_probs(VP10_COMMON *cm, vpx_writer *w,
FRAME_COUNTS *counts) { 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)
vpx_write_bit(w, cm->tx_mode == TX_MODE_SELECT);
// Probabilities
#endif
if (cm->tx_mode == TX_MODE_SELECT) { if (cm->tx_mode == TX_MODE_SELECT) {
int i, j; int i, j;
@ -1261,7 +1260,7 @@ static void write_uncompressed_header(VP10_COMP *cpi,
encode_quantization(cm, wb); encode_quantization(cm, wb);
encode_segmentation(cm, xd, wb); encode_segmentation(cm, xd, wb);
#if CONFIG_MISC_FIXES #if CONFIG_MISC_FIXES
if (!cm->seg.enabled && xd->lossless[0]) if (xd->lossless[0])
cm->tx_mode = TX_4X4; cm->tx_mode = TX_4X4;
else else
write_txfm_mode(cm->tx_mode, wb); write_txfm_mode(cm->tx_mode, wb);
@ -1291,10 +1290,12 @@ static size_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
vpx_start_encode(&header_bc, data); vpx_start_encode(&header_bc, data);
#if !CONFIG_MISC_FIXES #if !CONFIG_MISC_FIXES
if (cpi->td.mb.e_mbd.lossless[0]) if (cpi->td.mb.e_mbd.lossless[0]) {
cm->tx_mode = TX_4X4; cm->tx_mode = TX_4X4;
else } else {
write_txfm_mode(cm->tx_mode, &header_bc);
update_txfm_probs(cm, &header_bc, counts); update_txfm_probs(cm, &header_bc, counts);
}
#else #else
update_txfm_probs(cm, &header_bc, counts); update_txfm_probs(cm, &header_bc, counts);
#endif #endif

Просмотреть файл

@ -725,7 +725,7 @@ static void super_block_yrd(VP10_COMP *cpi, MACROBLOCK *x, int *rate,
assert(bs == xd->mi[0]->mbmi.sb_type); assert(bs == xd->mi[0]->mbmi.sb_type);
if (CONFIG_MISC_FIXES && xd->lossless[xd->mi[0]->mbmi.segment_id]) { if (CONFIG_MISC_FIXES && xd->lossless[0]) {
choose_smallest_tx_size(cpi, x, rate, distortion, skip, ret_sse, choose_smallest_tx_size(cpi, x, rate, distortion, skip, ret_sse,
ref_best_rd, bs); ref_best_rd, bs);
} else if (cpi->sf.tx_size_search_method == USE_LARGESTALL || } else if (cpi->sf.tx_size_search_method == USE_LARGESTALL ||