Showing the changes to libavfilter (2 of 2 files). Show all
Unified · Split
| @@ -37,6 +37,7 @@ typedef struct GBlurContext { · 36 unmodified lines | ||
| 37 | 37 | int steps; |
| 38 | 38 | int planes; |
| 39 | 39 | |
| 40 | + int flt; | |
| 40 | 41 | int depth; |
| 41 | 42 | int planewidth[4]; |
| 42 | 43 | int planeheight[4]; |
| @@ -25,6 +25,8 @@ · 24 unmodified lines | ||
| 25 | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | +#include <float.h> | |
| 29 | + | |
| 28 | 30 | #include "libavutil/imgutils.h" |
| 29 | 31 | #include "libavutil/opt.h" |
| 30 | 32 | #include "libavutil/pixdesc.h" |
| @@ -157,7 +159,8 @@ static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 126 unmodified lines | ||
| 157 | 159 | { |
| 158 | 160 | GBlurContext *s = ctx->priv; |
| 159 | 161 | ThreadData *td = arg; |
| 160 | − const float max = (1 << s->depth) - 1; | |
| 162 | + const float max = s->flt ? FLT_MAX : (1 << s->depth) - 1; | |
| 163 | + const float min = s->flt ? -FLT_MAX : 0.f; | |
| 161 | 164 | const int height = td->height; |
| 162 | 165 | const int width = td->width; |
| 163 | 166 | const int64_t numpixels = width * (int64_t)height; |
| @@ -169,7 +172,7 @@ static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 5 unmodified lines | ||
| 169 | 172 | |
| 170 | 173 | for (i = slice_start; i < slice_end; i++) { |
| 171 | 174 | buffer[i] *= postscale; |
| 172 | − buffer[i] = av_clipf(buffer[i], 0.f, max); | |
| 175 | + buffer[i] = av_clipf(buffer[i], min, max); | |
| 173 | 176 | } |
| 174 | 177 | |
| 175 | 178 | return 0; |
| @@ -214,6 +217,8 @@ static int query_formats(AVFilterContext *ctx) · 38 unmodified lines | ||
| 214 | 217 | AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, |
| 215 | 218 | AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, |
| 216 | 219 | AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16, |
| 220 | + AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, | |
| 221 | + AV_PIX_FMT_GRAYF32, | |
| 217 | 222 | AV_PIX_FMT_NONE |
| 218 | 223 | }; |
| 219 | 224 | |
| @@ -233,6 +238,7 @@ static int config_input(AVFilterLink *inlink) · 13 unmodified lines | ||
| 233 | 238 | GBlurContext *s = inlink->dst->priv; |
| 234 | 239 | |
| 235 | 240 | s->depth = desc->comp[0].depth; |
| 241 | + s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT); | |
| 236 | 242 | s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); |
| 237 | 243 | s->planewidth[0] = s->planewidth[3] = inlink->w; |
| 238 | 244 | s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); |
| @@ -303,7 +309,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 64 unmodified lines | ||
| 303 | 309 | continue; |
| 304 | 310 | } |
| 305 | 311 | |
| 306 | − if (s->depth == 8) { | |
| 312 | + if (s->flt) { | |
| 313 | + av_image_copy_plane((uint8_t *)bptr, width * sizeof(float), | |
| 314 | + in->data[plane], in->linesize[plane], | |
| 315 | + width * sizeof(float), height); | |
| 316 | + } else if (s->depth == 8) { | |
| 307 | 317 | for (y = 0; y < height; y++) { |
| 308 | 318 | for (x = 0; x < width; x++) { |
| 309 | 319 | bptr[x] = src[x]; |
| @@ -324,7 +334,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 14 unmodified lines | ||
| 324 | 334 | gaussianiir2d(ctx, plane); |
| 325 | 335 | |
| 326 | 336 | bptr = s->buffer; |
| 327 | − if (s->depth == 8) { | |
| 337 | + if (s->flt) { | |
| 338 | + av_image_copy_plane(out->data[plane], out->linesize[plane], | |
| 339 | + (uint8_t *)bptr, width * sizeof(float), | |
| 340 | + width * sizeof(float), height); | |
| 341 | + } else if (s->depth == 8) { | |
| 328 | 342 | for (y = 0; y < height; y++) { |
| 329 | 343 | for (x = 0; x < width; x++) { |
| 330 | 344 | dst[x] = bptr[x]; |