annotate imgconvert.c @ 989:fe9083c56733 libavcodec

simplified code (need automatic testing) - added primitive new format support.
author bellard
date Sat, 11 Jan 2003 00:08:48 +0000
parents ef769ec24115
children 895d3b01c6f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
2 * Misc image convertion routines
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
3 * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
5 * This library is free software; you can redistribute it and/or
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
7 * License as published by the Free Software Foundation; either
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
8 * version 2 of the License, or (at your option) any later version.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
9 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
10 * This library is distributed in the hope that it will be useful,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
13 * Lesser General Public License for more details.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
16 * License along with this library; if not, write to the Free Software
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
18 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
19 #include "avcodec.h"
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
20 #include "dsputil.h"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
21
17
b69fe46fd708 Adding fastmemcpy stuff to speedup mplayer project
nickols_k
parents: 0
diff changeset
22 #ifdef USE_FASTMEMCPY
b69fe46fd708 Adding fastmemcpy stuff to speedup mplayer project
nickols_k
parents: 0
diff changeset
23 #include "fastmemcpy.h"
b69fe46fd708 Adding fastmemcpy stuff to speedup mplayer project
nickols_k
parents: 0
diff changeset
24 #endif
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
25
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
26 #ifdef HAVE_MMX
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
27 #include "i386/mmx.h"
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
28 #endif
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
29
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
30 typedef struct PixFmtInfo {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
31 const char *name;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
32 UINT8 nb_components; /* number of components in AVPicture array */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
33 UINT8 is_yuv : 1; /* true if YUV instead of RGB color space */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
34 UINT8 is_packed : 1; /* true if multiple components in same word */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
35 UINT8 is_paletted : 1; /* true if paletted */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
36 UINT8 is_alpha : 1; /* true if alpha can be specified */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
37 UINT8 is_gray : 1; /* true if gray or monochrome format */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
38 UINT8 x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
39 UINT8 y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
40 } PixFmtInfo;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
41
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
42 /* this table gives more information about formats */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
43 static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
44 /* YUV formats */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
45 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
46 name: "yuv420p",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
47 nb_components: 3, is_yuv: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
48 x_chroma_shift: 1, y_chroma_shift: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
49 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
50 [PIX_FMT_YUV422P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
51 name: "yuv422p",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
52 nb_components: 3, is_yuv: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
53 x_chroma_shift: 1, y_chroma_shift: 0,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
54 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
55 [PIX_FMT_YUV444P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
56 name: "yuv444p",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
57 nb_components: 3, is_yuv: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
58 x_chroma_shift: 0, y_chroma_shift: 0,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
59 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
60 [PIX_FMT_YUV422] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
61 name: "yuv422",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
62 nb_components: 1, is_yuv: 1, is_packed: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
63 x_chroma_shift: 1, y_chroma_shift: 0,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
64 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
65 [PIX_FMT_YUV410P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
66 name: "yuv410p",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
67 nb_components: 3, is_yuv: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
68 x_chroma_shift: 2, y_chroma_shift: 2,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
69 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
70 [PIX_FMT_YUV411P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
71 name: "yuv411p",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
72 nb_components: 3, is_yuv: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
73 x_chroma_shift: 2, y_chroma_shift: 0,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
74 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
75
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
76 /* RGB formats */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
77 [PIX_FMT_RGB24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
78 name: "rgb24",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
79 nb_components: 1, is_packed: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
80 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
81 [PIX_FMT_BGR24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
82 name: "bgr24",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
83 nb_components: 1, is_packed: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
84 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
85 [PIX_FMT_RGBA32] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
86 name: "rgba32",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
87 nb_components: 1, is_packed: 1, is_alpha: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
88 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
89 [PIX_FMT_RGB565] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
90 name: "rgb565",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
91 nb_components: 1, is_packed: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
92 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
93 [PIX_FMT_RGB555] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
94 name: "rgb555",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
95 nb_components: 1, is_packed: 1, is_alpha : 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
96 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
97
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
98 /* gray / mono formats */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
99 [PIX_FMT_GRAY8] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
100 name: "gray",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
101 nb_components: 1, is_gray: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
102 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
103 [PIX_FMT_MONOWHITE] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
104 name: "monow",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
105 nb_components: 1, is_packed: 1, is_gray: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
106 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
107 [PIX_FMT_MONOBLACK] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
108 name: "monob",
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
109 nb_components: 1, is_packed: 1, is_gray: 1,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
110 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
111 };
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
112
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
113 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
114 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
115 if (pix_fmt_info[pix_fmt].is_yuv) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
116 *h_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
117 *v_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
118 } else {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
119 *h_shift=0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
120 *v_shift=0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
121 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
122 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
123
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
124 const char *avcodec_get_pix_fmt_name(int pix_fmt)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
125 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
126 if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
127 return "???";
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
128 else
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
129 return pix_fmt_info[pix_fmt].name;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
130 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
131
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
132 /* XXX: totally non optimized */
986e461dc072 Initial revision
glantau
parents:
diff changeset
133
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
134 static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
135 int width, int height)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
136 {
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
137 UINT8 *lum, *cb, *cr;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
138 int x, y;
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
139 const UINT8 *p;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
140
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
141 lum = dst->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
142 cb = dst->data[1];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
143 cr = dst->data[2];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
144 p = src->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
145
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
146 for(y=0;y<height;y+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
147 for(x=0;x<width;x+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
148 lum[0] = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
149 cb[0] = p[1];
986e461dc072 Initial revision
glantau
parents:
diff changeset
150 lum[1] = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
151 cr[0] = p[3];
986e461dc072 Initial revision
glantau
parents:
diff changeset
152 p += 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
153 lum += 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
154 cb++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
155 cr++;
986e461dc072 Initial revision
glantau
parents:
diff changeset
156 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
157 for(x=0;x<width;x+=2) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
158 lum[0] = p[0];
986e461dc072 Initial revision
glantau
parents:
diff changeset
159 lum[1] = p[2];
986e461dc072 Initial revision
glantau
parents:
diff changeset
160 p += 4;
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 lum += 2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
162 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
163 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
164 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
165
986e461dc072 Initial revision
glantau
parents:
diff changeset
166 #define SCALEBITS 8
986e461dc072 Initial revision
glantau
parents:
diff changeset
167 #define ONE_HALF (1 << (SCALEBITS - 1))
986e461dc072 Initial revision
glantau
parents:
diff changeset
168 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5))
986e461dc072 Initial revision
glantau
parents:
diff changeset
169
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
170 /* XXX: use generic filter ? */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
171 /* 1x2 -> 1x1 */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
172 static void shrink2(UINT8 *dst, int dst_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
173 UINT8 *src, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
174 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
175 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
176 int w;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
177 UINT8 *s1, *s2, *d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
178
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
179 for(;height > 0; height--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
180 s1 = src;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
181 s2 = s1 + src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
182 d = dst;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
183 for(w = width;w >= 4; w-=4) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
184 d[0] = (s1[0] + s2[0]) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
185 d[1] = (s1[1] + s2[1]) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
186 d[2] = (s1[2] + s2[2]) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
187 d[3] = (s1[3] + s2[3]) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
188 s1 += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
189 s2 += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
190 d += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
191 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
192 for(;w > 0; w--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
193 d[0] = (s1[0] + s2[0]) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
194 s1++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
195 s2++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
196 d++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
197 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
198 src += 2 * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
199 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
200 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
201 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
202
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
203 /* 2x2 -> 1x1 */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
204 static void shrink22(UINT8 *dst, int dst_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
205 UINT8 *src, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
206 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
207 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
208 int w;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
209 UINT8 *s1, *s2, *d;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
210
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
211 for(;height > 0; height--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
212 s1 = src;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
213 s2 = s1 + src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
214 d = dst;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
215 for(w = width;w >= 4; w-=4) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
216 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
217 d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
218 d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
219 d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
220 s1 += 8;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
221 s2 += 8;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
222 d += 4;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
223 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
224 for(;w > 0; w--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
225 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
226 s1 += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
227 s2 += 2;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
228 d++;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
229 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
230 src += 2 * src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
231 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
232 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
233 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
234
576
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
235 /* 1x1 -> 2x2 */
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
236 static void grow22(UINT8 *dst, int dst_wrap,
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
237 UINT8 *src, int src_wrap,
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
238 int width, int height)
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
239 {
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
240 int w;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
241 UINT8 *s1, *d;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
242
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
243 for(;height > 0; height--) {
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
244 s1 = src;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
245 d = dst;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
246 for(w = width;w >= 4; w-=4) {
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
247 d[1] = d[0] = s1[0];
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
248 d[3] = d[2] = s1[1];
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
249 s1 += 2;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
250 d += 4;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
251 }
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
252 for(;w > 0; w--) {
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
253 d[0] = s1[0];
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
254 s1 ++;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
255 d++;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
256 }
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
257 if (height%2)
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
258 src += src_wrap;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
259 dst += dst_wrap;
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
260 }
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
261 }
9aa5f0d0124e YUV410P to YUV420P patch by Fran«®ois Revol <revol at free dot fr>
michaelni
parents: 440
diff changeset
262
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
263 /* 1x2 -> 2x1 */
736
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
264 static void conv411(UINT8 *dst, int dst_wrap,
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
265 UINT8 *src, int src_wrap,
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
266 int width, int height)
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
267 {
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
268 int w, c;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
269 UINT8 *s1, *s2, *d;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
270
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
271 for(;height > 0; height--) {
736
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
272 s1 = src;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
273 s2 = src + src_wrap;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
274 d = dst;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
275 for(w = width;w > 0; w--) {
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
276 c = (s1[0] + s2[0]) >> 1;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
277 d[0] = c;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
278 d[1] = c;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
279 s1++;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
280 s2++;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
281 d += 2;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
282 }
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
283 src += src_wrap * 2;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
284 dst += dst_wrap;
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
285 }
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
286 }
918756bffda2 minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents: 583
diff changeset
287
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
288 static void img_copy(UINT8 *dst, int dst_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
289 UINT8 *src, int src_wrap,
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
290 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
291 {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
292 for(;height > 0; height--) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
293 memcpy(dst, src, width);
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
294 dst += dst_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
295 src += src_wrap;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
296 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
297 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
298
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
299 #define SCALE_BITS 10
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
300
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
301 #define C_Y (76309 >> (16 - SCALE_BITS))
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
302 #define C_RV (117504 >> (16 - SCALE_BITS))
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
303 #define C_BU (138453 >> (16 - SCALE_BITS))
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
304 #define C_GU (13954 >> (16 - SCALE_BITS))
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
305 #define C_GV (34903 >> (16 - SCALE_BITS))
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
306
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
307 #define YUV_TO_RGB2(r, g, b, y1)\
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
308 {\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
309 y = (y1 - 16) * C_Y;\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
310 r = cm[(y + r_add) >> SCALE_BITS];\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
311 g = cm[(y + g_add) >> SCALE_BITS];\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
312 b = cm[(y + b_add) >> SCALE_BITS];\
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
313 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
314
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
315 /* XXX: no chroma interpolating is done */
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
316 #define RGB_FUNCTIONS(rgb_name) \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
317 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
318 static void yuv420p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
319 int width, int height) \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
320 { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
321 UINT8 *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
322 int w, y, cb, cr, r_add, g_add, b_add, width2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
323 UINT8 *cm = cropTbl + MAX_NEG_CROP; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
324 unsigned int r, g, b; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
325 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
326 d = dst->data[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
327 y1_ptr = src->data[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
328 cb_ptr = src->data[1]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
329 cr_ptr = src->data[2]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
330 width2 = width >> 1; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
331 for(;height > 0; height -= 2) { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
332 d1 = d; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
333 d2 = d + dst->linesize[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
334 y2_ptr = y1_ptr + src->linesize[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
335 for(w = width2; w > 0; w --) { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
336 cb = cb_ptr[0] - 128; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
337 cr = cr_ptr[0] - 128; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
338 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
339 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
340 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
341 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
342 /* output 4 pixels */ \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
343 YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
344 RGB_OUT(d1, r, g, b); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
345 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
346 YUV_TO_RGB2(r, g, b, y1_ptr[1]); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
347 RGB_OUT(d1 + BPP, r, g, b); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
348 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
349 YUV_TO_RGB2(r, g, b, y2_ptr[0]); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
350 RGB_OUT(d2, r, g, b); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
351 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
352 YUV_TO_RGB2(r, g, b, y2_ptr[1]); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
353 RGB_OUT(d2 + BPP, r, g, b); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
354 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
355 d1 += 2 * BPP; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
356 d2 += 2 * BPP; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
357 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
358 y1_ptr += 2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
359 y2_ptr += 2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
360 cb_ptr++; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
361 cr_ptr++; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
362 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
363 d += 2 * dst->linesize[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
364 y1_ptr += 2 * src->linesize[0] - width; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
365 cb_ptr += src->linesize[1] - width2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
366 cr_ptr += src->linesize[2] - width2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
367 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
368 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
369 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
370 /* XXX: no chroma interpolating is done */ \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
371 static void yuv422p_to_ ## rgb_name (AVPicture *dst, AVPicture *src, \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
372 int width, int height) \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
373 { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
374 UINT8 *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
375 int w, y, cb, cr, r_add, g_add, b_add, width2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
376 UINT8 *cm = cropTbl + MAX_NEG_CROP; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
377 unsigned int r, g, b; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
378 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
379 d = dst->data[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
380 y1_ptr = src->data[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
381 cb_ptr = src->data[1]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
382 cr_ptr = src->data[2]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
383 width2 = width >> 1; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
384 for(;height > 0; height --) { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
385 d1 = d; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
386 for(w = width2; w > 0; w --) { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
387 cb = cb_ptr[0] - 128; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
388 cr = cr_ptr[0] - 128; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
389 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
390 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
391 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
392 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
393 /* output 2 pixels */ \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
394 YUV_TO_RGB2(r, g, b, y1_ptr[0]); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
395 RGB_OUT(d, r, g, b); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
396 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
397 YUV_TO_RGB2(r, g, b, y1_ptr[1]); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
398 RGB_OUT(d + BPP, r, g, b); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
399 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
400 d += 2 * BPP; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
401 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
402 y1_ptr += 2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
403 cb_ptr++; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
404 cr_ptr++; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
405 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
406 d += dst->linesize[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
407 y1_ptr += src->linesize[0] - width; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
408 cb_ptr += src->linesize[1] - width2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
409 cr_ptr += src->linesize[2] - width2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
410 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
411 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
412 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
413 static void rgb_name ## _to_yuv420p(AVPicture *dst, AVPicture *src, \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
414 int width, int height) \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
415 { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
416 int wrap, wrap3, x, y; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
417 int r, g, b, r1, g1, b1; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
418 UINT8 *lum, *cb, *cr; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
419 const UINT8 *p; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
420 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
421 lum = dst->data[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
422 cb = dst->data[1]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
423 cr = dst->data[2]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
424 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
425 wrap = width; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
426 wrap3 = width * 3; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
427 p = src->data[0]; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
428 for(y=0;y<height;y+=2) { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
429 for(x=0;x<width;x+=2) { \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
430 RGB_IN(r, g, b, p); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
431 r1 = r; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
432 g1 = g; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
433 b1 = b; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
434 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
435 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
436 RGB_IN(r, g, b, p + BPP); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
437 r1 += r; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
438 g1 += g; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
439 b1 += b; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
440 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
441 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
442 p += wrap3; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
443 lum += wrap; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
444 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
445 RGB_IN(r, g, b, p); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
446 r1 += r; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
447 g1 += g; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
448 b1 += b; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
449 lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g + \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
450 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
451 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
452 RGB_IN(r, g, b, p + BPP); \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
453 r1 += r; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
454 g1 += g; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
455 b1 += b; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
456 lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g + \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
457 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
458 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
459 cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
460 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
461 (SCALEBITS + 2)) + 128; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
462 cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
463 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
464 (SCALEBITS + 2)) + 128; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
465 \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
466 cb++; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
467 cr++; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
468 p += -wrap3 + 2 * 3; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
469 lum += -wrap + 2; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
470 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
471 p += wrap3; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
472 lum += wrap; \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
473 } \
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
474 }
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
475
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
476 /* copy bit n to bits 0 ... n - 1 */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
477 static inline unsigned int bitcopy_n(unsigned int a, int n)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
478 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
479 int mask;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
480 mask = (1 << n) - 1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
481 return (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
482 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
483
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
484 /* rgb555 handling */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
485
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
486 #define RGB_IN(r, g, b, s)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
487 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
488 unsigned int v = ((UINT16 *)(s))[0];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
489 r = bitcopy_n(v >> (10 - 3), 3);\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
490 g = bitcopy_n(v >> (5 - 3), 3);\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
491 b = bitcopy_n(v << 3, 3);\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
492 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
493
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
494 #define RGB_OUT(d, r, g, b)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
495 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
496 ((UINT16 *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
497 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
498
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
499 #define BPP 2
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
500
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
501 RGB_FUNCTIONS(rgb555)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
502
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
503 #undef RGB_IN
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
504 #undef RGB_OUT
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
505 #undef BPP
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
506
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
507 /* rgb565 handling */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
508
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
509 #define RGB_IN(r, g, b, s)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
510 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
511 unsigned int v = ((UINT16 *)(s))[0];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
512 r = bitcopy_n(v >> (11 - 3), 3);\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
513 g = bitcopy_n(v >> (5 - 2), 2);\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
514 b = bitcopy_n(v << 3, 3);\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
515 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
516
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
517 #define RGB_OUT(d, r, g, b)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
518 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
519 ((UINT16 *)(d))[0] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
520 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
521
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
522 #define BPP 2
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
523
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
524 RGB_FUNCTIONS(rgb565)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
525
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
526 #undef RGB_IN
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
527 #undef RGB_OUT
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
528 #undef BPP
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
529
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
530 /* bgr24 handling */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
531
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
532 #define RGB_IN(r, g, b, s)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
533 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
534 b = (s)[0];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
535 g = (s)[1];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
536 r = (s)[2];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
537 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
538
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
539 #define RGB_OUT(d, r, g, b)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
540 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
541 (d)[0] = b;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
542 (d)[1] = g;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
543 (d)[2] = r;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
544 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
545
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
546 #define BPP 3
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
547
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
548 RGB_FUNCTIONS(bgr24)
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
549
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
550 #undef RGB_IN
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
551 #undef RGB_OUT
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
552 #undef BPP
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
553
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
554 /* rgb24 handling */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
555
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
556 #define RGB_IN(r, g, b, s)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
557 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
558 r = (s)[0];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
559 g = (s)[1];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
560 b = (s)[2];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
561 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
562
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
563 #define RGB_OUT(d, r, g, b)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
564 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
565 (d)[0] = r;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
566 (d)[1] = g;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
567 (d)[2] = b;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
568 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
569
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
570 #define BPP 3
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
571
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
572 RGB_FUNCTIONS(rgb24)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
573
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
574 #undef RGB_IN
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
575 #undef RGB_OUT
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
576 #undef BPP
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
577
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
578 /* rgba32 handling */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
579
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
580 #define RGB_IN(r, g, b, s)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
581 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
582 unsigned int v = ((UINT32 *)(s))[0];\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
583 r = (v >> 16) & 0xff;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
584 g = (v >> 8) & 0xff;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
585 b = v & 0xff;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
586 }
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
587
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
588 #define RGB_OUT(d, r, g, b)\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
589 {\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
590 ((UINT32 *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;\
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
591 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
592
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
593 #define BPP 4
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
594
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
595 RGB_FUNCTIONS(rgba32)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
596
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
597 #undef RGB_IN
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
598 #undef RGB_OUT
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
599 #undef BPP
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
600
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
601
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
602 static void rgb24_to_rgb565(AVPicture *dst, AVPicture *src,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
603 int width, int height)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
604 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
605 const unsigned char *p;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
606 unsigned char *q;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
607 int r, g, b, dst_wrap, src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
608 int x, y;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
609
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
610 p = src->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
611 src_wrap = src->linesize[0] - 3 * width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
612
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
613 q = dst->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
614 dst_wrap = dst->linesize[0] - 2 * width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
615
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
616 for(y=0;y<height;y++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
617 for(x=0;x<width;x++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
618 r = p[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
619 g = p[1];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
620 b = p[2];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
621
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
622 ((unsigned short *)q)[0] =
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
623 ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
624 q += 2;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
625 p += 3;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
626 }
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
627 p += src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
628 q += dst_wrap;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
629 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
630 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
631
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
632 /* NOTE: we also add a dummy alpha bit */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
633 static void rgb24_to_rgb555(AVPicture *dst, AVPicture *src,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
634 int width, int height)
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
635 {
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
636 const unsigned char *p;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
637 unsigned char *q;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
638 int r, g, b, dst_wrap, src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
639 int x, y;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
640
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
641 p = src->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
642 src_wrap = src->linesize[0] - 3 * width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
643
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
644 q = dst->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
645 dst_wrap = dst->linesize[0] - 2 * width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
646
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
647 for(y=0;y<height;y++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
648 for(x=0;x<width;x++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
649 r = p[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
650 g = p[1];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
651 b = p[2];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
652
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
653 ((unsigned short *)q)[0] =
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
654 ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
655 q += 2;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
656 p += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
657 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
658 p += src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
659 q += dst_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
660 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
661 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
662
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
663 static void rgb24_to_gray(AVPicture *dst, AVPicture *src,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
664 int width, int height)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
665 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
666 const unsigned char *p;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
667 unsigned char *q;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
668 int r, g, b, dst_wrap, src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
669 int x, y;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
670
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
671 p = src->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
672 src_wrap = src->linesize[0] - 3 * width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
673
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
674 q = dst->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
675 dst_wrap = dst->linesize[0] - width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
676
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
677 for(y=0;y<height;y++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
678 for(x=0;x<width;x++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
679 r = p[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
680 g = p[1];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
681 b = p[2];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
682
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
683 q[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
684 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
685 q++;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
686 p += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
687 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
688 p += src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
689 q += dst_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
690 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
691 }
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
692
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
693 static void gray_to_rgb24(AVPicture *dst, AVPicture *src,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
694 int width, int height)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
695 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
696 const unsigned char *p;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
697 unsigned char *q;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
698 int r, dst_wrap, src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
699 int x, y;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
700
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
701 p = src->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
702 src_wrap = src->linesize[0] - width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
703
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
704 q = dst->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
705 dst_wrap = dst->linesize[0] - 3 * width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
706
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
707 for(y=0;y<height;y++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
708 for(x=0;x<width;x++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
709 r = p[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
710
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
711 q[0] = r;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
712 q[1] = r;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
713 q[2] = r;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
714
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
715 q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
716 p ++;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
717 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
718 p += src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
719 q += dst_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
720 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
721 }
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
722
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
723 static void monowhite_to_rgb24(AVPicture *dst, AVPicture *src,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
724 int width, int height)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
725 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
726 const unsigned char *p;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
727 unsigned char *q;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
728 int v, dst_wrap, src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
729 int y, w;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
730
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
731 p = src->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
732 src_wrap = src->linesize[0] - ((width + 7) >> 3);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
733
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
734 q = dst->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
735 dst_wrap = dst->linesize[0] - 3 * width;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
736
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
737 for(y=0;y<height;y++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
738 w = width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
739 while (w >= 8) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
740 v = *p++ ^ 0xff;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
741 q[0] = q[1] = q[2] = -(v >> 7); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
742 q[0] = q[1] = q[2] = -((v >> 6) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
743 q[0] = q[1] = q[2] = -((v >> 5) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
744 q[0] = q[1] = q[2] = -((v >> 4) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
745 q[0] = q[1] = q[2] = -((v >> 3) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
746 q[0] = q[1] = q[2] = -((v >> 2) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
747 q[0] = q[1] = q[2] = -((v >> 1) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
748 q[0] = q[1] = q[2] = -((v >> 0) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
749 w -= 8;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
750 }
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
751 if (w > 0) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
752 v = *p++ ^ 0xff;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
753 do {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
754 q[0] = q[1] = q[2] = -((v >> 7) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
755 v <<= 1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
756 } while (--w);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
757 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
758 p += src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
759 q += dst_wrap;
583
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
760 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
761 }
d6955d0d7d27 Add conversions to and from RGBA32 and BGRA32.
philipjsg
parents: 576
diff changeset
762
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
763 static void monoblack_to_rgb24(AVPicture *dst, AVPicture *src,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
764 int width, int height)
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
765 {
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
766 const unsigned char *p;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
767 unsigned char *q;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
768 int v, dst_wrap, src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
769 int y, w;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
770
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
771 p = src->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
772 src_wrap = src->linesize[0] - ((width + 7) >> 3);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
773
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
774 q = dst->data[0];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
775 dst_wrap = dst->linesize[0] - 3 * width;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
776
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
777 for(y=0;y<height;y++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
778 w = width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
779 while (w >= 8) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
780 v = *p++;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
781 q[0] = q[1] = q[2] = -(v >> 7); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
782 q[0] = q[1] = q[2] = -((v >> 6) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
783 q[0] = q[1] = q[2] = -((v >> 5) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
784 q[0] = q[1] = q[2] = -((v >> 4) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
785 q[0] = q[1] = q[2] = -((v >> 3) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
786 q[0] = q[1] = q[2] = -((v >> 2) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
787 q[0] = q[1] = q[2] = -((v >> 1) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
788 q[0] = q[1] = q[2] = -((v >> 0) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
789 w -= 8;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
790 }
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
791 if (w > 0) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
792 v = *p++;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
793 do {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
794 q[0] = q[1] = q[2] = -((v >> 7) & 1); q += 3;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
795 v <<= 1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
796 } while (--w);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
797 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
798 p += src_wrap;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
799 q += dst_wrap;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
800 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
801 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
802
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
803 typedef struct ConvertEntry {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
804 void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
805 } ConvertEntry;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
806
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
807 /* add each new convertion function in this table */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
808 /* constraints;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
809 - all non YUV modes must convert at least to and from PIX_FMT_RGB24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
810 */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
811 static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
812 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
813 [PIX_FMT_RGB555] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
814 convert: yuv420p_to_rgb555
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
815 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
816 [PIX_FMT_RGB565] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
817 convert: yuv420p_to_rgb565
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
818 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
819 [PIX_FMT_BGR24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
820 convert: yuv420p_to_bgr24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
821 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
822 [PIX_FMT_RGB24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
823 convert: yuv420p_to_rgb24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
824 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
825 [PIX_FMT_RGBA32] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
826 convert: yuv420p_to_rgba32
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
827 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
828 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
829 [PIX_FMT_YUV422P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
830 [PIX_FMT_RGB555] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
831 convert: yuv422p_to_rgb555
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
832 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
833 [PIX_FMT_RGB565] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
834 convert: yuv422p_to_rgb565
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
835 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
836 [PIX_FMT_BGR24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
837 convert: yuv422p_to_bgr24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
838 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
839 [PIX_FMT_RGB24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
840 convert: yuv422p_to_rgb24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
841 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
842 [PIX_FMT_RGBA32] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
843 convert: yuv422p_to_rgba32
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
844 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
845 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
846 [PIX_FMT_YUV422] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
847 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
848 convert: yuv422_to_yuv420p,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
849 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
850 },
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
851
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
852 [PIX_FMT_RGB24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
853 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
854 convert: rgb24_to_yuv420p
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
855 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
856 [PIX_FMT_RGB565] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
857 convert: rgb24_to_rgb565
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
858 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
859 [PIX_FMT_RGB555] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
860 convert: rgb24_to_rgb555
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
861 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
862 [PIX_FMT_GRAY8] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
863 convert: rgb24_to_gray
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
864 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
865 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
866 [PIX_FMT_RGBA32] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
867 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
868 convert: rgba32_to_yuv420p
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
869 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
870 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
871 [PIX_FMT_BGR24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
872 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
873 convert: bgr24_to_yuv420p
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
874 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
875 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
876 [PIX_FMT_RGB555] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
877 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
878 convert: rgb555_to_yuv420p
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
879 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
880 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
881 [PIX_FMT_RGB565] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
882 [PIX_FMT_YUV420P] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
883 convert: rgb565_to_yuv420p
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
884 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
885 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
886 [PIX_FMT_GRAY8] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
887 [PIX_FMT_RGB24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
888 convert: gray_to_rgb24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
889 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
890 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
891 [PIX_FMT_MONOWHITE] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
892 [PIX_FMT_RGB24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
893 convert: monowhite_to_rgb24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
894 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
895 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
896 [PIX_FMT_MONOBLACK] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
897 [PIX_FMT_RGB24] = {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
898 convert: monoblack_to_rgb24
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
899 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
900 },
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
901 };
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
902
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
903 static int avpicture_alloc(AVPicture *picture,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
904 int pix_fmt, int width, int height)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
905 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
906 int size;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
907 void *ptr;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
908
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
909 size = avpicture_get_size(pix_fmt, width, height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
910 if (size < 0)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
911 goto fail;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
912 ptr = av_malloc(size);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
913 if (!ptr)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
914 goto fail;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
915 avpicture_fill(picture, ptr, pix_fmt, width, height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
916 return 0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
917 fail:
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
918 memset(picture, 0, sizeof(AVPicture));
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
919 return -1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
920 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
921
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
922 static void avpicture_free(AVPicture *picture)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
923 {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
924 free(picture->data[0]);
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
925 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
926
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
927 /* XXX: always use linesize. Return -1 if not supported */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
928 int img_convert(AVPicture *dst, int dst_pix_fmt,
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
929 AVPicture *src, int src_pix_fmt,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
930 int src_width, int src_height)
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
931 {
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
932 int i, ret, dst_width, dst_height;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
933 PixFmtInfo *src_pix, *dst_pix;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
934 ConvertEntry *ce;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
935 AVPicture tmp1, *tmp = &tmp1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
936
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
937 if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB ||
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
938 dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
939 return -1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
940 if (src_width <= 0 || src_height <= 0)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
941 return 0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
942
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
943 dst_width = src_width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
944 dst_height = src_height;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
945
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
946 dst_pix = &pix_fmt_info[dst_pix_fmt];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
947 src_pix = &pix_fmt_info[src_pix_fmt];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
948 if (src_pix_fmt == dst_pix_fmt) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
949 /* same format: just copy */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
950 for(i = 0; i < dst_pix->nb_components; i++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
951 int w, h;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
952 w = dst_width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
953 h = dst_height;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
954 if (dst_pix->is_yuv && (i == 1 || i == 2)) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
955 w >>= dst_pix->x_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
956 h >>= dst_pix->y_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
957 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
958 img_copy(dst->data[i], dst->linesize[i],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
959 src->data[i], src->linesize[i],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
960 w, h);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
961 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
962 return 0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
963 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
964
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
965 ce = &convert_table[src_pix_fmt][dst_pix_fmt];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
966 if (ce->convert) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
967 /* specific convertion routine */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
968 ce->convert(dst, src, dst_width, dst_height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
969 return 0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
970 }
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
971
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
972 /* if both format are not YUV, try to use RGB24 as common
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
973 format */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
974 if (!dst_pix->is_yuv && !src_pix->is_yuv) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
975 if (avpicture_alloc(tmp, PIX_FMT_RGB24, dst_width, dst_height) < 0)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
976 return -1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
977 ret = -1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
978 if (img_convert(tmp, PIX_FMT_RGB24,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
979 src, src_pix_fmt, src_width, src_height) < 0)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
980 goto fail1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
981 if (img_convert(dst, dst_pix_fmt,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
982 tmp, PIX_FMT_RGB24, dst_width, dst_height) < 0)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
983 goto fail1;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
984 ret = 0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
985 fail1:
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
986 avpicture_free(tmp);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
987 return ret;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
988 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
990 /* gray to YUV */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
991 if (dst_pix->is_yuv && src_pix_fmt == PIX_FMT_GRAY8) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
992 int w, h, y;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
993 uint8_t *d;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
994
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
995 img_copy(dst->data[0], dst->linesize[0],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
996 src->data[0], src->linesize[0],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
997 dst_width, dst_height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
998 /* fill U and V with 128 */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
999 w = dst_width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1000 h = dst_height;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1001 w >>= dst_pix->x_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1002 h >>= dst_pix->y_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1003 for(i = 1; i <= 2; i++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1004 d = dst->data[i];
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1005 for(y = 0; y<h; y++) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1006 memset(d, 128, 0);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1007 d += dst->linesize[i];
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1008 }
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1009 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1010 return 0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1011 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1012
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1013 /* YUV to gray */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1014 if (src_pix->is_yuv && dst_pix_fmt == PIX_FMT_GRAY8) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1015 img_copy(dst->data[0], dst->linesize[0],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1016 src->data[0], src->linesize[0],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1017 dst_width, dst_height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1018 return 0;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1019 }
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1020
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1021 /* YUV to YUV */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1022 if (dst_pix->is_yuv && src_pix->is_yuv) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1023 int x_shift, y_shift, w, h;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1024 void (*resize_func)(UINT8 *dst, int dst_wrap,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1025 UINT8 *src, int src_wrap,
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1026 int width, int height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1027
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1028 /* compute chroma size of the smallest dimensions */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1029 w = dst_width;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1030 h = dst_height;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1031 if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1032 w >>= dst_pix->x_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1033 else
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1034 w >>= src_pix->x_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1035 if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1036 h >>= dst_pix->y_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1037 else
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1038 h >>= src_pix->y_chroma_shift;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1039
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1040 x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1041 y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1042 if (x_shift == 0 && y_shift == 0) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1043 resize_func = img_copy; /* should never happen */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1044 } else if (x_shift == 0 && y_shift == 1) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1045 resize_func = shrink2;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1046 } else if (x_shift == 1 && y_shift == 1) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1047 resize_func = shrink22;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1048 } else if (x_shift == -1 && y_shift == -1) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1049 resize_func = grow22;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1050 } else if (x_shift == -1 && y_shift == 1) {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1051 resize_func = conv411;
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1052 } else {
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1053 /* currently not handled */
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1054 return -1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1055 }
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1056
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1057 img_copy(dst->data[0], dst->linesize[0],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1058 src->data[0], src->linesize[0],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1059 dst_width, dst_height);
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1060 for(i = 1;i <= 2; i++)
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1061 resize_func(dst->data[1], dst->linesize[1],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1062 src->data[1], src->linesize[1],
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1063 w, h);
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1064 }
989
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1065
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1066 /* cannot convert yet */
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1067
fe9083c56733 simplified code (need automatic testing) - added primitive new format support.
bellard
parents: 940
diff changeset
1068 return -1;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1069 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1070
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1071
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1072 #ifdef HAVE_MMX
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1073 #define DEINT_INPLACE_LINE_LUM \
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1074 movd_m2r(lum_m4[0],mm0);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1075 movd_m2r(lum_m3[0],mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1076 movd_m2r(lum_m2[0],mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1077 movd_m2r(lum_m1[0],mm3);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1078 movd_m2r(lum[0],mm4);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1079 punpcklbw_r2r(mm7,mm0);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1080 movd_r2m(mm2,lum_m4[0]);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1081 punpcklbw_r2r(mm7,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1082 punpcklbw_r2r(mm7,mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1083 punpcklbw_r2r(mm7,mm3);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1084 punpcklbw_r2r(mm7,mm4);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1085 paddw_r2r(mm3,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1086 psllw_i2r(1,mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1087 paddw_r2r(mm4,mm0);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1088 psllw_i2r(2,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1089 paddw_r2r(mm6,mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1090 paddw_r2r(mm2,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1091 psubusw_r2r(mm0,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1092 psrlw_i2r(3,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1093 packuswb_r2r(mm7,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1094 movd_r2m(mm1,lum_m2[0]);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1095
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1096 #define DEINT_LINE_LUM \
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1097 movd_m2r(lum_m4[0],mm0);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1098 movd_m2r(lum_m3[0],mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1099 movd_m2r(lum_m2[0],mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1100 movd_m2r(lum_m1[0],mm3);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1101 movd_m2r(lum[0],mm4);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1102 punpcklbw_r2r(mm7,mm0);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1103 punpcklbw_r2r(mm7,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1104 punpcklbw_r2r(mm7,mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1105 punpcklbw_r2r(mm7,mm3);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1106 punpcklbw_r2r(mm7,mm4);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1107 paddw_r2r(mm3,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1108 psllw_i2r(1,mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1109 paddw_r2r(mm4,mm0);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1110 psllw_i2r(2,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1111 paddw_r2r(mm6,mm2);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1112 paddw_r2r(mm2,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1113 psubusw_r2r(mm0,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1114 psrlw_i2r(3,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1115 packuswb_r2r(mm7,mm1);\
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1116 movd_r2m(mm1,dst[0]);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1117 #endif
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1118
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1119 /* filter parameters: [-1 4 2 4 -1] // 8 */
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1120 static void deinterlace_line(UINT8 *dst, UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lum_m2, UINT8 *lum_m1, UINT8 *lum,
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1121 int size)
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1122 {
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1123 #ifndef HAVE_MMX
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1124 UINT8 *cm = cropTbl + MAX_NEG_CROP;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1125 int sum;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1126
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1127 for(;size > 0;size--) {
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1128 sum = -lum_m4[0];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1129 sum += lum_m3[0] << 2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1130 sum += lum_m2[0] << 1;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1131 sum += lum_m1[0] << 2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1132 sum += -lum[0];
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1133 dst[0] = cm[(sum + 4) >> 3];
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1134 lum_m4++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1135 lum_m3++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1136 lum_m2++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1137 lum_m1++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1138 lum++;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1139 dst++;
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1140 }
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1141 #else
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1142
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1143 for (;size > 3; size-=4) {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1144 DEINT_LINE_LUM
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1145 lum_m4+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1146 lum_m3+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1147 lum_m2+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1148 lum_m1+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1149 lum+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1150 dst+=4;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1151 }
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1152 #endif
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1153 }
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1154 static void deinterlace_line_inplace(UINT8 *lum_m4, UINT8 *lum_m3, UINT8 *lum_m2, UINT8 *lum_m1, UINT8 *lum,
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1155 int size)
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1156 {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1157 #ifndef HAVE_MMX
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1158 UINT8 *cm = cropTbl + MAX_NEG_CROP;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1159 int sum;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1160
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1161 for(;size > 0;size--) {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1162 sum = -lum_m4[0];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1163 sum += lum_m3[0] << 2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1164 sum += lum_m2[0] << 1;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1165 lum_m4[0]=lum_m2[0];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1166 sum += lum_m1[0] << 2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1167 sum += -lum[0];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1168 lum_m2[0] = cm[(sum + 4) >> 3];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1169 lum_m4++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1170 lum_m3++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1171 lum_m2++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1172 lum_m1++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1173 lum++;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1174 }
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1175 #else
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1176
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1177 for (;size > 3; size-=4) {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1178 DEINT_INPLACE_LINE_LUM
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1179 lum_m4+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1180 lum_m3+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1181 lum_m2+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1182 lum_m1+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1183 lum+=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1184 }
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1185 #endif
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1186 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1187
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1188 /* deinterlacing : 2 temporal taps, 3 spatial taps linear filter. The
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1189 top field is copied as is, but the bottom field is deinterlaced
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1190 against the top field. */
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1191 static void deinterlace_bottom_field(UINT8 *dst, int dst_wrap,
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1192 UINT8 *src1, int src_wrap,
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1193 int width, int height)
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1194 {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1195 UINT8 *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1196 int y;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1197
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1198 src_m2 = src1;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1199 src_m1 = src1;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1200 src_0=&src_m1[src_wrap];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1201 src_p1=&src_0[src_wrap];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1202 src_p2=&src_p1[src_wrap];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1203 for(y=0;y<(height-2);y+=2) {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1204 memcpy(dst,src_m1,width);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1205 dst += dst_wrap;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1206 deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1207 src_m2 = src_0;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1208 src_m1 = src_p1;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1209 src_0 = src_p2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1210 src_p1 += 2*src_wrap;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1211 src_p2 += 2*src_wrap;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1212 dst += dst_wrap;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1213 }
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1214 memcpy(dst,src_m1,width);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1215 dst += dst_wrap;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1216 /* do last line */
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1217 deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1218 }
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1219
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1220 static void deinterlace_bottom_field_inplace(UINT8 *src1, int src_wrap,
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1221 int width, int height)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1222 {
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1223 UINT8 *src_m1, *src_0, *src_p1, *src_p2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1224 int y;
64
5aa6292a1660 win32 fixes
glantau
parents: 52
diff changeset
1225 UINT8 *buf;
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1226 buf = (UINT8*)av_malloc(width);
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1227
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1228 src_m1 = src1;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1229 memcpy(buf,src_m1,width);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1230 src_0=&src_m1[src_wrap];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1231 src_p1=&src_0[src_wrap];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1232 src_p2=&src_p1[src_wrap];
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1233 for(y=0;y<(height-2);y+=2) {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1234 deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1235 src_m1 = src_p1;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1236 src_0 = src_p2;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1237 src_p1 += 2*src_wrap;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1238 src_p2 += 2*src_wrap;
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1239 }
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1240 /* do last line */
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1241 deinterlace_line_inplace(buf,src_m1,src_0,src_0,src_0,width);
396
fce0a2520551 removed useless header includes - use av memory functions
glantau
parents: 315
diff changeset
1242 av_free(buf);
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1243 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1244
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1245
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1246 /* deinterlace - if not supported return -1 */
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1247 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1248 int pix_fmt, int width, int height)
986e461dc072 Initial revision
glantau
parents:
diff changeset
1249 {
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1250 int i;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1251
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1252 if (pix_fmt != PIX_FMT_YUV420P &&
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1253 pix_fmt != PIX_FMT_YUV422P &&
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1254 pix_fmt != PIX_FMT_YUV444P)
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1255 return -1;
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1256 if ((width & 3) != 0 || (height & 3) != 0)
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1257 return -1;
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1258
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1259 #ifdef HAVE_MMX
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1260 {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1261 mmx_t rounder;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1262 rounder.uw[0]=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1263 rounder.uw[1]=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1264 rounder.uw[2]=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1265 rounder.uw[3]=4;
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1266 pxor_r2r(mm7,mm7);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1267 movq_m2r(rounder,mm6);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1268 }
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1269 #endif
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1270
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1271
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1272 for(i=0;i<3;i++) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1273 if (i == 1) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1274 switch(pix_fmt) {
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1275 case PIX_FMT_YUV420P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1276 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1277 height >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1278 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1279 case PIX_FMT_YUV422P:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1280 width >>= 1;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1281 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1282 default:
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1283 break;
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1284 }
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1285 }
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1286 if (src == dst) {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1287 deinterlace_bottom_field_inplace(src->data[i], src->linesize[i],
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1288 width, height);
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1289 } else {
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1290 deinterlace_bottom_field(dst->data[i],dst->linesize[i],
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1291 src->data[i], src->linesize[i],
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1292 width, height);
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1293 }
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1294 }
801
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1295 #ifdef HAVE_MMX
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1296 emms();
f720b01c0fd5 1) Add MMX deinterlace code.
michaelni
parents: 736
diff changeset
1297 #endif
52
1d796bdb2c2a added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents: 18
diff changeset
1298 return 0;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1299 }
440
000aeeac27a2 * started to cleanup name clashes for onetime compilation
kabi
parents: 429
diff changeset
1300
000aeeac27a2 * started to cleanup name clashes for onetime compilation
kabi
parents: 429
diff changeset
1301 #undef FIX