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