| 314 | | #define DEFINE_BLEND_EXPR(type, name, div) \ |
| 315 | | static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize, \ |
| 316 | | const uint8_t *_bottom, ptrdiff_t bottom_linesize, \ |
| 317 | | uint8_t *_dst, ptrdiff_t dst_linesize, \ |
| 318 | | ptrdiff_t width, ptrdiff_t height, \ |
| 319 | | FilterParams *param, double *values, int starty) \ |
| 320 | | { \ |
| 321 | | const type *top = (type*)_top; \ |
| 322 | | const type *bottom = (type*)_bottom; \ |
| 323 | | type *dst = (type*)_dst; \ |
| 324 | | AVExpr *e = param->e; \ |
| 325 | | int y, x; \ |
| 326 | | dst_linesize /= div; \ |
| 327 | | top_linesize /= div; \ |
| 328 | | bottom_linesize /= div; \ |
| 329 | | \ |
| 330 | | for (y = 0; y < height; y++) { \ |
| 331 | | values[VAR_Y] = y + starty; \ |
| 332 | | for (x = 0; x < width; x++) { \ |
| 333 | | values[VAR_X] = x; \ |
| 334 | | values[VAR_TOP] = values[VAR_A] = top[x]; \ |
| 335 | | values[VAR_BOTTOM] = values[VAR_B] = bottom[x]; \ |
| 336 | | dst[x] = av_expr_eval(e, values, NULL); \ |
| 337 | | } \ |
| 338 | | dst += dst_linesize; \ |
| 339 | | top += top_linesize; \ |
| 340 | | bottom += bottom_linesize; \ |
| 341 | | } \ |
| | 323 | static void blend_expr_8bit(const uint8_t *top, ptrdiff_t top_linesize, |
| | 324 | const uint8_t *bottom, ptrdiff_t bottom_linesize, |
| | 325 | uint8_t *dst, ptrdiff_t dst_linesize, |
| | 326 | ptrdiff_t width, ptrdiff_t height, |
| | 327 | FilterParams *param, double *values, int starty) |
| | 328 | { |
| | 329 | AVExpr *e = param->e; |
| | 330 | int y, x; |
| | 331 | |
| | 332 | for (y = 0; y < height; y++) { |
| | 333 | values[VAR_Y] = y + starty; |
| | 334 | for (x = 0; x < width; x++) { |
| | 335 | values[VAR_X] = x; |
| | 336 | values[VAR_TOP] = values[VAR_A] = top[x]; |
| | 337 | values[VAR_BOTTOM] = values[VAR_B] = bottom[x]; |
| | 338 | dst[x] = av_expr_eval(e, values, NULL); |
| | 339 | } |
| | 340 | dst += dst_linesize; |
| | 341 | top += top_linesize; |
| | 342 | bottom += bottom_linesize; |
| | 343 | } |
| 344 | | DEFINE_BLEND_EXPR(uint8_t, 8bit, 1) |
| 345 | | DEFINE_BLEND_EXPR(uint16_t, 16bit, 2) |
| | 346 | static void blend_expr_16bit(const uint8_t *_top, ptrdiff_t top_linesize, |
| | 347 | const uint8_t *_bottom, ptrdiff_t bottom_linesize, |
| | 348 | uint8_t *_dst, ptrdiff_t dst_linesize, |
| | 349 | ptrdiff_t width, ptrdiff_t height, |
| | 350 | FilterParams *param, double *values, int starty) |
| | 351 | { |
| | 352 | const uint16_t *top = (uint16_t*)_top; |
| | 353 | const uint16_t *bottom = (uint16_t*)_bottom; |
| | 354 | uint16_t *dst = (uint16_t*)_dst; |
| | 355 | AVExpr *e = param->e; |
| | 356 | int y, x; |
| | 357 | dst_linesize /= 2; |
| | 358 | top_linesize /= 2; |
| | 359 | bottom_linesize /= 2; |
| | 360 | |
| | 361 | for (y = 0; y < height; y++) { |
| | 362 | values[VAR_Y] = y + starty; |
| | 363 | for (x = 0; x < width; x++) { |
| | 364 | uint16_t dst_v; |
| | 365 | values[VAR_X] = x; |
| | 366 | values[VAR_TOP] = values[VAR_A] = AV_RN16(top + x); |
| | 367 | values[VAR_BOTTOM] = values[VAR_B] = AV_RN16(bottom + x); |
| | 368 | dst_v = av_expr_eval(e, values, NULL); |
| | 369 | AV_WN16(dst + x, dst_v); |
| | 370 | } |
| | 371 | dst += dst_linesize; |
| | 372 | top += top_linesize; |
| | 373 | bottom += bottom_linesize; |
| | 374 | } |
| | 375 | } |