This method is required for all derived classes of EffectBase, and returns a modified openshot::Frame object
| 48 | // This method is required for all derived classes of EffectBase, and returns a |
| 49 | // modified openshot::Frame object |
| 50 | std::shared_ptr<openshot::Frame> Blur::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) |
| 51 | { |
| 52 | // Get the frame's image |
| 53 | std::shared_ptr<QImage> frame_image = frame->GetImage(); |
| 54 | |
| 55 | // Get the current blur radius |
| 56 | int horizontal_radius_value = horizontal_radius.GetValue(frame_number); |
| 57 | int vertical_radius_value = vertical_radius.GetValue(frame_number); |
| 58 | float sigma_value = sigma.GetValue(frame_number); |
| 59 | int iteration_value = iterations.GetInt(frame_number); |
| 60 | (void) sigma_value; |
| 61 | |
| 62 | int w = frame_image->width(); |
| 63 | int h = frame_image->height(); |
| 64 | |
| 65 | // Grab two copies of the image pixel data |
| 66 | QImage image_copy = frame_image->copy(); |
| 67 | std::shared_ptr<QImage> frame_image_2 = std::make_shared<QImage>(image_copy); |
| 68 | |
| 69 | // Loop through each iteration |
| 70 | for (int iteration = 0; iteration < iteration_value; ++iteration) |
| 71 | { |
| 72 | // HORIZONTAL BLUR (if any) |
| 73 | if (horizontal_radius_value > 0.0) { |
| 74 | // Apply horizontal blur to target RGBA channels |
| 75 | boxBlurH(frame_image->bits(), frame_image_2->bits(), w, h, horizontal_radius_value); |
| 76 | |
| 77 | // Swap output image back to input |
| 78 | frame_image.swap(frame_image_2); |
| 79 | } |
| 80 | |
| 81 | // VERTICAL BLUR (if any) |
| 82 | if (vertical_radius_value > 0.0) { |
| 83 | // Apply vertical blur to target RGBA channels |
| 84 | boxBlurT(frame_image->bits(), frame_image_2->bits(), w, h, vertical_radius_value); |
| 85 | |
| 86 | // Swap output image back to input |
| 87 | frame_image.swap(frame_image_2); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // return the modified frame |
| 92 | return frame; |
| 93 | } |
| 94 | |
| 95 | bool Blur::UseCustomMaskBlend(int64_t frame_number) const { |
| 96 | (void) frame_number; |