summaryrefslogtreecommitdiff
path: root/vp8/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder')
-rw-r--r--vp8/encoder/bitstream.c175
-rw-r--r--vp8/encoder/block.h2
-rw-r--r--vp8/encoder/dct.c302
-rw-r--r--vp8/encoder/encodeframe.c75
-rw-r--r--vp8/encoder/encodemb.c14
-rw-r--r--vp8/encoder/mbgraph.c1
-rw-r--r--vp8/encoder/onyx_if.c129
-rw-r--r--vp8/encoder/onyx_int.h63
-rw-r--r--vp8/encoder/ratectrl.c12
-rw-r--r--vp8/encoder/rdopt.c182
10 files changed, 704 insertions, 251 deletions
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index a96a75e06..6033f790e 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -34,15 +34,18 @@ unsigned __int64 Sectionbits[500];
#endif
#ifdef ENTROPY_STATS
-int intra_mode_stats[10][10][10];
+int intra_mode_stats[VP8_BINTRAMODES]
+ [VP8_BINTRAMODES]
+ [VP8_BINTRAMODES];
static unsigned int tree_update_hist [BLOCK_TYPES]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
- [ENTROPY_NODES][2]={0};
+ [ENTROPY_NODES] [2]={0};
static unsigned int tree_update_hist_8x8 [BLOCK_TYPES_8X8]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] [2]={0};
+
extern unsigned int active_section;
#endif
@@ -64,19 +67,41 @@ static void compute_update_table()
update_bits[i] = vp8_count_term_subexp(i, SUBEXP_PARAM, 255);
}
+static int split_index(int i, int n, int modulus)
+{
+ int max1 = (n-1 - modulus/2)/modulus + 1;
+ if (i%modulus == modulus/2) i = i/modulus;
+ else i = max1 + i - (i + modulus-modulus/2)/modulus;
+ return i;
+}
+
static int remap_prob(int v, int m)
{
const int n = 256;
+ const int modulus = MODULUS_PARAM;
+ const int max1 = (n-2-modulus/2+modulus-1)/modulus;
int i;
if ((m<<1)<=n)
i = recenter_nonneg(v, m) - 1;
else
i = recenter_nonneg(n-1-v, n-1-m) - 1;
- //if (i >= s) i -= s; else i = n - 2 - i;
- //i = ((i>>4)&15) | ((i((i>>4)&15) | ((i&15)<<4);&15)<<4);
- i = (i%17)*15 + (i/17);
+
+ i = split_index(i, n-1, modulus);
return i;
}
+
+static void write_prob_diff_update(vp8_writer *const w,
+ vp8_prob newp, vp8_prob oldp)
+{
+ int delp = remap_prob(newp, oldp);
+ vp8_encode_term_subexp(w, delp, SUBEXP_PARAM, 255);
+}
+
+static int prob_diff_update_cost(vp8_prob newp, vp8_prob oldp)
+{
+ int delp = remap_prob(newp, oldp);
+ return update_bits[delp]*256;
+}
#endif
static void update_mode(
@@ -194,21 +219,11 @@ void update_skip_probs(VP8_COMP *cpi)
static void update_refpred_stats( VP8_COMP *cpi )
{
VP8_COMMON *const cm = & cpi->common;
- MACROBLOCKD *const xd = & cpi->mb.e_mbd;
-
- int mb_row, mb_col;
int i;
int tot_count;
- int ref_pred_count[PREDICTION_PROBS][2];
vp8_prob new_pred_probs[PREDICTION_PROBS];
- unsigned char pred_context;
- unsigned char pred_flag;
-
int old_cost, new_cost;
- // Clear the prediction hit counters
- vpx_memset(ref_pred_count, 0, sizeof(ref_pred_count));
-
// Set the prediction probability structures to defaults
if ( cm->frame_type == KEY_FRAME )
{
@@ -222,47 +237,17 @@ static void update_refpred_stats( VP8_COMP *cpi )
}
else
{
- // For non-key frames.......
-
- // Scan through the macroblocks and collate prediction counts.
- xd->mode_info_context = cm->mi;
- for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
- {
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- // Get the prediction context and status
- pred_flag = get_pred_flag( xd, PRED_REF );
- pred_context = get_pred_context( cm, xd, PRED_REF );
-
- // Count prediction success
- ref_pred_count[pred_context][pred_flag]++;
-
- // Step on to the next mb
- xd->mode_info_context++;
- }
-
- // this is to account for the border in mode_info_context
- xd->mode_info_context++;
- }
-
// From the prediction counts set the probabilities for each context
for ( i = 0; i < PREDICTION_PROBS; i++ )
{
- // MB reference frame not relevent to key frame encoding
- if ( cm->frame_type != KEY_FRAME )
+ tot_count = cpi->ref_pred_count[i][0] + cpi->ref_pred_count[i][1];
+ if ( tot_count )
{
- // Work out the probabilities for the reference frame predictor
- tot_count = ref_pred_count[i][0] + ref_pred_count[i][1];
- if ( tot_count )
- {
- new_pred_probs[i] =
- ( ref_pred_count[i][0] * 255 ) / tot_count;
+ new_pred_probs[i] =
+ ( cpi->ref_pred_count[i][0] * 255 + (tot_count >> 1)) / tot_count;
- // Clamp to minimum allowed value
- new_pred_probs[i] += !new_pred_probs[i];
- }
- else
- new_pred_probs[i] = 128;
+ // Clamp to minimum allowed value
+ new_pred_probs[i] += !new_pred_probs[i];
}
else
new_pred_probs[i] = 128;
@@ -270,12 +255,12 @@ static void update_refpred_stats( VP8_COMP *cpi )
// Decide whether or not to update the reference frame probs.
// Returned costs are in 1/256 bit units.
old_cost =
- (ref_pred_count[i][0] * vp8_cost_zero(cm->ref_pred_probs[i])) +
- (ref_pred_count[i][1] * vp8_cost_one(cm->ref_pred_probs[i]));
+ (cpi->ref_pred_count[i][0] * vp8_cost_zero(cm->ref_pred_probs[i])) +
+ (cpi->ref_pred_count[i][1] * vp8_cost_one(cm->ref_pred_probs[i]));
new_cost =
- (ref_pred_count[i][0] * vp8_cost_zero(new_pred_probs[i])) +
- (ref_pred_count[i][1] * vp8_cost_one(new_pred_probs[i]));
+ (cpi->ref_pred_count[i][0] * vp8_cost_zero(new_pred_probs[i])) +
+ (cpi->ref_pred_count[i][1] * vp8_cost_one(new_pred_probs[i]));
// Cost saving must be >= 8 bits (2048 in these units)
if ( (old_cost - new_cost) >= 2048 )
@@ -329,22 +314,28 @@ static int prob_update_savings(const unsigned int *ct,
{
const int old_b = vp8_cost_branch256(ct, oldp);
const int new_b = vp8_cost_branch256(ct, newp);
-#if CONFIG_NEWUPDATE
- const int delp = remap_prob(newp, oldp);
- const int update_b = update_bits[delp]*256 + vp8_cost_upd256;
-#else
const int update_b = 2048 + vp8_cost_upd256;
-#endif
return (old_b - new_b - update_b);
}
#if CONFIG_NEWUPDATE
-static int prob_update_savings_search(const unsigned int *ct,
+static int prob_diff_update_savings(const unsigned int *ct,
+ const vp8_prob oldp, const vp8_prob newp,
+ const vp8_prob upd)
+{
+ const int old_b = vp8_cost_branch256(ct, oldp);
+ const int new_b = vp8_cost_branch256(ct, newp);
+ const int update_b = (newp == oldp ? 0 :
+ prob_diff_update_cost(newp, oldp) + vp8_cost_upd256);
+ return (old_b - new_b - update_b);
+}
+
+static int prob_diff_update_savings_search(const unsigned int *ct,
const vp8_prob oldp, vp8_prob *bestp,
const vp8_prob upd)
{
const int old_b = vp8_cost_branch256(ct, oldp);
- int new_b, delp, update_b, savings, bestsavings, step;
+ int new_b, update_b, savings, bestsavings, step;
vp8_prob newp, bestnewp;
bestsavings = 0;
@@ -354,8 +345,7 @@ static int prob_update_savings_search(const unsigned int *ct,
for (newp = *bestp; newp != oldp; newp+=step)
{
new_b = vp8_cost_branch256(ct, newp);
- delp = remap_prob(newp, oldp);
- update_b = update_bits[delp]*256 + vp8_cost_upd256;
+ update_b = prob_diff_update_cost(newp, oldp) + vp8_cost_upd256;
savings = old_b - new_b - update_b;
if (savings > bestsavings)
{
@@ -1197,6 +1187,7 @@ static void write_kfmodes(VP8_COMP *cpi)
int row_delta[4] = { 0, +1, 0, -1};
int col_delta[4] = {+1, -1, +1, +1};
+ //printf("write_kfmodes\n");
if (c->mb_no_coeff_skip)
{
// Divide by 0 check. 0 case possible with segment features
@@ -1322,6 +1313,7 @@ static void write_kfmodes(VP8_COMP *cpi)
#endif
write_bmode(bc, bm, c->kf_bmode_prob [A] [L]);
+ //printf(" mode: %d\n", bm);
#if CONFIG_COMP_INTRA_PRED
if (uses_second)
{
@@ -1335,12 +1327,16 @@ static void write_kfmodes(VP8_COMP *cpi)
{
write_i8x8_mode(bc, m->bmi[0].as_mode.first,
c->i8x8_mode_prob);
+ //printf(" mode: %d\n", m->bmi[0].as_mode.first); fflush(stdout);
write_i8x8_mode(bc, m->bmi[2].as_mode.first,
c->i8x8_mode_prob);
+ //printf(" mode: %d\n", m->bmi[2].as_mode.first); fflush(stdout);
write_i8x8_mode(bc, m->bmi[8].as_mode.first,
c->i8x8_mode_prob);
+ //printf(" mode: %d\n", m->bmi[8].as_mode.first); fflush(stdout);
write_i8x8_mode(bc, m->bmi[10].as_mode.first,
c->i8x8_mode_prob);
+ //printf(" mode: %d\n", m->bmi[10].as_mode.first); fflush(stdout);
}
else
write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]);
@@ -1519,7 +1515,7 @@ static void update_coef_probs3(VP8_COMP *cpi)
#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
if (s > 0 && newp != *Pold) u = 1;
if (u)
@@ -1558,7 +1554,7 @@ static void update_coef_probs3(VP8_COMP *cpi)
continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
if (s > 0 && newp != *Pold) u = 1;
#else
@@ -1574,8 +1570,7 @@ static void update_coef_probs3(VP8_COMP *cpi)
#endif
if (u)
{ /* send/use new probability */
- int delp = remap_prob(newp, *Pold);
- vp8_encode_term_subexp(w, delp, SUBEXP_PARAM, 255);
+ write_prob_diff_update(w, newp, *Pold);
*Pold = newp;
}
@@ -1608,7 +1603,7 @@ static void update_coef_probs3(VP8_COMP *cpi)
continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct_8x8 [i][j][k][t],
*Pold, &newp, upd);
if (s > 0 && newp != *Pold)
@@ -1650,7 +1645,7 @@ static void update_coef_probs3(VP8_COMP *cpi)
continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct_8x8 [i][j][k][t],
*Pold, &newp, upd);
if (s > 0 && newp != *Pold)
@@ -1670,8 +1665,7 @@ static void update_coef_probs3(VP8_COMP *cpi)
if (u)
{
/* send/use new probability */
- int delp = remap_prob(newp, *Pold);
- vp8_encode_term_subexp( w, delp, SUBEXP_PARAM, 255);
+ write_prob_diff_update(w, newp, *Pold);
*Pold = newp;
}
}
@@ -1704,18 +1698,18 @@ static void update_coef_probs2(VP8_COMP *cpi)
{
for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
{
-#if CONFIG_EXPANDED_COEF_CONTEXT
- if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
- continue;
-#endif
vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
int s;
int u = 0;
+#if CONFIG_EXPANDED_COEF_CONTEXT
+ if (k >=3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
+ continue;
+#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
if (s > 0 && newp != *Pold) u = 1;
if (u)
@@ -1756,7 +1750,7 @@ static void update_coef_probs2(VP8_COMP *cpi)
continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct [i][j][k][t], *Pold, &newp, upd);
if (s > 0 && newp != *Pold) u = 1;
#else
@@ -1771,8 +1765,7 @@ static void update_coef_probs2(VP8_COMP *cpi)
#endif
if (u)
{ /* send/use new probability */
- int delp = remap_prob(newp, *Pold);
- vp8_encode_term_subexp(w, delp, SUBEXP_PARAM, 255);
+ write_prob_diff_update(w, newp, *Pold);
*Pold = newp;
}
}
@@ -1803,7 +1796,7 @@ static void update_coef_probs2(VP8_COMP *cpi)
continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct_8x8 [i][j][k][t],
*Pold, &newp, upd);
if (s > 0 && newp != *Pold)
@@ -1847,7 +1840,7 @@ static void update_coef_probs2(VP8_COMP *cpi)
continue;
#endif
#if defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct_8x8 [i][j][k][t],
*Pold, &newp, upd);
if (s > 0 && newp != *Pold)
@@ -1867,8 +1860,7 @@ static void update_coef_probs2(VP8_COMP *cpi)
if (u)
{
/* send/use new probability */
- int delp = remap_prob(newp, *Pold);
- vp8_encode_term_subexp( w, delp, SUBEXP_PARAM, 255);
+ write_prob_diff_update(w, newp, *Pold);
*Pold = newp;
}
}
@@ -1920,7 +1912,7 @@ static void update_coef_probs(VP8_COMP *cpi)
continue;
#endif
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct [i][j][k][t],
*Pold, &newp, upd);
if (s > 0 && newp != *Pold)
@@ -1992,7 +1984,7 @@ static void update_coef_probs(VP8_COMP *cpi)
#endif
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- s = prob_update_savings_search(
+ s = prob_diff_update_savings_search(
cpi->frame_branch_ct [i][j][k][t],
*Pold, &newp, upd);
if (s > 0 && newp != *Pold)
@@ -2015,9 +2007,7 @@ static void update_coef_probs(VP8_COMP *cpi)
{
/* send/use new probability */
#if CONFIG_NEWUPDATE
- vp8_encode_term_subexp(
- w, remap_prob(newp, *Pold), SUBEXP_PARAM, 255);
- //printf("delp = %d/%d/%d\n", *Pold, remap_prob(newp, *Pold, 256), newp);
+ write_prob_diff_update(w, newp, *Pold);
#else
vp8_write_literal(w, newp, 8);
#endif
@@ -2068,7 +2058,7 @@ static void update_coef_probs(VP8_COMP *cpi)
continue;
#endif
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- const int s = prob_update_savings_search(ct, oldp, &newp, upd);
+ const int s = prob_diff_update_savings_search(ct, oldp, &newp, upd);
const int u = s > 0 && newp != oldp ? 1 : 0;
if (u)
savings += s - (int)(vp8_cost_zero(upd));
@@ -2124,7 +2114,7 @@ static void update_coef_probs(VP8_COMP *cpi)
const vp8_prob oldp = *Pold;
const vp8_prob upd = vp8_coef_update_probs_8x8 [i][j][k][t];
#if CONFIG_NEWUPDATE && defined(SEARCH_NEWP)
- const int s = prob_update_savings_search(ct, oldp, &newp, upd);
+ const int s = prob_diff_update_savings_search(ct, oldp, &newp, upd);
const int u = s > 0 && newp != oldp ? 1 : 0;
#else
const int s = prob_update_savings(ct, oldp, newp, upd);
@@ -2144,8 +2134,7 @@ static void update_coef_probs(VP8_COMP *cpi)
{
/* send/use new probability */
#if CONFIG_NEWUPDATE
- vp8_encode_term_subexp(
- w, remap_prob(newp, oldp), SUBEXP_PARAM, 255);
+ write_prob_diff_update(w, newp, oldp);
#else
vp8_write_literal(w, newp, 8);
#endif
diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h
index 2b21fa2b2..98bc13277 100644
--- a/vp8/encoder/block.h
+++ b/vp8/encoder/block.h
@@ -124,7 +124,7 @@ typedef struct
#endif
int mbmode_cost[2][MB_MODE_COUNT];
int intra_uv_mode_cost[2][MB_MODE_COUNT];
- unsigned int bmode_costs[10][10][10];
+ unsigned int bmode_costs[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES];
unsigned int i8x8_mode_costs[MB_MODE_COUNT];
unsigned int inter_bmode_costs[B_MODE_COUNT];
diff --git a/vp8/encoder/dct.c b/vp8/encoder/dct.c
index c2f2d1117..6f9c68ef7 100644
--- a/vp8/encoder/dct.c
+++ b/vp8/encoder/dct.c
@@ -12,11 +12,250 @@
#include <math.h>
#include "vpx_ports/config.h"
+#if CONFIG_INT_8X8FDCT
+static const int xC1S7 = 16069;
+static const int xC2S6 = 15137;
+static const int xC3S5 = 13623;
+static const int xC4S4 = 11585;
+static const int xC5S3 = 9102;
+static const int xC6S2 = 6270;
+static const int xC7S1 = 3196;
+#define SHIFT_BITS 14
+#define DOROUND(X) X += (1<<(SHIFT_BITS-1));
+#define FINAL_SHIFT 3
+#define FINAL_ROUNDING (1<<(FINAL_SHIFT -1))
+#define IN_SHIFT (FINAL_SHIFT+1)
+void vp8_short_fdct8x8_c ( short * InputData, short * OutputData, int pitch)
+{
+ int loop;
+ int short_pitch = pitch>>1;
+ int is07, is12, is34, is56;
+ int is0734, is1256;
+ int id07, id12, id34, id56;
+ int irot_input_x, irot_input_y;
+ int icommon_product1; // Re-used product (c4s4 * (s12 - s56))
+ int icommon_product2; // Re-used product (c4s4 * (d12 + d56))
+ int temp1, temp2; // intermediate variable for computation
+
+ int InterData[64];
+ int *ip = InterData;
+ short *op = OutputData;
+
+ for (loop = 0; loop < 8; loop++)
+ {
+ // Pre calculate some common sums and differences.
+ is07 = (InputData[0] + InputData[7])<<IN_SHIFT;
+ is12 = (InputData[1] + InputData[2])<<IN_SHIFT;
+ is34 = (InputData[3] + InputData[4])<<IN_SHIFT;
+ is56 = (InputData[5] + InputData[6])<<IN_SHIFT;
+ id07 = (InputData[0] - InputData[7])<<IN_SHIFT;
+ id12 = (InputData[1] - InputData[2])<<IN_SHIFT;
+ id34 = (InputData[3] - InputData[4])<<IN_SHIFT;
+ id56 = (InputData[5] - InputData[6])<<IN_SHIFT;
+
+ is0734 = is07 + is34;
+ is1256 = is12 + is56;
+
+ // Pre-Calculate some common product terms.
+ icommon_product1 = xC4S4*(is12 - is56);
+ DOROUND(icommon_product1)
+ icommon_product1>>=SHIFT_BITS;
+
+ icommon_product2 = xC4S4*(id12 + id56);
+ DOROUND(icommon_product2)
+ icommon_product2>>=SHIFT_BITS;
+
+
+ ip[0] = (xC4S4*(is0734 + is1256));
+ DOROUND(ip[0]);
+ ip[0] >>= SHIFT_BITS;
+
+ ip[4] = (xC4S4*(is0734 - is1256));
+ DOROUND(ip[4]);
+ ip[4] >>= SHIFT_BITS;
+
+ // Define inputs to rotation for outputs 2 and 6
+ irot_input_x = id12 - id56;
+ irot_input_y = is07 - is34;
+
+ // Apply rotation for outputs 2 and 6.
+ temp1=xC6S2*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC2S6*irot_input_y;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ ip[2] = temp1 + temp2;
+
+ temp1=xC6S2*irot_input_y;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC2S6*irot_input_x ;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ ip[6] = temp1 -temp2 ;
+
+ // Define inputs to rotation for outputs 1 and 7
+ irot_input_x = icommon_product1 + id07;
+ irot_input_y = -( id34 + icommon_product2 );
+
+ // Apply rotation for outputs 1 and 7.
+ temp1=xC1S7*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC7S1*irot_input_y;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ ip[1] = temp1 - temp2;
+
+ temp1=xC7S1*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC1S7*irot_input_y ;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ ip[7] = temp1 + temp2 ;
+
+ // Define inputs to rotation for outputs 3 and 5
+ irot_input_x = id07 - icommon_product1;
+ irot_input_y = id34 - icommon_product2;
+
+ // Apply rotation for outputs 3 and 5.
+ temp1=xC3S5*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC5S3*irot_input_y ;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ ip[3] = temp1 - temp2 ;
+
+
+ temp1=xC5S3*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC3S5*irot_input_y;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ ip[5] = temp1 + temp2;
+
+ // Increment data pointer for next row
+ InputData += short_pitch ;
+ ip += 8;
+ }
+
+ // Performed DCT on rows, now transform the columns
+ ip = InterData;
+ for (loop = 0; loop < 8; loop++)
+ {
+ // Pre calculate some common sums and differences.
+ is07 = ip[0 * 8] + ip[7 * 8];
+ is12 = ip[1 * 8] + ip[2 * 8];
+ is34 = ip[3 * 8] + ip[4 * 8];
+ is56 = ip[5 * 8] + ip[6 * 8];
+
+ id07 = ip[0 * 8] - ip[7 * 8];
+ id12 = ip[1 * 8] - ip[2 * 8];
+ id34 = ip[3 * 8] - ip[4 * 8];
+ id56 = ip[5 * 8] - ip[6 * 8];
+
+ is0734 = is07 + is34;
+ is1256 = is12 + is56;
+
+ // Pre-Calculate some common product terms
+ icommon_product1 = xC4S4*(is12 - is56) ;
+ icommon_product2 = xC4S4*(id12 + id56) ;
+ DOROUND(icommon_product1)
+ DOROUND(icommon_product2)
+ icommon_product1>>=SHIFT_BITS;
+ icommon_product2>>=SHIFT_BITS;
+
+
+ temp1 = xC4S4*(is0734 + is1256) ;
+ temp2 = xC4S4*(is0734 - is1256) ;
+ DOROUND(temp1);
+ DOROUND(temp2);
+ temp1>>=SHIFT_BITS;
+
+ temp2>>=SHIFT_BITS;
+ op[0*8] = (temp1 + FINAL_ROUNDING)>>FINAL_SHIFT;
+ op[4*8] = (temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
+
+ // Define inputs to rotation for outputs 2 and 6
+ irot_input_x = id12 - id56;
+ irot_input_y = is07 - is34;
+
+ // Apply rotation for outputs 2 and 6.
+ temp1=xC6S2*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC2S6*irot_input_y;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ op[2*8] = (temp1 + temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
+
+ temp1=xC6S2*irot_input_y;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC2S6*irot_input_x ;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ op[6*8] = (temp1 -temp2 + FINAL_ROUNDING)>>FINAL_SHIFT ;
+
+ // Define inputs to rotation for outputs 1 and 7
+ irot_input_x = icommon_product1 + id07;
+ irot_input_y = -( id34 + icommon_product2 );
+
+ // Apply rotation for outputs 1 and 7.
+ temp1=xC1S7*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC7S1*irot_input_y;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ op[1*8] = (temp1 - temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
+
+ temp1=xC7S1*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC1S7*irot_input_y ;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ op[7*8] = (temp1 + temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
+
+ // Define inputs to rotation for outputs 3 and 5
+ irot_input_x = id07 - icommon_product1;
+ irot_input_y = id34 - icommon_product2;
+
+ // Apply rotation for outputs 3 and 5.
+ temp1=xC3S5*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC5S3*irot_input_y ;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ op[3*8] = (temp1 - temp2 + FINAL_ROUNDING)>>FINAL_SHIFT ;
+
+
+ temp1=xC5S3*irot_input_x;
+ DOROUND(temp1);
+ temp1>>=SHIFT_BITS;
+ temp2=xC3S5*irot_input_y;
+ DOROUND(temp2);
+ temp2>>=SHIFT_BITS;
+ op[5*8] = (temp1 + temp2 + FINAL_ROUNDING)>>FINAL_SHIFT;
+
+ // Increment data pointer for next column.
+ ip ++;
+ op ++;
+ }
+}
+#else
+
void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
{
int j1, i, j, k;
@@ -106,7 +345,7 @@ void vp8_short_fdct8x8_c(short *block, short *coefs, int pitch)
return;
}
-
+#endif
void vp8_short_fhaar2x2_c(short *input, short *output, int pitch) //pitch = 8
{
@@ -181,52 +420,41 @@ void vp8_short_walsh4x4_c(short *input, short *output, int pitch)
{
int i;
int a1, b1, c1, d1;
- int a2, b2, c2, d2;
short *ip = input;
short *op = output;
-
+ int pitch_short = pitch >>1;
for (i = 0; i < 4; i++)
{
- a1 = ((ip[0] + ip[2]));
- d1 = ((ip[1] + ip[3]));
- c1 = ((ip[1] - ip[3]));
- b1 = ((ip[0] - ip[2]));
-
- op[0] = a1 + d1;
- op[1] = b1 + c1;
- op[2] = b1 - c1;
- op[3] = a1 - d1;
- ip += pitch / 2;
- op += 4;
- }
+ a1 = ip[0 * pitch_short] + ip[3 * pitch_short];
+ b1 = ip[1 * pitch_short] + ip[2 * pitch_short];
+ c1 = ip[1 * pitch_short] - ip[2 * pitch_short];
+ d1 = ip[0 * pitch_short] - ip[3 * pitch_short];
+
+ op[0] = (a1 + b1 + 1)>>1;
+ op[4] = (c1 + d1)>>1;
+ op[8] = (a1 - b1)>>1;
+ op[12]= (d1 - c1)>>1;
+ ip++;
+ op++;
+ }
ip = output;
op = output;
for (i = 0; i < 4; i++)
{
- a1 = ip[0] + ip[8];
- d1 = ip[4] + ip[12];
- c1 = ip[4] - ip[12];
- b1 = ip[0] - ip[8];
-
- a2 = a1 + d1;
- b2 = b1 + c1;
- c2 = b1 - c1;
- d2 = a1 - d1;
-
- a2 += a2<0;
- b2 += b2<0;
- c2 += c2<0;
- d2 += d2<0;
-
- op[0] = (a2+1) >> 2;
- op[4] = (b2+1) >> 2;
- op[8] = (c2+1) >> 2;
- op[12]= (d2+1) >> 2;
+ a1 = ip[0] + ip[3];
+ b1 = ip[1] + ip[2];
+ c1 = ip[1] - ip[2];
+ d1 = ip[0] - ip[3];
- ip++;
- op++;
+ op[0] = (a1 + b1 + 1)>>1;
+ op[1] = (c1 + d1)>>1;
+ op[2] = (a1 - b1)>>1;
+ op[3] = (d1 - c1)>>1;
+
+ ip += 4;
+ op += 4;
}
-}
+} \ No newline at end of file
diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index a044f8cb9..364d6ed55 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -71,22 +71,14 @@ static void adjust_act_zbin( VP8_COMP *cpi, MACROBLOCK *x );
#ifdef MODE_STATS
-unsigned int inter_y_modes[MB_MODE_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-unsigned int inter_uv_modes[VP8_UV_MODES] = {0, 0, 0, 0};
-unsigned int inter_b_modes[B_MODE_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-unsigned int y_modes[VP8_YMODES] = {0, 0, 0, 0, 0, 0};
-unsigned int i8x8_modes[VP8_I8X8_MODES]={0 };
-unsigned int uv_modes[VP8_UV_MODES] = {0, 0, 0, 0};
-unsigned int uv_modes_y[VP8_YMODES][VP8_UV_MODES]=
-{
-{0, 0, 0, 0},
-{0, 0, 0, 0},
-{0, 0, 0, 0},
-{0, 0, 0, 0},
-{0, 0, 0, 0},
-{0, 0, 0, 0}
-};
-unsigned int b_modes[B_MODE_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+unsigned int inter_y_modes[MB_MODE_COUNT];
+unsigned int inter_uv_modes[VP8_UV_MODES];
+unsigned int inter_b_modes[B_MODE_COUNT];
+unsigned int y_modes[VP8_YMODES];
+unsigned int i8x8_modes[VP8_I8X8_MODES];
+unsigned int uv_modes[VP8_UV_MODES];
+unsigned int uv_modes_y[VP8_YMODES][VP8_UV_MODES];
+unsigned int b_modes[B_MODE_COUNT];
#endif
@@ -628,6 +620,23 @@ static void pick_mb_modes (VP8_COMP *cpi,
}
else
{
+ int seg_id;
+
+ if (xd->segmentation_enabled && cpi->seg0_cnt > 0 &&
+ !segfeature_active( xd, 0, SEG_LVL_REF_FRAME ) &&
+ segfeature_active( xd, 1, SEG_LVL_REF_FRAME ) &&
+ check_segref(xd, 1, INTRA_FRAME) +
+ check_segref(xd, 1, LAST_FRAME) +
+ check_segref(xd, 1, GOLDEN_FRAME) +
+ check_segref(xd, 1, ALTREF_FRAME) == 1)
+ {
+ cpi->seg0_progress = (cpi->seg0_idx << 16) / cpi->seg0_cnt;
+ }
+ else
+ {
+ cpi->seg0_progress = (((mb_col & ~1) * 2 + (mb_row & ~1) * cm->mb_cols + i) << 16) / cm->MBs;
+ }
+
*totalrate += vp8cx_pick_mode_inter_macroblock(cpi, x,
recon_yoffset,
recon_uvoffset);
@@ -635,6 +644,26 @@ static void pick_mb_modes (VP8_COMP *cpi,
// Dummy encode, do not do the tokenization
vp8cx_encode_inter_macroblock(cpi, x, tp,
recon_yoffset, recon_uvoffset, 0);
+
+ seg_id = xd->mode_info_context->mbmi.segment_id;
+ if (cpi->mb.e_mbd.segmentation_enabled && seg_id == 0)
+ {
+ cpi->seg0_idx++;
+ }
+ if (!xd->segmentation_enabled ||
+ !segfeature_active( xd, seg_id, SEG_LVL_REF_FRAME ) ||
+ check_segref(xd, seg_id, INTRA_FRAME) +
+ check_segref(xd, seg_id, LAST_FRAME) +
+ check_segref(xd, seg_id, GOLDEN_FRAME) +
+ check_segref(xd, seg_id, ALTREF_FRAME) > 1)
+ {
+ // Get the prediction context and status
+ int pred_flag = get_pred_flag( xd, PRED_REF );
+ int pred_context = get_pred_context( cm, xd, PRED_REF );
+
+ // Count prediction success
+ cpi->ref_pred_count[pred_context][pred_flag]++;
+ }
}
// Keep a copy of the updated left context
@@ -997,6 +1026,8 @@ void init_encode_frame_mb_context(VP8_COMP *cpi)
x->mb_activity_ptr = cpi->mb_activity_map;
x->act_zbin_adj = 0;
+ cpi->seg0_idx = 0;
+ vpx_memset(cpi->ref_pred_count, 0, sizeof(cpi->ref_pred_count));
x->partition_info = x->pi;
@@ -1288,11 +1319,13 @@ void vp8_encode_frame(VP8_COMP *cpi)
else
frame_type = 2;
- if (cpi->rd_prediction_type_threshes[frame_type][1] >
- cpi->rd_prediction_type_threshes[frame_type][0] &&
- cpi->rd_prediction_type_threshes[frame_type][1] >
- cpi->rd_prediction_type_threshes[frame_type][2] &&
- check_dual_ref_flags(cpi))
+ if (frame_type == 3)
+ pred_type = SINGLE_PREDICTION_ONLY;
+ else if (cpi->rd_prediction_type_threshes[frame_type][1] >
+ cpi->rd_prediction_type_threshes[frame_type][0] &&
+ cpi->rd_prediction_type_threshes[frame_type][1] >
+ cpi->rd_prediction_type_threshes[frame_type][2] &&
+ check_dual_ref_flags(cpi))
pred_type = COMP_PREDICTION_ONLY;
else if (cpi->rd_prediction_type_threshes[frame_type][0] >
cpi->rd_prediction_type_threshes[frame_type][1] &&
diff --git a/vp8/encoder/encodemb.c b/vp8/encoder/encodemb.c
index ae8ab8846..81c69d9f8 100644
--- a/vp8/encoder/encodemb.c
+++ b/vp8/encoder/encodemb.c
@@ -239,7 +239,9 @@ void vp8_transform_mbuv_8x8(MACROBLOCK *x)
{
int i;
+#if !CONFIG_INT_8X8FDCT
vp8_clear_system_state();
+#endif
for (i = 16; i < 24; i += 4)
{
@@ -252,9 +254,9 @@ void vp8_transform_mbuv_8x8(MACROBLOCK *x)
void vp8_transform_intra_mby_8x8(MACROBLOCK *x)//changed
{
int i;
-
+#if !CONFIG_INT_8X8FDCT
vp8_clear_system_state();
-
+#endif
for (i = 0; i < 9; i += 8)
{
x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
@@ -279,9 +281,9 @@ void vp8_transform_intra_mby_8x8(MACROBLOCK *x)//changed
void vp8_transform_mb_8x8(MACROBLOCK *x)
{
int i;
-
+#if !CONFIG_INT_8X8FDCT
vp8_clear_system_state();
-
+#endif
for (i = 0; i < 9; i += 8)
{
x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
@@ -312,9 +314,9 @@ void vp8_transform_mb_8x8(MACROBLOCK *x)
void vp8_transform_mby_8x8(MACROBLOCK *x)
{
int i;
-
+#if !CONFIG_INT_8X8FDCT
vp8_clear_system_state();
-
+#endif
for (i = 0; i < 9; i += 8)
{
x->vp8_short_fdct8x8(&x->block[i].src_diff[0],
diff --git a/vp8/encoder/mbgraph.c b/vp8/encoder/mbgraph.c
index ebdb9b504..d2d3b6bdc 100644
--- a/vp8/encoder/mbgraph.c
+++ b/vp8/encoder/mbgraph.c
@@ -502,6 +502,7 @@ void separate_arf_mbs
else
cpi->static_mb_pct = 0;
+ cpi->seg0_cnt = ncnt[0];
vp8_enable_segmentation((VP8_PTR) cpi);
}
else
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 1a174c125..a66e71af4 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -140,7 +140,7 @@ extern int skip_false_count;
#ifdef ENTROPY_STATS
-extern int intra_mode_stats[10][10][10];
+extern int intra_mode_stats[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES];
#endif
#ifdef SPEEDSTATS
@@ -156,13 +156,13 @@ extern unsigned __int64 Sectionbits[500];
#endif
#ifdef MODE_STATS
extern INT64 Sectionbits[500];
-extern int y_modes[VP8_YMODES] ;
-extern int i8x8_modes[VP8_I8X8_MODES];
-extern int uv_modes[VP8_UV_MODES] ;
-extern int uv_modes_y[VP8_YMODES][VP8_UV_MODES];
-extern int b_modes[B_MODE_COUNT];
-extern int inter_y_modes[MB_MODE_COUNT] ;
-extern int inter_uv_modes[VP8_UV_MODES] ;
+extern unsigned int y_modes[VP8_YMODES] ;
+extern unsigned int i8x8_modes[VP8_I8X8_MODES];
+extern unsigned int uv_modes[VP8_UV_MODES] ;
+extern unsigned int uv_modes_y[VP8_YMODES][VP8_UV_MODES];
+extern unsigned int b_modes[B_MODE_COUNT];
+extern unsigned int inter_y_modes[MB_MODE_COUNT] ;
+extern unsigned int inter_uv_modes[VP8_UV_MODES] ;
extern unsigned int inter_b_modes[B_MODE_COUNT];
#endif
@@ -760,6 +760,14 @@ void vp8_set_speed_features(VP8_COMP *cpi)
sf->thresh_mult[THR_V_PRED ] = 1000;
sf->thresh_mult[THR_H_PRED ] = 1000;
+#if CONFIG_NEWINTRAMODES
+ sf->thresh_mult[THR_D45_PRED ] = 1000;
+ sf->thresh_mult[THR_D135_PRED] = 1000;
+ sf->thresh_mult[THR_D117_PRED] = 1000;
+ sf->thresh_mult[THR_D153_PRED] = 1000;
+ sf->thresh_mult[THR_D27_PRED ] = 1000;
+ sf->thresh_mult[THR_D63_PRED ] = 1000;
+#endif
sf->thresh_mult[THR_B_PRED ] = 2000;
sf->thresh_mult[THR_I8X8_PRED] = 2000;
sf->thresh_mult[THR_TM ] = 1000;
@@ -803,6 +811,14 @@ void vp8_set_speed_features(VP8_COMP *cpi)
sf->thresh_mult[THR_NEARMV ] = 0;
sf->thresh_mult[THR_V_PRED ] = 1000;
sf->thresh_mult[THR_H_PRED ] = 1000;
+#if CONFIG_NEWINTRAMODES
+ sf->thresh_mult[THR_D45_PRED ] = 1000;
+ sf->thresh_mult[THR_D135_PRED] = 1000;
+ sf->thresh_mult[THR_D117_PRED] = 1000;
+ sf->thresh_mult[THR_D153_PRED] = 1000;
+ sf->thresh_mult[THR_D27_PRED ] = 1000;
+ sf->thresh_mult[THR_D63_PRED ] = 1000;
+#endif
sf->thresh_mult[THR_B_PRED ] = 2500;
sf->thresh_mult[THR_I8X8_PRED] = 2500;
sf->thresh_mult[THR_TM ] = 1000;
@@ -881,6 +897,14 @@ void vp8_set_speed_features(VP8_COMP *cpi)
sf->thresh_mult[THR_TM ] = 1500;
sf->thresh_mult[THR_V_PRED ] = 1500;
sf->thresh_mult[THR_H_PRED ] = 1500;
+#if CONFIG_NEWINTRAMODES
+ sf->thresh_mult[THR_D45_PRED ] = 1500;
+ sf->thresh_mult[THR_D135_PRED] = 1500;
+ sf->thresh_mult[THR_D117_PRED] = 1500;
+ sf->thresh_mult[THR_D153_PRED] = 1500;
+ sf->thresh_mult[THR_D27_PRED ] = 1500;
+ sf->thresh_mult[THR_D63_PRED ] = 1500;
+#endif
sf->thresh_mult[THR_B_PRED ] = 5000;
sf->thresh_mult[THR_I8X8_PRED] = 5000;
@@ -939,6 +963,14 @@ void vp8_set_speed_features(VP8_COMP *cpi)
sf->thresh_mult[THR_TM ] = 2000;
sf->thresh_mult[THR_V_PRED ] = 2000;
sf->thresh_mult[THR_H_PRED ] = 2000;
+#if CONFIG_NEWINTRAMODES
+ sf->thresh_mult[THR_D45_PRED ] = 2000;
+ sf->thresh_mult[THR_D135_PRED] = 2000;
+ sf->thresh_mult[THR_D117_PRED] = 2000;
+ sf->thresh_mult[THR_D153_PRED] = 2000;
+ sf->thresh_mult[THR_D27_PRED ] = 2000;
+ sf->thresh_mult[THR_D63_PRED ] = 2000;
+#endif
sf->thresh_mult[THR_B_PRED ] = 7500;
sf->thresh_mult[THR_I8X8_PRED] = 7500;
@@ -1719,6 +1751,16 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
#ifdef ENTROPY_STATS
init_context_counters();
#endif
+#ifdef MODE_STATS
+ vp8_zero(y_modes);
+ vp8_zero(i8x8_modes);
+ vp8_zero(uv_modes);
+ vp8_zero(uv_modes_y);
+ vp8_zero(b_modes);
+ vp8_zero(inter_y_modes);
+ vp8_zero(inter_uv_modes);
+ vp8_zero(inter_b_modes);
+#endif
/*Initialize the feed-forward activity masking.*/
cpi->activity_avg = 90<<12;
@@ -2006,32 +2048,49 @@ void vp8_remove_compressor(VP8_PTR *ptr)
sprintf(modes_stats_file, "modes_q%03d.stt",cpi->common.base_qindex);
f = fopen(modes_stats_file, "w");
fprintf(f, "intra_mode in Intra Frames:\n");
- fprintf(f, "Y: %8d, %8d, %8d, %8d, %8d, %8d\n", y_modes[0], y_modes[1], y_modes[2], y_modes[3], y_modes[4], y_modes[5]);
- fprintf(f, "I8:%8d, %8d, %8d, %8d\n", i8x8_modes[0], i8x8_modes[1], i8x8_modes[2], i8x8_modes[3]);
- fprintf(f, "UV:%8d, %8d, %8d, %8d\n", uv_modes[0], uv_modes[1], uv_modes[2], uv_modes[3]);
- fprintf(f, "KeyFrame Y-UV:\n");
{
int i;
+ fprintf(f, "Y: ");
+ for (i=0;i<VP8_YMODES;i++) fprintf(f, " %8d,", y_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "I8: ");
+ for (i=0;i<VP8_I8X8_MODES;i++) fprintf(f, " %8d,", i8x8_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "UV: ");
+ for (i=0;i<VP8_UV_MODES;i++) fprintf(f, " %8d,", uv_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i, j;
+ fprintf(f, "KeyFrame Y-UV:\n");
for(i=0;i<VP8_YMODES;i++)
{
- fprintf(f, "%2d:%8d, %8d, %8d, %8d\n",i,uv_modes_y[i][0],
- uv_modes_y[i][1], uv_modes_y[i][2], uv_modes_y[i][3]);
+ fprintf(f, "%2d:", i);
+ for (j=0; j<VP8_UV_MODES;j++) fprintf(f, "%8d, ",uv_modes_y[i][j]);
+ fprintf(f, "\n");
}
}
- fprintf(f, "Inter Y-UV:\n");
{
- int i;
+ int i, j;
+ fprintf(f, "Inter Y-UV:\n");
for(i=0;i<VP8_YMODES;i++)
{
- fprintf(f, "%2d:%8d, %8d, %8d, %8d\n",i,cpi->y_uv_mode_count[i][0],
- cpi->y_uv_mode_count[i][1], cpi->y_uv_mode_count[i][2], cpi->y_uv_mode_count[i][3]);
+ fprintf(f, "%2d:", i);
+ for (j=0; j<VP8_UV_MODES;j++) fprintf(f, "%8d, ",cpi->y_uv_mode_count[i][j]);
+ fprintf(f, "\n");
}
}
- fprintf(f, "B: ");
{
int i;
- for (i = 0; i < 10; i++)
+ fprintf(f, "B: ");
+ for (i = 0; i < VP8_BINTRAMODES; i++)
fprintf(f, "%8d, ", b_modes[i]);
fprintf(f, "\n");
@@ -2039,23 +2098,23 @@ void vp8_remove_compressor(VP8_PTR *ptr)
}
fprintf(f, "Modes in Inter Frames:\n");
- fprintf(f,
- "Y: %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d, %8d\n",
- inter_y_modes[0], inter_y_modes[1], inter_y_modes[2],
- inter_y_modes[3], inter_y_modes[4], inter_y_modes[5],
- inter_y_modes[6], inter_y_modes[7], inter_y_modes[8],
- inter_y_modes[9], inter_y_modes[10]);
- fprintf(f, "UV:%8d, %8d, %8d, %8d\n", inter_uv_modes[0],
- inter_uv_modes[1], inter_uv_modes[2], inter_uv_modes[3]);
- fprintf(f, "B: ");
{
int i;
-
- for (i = 0; i < 15; i++)
- fprintf(f, "%8d, ", inter_b_modes[i]);
-
+ fprintf(f, "Y: ");
+ for (i=0;i<MB_MODE_COUNT;i++) fprintf(f, " %8d,", inter_y_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "UV: ");
+ for (i=0;i<VP8_UV_MODES;i++) fprintf(f, " %8d,", inter_uv_modes[i]);
+ fprintf(f, "\n");
+ }
+ {
+ int i;
+ fprintf(f, "B: ");
+ for (i = 0; i < B_MODE_COUNT; i++) fprintf(f, "%8d, ", inter_b_modes[i]);
fprintf(f, "\n");
-
}
fprintf(f, "P:%8d, %8d, %8d, %8d\n", count_mb_seg[0], count_mb_seg[1], count_mb_seg[2], count_mb_seg[3]);
fprintf(f, "PB:%8d, %8d, %8d, %8d\n", inter_b_modes[LEFT4X4], inter_b_modes[ABOVE4X4], inter_b_modes[ZERO4X4], inter_b_modes[NEW4X4]);
@@ -2082,7 +2141,7 @@ void vp8_remove_compressor(VP8_PTR *ptr)
fprintf(fmode, " {");
- for (k = 0; k < 10; k++)
+ for (k = 0; k < VP8_BINTRAMODES; k++)
{
if (!intra_mode_stats[i][j][k])
fprintf(fmode, " %5d, ", 1);
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index 93a445cba..feefc249a 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -41,7 +41,12 @@
#define AF_THRESH 25
#define AF_THRESH2 100
#define ARF_DECAY_THRESH 12
+
+#if CONFIG_NEWINTRAMODES
+#define MAX_MODES 42
+#else
#define MAX_MODES 36
+#endif
#define MIN_THRESHMULT 32
#define MAX_THRESHMULT 512
@@ -173,38 +178,46 @@ typedef enum
THR_V_PRED = 10,
THR_H_PRED = 11,
- THR_TM = 12,
+#if CONFIG_NEWINTRAMODES
+ THR_D45_PRED,
+ THR_D135_PRED,
+ THR_D117_PRED,
+ THR_D153_PRED,
+ THR_D27_PRED,
+ THR_D63_PRED,
+#endif
+ THR_TM,
- THR_NEWMV = 13,
- THR_NEWG = 14,
- THR_NEWA = 15,
+ THR_NEWMV,
+ THR_NEWG,
+ THR_NEWA,
- THR_SPLITMV = 16,
- THR_SPLITG = 17,
- THR_SPLITA = 18,
+ THR_SPLITMV,
+ THR_SPLITG,
+ THR_SPLITA,
- THR_B_PRED = 19,
- THR_I8X8_PRED = 20,
+ THR_B_PRED,
+ THR_I8X8_PRED,
- THR_COMP_ZEROLG = 21,
- THR_COMP_NEARESTLG = 22,
- THR_COMP_NEARLG = 23,
+ THR_COMP_ZEROLG,
+ THR_COMP_NEARESTLG,
+ THR_COMP_NEARLG,
- THR_COMP_ZEROLA = 24,
- THR_COMP_NEARESTLA = 25,
- THR_COMP_NEARLA = 26,
+ THR_COMP_ZEROLA,
+ THR_COMP_NEARESTLA,
+ THR_COMP_NEARLA,
- THR_COMP_ZEROGA = 27,
- THR_COMP_NEARESTGA = 28,
- THR_COMP_NEARGA = 29,
+ THR_COMP_ZEROGA,
+ THR_COMP_NEARESTGA,
+ THR_COMP_NEARGA,
- THR_COMP_NEWLG = 30,
- THR_COMP_NEWLA = 31,
- THR_COMP_NEWGA = 32,
+ THR_COMP_NEWLG,
+ THR_COMP_NEWLA,
+ THR_COMP_NEWGA,
- THR_COMP_SPLITLG = 33,
- THR_COMP_SPLITLA = 34,
- THR_COMP_SPLITGA = 35,
+ THR_COMP_SPLITLG,
+ THR_COMP_SPLITLA,
+ THR_COMP_SPLITGA,
}
THR_MODES;
@@ -472,6 +485,8 @@ typedef struct VP8_COMP
MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
int mbgraph_n_frames; // number of frames filled in the above
int static_mb_pct; // % forced skip mbs by segmentation
+ int seg0_progress, seg0_idx, seg0_cnt;
+ int ref_pred_count[3][2];
int decimation_factor;
int decimation_count;
diff --git a/vp8/encoder/ratectrl.c b/vp8/encoder/ratectrl.c
index f51fe6fb2..864dd6573 100644
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -33,13 +33,13 @@ extern const MV_REFERENCE_FRAME vp8_ref_frame_order[MAX_MODES];
#ifdef MODE_STATS
-extern int y_modes[VP8_YMODES];
-extern int uv_modes[VP8_UV_MODES];
-extern int b_modes[B_MODE_COUNT];
+extern unsigned int y_modes[VP8_YMODES];
+extern unsigned int uv_modes[VP8_UV_MODES];
+extern unsigned int b_modes[B_MODE_COUNT];
-extern int inter_y_modes[MB_MODE_COUNT];
-extern int inter_uv_modes[VP8_UV_MODES];
-extern int inter_b_modes[B_MODE_COUNT];
+extern unsigned int inter_y_modes[MB_MODE_COUNT];
+extern unsigned int inter_uv_modes[VP8_UV_MODES];
+extern unsigned int inter_b_modes[B_MODE_COUNT];
#endif
// Bits Per MB at different Q (Multiplied by 512)
diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c
index cceeb7617..0caa4c73d 100644
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -100,6 +100,14 @@ const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES] =
V_PRED,
H_PRED,
+#if CONFIG_NEWINTRAMODES
+ D45_PRED,
+ D135_PRED,
+ D117_PRED,
+ D153_PRED,
+ D27_PRED,
+ D63_PRED,
+#endif
TM_PRED,
NEWMV,
@@ -154,6 +162,14 @@ const MV_REFERENCE_FRAME vp8_ref_frame_order[MAX_MODES] =
INTRA_FRAME,
INTRA_FRAME,
+#if CONFIG_NEWINTRAMODES
+ INTRA_FRAME,
+ INTRA_FRAME,
+ INTRA_FRAME,
+ INTRA_FRAME,
+ INTRA_FRAME,
+ INTRA_FRAME,
+#endif
INTRA_FRAME,
LAST_FRAME,
@@ -191,9 +207,13 @@ const MV_REFERENCE_FRAME vp8_ref_frame_order[MAX_MODES] =
const MV_REFERENCE_FRAME vp8_second_ref_frame_order[MAX_MODES] =
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+#if CONFIG_NEWINTRAMODES
+ 0, 0,
+ 0, 0,
+ 0, 0,
+#endif
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* compound prediction modes */
GOLDEN_FRAME,
@@ -898,7 +918,6 @@ static int rd_pick_intra4x4block(
// Do we need to do this for mode2 also?
if (mode==B_LD_PRED || mode==B_VL_PRED)
continue;
-
rate = bmode_costs[mode];
#if CONFIG_COMP_INTRA_PRED
@@ -2562,7 +2581,66 @@ static void set_i8x8_block_modes(MACROBLOCK *x, int modes[2][4])
}
}
-void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, unsigned int * ref_costs )
+extern void calc_ref_probs( int * count, vp8_prob * probs );
+static void estimate_curframe_refprobs(VP8_COMP *cpi, vp8_prob mod_refprobs[3], int pred_ref)
+{
+ int norm_cnt[MAX_REF_FRAMES];
+ const int *const rfct = cpi->count_mb_ref_frame_usage;
+ int intra_count = rfct[INTRA_FRAME];
+ int last_count = rfct[LAST_FRAME];
+ int gf_count = rfct[GOLDEN_FRAME];
+ int arf_count = rfct[ALTREF_FRAME];
+
+ // Work out modified reference frame probabilities to use where prediction
+ // of the reference frame fails
+ if (pred_ref == INTRA_FRAME)
+ {
+ norm_cnt[0] = 0;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs( norm_cnt, mod_refprobs );
+ mod_refprobs[0] = 0; // This branch implicit
+ }
+ else if (pred_ref == LAST_FRAME)
+ {
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = 0;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs( norm_cnt, mod_refprobs);
+ mod_refprobs[1] = 0; // This branch implicit
+ }
+ else if (pred_ref == GOLDEN_FRAME)
+ {
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = 0;
+ norm_cnt[3] = arf_count;
+ calc_ref_probs( norm_cnt, mod_refprobs );
+ mod_refprobs[2] = 0; // This branch implicit
+ }
+ else
+ {
+ norm_cnt[0] = intra_count;
+ norm_cnt[1] = last_count;
+ norm_cnt[2] = gf_count;
+ norm_cnt[3] = 0;
+ calc_ref_probs( norm_cnt, mod_refprobs );
+ mod_refprobs[2] = 0; // This branch implicit
+ }
+}
+
+static __inline unsigned weighted_cost(vp8_prob *tab0, vp8_prob *tab1, int idx, int val, int weight)
+{
+ unsigned cost0 = tab0[idx] ? vp8_cost_bit(tab0[idx], val) : 0;
+ unsigned cost1 = tab1[idx] ? vp8_cost_bit(tab1[idx], val) : 0;
+ // weight is 16-bit fixed point, so this basically calculates:
+ // 0.5 + weight * cost1 + (1.0 - weight) * cost0
+ return (0x8000 + weight * cost1 + (0x10000 - weight) * cost0) >> 16;
+}
+
+static void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, int segment_id, unsigned int * ref_costs )
{
VP8_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &cpi->mb.e_mbd;
@@ -2571,47 +2649,87 @@ void vp8_estimate_ref_frame_costs(VP8_COMP *cpi, unsigned int * ref_costs )
unsigned int cost;
int pred_ref ;
int pred_flag;
+ int pred_ctx ;
int i;
+ int tot_count;
- vp8_prob pred_prob;
+ vp8_prob pred_prob, new_pred_prob;
+ int seg_ref_active;
+ int seg_ref_count = 0;
+ seg_ref_active = segfeature_active( xd,
+ segment_id,
+ SEG_LVL_REF_FRAME );
+
+ if ( seg_ref_active )
+ {
+ seg_ref_count = check_segref( xd, segment_id, INTRA_FRAME ) +
+ check_segref( xd, segment_id, LAST_FRAME ) +
+ check_segref( xd, segment_id, GOLDEN_FRAME ) +
+ check_segref( xd, segment_id, ALTREF_FRAME );
+ }
// Get the predicted reference for this mb
pred_ref = get_pred_ref( cm, xd );
- // Get the context probability for the prediction flag
+ // Get the context probability for the prediction flag (based on last frame)
pred_prob = get_pred_prob( cm, xd, PRED_REF );
+ // Predict probability for current frame based on stats so far
+ pred_ctx = get_pred_context(cm, xd, PRED_REF);
+ tot_count = cpi->ref_pred_count[pred_ctx][0] + cpi->ref_pred_count[pred_ctx][1];
+ if ( tot_count )
+ {
+ new_pred_prob =
+ ( cpi->ref_pred_count[pred_ctx][0] * 255 + (tot_count >> 1)) / tot_count;
+ new_pred_prob += !new_pred_prob;
+ }
+ else
+ new_pred_prob = 128;
+
// Get the set of probabilities to use if prediction fails
mod_refprobs = cm->mod_refprobs[pred_ref];
// For each possible selected reference frame work out a cost.
- // TODO: correct handling of costs if segment indicates only a subset of
- // reference frames are allowed... though mostly this should come out
- // in the wash.
for ( i = 0; i < MAX_REF_FRAMES; i++ )
{
- pred_flag = (i == pred_ref);
-
- // Get the prediction for the current mb
- cost = vp8_cost_bit( pred_prob, pred_flag );
-
- // for incorrectly predicted cases
- if ( ! pred_flag )
+ if (seg_ref_active && seg_ref_count == 1)
+ {
+ cost = 0;
+ }
+ else
{
- if ( mod_refprobs[0] )
- cost += vp8_cost_bit( mod_refprobs[0], (i != INTRA_FRAME) );
+ pred_flag = (i == pred_ref);
+
+ // Get the prediction for the current mb
+ cost = weighted_cost(&pred_prob, &new_pred_prob, 0,
+ pred_flag, cpi->seg0_progress);
+ if (cost > 1024) cost = 768; // i.e. account for 4 bits max.
- // Inter coded
- if (i != INTRA_FRAME)
+ // for incorrectly predicted cases
+ if ( ! pred_flag )
{
- if ( mod_refprobs[1] )
- cost += vp8_cost_bit( mod_refprobs[1], (i != LAST_FRAME) );
+ vp8_prob curframe_mod_refprobs[3];
- if (i != LAST_FRAME)
+ if (cpi->seg0_progress)
+ {
+ estimate_curframe_refprobs(cpi, curframe_mod_refprobs, pred_ref);
+ }
+ else
{
- if ( mod_refprobs[2] )
- cost += vp8_cost_bit( mod_refprobs[2],
- (i != GOLDEN_FRAME));
+ vpx_memset(curframe_mod_refprobs, 0, sizeof(curframe_mod_refprobs));
+ }
+
+ cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 0,
+ (i != INTRA_FRAME), cpi->seg0_progress);
+ if (i != INTRA_FRAME)
+ {
+ cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 1,
+ (i != LAST_FRAME), cpi->seg0_progress);
+ if (i != LAST_FRAME)
+ {
+ cost += weighted_cost(mod_refprobs, curframe_mod_refprobs, 2,
+ (i != GOLDEN_FRAME), cpi->seg0_progress);
+ }
}
}
}
@@ -2800,7 +2918,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
// Get estimates of reference frame costs for each reference frame
// that depend on the current prediction etc.
- vp8_estimate_ref_frame_costs( cpi, ref_costs );
+ vp8_estimate_ref_frame_costs( cpi, segment_id, ref_costs );
for (mode_index = 0; mode_index < MAX_MODES; mode_index++)
{
@@ -3017,6 +3135,14 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
vp8_cost_bit( get_pred_prob( cm, xd, PRED_COMP ), 0 );
}
break;
+#if CONFIG_NEWINTRAMODES
+ case D45_PRED:
+ case D135_PRED:
+ case D117_PRED:
+ case D153_PRED:
+ case D27_PRED:
+ case D63_PRED:
+#endif
case DC_PRED:
case V_PRED:
case H_PRED: