Mercurial > libavcodec.hg
annotate imgconvert.c @ 1086:d3b93dc997a3 libavcodec
user specified motion estimation range limit
h263 me range fixed (was smaller then needed)
author | michaelni |
---|---|
date | Thu, 27 Feb 2003 22:56:07 +0000 |
parents | 4bc02fcf4d8c |
children | 1e39f273ecd6 |
rev | line source |
---|---|
0 | 1 /* |
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 | 4 * |
429 | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
0 | 9 * |
429 | 10 * This library is distributed in the hope that it will be useful, |
0 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Lesser General Public License for more details. | |
0 | 14 * |
429 | 15 * You should have received a copy of the GNU Lesser General Public |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
0 | 18 */ |
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 | 21 |
17 | 22 #ifdef USE_FASTMEMCPY |
23 #include "fastmemcpy.h" | |
24 #endif | |
801 | 25 |
26 #ifdef HAVE_MMX | |
27 #include "i386/mmx.h" | |
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; |
1064 | 32 uint8_t nb_components; /* number of components in AVPicture array */ |
33 uint8_t is_yuv : 1; /* true if YUV instead of RGB color space */ | |
34 uint8_t is_packed : 1; /* true if multiple components in same word */ | |
35 uint8_t is_paletted : 1; /* true if paletted */ | |
36 uint8_t is_alpha : 1; /* true if alpha can be specified */ | |
37 uint8_t is_gray : 1; /* true if gray or monochrome format */ | |
38 uint8_t x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */ | |
39 uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */ | |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
46 .name = "yuv420p", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
47 .nb_components = 3, .is_yuv = 1, |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
48 .x_chroma_shift = 1, .y_chroma_shift = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
51 .name = "yuv422p", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
52 .nb_components = 3, .is_yuv = 1, |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
53 .x_chroma_shift = 1, .y_chroma_shift = 0, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
56 .name = "yuv444p", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
57 .nb_components = 3, .is_yuv = 1, |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
58 .x_chroma_shift = 0, .y_chroma_shift = 0, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
61 .name = "yuv422", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
62 .nb_components = 1, .is_yuv = 1, .is_packed = 1, |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
63 .x_chroma_shift = 1, .y_chroma_shift = 0, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
66 .name = "yuv410p", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
67 .nb_components = 3, .is_yuv = 1, |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
68 .x_chroma_shift = 2, .y_chroma_shift = 2, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
71 .name = "yuv411p", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
72 .nb_components = 3, .is_yuv = 1, |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
73 .x_chroma_shift = 2, .y_chroma_shift = 0, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
78 .name = "rgb24", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
79 .nb_components = 1, .is_packed = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
82 .name = "bgr24", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
83 .nb_components = 1, .is_packed = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
86 .name = "rgba32", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
87 .nb_components = 1, .is_packed = 1, .is_alpha = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
90 .name = "rgb565", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
91 .nb_components = 1, .is_packed = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
94 .name = "rgb555", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
95 .nb_components = 1, .is_packed = 1, .is_alpha = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
100 .name = "gray", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
101 .nb_components = 1, .is_gray = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
104 .name = "monow", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
105 .nb_components = 1, .is_packed = 1, .is_gray = 1, |
989
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] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
108 .name = "monob", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
109 .nb_components = 1, .is_packed = 1, .is_gray = 1, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
110 }, |
1055 | 111 |
112 /* paletted formats */ | |
113 [PIX_FMT_PAL8] = { | |
114 .name = "pal8", | |
115 .nb_components = 1, .is_packed = 1, .is_paletted = 1, | |
116 }, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
117 }; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
118 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
119 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
|
120 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
121 if (pix_fmt_info[pix_fmt].is_yuv) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
122 *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
|
123 *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
|
124 } else { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
125 *h_shift=0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
126 *v_shift=0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
127 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
128 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
129 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
130 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
|
131 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
132 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
|
133 return "???"; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
134 else |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
135 return pix_fmt_info[pix_fmt].name; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
136 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
137 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
138 /* Picture field are filled with 'ptr' addresses. Also return size */ |
1064 | 139 int avpicture_fill(AVPicture *picture, uint8_t *ptr, |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
140 int pix_fmt, int width, int height) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
141 { |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
142 int size, w2, h2, size2; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
143 PixFmtInfo *pinfo; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
144 |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
145 pinfo = &pix_fmt_info[pix_fmt]; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
146 size = width * height; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
147 switch(pix_fmt) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
148 case PIX_FMT_YUV420P: |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
149 case PIX_FMT_YUV422P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
150 case PIX_FMT_YUV444P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
151 case PIX_FMT_YUV410P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
152 case PIX_FMT_YUV411P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
153 w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
154 h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
155 size2 = w2 * h2; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
156 picture->data[0] = ptr; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
157 picture->data[1] = picture->data[0] + size; |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
158 picture->data[2] = picture->data[1] + size2; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
159 picture->linesize[0] = width; |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
160 picture->linesize[1] = w2; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
161 picture->linesize[2] = w2; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
162 return size + 2 * size2; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
163 case PIX_FMT_RGB24: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
164 case PIX_FMT_BGR24: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
165 picture->data[0] = ptr; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
166 picture->data[1] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
167 picture->data[2] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
168 picture->linesize[0] = width * 3; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
169 return size * 3; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
170 case PIX_FMT_RGBA32: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
171 picture->data[0] = ptr; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
172 picture->data[1] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
173 picture->data[2] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
174 picture->linesize[0] = width * 4; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
175 return size * 4; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
176 case PIX_FMT_RGB555: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
177 case PIX_FMT_RGB565: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
178 case PIX_FMT_YUV422: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
179 picture->data[0] = ptr; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
180 picture->data[1] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
181 picture->data[2] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
182 picture->linesize[0] = width * 2; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
183 return size * 2; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
184 case PIX_FMT_GRAY8: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
185 picture->data[0] = ptr; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
186 picture->data[1] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
187 picture->data[2] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
188 picture->linesize[0] = width; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
189 return size; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
190 case PIX_FMT_MONOWHITE: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
191 case PIX_FMT_MONOBLACK: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
192 picture->data[0] = ptr; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
193 picture->data[1] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
194 picture->data[2] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
195 picture->linesize[0] = (width + 7) >> 3; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
196 return picture->linesize[0] * height; |
1055 | 197 case PIX_FMT_PAL8: |
198 size2 = (size + 3) & ~3; | |
199 picture->data[0] = ptr; | |
200 picture->data[1] = ptr + size2; /* palette is stored here as 256 32 bit words */ | |
201 picture->data[2] = NULL; | |
202 picture->linesize[0] = width; | |
203 picture->linesize[1] = 4; | |
204 return size2 + 256 * 4; | |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
205 default: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
206 picture->data[0] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
207 picture->data[1] = NULL; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
208 picture->data[2] = NULL; |
1055 | 209 picture->data[3] = NULL; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
210 return -1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
211 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
212 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
213 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
214 int avpicture_get_size(int pix_fmt, int width, int height) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
215 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
216 AVPicture dummy_pict; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
217 return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
218 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
219 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
220 |
0 | 221 /* XXX: totally non optimized */ |
222 | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
223 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
|
224 int width, int height) |
0 | 225 { |
1064 | 226 uint8_t *lum, *cb, *cr; |
0 | 227 int x, y; |
1064 | 228 const uint8_t *p; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
229 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
230 lum = dst->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
231 cb = dst->data[1]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
232 cr = dst->data[2]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
233 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
234 |
0 | 235 for(y=0;y<height;y+=2) { |
236 for(x=0;x<width;x+=2) { | |
1028
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
237 lum[0] = p[0]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
238 cb[0] = p[1]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
239 lum[1] = p[2]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
240 cr[0] = p[3]; |
0 | 241 p += 4; |
242 lum += 2; | |
243 cb++; | |
244 cr++; | |
245 } | |
246 for(x=0;x<width;x+=2) { | |
1028
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
247 lum[0] = p[0]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
248 lum[1] = p[2]; |
0 | 249 p += 4; |
250 lum += 2; | |
251 } | |
252 } | |
253 } | |
254 | |
255 #define SCALEBITS 8 | |
256 #define ONE_HALF (1 << (SCALEBITS - 1)) | |
257 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) | |
258 | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
259 /* XXX: use generic filter ? */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
260 /* 1x2 -> 1x1 */ |
1064 | 261 static void shrink2(uint8_t *dst, int dst_wrap, |
262 uint8_t *src, int src_wrap, | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
263 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
264 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
265 int w; |
1064 | 266 uint8_t *s1, *s2, *d; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
267 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
268 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
269 s1 = src; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
270 s2 = s1 + src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
271 d = dst; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
272 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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 s1 += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
278 s2 += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
279 d += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
280 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
281 for(;w > 0; w--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
282 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
|
283 s1++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
284 s2++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
285 d++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
286 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
287 src += 2 * src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
288 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
289 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
290 } |
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 /* 2x2 -> 1x1 */ |
1064 | 293 static void shrink22(uint8_t *dst, int dst_wrap, |
294 uint8_t *src, int src_wrap, | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
295 int width, int height) |
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 int w; |
1064 | 298 uint8_t *s1, *s2, *d; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
299 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
300 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
301 s1 = src; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
302 s2 = s1 + src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
303 d = dst; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 s1 += 8; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
310 s2 += 8; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
311 d += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
312 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
313 for(;w > 0; w--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
314 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
|
315 s1 += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
316 s2 += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
317 d++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
318 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
319 src += 2 * src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
320 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
321 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
322 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
323 |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
324 /* 1x1 -> 2x2 */ |
1064 | 325 static void grow22(uint8_t *dst, int dst_wrap, |
326 uint8_t *src, int src_wrap, | |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
327 int width, int height) |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
328 { |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
329 int w; |
1064 | 330 uint8_t *s1, *d; |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
331 |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
332 for(;height > 0; height--) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
333 s1 = src; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
334 d = dst; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
335 for(w = width;w >= 4; w-=4) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
336 d[1] = d[0] = s1[0]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
337 d[3] = d[2] = s1[1]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
338 s1 += 2; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
339 d += 4; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
340 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
341 for(;w > 0; w--) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
342 d[0] = s1[0]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
343 s1 ++; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
344 d++; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
345 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
346 if (height%2) |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
347 src += src_wrap; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
348 dst += dst_wrap; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
349 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
350 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
351 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
352 /* 1x2 -> 2x1 */ |
1064 | 353 static void conv411(uint8_t *dst, int dst_wrap, |
354 uint8_t *src, int src_wrap, | |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
355 int width, int height) |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
356 { |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
357 int w, c; |
1064 | 358 uint8_t *s1, *s2, *d; |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
359 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
360 for(;height > 0; height--) { |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
361 s1 = src; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
362 s2 = src + src_wrap; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
363 d = dst; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
364 for(w = width;w > 0; w--) { |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
365 c = (s1[0] + s2[0]) >> 1; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
366 d[0] = c; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
367 d[1] = c; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
368 s1++; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
369 s2++; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
370 d += 2; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
371 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
372 src += src_wrap * 2; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
373 dst += dst_wrap; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
374 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
375 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
376 |
1064 | 377 static void img_copy(uint8_t *dst, int dst_wrap, |
378 uint8_t *src, int src_wrap, | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
379 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
380 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
381 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
382 memcpy(dst, src, width); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
383 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
384 src += src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
385 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
386 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
387 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
388 #define SCALE_BITS 10 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
389 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
390 #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
|
391 #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
|
392 #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
|
393 #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
|
394 #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
|
395 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
396 #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
|
397 {\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
398 y = (y1 - 16) * C_Y;\ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
399 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
|
400 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
|
401 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
|
402 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
403 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
404 /* XXX: no chroma interpolating is done */ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
405 #define RGB_FUNCTIONS(rgb_name) \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
406 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
407 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
|
408 int width, int height) \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
409 { \ |
1064 | 410 uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
411 int w, y, cb, cr, r_add, g_add, b_add, width2; \ |
1064 | 412 uint8_t *cm = cropTbl + MAX_NEG_CROP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
413 unsigned int r, g, b; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
414 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
415 d = dst->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
416 y1_ptr = src->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
417 cb_ptr = src->data[1]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
418 cr_ptr = src->data[2]; \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
419 width2 = (width + 1) >> 1; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
420 for(;height >= 2; height -= 2) { \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
421 d1 = d; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
422 d2 = d + dst->linesize[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
423 y2_ptr = y1_ptr + src->linesize[0]; \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
424 for(w = width; w >= 2; w -= 2) { \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
425 cb = cb_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
426 cr = cr_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
427 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
|
428 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
|
429 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
|
430 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
431 /* output 4 pixels */ \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
432 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
|
433 RGB_OUT(d1, r, g, b); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
434 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
435 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
|
436 RGB_OUT(d1 + BPP, r, g, b); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
437 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
438 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
|
439 RGB_OUT(d2, r, g, b); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
440 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
441 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
|
442 RGB_OUT(d2 + BPP, r, g, b); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
443 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
444 d1 += 2 * BPP; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
445 d2 += 2 * BPP; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
446 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
447 y1_ptr += 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
448 y2_ptr += 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
449 cb_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
450 cr_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
451 } \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
452 /* handle odd width */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
453 if (w) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
454 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
455 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
456 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
457 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
458 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
459 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
460 YUV_TO_RGB2(r, g, b, y1_ptr[0]); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
461 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
462 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
463 YUV_TO_RGB2(r, g, b, y2_ptr[0]); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
464 RGB_OUT(d2, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
465 d1 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
466 d2 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
467 y1_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
468 y2_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
469 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
470 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
471 } \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
472 d += 2 * dst->linesize[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
473 y1_ptr += 2 * src->linesize[0] - width; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
474 cb_ptr += src->linesize[1] - width2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
475 cr_ptr += src->linesize[2] - width2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
476 } \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
477 /* handle odd height */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
478 if (height) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
479 d1 = d; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
480 for(w = width; w >= 2; w -= 2) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
481 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
482 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
483 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
484 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
485 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
486 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
487 /* output 2 pixels */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
488 YUV_TO_RGB2(r, g, b, y1_ptr[0]); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
489 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
490 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
491 YUV_TO_RGB2(r, g, b, y1_ptr[1]); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
492 RGB_OUT(d1 + BPP, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
493 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
494 d1 += 2 * BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
495 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
496 y1_ptr += 2; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
497 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
498 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
499 } \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
500 /* handle width */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
501 if (w) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
502 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
503 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
504 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
505 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
506 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
507 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
508 /* output 2 pixels */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
509 YUV_TO_RGB2(r, g, b, y1_ptr[0]); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
510 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
511 d1 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
512 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
513 y1_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
514 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
515 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
516 } \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
517 } \ |
989
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 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
520 /* XXX: no chroma interpolating is done */ \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
521 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
|
522 int width, int height) \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
523 { \ |
1064 | 524 uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
525 int w, y, cb, cr, r_add, g_add, b_add, width2; \ |
1064 | 526 uint8_t *cm = cropTbl + MAX_NEG_CROP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
527 unsigned int r, g, b; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
528 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
529 d = dst->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
530 y1_ptr = src->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
531 cb_ptr = src->data[1]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
532 cr_ptr = src->data[2]; \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
533 width2 = (width + 1) >> 1; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
534 for(;height > 0; height --) { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
535 d1 = d; \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
536 for(w = width; w >= 2; w -= 2) { \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
537 cb = cb_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
538 cr = cr_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
539 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
|
540 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
|
541 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
|
542 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
543 /* output 2 pixels */ \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
544 YUV_TO_RGB2(r, g, b, y1_ptr[0]); \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
545 RGB_OUT(d1, r, g, b); \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
546 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
547 YUV_TO_RGB2(r, g, b, y1_ptr[1]); \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
548 RGB_OUT(d1 + BPP, r, g, b); \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
549 \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
550 d1 += 2 * BPP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
551 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
552 y1_ptr += 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
553 cb_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
554 cr_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
555 } \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
556 /* handle width */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
557 if (w) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
558 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
559 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
560 r_add = C_RV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
561 g_add = - C_GU * cb - C_GV * cr + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
562 b_add = C_BU * cb + (1 << (SCALE_BITS - 1)); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
563 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
564 /* output 2 pixels */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
565 YUV_TO_RGB2(r, g, b, y1_ptr[0]); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
566 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
567 d1 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
568 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
569 y1_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
570 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
571 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
572 } \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
573 d += dst->linesize[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
574 y1_ptr += src->linesize[0] - width; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
575 cb_ptr += src->linesize[1] - width2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
576 cr_ptr += src->linesize[2] - width2; \ |
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 } \ |
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 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
|
581 int width, int height) \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
582 { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
583 int wrap, wrap3, x, y; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
584 int r, g, b, r1, g1, b1; \ |
1064 | 585 uint8_t *lum, *cb, *cr; \ |
586 const uint8_t *p; \ | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
587 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
588 lum = dst->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
589 cb = dst->data[1]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
590 cr = dst->data[2]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
591 \ |
1052
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
592 wrap = dst->linesize[0]; \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
593 wrap3 = src->linesize[0]; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
594 p = src->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
595 for(y=0;y<height;y+=2) { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
596 for(x=0;x<width;x+=2) { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
597 RGB_IN(r, g, b, p); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
598 r1 = r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
599 g1 = g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
600 b1 = b; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
601 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
|
602 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
603 RGB_IN(r, g, b, p + BPP); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
604 r1 += r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
605 g1 += g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
606 b1 += b; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
607 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
|
608 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
609 p += wrap3; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
610 lum += wrap; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
611 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
612 RGB_IN(r, g, b, p); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
613 r1 += r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
614 g1 += g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
615 b1 += b; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
616 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
|
617 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
618 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
619 RGB_IN(r, g, b, p + BPP); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
620 r1 += r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
621 g1 += g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
622 b1 += b; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
623 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
|
624 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
625 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
626 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
|
627 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
628 (SCALEBITS + 2)) + 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
629 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
|
630 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
631 (SCALEBITS + 2)) + 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
632 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
633 cb++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
634 cr++; \ |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
635 p += -wrap3 + 2 * BPP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
636 lum += -wrap + 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
637 } \ |
1052
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
638 p += wrap3 + (wrap3 - width * BPP); \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
639 lum += wrap + (wrap - width); \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
640 cb += dst->linesize[1] - width / 2; \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
641 cr += dst->linesize[2] - width / 2; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
642 } \ |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
643 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
644 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
645 static void rgb_name ## _to_gray(AVPicture *dst, AVPicture *src, \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
646 int width, int height) \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
647 { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
648 const unsigned char *p; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
649 unsigned char *q; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
650 int r, g, b, dst_wrap, src_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
651 int x, y; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
652 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
653 p = src->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
654 src_wrap = src->linesize[0] - BPP * width; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
655 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
656 q = dst->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
657 dst_wrap = dst->linesize[0] - width; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
658 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
659 for(y=0;y<height;y++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
660 for(x=0;x<width;x++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
661 RGB_IN(r, g, b, p); \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
662 q[0] = (FIX(0.29900) * r + FIX(0.58700) * g + \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
663 FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
664 q++; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
665 p += BPP; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
666 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
667 p += src_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
668 q += dst_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
669 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
670 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
671 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
672 static void gray_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
673 int width, int height) \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
674 { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
675 const unsigned char *p; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
676 unsigned char *q; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
677 int r, dst_wrap, src_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
678 int x, y; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
679 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
680 p = src->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
681 src_wrap = src->linesize[0] - width; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
682 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
683 q = dst->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
684 dst_wrap = dst->linesize[0] - BPP * width; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
685 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
686 for(y=0;y<height;y++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
687 for(x=0;x<width;x++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
688 r = p[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
689 RGB_OUT(q, r, r, r); \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
690 q += BPP; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
691 p ++; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
692 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
693 p += src_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
694 q += dst_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
695 } \ |
1055 | 696 } \ |
697 \ | |
698 static void pal8_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \ | |
699 int width, int height) \ | |
700 { \ | |
701 const unsigned char *p; \ | |
702 unsigned char *q; \ | |
703 int r, g, b, dst_wrap, src_wrap; \ | |
704 int x, y; \ | |
705 uint32_t v;\ | |
706 const uint32_t *palette;\ | |
707 \ | |
708 p = src->data[0]; \ | |
709 src_wrap = src->linesize[0] - width; \ | |
710 palette = (uint32_t *)src->data[1];\ | |
711 \ | |
712 q = dst->data[0]; \ | |
713 dst_wrap = dst->linesize[0] - BPP * width; \ | |
714 \ | |
715 for(y=0;y<height;y++) { \ | |
716 for(x=0;x<width;x++) { \ | |
717 v = palette[p[0]];\ | |
718 r = (v >> 16) & 0xff;\ | |
719 g = (v >> 8) & 0xff;\ | |
720 b = (v) & 0xff;\ | |
721 RGB_OUT(q, r, g, b); \ | |
722 q += BPP; \ | |
723 p ++; \ | |
724 } \ | |
725 p += src_wrap; \ | |
726 q += dst_wrap; \ | |
727 } \ | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
728 } |
583 | 729 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
730 /* copy bit n to bits 0 ... n - 1 */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
731 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
|
732 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
733 int mask; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
734 mask = (1 << n) - 1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
735 return (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
736 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
737 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
738 /* rgb555 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
739 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
740 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
741 {\ |
1064 | 742 unsigned int v = ((const uint16_t *)(s))[0];\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
743 r = bitcopy_n(v >> (10 - 3), 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
744 g = bitcopy_n(v >> (5 - 3), 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
745 b = bitcopy_n(v << 3, 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
746 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
747 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
748 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
749 {\ |
1064 | 750 ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
751 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
752 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
753 #define BPP 2 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
754 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
755 RGB_FUNCTIONS(rgb555) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
756 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
757 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
758 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
759 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
760 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
761 /* rgb565 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
762 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
763 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
764 {\ |
1064 | 765 unsigned int v = ((const uint16_t *)(s))[0];\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
766 r = bitcopy_n(v >> (11 - 3), 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
767 g = bitcopy_n(v >> (5 - 2), 2);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
768 b = bitcopy_n(v << 3, 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
769 } |
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 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
772 {\ |
1064 | 773 ((uint16_t *)(d))[0] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
774 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
775 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
776 #define BPP 2 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
777 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
778 RGB_FUNCTIONS(rgb565) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
779 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
780 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
781 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
782 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
783 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
784 /* bgr24 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
785 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
786 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
787 {\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
788 b = (s)[0];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
789 g = (s)[1];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
790 r = (s)[2];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
791 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
792 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
793 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
794 {\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
795 (d)[0] = b;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
796 (d)[1] = g;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
797 (d)[2] = r;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
798 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
799 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
800 #define BPP 3 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
801 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
802 RGB_FUNCTIONS(bgr24) |
583 | 803 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
804 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
805 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
806 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
807 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
808 /* rgb24 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
809 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
810 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
811 {\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
812 r = (s)[0];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
813 g = (s)[1];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
814 b = (s)[2];\ |
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 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
817 #define RGB_OUT(d, r, g, b)\ |
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 (d)[0] = r;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
820 (d)[1] = g;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
821 (d)[2] = b;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
822 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
823 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
824 #define BPP 3 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
825 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
826 RGB_FUNCTIONS(rgb24) |
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 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
829 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
830 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
831 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
832 /* rgba32 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
833 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
834 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
835 {\ |
1064 | 836 unsigned int v = ((const uint32_t *)(s))[0];\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
837 r = (v >> 16) & 0xff;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
838 g = (v >> 8) & 0xff;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
839 b = v & 0xff;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
840 } |
583 | 841 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
842 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
843 {\ |
1064 | 844 ((uint32_t *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;\ |
989
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 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
847 #define BPP 4 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
848 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
849 RGB_FUNCTIONS(rgba32) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
850 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
851 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
852 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
853 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
854 |
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 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
|
857 int width, int height) |
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 const unsigned char *p; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
860 unsigned char *q; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
861 int r, g, b, dst_wrap, src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
862 int x, y; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
863 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
864 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
865 src_wrap = src->linesize[0] - 3 * width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
866 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
867 q = dst->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
868 dst_wrap = dst->linesize[0] - 2 * width; |
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 for(y=0;y<height;y++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
871 for(x=0;x<width;x++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
872 r = p[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
873 g = p[1]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
874 b = p[2]; |
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 ((unsigned short *)q)[0] = |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
877 ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
878 q += 2; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
879 p += 3; |
583 | 880 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
881 p += src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
882 q += dst_wrap; |
583 | 883 } |
884 } | |
885 | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
886 /* NOTE: we also add a dummy alpha bit */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
887 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
|
888 int width, int height) |
583 | 889 { |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
890 const unsigned char *p; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
891 unsigned char *q; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
892 int r, g, b, dst_wrap, src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
893 int x, y; |
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 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
896 src_wrap = src->linesize[0] - 3 * width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
897 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
898 q = dst->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
899 dst_wrap = dst->linesize[0] - 2 * width; |
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 for(y=0;y<height;y++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
902 for(x=0;x<width;x++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
903 r = p[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
904 g = p[1]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
905 b = p[2]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
906 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
907 ((unsigned short *)q)[0] = |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
908 ((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
|
909 q += 2; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
910 p += 3; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
911 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
912 p += src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
913 q += dst_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
914 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
915 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
916 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
917 static void mono_to_gray(AVPicture *dst, AVPicture *src, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
918 int width, int height, int xor_mask) |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
919 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
920 const unsigned char *p; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
921 unsigned char *q; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
922 int v, dst_wrap, src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
923 int y, w; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
924 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
925 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
926 src_wrap = src->linesize[0] - ((width + 7) >> 3); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
927 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
928 q = dst->data[0]; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
929 dst_wrap = dst->linesize[0] - width; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
930 for(y=0;y<height;y++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
931 w = width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
932 while (w >= 8) { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
933 v = *p++ ^ xor_mask; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
934 q[0] = -(v >> 7); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
935 q[1] = -((v >> 6) & 1); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
936 q[2] = -((v >> 5) & 1); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
937 q[3] = -((v >> 4) & 1); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
938 q[4] = -((v >> 3) & 1); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
939 q[5] = -((v >> 2) & 1); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
940 q[6] = -((v >> 1) & 1); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
941 q[7] = -((v >> 0) & 1); |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
942 w -= 8; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
943 q += 8; |
583 | 944 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
945 if (w > 0) { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
946 v = *p++ ^ xor_mask; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
947 do { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
948 q[0] = -((v >> 7) & 1); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
949 q++; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
950 v <<= 1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
951 } while (--w); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
952 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
953 p += src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
954 q += dst_wrap; |
583 | 955 } |
956 } | |
957 | |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
958 static void monowhite_to_gray(AVPicture *dst, AVPicture *src, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
959 int width, int height) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
960 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
961 mono_to_gray(dst, src, width, height, 0xff); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
962 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
963 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
964 static void monoblack_to_gray(AVPicture *dst, AVPicture *src, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
965 int width, int height) |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
966 { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
967 mono_to_gray(dst, src, width, height, 0x00); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
968 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
969 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
970 static void gray_to_mono(AVPicture *dst, AVPicture *src, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
971 int width, int height, int xor_mask) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
972 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
973 int n; |
1064 | 974 const uint8_t *s; |
975 uint8_t *d; | |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
976 int j, b, v, n1, src_wrap, dst_wrap, y; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
977 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
978 s = src->data[0]; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
979 src_wrap = src->linesize[0] - width; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
980 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
981 d = dst->data[0]; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
982 dst_wrap = dst->linesize[0] - ((width + 7) >> 3); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
983 printf("%d %d\n", width, height); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
984 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
985 for(y=0;y<height;y++) { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
986 n = width; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
987 while (n >= 8) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
988 v = 0; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
989 for(j=0;j<8;j++) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
990 b = s[0]; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
991 s++; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
992 v = (v << 1) | (b >> 7); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
993 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
994 d[0] = v ^ xor_mask; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
995 d++; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
996 n -= 8; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
997 } |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
998 if (n > 0) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
999 n1 = n; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1000 v = 0; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1001 while (n > 0) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1002 b = s[0]; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1003 s++; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1004 v = (v << 1) | (b >> 7); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1005 n--; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1006 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1007 d[0] = (v << (8 - (n1 & 7))) ^ xor_mask; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1008 d++; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1009 } |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1010 s += src_wrap; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1011 d += dst_wrap; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1012 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1013 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1014 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1015 static void gray_to_monowhite(AVPicture *dst, AVPicture *src, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1016 int width, int height) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1017 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1018 gray_to_mono(dst, src, width, height, 0xff); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1019 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1020 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1021 static void gray_to_monoblack(AVPicture *dst, AVPicture *src, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1022 int width, int height) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1023 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1024 gray_to_mono(dst, src, width, height, 0x00); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1025 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1026 |
1055 | 1027 /* this is maybe slow, but allows for extensions */ |
1064 | 1028 static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b) |
1055 | 1029 { |
1030 return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6)); | |
1031 } | |
1032 | |
1033 /* XXX: put jpeg quantize code instead */ | |
1034 static void rgb24_to_pal8(AVPicture *dst, AVPicture *src, | |
1035 int width, int height) | |
1036 { | |
1037 const unsigned char *p; | |
1038 unsigned char *q; | |
1039 int r, g, b, dst_wrap, src_wrap; | |
1040 int x, y, i; | |
1041 static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff }; | |
1042 uint32_t *pal; | |
1043 | |
1044 p = src->data[0]; | |
1045 src_wrap = src->linesize[0] - 3 * width; | |
1046 | |
1047 q = dst->data[0]; | |
1048 dst_wrap = dst->linesize[0] - width; | |
1049 | |
1050 for(y=0;y<height;y++) { | |
1051 for(x=0;x<width;x++) { | |
1052 r = p[0]; | |
1053 g = p[1]; | |
1054 b = p[2]; | |
1055 | |
1056 q[0] = gif_clut_index(r, g, b); | |
1057 q++; | |
1058 p += 3; | |
1059 } | |
1060 p += src_wrap; | |
1061 q += dst_wrap; | |
1062 } | |
1063 | |
1064 /* build palette */ | |
1065 pal = (uint32_t *)dst->data[1]; | |
1066 i = 0; | |
1067 for(r = 0; r < 6; r++) { | |
1068 for(g = 0; g < 6; g++) { | |
1069 for(b = 0; b < 6; b++) { | |
1070 pal[i++] = (0xff << 24) | (pal_value[r] << 16) | | |
1071 (pal_value[g] << 8) | pal_value[b]; | |
1072 } | |
1073 } | |
1074 } | |
1075 while (i < 256) | |
1076 pal[i++] = 0; | |
1077 } | |
1078 | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1079 typedef struct ConvertEntry { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1080 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
|
1081 } ConvertEntry; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1082 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1083 /* add each new convertion function in this table */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1084 /* constraints; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1085 - 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
|
1086 */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1087 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
|
1088 [PIX_FMT_YUV420P] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1089 [PIX_FMT_RGB555] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1090 .convert = yuv420p_to_rgb555 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1091 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1092 [PIX_FMT_RGB565] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1093 .convert = yuv420p_to_rgb565 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1094 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1095 [PIX_FMT_BGR24] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1096 .convert = yuv420p_to_bgr24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1097 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1098 [PIX_FMT_RGB24] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1099 .convert = yuv420p_to_rgb24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1100 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1101 [PIX_FMT_RGBA32] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1102 .convert = yuv420p_to_rgba32 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1103 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1104 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1105 [PIX_FMT_YUV422P] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1106 [PIX_FMT_RGB555] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1107 .convert = yuv422p_to_rgb555 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1108 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1109 [PIX_FMT_RGB565] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1110 .convert = yuv422p_to_rgb565 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1111 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1112 [PIX_FMT_BGR24] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1113 .convert = yuv422p_to_bgr24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1114 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1115 [PIX_FMT_RGB24] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1116 .convert = yuv422p_to_rgb24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1117 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1118 [PIX_FMT_RGBA32] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1119 .convert = yuv422p_to_rgba32 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1120 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1121 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1122 [PIX_FMT_YUV422] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1123 [PIX_FMT_YUV420P] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1124 .convert = yuv422_to_yuv420p, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1125 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1126 }, |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1127 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1128 [PIX_FMT_RGB24] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1129 [PIX_FMT_YUV420P] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1130 .convert = rgb24_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1131 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1132 [PIX_FMT_RGB565] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1133 .convert = rgb24_to_rgb565 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1134 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1135 [PIX_FMT_RGB555] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1136 .convert = rgb24_to_rgb555 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1137 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1138 [PIX_FMT_GRAY8] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1139 .convert = rgb24_to_gray |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1140 }, |
1055 | 1141 [PIX_FMT_PAL8] = { |
1142 .convert = rgb24_to_pal8 | |
1143 }, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1144 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1145 [PIX_FMT_RGBA32] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1146 [PIX_FMT_YUV420P] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1147 .convert = rgba32_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1148 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1149 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1150 .convert = rgba32_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1151 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1152 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1153 [PIX_FMT_BGR24] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1154 [PIX_FMT_YUV420P] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1155 .convert = bgr24_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1156 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1157 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1158 .convert = bgr24_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1159 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1160 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1161 [PIX_FMT_RGB555] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1162 [PIX_FMT_YUV420P] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1163 .convert = rgb555_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1164 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1165 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1166 .convert = rgb555_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1167 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1168 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1169 [PIX_FMT_RGB565] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1170 [PIX_FMT_YUV420P] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1171 .convert = rgb565_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1172 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1173 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1174 .convert = rgb565_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1175 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1176 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1177 [PIX_FMT_GRAY8] = { |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1178 [PIX_FMT_RGB555] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1179 .convert = gray_to_rgb555 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1180 }, |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1181 [PIX_FMT_RGB565] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1182 .convert = gray_to_rgb565 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1183 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1184 [PIX_FMT_RGB24] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1185 .convert = gray_to_rgb24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1186 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1187 [PIX_FMT_BGR24] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1188 .convert = gray_to_bgr24 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1189 }, |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1190 [PIX_FMT_RGBA32] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1191 .convert = gray_to_rgba32 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1192 }, |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1193 [PIX_FMT_MONOWHITE] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1194 .convert = gray_to_monowhite |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1195 }, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1196 [PIX_FMT_MONOBLACK] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1197 .convert = gray_to_monoblack |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1198 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1199 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1200 [PIX_FMT_MONOWHITE] = { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1201 [PIX_FMT_GRAY8] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1202 .convert = monowhite_to_gray |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1203 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1204 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1205 [PIX_FMT_MONOBLACK] = { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1206 [PIX_FMT_GRAY8] = { |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
1207 .convert = monoblack_to_gray |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1208 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1209 }, |
1055 | 1210 [PIX_FMT_PAL8] = { |
1211 [PIX_FMT_RGB555] = { | |
1212 .convert = pal8_to_rgb555 | |
1213 }, | |
1214 [PIX_FMT_RGB565] = { | |
1215 .convert = pal8_to_rgb565 | |
1216 }, | |
1217 [PIX_FMT_BGR24] = { | |
1218 .convert = pal8_to_bgr24 | |
1219 }, | |
1220 [PIX_FMT_RGB24] = { | |
1221 .convert = pal8_to_rgb24 | |
1222 }, | |
1223 [PIX_FMT_RGBA32] = { | |
1224 .convert = pal8_to_rgba32 | |
1225 }, | |
1226 }, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1227 }; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1228 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1229 static int avpicture_alloc(AVPicture *picture, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1230 int pix_fmt, int width, int height) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1231 { |
1057 | 1232 unsigned int size; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1233 void *ptr; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1234 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1235 size = avpicture_get_size(pix_fmt, width, height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1236 if (size < 0) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1237 goto fail; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1238 ptr = av_malloc(size); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1239 if (!ptr) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1240 goto fail; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1241 avpicture_fill(picture, ptr, pix_fmt, width, height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1242 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1243 fail: |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1244 memset(picture, 0, sizeof(AVPicture)); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1245 return -1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1246 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1247 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1248 static void avpicture_free(AVPicture *picture) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1249 { |
1031
19de1445beb2
use av_malloc() functions - added av_strdup and av_realloc()
bellard
parents:
1028
diff
changeset
|
1250 av_free(picture->data[0]); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1251 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1252 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1253 /* 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
|
1254 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
|
1255 AVPicture *src, int src_pix_fmt, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1256 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
|
1257 { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1258 int i, ret, dst_width, dst_height, int_pix_fmt; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1259 PixFmtInfo *src_pix, *dst_pix; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1260 ConvertEntry *ce; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1261 AVPicture tmp1, *tmp = &tmp1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1262 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1263 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
|
1264 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
|
1265 return -1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1266 if (src_width <= 0 || src_height <= 0) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1267 return 0; |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1268 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1269 dst_width = src_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1270 dst_height = src_height; |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1271 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1272 dst_pix = &pix_fmt_info[dst_pix_fmt]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1273 src_pix = &pix_fmt_info[src_pix_fmt]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1274 if (src_pix_fmt == dst_pix_fmt) { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1275 /* XXX: incorrect */ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1276 /* same format: just copy */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1277 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
|
1278 int w, h; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1279 w = dst_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1280 h = dst_height; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1281 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
|
1282 w >>= dst_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1283 h >>= dst_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1284 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1285 img_copy(dst->data[i], dst->linesize[i], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1286 src->data[i], src->linesize[i], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1287 w, h); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1288 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1289 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1290 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1291 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1292 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
|
1293 if (ce->convert) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1294 /* specific convertion routine */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1295 ce->convert(dst, src, dst_width, dst_height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1296 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1297 } |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1298 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1299 /* gray to YUV */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1300 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
|
1301 int w, h, y; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1302 uint8_t *d; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1303 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1304 img_copy(dst->data[0], dst->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1305 src->data[0], src->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1306 dst_width, dst_height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1307 /* fill U and V with 128 */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1308 w = dst_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1309 h = dst_height; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1310 w >>= dst_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1311 h >>= dst_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1312 for(i = 1; i <= 2; i++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1313 d = dst->data[i]; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1314 for(y = 0; y< h; y++) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1315 memset(d, 128, w); |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1316 d += dst->linesize[i]; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1317 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1318 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1319 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1320 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1321 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1322 /* YUV to gray */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1323 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
|
1324 img_copy(dst->data[0], dst->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1325 src->data[0], src->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1326 dst_width, dst_height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1327 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1328 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1329 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1330 /* YUV to YUV */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1331 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
|
1332 int x_shift, y_shift, w, h; |
1064 | 1333 void (*resize_func)(uint8_t *dst, int dst_wrap, |
1334 uint8_t *src, int src_wrap, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1335 int width, int height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1336 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1337 /* compute chroma size of the smallest dimensions */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1338 w = dst_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1339 h = dst_height; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1340 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
|
1341 w >>= dst_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1342 else |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1343 w >>= src_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1344 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
|
1345 h >>= dst_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1346 else |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1347 h >>= src_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1348 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1349 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
|
1350 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
|
1351 if (x_shift == 0 && y_shift == 0) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1352 resize_func = img_copy; /* should never happen */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1353 } else if (x_shift == 0 && y_shift == 1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1354 resize_func = shrink2; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1355 } else if (x_shift == 1 && y_shift == 1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1356 resize_func = shrink22; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1357 } else if (x_shift == -1 && y_shift == -1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1358 resize_func = grow22; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1359 } else if (x_shift == -1 && y_shift == 1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1360 resize_func = conv411; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1361 } else { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1362 /* currently not handled */ |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1363 return -1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1364 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1365 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1366 img_copy(dst->data[0], dst->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1367 src->data[0], src->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1368 dst_width, dst_height); |
1023
e61be5796027
img_convert() (YUV to YUV) patch by (Max Krasnyansky <maxk at qualcomm dot com>)
michaelni
parents:
1022
diff
changeset
|
1369 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1370 for(i = 1;i <= 2; i++) |
1023
e61be5796027
img_convert() (YUV to YUV) patch by (Max Krasnyansky <maxk at qualcomm dot com>)
michaelni
parents:
1022
diff
changeset
|
1371 resize_func(dst->data[i], dst->linesize[i], |
e61be5796027
img_convert() (YUV to YUV) patch by (Max Krasnyansky <maxk at qualcomm dot com>)
michaelni
parents:
1022
diff
changeset
|
1372 src->data[i], src->linesize[i], |
1073 | 1373 dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift); |
1023
e61be5796027
img_convert() (YUV to YUV) patch by (Max Krasnyansky <maxk at qualcomm dot com>)
michaelni
parents:
1022
diff
changeset
|
1374 return 0; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1375 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1376 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1377 /* try to use an intermediate format */ |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1378 if (src_pix_fmt == PIX_FMT_MONOWHITE || |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1379 src_pix_fmt == PIX_FMT_MONOBLACK || |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1380 dst_pix_fmt == PIX_FMT_MONOWHITE || |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1381 dst_pix_fmt == PIX_FMT_MONOBLACK) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1382 int_pix_fmt = PIX_FMT_GRAY8; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1383 } else { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1384 int_pix_fmt = PIX_FMT_RGB24; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1385 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1386 if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1387 return -1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1388 ret = -1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1389 if (img_convert(tmp, int_pix_fmt, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1390 src, src_pix_fmt, src_width, src_height) < 0) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1391 goto fail1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1392 if (img_convert(dst, dst_pix_fmt, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1393 tmp, int_pix_fmt, dst_width, dst_height) < 0) |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1394 goto fail1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1395 ret = 0; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1396 fail1: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1397 avpicture_free(tmp); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1398 return ret; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1399 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1400 |
801 | 1401 |
1402 #ifdef HAVE_MMX | |
1403 #define DEINT_INPLACE_LINE_LUM \ | |
1404 movd_m2r(lum_m4[0],mm0);\ | |
1405 movd_m2r(lum_m3[0],mm1);\ | |
1406 movd_m2r(lum_m2[0],mm2);\ | |
1407 movd_m2r(lum_m1[0],mm3);\ | |
1408 movd_m2r(lum[0],mm4);\ | |
1409 punpcklbw_r2r(mm7,mm0);\ | |
1410 movd_r2m(mm2,lum_m4[0]);\ | |
1411 punpcklbw_r2r(mm7,mm1);\ | |
1412 punpcklbw_r2r(mm7,mm2);\ | |
1413 punpcklbw_r2r(mm7,mm3);\ | |
1414 punpcklbw_r2r(mm7,mm4);\ | |
1415 paddw_r2r(mm3,mm1);\ | |
1416 psllw_i2r(1,mm2);\ | |
1417 paddw_r2r(mm4,mm0);\ | |
1418 psllw_i2r(2,mm1);\ | |
1419 paddw_r2r(mm6,mm2);\ | |
1420 paddw_r2r(mm2,mm1);\ | |
1421 psubusw_r2r(mm0,mm1);\ | |
1422 psrlw_i2r(3,mm1);\ | |
1423 packuswb_r2r(mm7,mm1);\ | |
1424 movd_r2m(mm1,lum_m2[0]); | |
1425 | |
1426 #define DEINT_LINE_LUM \ | |
1427 movd_m2r(lum_m4[0],mm0);\ | |
1428 movd_m2r(lum_m3[0],mm1);\ | |
1429 movd_m2r(lum_m2[0],mm2);\ | |
1430 movd_m2r(lum_m1[0],mm3);\ | |
1431 movd_m2r(lum[0],mm4);\ | |
1432 punpcklbw_r2r(mm7,mm0);\ | |
1433 punpcklbw_r2r(mm7,mm1);\ | |
1434 punpcklbw_r2r(mm7,mm2);\ | |
1435 punpcklbw_r2r(mm7,mm3);\ | |
1436 punpcklbw_r2r(mm7,mm4);\ | |
1437 paddw_r2r(mm3,mm1);\ | |
1438 psllw_i2r(1,mm2);\ | |
1439 paddw_r2r(mm4,mm0);\ | |
1440 psllw_i2r(2,mm1);\ | |
1441 paddw_r2r(mm6,mm2);\ | |
1442 paddw_r2r(mm2,mm1);\ | |
1443 psubusw_r2r(mm0,mm1);\ | |
1444 psrlw_i2r(3,mm1);\ | |
1445 packuswb_r2r(mm7,mm1);\ | |
1446 movd_r2m(mm1,dst[0]); | |
1447 #endif | |
1448 | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1449 /* filter parameters: [-1 4 2 4 -1] // 8 */ |
1064 | 1450 static void deinterlace_line(uint8_t *dst, uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum, |
801 | 1451 int size) |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1452 { |
801 | 1453 #ifndef HAVE_MMX |
1064 | 1454 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1455 int sum; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1456 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1457 for(;size > 0;size--) { |
801 | 1458 sum = -lum_m4[0]; |
1459 sum += lum_m3[0] << 2; | |
1460 sum += lum_m2[0] << 1; | |
1461 sum += lum_m1[0] << 2; | |
1462 sum += -lum[0]; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1463 dst[0] = cm[(sum + 4) >> 3]; |
801 | 1464 lum_m4++; |
1465 lum_m3++; | |
1466 lum_m2++; | |
1467 lum_m1++; | |
1468 lum++; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1469 dst++; |
801 | 1470 } |
1471 #else | |
1472 | |
1044 | 1473 { |
1474 mmx_t rounder; | |
1475 rounder.uw[0]=4; | |
1476 rounder.uw[1]=4; | |
1477 rounder.uw[2]=4; | |
1478 rounder.uw[3]=4; | |
1479 pxor_r2r(mm7,mm7); | |
1480 movq_m2r(rounder,mm6); | |
1481 } | |
801 | 1482 for (;size > 3; size-=4) { |
1483 DEINT_LINE_LUM | |
1484 lum_m4+=4; | |
1485 lum_m3+=4; | |
1486 lum_m2+=4; | |
1487 lum_m1+=4; | |
1488 lum+=4; | |
1489 dst+=4; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1490 } |
801 | 1491 #endif |
1492 } | |
1064 | 1493 static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum, |
801 | 1494 int size) |
1495 { | |
1496 #ifndef HAVE_MMX | |
1064 | 1497 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
801 | 1498 int sum; |
1499 | |
1500 for(;size > 0;size--) { | |
1501 sum = -lum_m4[0]; | |
1502 sum += lum_m3[0] << 2; | |
1503 sum += lum_m2[0] << 1; | |
1504 lum_m4[0]=lum_m2[0]; | |
1505 sum += lum_m1[0] << 2; | |
1506 sum += -lum[0]; | |
1507 lum_m2[0] = cm[(sum + 4) >> 3]; | |
1508 lum_m4++; | |
1509 lum_m3++; | |
1510 lum_m2++; | |
1511 lum_m1++; | |
1512 lum++; | |
1513 } | |
1514 #else | |
1515 | |
1044 | 1516 { |
1517 mmx_t rounder; | |
1518 rounder.uw[0]=4; | |
1519 rounder.uw[1]=4; | |
1520 rounder.uw[2]=4; | |
1521 rounder.uw[3]=4; | |
1522 pxor_r2r(mm7,mm7); | |
1523 movq_m2r(rounder,mm6); | |
1524 } | |
801 | 1525 for (;size > 3; size-=4) { |
1526 DEINT_INPLACE_LINE_LUM | |
1527 lum_m4+=4; | |
1528 lum_m3+=4; | |
1529 lum_m2+=4; | |
1530 lum_m1+=4; | |
1531 lum+=4; | |
1532 } | |
1533 #endif | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1534 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1535 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1536 /* 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
|
1537 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
|
1538 against the top field. */ |
1064 | 1539 static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap, |
1540 uint8_t *src1, int src_wrap, | |
801 | 1541 int width, int height) |
1542 { | |
1064 | 1543 uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2; |
801 | 1544 int y; |
1545 | |
1546 src_m2 = src1; | |
1547 src_m1 = src1; | |
1548 src_0=&src_m1[src_wrap]; | |
1549 src_p1=&src_0[src_wrap]; | |
1550 src_p2=&src_p1[src_wrap]; | |
1551 for(y=0;y<(height-2);y+=2) { | |
1552 memcpy(dst,src_m1,width); | |
1553 dst += dst_wrap; | |
1554 deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width); | |
1555 src_m2 = src_0; | |
1556 src_m1 = src_p1; | |
1557 src_0 = src_p2; | |
1558 src_p1 += 2*src_wrap; | |
1559 src_p2 += 2*src_wrap; | |
1560 dst += dst_wrap; | |
1561 } | |
1562 memcpy(dst,src_m1,width); | |
1563 dst += dst_wrap; | |
1564 /* do last line */ | |
1565 deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width); | |
1566 } | |
1567 | |
1064 | 1568 static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap, |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1569 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1570 { |
1064 | 1571 uint8_t *src_m1, *src_0, *src_p1, *src_p2; |
801 | 1572 int y; |
1064 | 1573 uint8_t *buf; |
1574 buf = (uint8_t*)av_malloc(width); | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1575 |
801 | 1576 src_m1 = src1; |
1577 memcpy(buf,src_m1,width); | |
1578 src_0=&src_m1[src_wrap]; | |
1579 src_p1=&src_0[src_wrap]; | |
1580 src_p2=&src_p1[src_wrap]; | |
1581 for(y=0;y<(height-2);y+=2) { | |
1582 deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width); | |
1583 src_m1 = src_p1; | |
1584 src_0 = src_p2; | |
1585 src_p1 += 2*src_wrap; | |
1586 src_p2 += 2*src_wrap; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1587 } |
801 | 1588 /* do last line */ |
1589 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
|
1590 av_free(buf); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1591 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1592 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1593 |
801 | 1594 /* 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
|
1595 int avpicture_deinterlace(AVPicture *dst, AVPicture *src, |
0 | 1596 int pix_fmt, int width, int height) |
1597 { | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1598 int i; |
0 | 1599 |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1600 if (pix_fmt != PIX_FMT_YUV420P && |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1601 pix_fmt != PIX_FMT_YUV422P && |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1602 pix_fmt != PIX_FMT_YUV444P) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1603 return -1; |
801 | 1604 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
|
1605 return -1; |
801 | 1606 |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1607 for(i=0;i<3;i++) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1608 if (i == 1) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1609 switch(pix_fmt) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1610 case PIX_FMT_YUV420P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1611 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1612 height >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1613 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1614 case PIX_FMT_YUV422P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1615 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1616 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1617 default: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1618 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1619 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1620 } |
801 | 1621 if (src == dst) { |
1622 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
|
1623 width, height); |
801 | 1624 } else { |
1625 deinterlace_bottom_field(dst->data[i],dst->linesize[i], | |
1626 src->data[i], src->linesize[i], | |
1627 width, height); | |
1628 } | |
0 | 1629 } |
801 | 1630 #ifdef HAVE_MMX |
1631 emms(); | |
1632 #endif | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1633 return 0; |
0 | 1634 } |
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
1635 |
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
1636 #undef FIX |