[FFmpeg-trac] #7124(swscale:reopened): Unexpected results from YUV-RGB color space conversion optimization on POWER8/LE

FFmpeg trac at avcodec.org
Thu Jan 31 05:04:42 EET 2019


#7124: Unexpected results from YUV-RGB color space conversion optimization on
POWER8/LE
-------------------------------------+------------------------------------
             Reporter:  seiko        |                    Owner:
                 Type:  defect       |                   Status:  reopened
             Priority:  normal       |                Component:  swscale
              Version:  git-master   |               Resolution:
             Keywords:  ppc altivec  |               Blocked By:
             Blocking:               |  Reproduced by developer:  1
Analyzed by developer:  0            |
-------------------------------------+------------------------------------

Comment (by winice):

 I did some investigate in this ticket. 2 issues were found.

 Firstly, the code yuv2rgb_altivec.c uses vec_ld/vec_st to load and store
 data. But the compiler automatically do some changes for the perm masks
 for LE. So it is better use vec_xl (or vec_vsx_ld) for the data load and
 vec_xst for store.

 One more important change is related to the YUV->RGB transform. I searched
 on web, there are 2 formulas. I checked all the coefficients of CRV, CBU,
 CGU, CGV in the code and they matches this formula
     B = 1.164(Y - 16)                            + 2.018(U - 128)
     G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128)
     R = 1.164(Y - 16) + 1.596(V - 128)
 (http://www.mplayerhq.hu/DOCS/tech/colorspaces.txt)
 OpenCV imgproc/src/color_yuv.cpp uses the same formula in YUV420 - RGB
 transform.

 But as stated in the same page,
     Julien (sorry, I can't recall his surname) suggests that there are
 problems with the above formula

 So there is another usage in OpenCV YCrCb - RGB transform following
 Julien's proposal as:
     R = Y + 1.403V'
     G = Y - 0.344U' - 0.714V'
     B = Y + 1.770U'

 While in existing libswscale code, it uses formula as B = Y+2.018 (U-128),
 etc. I have to change CY and subtract by 16. After this, all the test
 passes.

 I also found some other locations of vec_ld/vec_st. But I have no test
 data to get to those calling path. So I only made a patch for this ticket.
 Please review. Thanks!

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7124#comment:7>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list