1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

swscale/output: add support for NV20

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2025-03-16 17:14:20 -03:00
parent 2f856b488b
commit b8dc875249
15 changed files with 52 additions and 24 deletions

View File

@@ -226,8 +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_NV20BE] = { 1, 1 },
[AV_PIX_FMT_NV20LE] = { 1, 0 }, [AV_PIX_FMT_NV20LE] = { 1, 1 },
[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

@@ -472,11 +472,10 @@ static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither,
static void yuv2p01xl1_c(const int16_t *src, static void yuv2p01xl1_c(const int16_t *src,
uint16_t *dest, int dstW, uint16_t *dest, int dstW,
int big_endian, int output_bits) int big_endian, int output_bits, int output_shift)
{ {
int i; int i;
int shift = 15 - output_bits; int shift = 15 - output_bits;
int output_shift = 16 - output_bits;
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
int val = src[i] + (1 << (shift - 1)); int val = src[i] + (1 << (shift - 1));
@@ -486,11 +485,10 @@ static void yuv2p01xl1_c(const int16_t *src,
static void yuv2p01xlX_c(const int16_t *filter, int filterSize, static void yuv2p01xlX_c(const int16_t *filter, int filterSize,
const int16_t **src, uint16_t *dest, int dstW, const int16_t **src, uint16_t *dest, int dstW,
int big_endian, int output_bits) int big_endian, int output_bits, int output_shift)
{ {
int i, j; int i, j;
int shift = 11 + 16 - output_bits; int shift = 11 + 16 - output_bits;
int output_shift = 16 - output_bits;
for (i = 0; i < dstW; i++) { for (i = 0; i < dstW; i++) {
int val = 1 << (shift - 1); int val = 1 << (shift - 1);
@@ -505,12 +503,11 @@ static void yuv2p01xlX_c(const int16_t *filter, int filterSize,
static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither,
const int16_t *chrFilter, int chrFilterSize, const int16_t *chrFilter, int chrFilterSize,
const int16_t **chrUSrc, const int16_t **chrVSrc, const int16_t **chrUSrc, const int16_t **chrVSrc,
uint8_t *dest8, int chrDstW, int output_bits) uint8_t *dest8, int chrDstW, int output_bits, int output_shift)
{ {
uint16_t *dest = (uint16_t*)dest8; uint16_t *dest = (uint16_t*)dest8;
int i, j; int i, j;
int shift = 11 + 16 - output_bits; int shift = 11 + 16 - output_bits;
int output_shift = 16 - output_bits;
for (i = 0; i < chrDstW; i++) { for (i = 0; i < chrDstW; i++) {
int u = 1 << (shift - 1); int u = 1 << (shift - 1);
@@ -528,38 +525,40 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither,
#undef output_pixel #undef output_pixel
#define yuv2p01x_wrapper(bits) \ #define yuv2p01x_wrapper(fmt, bits, shift) \
static void yuv2p0 ## bits ## l1_LE_c(const int16_t *src, \ static void yuv2 ## fmt ## l1_LE_c(const int16_t *src, \
uint8_t *dest, int dstW, \ uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \ const uint8_t *dither, int offset) \
{ \ { \
yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits); \ yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits, shift); \
} \ } \
\ \
static void yuv2p0 ## bits ## l1_BE_c(const int16_t *src, \ static void yuv2 ## fmt ## l1_BE_c(const int16_t *src, \
uint8_t *dest, int dstW, \ uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \ const uint8_t *dither, int offset) \
{ \ { \
yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits); \ yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits, shift); \
} \ } \
\ \
static void yuv2p0 ## bits ## lX_LE_c(const int16_t *filter, \ static void yuv2 ## fmt ## lX_LE_c(const int16_t *filter, \
int filterSize, const int16_t **src, \ int filterSize, const int16_t **src, \
uint8_t *dest, int dstW, \ uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \ const uint8_t *dither, int offset) \
{ \ { \
yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, bits); \ yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, \
bits, shift); \
} \ } \
\ \
static void yuv2p0 ## bits ## lX_BE_c(const int16_t *filter, \ static void yuv2 ## fmt ## lX_BE_c(const int16_t *filter, \
int filterSize, const int16_t **src, \ int filterSize, const int16_t **src, \
uint8_t *dest, int dstW, \ uint8_t *dest, int dstW, \
const uint8_t *dither, int offset) \ const uint8_t *dither, int offset) \
{ \ { \
yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, bits); \ yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, \
bits, shift); \
} \ } \
\ \
static void yuv2p0 ## bits ## cX_LE_c(enum AVPixelFormat dstFormat, \ static void yuv2 ## fmt ## cX_LE_c(enum AVPixelFormat dstFormat, \
const uint8_t *chrDither, \ const uint8_t *chrDither, \
const int16_t *chrFilter, \ const int16_t *chrFilter, \
int chrFilterSize, \ int chrFilterSize, \
@@ -568,10 +567,10 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither,
uint8_t *dest8, int chrDstW) \ uint8_t *dest8, int chrDstW) \
{ \ { \
yuv2p01xcX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \ yuv2p01xcX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
dest8, chrDstW, bits); \ dest8, chrDstW, bits, shift); \
} \ } \
\ \
static void yuv2p0 ## bits ## cX_BE_c(enum AVPixelFormat dstFormat, \ static void yuv2 ## fmt ## cX_BE_c(enum AVPixelFormat dstFormat, \
const uint8_t *chrDither, \ const uint8_t *chrDither, \
const int16_t *chrFilter, \ const int16_t *chrFilter, \
int chrFilterSize, \ int chrFilterSize, \
@@ -580,11 +579,12 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither,
uint8_t *dest8, int chrDstW) \ uint8_t *dest8, int chrDstW) \
{ \ { \
yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \ yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
dest8, chrDstW, bits); \ dest8, chrDstW, bits, shift); \
} }
yuv2p01x_wrapper(10) yuv2p01x_wrapper(p010, 10, 6)
yuv2p01x_wrapper(12) yuv2p01x_wrapper(p012, 12, 4)
yuv2p01x_wrapper(nv20, 10, 0)
#define accumulate_bit(acc, val) \ #define accumulate_bit(acc, val) \
acc <<= 1; \ acc <<= 1; \
@@ -3201,6 +3201,13 @@ av_cold void ff_sws_init_output_funcs(SwsInternal *c,
*yuv2nv12cX = isBE(dstFormat) ? yuv2p012cX_BE_c : yuv2p012cX_LE_c; *yuv2nv12cX = isBE(dstFormat) ? yuv2p012cX_BE_c : yuv2p012cX_LE_c;
} else } else
av_assert0(0); av_assert0(0);
} else if (isSemiPlanarYUV(dstFormat) && isNBPS(dstFormat)) {
if (desc->comp[0].depth == 10) {
*yuv2plane1 = isBE(dstFormat) ? yuv2nv20l1_BE_c : yuv2nv20l1_LE_c;
*yuv2planeX = isBE(dstFormat) ? yuv2nv20lX_BE_c : yuv2nv20lX_LE_c;
*yuv2nv12cX = isBE(dstFormat) ? yuv2nv20cX_BE_c : yuv2nv20cX_LE_c;
} else
av_assert0(0);
} else if (is16BPS(dstFormat)) { } else if (is16BPS(dstFormat)) {
*yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c; *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
*yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c; *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;

View File

@@ -29,7 +29,7 @@
#include "version_major.h" #include "version_major.h"
#define LIBSWSCALE_VERSION_MINOR 13 #define LIBSWSCALE_VERSION_MINOR 13
#define LIBSWSCALE_VERSION_MICRO 102 #define LIBSWSCALE_VERSION_MICRO 103
#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
LIBSWSCALE_VERSION_MINOR, \ LIBSWSCALE_VERSION_MINOR, \

View File

@@ -0,0 +1 @@
pixdesc-nv20be 145a739af0a3f51705493f09380794e5

View File

@@ -0,0 +1 @@
pixdesc-nv20le f28f8ab3015403e7e932592e08413120

View File

@@ -61,6 +61,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5
monow 54d16d2c01abfd72ecdb5e51e283937c monow 54d16d2c01abfd72ecdb5e51e283937c
nv12 8e24feb2c544dc26a20047a71e4c27aa nv12 8e24feb2c544dc26a20047a71e4c27aa
nv16 22b1916c0694c4e2979bab8eb71f3d6b nv16 22b1916c0694c4e2979bab8eb71f3d6b
nv20be d3a724e46ec52f8796f7c0705893e0d9
nv20le 3f0f46d5f65cf314eb1e24d21028afb8
nv21 335d85c9af6110f26ae9e187a82ed2cf nv21 335d85c9af6110f26ae9e187a82ed2cf
nv24 f30fc8d0ac40af69e119ea919a314572 nv24 f30fc8d0ac40af69e119ea919a314572
nv42 29a212f70f8780fe0eb99abcae81894d nv42 29a212f70f8780fe0eb99abcae81894d

View File

@@ -59,6 +59,8 @@ grayf32be cf40ec06a8abe54852b7f85a00549eec
grayf32le b672526c9da9c8959ab881f242f6890a grayf32le b672526c9da9c8959ab881f242f6890a
nv12 92cda427f794374731ec0321ee00caac nv12 92cda427f794374731ec0321ee00caac
nv16 3264b16aaae554c21f052102b491c13b nv16 3264b16aaae554c21f052102b491c13b
nv20be a69262f462f71973860ab08f2789ee6b
nv20le a31f7f8105a8d9cfa6de13d865cff870
nv21 1bcfc197f4fb95de85ba58182d8d2f69 nv21 1bcfc197f4fb95de85ba58182d8d2f69
nv24 514c8f12082f0737e558778cbe7de258 nv24 514c8f12082f0737e558778cbe7de258
nv42 ece9baae1c5de579dac2c66a89e08ef3 nv42 ece9baae1c5de579dac2c66a89e08ef3

View File

@@ -61,6 +61,8 @@ monob 2129cc72a484d7e10a44de9117aa9f80
monow 03d783611d265cae78293f88ea126ea1 monow 03d783611d265cae78293f88ea126ea1
nv12 16f7a46708ef25ebd0b72e47920cc11e nv12 16f7a46708ef25ebd0b72e47920cc11e
nv16 34f36b03f5fccf4eac147b26bbc0a5e5 nv16 34f36b03f5fccf4eac147b26bbc0a5e5
nv20be 1557f4523a0e03cf1a4c2e0cbdb8e336
nv20le 342f2736c3c5f6277c46ba66101101ec
nv21 7294574037cc7f9373ef5695d8ebe809 nv21 7294574037cc7f9373ef5695d8ebe809
nv24 3b100fb527b64ee2b2d7120da573faf5 nv24 3b100fb527b64ee2b2d7120da573faf5
nv42 1841ce853152d86b27c130f319ea0db2 nv42 1841ce853152d86b27c130f319ea0db2

View File

@@ -58,6 +58,8 @@ gray9le c45eb848ab86f63f30ceb7206fb41be9
grayf32be 1aa7960131f880c54fe3c77f13448674 grayf32be 1aa7960131f880c54fe3c77f13448674
grayf32le 4029ac9d197f255794c1b9e416520fc7 grayf32le 4029ac9d197f255794c1b9e416520fc7
nv16 085deb984ab986eb5cc961fe265e30c0 nv16 085deb984ab986eb5cc961fe265e30c0
nv20be 16998bc4aa2bfa3255d115a0a19ad80e
nv20le c8bd359ec00903dd2b5526b4d8ecb09f
nv24 4fdbef26042c77f012df114e666efdb2 nv24 4fdbef26042c77f012df114e666efdb2
nv42 59608290fece913e6b7d61edf581a529 nv42 59608290fece913e6b7d61edf581a529
p210be ca2ce2c25db43dcd14729b2a72a7c604 p210be ca2ce2c25db43dcd14729b2a72a7c604

View File

@@ -59,6 +59,8 @@ grayf32be a69add7bbf892a71fe81b3b75982dbe2
grayf32le 4563e176a35dc8a8a07e0829fad5eb88 grayf32le 4563e176a35dc8a8a07e0829fad5eb88
nv12 801e58f1be5fd0b5bc4bf007c604b0b4 nv12 801e58f1be5fd0b5bc4bf007c604b0b4
nv16 06ba714cb8b220c203f5898ef39abf93 nv16 06ba714cb8b220c203f5898ef39abf93
nv20be 979181e11f7bb74ad2d891daeebb7649
nv20le eaac839121362f12270af3deff4d32e7
nv21 9f10dfff8963dc327d3395af21f0554f nv21 9f10dfff8963dc327d3395af21f0554f
nv24 f0c5b2f42970f8d4003621d8857a872f nv24 f0c5b2f42970f8d4003621d8857a872f
nv42 4dcf9aec82b110712b396a8b365dcb13 nv42 4dcf9aec82b110712b396a8b365dcb13

View File

@@ -61,6 +61,8 @@ monob faba75df28033ba7ce3d82ff2a99ee68
monow 6e9cfb8d3a344c5f0c3e1d5e1297e580 monow 6e9cfb8d3a344c5f0c3e1d5e1297e580
nv12 3c3ba9b1b4c4dfff09c26f71b51dd146 nv12 3c3ba9b1b4c4dfff09c26f71b51dd146
nv16 355d055f91793a171302021b3fc486b0 nv16 355d055f91793a171302021b3fc486b0
nv20be e09c264498100eb85364e10378adbc07
nv20le 02e738d5bcd8c7b57cb56dee663232f6
nv21 ab586d8781246b5a32d8760a61db9797 nv21 ab586d8781246b5a32d8760a61db9797
nv24 554153c71d142e3fd8e40b7dcaaec229 nv24 554153c71d142e3fd8e40b7dcaaec229
nv42 d699724c8deaeb4f87faf2766512eec3 nv42 d699724c8deaeb4f87faf2766512eec3

View File

@@ -61,6 +61,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5
monow 54d16d2c01abfd72ecdb5e51e283937c monow 54d16d2c01abfd72ecdb5e51e283937c
nv12 8e24feb2c544dc26a20047a71e4c27aa nv12 8e24feb2c544dc26a20047a71e4c27aa
nv16 22b1916c0694c4e2979bab8eb71f3d6b nv16 22b1916c0694c4e2979bab8eb71f3d6b
nv20be d3a724e46ec52f8796f7c0705893e0d9
nv20le 3f0f46d5f65cf314eb1e24d21028afb8
nv21 335d85c9af6110f26ae9e187a82ed2cf nv21 335d85c9af6110f26ae9e187a82ed2cf
nv24 f30fc8d0ac40af69e119ea919a314572 nv24 f30fc8d0ac40af69e119ea919a314572
nv42 29a212f70f8780fe0eb99abcae81894d nv42 29a212f70f8780fe0eb99abcae81894d

View File

@@ -26,6 +26,7 @@ gray16le 4347c5ca559a06948c1e7e7c2f06657d
gray9le 99f825e62d5786901dba9abc88878ffb gray9le 99f825e62d5786901dba9abc88878ffb
nv12 381574979cb04be10c9168540310afad nv12 381574979cb04be10c9168540310afad
nv16 d3a50501d2ea8535489fd5ec49e7866d nv16 d3a50501d2ea8535489fd5ec49e7866d
nv20le 59511282a2565ed060e4fb1fee8f6bcb
nv21 0fdeb2cdd56cf5a7147dc273456fa217 nv21 0fdeb2cdd56cf5a7147dc273456fa217
nv24 193b9eadcc06ad5081609f76249b3e47 nv24 193b9eadcc06ad5081609f76249b3e47
nv42 1738ad3c31c6c16e17679f5b09ce4677 nv42 1738ad3c31c6c16e17679f5b09ce4677

View File

@@ -61,6 +61,8 @@ monob f01cb0b623357387827902d9d0963435
monow 35c68b86c226d6990b2dcb573a05ff6b monow 35c68b86c226d6990b2dcb573a05ff6b
nv12 b118d24a3653fe66e5d9e079033aef79 nv12 b118d24a3653fe66e5d9e079033aef79
nv16 68e757396b62b84aad657274b8f6ce15 nv16 68e757396b62b84aad657274b8f6ce15
nv20be 1f207474a71da5be34f764b20f0f59ed
nv20le 011d1e266e52e9587b0f257ab4533095
nv21 c74bb1c10dbbdee8a1f682b194486c4d nv21 c74bb1c10dbbdee8a1f682b194486c4d
nv24 2aa6e805bf6d4179ed8d7dea37d75db3 nv24 2aa6e805bf6d4179ed8d7dea37d75db3
nv42 80714d1eb2d8bcaeab3abc3124df1abd nv42 80714d1eb2d8bcaeab3abc3124df1abd

View File

@@ -61,6 +61,8 @@ monob 7810c4857822ccfc844d78f5e803269a
monow 90a947bfcd5f2261e83b577f48ec57b1 monow 90a947bfcd5f2261e83b577f48ec57b1
nv12 261ebe585ae2aa4e70d39a10c1679294 nv12 261ebe585ae2aa4e70d39a10c1679294
nv16 f20f3448c900847aaff74429196f5a00 nv16 f20f3448c900847aaff74429196f5a00
nv20be f73c202e6a0d35b9ff5b7fc7fdd04ed4
nv20le 8f53d78acd0af1c7fb676b38ba4ba12b
nv21 2909feacd27bebb080c8e0fa41795269 nv21 2909feacd27bebb080c8e0fa41795269
nv24 334420b9d3df84499d2ca16bb66eed2b nv24 334420b9d3df84499d2ca16bb66eed2b
nv42 ba4063e2795c17fea3c8a646b01fd1f5 nv42 ba4063e2795c17fea3c8a646b01fd1f5