Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -73,7 +73,7 @@ static int query_formats(AVFilterContext *ctx) · 72 unmodified lines | ||
| 73 | 73 | AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14, |
| 74 | 74 | AV_PIX_FMT_YUV444P16, |
| 75 | 75 | AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, |
| 76 | − AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, | |
| 76 | + AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRPF32, | |
| 77 | 77 | AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16, |
| 78 | 78 | AV_PIX_FMT_NONE |
| 79 | 79 | }; |
| @@ -82,7 +82,7 @@ static int query_formats(AVFilterContext *ctx) · 2 unmodified lines | ||
| 82 | 82 | AV_PIX_FMT_YUVA444P, |
| 83 | 83 | AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA444P16, |
| 84 | 84 | AV_PIX_FMT_GBRAP, |
| 85 | − AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, | |
| 85 | + AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, AV_PIX_FMT_GBRAPF32, | |
| 86 | 86 | AV_PIX_FMT_NONE |
| 87 | 87 | }; |
| 88 | 88 | |
| @@ -218,6 +218,54 @@ static void premultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc, · 129 unmodified lines | ||
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | +static void premultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc, | |
| 222 | + uint8_t *ddst, | |
| 223 | + ptrdiff_t mlinesize, ptrdiff_t alinesize, | |
| 224 | + ptrdiff_t dlinesize, | |
| 225 | + int w, int h, | |
| 226 | + int half, int shift, int offset) | |
| 227 | +{ | |
| 228 | + const float *msrc = (const float *)mmsrc; | |
| 229 | + const float *asrc = (const float *)aasrc; | |
| 230 | + float *dst = (float *)ddst; | |
| 231 | + int x, y; | |
| 232 | + | |
| 233 | + for (y = 0; y < h; y++) { | |
| 234 | + for (x = 0; x < w; x++) { | |
| 235 | + dst[x] = msrc[x] * asrc[x]; | |
| 236 | + } | |
| 237 | + | |
| 238 | + dst += dlinesize / 4; | |
| 239 | + msrc += mlinesize / 4; | |
| 240 | + asrc += alinesize / 4; | |
| 241 | + } | |
| 242 | +} | |
| 243 | + | |
| 244 | +static void premultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc, | |
| 245 | + uint8_t *ddst, | |
| 246 | + ptrdiff_t mlinesize, ptrdiff_t alinesize, | |
| 247 | + ptrdiff_t dlinesize, | |
| 248 | + int w, int h, | |
| 249 | + int half, int shift, int offset) | |
| 250 | +{ | |
| 251 | + const float *msrc = (const float *)mmsrc; | |
| 252 | + const float *asrc = (const float *)aasrc; | |
| 253 | + float *dst = (float *)ddst; | |
| 254 | + int x, y; | |
| 255 | + | |
| 256 | + float offsetf = offset / 65535.0f; | |
| 257 | + | |
| 258 | + for (y = 0; y < h; y++) { | |
| 259 | + for (x = 0; x < w; x++) { | |
| 260 | + dst[x] = ((msrc[x] - offsetf) * asrc[x]) + offsetf; | |
| 261 | + } | |
| 262 | + | |
| 263 | + dst += dlinesize / 4; | |
| 264 | + msrc += mlinesize / 4; | |
| 265 | + asrc += alinesize / 4; | |
| 266 | + } | |
| 267 | +} | |
| 268 | + | |
| 221 | 269 | static void unpremultiply8(const uint8_t *msrc, const uint8_t *asrc, |
| 222 | 270 | uint8_t *dst, |
| 223 | 271 | ptrdiff_t mlinesize, ptrdiff_t alinesize, |
| @@ -365,6 +413,62 @@ static void unpremultiply16offset(const uint8_t *mmsrc, const uint8_t *aasrc, · 141 unmodified lines | ||
| 365 | 413 | } |
| 366 | 414 | } |
| 367 | 415 | |
| 416 | +static void unpremultiplyf32(const uint8_t *mmsrc, const uint8_t *aasrc, | |
| 417 | + uint8_t *ddst, | |
| 418 | + ptrdiff_t mlinesize, ptrdiff_t alinesize, | |
| 419 | + ptrdiff_t dlinesize, | |
| 420 | + int w, int h, | |
| 421 | + int half, int max, int offset) | |
| 422 | +{ | |
| 423 | + const float *msrc = (const float *)mmsrc; | |
| 424 | + const float *asrc = (const float *)aasrc; | |
| 425 | + | |
| 426 | + float *dst = (float *)ddst; | |
| 427 | + int x, y; | |
| 428 | + | |
| 429 | + for (y = 0; y < h; y++) { | |
| 430 | + for (x = 0; x < w; x++) { | |
| 431 | + if (asrc[x] > 0.0f) | |
| 432 | + dst[x] = msrc[x] / asrc[x]; | |
| 433 | + else | |
| 434 | + dst[x] = msrc[x]; | |
| 435 | + } | |
| 436 | + | |
| 437 | + dst += dlinesize / 4; | |
| 438 | + msrc += mlinesize / 4; | |
| 439 | + asrc += alinesize / 4; | |
| 440 | + } | |
| 441 | +} | |
| 442 | + | |
| 443 | +static void unpremultiplyf32offset(const uint8_t *mmsrc, const uint8_t *aasrc, | |
| 444 | + uint8_t *ddst, | |
| 445 | + ptrdiff_t mlinesize, ptrdiff_t alinesize, | |
| 446 | + ptrdiff_t dlinesize, | |
| 447 | + int w, int h, | |
| 448 | + int half, int max, int offset) | |
| 449 | +{ | |
| 450 | + const float *msrc = (const float *)mmsrc; | |
| 451 | + const float *asrc = (const float *)aasrc; | |
| 452 | + | |
| 453 | + float *dst = (float *)ddst; | |
| 454 | + int x, y; | |
| 455 | + | |
| 456 | + float offsetf = offset / 65535.0f; | |
| 457 | + | |
| 458 | + for (y = 0; y < h; y++) { | |
| 459 | + for (x = 0; x < w; x++) { | |
| 460 | + if (asrc[x] > 0.0f) | |
| 461 | + dst[x] = (msrc[x] - offsetf) / asrc[x] + offsetf; | |
| 462 | + else | |
| 463 | + dst[x] = msrc[x]; | |
| 464 | + } | |
| 465 | + | |
| 466 | + dst += dlinesize / 4; | |
| 467 | + msrc += mlinesize / 4; | |
| 468 | + asrc += alinesize / 4; | |
| 469 | + } | |
| 470 | +} | |
| 471 | + | |
| 368 | 472 | static int premultiply_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) |
| 369 | 473 | { |
| 370 | 474 | PreMultiplyContext *s = ctx->priv; |
| @@ -458,6 +562,10 @@ static int filter_frame(AVFilterContext *ctx, · 87 unmodified lines | ||
| 458 | 562 | case AV_PIX_FMT_GBRAP16: |
| 459 | 563 | s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiply16offset : unpremultiply16; |
| 460 | 564 | break; |
| 565 | + case AV_PIX_FMT_GBRPF32: | |
| 566 | + case AV_PIX_FMT_GBRAPF32: | |
| 567 | + s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? unpremultiplyf32offset : unpremultiplyf32; | |
| 568 | + break; | |
| 461 | 569 | case AV_PIX_FMT_GRAY8: |
| 462 | 570 | s->premultiply[0] = limited ? unpremultiply8offset : unpremultiply8; |
| 463 | 571 | break; |
| @@ -505,6 +613,10 @@ static int filter_frame(AVFilterContext *ctx, · 41 unmodified lines | ||
| 505 | 613 | case AV_PIX_FMT_GBRAP16: |
| 506 | 614 | s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiply16offset : premultiply16; |
| 507 | 615 | break; |
| 616 | + case AV_PIX_FMT_GBRPF32: | |
| 617 | + case AV_PIX_FMT_GBRAPF32: | |
| 618 | + s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = limited ? premultiplyf32offset: premultiplyf32; | |
| 619 | + break; | |
| 508 | 620 | case AV_PIX_FMT_GRAY8: |
| 509 | 621 | s->premultiply[0] = limited ? premultiply8offset : premultiply8; |
| 510 | 622 | break; |
| @@ -567,7 +679,7 @@ static int config_input(AVFilterLink *inlink) · 56 unmodified lines | ||
| 567 | 679 | s->width[1] = s->width[2] = AV_CEIL_RSHIFT(inlink->w, hsub); |
| 568 | 680 | s->width[0] = s->width[3] = inlink->w; |
| 569 | 681 | |
| 570 | − s->depth = desc->comp[0].depth; | |
| 682 | + s->depth = desc->flags & AV_PIX_FMT_FLAG_FLOAT ? 16 : desc->comp[0].depth; | |
| 571 | 683 | s->max = (1 << s->depth) - 1; |
| 572 | 684 | s->half = (1 << s->depth) / 2; |
| 573 | 685 | s->offset = 16 << (s->depth - 8); |