diff options
author | Víctor Manuel Jáquez Leal <vjaquez@igalia.com> | 2018-02-14 14:31:00 +0100 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2018-03-14 12:09:44 +0800 |
commit | 555cd80a64ebf72d75c3bc9dbee6e05f2f03cca6 (patch) | |
tree | 37eefd78aeefb65c84624fdd049598c9058ad159 | |
parent | 5802bd725347f7b6ee012e60f741508257e2ee76 (diff) | |
download | libva-intel-driver-555cd80a64ebf72d75c3bc9dbee6e05f2f03cca6.tar.gz |
Remove implicit truncation from unsigned int to bit field
All the members of struct i965_sampler_8x8_coefficient are signed
int of 8 bit long (ranging from -128 to 127).
But there is an assignation of 1U<<7 which is implicitly truncated
to -128.
To make explicit the casting, without losing the expresiveness of
the bitwise operation, this patch adds a macro which uses the
anonymous union technique.
-rw-r--r-- | src/i965_post_processing.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/i965_post_processing.c b/src/i965_post_processing.c index cd6b2c03..a75ea07f 100644 --- a/src/i965_post_processing.c +++ b/src/i965_post_processing.c @@ -63,6 +63,8 @@ vpp_surface_convert(VADriverContextP ctx, #define VA_STATUS_SUCCESS_1 0xFFFFFFFE +#define BIT_CAST(x) (((union{unsigned int a;int b:8;})x).b) + static const uint32_t pp_null_gen5[][4] = { #include "shaders/post_processing/gen5_6/null.g4b.gen5" }; @@ -2806,7 +2808,7 @@ pp_nv12_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context } /* Adaptive filter for all channels (DW4.15) */ - sampler_8x8_state->coefficients[0].dw4.table_1x_filter_c1 = 1U << 7; + sampler_8x8_state->coefficients[0].dw4.table_1x_filter_c1 = BIT_CAST((1U << 7)); sampler_8x8_state->dw136.default_sharpness_level = -avs_is_needed(pp_context->filter_flags); @@ -3152,7 +3154,7 @@ gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_con sampler_8x8_state->dw137.hsw.bypass_y_adaptive_filtering = 1; sampler_8x8_state->dw137.hsw.bypass_x_adaptive_filtering = 1; } else { - sampler_8x8_state->coefficients[0].dw4.table_1x_filter_c1 = 1U << 7; + sampler_8x8_state->coefficients[0].dw4.table_1x_filter_c1 = BIT_CAST((1U << 7)); sampler_8x8_state->dw137.ilk.bypass_y_adaptive_filtering = 1; sampler_8x8_state->dw137.ilk.bypass_x_adaptive_filtering = 1; } |