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