+typedef struct ThreadData {
+ AVFrame *in, *out;
+ const AVPixFmtDescriptor *desc;
+ double peak;
+} ThreadData;
+
+static int tonemap_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+{
+ TonemapContext *s = ctx->priv;
+ ThreadData *td = arg;
+ AVFrame *in = td->in;
+ AVFrame *out = td->out;
+ const AVPixFmtDescriptor *desc = td->desc;
+ const int slice_start = (in->height * jobnr) / nb_jobs;
+ const int slice_end = (in->height * (jobnr+1)) / nb_jobs;
+ double peak = td->peak;
+
+ for (int y = slice_start; y < slice_end; y++)
+ for (int x = 0; x < out->width; x++)
+ tonemap(s, out, in, desc, x, y, peak);
+
+ return 0;
+}
+