⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yuv2rgb.c

📁 linux下的一款播放器
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: yuv2rgb.c,v 1.2.42.2 2004/07/13 19:01:32 bobclark Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** *//*** #includes: ********************************************/#include "env.h"#include "rgb.h"    /* basic RGB-data definitions & macros */#include "yuv.h"    /* YUV-to-RGB conversion tables & macros */#include "clip.h"   /* macros for clipping & dithering */#include "scale.h"  /* scale algorithms */#include "colorlib.h" /* ensure that prototypes get extern C'ed */#ifdef _MACINTOSH#pragma require_prototypes off#endifstatic int YUVtoRGB2 (    int dest_format,    unsigned char *dest_ptr, int dest_width, int dest_height,    int dest_pitch, int dest_x, int dest_y, int dest_dx, int dest_dy,    unsigned char *pY, unsigned char *pU, unsigned char *pV,    int src_width, int src_height, int yPitch, int uPitch, int vPitch,    int src_x, int src_y, int src_dx, int src_dy);/*** Additional pixel-level macros: ************************//* * Add dither, clip and assign values to RGB pixels: */#define RGBX_CLIP_X(f,rnd,x,v)  (CLIP(rnd,BITS(f,x),v) << START(f,x))#define RGBX_CLIP_SET(f,rnd,a,r,g,b) \    a##_rgb = RGBX_CLIP_X(f,rnd,R,r) | RGBX_CLIP_X(f,rnd,G,g) | RGBX_CLIP_X(f,rnd,B,b)#define RGB32_CLIP_SET(rnd,a,r,g,b)  RGBX_CLIP_SET(RGB32,rnd,a,r,g,b)#define BGR32_CLIP_SET(rnd,a,r,g,b)  RGBX_CLIP_SET(BGR32,rnd,a,r,g,b)#define RGB24_CLIP_SET(rnd,a,r,g,b)  \    a##_b = CLIP(rnd,8,b), a##_g = CLIP(rnd,8,g), a##_r = CLIP(rnd,8,r)#define RGB565_CLIP_SET(rnd,a,r,g,b) RGBX_CLIP_SET(RGB565,rnd,a,r,g,b)#define RGB555_CLIP_SET(rnd,a,r,g,b) RGBX_CLIP_SET(RGB555,rnd,a,r,g,b)#define RGB444_CLIP_SET(rnd,a,r,g,b) RGBX_CLIP_SET(RGB444,rnd,a,r,g,b)#define RGB8_CLIP_SET(rnd,a,r,g,b)   \    a##_idx = pmap[(CLIP(rnd,4,r)<<8) | (CLIP(rnd,4,g)<<4) | CLIP(rnd,4,b)]/* * Generic RGB clipping & assignment macro: */#define CLIP_SET(f,rnd,a,r,g,b)      f##_CLIP_SET(rnd,a,r,g,b)/* * YUV 2x1-block load and convert macros: */#define YUV_LOAD_CONVERT_2x1_FAST(df,a1,a2,sy1,sy2,su,sv)   \    {                                                       \        register int y1, y2, rv, guv, bu;                   \        bu = butab[su[0]];                                  \        guv = gutab[su[0]] + gvtab[sv[0]];                  \        rv = rvtab[sv[0]];                                  \        y1 = ytab[sy1[0]];                                  \        y2 = ytab[sy2[0]];                                  \        CLIP_SET(df,ROUND,a1,y1+rv,y1+guv,y1+bu);           \        CLIP_SET(df,ROUND,a2,y2+rv,y2+guv,y2+bu);           \    }/* with Hue rotation: */#define YUV_LOAD_CONVERT_2x1_FULL(df,a1,a2,sy1,sy2,su,sv)   \    {                                                       \        register int y1, y2, ruv, guv, buv;                 \        buv = butab[su[0]] + bvtab[sv[0]];                  \        guv = gutab[su[0]] + gvtab[sv[0]];                  \        ruv = rutab[su[0]] + rvtab[sv[0]];                  \        y1 = ytab[sy1[0]];                                  \        y2 = ytab[sy2[0]];                                  \        CLIP_SET(df,ROUND,a1,y1+ruv,y1+guv,y1+buv);         \        CLIP_SET(df,ROUND,a2,y2+ruv,y2+guv,y2+buv);         \    }/* * Generic YUV 2x1-block load & convert macro: */#define YUV_LOAD_CONVERT_2x1(cc,df,a1,a2,sy1,sy2,su,sv)  \    YUV_LOAD_CONVERT_2x1_##cc(df,a1,a2,sy1,sy2,su,sv)/* * YUV 2x2-block load and convert macros: * (without dithering) */#define YUV_LOAD_CONVERT_2x2_FAST(df,a11,a12,a21,a22,sy1,sy2,su,sv) \    {                                                       \        register int y11, y12, y21, y22, rv, guv, bu;       \        bu = butab[su[0]];                                  \        guv = gutab[su[0]] + gvtab[sv[0]];                  \        rv = rvtab[sv[0]];                                  \        y11 = ytab[sy1[0]];                                 \        y21 = ytab[sy2[0]];                                 \        y12 = ytab[sy1[1]];                                 \        y22 = ytab[sy2[1]];                                 \        CLIP_SET(df,ROUND,a11,y11+rv,y11+guv,y11+bu);       \        CLIP_SET(df,ROUND,a21,y21+rv,y21+guv,y21+bu);       \        CLIP_SET(df,ROUND,a12,y12+rv,y12+guv,y12+bu);       \        CLIP_SET(df,ROUND,a22,y22+rv,y22+guv,y22+bu);       \    }/* with Hue rotation: */#define YUV_LOAD_CONVERT_2x2_FULL(df,a11,a12,a21,a22,sy1,sy2,su,sv) \    {                                                       \        register int y11, y12, y21, y22, ruv, guv, buv;     \        buv = butab[su[0]] + bvtab[sv[0]];                  \        guv = gutab[su[0]] + gvtab[sv[0]];                  \        ruv = rutab[su[0]] + rvtab[sv[0]];                  \        y11 = ytab[sy1[0]];                                 \        y21 = ytab[sy2[0]];                                 \        y12 = ytab[sy1[1]];                                 \        y22 = ytab[sy2[1]];                                 \        CLIP_SET(df,ROUND,a11,y11+ruv,y11+guv,y11+buv);     \        CLIP_SET(df,ROUND,a21,y21+ruv,y21+guv,y21+buv);     \        CLIP_SET(df,ROUND,a12,y12+ruv,y12+guv,y12+buv);     \        CLIP_SET(df,ROUND,a22,y22+ruv,y22+guv,y22+buv);     \    }/* * Generic YUV 2x1-block load & convert macro: */#define YUV_LOAD_CONVERT_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv) \    YUV_LOAD_CONVERT_2x2_##cc(df,a11,a12,a21,a22,sy1,sy2,su,sv)/* * YUV 2x2-block load and convert macros: *  (adds symmetric 2x2 dither noise) */#define YUV_LOAD_CONVERT_DITHER_2x2_FAST(df,a11,a12,a21,a22,sy1,sy2,su,sv) \    {                                                       \        register int y11, y12, y21, y22, rv, guv, bu;       \        bu = butab[su[0]];                                  \        guv = gutab[su[0]] + gvtab[sv[0]];                  \        rv = rvtab[sv[0]];                                  \        y11 = ytab[sy1[0]];                                 \        y21 = ytab[sy2[0]];                                 \        y12 = ytab[sy1[1]];                                 \        y22 = ytab[sy2[1]];                                 \        CLIP_SET(df,HIGH,a11,y11+rv,y11+guv,y11+bu);        \        CLIP_SET(df,LOW ,a21,y21+rv,y21+guv,y21+bu);        \        CLIP_SET(df,LOW ,a12,y12+rv,y12+guv,y12+bu);        \        CLIP_SET(df,HIGH,a22,y22+rv,y22+guv,y22+bu);        \    }/* with Hue rotation: */#define YUV_LOAD_CONVERT_DITHER_2x2_FULL(df,a11,a12,a21,a22,sy1,sy2,su,sv) \    {                                                       \        register int y11, y12, y21, y22, ruv, guv, buv;     \        buv = butab[su[0]] + bvtab[sv[0]];                  \        guv = gutab[su[0]] + gvtab[sv[0]];                  \        ruv = rutab[su[0]] + rvtab[sv[0]];                  \        y11 = ytab[sy1[0]];                                 \        y21 = ytab[sy2[0]];                                 \        y12 = ytab[sy1[1]];                                 \        y22 = ytab[sy2[1]];                                 \        CLIP_SET(df,HIGH,a11,y11+ruv,y11+guv,y11+buv);      \        CLIP_SET(df,LOW ,a21,y21+ruv,y21+guv,y21+buv);      \        CLIP_SET(df,LOW ,a12,y12+ruv,y12+guv,y12+buv);      \        CLIP_SET(df,HIGH,a22,y22+ruv,y22+guv,y22+buv);      \    }/* * Generic YUV 2x1-block load & convert macro: */#define YUV_LOAD_CONVERT_DITHER_2x2(cc,df,a11,a12,a21,a22,sy1,sy2,su,sv) \    YUV_LOAD_CONVERT_DITHER_2x2_##cc(df,a11,a12,a21,a22,sy1,sy2,su,sv)/* * Generic YUV load-convert-store macros: */#define YUV_LOAD_CONVERT_STORE_2x1(cc,df,d1,d2,sy1,sy2,su,sv) \    {                                                       \        PIXEL(df,a1); PIXEL(df,a2);                         \        YUV_LOAD_CONVERT_2x1(cc,df,a1,a2,sy1,sy2,su,sv);    \        sy1++; sy2++; su++; sv++;                           \        STORE(df,d1,a1);                                    \        d1+=BPP(df);                                        \        STORE(df,d2,a2);                                    \        d2+=BPP(df);                                        \    }#define YUV_LOAD_CONVERT_STORE_2x2(cc,df,d1,d2,sy1,sy2,su,sv) \    {                                                       \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -