Give more flexibility to the predictor generating macro.

Change-Id: Ia651afa8322cb5c5ae87128340d05245c0f6a900
This commit is contained in:
Vincent Rabaud 2016-12-02 18:51:47 +01:00 committed by James Zern
parent 28e0bb7088
commit 2e6cb6f34e
4 changed files with 60 additions and 60 deletions

View File

@ -167,20 +167,20 @@ static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {
return pred; return pred;
} }
GENERATE_PREDICTOR_ADD(0) GENERATE_PREDICTOR_ADD(Predictor0, PredictorAdd0)
GENERATE_PREDICTOR_ADD(1) GENERATE_PREDICTOR_ADD(Predictor1, PredictorAdd1)
GENERATE_PREDICTOR_ADD(2) GENERATE_PREDICTOR_ADD(Predictor2, PredictorAdd2)
GENERATE_PREDICTOR_ADD(3) GENERATE_PREDICTOR_ADD(Predictor3, PredictorAdd3)
GENERATE_PREDICTOR_ADD(4) GENERATE_PREDICTOR_ADD(Predictor4, PredictorAdd4)
GENERATE_PREDICTOR_ADD(5) GENERATE_PREDICTOR_ADD(Predictor5, PredictorAdd5)
GENERATE_PREDICTOR_ADD(6) GENERATE_PREDICTOR_ADD(Predictor6, PredictorAdd6)
GENERATE_PREDICTOR_ADD(7) GENERATE_PREDICTOR_ADD(Predictor7, PredictorAdd7)
GENERATE_PREDICTOR_ADD(8) GENERATE_PREDICTOR_ADD(Predictor8, PredictorAdd8)
GENERATE_PREDICTOR_ADD(9) GENERATE_PREDICTOR_ADD(Predictor9, PredictorAdd9)
GENERATE_PREDICTOR_ADD(10) GENERATE_PREDICTOR_ADD(Predictor10, PredictorAdd10)
GENERATE_PREDICTOR_ADD(11) GENERATE_PREDICTOR_ADD(Predictor11, PredictorAdd11)
GENERATE_PREDICTOR_ADD(12) GENERATE_PREDICTOR_ADD(Predictor12, PredictorAdd12)
GENERATE_PREDICTOR_ADD(13) GENERATE_PREDICTOR_ADD(Predictor13, PredictorAdd13)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -181,24 +181,24 @@ uint32_t VP8LSubPixels(uint32_t a, uint32_t b) {
// The predictor is added to the output pixel (which // The predictor is added to the output pixel (which
// is therefore considered as a residual) to get the final prediction. // is therefore considered as a residual) to get the final prediction.
#define GENERATE_PREDICTOR_ADD(X) \ #define GENERATE_PREDICTOR_ADD(PREDICTOR, PREDICTOR_ADD) \
static void PredictorAdd##X(const uint32_t* in, const uint32_t* upper, \ static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \
int num_pixels, uint32_t* out) { \ int num_pixels, uint32_t* out) { \
int x; \ int x; \
for (x = 0; x < num_pixels; ++x) { \ for (x = 0; x < num_pixels; ++x) { \
const uint32_t pred = VP8LPredictors[(X)](out[x - 1], upper + x); \ const uint32_t pred = (PREDICTOR)(out[x - 1], upper + x); \
out[x] = VP8LAddPixels(in[x], pred); \ out[x] = VP8LAddPixels(in[x], pred); \
} \ } \
} }
// It subtracts the prediction from the input pixel and stores the residual // It subtracts the prediction from the input pixel and stores the residual
// in the output pixel. // in the output pixel.
#define GENERATE_PREDICTOR_SUB(X) \ #define GENERATE_PREDICTOR_SUB(PREDICTOR, PREDICTOR_SUB) \
static void PredictorSub##X(const uint32_t* in, const uint32_t* upper, \ static void PREDICTOR_SUB(const uint32_t* in, const uint32_t* upper, \
int num_pixels, uint32_t* out) { \ int num_pixels, uint32_t* out) { \
int x; \ int x; \
for (x = 0; x < num_pixels; ++x) { \ for (x = 0; x < num_pixels; ++x) { \
const uint32_t pred = VP8LPredictors[(X)](in[x - 1], upper + x); \ const uint32_t pred = (PREDICTOR)(in[x - 1], upper + x); \
out[x] = VP8LSubPixels(in[x], pred); \ out[x] = VP8LSubPixels(in[x], pred); \
} \ } \
} }

View File

@ -665,20 +665,20 @@ static void HistogramAdd(const VP8LHistogram* const a,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
GENERATE_PREDICTOR_SUB(0) GENERATE_PREDICTOR_SUB(VP8LPredictors[0], PredictorSub0)
GENERATE_PREDICTOR_SUB(1) GENERATE_PREDICTOR_SUB(VP8LPredictors[1], PredictorSub1)
GENERATE_PREDICTOR_SUB(2) GENERATE_PREDICTOR_SUB(VP8LPredictors[2], PredictorSub2)
GENERATE_PREDICTOR_SUB(3) GENERATE_PREDICTOR_SUB(VP8LPredictors[3], PredictorSub3)
GENERATE_PREDICTOR_SUB(4) GENERATE_PREDICTOR_SUB(VP8LPredictors[4], PredictorSub4)
GENERATE_PREDICTOR_SUB(5) GENERATE_PREDICTOR_SUB(VP8LPredictors[5], PredictorSub5)
GENERATE_PREDICTOR_SUB(6) GENERATE_PREDICTOR_SUB(VP8LPredictors[6], PredictorSub6)
GENERATE_PREDICTOR_SUB(7) GENERATE_PREDICTOR_SUB(VP8LPredictors[7], PredictorSub7)
GENERATE_PREDICTOR_SUB(8) GENERATE_PREDICTOR_SUB(VP8LPredictors[8], PredictorSub8)
GENERATE_PREDICTOR_SUB(9) GENERATE_PREDICTOR_SUB(VP8LPredictors[9], PredictorSub9)
GENERATE_PREDICTOR_SUB(10) GENERATE_PREDICTOR_SUB(VP8LPredictors[10], PredictorSub10)
GENERATE_PREDICTOR_SUB(11) GENERATE_PREDICTOR_SUB(VP8LPredictors[11], PredictorSub11)
GENERATE_PREDICTOR_SUB(12) GENERATE_PREDICTOR_SUB(VP8LPredictors[12], PredictorSub12)
GENERATE_PREDICTOR_SUB(13) GENERATE_PREDICTOR_SUB(VP8LPredictors[13], PredictorSub13)
VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed; VP8LProcessEncBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;

View File

@ -217,12 +217,12 @@ GENERATE_PREDICTOR_1(4, upper[i - 1])
// Due to averages with integers, values cannot be accumulated in parallel for // Due to averages with integers, values cannot be accumulated in parallel for
// predictors 5 to 10. // predictors 5 to 10.
GENERATE_PREDICTOR_ADD(5) GENERATE_PREDICTOR_ADD(VP8LPredictors[5], PredictorAdd5_SSE2)
GENERATE_PREDICTOR_ADD(6) GENERATE_PREDICTOR_ADD(VP8LPredictors[6], PredictorAdd6_SSE2)
GENERATE_PREDICTOR_ADD(7) GENERATE_PREDICTOR_ADD(VP8LPredictors[7], PredictorAdd7_SSE2)
GENERATE_PREDICTOR_ADD(8) GENERATE_PREDICTOR_ADD(VP8LPredictors[8], PredictorAdd8_SSE2)
GENERATE_PREDICTOR_ADD(9) GENERATE_PREDICTOR_ADD(VP8LPredictors[9], PredictorAdd9_SSE2)
GENERATE_PREDICTOR_ADD(10) GENERATE_PREDICTOR_ADD(VP8LPredictors[10], PredictorAdd10_SSE2)
// Predictor11: select. // Predictor11: select.
static void PredictorAdd11_SSE2(const uint32_t* in, const uint32_t* upper, static void PredictorAdd11_SSE2(const uint32_t* in, const uint32_t* upper,
@ -300,7 +300,7 @@ static void PredictorAdd12_SSE2(const uint32_t* in, const uint32_t* upper,
// Due to averages with integers, values cannot be accumulated in parallel for // Due to averages with integers, values cannot be accumulated in parallel for
// predictors 13. // predictors 13.
GENERATE_PREDICTOR_ADD(13) GENERATE_PREDICTOR_ADD(VP8LPredictors[13], PredictorAdd13_SSE2)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Subtract-Green Transform // Subtract-Green Transform
@ -547,15 +547,15 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInitSSE2(void) {
VP8LPredictorsAdd[2] = PredictorAdd2_SSE2; VP8LPredictorsAdd[2] = PredictorAdd2_SSE2;
VP8LPredictorsAdd[3] = PredictorAdd3_SSE2; VP8LPredictorsAdd[3] = PredictorAdd3_SSE2;
VP8LPredictorsAdd[4] = PredictorAdd4_SSE2; VP8LPredictorsAdd[4] = PredictorAdd4_SSE2;
VP8LPredictorsAdd[5] = PredictorAdd5; VP8LPredictorsAdd[5] = PredictorAdd5_SSE2;
VP8LPredictorsAdd[6] = PredictorAdd6; VP8LPredictorsAdd[6] = PredictorAdd6_SSE2;
VP8LPredictorsAdd[7] = PredictorAdd7; VP8LPredictorsAdd[7] = PredictorAdd7_SSE2;
VP8LPredictorsAdd[8] = PredictorAdd8; VP8LPredictorsAdd[8] = PredictorAdd8_SSE2;
VP8LPredictorsAdd[9] = PredictorAdd9; VP8LPredictorsAdd[9] = PredictorAdd9_SSE2;
VP8LPredictorsAdd[10] = PredictorAdd10; VP8LPredictorsAdd[10] = PredictorAdd10_SSE2;
VP8LPredictorsAdd[11] = PredictorAdd11_SSE2; VP8LPredictorsAdd[11] = PredictorAdd11_SSE2;
VP8LPredictorsAdd[12] = PredictorAdd12_SSE2; VP8LPredictorsAdd[12] = PredictorAdd12_SSE2;
VP8LPredictorsAdd[13] = PredictorAdd13; VP8LPredictorsAdd[13] = PredictorAdd13_SSE2;
VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed; VP8LAddGreenToBlueAndRed = AddGreenToBlueAndRed;
VP8LTransformColorInverse = TransformColorInverse; VP8LTransformColorInverse = TransformColorInverse;