[FFmpeg-cvslog] lavfi/colorspace_common: add ifdef check to be more compatible.

Ruiling Song git at videolan.org
Fri Mar 22 03:40:35 EET 2019


ffmpeg | branch: master | Ruiling Song <ruiling.song at intel.com> | Mon Jan 21 15:44:04 2019 +0800| [b073fb9eeae8f021a4e18886ccf73cda9f67b00c] | committer: Ruiling Song

lavfi/colorspace_common: add ifdef check to be more compatible.

Some filters may not need to do linearize/delinearize, thus
will even not define them. Add ifdef check, so they could easily
re-use the .cl file.

Signed-off-by: Ruiling Song <ruiling.song at intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b073fb9eeae8f021a4e18886ccf73cda9f67b00c
---

 libavfilter/opencl/colorspace_common.cl | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavfilter/opencl/colorspace_common.cl b/libavfilter/opencl/colorspace_common.cl
index 1d68a546c7..ac911f03ef 100644
--- a/libavfilter/opencl/colorspace_common.cl
+++ b/libavfilter/opencl/colorspace_common.cl
@@ -124,10 +124,14 @@ float3 yuv2rgb(float y, float u, float v) {
 
 float3 yuv2lrgb(float3 yuv) {
     float3 rgb = yuv2rgb(yuv.x, yuv.y, yuv.z);
+#ifdef linearize
     float r = linearize(rgb.x);
     float g = linearize(rgb.y);
     float b = linearize(rgb.z);
     return (float3)(r, g, b);
+#else
+    return rgb;
+#endif
 }
 
 float3 rgb2yuv(float r, float g, float b) {
@@ -151,19 +155,25 @@ float rgb2y(float r, float g, float b) {
 }
 
 float3 lrgb2yuv(float3 c) {
+#ifdef delinearize
     float r = delinearize(c.x);
     float g = delinearize(c.y);
     float b = delinearize(c.z);
-
     return rgb2yuv(r, g, b);
+#else
+    return rgb2yuv(c.x, c.y, c.z);
+#endif
 }
 
 float lrgb2y(float3 c) {
+#ifdef delinearize
     float r = delinearize(c.x);
     float g = delinearize(c.y);
     float b = delinearize(c.z);
-
     return rgb2y(r, g, b);
+#else
+    return rgb2y(c.x, c.y, c.z);
+#endif
 }
 
 float3 lrgb2lrgb(float3 c) {



More information about the ffmpeg-cvslog mailing list