diff options
author | Timo Rothenpieler <timo@rothenpieler.org> | 2016-08-29 17:44:42 +0200 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2016-08-31 13:19:46 +0200 |
commit | 99882d05a6635446d587ed51b095c627abc42587 (patch) | |
tree | e9086b3d567fb6b467622d8594a6cefabb55f57f /libswscale | |
parent | 2625b955a31a94d5f433ba75e933d1acf4259f13 (diff) |
swscale: add support for P010LE/BE output
Diffstat (limited to 'libswscale')
-rw-r--r-- | libswscale/output.c | 98 | ||||
-rw-r--r-- | libswscale/utils.c | 4 | ||||
-rw-r--r-- | libswscale/x86/swscale.c | 4 |
3 files changed, 101 insertions, 5 deletions
diff --git a/libswscale/output.c b/libswscale/output.c index f340c53eaa..62cbe2ffaa 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -311,6 +311,98 @@ static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterS } } + +#define output_pixel(pos, val) \ + if (big_endian) { \ + AV_WB16(pos, av_clip_uintp2(val >> shift, 10) << 6); \ + } else { \ + AV_WL16(pos, av_clip_uintp2(val >> shift, 10) << 6); \ + } + +static void yuv2p010l1_c(const int16_t *src, + uint16_t *dest, int dstW, + int big_endian) +{ + int i; + int shift = 5; + + for (i = 0; i < dstW; i++) { + int val = src[i] + (1 << (shift - 1)); + output_pixel(&dest[i], val); + } +} + +static void yuv2p010lX_c(const int16_t *filter, int filterSize, + const int16_t **src, uint16_t *dest, int dstW, + int big_endian) +{ + int i, j; + int shift = 17; + + for (i = 0; i < dstW; i++) { + int val = 1 << (shift - 1); + + for (j = 0; j < filterSize; j++) + val += src[j][i] * filter[j]; + + output_pixel(&dest[i], val); + } +} + +static void yuv2p010cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize, + const int16_t **chrUSrc, const int16_t **chrVSrc, + uint8_t *dest8, int chrDstW) +{ + uint16_t *dest = (uint16_t*)dest8; + int shift = 17; + int big_endian = c->dstFormat == AV_PIX_FMT_P010BE; + int i, j; + + for (i = 0; i < chrDstW; i++) { + int u = 1 << (shift - 1); + int v = 1 << (shift - 1); + + for (j = 0; j < chrFilterSize; j++) { + u += chrUSrc[j][i] * chrFilter[j]; + v += chrVSrc[j][i] * chrFilter[j]; + } + + output_pixel(&dest[2*i] , u); + output_pixel(&dest[2*i+1], v); + } +} + +static void yuv2p010l1_LE_c(const int16_t *src, + uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010l1_c(src, (uint16_t*)dest, dstW, 0); +} + +static void yuv2p010l1_BE_c(const int16_t *src, + uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010l1_c(src, (uint16_t*)dest, dstW, 1); +} + +static void yuv2p010lX_LE_c(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0); +} + +static void yuv2p010lX_BE_c(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1); +} + +#undef output_pixel + + #define accumulate_bit(acc, val) \ acc <<= 1; \ acc |= (val) >= 234 @@ -2085,7 +2177,11 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, enum AVPixelFormat dstFormat = c->dstFormat; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat); - if (is16BPS(dstFormat)) { + if (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P010BE) { + *yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c; + *yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c; + *yuv2nv12cX = yuv2p010cX_c; + } else if (is16BPS(dstFormat)) { *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c; *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c; } else if (is9_OR_10BPS(dstFormat)) { diff --git a/libswscale/utils.c b/libswscale/utils.c index 576d8f0d5a..0aef672041 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -246,8 +246,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = { [AV_PIX_FMT_XYZ12BE] = { 1, 1, 1 }, [AV_PIX_FMT_XYZ12LE] = { 1, 1, 1 }, [AV_PIX_FMT_AYUV64LE] = { 1, 1}, - [AV_PIX_FMT_P010LE] = { 1, 0 }, - [AV_PIX_FMT_P010BE] = { 1, 0 }, + [AV_PIX_FMT_P010LE] = { 1, 1 }, + [AV_PIX_FMT_P010BE] = { 1, 1 }, }; int sws_isSupportedInput(enum AVPixelFormat pix_fmt) diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index d68e46b1c3..869e7fb176 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -429,14 +429,14 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c) #define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \ switch(c->dstBpc){ \ case 16: do_16_case; break; \ - case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ + case 10: if (!isBE(c->dstFormat) && c->dstFormat != AV_PIX_FMT_P010LE) vscalefn = ff_yuv2planeX_10_ ## opt; break; \ case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \ case 8: if ((condition_8bit) && !c->use_mmx_vfilter) vscalefn = ff_yuv2planeX_8_ ## opt; break; \ } #define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \ switch(c->dstBpc){ \ case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \ - case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ + case 10: if (!isBE(c->dstFormat) && c->dstFormat != AV_PIX_FMT_P010LE && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \ case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \ case 8: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \ default: av_assert0(c->dstBpc>8); \ |