Clean up prediction mode coding.

This was done as preparation for adding NxN intra.

- Monochrome coding was removed as it's not part of the standard.
- No other functional changes.
This commit is contained in:
Ari Koivula 2013-12-18 11:25:44 +02:00
parent 8f610176d8
commit cf0d314d03

View file

@ -1216,82 +1216,68 @@ void encode_coding_tree(encoder_control *encoder, uint16_t x_ctb,
// For each part { // For each part {
flag = (mpm_preds == -1) ? 0 : 1; flag = (mpm_preds == -1) ? 0 : 1;
cabac.ctx = &g_intra_mode_model; cabac.ctx = &g_intra_mode_model;
CABAC_BIN(&cabac,flag,"IntraPred"); CABAC_BIN(&cabac,flag,"prev_intra_luma_pred_flag");
// } End for each part // } End for each part
// Intrapredmode signaling // Intrapredmode signaling
// If found from predictors, we can simplify signaling // If found from predictors, we can simplify signaling
if (flag) { if (flag) {
flag = (mpm_preds == 0) ? 0 : 1; CABAC_BIN_EP(&cabac, (mpm_preds == 0 ? 0 : 1), "mpm_idx");
CABAC_BIN_EP(&cabac, flag, "intraPredMode");
if (mpm_preds != 0) { if (mpm_preds != 0) {
flag = (mpm_preds == 1) ? 0 : 1; CABAC_BIN_EP(&cabac, (mpm_preds == 1 ? 0 : 1), "mpm_idx");
CABAC_BIN_EP(&cabac, flag, "intraPredMode");
} }
} else { } else {
// we signal the "full" predmode // we signal the "full" predmode
int32_t intra_pred_mode_temp = intra_pred_mode; int32_t tmp_pred = intra_pred_mode;
if (intra_preds[0] > intra_preds[1]) { if (intra_preds[0] > intra_preds[1]) SWAP(intra_preds[0], intra_preds[1], int8_t);
SWAP(intra_preds[0], intra_preds[1], int8_t); if (intra_preds[0] > intra_preds[2]) SWAP(intra_preds[0], intra_preds[2], int8_t);
} if (intra_preds[1] > intra_preds[2]) SWAP(intra_preds[1], intra_preds[2], int8_t);
if (intra_preds[0] > intra_preds[2]) {
SWAP(intra_preds[0], intra_preds[2], int8_t);
}
if (intra_preds[1] > intra_preds[2]) {
SWAP(intra_preds[1], intra_preds[2], int8_t);
}
for (i = 2; i >= 0; i--) { for (i = 2; i >= 0; i--) {
intra_pred_mode_temp = intra_pred_mode_temp > intra_preds[i] ? tmp_pred = (tmp_pred > intra_preds[i] ? tmp_pred - 1 : tmp_pred);
intra_pred_mode_temp - 1 : intra_pred_mode_temp;
} }
CABAC_BINS_EP(&cabac, intra_pred_mode_temp, 5, "intraPredMode"); CABAC_BINS_EP(&cabac, tmp_pred, 5, "rem_intra_luma_pred_mode");
} }
// If we have chroma, signal it
if (encoder->in.video_format != FORMAT_400) {
// Chroma intra prediction // Chroma intra prediction
/** Table 9-35 Binarization for intra_chroma_pred_mode
* intra_chroma_pred_mode bin_string
* 4 0
* 0 100
* 1 101
* 2 110
* 3 111
*/
cabac.ctx = &g_chroma_pred_model[0]; cabac.ctx = &g_chroma_pred_model[0];
CABAC_BIN(&cabac, ((intra_pred_mode_chroma != 36) ? 1 : 0), "IntraPredChroma"); CABAC_BIN(&cabac, ((intra_pred_mode_chroma != 36) ? 1 : 0), "intra_chroma_pred_mode");
// If not copied from luma, signal it // If not copied from luma, signal it
if (intra_pred_mode_chroma != 36) { if (intra_pred_mode_chroma != 36) {
int8_t intra_pred_mode_chroma_temp = intra_pred_mode_chroma; int8_t tmp_pred = intra_pred_mode_chroma;
// Default chroma predictors // Default chroma predictors
uint32_t allowed_chroma_dir[5] = { 0, 26, 10, 1, 36 }; uint32_t allowed_chroma_dir[5] = { 0, 26, 10, 1, 36 };
// If intra is the same as one of the default predictors, replace it // If intra is the same as one of the default predictors, replace it
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (intra_pred_mode == allowed_chroma_dir[i]) { if (intra_pred_mode == allowed_chroma_dir[i]) {
allowed_chroma_dir[i] = 34; /* VER+8 mode */ allowed_chroma_dir[i] = 34; // VER+8 mode
break; break;
} }
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (intra_pred_mode_chroma_temp == allowed_chroma_dir[i]) { if (tmp_pred == allowed_chroma_dir[i]) {
intra_pred_mode_chroma_temp = i; tmp_pred = i;
break; break;
} }
} }
CABAC_BINS_EP(&cabac, intra_pred_mode_chroma_temp, 2, "intraPredModeChroma"); CABAC_BINS_EP(&cabac, tmp_pred, 2, "intra_chroma_pred_mode");
}
} }
// END OF PREDINFO CODING
// Coeff
// Transform tree
encode_transform_coeff(encoder, x_ctb, y_ctb, depth, 0, 0, 0); encode_transform_coeff(encoder, x_ctb, y_ctb, depth, 0, 0, 0);
// end Transform tree
// end Coeff
} }
#if ENABLE_PCM == 1 #if ENABLE_PCM == 1