From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 2/2] swscale/output: add support for NV20 Date: Sun, 16 Mar 2025 17:56:09 -0300 Message-ID: <20250316205609.58465-2-jamrial@gmail.com> (raw) In-Reply-To: <20250316205609.58465-1-jamrial@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com> --- libswscale/format.c | 4 +- libswscale/output.c | 49 ++++++++++++++---------- tests/ref/fate/filter-pixdesc-nv20be | 1 + tests/ref/fate/filter-pixdesc-nv20le | 1 + tests/ref/fate/filter-pixfmts-copy | 2 + tests/ref/fate/filter-pixfmts-crop | 2 + tests/ref/fate/filter-pixfmts-field | 2 + tests/ref/fate/filter-pixfmts-fieldorder | 2 + tests/ref/fate/filter-pixfmts-hflip | 2 + tests/ref/fate/filter-pixfmts-il | 2 + tests/ref/fate/filter-pixfmts-null | 2 + tests/ref/fate/filter-pixfmts-pad | 1 + tests/ref/fate/filter-pixfmts-scale | 2 + tests/ref/fate/filter-pixfmts-vflip | 2 + 14 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-nv20be create mode 100644 tests/ref/fate/filter-pixdesc-nv20le diff --git a/libswscale/format.c b/libswscale/format.c index fd0269a23e..cdffb3e863 100644 --- a/libswscale/format.c +++ b/libswscale/format.c @@ -226,8 +226,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_Y216LE] = { 1, 1 }, [AV_PIX_FMT_X2RGB10LE] = { 1, 1 }, [AV_PIX_FMT_X2BGR10LE] = { 1, 1 }, - [AV_PIX_FMT_NV20BE] = { 1, 0 }, - [AV_PIX_FMT_NV20LE] = { 1, 0 }, + [AV_PIX_FMT_NV20BE] = { 1, 1 }, + [AV_PIX_FMT_NV20LE] = { 1, 1 }, [AV_PIX_FMT_P210BE] = { 1, 1 }, [AV_PIX_FMT_P210LE] = { 1, 1 }, [AV_PIX_FMT_P212BE] = { 1, 1 }, diff --git a/libswscale/output.c b/libswscale/output.c index 21c3bdc307..2253706c6a 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -472,11 +472,10 @@ static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither, static void yuv2p01xl1_c(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; int shift = 15 - output_bits; - int output_shift = 16 - output_bits; for (i = 0; i < dstW; i++) { 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, 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 shift = 11 + 16 - output_bits; - int output_shift = 16 - output_bits; for (i = 0; i < dstW; i++) { 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, const int16_t *chrFilter, int chrFilterSize, 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; int i, j; int shift = 11 + 16 - output_bits; - int output_shift = 16 - output_bits; for (i = 0; i < chrDstW; i++) { int u = 1 << (shift - 1); @@ -528,38 +525,40 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, #undef output_pixel -#define yuv2p01x_wrapper(bits) \ - static void yuv2p0 ## bits ## l1_LE_c(const int16_t *src, \ +#define yuv2p01x_wrapper(fmt, bits, shift) \ + static void yuv2 ## fmt ## l1_LE_c(const int16_t *src, \ uint8_t *dest, int dstW, \ 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, \ 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, \ uint8_t *dest, int dstW, \ 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, \ uint8_t *dest, int dstW, \ 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 int16_t *chrFilter, \ int chrFilterSize, \ @@ -568,10 +567,10 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, uint8_t *dest8, int chrDstW) \ { \ 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 int16_t *chrFilter, \ int chrFilterSize, \ @@ -580,11 +579,12 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, uint8_t *dest8, int chrDstW) \ { \ yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \ - dest8, chrDstW, bits); \ + dest8, chrDstW, bits, shift); \ } -yuv2p01x_wrapper(10) -yuv2p01x_wrapper(12) +yuv2p01x_wrapper(p010, 10, 6) +yuv2p01x_wrapper(p012, 12, 4) +yuv2p01x_wrapper(nv20, 10, 0) #define accumulate_bit(acc, val) \ 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; } else 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)) { *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c; *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c; diff --git a/tests/ref/fate/filter-pixdesc-nv20be b/tests/ref/fate/filter-pixdesc-nv20be new file mode 100644 index 0000000000..3afd4495fb --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-nv20be @@ -0,0 +1 @@ +pixdesc-nv20be 145a739af0a3f51705493f09380794e5 diff --git a/tests/ref/fate/filter-pixdesc-nv20le b/tests/ref/fate/filter-pixdesc-nv20le new file mode 100644 index 0000000000..c0115106b4 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-nv20le @@ -0,0 +1 @@ +pixdesc-nv20le f28f8ab3015403e7e932592e08413120 diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index e511905656..1ab94d515e 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -61,6 +61,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5 monow 54d16d2c01abfd72ecdb5e51e283937c nv12 8e24feb2c544dc26a20047a71e4c27aa nv16 22b1916c0694c4e2979bab8eb71f3d6b +nv20be d3a724e46ec52f8796f7c0705893e0d9 +nv20le 3f0f46d5f65cf314eb1e24d21028afb8 nv21 335d85c9af6110f26ae9e187a82ed2cf nv24 f30fc8d0ac40af69e119ea919a314572 nv42 29a212f70f8780fe0eb99abcae81894d diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 4920140ad9..300c64ad9a 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -59,6 +59,8 @@ grayf32be cf40ec06a8abe54852b7f85a00549eec grayf32le b672526c9da9c8959ab881f242f6890a nv12 92cda427f794374731ec0321ee00caac nv16 3264b16aaae554c21f052102b491c13b +nv20be a69262f462f71973860ab08f2789ee6b +nv20le a31f7f8105a8d9cfa6de13d865cff870 nv21 1bcfc197f4fb95de85ba58182d8d2f69 nv24 514c8f12082f0737e558778cbe7de258 nv42 ece9baae1c5de579dac2c66a89e08ef3 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 6d7be8b896..a94543a60f 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -61,6 +61,8 @@ monob 2129cc72a484d7e10a44de9117aa9f80 monow 03d783611d265cae78293f88ea126ea1 nv12 16f7a46708ef25ebd0b72e47920cc11e nv16 34f36b03f5fccf4eac147b26bbc0a5e5 +nv20be 1557f4523a0e03cf1a4c2e0cbdb8e336 +nv20le 342f2736c3c5f6277c46ba66101101ec nv21 7294574037cc7f9373ef5695d8ebe809 nv24 3b100fb527b64ee2b2d7120da573faf5 nv42 1841ce853152d86b27c130f319ea0db2 diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index d780a50e2a..318474b7d7 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -58,6 +58,8 @@ gray9le c45eb848ab86f63f30ceb7206fb41be9 grayf32be 1aa7960131f880c54fe3c77f13448674 grayf32le 4029ac9d197f255794c1b9e416520fc7 nv16 085deb984ab986eb5cc961fe265e30c0 +nv20be 16998bc4aa2bfa3255d115a0a19ad80e +nv20le c8bd359ec00903dd2b5526b4d8ecb09f nv24 4fdbef26042c77f012df114e666efdb2 nv42 59608290fece913e6b7d61edf581a529 p210be ca2ce2c25db43dcd14729b2a72a7c604 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index dcaa3fccf0..56f347531c 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -59,6 +59,8 @@ grayf32be a69add7bbf892a71fe81b3b75982dbe2 grayf32le 4563e176a35dc8a8a07e0829fad5eb88 nv12 801e58f1be5fd0b5bc4bf007c604b0b4 nv16 06ba714cb8b220c203f5898ef39abf93 +nv20be 979181e11f7bb74ad2d891daeebb7649 +nv20le eaac839121362f12270af3deff4d32e7 nv21 9f10dfff8963dc327d3395af21f0554f nv24 f0c5b2f42970f8d4003621d8857a872f nv42 4dcf9aec82b110712b396a8b365dcb13 diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index f5b9555e7e..9135b46c02 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -61,6 +61,8 @@ monob faba75df28033ba7ce3d82ff2a99ee68 monow 6e9cfb8d3a344c5f0c3e1d5e1297e580 nv12 3c3ba9b1b4c4dfff09c26f71b51dd146 nv16 355d055f91793a171302021b3fc486b0 +nv20be e09c264498100eb85364e10378adbc07 +nv20le 02e738d5bcd8c7b57cb56dee663232f6 nv21 ab586d8781246b5a32d8760a61db9797 nv24 554153c71d142e3fd8e40b7dcaaec229 nv42 d699724c8deaeb4f87faf2766512eec3 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index e511905656..1ab94d515e 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -61,6 +61,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5 monow 54d16d2c01abfd72ecdb5e51e283937c nv12 8e24feb2c544dc26a20047a71e4c27aa nv16 22b1916c0694c4e2979bab8eb71f3d6b +nv20be d3a724e46ec52f8796f7c0705893e0d9 +nv20le 3f0f46d5f65cf314eb1e24d21028afb8 nv21 335d85c9af6110f26ae9e187a82ed2cf nv24 f30fc8d0ac40af69e119ea919a314572 nv42 29a212f70f8780fe0eb99abcae81894d diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad index b45b47af40..9370ca2cb3 100644 --- a/tests/ref/fate/filter-pixfmts-pad +++ b/tests/ref/fate/filter-pixfmts-pad @@ -26,6 +26,7 @@ gray16le 4347c5ca559a06948c1e7e7c2f06657d gray9le 99f825e62d5786901dba9abc88878ffb nv12 381574979cb04be10c9168540310afad nv16 d3a50501d2ea8535489fd5ec49e7866d +nv20le 59511282a2565ed060e4fb1fee8f6bcb nv21 0fdeb2cdd56cf5a7147dc273456fa217 nv24 193b9eadcc06ad5081609f76249b3e47 nv42 1738ad3c31c6c16e17679f5b09ce4677 diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index 07a15d3aca..09fdbee7a3 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -61,6 +61,8 @@ monob f01cb0b623357387827902d9d0963435 monow 35c68b86c226d6990b2dcb573a05ff6b nv12 b118d24a3653fe66e5d9e079033aef79 nv16 68e757396b62b84aad657274b8f6ce15 +nv20be 1f207474a71da5be34f764b20f0f59ed +nv20le 011d1e266e52e9587b0f257ab4533095 nv21 c74bb1c10dbbdee8a1f682b194486c4d nv24 2aa6e805bf6d4179ed8d7dea37d75db3 nv42 80714d1eb2d8bcaeab3abc3124df1abd diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index d03838c90a..905e334325 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -61,6 +61,8 @@ monob 7810c4857822ccfc844d78f5e803269a monow 90a947bfcd5f2261e83b577f48ec57b1 nv12 261ebe585ae2aa4e70d39a10c1679294 nv16 f20f3448c900847aaff74429196f5a00 +nv20be f73c202e6a0d35b9ff5b7fc7fdd04ed4 +nv20le 8f53d78acd0af1c7fb676b38ba4ba12b nv21 2909feacd27bebb080c8e0fa41795269 nv24 334420b9d3df84499d2ca16bb66eed2b nv42 ba4063e2795c17fea3c8a646b01fd1f5 -- 2.48.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2025-03-16 20:56 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-03-16 20:56 [FFmpeg-devel] [PATCH 1/2] swscale/input: " James Almer 2025-03-16 20:56 ` James Almer [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250316205609.58465-2-jamrial@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git