aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-25 23:19:42 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-28 23:37:12 +0200
commit4393331250d1f61be0d159de2a7976087a118c25 (patch)
tree241e43832c39d39227c533e3a41fc790fb5027c2 /libavcodec
parenta91ddce6894af70ed7389eaf2a84f844e9f7b7e9 (diff)
downloadffmpeg-4393331250d1f61be0d159de2a7976087a118c25.tar.gz
avcodec/dirac_dwt: Avoid conversions between function pointers and void*
Pointers to void can be converted to any pointer to incomplete or object type and back; but they are nevertheless not completely generic pointers: There is no provision in the C standard that guarantees their convertibility with function pointers. C90 lacks a generic function pointer, C99 made every function pointer a generic function pointer and still disallows the convertibility with void *. Both GCC as well as Clang warn about this when using -pedantic. Therefore use unions to avoid these conversions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/dirac_dwt.h13
-rw-r--r--libavcodec/dirac_dwt_template.c52
-rw-r--r--libavcodec/x86/dirac_dwt_init.c16
3 files changed, 42 insertions, 39 deletions
diff --git a/libavcodec/dirac_dwt.h b/libavcodec/dirac_dwt.h
index 994dc21d70..84f71d9120 100644
--- a/libavcodec/dirac_dwt.h
+++ b/libavcodec/dirac_dwt.h
@@ -61,11 +61,14 @@ typedef struct DWTContext {
int support;
void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride);
- void (*vertical_compose_l0)(void);
- void (*vertical_compose_h0)(void);
- void (*vertical_compose_l1)(void);
- void (*vertical_compose_h1)(void);
- void (*vertical_compose)(void); ///< one set of lowpass and highpass combined
+ union {
+ vertical_compose_3tap tap3;
+ vertical_compose_5tap tap5;
+ vertical_compose_9tap tap9;
+ } vertical_compose_l0, vertical_compose_h0;
+ vertical_compose_3tap vertical_compose_l1;
+ vertical_compose_3tap vertical_compose_h1;
+ vertical_compose_2tap vertical_compose; ///< one set of lowpass and highpass combined
void (*horizontal_compose)(uint8_t *b, uint8_t *tmp, int width);
DWTCompose cs[MAX_DECOMPOSITIONS];
diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c
index f1d7f8b22f..0d39754ed8 100644
--- a/libavcodec/dirac_dwt_template.c
+++ b/libavcodec/dirac_dwt_template.c
@@ -338,8 +338,8 @@ static void RENAME(vertical_compose_daub97iL1)(uint8_t *_b0, uint8_t *_b1, uint8
static void RENAME(spatial_compose_dd97i_dy)(DWTContext *d, int level, int width, int height, int stride)
{
- vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
- vertical_compose_5tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
+ vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3;
+ vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0.tap5;
DWTCompose *cs = d->cs + level;
int i, y = cs->y;
@@ -362,8 +362,8 @@ static void RENAME(spatial_compose_dd97i_dy)(DWTContext *d, int level, int width
static void RENAME(spatial_compose_dirac53i_dy)(DWTContext *d, int level, int width, int height, int stride)
{
- vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
- vertical_compose_3tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
+ vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3;
+ vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0.tap3;
DWTCompose *cs = d->cs + level;
int y= cs->y;
@@ -384,8 +384,8 @@ static void RENAME(spatial_compose_dirac53i_dy)(DWTContext *d, int level, int wi
static void RENAME(spatial_compose_dd137i_dy)(DWTContext *d, int level, int width, int height, int stride)
{
- vertical_compose_5tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
- vertical_compose_5tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
+ vertical_compose_5tap vertical_compose_l0 = d->vertical_compose_l0.tap5;
+ vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0.tap5;
DWTCompose *cs = d->cs + level;
int i, y = cs->y;
@@ -409,7 +409,7 @@ static void RENAME(spatial_compose_dd137i_dy)(DWTContext *d, int level, int widt
// haar makes the assumption that height is even (always true for dirac)
static void RENAME(spatial_compose_haari_dy)(DWTContext *d, int level, int width, int height, int stride)
{
- vertical_compose_2tap vertical_compose = (void*)d->vertical_compose;
+ vertical_compose_2tap vertical_compose = d->vertical_compose;
int y = d->cs[level].y;
uint8_t *b0 = d->buffer + (y-1)*stride;
uint8_t *b1 = d->buffer + (y )*stride;
@@ -425,8 +425,8 @@ static void RENAME(spatial_compose_haari_dy)(DWTContext *d, int level, int width
// Fortunately, this filter isn't used in practice.
static void RENAME(spatial_compose_fidelity)(DWTContext *d, int level, int width, int height, int stride)
{
- vertical_compose_9tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
- vertical_compose_9tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
+ vertical_compose_9tap vertical_compose_l0 = d->vertical_compose_l0.tap9;
+ vertical_compose_9tap vertical_compose_h0 = d->vertical_compose_h0.tap9;
int i, y;
uint8_t *b[8];
@@ -450,10 +450,10 @@ static void RENAME(spatial_compose_fidelity)(DWTContext *d, int level, int width
static void RENAME(spatial_compose_daub97i_dy)(DWTContext *d, int level, int width, int height, int stride)
{
- vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0;
- vertical_compose_3tap vertical_compose_h0 = (void*)d->vertical_compose_h0;
- vertical_compose_3tap vertical_compose_l1 = (void*)d->vertical_compose_l1;
- vertical_compose_3tap vertical_compose_h1 = (void*)d->vertical_compose_h1;
+ vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3;
+ vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0.tap3;
+ vertical_compose_3tap vertical_compose_l1 = d->vertical_compose_l1;
+ vertical_compose_3tap vertical_compose_h1 = d->vertical_compose_h1;
DWTCompose *cs = d->cs + level;
int i, y = cs->y;
@@ -552,29 +552,29 @@ static int RENAME(spatial_idwt_init)(DWTContext *d, enum dwt_type type)
switch (type) {
case DWT_DIRAC_DD9_7:
d->spatial_compose = RENAME(spatial_compose_dd97i_dy);
- d->vertical_compose_l0 = (void*)RENAME(vertical_compose53iL0);
- d->vertical_compose_h0 = (void*)RENAME(vertical_compose_dd97iH0);
+ d->vertical_compose_l0.tap3 = RENAME(vertical_compose53iL0);
+ d->vertical_compose_h0.tap5 = RENAME(vertical_compose_dd97iH0);
d->horizontal_compose = RENAME(horizontal_compose_dd97i);
d->support = 7;
break;
case DWT_DIRAC_LEGALL5_3:
d->spatial_compose = RENAME(spatial_compose_dirac53i_dy);
- d->vertical_compose_l0 = (void*)RENAME(vertical_compose53iL0);
- d->vertical_compose_h0 = (void*)RENAME(vertical_compose_dirac53iH0);
+ d->vertical_compose_l0.tap3 = RENAME(vertical_compose53iL0);
+ d->vertical_compose_h0.tap3 = RENAME(vertical_compose_dirac53iH0);
d->horizontal_compose = RENAME(horizontal_compose_dirac53i);
d->support = 3;
break;
case DWT_DIRAC_DD13_7:
d->spatial_compose = RENAME(spatial_compose_dd137i_dy);
- d->vertical_compose_l0 = (void*)RENAME(vertical_compose_dd137iL0);
- d->vertical_compose_h0 = (void*)RENAME(vertical_compose_dd97iH0);
+ d->vertical_compose_l0.tap5 = RENAME(vertical_compose_dd137iL0);
+ d->vertical_compose_h0.tap5 = RENAME(vertical_compose_dd97iH0);
d->horizontal_compose = RENAME(horizontal_compose_dd137i);
d->support = 7;
break;
case DWT_DIRAC_HAAR0:
case DWT_DIRAC_HAAR1:
d->spatial_compose = RENAME(spatial_compose_haari_dy);
- d->vertical_compose = (void*)RENAME(vertical_compose_haar);
+ d->vertical_compose = RENAME(vertical_compose_haar);
if (type == DWT_DIRAC_HAAR0)
d->horizontal_compose = RENAME(horizontal_compose_haar0i);
else
@@ -583,17 +583,17 @@ static int RENAME(spatial_idwt_init)(DWTContext *d, enum dwt_type type)
break;
case DWT_DIRAC_FIDELITY:
d->spatial_compose = RENAME(spatial_compose_fidelity);
- d->vertical_compose_l0 = (void*)RENAME(vertical_compose_fidelityiL0);
- d->vertical_compose_h0 = (void*)RENAME(vertical_compose_fidelityiH0);
+ d->vertical_compose_l0.tap9 = RENAME(vertical_compose_fidelityiL0);
+ d->vertical_compose_h0.tap9 = RENAME(vertical_compose_fidelityiH0);
d->horizontal_compose = RENAME(horizontal_compose_fidelityi);
d->support = 0; // not really used
break;
case DWT_DIRAC_DAUB9_7:
d->spatial_compose = RENAME(spatial_compose_daub97i_dy);
- d->vertical_compose_l0 = (void*)RENAME(vertical_compose_daub97iL0);
- d->vertical_compose_h0 = (void*)RENAME(vertical_compose_daub97iH0);
- d->vertical_compose_l1 = (void*)RENAME(vertical_compose_daub97iL1);
- d->vertical_compose_h1 = (void*)RENAME(vertical_compose_daub97iH1);
+ d->vertical_compose_l0.tap3 = RENAME(vertical_compose_daub97iL0);
+ d->vertical_compose_h0.tap3 = RENAME(vertical_compose_daub97iH0);
+ d->vertical_compose_l1 = RENAME(vertical_compose_daub97iL1);
+ d->vertical_compose_h1 = RENAME(vertical_compose_daub97iH1);
d->horizontal_compose = RENAME(horizontal_compose_daub97i);
d->support = 5;
break;
diff --git a/libavcodec/x86/dirac_dwt_init.c b/libavcodec/x86/dirac_dwt_init.c
index 9200618283..13b42b60cb 100644
--- a/libavcodec/x86/dirac_dwt_init.c
+++ b/libavcodec/x86/dirac_dwt_init.c
@@ -165,23 +165,23 @@ void ff_spatial_idwt_init_x86(DWTContext *d, enum dwt_type type)
switch (type) {
case DWT_DIRAC_DD9_7:
- d->vertical_compose_l0 = (void*)vertical_compose53iL0_sse2;
- d->vertical_compose_h0 = (void*)vertical_compose_dd97iH0_sse2;
+ d->vertical_compose_l0.tap3 = vertical_compose53iL0_sse2;
+ d->vertical_compose_h0.tap5 = vertical_compose_dd97iH0_sse2;
break;
case DWT_DIRAC_LEGALL5_3:
- d->vertical_compose_l0 = (void*)vertical_compose53iL0_sse2;
- d->vertical_compose_h0 = (void*)vertical_compose_dirac53iH0_sse2;
+ d->vertical_compose_l0.tap3 = vertical_compose53iL0_sse2;
+ d->vertical_compose_h0.tap3 = vertical_compose_dirac53iH0_sse2;
break;
case DWT_DIRAC_DD13_7:
- d->vertical_compose_l0 = (void*)vertical_compose_dd137iL0_sse2;
- d->vertical_compose_h0 = (void*)vertical_compose_dd97iH0_sse2;
+ d->vertical_compose_l0.tap5 = vertical_compose_dd137iL0_sse2;
+ d->vertical_compose_h0.tap5 = vertical_compose_dd97iH0_sse2;
break;
case DWT_DIRAC_HAAR0:
- d->vertical_compose = (void*)vertical_compose_haar_sse2;
+ d->vertical_compose = vertical_compose_haar_sse2;
d->horizontal_compose = horizontal_compose_haar0i_sse2;
break;
case DWT_DIRAC_HAAR1:
- d->vertical_compose = (void*)vertical_compose_haar_sse2;
+ d->vertical_compose = vertical_compose_haar_sse2;
d->horizontal_compose = horizontal_compose_haar1i_sse2;
break;
}