History

avfilter/vf_gblur: add float format support

Paul B Mahol committed 5 years ago

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

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
37 int steps;37 int steps;
38 int planes;38 int planes;
39 39
40 int flt;
40 int depth;41 int depth;
41 int planewidth[4];42 int planewidth[4];
42 int planeheight[4];43 int planeheight[4];
libavfilter/vf_gblur.c+18−4
@@ -25,6 +25,8 @@ · 24 unmodified lines
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */26 */
27 27
28#include <float.h>
29
28#include "libavutil/imgutils.h"30#include "libavutil/imgutils.h"
29#include "libavutil/opt.h"31#include "libavutil/opt.h"
30#include "libavutil/pixdesc.h"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 GBlurContext *s = ctx->priv;160 GBlurContext *s = ctx->priv;
159 ThreadData *td = arg;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 const int height = td->height;164 const int height = td->height;
162 const int width = td->width;165 const int width = td->width;
163 const int64_t numpixels = width * (int64_t)height;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 for (i = slice_start; i < slice_end; i++) {173 for (i = slice_start; i < slice_end; i++) {
171 buffer[i] *= postscale;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 return 0;178 return 0;
@@ -214,6 +217,8 @@ static int query_formats(AVFilterContext *ctx) · 38 unmodified lines
214 AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,217 AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
215 AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,218 AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
216 AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,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 AV_PIX_FMT_NONE222 AV_PIX_FMT_NONE
218 };223 };
219 224
@@ -233,6 +238,7 @@ static int config_input(AVFilterLink *inlink) · 13 unmodified lines
233 GBlurContext *s = inlink->dst->priv;238 GBlurContext *s = inlink->dst->priv;
234 239
235 s->depth = desc->comp[0].depth;240 s->depth = desc->comp[0].depth;
241 s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT);
236 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);242 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
237 s->planewidth[0] = s->planewidth[3] = inlink->w;243 s->planewidth[0] = s->planewidth[3] = inlink->w;
238 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);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 continue;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 for (y = 0; y < height; y++) {317 for (y = 0; y < height; y++) {
308 for (x = 0; x < width; x++) {318 for (x = 0; x < width; x++) {
309 bptr[x] = src[x];319 bptr[x] = src[x];
@@ -324,7 +334,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 14 unmodified lines
324 gaussianiir2d(ctx, plane);334 gaussianiir2d(ctx, plane);
325 335
326 bptr = s->buffer;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 for (y = 0; y < height; y++) {342 for (y = 0; y < height; y++) {
329 for (x = 0; x < width; x++) {343 for (x = 0; x < width; x++) {
330 dst[x] = bptr[x];344 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