#include "libavutil/avstring.h"
#include "libavutil/eval.h"
#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP16,
+ AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32,
AV_PIX_FMT_NONE
};
int ret;
format->subsample_w = desc->log2_chroma_w;
format->subsample_h = desc->log2_chroma_h;
format->depth = desc->comp[0].depth;
- format->pixel_type = desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
+ format->pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
format->color_family = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_COLOR_RGB : ZIMG_COLOR_YUV;
format->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? ZIMG_MATRIX_RGB : colorspace == -1 ? convert_matrix(frame->colorspace) : colorspace;
format->color_primaries = primaries == -1 ? convert_primaries(frame->color_primaries) : primaries;
format->chroma_location = location == -1 ? convert_chroma_location(frame->chroma_location) : location;
}
+static int graph_build(zimg_filter_graph **graph, zimg_graph_builder_params *params,
+ zimg_image_format *src_format, zimg_image_format *dst_format,
+ void **tmp, size_t *tmp_size)
+{
+ int ret;
+ size_t size;
+
+ zimg_filter_graph_free(*graph);
+ *graph = zimg_filter_graph_build(src_format, dst_format, params);
+ if (!*graph)
+ return print_zimg_error(NULL);
+
+ ret = zimg_filter_graph_get_tmp_size(*graph, &size);
+ if (ret)
+ return print_zimg_error(NULL);
+
+ if (size > *tmp_size) {
+ av_freep(tmp);
+ *tmp = av_malloc(size);
+ if (!*tmp)
+ return AVERROR(ENOMEM);
+
+ *tmp_size = size;
+ }
+
+ return 0;
+}
+
static int filter_frame(AVFilterLink *link, AVFrame *in)
{
ZScaleContext *s = link->dst->priv;
zimg_image_buffer_const src_buf = { ZIMG_API_VERSION };
zimg_image_buffer dst_buf = { ZIMG_API_VERSION };
char buf[32];
- size_t tmp_size;
int ret = 0, plane;
AVFrame *out;
if (s->chromal != -1)
out->chroma_location = (int)s->dst_format.chroma_location - 1;
- zimg_filter_graph_free(s->graph);
- s->graph = zimg_filter_graph_build(&s->src_format, &s->dst_format, &s->params);
- if (!s->graph) {
- ret = print_zimg_error(link->dst);
+ ret = graph_build(&s->graph, &s->params, &s->src_format, &s->dst_format,
+ &s->tmp, &s->tmp_size);
+ if (ret < 0)
goto fail;
- }
-
- if ((ret = zimg_filter_graph_get_tmp_size(s->graph, &tmp_size))) {
- ret = print_zimg_error(link->dst);
- goto fail;
- }
-
- if (tmp_size > s->tmp_size) {
- av_freep(&s->tmp);
- s->tmp = av_malloc(tmp_size);
- if (!s->tmp) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
- s->tmp_size = tmp_size;
- }
s->in_colorspace = in->colorspace;
s->in_trc = in->color_trc;
s->alpha_src_format.width = in->width;
s->alpha_src_format.height = in->height;
s->alpha_src_format.depth = desc->comp[0].depth;
- s->alpha_src_format.pixel_type = desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
+ 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;
s->alpha_src_format.color_family = ZIMG_COLOR_GREY;
s->alpha_dst_format.width = out->width;
s->alpha_dst_format.height = out->height;
s->alpha_dst_format.depth = odesc->comp[0].depth;
- s->alpha_dst_format.pixel_type = odesc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
+ 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;
s->alpha_dst_format.color_family = ZIMG_COLOR_GREY;
zimg_filter_graph_free(s->alpha_graph);
goto fail;
}
} else if (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
- int y;
-
- for (y = 0; y < outlink->h; y++)
- memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w);
+ int x, y;
+
+ if (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) {
+ for (y = 0; y < out->height; y++) {
+ for (x = 0; x < out->width; x++) {
+ AV_WN32(out->data[3] + x * odesc->comp[3].step + y * out->linesize[3],
+ av_float2int(1.0f));
+ }
+ }
+ } else {
+ for (y = 0; y < outlink->h; y++)
+ memset(out->data[3] + y * out->linesize[3], 0xff, outlink->w);
+ }
}
fail: