Move yuv2rgb code to subdirs.
[libav.git] / libswscale / mlib / yuv2rgb_mlib.c
CommitLineData
6a4970ab 1/*
8a322796
DB
2 * software YUV to RGB converter using mediaLib
3 *
325751ef 4 * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at>
6611aa83 5 *
325751ef 6 * This file is part of FFmpeg.
6611aa83 7 *
325751ef
DB
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
6611aa83 12 *
325751ef
DB
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
6611aa83 17 *
325751ef
DB
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6611aa83
NK
21 */
22
6611aa83
NK
23#include <mlib_types.h>
24#include <mlib_status.h>
25#include <mlib_sys.h>
26#include <mlib_video.h>
5427e242
MN
27#include <inttypes.h>
28#include <stdlib.h>
29#include <assert.h>
6611aa83 30
befa8e66 31#include "libswscale/swscale.h"
6611aa83 32
6a4970ab 33static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
42809816 34 int srcSliceH, uint8_t* dst[], int dstStride[]){
e9e12f0e 35 if(c->srcFormat == PIX_FMT_YUV422P){
42809816
DB
36 srcStride[1] *= 2;
37 srcStride[2] *= 2;
5427e242 38 }
6a4970ab 39
5427e242 40 assert(srcStride[1] == srcStride[2]);
6a4970ab 41
23669983 42 mlib_VideoColorYUV2ARGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
42809816 43 srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
d4e24275 44 return srcSliceH;
6611aa83
NK
45}
46
6a4970ab 47static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
42809816 48 int srcSliceH, uint8_t* dst[], int dstStride[]){
e9e12f0e 49 if(c->srcFormat == PIX_FMT_YUV422P){
42809816
DB
50 srcStride[1] *= 2;
51 srcStride[2] *= 2;
5427e242 52 }
6a4970ab 53
5427e242 54 assert(srcStride[1] == srcStride[2]);
6a4970ab 55
23669983 56 mlib_VideoColorYUV2ABGR420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
42809816 57 srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
d4e24275 58 return srcSliceH;
6611aa83
NK
59}
60
6a4970ab 61static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
42809816 62 int srcSliceH, uint8_t* dst[], int dstStride[]){
e9e12f0e 63 if(c->srcFormat == PIX_FMT_YUV422P){
42809816
DB
64 srcStride[1] *= 2;
65 srcStride[2] *= 2;
5427e242 66 }
6a4970ab 67
5427e242 68 assert(srcStride[1] == srcStride[2]);
6a4970ab 69
23669983 70 mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
42809816 71 srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
d4e24275 72 return srcSliceH;
5427e242 73}
6611aa83 74
6611aa83 75
780daf2b 76SwsFunc ff_yuv2rgb_init_mlib(SwsContext *c)
5427e242 77{
42809816
DB
78 switch(c->dstFormat){
79 case PIX_FMT_RGB24: return mlib_YUV2RGB420_24;
80 case PIX_FMT_BGR32: return mlib_YUV2ARGB420_32;
81 case PIX_FMT_RGB32: return mlib_YUV2ABGR420_32;
82 default: return NULL;
83 }
6611aa83
NK
84}
85