History

swscale/output: add support for NV20

James Almer committed 1 year ago

Commit b8dc8751 parent 2f856b415 files · +52 −24Browse files

Unified · Split

15 files
  1. libswscale/format.c +2 −2
  2. libswscale/output.c +28 −21
  3. libswscale/version.h +1 −1
  4. tests/ref/fate/filter-pixdesc-nv20be +1 −0
  5. tests/ref/fate/filter-pixdesc-nv20le +1 −0
  6. tests/ref/fate/filter-pixfmts-copy +2 −0
  7. tests/ref/fate/filter-pixfmts-crop +2 −0
  8. tests/ref/fate/filter-pixfmts-field +2 −0
  9. tests/ref/fate/filter-pixfmts-fieldorder +2 −0
  10. tests/ref/fate/filter-pixfmts-hflip +2 −0
  11. tests/ref/fate/filter-pixfmts-il +2 −0
  12. tests/ref/fate/filter-pixfmts-null +2 −0
  13. tests/ref/fate/filter-pixfmts-pad +1 −0
  14. tests/ref/fate/filter-pixfmts-scale +2 −0
  15. tests/ref/fate/filter-pixfmts-vflip +2 −0
libswscale/format.c+2−2
@@ -226,8 +226,8 @@ static const FormatEntry format_entries[] = { · 225 unmodified lines
226226 [AV_PIX_FMT_Y216LE] = { 1, 1 },
227227 [AV_PIX_FMT_X2RGB10LE] = { 1, 1 },
228228 [AV_PIX_FMT_X2BGR10LE] = { 1, 1 },
229− [AV_PIX_FMT_NV20BE] = { 1, 0 },
230− [AV_PIX_FMT_NV20LE] = { 1, 0 },
229+ [AV_PIX_FMT_NV20BE] = { 1, 1 },
230+ [AV_PIX_FMT_NV20LE] = { 1, 1 },
231231 [AV_PIX_FMT_P210BE] = { 1, 1 },
232232 [AV_PIX_FMT_P210LE] = { 1, 1 },
233233 [AV_PIX_FMT_P212BE] = { 1, 1 },
libswscale/output.c+28−21
@@ -472,11 +472,10 @@ static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither, · 471 unmodified lines
472472
473473 static void yuv2p01xl1_c(const int16_t *src,
474474 uint16_t *dest, int dstW,
475− int big_endian, int output_bits)
475+ int big_endian, int output_bits, int output_shift)
476476 {
477477 int i;
478478 int shift = 15 - output_bits;
479− int output_shift = 16 - output_bits;
480479
481480 for (i = 0; i < dstW; i++) {
482481 int val = src[i] + (1 << (shift - 1));
@@ -486,11 +485,10 @@ static void yuv2p01xl1_c(const int16_t *src, · 3 unmodified lines
486485
487486 static void yuv2p01xlX_c(const int16_t *filter, int filterSize,
488487 const int16_t **src, uint16_t *dest, int dstW,
489− int big_endian, int output_bits)
488+ int big_endian, int output_bits, int output_shift)
490489 {
491490 int i, j;
492491 int shift = 11 + 16 - output_bits;
493− int output_shift = 16 - output_bits;
494492
495493 for (i = 0; i < dstW; i++) {
496494 int val = 1 << (shift - 1);
@@ -505,12 +503,11 @@ static void yuv2p01xlX_c(const int16_t *filter, int filterSize, · 8 unmodified lines
505503 static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither,
506504 const int16_t *chrFilter, int chrFilterSize,
507505 const int16_t **chrUSrc, const int16_t **chrVSrc,
508− uint8_t *dest8, int chrDstW, int output_bits)
506+ uint8_t *dest8, int chrDstW, int output_bits, int output_shift)
509507 {
510508 uint16_t *dest = (uint16_t*)dest8;
511509 int i, j;
512510 int shift = 11 + 16 - output_bits;
513− int output_shift = 16 - output_bits;
514511
515512 for (i = 0; i < chrDstW; i++) {
516513 int u = 1 << (shift - 1);
@@ -528,38 +525,40 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, · 11 unmodified lines
528525
529526 #undef output_pixel
530527
531−#define yuv2p01x_wrapper(bits) \
532− static void yuv2p0 ## bits ## l1_LE_c(const int16_t *src, \
528+#define yuv2p01x_wrapper(fmt, bits, shift) \
529+ static void yuv2 ## fmt ## l1_LE_c(const int16_t *src, \
533530 uint8_t *dest, int dstW, \
534531 const uint8_t *dither, int offset) \
535532 { \
536− yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits); \
533+ yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits, shift); \
537534 } \
538535 \
539− static void yuv2p0 ## bits ## l1_BE_c(const int16_t *src, \
536+ static void yuv2 ## fmt ## l1_BE_c(const int16_t *src, \
540537 uint8_t *dest, int dstW, \
541538 const uint8_t *dither, int offset) \
542539 { \
543− yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits); \
540+ yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits, shift); \
544541 } \
545542 \
546− static void yuv2p0 ## bits ## lX_LE_c(const int16_t *filter, \
543+ static void yuv2 ## fmt ## lX_LE_c(const int16_t *filter, \
547544 int filterSize, const int16_t **src, \
548545 uint8_t *dest, int dstW, \
549546 const uint8_t *dither, int offset) \
550547 { \
551− yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, bits); \
548+ yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, \
549+ bits, shift); \
552550 } \
553551 \
554− static void yuv2p0 ## bits ## lX_BE_c(const int16_t *filter, \
552+ static void yuv2 ## fmt ## lX_BE_c(const int16_t *filter, \
555553 int filterSize, const int16_t **src, \
556554 uint8_t *dest, int dstW, \
557555 const uint8_t *dither, int offset) \
558556 { \
559− yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, bits); \
557+ yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, \
558+ bits, shift); \
560559 } \
561560 \
562− static void yuv2p0 ## bits ## cX_LE_c(enum AVPixelFormat dstFormat, \
561+ static void yuv2 ## fmt ## cX_LE_c(enum AVPixelFormat dstFormat, \
563562 const uint8_t *chrDither, \
564563 const int16_t *chrFilter, \
565564 int chrFilterSize, \
@@ -568,10 +567,10 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, · 2 unmodified lines
568567 uint8_t *dest8, int chrDstW) \
569568 { \
570569 yuv2p01xcX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
571− dest8, chrDstW, bits); \
570+ dest8, chrDstW, bits, shift); \
572571 } \
573572 \
574− static void yuv2p0 ## bits ## cX_BE_c(enum AVPixelFormat dstFormat, \
573+ static void yuv2 ## fmt ## cX_BE_c(enum AVPixelFormat dstFormat, \
575574 const uint8_t *chrDither, \
576575 const int16_t *chrFilter, \
577576 int chrFilterSize, \
@@ -580,11 +579,12 @@ static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, · 2 unmodified lines
580579 uint8_t *dest8, int chrDstW) \
581580 { \
582581 yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \
583− dest8, chrDstW, bits); \
582+ dest8, chrDstW, bits, shift); \
584583 }
585584
586−yuv2p01x_wrapper(10)
587−yuv2p01x_wrapper(12)
585+yuv2p01x_wrapper(p010, 10, 6)
586+yuv2p01x_wrapper(p012, 12, 4)
587+yuv2p01x_wrapper(nv20, 10, 0)
588588
589589 #define accumulate_bit(acc, val) \
590590 acc <<= 1; \
@@ -3201,6 +3201,13 @@ av_cold void ff_sws_init_output_funcs(SwsInternal *c, · 2610 unmodified lines
32013201 *yuv2nv12cX = isBE(dstFormat) ? yuv2p012cX_BE_c : yuv2p012cX_LE_c;
32023202 } else
32033203 av_assert0(0);
3204+ } else if (isSemiPlanarYUV(dstFormat) && isNBPS(dstFormat)) {
3205+ if (desc->comp[0].depth == 10) {
3206+ *yuv2plane1 = isBE(dstFormat) ? yuv2nv20l1_BE_c : yuv2nv20l1_LE_c;
3207+ *yuv2planeX = isBE(dstFormat) ? yuv2nv20lX_BE_c : yuv2nv20lX_LE_c;
3208+ *yuv2nv12cX = isBE(dstFormat) ? yuv2nv20cX_BE_c : yuv2nv20cX_LE_c;
3209+ } else
3210+ av_assert0(0);
32043211 } else if (is16BPS(dstFormat)) {
32053212 *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
32063213 *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
libswscale/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "version_major.h"
3030
3131 #define LIBSWSCALE_VERSION_MINOR 13
32−#define LIBSWSCALE_VERSION_MICRO 102
32+#define LIBSWSCALE_VERSION_MICRO 103
3333
3434 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
3535 LIBSWSCALE_VERSION_MINOR, \
tests/ref/fate/filter-pixdesc-nv20be+1−0
@@ -0,0 +1 @@
1+pixdesc-nv20be 145a739af0a3f51705493f09380794e5
tests/ref/fate/filter-pixdesc-nv20le+1−0
@@ -0,0 +1 @@
1+pixdesc-nv20le f28f8ab3015403e7e932592e08413120
tests/ref/fate/filter-pixfmts-copy+2−0
@@ -61,6 +61,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5 · 60 unmodified lines
6161 monow 54d16d2c01abfd72ecdb5e51e283937c
6262 nv12 8e24feb2c544dc26a20047a71e4c27aa
6363 nv16 22b1916c0694c4e2979bab8eb71f3d6b
64+nv20be d3a724e46ec52f8796f7c0705893e0d9
65+nv20le 3f0f46d5f65cf314eb1e24d21028afb8
6466 nv21 335d85c9af6110f26ae9e187a82ed2cf
6567 nv24 f30fc8d0ac40af69e119ea919a314572
6668 nv42 29a212f70f8780fe0eb99abcae81894d
tests/ref/fate/filter-pixfmts-crop+2−0
@@ -59,6 +59,8 @@ grayf32be cf40ec06a8abe54852b7f85a00549eec · 58 unmodified lines
5959 grayf32le b672526c9da9c8959ab881f242f6890a
6060 nv12 92cda427f794374731ec0321ee00caac
6161 nv16 3264b16aaae554c21f052102b491c13b
62+nv20be a69262f462f71973860ab08f2789ee6b
63+nv20le a31f7f8105a8d9cfa6de13d865cff870
6264 nv21 1bcfc197f4fb95de85ba58182d8d2f69
6365 nv24 514c8f12082f0737e558778cbe7de258
6466 nv42 ece9baae1c5de579dac2c66a89e08ef3
tests/ref/fate/filter-pixfmts-field+2−0
@@ -61,6 +61,8 @@ monob 2129cc72a484d7e10a44de9117aa9f80 · 60 unmodified lines
6161 monow 03d783611d265cae78293f88ea126ea1
6262 nv12 16f7a46708ef25ebd0b72e47920cc11e
6363 nv16 34f36b03f5fccf4eac147b26bbc0a5e5
64+nv20be 1557f4523a0e03cf1a4c2e0cbdb8e336
65+nv20le 342f2736c3c5f6277c46ba66101101ec
6466 nv21 7294574037cc7f9373ef5695d8ebe809
6567 nv24 3b100fb527b64ee2b2d7120da573faf5
6668 nv42 1841ce853152d86b27c130f319ea0db2
tests/ref/fate/filter-pixfmts-fieldorder+2−0
@@ -58,6 +58,8 @@ gray9le c45eb848ab86f63f30ceb7206fb41be9 · 57 unmodified lines
5858 grayf32be 1aa7960131f880c54fe3c77f13448674
5959 grayf32le 4029ac9d197f255794c1b9e416520fc7
6060 nv16 085deb984ab986eb5cc961fe265e30c0
61+nv20be 16998bc4aa2bfa3255d115a0a19ad80e
62+nv20le c8bd359ec00903dd2b5526b4d8ecb09f
6163 nv24 4fdbef26042c77f012df114e666efdb2
6264 nv42 59608290fece913e6b7d61edf581a529
6365 p210be ca2ce2c25db43dcd14729b2a72a7c604
tests/ref/fate/filter-pixfmts-hflip+2−0
@@ -59,6 +59,8 @@ grayf32be a69add7bbf892a71fe81b3b75982dbe2 · 58 unmodified lines
5959 grayf32le 4563e176a35dc8a8a07e0829fad5eb88
6060 nv12 801e58f1be5fd0b5bc4bf007c604b0b4
6161 nv16 06ba714cb8b220c203f5898ef39abf93
62+nv20be 979181e11f7bb74ad2d891daeebb7649
63+nv20le eaac839121362f12270af3deff4d32e7
6264 nv21 9f10dfff8963dc327d3395af21f0554f
6365 nv24 f0c5b2f42970f8d4003621d8857a872f
6466 nv42 4dcf9aec82b110712b396a8b365dcb13
tests/ref/fate/filter-pixfmts-il+2−0
@@ -61,6 +61,8 @@ monob faba75df28033ba7ce3d82ff2a99ee68 · 60 unmodified lines
6161 monow 6e9cfb8d3a344c5f0c3e1d5e1297e580
6262 nv12 3c3ba9b1b4c4dfff09c26f71b51dd146
6363 nv16 355d055f91793a171302021b3fc486b0
64+nv20be e09c264498100eb85364e10378adbc07
65+nv20le 02e738d5bcd8c7b57cb56dee663232f6
6466 nv21 ab586d8781246b5a32d8760a61db9797
6567 nv24 554153c71d142e3fd8e40b7dcaaec229
6668 nv42 d699724c8deaeb4f87faf2766512eec3
tests/ref/fate/filter-pixfmts-null+2−0
@@ -61,6 +61,8 @@ monob 8b04f859fee6a0be856be184acd7a0b5 · 60 unmodified lines
6161 monow 54d16d2c01abfd72ecdb5e51e283937c
6262 nv12 8e24feb2c544dc26a20047a71e4c27aa
6363 nv16 22b1916c0694c4e2979bab8eb71f3d6b
64+nv20be d3a724e46ec52f8796f7c0705893e0d9
65+nv20le 3f0f46d5f65cf314eb1e24d21028afb8
6466 nv21 335d85c9af6110f26ae9e187a82ed2cf
6567 nv24 f30fc8d0ac40af69e119ea919a314572
6668 nv42 29a212f70f8780fe0eb99abcae81894d
tests/ref/fate/filter-pixfmts-pad+1−0
@@ -26,6 +26,7 @@ gray16le 4347c5ca559a06948c1e7e7c2f06657d · 25 unmodified lines
2626 gray9le 99f825e62d5786901dba9abc88878ffb
2727 nv12 381574979cb04be10c9168540310afad
2828 nv16 d3a50501d2ea8535489fd5ec49e7866d
29+nv20le 59511282a2565ed060e4fb1fee8f6bcb
2930 nv21 0fdeb2cdd56cf5a7147dc273456fa217
3031 nv24 193b9eadcc06ad5081609f76249b3e47
3132 nv42 1738ad3c31c6c16e17679f5b09ce4677
tests/ref/fate/filter-pixfmts-scale+2−0
@@ -61,6 +61,8 @@ monob f01cb0b623357387827902d9d0963435 · 60 unmodified lines
6161 monow 35c68b86c226d6990b2dcb573a05ff6b
6262 nv12 b118d24a3653fe66e5d9e079033aef79
6363 nv16 68e757396b62b84aad657274b8f6ce15
64+nv20be 1f207474a71da5be34f764b20f0f59ed
65+nv20le 011d1e266e52e9587b0f257ab4533095
6466 nv21 c74bb1c10dbbdee8a1f682b194486c4d
6567 nv24 2aa6e805bf6d4179ed8d7dea37d75db3
6668 nv42 80714d1eb2d8bcaeab3abc3124df1abd
tests/ref/fate/filter-pixfmts-vflip+2−0
@@ -61,6 +61,8 @@ monob 7810c4857822ccfc844d78f5e803269a · 60 unmodified lines
6161 monow 90a947bfcd5f2261e83b577f48ec57b1
6262 nv12 261ebe585ae2aa4e70d39a10c1679294
6363 nv16 f20f3448c900847aaff74429196f5a00
64+nv20be f73c202e6a0d35b9ff5b7fc7fdd04ed4
65+nv20le 8f53d78acd0af1c7fb676b38ba4ba12b
6466 nv21 2909feacd27bebb080c8e0fa41795269
6567 nv24 334420b9d3df84499d2ca16bb66eed2b
6668 nv42 ba4063e2795c17fea3c8a646b01fd1f5

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t