Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

yuv2rgb_mlib.c

00001 /* 
00002  * yuv2rgb_mlib.c, Software YUV to RGB coverter using mediaLib
00003  *
00004  *  Copyright (C) 2000, Håkan Hjort <[email protected]>
00005  *  All Rights Reserved.
00006  *
00007  *  This file is part of mpeg2dec, a free MPEG-2 video decoder
00008  *
00009  *  mpeg2dec is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2, or (at your option)
00012  *  any later version.
00013  *
00014  *  mpeg2dec is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with GNU Make; see the file COPYING.  If not, write to
00021  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00022  *
00023  */
00024 
00025 #include <mlib_types.h>
00026 #include <mlib_status.h>
00027 #include <mlib_sys.h>
00028 #include <mlib_video.h>
00029 #include <inttypes.h>
00030 #include <stdlib.h>
00031 #include <assert.h>
00032 
00033 #include "img_format.h" //FIXME try to reduce dependency of such stuff
00034 #include "swscale.h"
00035 
00036 static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
00037              int srcSliceH, uint8_t* dst[], int dstStride[]){
00038     if(c->srcFormat == IMGFMT_422P){
00039         srcStride[1] *= 2;
00040         srcStride[2] *= 2;
00041     }
00042     
00043     assert(srcStride[1] == srcStride[2]);
00044  
00045     mlib_VideoColorYUV2ARGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
00046                              srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
00047     return srcSliceH;
00048 }
00049 
00050 static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
00051              int srcSliceH, uint8_t* dst[], int dstStride[]){
00052     if(c->srcFormat == IMGFMT_422P){
00053         srcStride[1] *= 2;
00054         srcStride[2] *= 2;
00055     }
00056     
00057     assert(srcStride[1] == srcStride[2]);
00058  
00059     mlib_VideoColorYUV2ABGR420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
00060                              srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
00061     return srcSliceH;
00062 }
00063 
00064 static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, 
00065              int srcSliceH, uint8_t* dst[], int dstStride[]){
00066     if(c->srcFormat == IMGFMT_422P){
00067         srcStride[1] *= 2;
00068         srcStride[2] *= 2;
00069     }
00070     
00071     assert(srcStride[1] == srcStride[2]);
00072  
00073     mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
00074                              srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
00075     return srcSliceH;
00076 }
00077 
00078 
00079 SwsFunc yuv2rgb_init_mlib(SwsContext *c) 
00080 {
00081         switch(c->dstFormat){
00082         case IMGFMT_RGB24: return mlib_YUV2RGB420_24;
00083         case IMGFMT_RGB32: return mlib_YUV2ARGB420_32;
00084         case IMGFMT_BGR32: return mlib_YUV2ABGR420_32;
00085         default: return NULL;
00086         }
00087 }
00088 

Generated on Tue Dec 20 10:14:55 2005 for vlc-0.8.4a by  doxygen 1.4.2