Commit 328ea6a9 authored by Michael Niedermayer's avatar Michael Niedermayer Committed by Luca Barbato

swscale: Add input support for 12-bit formats

Implemented for AV_PIX_FMT_GBRP12.
Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent 1e93aa69
...@@ -691,6 +691,16 @@ static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w) ...@@ -691,6 +691,16 @@ static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
planar_rgb16_to_y(dst, src, w, 10, 1); planar_rgb16_to_y(dst, src, w, 10, 1);
} }
static void planar_rgb12le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
{
planar_rgb16_to_y(dst, src, w, 12, 0);
}
static void planar_rgb12be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
{
planar_rgb16_to_y(dst, src, w, 12, 1);
}
static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w) static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
{ {
planar_rgb16_to_y(dst, src, w, 16, 0); planar_rgb16_to_y(dst, src, w, 16, 0);
...@@ -744,6 +754,18 @@ static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV, ...@@ -744,6 +754,18 @@ static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV,
planar_rgb16_to_uv(dstU, dstV, src, w, 10, 1); planar_rgb16_to_uv(dstU, dstV, src, w, 10, 1);
} }
static void planar_rgb12le_to_uv(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src[4], int w)
{
planar_rgb16_to_uv(dstU, dstV, src, w, 12, 0);
}
static void planar_rgb12be_to_uv(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src[4], int w)
{
planar_rgb16_to_uv(dstU, dstV, src, w, 12, 1);
}
static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV, static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src[4], int w) const uint8_t *src[4], int w)
{ {
...@@ -790,6 +812,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) ...@@ -790,6 +812,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP10LE: case AV_PIX_FMT_GBRP10LE:
c->readChrPlanar = planar_rgb10le_to_uv; c->readChrPlanar = planar_rgb10le_to_uv;
break; break;
case AV_PIX_FMT_GBRP12LE:
c->readChrPlanar = planar_rgb12le_to_uv;
break;
case AV_PIX_FMT_GBRAP16LE: case AV_PIX_FMT_GBRAP16LE:
case AV_PIX_FMT_GBRP16LE: case AV_PIX_FMT_GBRP16LE:
c->readChrPlanar = planar_rgb16le_to_uv; c->readChrPlanar = planar_rgb16le_to_uv;
...@@ -800,6 +825,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) ...@@ -800,6 +825,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP10BE: case AV_PIX_FMT_GBRP10BE:
c->readChrPlanar = planar_rgb10be_to_uv; c->readChrPlanar = planar_rgb10be_to_uv;
break; break;
case AV_PIX_FMT_GBRP12BE:
c->readChrPlanar = planar_rgb12be_to_uv;
break;
case AV_PIX_FMT_GBRAP16BE: case AV_PIX_FMT_GBRAP16BE:
case AV_PIX_FMT_GBRP16BE: case AV_PIX_FMT_GBRP16BE:
c->readChrPlanar = planar_rgb16be_to_uv; c->readChrPlanar = planar_rgb16be_to_uv;
...@@ -1013,6 +1041,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) ...@@ -1013,6 +1041,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP10LE: case AV_PIX_FMT_GBRP10LE:
c->readLumPlanar = planar_rgb10le_to_y; c->readLumPlanar = planar_rgb10le_to_y;
break; break;
case AV_PIX_FMT_GBRP12LE:
c->readLumPlanar = planar_rgb12le_to_y;
break;
case AV_PIX_FMT_GBRAP16LE: case AV_PIX_FMT_GBRAP16LE:
case AV_PIX_FMT_GBRP16LE: case AV_PIX_FMT_GBRP16LE:
c->readLumPlanar = planar_rgb16le_to_y; c->readLumPlanar = planar_rgb16le_to_y;
...@@ -1023,6 +1054,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) ...@@ -1023,6 +1054,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
case AV_PIX_FMT_GBRP10BE: case AV_PIX_FMT_GBRP10BE:
c->readLumPlanar = planar_rgb10be_to_y; c->readLumPlanar = planar_rgb10be_to_y;
break; break;
case AV_PIX_FMT_GBRP12BE:
c->readLumPlanar = planar_rgb12be_to_y;
break;
case AV_PIX_FMT_GBRAP16BE: case AV_PIX_FMT_GBRAP16BE:
case AV_PIX_FMT_GBRP16BE: case AV_PIX_FMT_GBRP16BE:
c->readLumPlanar = planar_rgb16be_to_y; c->readLumPlanar = planar_rgb16be_to_y;
......
...@@ -295,7 +295,7 @@ av_cold void ff_sws_init_swscale_ppc(SwsContext *c) ...@@ -295,7 +295,7 @@ av_cold void ff_sws_init_swscale_ppc(SwsContext *c)
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return; return;
if (c->srcBpc == 8 && c->dstBpc <= 10) { if (c->srcBpc == 8 && c->dstBpc <= 12) {
c->hyScale = c->hcScale = hScale_altivec_real; c->hyScale = c->hcScale = hScale_altivec_real;
} }
if (!is16BPS(dstFormat) && !is9_15BPS(dstFormat) && if (!is16BPS(dstFormat) && !is9_15BPS(dstFormat) &&
......
...@@ -184,6 +184,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = { ...@@ -184,6 +184,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
[AV_PIX_FMT_GBRP9BE] = { 1, 1 }, [AV_PIX_FMT_GBRP9BE] = { 1, 1 },
[AV_PIX_FMT_GBRP10LE] = { 1, 1 }, [AV_PIX_FMT_GBRP10LE] = { 1, 1 },
[AV_PIX_FMT_GBRP10BE] = { 1, 1 }, [AV_PIX_FMT_GBRP10BE] = { 1, 1 },
[AV_PIX_FMT_GBRP12LE] = { 1, 0 },
[AV_PIX_FMT_GBRP12BE] = { 1, 0 },
[AV_PIX_FMT_GBRP16LE] = { 1, 0 }, [AV_PIX_FMT_GBRP16LE] = { 1, 0 },
[AV_PIX_FMT_GBRP16BE] = { 1, 0 }, [AV_PIX_FMT_GBRP16BE] = { 1, 0 },
[AV_PIX_FMT_GBRAP] = { 1, 1 }, [AV_PIX_FMT_GBRAP] = { 1, 1 },
...@@ -1015,6 +1017,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, ...@@ -1015,6 +1017,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
srcFormat != AV_PIX_FMT_RGB4_BYTE && srcFormat != AV_PIX_FMT_BGR4_BYTE && srcFormat != AV_PIX_FMT_RGB4_BYTE && srcFormat != AV_PIX_FMT_BGR4_BYTE &&
srcFormat != AV_PIX_FMT_GBRP9BE && srcFormat != AV_PIX_FMT_GBRP9LE && srcFormat != AV_PIX_FMT_GBRP9BE && srcFormat != AV_PIX_FMT_GBRP9LE &&
srcFormat != AV_PIX_FMT_GBRP10BE && srcFormat != AV_PIX_FMT_GBRP10LE && srcFormat != AV_PIX_FMT_GBRP10BE && srcFormat != AV_PIX_FMT_GBRP10LE &&
srcFormat != AV_PIX_FMT_GBRP12BE && srcFormat != AV_PIX_FMT_GBRP12LE &&
srcFormat != AV_PIX_FMT_GBRP16BE && srcFormat != AV_PIX_FMT_GBRP16LE && srcFormat != AV_PIX_FMT_GBRP16BE && srcFormat != AV_PIX_FMT_GBRP16LE &&
((dstW >> c->chrDstHSubSample) <= (srcW >> 1) || ((dstW >> c->chrDstHSubSample) <= (srcW >> 1) ||
(flags & SWS_FAST_BILINEAR))) (flags & SWS_FAST_BILINEAR)))
...@@ -1051,7 +1054,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, ...@@ -1051,7 +1054,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FF_ALLOC_OR_GOTO(c, c->formatConvBuffer,
(FFALIGN(srcW, 16) * 2 * FFALIGN(c->srcBpc, 8) >> 3) + 16, (FFALIGN(srcW, 16) * 2 * FFALIGN(c->srcBpc, 8) >> 3) + 16,
fail); fail);
if (INLINE_MMXEXT(cpu_flags) && c->srcBpc == 8 && c->dstBpc <= 10) { if (INLINE_MMXEXT(cpu_flags) && c->srcBpc == 8 && c->dstBpc <= 12) {
c->canMMXEXTBeUsed = (dstW >= srcW && (dstW & 31) == 0 && c->canMMXEXTBeUsed = (dstW >= srcW && (dstW & 31) == 0 &&
(srcW & 15) == 0) ? 1 : 0; (srcW & 15) == 0) ? 1 : 0;
if (!c->canMMXEXTBeUsed && dstW >= srcW && (srcW & 15) == 0 if (!c->canMMXEXTBeUsed && dstW >= srcW && (srcW & 15) == 0
......
...@@ -324,6 +324,9 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c) ...@@ -324,6 +324,9 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c)
} else if (c->srcBpc == 10) { \ } else if (c->srcBpc == 10) { \
hscalefn = c->dstBpc <= 15 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \ hscalefn = c->dstBpc <= 15 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
ff_hscale10to19_ ## filtersize ## _ ## opt1; \ ff_hscale10to19_ ## filtersize ## _ ## opt1; \
} else if (c->srcBpc == 12) { \
hscalefn = c->dstBpc <= 15 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
ff_hscale16to19_ ## filtersize ## _ ## opt1; \
} else if (c->srcBpc == 16) { \ } else if (c->srcBpc == 16) { \
hscalefn = c->dstBpc <= 15 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \ hscalefn = c->dstBpc <= 15 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
ff_hscale16to19_ ## filtersize ## _ ## opt1; \ ff_hscale16to19_ ## filtersize ## _ ## opt1; \
......
...@@ -1619,7 +1619,7 @@ static av_cold void RENAME(sws_init_swscale)(SwsContext *c) ...@@ -1619,7 +1619,7 @@ static av_cold void RENAME(sws_init_swscale)(SwsContext *c)
} }
} }
if (c->srcBpc == 8 && c->dstBpc <= 10) { if (c->srcBpc == 8 && c->dstBpc <= 12) {
// Use the new MMX scaler if the MMXEXT one can't be used (it is faster than the x86 ASM one). // Use the new MMX scaler if the MMXEXT one can't be used (it is faster than the x86 ASM one).
#if COMPILE_TEMPLATE_MMXEXT #if COMPILE_TEMPLATE_MMXEXT
if (c->flags & SWS_FAST_BILINEAR && c->canMMXEXTBeUsed) { if (c->flags & SWS_FAST_BILINEAR && c->canMMXEXTBeUsed) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment