From 2f13f74791a207b2a6ca3e76a8e5de8c9fc7865f Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 23 Oct 2024 13:10:53 -0300 Subject: [PATCH] swscale/input: add XV48 input support Signed-off-by: James Almer --- libswscale/input.c | 40 ++++++++++++++++++++++++++++++++-------- libswscale/utils.c | 2 ++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/libswscale/input.c b/libswscale/input.c index 15bd9fbe2d..a298b92a05 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -674,26 +674,42 @@ static void read_ayuv64be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *u AV_WN16(dst + i * 2, AV_RB16(src + i * 8 + 2)); } -static void read_ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, - const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +static av_always_inline void ayuv64le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, int width, + int u_offset, int v_offset) { int i; for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 4)); - AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6)); + AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + u_offset)); + AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + v_offset)); } } -static void read_ayuv64be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, - const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +static av_always_inline void ayuv64be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, int width, + int u_offset, int v_offset) { int i; for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + 4)); - AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + 6)); + AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + u_offset)); + AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + v_offset)); } } +#define ayuv64_UV_funcs(pixfmt, U, V) \ +static void read_ ## pixfmt ## le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, \ + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) \ +{ \ + ayuv64le_UV_c(dstU, dstV, src, width, U, V); \ +} \ + \ +static void read_ ## pixfmt ## be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, \ + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) \ +{ \ + ayuv64be_UV_c(dstU, dstV, src, width, U, V); \ +} + +ayuv64_UV_funcs(ayuv64, 4, 6) +ayuv64_UV_funcs(xv48, 0, 4) + static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { @@ -1722,6 +1738,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, case AV_PIX_FMT_XV36BE: *chrToYV12 = read_xv36be_UV_c; break; + case AV_PIX_FMT_XV48LE: + *chrToYV12 = read_xv48le_UV_c; + break; + case AV_PIX_FMT_XV48BE: + *chrToYV12 = read_xv48be_UV_c; + break; case AV_PIX_FMT_P010LE: case AV_PIX_FMT_P210LE: case AV_PIX_FMT_P410LE: @@ -2146,9 +2168,11 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c, *lumToYV12 = read_ayuv_Y_c; break; case AV_PIX_FMT_AYUV64LE: + case AV_PIX_FMT_XV48LE: *lumToYV12 = read_ayuv64le_Y_c; break; case AV_PIX_FMT_AYUV64BE: + case AV_PIX_FMT_XV48BE: *lumToYV12 = read_ayuv64be_Y_c; break; case AV_PIX_FMT_XV36LE: diff --git a/libswscale/utils.c b/libswscale/utils.c index 31c136ad15..004cdf749f 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -277,6 +277,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_XV30LE] = { 1, 1 }, [AV_PIX_FMT_XV36LE] = { 1, 1 }, [AV_PIX_FMT_XV36BE] = { 1, 1 }, + [AV_PIX_FMT_XV48LE] = { 1, 0 }, + [AV_PIX_FMT_XV48BE] = { 1, 0 }, [AV_PIX_FMT_AYUV] = { 1, 1 }, [AV_PIX_FMT_UYVA] = { 1, 1 }, [AV_PIX_FMT_VYU444] = { 1, 1 },