aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-11-12 02:37:04 +0100
committerPaul B Mahol <onemda@gmail.com>2023-11-12 02:39:44 +0100
commit3ff811a41fd5fb53d7fb0a576a9a07ce10bed135 (patch)
treea85b6e491235176e2b1142fb56105d388d9f5aff
parent10440a489af0dd8a6e1cd8cfdcaa81473569868a (diff)
downloadffmpeg-3ff811a41fd5fb53d7fb0a576a9a07ce10bed135.tar.gz
avfilter/vf_colortemperature: add gbr(a)pf support
-rw-r--r--libavfilter/vf_colortemperature.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libavfilter/vf_colortemperature.c b/libavfilter/vf_colortemperature.c
index a44dd08004..b06b04e704 100644
--- a/libavfilter/vf_colortemperature.c
+++ b/libavfilter/vf_colortemperature.c
@@ -183,6 +183,47 @@ static int temperature_slice16(AVFilterContext *ctx, void *arg, int jobnr, int n
return 0;
}
+static int temperature_slice32(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+{
+ ColorTemperatureContext *s = ctx->priv;
+ AVFrame *frame = arg;
+ const int width = frame->width;
+ const int height = frame->height;
+ const float preserve = s->preserve;
+ const float mix = s->mix;
+ const float *color = s->color;
+ const int slice_start = (height * jobnr) / nb_jobs;
+ const int slice_end = (height * (jobnr + 1)) / nb_jobs;
+ const ptrdiff_t glinesize = frame->linesize[0] / sizeof(float);
+ const ptrdiff_t blinesize = frame->linesize[1] / sizeof(float);
+ const ptrdiff_t rlinesize = frame->linesize[2] / sizeof(float);
+ float *gptr = (float *)frame->data[0] + slice_start * glinesize;
+ float *bptr = (float *)frame->data[1] + slice_start * blinesize;
+ float *rptr = (float *)frame->data[2] + slice_start * rlinesize;
+
+ for (int y = slice_start; y < slice_end; y++) {
+ for (int x = 0; x < width; x++) {
+ float g = gptr[x];
+ float b = bptr[x];
+ float r = rptr[x];
+ float nr, ng, nb;
+ float l0, l1, l;
+
+ PROCESS()
+
+ gptr[x] = ng;
+ bptr[x] = nb;
+ rptr[x] = nr;
+ }
+
+ gptr += glinesize;
+ bptr += blinesize;
+ rptr += rlinesize;
+ }
+
+ return 0;
+}
+
static int temperature_slice8p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
ColorTemperatureContext *s = ctx->priv;
@@ -285,6 +326,7 @@ static const enum AVPixelFormat pixel_fmts[] = {
AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12,
AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
+ AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32,
AV_PIX_FMT_RGB48, AV_PIX_FMT_BGR48,
AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
AV_PIX_FMT_NONE
@@ -308,6 +350,8 @@ static av_cold int config_input(AVFilterLink *inlink)
s->do_slice = s->depth <= 8 ? temperature_slice8 : temperature_slice16;
if (!planar)
s->do_slice = s->depth <= 8 ? temperature_slice8p : temperature_slice16p;
+ if (s->depth == 32)
+ s->do_slice = temperature_slice32;
ff_fill_rgba_map(s->rgba_map, inlink->format);