summaryrefslogtreecommitdiff
path: root/vp8
diff options
context:
space:
mode:
Diffstat (limited to 'vp8')
-rw-r--r--vp8/common/entropy.h5
-rw-r--r--vp8/common/idctllm.c73
-rw-r--r--vp8/decoder/decodframe.c62
-rw-r--r--vp8/encoder/bitstream.c102
-rw-r--r--vp8/encoder/dct.c302
-rw-r--r--vp8/encoder/encodeframe.c12
-rw-r--r--vp8/encoder/encodemb.c14
7 files changed, 410 insertions, 160 deletions
diff --git a/vp8/common/entropy.h b/vp8/common/entropy.h
index 42de3ea52..4c42d455d 100644
--- a/vp8/common/entropy.h
+++ b/vp8/common/entropy.h
@@ -91,8 +91,9 @@ extern DECLARE_ALIGNED(64, const unsigned char, vp8_coef_bands_8x8[64]);
#endif
#if CONFIG_NEWUPDATE
-#define SUBEXP_PARAM 1 /* Subexponential code parameter */
-#define COEFUPDATETYPE 2 /* coef update type to use (1/2/3) */
+#define SUBEXP_PARAM 2 /* Subexponential code parameter */
+#define MODULUS_PARAM 21 /* Modulus parameter */
+#define COEFUPDATETYPE 2 /* coef update type to use (1/2/3) */
#endif
diff --git a/vp8/common/idctllm.c b/vp8/common/idctllm.c
index f0536d5e4..b2523ba7c 100644
--- a/vp8/common/idctllm.c
+++ b/vp8/common/idctllm.c
@@ -138,65 +138,60 @@ void vp8_short_inv_walsh4x4_c(short *input, short *output)
{
int i;
int a1, b1, c1, d1;
- int a2, b2, c2, d2;
short *ip = input;
short *op = output;
for (i = 0; i < 4; i++)
{
- a1 = ip[0] + ip[12];
- b1 = ip[4] + ip[8];
- c1 = ip[4] - ip[8];
- d1 = ip[0] - ip[12];
+ a1 = ((ip[0] + ip[3]));
+ b1 = ((ip[1] + ip[2]));
+ c1 = ((ip[1] - ip[2]));
+ d1 = ((ip[0] - ip[3]));
- op[0] = a1 + b1;
- op[4] = c1 + d1;
- op[8] = a1 - b1;
- op[12] = d1 - c1;
- 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;
}
ip = output;
op = output;
-
for (i = 0; i < 4; i++)
{
- a1 = ip[0] + ip[3];
- b1 = ip[1] + ip[2];
- c1 = ip[1] - ip[2];
- d1 = ip[0] - ip[3];
-
- a2 = a1 + b1;
- b2 = c1 + d1;
- c2 = a1 - b1;
- d2 = d1 - c1;
-
- op[0] = (a2 + 1) >> 2;
- op[1] = (b2 + 1) >> 2;
- op[2] = (c2 + 1) >> 2;
- op[3] = (d2 + 1) >> 2;
-
- ip += 4;
- op += 4;
+ a1 = ip[0] + ip[12];
+ b1 = ip[4] + ip[8];
+ c1 = ip[4] - ip[8];
+ d1 = ip[0] - ip[12];
+ op[0] = (a1 + b1 + 1)>>1;
+ op[4] = (c1 + d1)>>1;
+ op[8] = (a1 - b1)>>1;
+ op[12]= (d1 - c1)>>1;
+ ip++;
+ op++;
}
}
-void vp8_short_inv_walsh4x4_1_c(short *input, short *output)
+void vp8_short_inv_walsh4x4_1_c(short *in, short *out)
{
int i;
- int a1;
- short *op = output;
+ short tmp[4];
+ short *ip = in;
+ short *op = tmp;
- a1 = (input[0] + 1 )>> 2;
+ op[0] =(ip[0]+ 1)>>1;
+ op[1] = op[2] = op[3] = (ip[0]>>1);
- for (i = 0; i < 4; i++)
+ ip = tmp;
+ op = out;
+ for(i = 0; i<4; i++)
{
- op[0] = a1;
- op[1] = a1;
- op[2] = a1;
- op[3] = a1;
- op += 4;
+ op[0] =(ip[0]+ 1)>>1;
+ op[4] = op[8] = op[12] = (ip[0]>>1);
+ ip ++;
+ op ++;
}
}
diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
index 877653290..d375cdd52 100644
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -45,13 +45,29 @@ int dec_debug = 0;
#endif
#if CONFIG_NEWUPDATE
+
+static int merge_index(int v, int n, int modulus)
+{
+ int max1 = (n-1 - modulus/2)/modulus + 1;
+ if (v < max1) v = v * modulus + modulus/2;
+ else
+ {
+ int w;
+ v -= max1;
+ w = v;
+ v += (v + modulus-modulus/2)/modulus;
+ while (v%modulus == modulus/2 ||
+ w != v - (v + modulus-modulus/2)/modulus) v++;
+ }
+ return v;
+}
+
static int inv_remap_prob(int v, int m)
{
const int n = 256;
- int i;
- //if (v <= n - 2 - s) v += s; else v = n - 2 - v;
- //v = ((v&240)>>4) | ((v&15)<<4);
- v = (v%15)*17 + (v/15);
+ const int modulus = MODULUS_PARAM;
+ int i, w;
+ v = merge_index(v, n-1, modulus);
if ((m<<1)<=n) {
i = inv_recenter_nonneg(v+1, m);
} else {
@@ -59,6 +75,12 @@ static int inv_remap_prob(int v, int m)
}
return i;
}
+
+static vp8_prob read_prob_diff_update(vp8_reader *const bc, int oldp)
+{
+ int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
+ return (vp8_prob)inv_remap_prob(delp, oldp);
+}
#endif
void vp8cx_init_de_quantizer(VP8D_COMP *pbi)
@@ -811,11 +833,7 @@ static void read_coef_probs3(VP8D_COMP *pbi)
{
vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
int u = vp8_read(bc, vp8_coef_update_probs [i][j][k][l]);
- if (u)
- {
- int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
- *p = (vp8_prob)inv_remap_prob(delp, *p);
- }
+ if (u) *p = read_prob_diff_update(bc, *p);
}
}
}
@@ -839,11 +857,7 @@ static void read_coef_probs3(VP8D_COMP *pbi)
{
vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
int u = vp8_read(bc, vp8_coef_update_probs_8x8 [i][j][k][l]);
- if (u)
- {
- int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
- *p = (vp8_prob)inv_remap_prob(delp, *p);
- }
+ if (u) *p = read_prob_diff_update(bc, *p);
}
}
}
@@ -874,11 +888,7 @@ static void read_coef_probs2(VP8D_COMP *pbi)
{
vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l;
int u = vp8_read(bc, vp8_coef_update_probs [i][j][k][l]);
- if (u)
- {
- int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
- *p = (vp8_prob)inv_remap_prob(delp, *p);
- }
+ if (u) *p = read_prob_diff_update(bc, *p);
}
}
}
@@ -902,11 +912,7 @@ static void read_coef_probs2(VP8D_COMP *pbi)
vp8_prob *const p = pc->fc.coef_probs_8x8 [i][j][k] + l;
int u = vp8_read(bc, vp8_coef_update_probs_8x8 [i][j][k][l]);
- if (u)
- {
- int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
- *p = (vp8_prob)inv_remap_prob(delp, *p);
- }
+ if (u) *p = read_prob_diff_update(bc, *p);
}
}
}
@@ -945,10 +951,7 @@ static void read_coef_probs(VP8D_COMP *pbi)
if (vp8_read(bc, vp8_coef_update_probs [i][j][k][l]))
{
#if CONFIG_NEWUPDATE
- int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
- //printf("delp = %d/%d", *p, delp);
- *p = (vp8_prob)inv_remap_prob(delp, *p);
- //printf("/%d\n", *p);
+ *p = read_prob_diff_update(bc, *p);
#else
*p = (vp8_prob)vp8_read_literal(bc, 8);
#endif
@@ -982,8 +985,7 @@ static void read_coef_probs(VP8D_COMP *pbi)
if (vp8_read(bc, vp8_coef_update_probs_8x8 [i][j][k][l]))
{
#if CONFIG_NEWUPDATE
- int delp = vp8_decode_term_subexp(bc, SUBEXP_PARAM, 255);
- *p = (vp8_prob)inv_remap_prob(delp, *p);
+ *p = read_prob_diff_update(bc, *p);
#else
*p = (vp8_prob)vp8_read_literal(bc, 8);
#endif
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index a96a75e06..4918e2cb2 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -64,19 +64,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(
@@ -329,22 +351,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 +382,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)
{
@@ -1519,7 +1546,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 +1585,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 +1601,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 +1634,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 +1676,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 +1696,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 +1729,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 +1781,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 +1796,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 +1827,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 +1871,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 +1891,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 +1943,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 +2015,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 +2038,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 +2089,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 +2145,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 +2165,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/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..ec3e1602c 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -1288,11 +1288,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],