Path: blob/master/thirdparty/libpng/loongarch/loongarch_lsx_init.c
22756 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 int20png_has_lsx(void)21{22int flags = 0;23int flag = (int)getauxval(AT_HWCAP);2425if (flag & LA_HWCAP_LSX)26return 1;2728return 0;29}3031void32png_init_filter_functions_lsx(png_structp pp, unsigned int bpp)33{34/* IMPORTANT: any new external functions used here must be declared using35* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the36* 'prefix' option to configure works:37*38* ./configure --with-libpng-prefix=foobar_39*40* Verify you have got this right by running the above command, doing a build41* and examining pngprefix.h; it must contain a #define for every external42* function you add. (Notice that this happens automatically for the43* initialization function.)44*/4546if (png_has_lsx())47{48pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_lsx;49if (bpp == 3)50{51pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_lsx;52pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_lsx;53pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_lsx;54}55else if (bpp == 4)56{57pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_lsx;58pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_lsx;59pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_lsx;60}61}62}6364#endif /* PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 */65#endif /* PNG_READ_SUPPORTED */666768