Unified · Split
| @@ -322,24 +322,31 @@ static inline int selective_color_##nbits(AVFilterContext *ctx, ThreadData *td, · 321 unmodified lines | |||
| 322 | const int width = in->width; \ | 322 | const int width = in->width; \ |
| 323 | const int slice_start = (height * jobnr ) / nb_jobs; \ | 323 | const int slice_start = (height * jobnr ) / nb_jobs; \ |
| 324 | const int slice_end = (height * (jobnr+1)) / nb_jobs; \ | 324 | const int slice_end = (height * (jobnr+1)) / nb_jobs; \ |
| 325 | const int dst_linesize = out->linesize[0]; \ | 325 | const int dst_linesize = out->linesize[0] / ((nbits + 7) / 8); \ |
| 326 | const int src_linesize = in->linesize[0]; \ | 326 | const int src_linesize = in->linesize[0] / ((nbits + 7) / 8); \ |
| 327 | const uint8_t roffset = s->rgba_map[R]; \ | 327 | const uint8_t roffset = s->rgba_map[R]; \ |
| 328 | const uint8_t goffset = s->rgba_map[G]; \ | 328 | const uint8_t goffset = s->rgba_map[G]; \ |
| 329 | const uint8_t boffset = s->rgba_map[B]; \ | 329 | const uint8_t boffset = s->rgba_map[B]; \ |
| 330 | const uint8_t aoffset = s->rgba_map[A]; \ | 330 | const uint8_t aoffset = s->rgba_map[A]; \ |
| 331 | uint##nbits##_t *dst = (uint##nbits##_t *)out->data[0] + slice_start * dst_linesize; \ | ||
| 332 | const uint##nbits##_t *src = (const uint##nbits##_t *)in->data[0] + slice_start * src_linesize; \ | ||
| 333 | const uint##nbits##_t *src_r = (const uint##nbits##_t *)src + roffset; \ | ||
| 334 | const uint##nbits##_t *src_g = (const uint##nbits##_t *)src + goffset; \ | ||
| 335 | const uint##nbits##_t *src_b = (const uint##nbits##_t *)src + boffset; \ | ||
| 336 | const uint##nbits##_t *src_a = (const uint##nbits##_t *)src + aoffset; \ | ||
| 337 | uint##nbits##_t *dst_r = (uint##nbits##_t *)dst + roffset; \ | ||
| 338 | uint##nbits##_t *dst_g = (uint##nbits##_t *)dst + goffset; \ | ||
| 339 | uint##nbits##_t *dst_b = (uint##nbits##_t *)dst + boffset; \ | ||
| 340 | uint##nbits##_t *dst_a = (uint##nbits##_t *)dst + aoffset; \ | ||
| 331 | const int mid = 1<<(nbits-1); \ | 341 | const int mid = 1<<(nbits-1); \ |
| 332 | const int max = (1<<nbits)-1; \ | 342 | const int max = (1<<nbits)-1; \ |
| 333 | const float scale = 1.f / max; \ | 343 | const float scale = 1.f / max; \ |
| 334 | \ | 344 | \ |
| 335 | for (y = slice_start; y < slice_end; y++) { \ | 345 | for (y = slice_start; y < slice_end; y++) { \ |
| 336 | uint##nbits##_t *dst = ( uint##nbits##_t *)(out->data[0] + y * dst_linesize); \ | ||
| 337 | const uint##nbits##_t *src = (const uint##nbits##_t *)( in->data[0] + y * src_linesize); \ | ||
| 338 | \ | ||
| 339 | for (x = 0; x < width * s->step; x += s->step) { \ | 346 | for (x = 0; x < width * s->step; x += s->step) { \ |
| 340 | const int r = src[x + roffset]; \ | 347 | const int r = src_r[x]; \ |
| 341 | const int g = src[x + goffset]; \ | 348 | const int g = src_g[x]; \ |
| 342 | const int b = src[x + boffset]; \ | 349 | const int b = src_b[x]; \ |
| 343 | const int min_color = FFMIN3(r, g, b); \ | 350 | const int min_color = FFMIN3(r, g, b); \ |
| 344 | const int max_color = FFMAX3(r, g, b); \ | 351 | const int max_color = FFMAX3(r, g, b); \ |
| 345 | const int is_white = (r > mid && g > mid && b > mid); \ | 352 | const int is_white = (r > mid && g > mid && b > mid); \ |
| @@ -382,13 +389,23 @@ static inline int selective_color_##nbits(AVFilterContext *ctx, ThreadData *td, · 36 unmodified lines | |||
| 382 | } \ | 389 | } \ |
| 383 | \ | 390 | \ |
| 384 | if (!direct || adjust_r || adjust_g || adjust_b) { \ | 391 | if (!direct || adjust_r || adjust_g || adjust_b) { \ |
| 385 | dst[x + roffset] = av_clip_uint##nbits(r + adjust_r); \ | 392 | dst_r[x] = av_clip_uint##nbits(r + adjust_r); \ |
| 386 | dst[x + goffset] = av_clip_uint##nbits(g + adjust_g); \ | 393 | dst_g[x] = av_clip_uint##nbits(g + adjust_g); \ |
| 387 | dst[x + boffset] = av_clip_uint##nbits(b + adjust_b); \ | 394 | dst_b[x] = av_clip_uint##nbits(b + adjust_b); \ |
| 388 | if (!direct && s->step == 4) \ | 395 | if (!direct && s->step == 4) \ |
| 389 | dst[x + aoffset] = src[x + aoffset]; \ | 396 | dst_a[x] = src_a[x]; \ |
| 390 | } \ | 397 | } \ |
| 391 | } \ | 398 | } \ |
| 399 | \ | ||
| 400 | src_r += src_linesize; \ | ||
| 401 | src_g += src_linesize; \ | ||
| 402 | src_b += src_linesize; \ | ||
| 403 | src_a += src_linesize; \ | ||
| 404 | \ | ||
| 405 | dst_r += dst_linesize; \ | ||
| 406 | dst_g += dst_linesize; \ | ||
| 407 | dst_b += dst_linesize; \ | ||
| 408 | dst_a += dst_linesize; \ | ||
| 392 | } \ | 409 | } \ |
| 393 | return 0; \ | 410 | return 0; \ |
| 394 | } | 411 | } |