1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avfilter/vf_extractplanes: add float formats support

This commit is contained in:
Paul B Mahol 2021-02-07 21:41:04 +01:00
parent cae57cae1f
commit 629dd8efb5
2 changed files with 18 additions and 2 deletions

View File

@ -70,6 +70,10 @@ int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
case AV_PIX_FMT_GBRAP12BE:
case AV_PIX_FMT_GBRAP16LE:
case AV_PIX_FMT_GBRAP16BE:
case AV_PIX_FMT_GBRPF32LE:
case AV_PIX_FMT_GBRPF32BE:
case AV_PIX_FMT_GBRAPF32LE:
case AV_PIX_FMT_GBRAPF32BE:
case AV_PIX_FMT_GBRP: rgba_map[GREEN] = 0; rgba_map[BLUE ] = 1; rgba_map[RED ] = 2; rgba_map[ALPHA] = 3; break;
default: /* unsupported */
return AVERROR(EINVAL);

View File

@ -115,16 +115,22 @@ AVFILTER_DEFINE_CLASS(extractplanes);
AV_PIX_FMT_YUV422P14##suf, \
AV_PIX_FMT_YUV444P14##suf
#define FLOAT_FORMATS(suf) \
AV_PIX_FMT_GRAYF32##suf, \
AV_PIX_FMT_GBRPF32##suf, AV_PIX_FMT_GBRAPF32##suf \
static int query_formats(AVFilterContext *ctx)
{
static const enum AVPixelFormat in_pixfmts_le[] = {
EIGHTBIT_FORMATS,
HIGHDEPTH_FORMATS(LE),
FLOAT_FORMATS(LE),
AV_PIX_FMT_NONE,
};
static const enum AVPixelFormat in_pixfmts_be[] = {
EIGHTBIT_FORMATS,
HIGHDEPTH_FORMATS(BE),
FLOAT_FORMATS(BE),
AV_PIX_FMT_NONE,
};
static const enum AVPixelFormat out8_pixfmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE };
@ -138,6 +144,8 @@ static int query_formats(AVFilterContext *ctx)
static const enum AVPixelFormat out14be_pixfmts[] = { AV_PIX_FMT_GRAY14BE, AV_PIX_FMT_NONE };
static const enum AVPixelFormat out16le_pixfmts[] = { AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_NONE };
static const enum AVPixelFormat out16be_pixfmts[] = { AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_NONE };
static const enum AVPixelFormat out32le_pixfmts[] = { AV_PIX_FMT_GRAYF32LE, AV_PIX_FMT_NONE };
static const enum AVPixelFormat out32be_pixfmts[] = { AV_PIX_FMT_GRAYF32BE, AV_PIX_FMT_NONE };
const enum AVPixelFormat *out_pixfmts, *in_pixfmts;
const AVPixFmtDescriptor *desc;
AVFilterFormats *avff;
@ -187,10 +195,14 @@ static int query_formats(AVFilterContext *ctx)
out_pixfmts = out14le_pixfmts;
else if (be && depth == 14)
out_pixfmts = out14be_pixfmts;
else if (be)
else if (be && depth == 16)
out_pixfmts = out16be_pixfmts;
else
else if (!be && depth == 16)
out_pixfmts = out16le_pixfmts;
else if (be && depth == 32)
out_pixfmts = out32be_pixfmts;
else
out_pixfmts = out32le_pixfmts;
for (i = 0; i < ctx->nb_outputs; i++)
if ((ret = ff_formats_ref(ff_make_format_list(out_pixfmts), &ctx->outputs[i]->incfg.formats)) < 0)