summaryrefslogtreecommitdiff
path: root/vp8/encoder/quantize.c
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2011-10-05 11:26:00 +0100
committerPaul Wilkins <paulwilkins@google.com>2011-10-24 15:52:18 +0100
commit01ce04bc06d34a3d58cd900664d233f41e6e06d0 (patch)
treea1483e8aad14036bdc3fbf08e8e4128d2c6b3c5f /vp8/encoder/quantize.c
parent152ce6b2b901279d1154ef45e8b387eb23cad3a0 (diff)
downloadlibvpx-01ce04bc06d34a3d58cd900664d233f41e6e06d0.tar
libvpx-01ce04bc06d34a3d58cd900664d233f41e6e06d0.tar.gz
libvpx-01ce04bc06d34a3d58cd900664d233f41e6e06d0.tar.bz2
libvpx-01ce04bc06d34a3d58cd900664d233f41e6e06d0.zip
Further segment feature extensions.
This quite large check in includes the following: Merge in some code from Ronald (mbgraph.c) that scans a Gf/arf group. This is used as a basis for a simple segmentation for the normal frames in a gf/arf group. This code also uses satd functions from Yaowu. Adds functionality for coding the latest possible position of an EOB for blocks in the segment. (Currently 0-15 only, hence just for 4x4 dct). Where the EOB position is 0 this acts like "skip" and the normal coding of skip at the per mb level is disabled. Added functions (seg_common.c) for setting and reading segment feature elements. These may want to be optimized away at some point but while the mecahnism is in a state of flux they provide a single location for making changes and keep things a bit cleaner. This is still proof of concept code. Currently the tested feature set:- Quantizer, Loop Filter level, Reference frame, Prediction Mode, EOB end stop. TBD:- Add functions for setting and reading the feature data with range and validity checking. Handling of signed and unsigned feature data. At the moment all is assumed to be signed and a sign bit is coded but many cannot be negative. Correct handling of EOB feature with intra coded blocks. Testing/trapping of legal/illegal ref frame and mode combinations. Transform size switch plus merge and test with 8c8 DCT work Merge and test with Sumans Segmenation coding optimizations Change-Id: Iee12e83661c7abbd1e0ce6810915eb4ec35e2d8e
Diffstat (limited to 'vp8/encoder/quantize.c')
-rw-r--r--vp8/encoder/quantize.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/vp8/encoder/quantize.c b/vp8/encoder/quantize.c
index 156989fc3..89559273f 100644
--- a/vp8/encoder/quantize.c
+++ b/vp8/encoder/quantize.c
@@ -16,6 +16,10 @@
#include "quantize.h"
#include "vp8/common/quant_common.h"
+#if CONFIG_SEGFEATURES
+#include "vp8/common/seg_common.h"
+#endif
+
#ifdef ENC_DEBUG
extern int enc_debug;
#endif
@@ -132,7 +136,11 @@ void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
eob = -1;
+#if CONFIG_SEGFEATURES
+ for (i = 0; i < b->eob_max_offset; i++)
+#else
for (i = 0; i < 16; i++)
+#endif
{
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
@@ -1171,8 +1179,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
// Select the baseline MB Q index allowing for any segment level change.
#if CONFIG_SEGFEATURES
- if ( xd->segmentation_enabled &&
- ( xd->segment_feature_mask[segment_id] & (0x01 << SEG_LVL_ALT_Q) ) )
+ if ( segfeature_active( xd, segment_id, SEG_LVL_ALT_Q ) )
#else
if ( xd->segmentation_enabled )
#endif
@@ -1210,6 +1217,16 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
x->e_mbd.block[i].dequant = cpi->common.Y1dequant[QIndex];
x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_y1[QIndex];
x->block[i].zbin_extra = (short)zbin_extra;
+#if CONFIG_SEGFEATURES
+ // Segment max eob offset feature.
+ if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
+ {
+ x->block[i].eob_max_offset =
+ xd->segment_feature_data[segment_id][SEG_LVL_EOB];
+ }
+ else
+ x->block[i].eob_max_offset = 16;
+#endif
}
// UV
@@ -1228,6 +1245,16 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
x->e_mbd.block[i].dequant = cpi->common.UVdequant[QIndex];
x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_uv[QIndex];
x->block[i].zbin_extra = (short)zbin_extra;
+#if CONFIG_SEGFEATURES
+ // Segment max eob offset feature.
+ if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
+ {
+ x->block[i].eob_max_offset =
+ xd->segment_feature_data[segment_id][SEG_LVL_EOB];
+ }
+ else
+ x->block[i].eob_max_offset = 16;
+#endif
}
// Y2
@@ -1245,6 +1272,18 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex];
x->block[24].zbin_extra = (short)zbin_extra;
+#if CONFIG_SEGFEATURES
+ // TBD perhaps not use for Y2
+ // Segment max eob offset feature.
+ if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
+ {
+ x->block[24].eob_max_offset =
+ xd->segment_feature_data[segment_id][SEG_LVL_EOB];
+ }
+ else
+ x->block[24].eob_max_offset = 16;
+#endif
+
/* save this macroblock QIndex for vp8_update_zbin_extra() */
x->q_index = QIndex;
}
@@ -1324,23 +1363,8 @@ void vp8_set_quantizer(struct VP8_COMP *cpi, int Q)
update |= cm->y2dc_delta_q != new_delta_q;
cm->y2dc_delta_q = new_delta_q;
-
- // Set Segment specific quatizers if enabled
- for ( i = 0; i < MAX_MB_SEGMENTS; i++ )
- {
- mbd->segment_feature_data[i][SEG_LVL_ALT_Q] =
- cpi->segment_feature_data[i][SEG_LVL_ALT_Q];
-
-#if CONFIG_SEGFEATURES
- mbd->segment_feature_mask[i] &= ~(1 << SEG_LVL_ALT_Q);
- mbd->segment_feature_mask[i] |=
- cpi->segment_feature_mask[i] & (1 << SEG_LVL_ALT_Q);
-#endif
- }
-
/* quantizer has to be reinitialized for any delta_q changes */
if(update)
vp8cx_init_quantizer(cpi);
-
}