You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avfilter/vf_zscale: add support for half precision float RGB formats
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@ -209,6 +209,7 @@ static int query_formats(const AVFilterContext *ctx,
|
|||||||
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
|
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_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
|
||||||
AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP14, AV_PIX_FMT_GBRAP16,
|
AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP14, AV_PIX_FMT_GBRAP16,
|
||||||
|
AV_PIX_FMT_GBRPF16, AV_PIX_FMT_GBRAPF16,
|
||||||
AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32,
|
AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32,
|
||||||
AV_PIX_FMT_NONE
|
AV_PIX_FMT_NONE
|
||||||
};
|
};
|
||||||
@ -582,7 +583,8 @@ static void format_init(zimg_image_format *format, AVFrame *frame, const AVPixFm
|
|||||||
format->subsample_w = desc->log2_chroma_w;
|
format->subsample_w = desc->log2_chroma_w;
|
||||||
format->subsample_h = desc->log2_chroma_h;
|
format->subsample_h = desc->log2_chroma_h;
|
||||||
format->depth = desc->comp[0].depth;
|
format->depth = desc->comp[0].depth;
|
||||||
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->pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? (desc->comp[0].depth > 16 ? ZIMG_PIXEL_FLOAT : ZIMG_PIXEL_HALF)
|
||||||
|
: (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->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->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->color_primaries = primaries == -1 ? convert_primaries(frame->color_primaries) : primaries;
|
||||||
@ -861,11 +863,13 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
|
|||||||
s->alpha_src_format.width = in->width;
|
s->alpha_src_format.width = in->width;
|
||||||
s->alpha_src_format.height = in->height;
|
s->alpha_src_format.height = in->height;
|
||||||
s->alpha_src_format.depth = desc->comp[0].depth;
|
s->alpha_src_format.depth = desc->comp[0].depth;
|
||||||
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.pixel_type = (desc->flags & AV_PIX_FMT_FLAG_FLOAT) ? (desc->comp[0].depth > 16 ? ZIMG_PIXEL_FLOAT : ZIMG_PIXEL_HALF)
|
||||||
|
: (desc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE);
|
||||||
s->alpha_src_format.color_family = ZIMG_COLOR_GREY;
|
s->alpha_src_format.color_family = ZIMG_COLOR_GREY;
|
||||||
|
|
||||||
s->alpha_dst_format.depth = odesc->comp[0].depth;
|
s->alpha_dst_format.depth = odesc->comp[0].depth;
|
||||||
s->alpha_dst_format.pixel_type = (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) ? ZIMG_PIXEL_FLOAT : odesc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE;
|
s->alpha_dst_format.pixel_type = (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) ? (odesc->comp[0].depth > 16 ? ZIMG_PIXEL_FLOAT : ZIMG_PIXEL_HALF)
|
||||||
|
: (odesc->comp[0].depth > 8 ? ZIMG_PIXEL_WORD : ZIMG_PIXEL_BYTE);
|
||||||
s->alpha_dst_format.color_family = ZIMG_COLOR_GREY;
|
s->alpha_dst_format.color_family = ZIMG_COLOR_GREY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,8 +913,14 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
|
|||||||
if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) && (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) ){
|
if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) && (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) ){
|
||||||
int x, y;
|
int x, y;
|
||||||
if (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) {
|
if (odesc->flags & AV_PIX_FMT_FLAG_FLOAT) {
|
||||||
|
const uint16_t h_one = 0x3C00; // float2half(1.0f)
|
||||||
for (y = 0; y < out->height; y++) {
|
for (y = 0; y < out->height; y++) {
|
||||||
const ptrdiff_t row = y * out->linesize[3];
|
const ptrdiff_t row = y * out->linesize[3];
|
||||||
|
if (odesc->comp[0].depth == 16)
|
||||||
|
for (x = 0; x < out->width; x++) {
|
||||||
|
AV_WN16(out->data[3] + x * odesc->comp[3].step + row, h_one);
|
||||||
|
}
|
||||||
|
else
|
||||||
for (x = 0; x < out->width; x++) {
|
for (x = 0; x < out->width; x++) {
|
||||||
AV_WN32(out->data[3] + x * odesc->comp[3].step + row,
|
AV_WN32(out->data[3] + x * odesc->comp[3].step + row,
|
||||||
av_float2int(1.0f));
|
av_float2int(1.0f));
|
||||||
|
Reference in New Issue
Block a user