libultrahdr icon indicating copy to clipboard operation
libultrahdr copied to clipboard

Yuv color gamut conversion and transformYuv420 using Risc-V Vector

Open lhpqaq opened this issue 11 months ago • 4 comments

This PR is a mirror relative to #124, with the same content implemented using RVV. Testing under Riscv32 and Riscv64 image

Command:

(base)  build (rvv_test) ✗ qemu-riscv64 -cpu rv64,v=true,vlen=128,vext_spec=v1.0 -L /usr/riscv64-linux-gnu/ ./ultrahdr_unit_test --gtest_filter=GainMapMathTest.TransformYuv420Rvv   
Running main() from /home/lhp/libultrahdr/third_party/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = GainMapMathTest.TransformYuv420Rvv
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from GainMapMathTest
[ RUN      ] GainMapMathTest.TransformYuv420Rvv
[       OK ] GainMapMathTest.TransformYuv420Rvv (5 ms)
[----------] 1 test from GainMapMathTest (10 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (15 ms total)
[  PASSED  ] 1 test.
(base)  build (rvv_test) ✗ cd ../build32
(base)  build32 (rvv_test) ✗ qemu-riscv32 -cpu rv32,v=true,vlen=128,vext_spec=v1.0 ./ultrahdr_unit_test --gtest_filter=GainMapMathTest.TransformYuv420Rvv
Running main() from /home/lhp/libultrahdr/third_party/googletest/googletest/src/gtest_main.cc
Note: Google Test filter = GainMapMathTest.TransformYuv420Rvv
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from GainMapMathTest
[ RUN      ] GainMapMathTest.TransformYuv420Rvv
[       OK ] GainMapMathTest.TransformYuv420Rvv (5 ms)
[----------] 1 test from GainMapMathTest (8 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (12 ms total)
[  PASSED  ] 1 test.

!!!!!! ------------------------------------------------Note------------------------------------------------

It should be noted that in some cases, the error of y is 2: image

So this is the only difference compared to #124 (only y)

        EXPECT_NEAR(expect_y1, out1.y, 2);
        EXPECT_NEAR(expect_y2, out2.y, 2);
        EXPECT_NEAR(expect_y3, out3.y, 2);
        EXPECT_NEAR(expect_y4, out4.y, 2);

lhpqaq avatar Dec 02 '24 12:12 lhpqaq

considerable amount of code seems to be duplicated across archs. for instance weights used in conversion, they can be moved to common place and reused. Also, please wait on further development as we working on some refactoring which may effect some of the changes you are making.

ram-mohan avatar Dec 03 '24 20:12 ram-mohan

I have removed the redundant code related to weights and unit tests. I will also be working on this project long-term.

lhpqaq avatar Dec 04 '24 02:12 lhpqaq

@ram-mohan Hi, I am preparing to port other functions. Is my code structure suitable in the current situation?

lhpqaq avatar Dec 09 '24 01:12 lhpqaq

@ram-mohan Hi, I am preparing to port other functions. Is my code structure suitable in the current situation?

yes changes look good to me

ram-mohan avatar Dec 09 '24 08:12 ram-mohan