Commit 4c14efd2 authored by Yunqing Wang's avatar Yunqing Wang
Browse files

Fix checks in MB quantizer initialization

vp8cx_mb_init_quantizer() needs to be called at least once to get
all values calculated. This change added one check to decide if
we could skip initialization or not.

Change-Id: I3f65eb548be57580a61444328336bc18c25c085b
parent aa6afc01
...@@ -465,7 +465,7 @@ void encode_mb_row(VP8_COMP *cpi, ...@@ -465,7 +465,7 @@ void encode_mb_row(VP8_COMP *cpi,
else else
xd->mode_info_context->mbmi.segment_id = 0; xd->mode_info_context->mbmi.segment_id = 0;
vp8cx_mb_init_quantizer(cpi, x); vp8cx_mb_init_quantizer(cpi, x, 1);
} }
else else
xd->mode_info_context->mbmi.segment_id = 0; // Set to Segment 0 by default xd->mode_info_context->mbmi.segment_id = 0; // Set to Segment 0 by default
...@@ -1255,7 +1255,7 @@ int vp8cx_encode_inter_macroblock ...@@ -1255,7 +1255,7 @@ int vp8cx_encode_inter_macroblock
xd->mode_info_context->mbmi.segment_id = 0; xd->mode_info_context->mbmi.segment_id = 0;
/* segment_id changed, so update */ /* segment_id changed, so update */
vp8cx_mb_init_quantizer(cpi, x); vp8cx_mb_init_quantizer(cpi, x, 1);
} }
} }
} }
......
...@@ -20,7 +20,7 @@ extern int vp8cx_encode_inter_macroblock(VP8_COMP *cpi, MACROBLOCK *x, ...@@ -20,7 +20,7 @@ extern int vp8cx_encode_inter_macroblock(VP8_COMP *cpi, MACROBLOCK *x,
int recon_uvoffset); int recon_uvoffset);
extern int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, extern int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x,
TOKENEXTRA **t); TOKENEXTRA **t);
extern void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x); extern void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip);
extern void vp8_build_block_offsets(MACROBLOCK *x); extern void vp8_build_block_offsets(MACROBLOCK *x);
extern void vp8_setup_block_ptrs(MACROBLOCK *x); extern void vp8_setup_block_ptrs(MACROBLOCK *x);
...@@ -163,7 +163,7 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data) ...@@ -163,7 +163,7 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
else else
xd->mode_info_context->mbmi.segment_id = 0; xd->mode_info_context->mbmi.segment_id = 0;
vp8cx_mb_init_quantizer(cpi, x); vp8cx_mb_init_quantizer(cpi, x, 1);
} }
else else
xd->mode_info_context->mbmi.segment_id = 0; // Set to Segment 0 by default xd->mode_info_context->mbmi.segment_id = 0; // Set to Segment 0 by default
......
...@@ -583,7 +583,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi) ...@@ -583,7 +583,7 @@ void vp8cx_init_quantizer(VP8_COMP *cpi)
cpi->zbin_mode_boost + \ cpi->zbin_mode_boost + \
x->act_zbin_adj ) ) >> 7) x->act_zbin_adj ) ) >> 7)
void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x) void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip)
{ {
int i; int i;
int QIndex; int QIndex;
...@@ -607,7 +607,10 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x) ...@@ -607,7 +607,10 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
else else
QIndex = cpi->common.base_qindex; QIndex = cpi->common.base_qindex;
if (QIndex != x->q_index) /* This initialization should be called at least once. Use ok_to_skip to
* decide if it is ok to skip.
*/
if (!ok_to_skip || QIndex != x->q_index)
{ {
// Y // Y
zbin_extra = ZBIN_EXTRA_Y; zbin_extra = ZBIN_EXTRA_Y;
...@@ -716,7 +719,7 @@ void vp8cx_frame_init_quantizer(VP8_COMP *cpi) ...@@ -716,7 +719,7 @@ void vp8cx_frame_init_quantizer(VP8_COMP *cpi)
cpi->zbin_mode_boost = 0; cpi->zbin_mode_boost = 0;
// MB level quantizer setup // MB level quantizer setup
vp8cx_mb_init_quantizer(cpi, &cpi->mb); vp8cx_mb_init_quantizer(cpi, &cpi->mb, 0);
} }
......
...@@ -86,7 +86,7 @@ struct VP8_COMP; ...@@ -86,7 +86,7 @@ struct VP8_COMP;
extern void vp8_set_quantizer(struct VP8_COMP *cpi, int Q); extern void vp8_set_quantizer(struct VP8_COMP *cpi, int Q);
extern void vp8cx_frame_init_quantizer(struct VP8_COMP *cpi); extern void vp8cx_frame_init_quantizer(struct VP8_COMP *cpi);
extern void vp8_update_zbin_extra(struct VP8_COMP *cpi, MACROBLOCK *x); extern void vp8_update_zbin_extra(struct VP8_COMP *cpi, MACROBLOCK *x);
extern void vp8cx_mb_init_quantizer(struct VP8_COMP *cpi, MACROBLOCK *x); extern void vp8cx_mb_init_quantizer(struct VP8_COMP *cpi, MACROBLOCK *x, int ok_to_skip);
extern void vp8cx_init_quantizer(struct VP8_COMP *cpi); extern void vp8cx_init_quantizer(struct VP8_COMP *cpi);
#endif #endif
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#endif #endif
extern void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x);
extern void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x); extern void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x);
#define MAXF(a,b) (((a) > (b)) ? (a) : (b)) #define MAXF(a,b) (((a) > (b)) ? (a) : (b))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment