Re: [Pixman] [cairo] Image resampling [PATCH 0/6]
Siarhei Siamashka wrote: Bilinear scaling uses weighted average of 2 pixels (in one direction), with weights calculated on the go. Separable convolution uses weighted average of N pixels, with weights obtained by table lookups. Both use subpixel positions (7 phase bits or 128 phases for current bilinear implementation) to lookup or calculate weights. Bilinear filter is naturally a subset of separable convolution. Also note that the separable filters need different "widths" as well as different phases. This is the distance from the center to the first 0 crossing in a sync filter, note that the non-zero part of the filter is several times the width (3 for a triangle, 5 for most, and 7 for lancos3). If the image is being scaled by 1/N the width is max(1,N). There probably should be a pre-calculated table of all combinations of width and phase. The minimum width is 1, but there will have to be a maximum chosen. Pixman would use the maximum if a larger size is wanted, which would mean that scales smaller than a certain value would be noisy. However if Cairo prescales by a power of 2 then the maximum scale may be 4. In Nuke the pre-calculated table is just a very wide filter (I think the width is 64) and that is the maximum filter size. Smaller filters and different offsets are chosen by subsampling this large filter at even intervals (Nuke chose the closest sample, but bilinear sampling would be better). The table was "normalized" so that the width of 1 produced samples that sum to 1, all larger filters needed to a normalization factor calculated by doing 1/sum of the samples. ___ Pixman mailing list Pixman@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pixman
Re: [Pixman] [cairo] Image resampling [PATCH 0/6]
Adrian Johnson wrote: On 24/11/12 14:27, Søren Sandmann wrote: -=- Adding support to cairo and further work Once these patches have landed in Pixman, support will have to be added to cairo to make use of them. How to do that exactly requires figuring out what new API to offer, and how the tradeoffs between performance and quality should be made. This is not something that I personally plan to work on anytime soon, except to make three notes: It would be useful to have an API for downscaling that does not require the entire source image to be loaded into memory. I've recently updated the downscaling box filter code in the cairo backend of poppler to read the source image one line at a time as it is uncompressed from the pdf file. This was to fix a bug where rendering a PDF containing a 21,590 x 161,385 1 bit/pixel image failed due to the 32,767 x 32,767 image limit. Yes I think Cairo will have to downrez an image before applying this filtering. It could keep the downrez image around until a different downrez is needed or the source image is damaged. I now think this down rez could be restricted to powers of 2 and a box filter, allowing it to be run very quickly with a recursive version that never needs more than 2 source lines at a time. Unless the filter is box, the downrez has to make the image no smaller than 2x the final size, to avoid hiding the nice aspects of the filters. There is also a problem where a huge image is not scaled down, so this source image is not any smaller. But in that case it would be clipped, so a temporary source image that is clipped to only the area that projects to the output clip is needed. This clipped image can be produced by code that only looks at 1 source line at a time. Combining them and assuming the worst possible case (a scale of 1/3.... and a rotation by 45 degrees) it looks like the maximum texture size would be the size of the output surface multiplied by 4*sqrt(2). That may still be a problem if the maximum texture size is equal to the maximum output size. Perhaps it could just produce a blurry picture in that case by downrezing excessively. ___ Pixman mailing list Pixman@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pixman
Re: [Pixman] [cairo] Image resampling [PATCH 0/6]
On 24/11/12 14:27, Søren Sandmann wrote: > -=- Adding support to cairo and further work > > Once these patches have landed in Pixman, support will have to be > added to cairo to make use of them. How to do that exactly requires > figuring out what new API to offer, and how the tradeoffs between > performance and quality should be made. This is not something that I > personally plan to work on anytime soon, except to make three notes: It would be useful to have an API for downscaling that does not require the entire source image to be loaded into memory. I've recently updated the downscaling box filter code in the cairo backend of poppler to read the source image one line at a time as it is uncompressed from the pdf file. This was to fix a bug where rendering a PDF containing a 21,590 x 161,385 1 bit/pixel image failed due to the 32,767 x 32,767 image limit. ___ Pixman mailing list Pixman@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pixman