Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adm_dwt2_cy.pyx: fix cython warnings #1321

Merged
merged 1 commit into from
Feb 8, 2024
Merged

Conversation

nilfm99
Copy link
Collaborator

@nilfm99 nilfm99 commented Jan 29, 2024

Fixes the following warnings:

/home/coder/vmaf/.venv/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   17 | #warning "Using deprecated NumPy API, disable it with " \
      |  ^~~~~~~
In file included from vmaf/core/adm_dwt2_cy.c:1221:
vmaf/core/../../../libvmaf/src/mem.c:19: warning: "_POSIX_C_SOURCE" redefined
   19 | #define _POSIX_C_SOURCE 200112L
      | 
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/limits.h:26,
                 from /usr/lib/gcc/x86_64-linux-gnu/11/include/limits.h:203,
                 from /usr/lib/gcc/x86_64-linux-gnu/11/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/11/include/limits.h:34,
                 from /usr/include/python3.10/Python.h:11,
                 from vmaf/core/adm_dwt2_cy.c:37:
/usr/include/features.h:290: note: this is the location of the previous definition
  290 | # define _POSIX_C_SOURCE        200809L
      | 
vmaf/core/adm_dwt2_cy.c: In function ‘__pyx_pf_4vmaf_4core_11adm_dwt2_cy_adm_dwt2_cy’:
vmaf/core/adm_dwt2_cy.c:20302:39: warning: passing argument 1 of ‘init_dwt_band_d’ from incompatible pointer type [-Wincompatible-pointer-types]
20302 |   __pyx_v_data_top = init_dwt_band_d((&__pyx_v_aa_dwt2), __pyx_v_data_top, __pyx_v_buf_sz_one);
      |                                      ~^~~~~~~~~~~~~~~~~
      |                                       |
      |                                       struct __pyx_t_4vmaf_4core_11adm_dwt2_cy_adm_dwt_band_t *
In file included from vmaf/core/adm_dwt2_cy.c:1220:
vmaf/core/../../../libvmaf/src/feature/adm.c:53:48: note: expected ‘adm_dwt_band_t_d *’ but argument is of type ‘struct __pyx_t_4vmaf_4core_11adm_dwt2_cy_adm_dwt_band_t *’
   53 | static char *init_dwt_band_d(adm_dwt_band_t_d *band, char *data_top, size_t buf_sz_one)
      |                              ~~~~~~~~~~~~~~~~~~^~~~
vmaf/core/adm_dwt2_cy.c:20563:29: warning: passing argument 2 of ‘adm_dwt2_d’ from incompatible pointer type [-Wincompatible-pointer-types]
20563 |     adm_dwt2_d(__pyx_v_aa, (&__pyx_v_aa_dwt2), __pyx_v_ind_y, __pyx_v_ind_x, __pyx_v_w, __pyx_v_h, __pyx_v_curr_ref_stride, __pyx_v_buf_stride);
      |                            ~^~~~~~~~~~~~~~~~~
      |                             |
      |                             struct __pyx_t_4vmaf_4core_11adm_dwt2_cy_adm_dwt_band_t *
In file included from vmaf/core/adm_dwt2_cy.c:1219:
vmaf/core/../../../libvmaf/src/feature/adm_tools.c:943:60: note: expected ‘const adm_dwt_band_t_d *’ but argument is of type ‘struct __pyx_t_4vmaf_4core_11adm_dwt2_cy_adm_dwt_band_t *’
  943 | void adm_dwt2_d(const double *src, const adm_dwt_band_t_d *dst, int **ind_y, int **ind_x, int w, int h, int src_stride, int dst_stride)
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.10/vmaf/core/adm_dwt2_cy.o -o ./vmaf/core/adm_dwt2_cy.cpython-310-x86_64-linux-gnu.so

At least on the system I'm working on, this also introduces a new warning, due to a redefinition of _POSIX_C_SOURCE in both the header Python.h and our file libvmaf/src/mem.c. We can avoid this by wrapping our statement in #ifndef/#endif, will do this on a follow up commit.

In file included from vmaf/core/adm_dwt2_cy.c:1228:
vmaf/core/../../../libvmaf/src/mem.c:19: warning: "_POSIX_C_SOURCE" redefined
   19 | #define _POSIX_C_SOURCE 200112L
      | 
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/limits.h:26,
                 from /usr/lib/gcc/x86_64-linux-gnu/11/include/limits.h:203,
                 from /usr/lib/gcc/x86_64-linux-gnu/11/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/11/include/limits.h:34,
                 from /usr/include/python3.10/Python.h:11,
                 from vmaf/core/adm_dwt2_cy.c:43:
/usr/include/features.h:290: note: this is the location of the previous definition
  290 | # define _POSIX_C_SOURCE        200809L

@nilfm99 nilfm99 requested review from kylophone and li-zhi January 29, 2024 20:24
@nilfm99 nilfm99 changed the base branch from feature/nilfm-setup-py to master January 29, 2024 21:58
@nilfm99 nilfm99 force-pushed the feature/nilfm-fix-cython branch from 1aadbbe to 0fea102 Compare January 29, 2024 22:00
@nilfm99
Copy link
Collaborator Author

nilfm99 commented Jan 29, 2024

To fix: this fails on Mac with the macro that I added to bypass the warning:

vmaf/core/adm_dwt2_cy.c:2928:42: error: no member named 'data' in 'struct tagPyArrayObject'
  __pyx_v_aa = ((double *)__pyx_v_a_buf->data);
                          ~~~~~~~~~~~~~  ^

@nilfm99 nilfm99 marked this pull request as draft January 30, 2024 23:00
@nilfm99 nilfm99 force-pushed the feature/nilfm-fix-cython branch from 0fea102 to c396ca4 Compare February 8, 2024 20:19
@nilfm99 nilfm99 marked this pull request as ready for review February 8, 2024 20:22
@nilfm99
Copy link
Collaborator Author

nilfm99 commented Feb 8, 2024

Removed the macro, now only the following two warnings are fixed:

vmaf/core/adm_dwt2_cy.c:3206:38: warning: incompatible pointer types passing 'struct __pyx_t_4vmaf_4core_11adm_dwt2_cy_adm_dwt_band_t *' to parameter of type 'adm_dwt_band_t_d *' (aka 'struct adm_dwt_band_t_d *') [-Wincompatible-pointer-types]
  __pyx_v_data_top = init_dwt_band_d((&__pyx_v_aa_dwt2), __pyx_v_data_top, __pyx_v_buf_sz_one);
                                     ^~~~~~~~~~~~~~~~~~
vmaf/core/../../../libvmaf/src/feature/adm.c:53:48: note: passing argument to parameter 'band' here
static char *init_dwt_band_d(adm_dwt_band_t_d *band, char *data_top, size_t buf_sz_one)
                                               ^
vmaf/core/adm_dwt2_cy.c:3467:28: warning: incompatible pointer types passing 'struct __pyx_t_4vmaf_4core_11adm_dwt2_cy_adm_dwt_band_t *' to parameter of type 'const adm_dwt_band_t_d *' (aka 'const struct adm_dwt_band_t_d *') [-Wincompatible-pointer-types]
    adm_dwt2_d(__pyx_v_aa, (&__pyx_v_aa_dwt2), __pyx_v_ind_y, __pyx_v_ind_x, __pyx_v_w, __pyx_v_h, __pyx_v_curr_ref_stride, __pyx_v_buf_stride);
                           ^~~~~~~~~~~~~~~~~~
vmaf/core/../../../libvmaf/src/feature/adm_tools.c:943:60: note: passing argument to parameter 'dst' here
void adm_dwt2_d(const double *src, const adm_dwt_band_t_d *dst, int **ind_y, int **ind_x, int w, int h, int src_stride, int dst_stride)

@nilfm99 nilfm99 merged commit 74b87af into master Feb 8, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant