/** * Blur image plane using a mask. * * @param source The image to have it's logo removed. * @param destination Where the output image will be stored. * @param source_stride How far apart (in memory) two consecutive lines are. * @param destination Same as source_stride, but for the destination image. * @param width Width of the image. This is the same for source and destination. * @param height Height of the image. This is the same for source and destination. * @param is_image_direct If the image is direct, then source and destination are * the same and we can save a lot of time by not copying pixels that * haven't changed. * @param filter The image that stores the distance to the edge of the logo for * each pixel. * @param logo_start_x smallest x-coordinate that contains at least 1 logo pixel. * @param logo_start_y smallest y-coordinate that contains at least 1 logo pixel. * @param logo_end_x largest x-coordinate that contains at least 1 logo pixel. * @param logo_end_y largest y-coordinate that contains at least 1 logo pixel. * * This function processes an entire plane. Pixels outside of the logo are copied * to the output without change, and pixels inside the logo have the de-blurring * function applied. */ static void blur_image(int ***mask, const uint8_t *src_data, int src_linesize, uint8_t *dst_data, int dst_linesize, const uint8_t *mask_data, int mask_linesize, int w, int h, int direct, FFBoundingBox *bbox) { int x, y; uint8_t *dst_line; const uint8_t *src_line; if (!direct) av_image_copy_plane(dst_data, dst_linesize, src_data, src_linesize, w, h); for (y = bbox->y1; y <= bbox->y2; y++) { src_line = src_data + src_linesize * y; dst_line = dst_data + dst_linesize * y; for (x = bbox->x1; x <= bbox->x2; x++) { if (mask_data[y * mask_linesize + x]) { /* Only process if we are in the mask. */ dst_line[x] = blur_pixel(mask, mask_data, mask_linesize, dst_data, dst_linesize, w, h, x, y); } else { /* Else just copy the data. */ if (!direct) dst_line[x] = src_line[x]; } } } }
SkBitmap slow_blur(const SkBitmap& src, float sigma) { SkBitmap dst; dst.allocN32Pixels(src.width(), src.height(), true); int wh; SkAutoTDeleteArray<float> kernel(create_2d_kernel(sigma, &wh)); for (int y = 0; y < src.height(); ++y) { for (int x = 0; x < src.width(); ++x) { *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh); } } return dst; }