annotate libswscale/mlib/yuv2rgb_mlib.c @ 30526:68e260df472b

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