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