History

avfilter/vf_colortemperature: add gbr(a)pf support

Paul B Mahol committed 3 years ago

Commit 3ff811a1 parent 10440a41 file · +44 −0Browse files

Unified · Split

libavfilter/vf_colortemperature.c+44−0
@@ -183,6 +183,47 @@ static int temperature_slice16(AVFilterContext *ctx, void *arg, int jobnr, int n · 182 unmodified lines
183183 return 0;
184184 }
185185
186+static int temperature_slice32(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
187+{
188+ ColorTemperatureContext *s = ctx->priv;
189+ AVFrame *frame = arg;
190+ const int width = frame->width;
191+ const int height = frame->height;
192+ const float preserve = s->preserve;
193+ const float mix = s->mix;
194+ const float *color = s->color;
195+ const int slice_start = (height * jobnr) / nb_jobs;
196+ const int slice_end = (height * (jobnr + 1)) / nb_jobs;
197+ const ptrdiff_t glinesize = frame->linesize[0] / sizeof(float);
198+ const ptrdiff_t blinesize = frame->linesize[1] / sizeof(float);
199+ const ptrdiff_t rlinesize = frame->linesize[2] / sizeof(float);
200+ float *gptr = (float *)frame->data[0] + slice_start * glinesize;
201+ float *bptr = (float *)frame->data[1] + slice_start * blinesize;
202+ float *rptr = (float *)frame->data[2] + slice_start * rlinesize;
203+
204+ for (int y = slice_start; y < slice_end; y++) {
205+ for (int x = 0; x < width; x++) {
206+ float g = gptr[x];
207+ float b = bptr[x];
208+ float r = rptr[x];
209+ float nr, ng, nb;
210+ float l0, l1, l;
211+
212+ PROCESS()
213+
214+ gptr[x] = ng;
215+ bptr[x] = nb;
216+ rptr[x] = nr;
217+ }
218+
219+ gptr += glinesize;
220+ bptr += blinesize;
221+ rptr += rlinesize;
222+ }
223+
224+ return 0;
225+}
226+
186227 static int temperature_slice8p(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
187228 {
188229 ColorTemperatureContext *s = ctx->priv;
@@ -285,6 +326,7 @@ static const enum AVPixelFormat pixel_fmts[] = { · 96 unmodified lines
285326 AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12,
286327 AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
287328 AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
329+ AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32,
288330 AV_PIX_FMT_RGB48, AV_PIX_FMT_BGR48,
289331 AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
290332 AV_PIX_FMT_NONE
@@ -308,6 +350,8 @@ static av_cold int config_input(AVFilterLink *inlink) · 17 unmodified lines
308350 s->do_slice = s->depth <= 8 ? temperature_slice8 : temperature_slice16;
309351 if (!planar)
310352 s->do_slice = s->depth <= 8 ? temperature_slice8p : temperature_slice16p;
353+ if (s->depth == 32)
354+ s->do_slice = temperature_slice32;
311355
312356 ff_fill_rgba_map(s->rgba_map, inlink->format);
313357

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