Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Vittorio Giovara authored on 2017/07/11 00:21:30... | ... |
@@ -36,6 +36,7 @@ |
36 | 36 |
#include "libavutil/avstring.h" |
37 | 37 |
#include "libavutil/eval.h" |
38 | 38 |
#include "libavutil/internal.h" |
39 |
+#include "libavutil/intreadwrite.h" |
|
39 | 40 |
#include "libavutil/mathematics.h" |
40 | 41 |
#include "libavutil/opt.h" |
41 | 42 |
#include "libavutil/parseutils.h" |
... | ... |
@@ -179,6 +180,7 @@ static int query_formats(AVFilterContext *ctx) |
179 | 179 |
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, |
180 | 180 |
AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, |
181 | 181 |
AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP16, |
182 |
+ AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, |
|
182 | 183 |
AV_PIX_FMT_NONE |
183 | 184 |
}; |
184 | 185 |
int ret; |
... | ... |
@@ -429,7 +431,7 @@ static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFm |
429 | 429 |
format->subsample_w = desc->log2_chroma_w; |
430 | 430 |
format->subsample_h = desc->log2_chroma_h; |
431 | 431 |
format->depth = desc->comp[0].depth; |
432 |
- format->pixel_type = desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE; |
|
432 |
+ format->pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE; |
|
433 | 433 |
format->color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV; |
434 | 434 |
format->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : colorspace == -1 ? convert_matrix(frame->colorspace) : colorspace; |
435 | 435 |
format->color_primaries = primaries == -1 ? convert_primaries(frame->color_primaries) : primaries; |
... | ... |
@@ -573,13 +575,13 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) |
573 | 573 |
s->alpha_src_format.width = in->width; |
574 | 574 |
s->alpha_src_format.height = in->height; |
575 | 575 |
s->alpha_src_format.depth = desc->comp[0].depth; |
576 |
- s->alpha_src_format.pixel_type = desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE; |
|
576 |
+ s->alpha_src_format.pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE; |
|
577 | 577 |
s->alpha_src_format.color_family = ZIMG_COLOR_GREY; |
578 | 578 |
|
579 | 579 |
s->alpha_dst_format.width = out->width; |
580 | 580 |
s->alpha_dst_format.height = out->height; |
581 | 581 |
s->alpha_dst_format.depth = odesc->comp[0].depth; |
582 |
- s->alpha_dst_format.pixel_type = odesc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE; |
|
582 |
+ s->alpha_dst_format.pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : odesc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE; |
|
583 | 583 |
s->alpha_dst_format.color_family = ZIMG_COLOR_GREY; |
584 | 584 |
|
585 | 585 |
zimg_filter_graph_free(s->alpha_graph); |
... | ... |
@@ -641,10 +643,19 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) |
641 | 641 |
goto fail; |
642 | 642 |
} |
643 | 643 |
} else if (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) { |
644 |
- int y; |
|
645 |
- |
|
646 |
- for (y = 0; y < outlink->h; y++) |
|
647 |
- memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w); |
|
644 |
+ int x, y; |
|
645 |
+ |
|
646 |
+ if (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) { |
|
647 |
+ for (y = 0; y < out->height; y++) { |
|
648 |
+ for (x = 0; x < out->width; x++) { |
|
649 |
+ AV_WN32(out->data[3] + x * odesc->comp[3].step + y * out->linesize[3], |
|
650 |
+ av_float2int(1.0f)); |
|
651 |
+ } |
|
652 |
+ } |
|
653 |
+ } else { |
|
654 |
+ for (y = 0; y < outlink->h; y++) |
|
655 |
+ memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w); |
|
656 |
+ } |
|
648 | 657 |
} |
649 | 658 |
|
650 | 659 |
fail: |