diff options
author | Sergey Lavrushkin <dualfal@gmail.com> | 2018-08-03 18:06:50 +0300 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-08-14 19:22:39 +0300 |
commit | 582bc5a348f5cd12b6ad3be4ecbee71bc082ea32 (patch) | |
tree | 8d53324a7a2b107bf4541740c07a6fcc4640f3b1 /libswscale/utils.c | |
parent | 551a029a181abe2b7b6f16e9631423a12e9fcae9 (diff) |
libswscale: Adds conversions from/to float gray format.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r-- | libswscale/utils.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c index 61b47182f8..5e56371180 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -258,6 +258,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = { [AV_PIX_FMT_P010BE] = { 1, 1 }, [AV_PIX_FMT_P016LE] = { 1, 1 }, [AV_PIX_FMT_P016BE] = { 1, 1 }, + [AV_PIX_FMT_GRAYF32LE] = { 1, 1 }, + [AV_PIX_FMT_GRAYF32BE] = { 1, 1 }, }; int sws_isSupportedInput(enum AVPixelFormat pix_fmt) @@ -1173,6 +1175,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, const AVPixFmtDescriptor *desc_dst; int ret = 0; enum AVPixelFormat tmpFmt; + static const float float_mult = 1.0f / 255.0f; cpu_flags = av_get_cpu_flags(); flags = c->flags; @@ -1537,6 +1540,19 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, } } + if (unscaled && c->srcBpc == 8 && dstFormat == AV_PIX_FMT_GRAYF32){ + for (i = 0; i < 256; ++i){ + c->uint2float_lut[i] = (float)i * float_mult; + } + } + + // float will be converted to uint16_t + if ((srcFormat == AV_PIX_FMT_GRAYF32BE || srcFormat == AV_PIX_FMT_GRAYF32LE) && + (!unscaled || unscaled && dstFormat != srcFormat && (srcFormat != AV_PIX_FMT_GRAYF32 || + dstFormat != AV_PIX_FMT_GRAY8))){ + c->srcBpc = 16; + } + if (CONFIG_SWSCALE_ALPHA && isALPHA(srcFormat) && !isALPHA(dstFormat)) { enum AVPixelFormat tmpFormat = alphaless_fmt(srcFormat); @@ -1793,7 +1809,9 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, /* unscaled special cases */ if (unscaled && !usesHFilter && !usesVFilter && - (c->srcRange == c->dstRange || isAnyRGB(dstFormat))) { + (c->srcRange == c->dstRange || isAnyRGB(dstFormat) || + srcFormat == AV_PIX_FMT_GRAYF32 && dstFormat == AV_PIX_FMT_GRAY8 || + srcFormat == AV_PIX_FMT_GRAY8 && dstFormat == AV_PIX_FMT_GRAYF32)) { ff_get_unscaled_swscale(c); if (c->swscale) { |