Statistics
| Branch: | Revision:

ffmpeg / libswscale / yuv2rgb_mlib.c @ d7fb5a18

History | View | Annotate | Download (2.82 KB)

1 6a4970ab Diego Biurrun
/*
2 8a322796 Diego Biurrun
 * software YUV to RGB converter using mediaLib
3
 *
4 325751ef Diego Biurrun
 * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at>
5 6611aa83 Nick Kurshev
 *
6 325751ef Diego Biurrun
 * This file is part of FFmpeg.
7 6611aa83 Nick Kurshev
 *
8 325751ef Diego Biurrun
 * 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.
12 6611aa83 Nick Kurshev
 *
13 325751ef Diego Biurrun
 * 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.
17 6611aa83 Nick Kurshev
 *
18 325751ef Diego Biurrun
 * 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
21 6611aa83 Nick Kurshev
 */
22
23
#include <mlib_types.h>
24
#include <mlib_status.h>
25
#include <mlib_sys.h>
26
#include <mlib_video.h>
27 5427e242 Michael Niedermayer
#include <inttypes.h>
28
#include <stdlib.h>
29
#include <assert.h>
30 6611aa83 Nick Kurshev
31 5427e242 Michael Niedermayer
#include "swscale.h"
32 6611aa83 Nick Kurshev
33 6a4970ab Diego Biurrun
static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
34 42809816 Diego Biurrun
                               int srcSliceH, uint8_t* dst[], int dstStride[]){
35 e9e12f0e Luca Abeni
    if(c->srcFormat == PIX_FMT_YUV422P){
36 42809816 Diego Biurrun
        srcStride[1] *= 2;
37
        srcStride[2] *= 2;
38 5427e242 Michael Niedermayer
    }
39 6a4970ab Diego Biurrun
40 5427e242 Michael Niedermayer
    assert(srcStride[1] == srcStride[2]);
41 6a4970ab Diego Biurrun
42 23669983 Ken Mandelberg
    mlib_VideoColorYUV2ARGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
43 42809816 Diego Biurrun
                               srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
44 d4e24275 Michael Niedermayer
    return srcSliceH;
45 6611aa83 Nick Kurshev
}
46
47 6a4970ab Diego Biurrun
static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
48 42809816 Diego Biurrun
                               int srcSliceH, uint8_t* dst[], int dstStride[]){
49 e9e12f0e Luca Abeni
    if(c->srcFormat == PIX_FMT_YUV422P){
50 42809816 Diego Biurrun
        srcStride[1] *= 2;
51
        srcStride[2] *= 2;
52 5427e242 Michael Niedermayer
    }
53 6a4970ab Diego Biurrun
54 5427e242 Michael Niedermayer
    assert(srcStride[1] == srcStride[2]);
55 6a4970ab Diego Biurrun
56 23669983 Ken Mandelberg
    mlib_VideoColorYUV2ABGR420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
57 42809816 Diego Biurrun
                               srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
58 d4e24275 Michael Niedermayer
    return srcSliceH;
59 6611aa83 Nick Kurshev
}
60
61 6a4970ab Diego Biurrun
static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
62 42809816 Diego Biurrun
                              int srcSliceH, uint8_t* dst[], int dstStride[]){
63 e9e12f0e Luca Abeni
    if(c->srcFormat == PIX_FMT_YUV422P){
64 42809816 Diego Biurrun
        srcStride[1] *= 2;
65
        srcStride[2] *= 2;
66 5427e242 Michael Niedermayer
    }
67 6a4970ab Diego Biurrun
68 5427e242 Michael Niedermayer
    assert(srcStride[1] == srcStride[2]);
69 6a4970ab Diego Biurrun
70 23669983 Ken Mandelberg
    mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW,
71 42809816 Diego Biurrun
                              srcSliceH, dstStride[0], srcStride[0], srcStride[1]);
72 d4e24275 Michael Niedermayer
    return srcSliceH;
73 5427e242 Michael Niedermayer
}
74 6611aa83 Nick Kurshev
75
76 6a4970ab Diego Biurrun
SwsFunc yuv2rgb_init_mlib(SwsContext *c)
77 5427e242 Michael Niedermayer
{
78 42809816 Diego Biurrun
    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
    }
84 6611aa83 Nick Kurshev
}