Path: blob/master/thirdparty/libpng/loongarch/loongarch_lsx_init.c
9904 views
/* loongarch_lsx_init.c - LSX optimized filter functions1*2* Copyright (c) 2021 Loongson Technology Corporation Limited3* All rights reserved.4* Contributed by Jin Bo <[email protected]>5*6* This code is released under the libpng license.7* For conditions of distribution and use, see the disclaimer8* and license in png.h9*/1011#include "../pngpriv.h"1213#ifdef PNG_READ_SUPPORTED14#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 11516#include <sys/auxv.h>1718#define LA_HWCAP_LSX (1<<4)19static int png_has_lsx(void)20{21int flags = 0;22int flag = (int)getauxval(AT_HWCAP);2324if (flag & LA_HWCAP_LSX)25return 1;2627return 0;28}2930void31png_init_filter_functions_lsx(png_structp pp, unsigned int bpp)32{33/* IMPORTANT: any new external functions used here must be declared using34* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the35* 'prefix' option to configure works:36*37* ./configure --with-libpng-prefix=foobar_38*39* Verify you have got this right by running the above command, doing a build40* and examining pngprefix.h; it must contain a #define for every external41* function you add. (Notice that this happens automatically for the42* initialization function.)43*/4445if (png_has_lsx())46{47pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_lsx;48if (bpp == 3)49{50pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_lsx;51pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_lsx;52pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_lsx;53}54else if (bpp == 4)55{56pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_lsx;57pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_lsx;58pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_lsx;59}60}61}6263#endif /* PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 */64#endif /* PNG_READ_SUPPORTED */656667