mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 00:01:23 +00:00
57 lines
1.8 KiB
C
57 lines
1.8 KiB
C
/*
|
|
* This file is copied from ffmpeg's libavcodec/colorspace.h
|
|
* for the YUV_TO_RGB{1,2}_CCIR macros.
|
|
* Original copyright header and contents follows:
|
|
*/
|
|
/*
|
|
* Colorspace conversion defines
|
|
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard
|
|
*
|
|
* This file is part of FFmpeg.
|
|
*
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
/**
|
|
* @file libavcodec/colorspace.h
|
|
* Various defines for YUV<->RGB conversion
|
|
*/
|
|
|
|
#ifndef AVCODEC_COLORSPACE_H
|
|
#define AVCODEC_COLORSPACE_H
|
|
|
|
#define SCALEBITS 10
|
|
#define ONE_HALF (1 << (SCALEBITS - 1))
|
|
#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
|
|
|
|
#define YUV_TO_RGB1_CCIR(cb1, cr1)\
|
|
{\
|
|
cb = (cb1) - 128;\
|
|
cr = (cr1) - 128;\
|
|
r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
|
|
g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
|
|
ONE_HALF;\
|
|
b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
|
|
}
|
|
|
|
#define YUV_TO_RGB2_CCIR(r, g, b, y1)\
|
|
{\
|
|
y = ((y1) - 16) * FIX(255.0/219.0);\
|
|
r = cm[(y + r_add) >> SCALEBITS];\
|
|
g = cm[(y + g_add) >> SCALEBITS];\
|
|
b = cm[(y + b_add) >> SCALEBITS];\
|
|
}
|
|
|
|
#endif /* AVCODEC_COLORSPACE_H */
|