History

avfilter/vf_gblur: add float format support

Paul B Mahol committed 5 years ago

Commit 34922df1 parent d1802e22 files · +19 −4Browse files

Showing the changes to libavfilter (2 of 2 files). Show all

Unified · Split

2 files
  1. libavfilter/gblur.h +1 −0
  2. libavfilter/vf_gblur.c +18 −4
libavfilter/gblur.h+1−0
@@ -37,6 +37,7 @@ typedef struct GBlurContext { · 36 unmodified lines
3737 int steps;
3838 int planes;
3939
40+ int flt;
4041 int depth;
4142 int planewidth[4];
4243 int planeheight[4];
libavfilter/vf_gblur.c+18−4
@@ -25,6 +25,8 @@ · 24 unmodified lines
2525 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626 */
2727
28+#include <float.h>
29+
2830 #include "libavutil/imgutils.h"
2931 #include "libavutil/opt.h"
3032 #include "libavutil/pixdesc.h"
@@ -157,7 +159,8 @@ static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 126 unmodified lines
157159 {
158160 GBlurContext *s = ctx->priv;
159161 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;
161164 const int height = td->height;
162165 const int width = td->width;
163166 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
169172
170173 for (i = slice_start; i < slice_end; i++) {
171174 buffer[i] *= postscale;
172− buffer[i] = av_clipf(buffer[i], 0.f, max);
175+ buffer[i] = av_clipf(buffer[i], min, max);
173176 }
174177
175178 return 0;
@@ -214,6 +217,8 @@ static int query_formats(AVFilterContext *ctx) · 38 unmodified lines
214217 AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
215218 AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
216219 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,
217222 AV_PIX_FMT_NONE
218223 };
219224
@@ -233,6 +238,7 @@ static int config_input(AVFilterLink *inlink) · 13 unmodified lines
233238 GBlurContext *s = inlink->dst->priv;
234239
235240 s->depth = desc->comp[0].depth;
241+ s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
236242 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
237243 s->planewidth[0] = s->planewidth[3] = inlink->w;
238244 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
303309 continue;
304310 }
305311
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) {
307317 for (y = 0; y < height; y++) {
308318 for (x = 0; x < width; x++) {
309319 bptr[x] = src[x];
@@ -324,7 +334,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 14 unmodified lines
324334 gaussianiir2d(ctx, plane);
325335
326336 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) {
328342 for (y = 0; y < height; y++) {
329343 for (x = 0; x < width; x++) {
330344 dst[x] = bptr[x];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t