[FFmpeg-devel] [PATCH] FLIF16 GSOC Project - Added RGB to YCoCg macros

Jai Luthra me at jailuthra.in
Sat Mar 21 11:24:44 EET 2020


Please mark the patch as [WIP] or [RFC] if you are not sending it for a merge 
review.

On Wed, Mar 18, 2020 at 11:01:22AM +0530, Kartik wrote:
>From: Kartik K. Khullar<kartikkhullar840 at gmail.com>
>
>---
> FFmpeg/libavutil/colorspace.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
>diff --git a/FFmpeg/libavutil/colorspace.h b/FFmpeg/libavutil/colorspace.h
>index ef6f610..bf53afe 100644
>--- a/FFmpeg/libavutil/colorspace.h
>+++ b/FFmpeg/libavutil/colorspace.h
>@@ -94,6 +94,17 @@ static inline int C_JPEG_TO_CCIR(int y) {
>     return y;
> }
>
>+#define RGB_TO_YCoCg(R, G, B, Y, Co, Cg){\
>+	Y = (((R+B)>>1) + G)>>1;\
>+    Co = R - B;\
>+    Cg = G - ((R+B)>>1);\
>+}

You don't need to take Y,Co,Cg as inputs to the macro, look at other similar 
macros.

I would also suggest defining different macros for different output channels 
as it does not assume that Y,Co,Cg will be variables defined in the caller's 
context. Take a look at RGB_TO_Y/U/V_JPEG etc.

>+
>+#define YCoCg_TO_RGB(R, G, B, Y, Co, Cg){\
>+	Y = (((R+B)>>1) + G)>>1;\
>+    Co = R - B;\
>+    Cg = G - ((R+B)>>1);\
>+}

Only the name is inverse here, it still does the forward transform.

>
> #define RGB_TO_Y_CCIR(r, g, b) \
> ((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
>-- 
>2.20.1.windows.1
>


More information about the ffmpeg-devel mailing list