-static void remap_packed(RemapContext *s, const AVFrame *in,
- const AVFrame *xin, const AVFrame *yin,
- AVFrame *out)
-{
- uint8_t *dst = out->data[0];
- const uint8_t *src = in->data[0];
- const int dlinesize = out->linesize[0];
- const int slinesize = in->linesize[0];
- const int xlinesize = xin->linesize[0] / 2;
- const int ylinesize = yin->linesize[0] / 2;
- const uint16_t *xmap = (const uint16_t *)xin->data[0];
- const uint16_t *ymap = (const uint16_t *)yin->data[0];
- const int step = s->step;
- int c, x, y;
-
- for (y = 0; y < out->height; y++) {
- for (x = 0; x < out->width; x++) {
- for (c = 0; c < s->nb_components; c++) {
- if (ymap[x] < in->height && xmap[x] < in->width) {
- dst[x * step + c] = src[ymap[x] * slinesize + xmap[x] * step + c];
- } else {
- dst[x * step + c] = 0;
- }
- }
- }
- dst += dlinesize;
- xmap += xlinesize;
- ymap += ylinesize;
- }
+#define DEFINE_REMAP_PACKED_FUNC(name, bits, div) \
+static int remap_packed##bits##_##name##_slice(AVFilterContext *ctx, void *arg, \
+ int jobnr, int nb_jobs) \
+{ \
+ RemapContext *s = ctx->priv; \
+ const ThreadData *td = arg; \
+ const AVFrame *in = td->in; \
+ const AVFrame *xin = td->xin; \
+ const AVFrame *yin = td->yin; \
+ const AVFrame *out = td->out; \
+ const int slice_start = (out->height * jobnr ) / nb_jobs; \
+ const int slice_end = (out->height * (jobnr+1)) / nb_jobs; \
+ const int dlinesize = out->linesize[0] / div; \
+ const int slinesize = in->linesize[0] / div; \
+ const int xlinesize = xin->linesize[0] / 2; \
+ const int ylinesize = yin->linesize[0] / 2; \
+ const uint##bits##_t *src = (const uint##bits##_t *)in->data[0]; \
+ uint##bits##_t *dst = (uint##bits##_t *)out->data[0] + slice_start * dlinesize; \
+ const uint16_t *xmap = (const uint16_t *)xin->data[0] + slice_start * xlinesize; \
+ const uint16_t *ymap = (const uint16_t *)yin->data[0] + slice_start * ylinesize; \
+ const int step = td->step / div; \
+ int c, x, y; \
+ \
+ for (y = slice_start; y < slice_end; y++) { \
+ for (x = 0; x < out->width; x++) { \
+ for (c = 0; c < td->nb_components; c++) { \
+ if (ymap[x] < in->height && xmap[x] < in->width) { \
+ dst[x * step + c] = src[ymap[x] * slinesize + xmap[x] * step + c]; \
+ } else { \
+ dst[x * step + c] = s->fill_color[c]; \
+ } \
+ } \
+ } \
+ dst += dlinesize; \
+ xmap += xlinesize; \
+ ymap += ylinesize; \
+ } \
+ \
+ return 0; \