1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

swscale/input: add support for NV20

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-03-16 16:52:29 -03:00
parent 1502551dd3
commit 2f856b488b
2 changed files with 29 additions and 10 deletions

View File

@ -226,6 +226,8 @@ static const FormatEntry format_entries[] = {
[AV_PIX_FMT_Y216LE] = { 1, 1 }, [AV_PIX_FMT_Y216LE] = { 1, 1 },
[AV_PIX_FMT_X2RGB10LE] = { 1, 1 }, [AV_PIX_FMT_X2RGB10LE] = { 1, 1 },
[AV_PIX_FMT_X2BGR10LE] = { 1, 1 }, [AV_PIX_FMT_X2BGR10LE] = { 1, 1 },
[AV_PIX_FMT_NV20BE] = { 1, 0 },
[AV_PIX_FMT_NV20LE] = { 1, 0 },
[AV_PIX_FMT_P210BE] = { 1, 1 }, [AV_PIX_FMT_P210BE] = { 1, 1 },
[AV_PIX_FMT_P210LE] = { 1, 1 }, [AV_PIX_FMT_P210LE] = { 1, 1 },
[AV_PIX_FMT_P212BE] = { 1, 1 }, [AV_PIX_FMT_P212BE] = { 1, 1 },

View File

@ -945,8 +945,9 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
nvXXtoUV_c(dstV, dstU, src1, width); nvXXtoUV_c(dstV, dstU, src1, width);
} }
#define p01x_uv_wrapper(bits, shift) \ #define p01x_uv_wrapper(fmt, shift) \
static void p0 ## bits ## LEToUV_c(uint8_t *dstU, uint8_t *dstV, \ static void fmt ## LEToUV ## _c(uint8_t *dstU, \
uint8_t *dstV, \
const uint8_t *unused0, \ const uint8_t *unused0, \
const uint8_t *src1, \ const uint8_t *src1, \
const uint8_t *src2, int width, \ const uint8_t *src2, int width, \
@ -959,7 +960,8 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
} \ } \
} \ } \
\ \
static void p0 ## bits ## BEToUV_c(uint8_t *dstU, uint8_t *dstV, \ static void fmt ## BEToUV ## _c(uint8_t *dstU, \
uint8_t *dstV, \
const uint8_t *unused0, \ const uint8_t *unused0, \
const uint8_t *src1, \ const uint8_t *src1, \
const uint8_t *src2, int width, \ const uint8_t *src2, int width, \
@ -972,8 +974,9 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
} \ } \
} }
#define p01x_wrapper(bits, shift) \ #define p01x_wrapper(fmt, shift) \
static void p0 ## bits ## LEToY_c(uint8_t *dst, const uint8_t *src, \ static void fmt ## LEToY ## _c(uint8_t *dst, \
const uint8_t *src, \
const uint8_t *unused1, \ const uint8_t *unused1, \
const uint8_t *unused2, int width, \ const uint8_t *unused2, int width, \
uint32_t *unused, void *opq) \ uint32_t *unused, void *opq) \
@ -984,7 +987,8 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
} \ } \
} \ } \
\ \
static void p0 ## bits ## BEToY_c(uint8_t *dst, const uint8_t *src, \ static void fmt ## BEToY ## _c(uint8_t *dst, \
const uint8_t *src, \
const uint8_t *unused1, \ const uint8_t *unused1, \
const uint8_t *unused2, int width, \ const uint8_t *unused2, int width, \
uint32_t *unused, void *opq) \ uint32_t *unused, void *opq) \
@ -994,11 +998,12 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> shift); \ AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> shift); \
} \ } \
} \ } \
p01x_uv_wrapper(bits, shift) p01x_uv_wrapper(fmt, shift)
p01x_wrapper(10, 6) p01x_wrapper(nv20, 0)
p01x_wrapper(12, 4) p01x_wrapper(p010, 6)
p01x_uv_wrapper(16, 0) p01x_wrapper(p012, 4)
p01x_uv_wrapper(p016, 0)
static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
int width, uint32_t *rgb2yuv, void *opq) int width, uint32_t *rgb2yuv, void *opq)
@ -1910,11 +1915,17 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c,
case AV_PIX_FMT_XV48BE: case AV_PIX_FMT_XV48BE:
*chrToYV12 = read_xv48be_UV_c; *chrToYV12 = read_xv48be_UV_c;
break; break;
case AV_PIX_FMT_NV20LE:
*chrToYV12 = nv20LEToUV_c;
break;
case AV_PIX_FMT_P010LE: case AV_PIX_FMT_P010LE:
case AV_PIX_FMT_P210LE: case AV_PIX_FMT_P210LE:
case AV_PIX_FMT_P410LE: case AV_PIX_FMT_P410LE:
*chrToYV12 = p010LEToUV_c; *chrToYV12 = p010LEToUV_c;
break; break;
case AV_PIX_FMT_NV20BE:
*chrToYV12 = nv20BEToUV_c;
break;
case AV_PIX_FMT_P010BE: case AV_PIX_FMT_P010BE:
case AV_PIX_FMT_P210BE: case AV_PIX_FMT_P210BE:
case AV_PIX_FMT_P410BE: case AV_PIX_FMT_P410BE:
@ -2468,11 +2479,17 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c,
case AV_PIX_FMT_BGRA64LE: case AV_PIX_FMT_BGRA64LE:
*lumToYV12 = bgr64LEToY_c; *lumToYV12 = bgr64LEToY_c;
break; break;
case AV_PIX_FMT_NV20LE:
*lumToYV12 = nv20LEToY_c;
break;
case AV_PIX_FMT_P010LE: case AV_PIX_FMT_P010LE:
case AV_PIX_FMT_P210LE: case AV_PIX_FMT_P210LE:
case AV_PIX_FMT_P410LE: case AV_PIX_FMT_P410LE:
*lumToYV12 = p010LEToY_c; *lumToYV12 = p010LEToY_c;
break; break;
case AV_PIX_FMT_NV20BE:
*lumToYV12 = nv20BEToY_c;
break;
case AV_PIX_FMT_P010BE: case AV_PIX_FMT_P010BE:
case AV_PIX_FMT_P210BE: case AV_PIX_FMT_P210BE:
case AV_PIX_FMT_P410BE: case AV_PIX_FMT_P410BE: