2329 #ifdef PNG_WRITE_FILTER_SUPPORTED 2331 png_uint_32 mins, bpp;
2332 png_byte filter_to_do = png_ptr->
do_filter;
2334 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2335 int num_p_filters = png_ptr->num_prev_filters;
2338 png_debug(1,
"in png_write_find_filter");
2340 #ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2354 #ifdef PNG_WRITE_FILTER_SUPPORTED 2389 png_uint_32 sum = 0;
2393 for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
2396 sum += (v < 128) ? v : 256 - v;
2399 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2402 png_uint_32 sumhi, sumlo;
2408 for (j = 0; j < num_p_filters; j++)
2412 sumlo = (sumlo * png_ptr->filter_weights[j]) >>
2415 sumhi = (sumhi * png_ptr->filter_weights[j]) >>
2447 for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
2453 for (lp = row_buf + 1; i < row_bytes;
2454 i++, rp++, lp++, dp++)
2456 *dp = (png_byte)(((
int)*rp - (int)*lp) & 0xff);
2459 best_row = png_ptr->sub_row;
2465 png_uint_32 sum = 0, lmins = mins;
2469 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2477 png_uint_32 lmhi, lmlo;
2481 for (j = 0; j < num_p_filters; j++)
2485 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
2488 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
2507 for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;
2512 sum += (v < 128) ? v : 256 - v;
2515 for (lp = row_buf + 1; i < row_bytes;
2516 i++, rp++, lp++, dp++)
2518 v = *dp = (png_byte)(((
int)*rp - (int)*lp) & 0xff);
2520 sum += (v < 128) ? v : 256 - v;
2526 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2530 png_uint_32 sumhi, sumlo;
2534 for (j = 0; j < num_p_filters; j++)
2538 sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>
2541 sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>
2563 best_row = png_ptr->sub_row;
2573 for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
2574 pp = prev_row + 1; i < row_bytes;
2575 i++, rp++, pp++, dp++)
2577 *dp = (png_byte)(((
int)*rp - (int)*pp) & 0xff);
2580 best_row = png_ptr->up_row;
2586 png_uint_32 sum = 0, lmins = mins;
2591 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2595 png_uint_32 lmhi, lmlo;
2599 for (j = 0; j < num_p_filters; j++)
2603 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
2606 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
2625 for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,
2626 pp = prev_row + 1; i < row_bytes; i++)
2628 v = *dp++ = (png_byte)(((
int)*rp++ - (int)*pp++) & 0xff);
2630 sum += (v < 128) ? v : 256 - v;
2636 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2640 png_uint_32 sumhi, sumlo;
2644 for (j = 0; j < num_p_filters; j++)
2648 sumlo = (sumlo * png_ptr->filter_weights[j]) >>
2651 sumhi = (sumhi * png_ptr->filter_weights[j]) >>
2673 best_row = png_ptr->up_row;
2683 for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
2684 pp = prev_row + 1; i < bpp; i++)
2686 *dp++ = (png_byte)(((
int)*rp++ - ((int)*pp++ / 2)) & 0xff);
2689 for (lp = row_buf + 1; i < row_bytes; i++)
2691 *dp++ = (png_byte)(((
int)*rp++ - (((int)*pp++ + (
int)*lp++) / 2))
2694 best_row = png_ptr->avg_row;
2700 png_uint_32 sum = 0, lmins = mins;
2704 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2708 png_uint_32 lmhi, lmlo;
2712 for (j = 0; j < num_p_filters; j++)
2716 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
2719 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
2738 for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,
2739 pp = prev_row + 1; i < bpp; i++)
2741 v = *dp++ = (png_byte)(((
int)*rp++ - ((int)*pp++ / 2)) & 0xff);
2743 sum += (v < 128) ? v : 256 - v;
2746 for (lp = row_buf + 1; i < row_bytes; i++)
2749 (png_byte)(((
int)*rp++ - (((int)*pp++ + (
int)*lp++) / 2)) & 0xff);
2751 sum += (v < 128) ? v : 256 - v;
2757 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2761 png_uint_32 sumhi, sumlo;
2765 for (j = 0; j < num_p_filters; j++)
2769 sumlo = (sumlo * png_ptr->filter_weights[j]) >>
2772 sumhi = (sumhi * png_ptr->filter_weights[j]) >>
2794 best_row = png_ptr->avg_row;
2804 for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
2805 pp = prev_row + 1; i < bpp; i++)
2807 *dp++ = (png_byte)(((
int)*rp++ - (int)*pp++) & 0xff);
2810 for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
2812 int a,
b, c, pa, pb, pc,
p;
2826 pa = p < 0 ? -p :
p;
2827 pb = pc < 0 ? -pc : pc;
2828 pc = (p + pc) < 0 ? -(p + pc) : p + pc;
2831 p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
2833 *dp++ = (png_byte)(((
int)*rp++ -
p) & 0xff);
2835 best_row = png_ptr->paeth_row;
2841 png_uint_32 sum = 0, lmins = mins;
2845 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2849 png_uint_32 lmhi, lmlo;
2853 for (j = 0; j < num_p_filters; j++)
2857 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>
2860 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>
2879 for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,
2880 pp = prev_row + 1; i < bpp; i++)
2882 v = *dp++ = (png_byte)(((
int)*rp++ - (int)*pp++) & 0xff);
2884 sum += (v < 128) ? v : 256 - v;
2887 for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)
2889 int a,
b, c, pa, pb, pc,
p;
2895 #ifndef PNG_SLOW_PAETH 2903 pa = p < 0 ? -p :
p;
2904 pb = pc < 0 ? -pc : pc;
2905 pc = (p + pc) < 0 ? -(p + pc) : p + pc;
2907 p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
2914 if (pa <= pb && pa <= pc)
2924 v = *dp++ = (png_byte)(((
int)*rp++ - p) & 0xff);
2926 sum += (v < 128) ? v : 256 - v;
2932 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2936 png_uint_32 sumhi, sumlo;
2940 for (j = 0; j < num_p_filters; j++)
2944 sumlo = (sumlo * png_ptr->filter_weights[j]) >>
2947 sumhi = (sumhi * png_ptr->filter_weights[j]) >>
2968 best_row = png_ptr->paeth_row;
2976 #ifdef PNG_WRITE_FILTER_SUPPORTED 2977 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2979 if (png_ptr->num_prev_filters > 0)
2983 for (j = 1; j < num_p_filters; j++)
2985 png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];
2988 png_ptr->prev_filters[j] = best_row[0];
#define PNG_FILTER_VALUE_AVG
Definition: png.h:1615
#define PNG_WEIGHT_SHIFT
Definition: pnglibconf.h:201
#define PNG_FILTER_PAETH
Definition: png.h:1605
#define PNG_FILTER_HEURISTIC_WEIGHTED
Definition: png.h:1662
#define PNG_FILTER_SUB
Definition: png.h:1602
png_uint_32 row_number
Definition: pngstruct.h:220
int i
Definition: rw_test.cpp:37
png_byte * png_bytep
Definition: pngconf.h:600
#define PNG_FILTER_VALUE_PAETH
Definition: png.h:1616
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_HIMASK
Definition: pngwutil.c:2324
static void png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, png_size_t row_bytes)
Definition: pngwutil.c:2997
long b
Definition: jpegint.h:371
png_byte do_filter
Definition: pngstruct.h:251
static double * p
Definition: gauss_jackson_test.cpp:42
#define PNG_LOMASK
Definition: pngwutil.c:2323
png_bytep prev_row
Definition: pngstruct.h:222
#define PNG_FILTER_VALUE_SUB
Definition: png.h:1613
png_bytep row_buf
Definition: pngstruct.h:225
#define PNG_ALL_FILTERS
Definition: png.h:1606
png_byte pixel_depth
Definition: png.h:901
#define PNG_FILTER_UP
Definition: png.h:1603
#define PNG_FILTER_AVG
Definition: png.h:1604
Definition: eci2kep_test.cpp:33
#define PNG_FILTER_VALUE_UP
Definition: png.h:1614
png_size_t rowbytes
Definition: png.h:897
#define PNG_HISHIFT
Definition: pngwutil.c:2322
#define PNG_FILTER_VALUE_NONE
Definition: png.h:1612
size_t png_size_t
Definition: pngconf.h:543
#define PNG_FILTER_NONE
Definition: png.h:1601
#define PNG_MAXSUM
Definition: pngwutil.c:2321
#define PNG_COST_SHIFT
Definition: pnglibconf.h:190