Mercurial > libavcodec.hg
annotate imgconvert.c @ 1202:8b49a7ee4e4e libavcodec
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
author | bellard |
---|---|
date | Sun, 20 Apr 2003 16:18:44 +0000 |
parents | 6b566c5d02e4 |
children | 80c73b9b0ba2 |
rev | line source |
---|---|
0 | 1 /* |
2 * Misc image convertion routines | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
3 * Copyright (c) 2001, 2002, 2003 Fabrice Bellard. |
0 | 4 * |
429 | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
0 | 9 * |
429 | 10 * This library is distributed in the hope that it will be useful, |
0 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Lesser General Public License for more details. | |
0 | 14 * |
429 | 15 * You should have received a copy of the GNU Lesser General Public |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
0 | 18 */ |
1106 | 19 |
20 /** | |
1108 | 21 * @file imgconvert.c |
1106 | 22 * Misc image convertion routines. |
23 */ | |
24 | |
25 | |
0 | 26 #include "avcodec.h" |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
27 #include "dsputil.h" |
0 | 28 |
17 | 29 #ifdef USE_FASTMEMCPY |
30 #include "fastmemcpy.h" | |
31 #endif | |
801 | 32 |
33 #ifdef HAVE_MMX | |
34 #include "i386/mmx.h" | |
35 #endif | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
36 |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
37 #define FF_COLOR_RGB 0 /* RGB color space */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
38 #define FF_COLOR_GRAY 1 /* gray color space */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
39 #define FF_COLOR_YUV 2 /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
40 #define FF_COLOR_YUV_JPEG 3 /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
41 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
42 typedef struct PixFmtInfo { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
43 const char *name; |
1064 | 44 uint8_t nb_components; /* number of components in AVPicture array */ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
45 uint8_t color_type; /* color type (see FF_COLOR_xxx constants) */ |
1064 | 46 uint8_t is_packed : 1; /* true if multiple components in same word */ |
47 uint8_t is_paletted : 1; /* true if paletted */ | |
48 uint8_t is_alpha : 1; /* true if alpha can be specified */ | |
49 uint8_t x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */ | |
50 uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */ | |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
51 uint8_t depth; /* bit depth of the color components */ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
52 } PixFmtInfo; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
53 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
54 /* this table gives more information about formats */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
55 static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
56 /* YUV formats */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
57 [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
|
58 .name = "yuv420p", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
59 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
60 .color_type = FF_COLOR_YUV, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
61 .depth = 8, |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
62 .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
|
63 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
64 [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
|
65 .name = "yuv422p", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
66 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
67 .color_type = FF_COLOR_YUV, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
68 .depth = 8, |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
69 .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
|
70 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
71 [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
|
72 .name = "yuv444p", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
73 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
74 .color_type = FF_COLOR_YUV, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
75 .depth = 8, |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
76 .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
|
77 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
78 [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
|
79 .name = "yuv422", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
80 .nb_components = 1, .is_packed = 1, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
81 .color_type = FF_COLOR_YUV, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
82 .depth = 8, |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
83 .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
|
84 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
85 [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
|
86 .name = "yuv410p", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
87 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
88 .color_type = FF_COLOR_YUV, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
89 .depth = 8, |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
90 .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
|
91 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
92 [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
|
93 .name = "yuv411p", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
94 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
95 .color_type = FF_COLOR_YUV, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
96 .depth = 8, |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
97 .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
|
98 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
99 |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
100 /* JPEG YUV */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
101 [PIX_FMT_YUVJ420P] = { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
102 .name = "yuvj420p", |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
103 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
104 .color_type = FF_COLOR_YUV_JPEG, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
105 .depth = 8, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
106 .x_chroma_shift = 1, .y_chroma_shift = 1, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
107 }, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
108 [PIX_FMT_YUVJ422P] = { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
109 .name = "yuvj422p", |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
110 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
111 .color_type = FF_COLOR_YUV_JPEG, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
112 .depth = 8, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
113 .x_chroma_shift = 1, .y_chroma_shift = 0, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
114 }, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
115 [PIX_FMT_YUVJ444P] = { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
116 .name = "yuvj444p", |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
117 .nb_components = 3, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
118 .color_type = FF_COLOR_YUV_JPEG, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
119 .depth = 8, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
120 .x_chroma_shift = 0, .y_chroma_shift = 0, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
121 }, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
122 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
123 /* RGB formats */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
124 [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
|
125 .name = "rgb24", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
126 .nb_components = 1, .is_packed = 1, |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
127 .color_type = FF_COLOR_RGB, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
128 .depth = 8, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
129 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
130 [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
|
131 .name = "bgr24", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
132 .nb_components = 1, .is_packed = 1, |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
133 .color_type = FF_COLOR_RGB, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
134 .depth = 8, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
135 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
136 [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
|
137 .name = "rgba32", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
138 .nb_components = 1, .is_packed = 1, .is_alpha = 1, |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
139 .color_type = FF_COLOR_RGB, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
140 .depth = 8, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
141 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
142 [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
|
143 .name = "rgb565", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
144 .nb_components = 1, .is_packed = 1, |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
145 .color_type = FF_COLOR_RGB, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
146 .depth = 5, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
147 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
148 [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
|
149 .name = "rgb555", |
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (Mns Rullgrd))
michaelni
parents:
993
diff
changeset
|
150 .nb_components = 1, .is_packed = 1, .is_alpha = 1, |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
151 .color_type = FF_COLOR_RGB, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
152 .depth = 5, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
153 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
154 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
155 /* gray / mono formats */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
156 [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
|
157 .name = "gray", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
158 .nb_components = 1, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
159 .color_type = FF_COLOR_GRAY, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
160 .depth = 8, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
161 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
162 [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
|
163 .name = "monow", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
164 .nb_components = 1, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
165 .color_type = FF_COLOR_GRAY, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
166 .depth = 1, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
167 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
168 [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
|
169 .name = "monob", |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
170 .nb_components = 1, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
171 .color_type = FF_COLOR_GRAY, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
172 .depth = 1, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
173 }, |
1055 | 174 |
175 /* paletted formats */ | |
176 [PIX_FMT_PAL8] = { | |
177 .name = "pal8", | |
1199 | 178 .nb_components = 1, .is_packed = 1, .is_alpha = 1, .is_paletted = 1, |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
179 .color_type = FF_COLOR_RGB, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
180 .depth = 8, |
1055 | 181 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
182 }; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
183 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
184 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
|
185 { |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
186 *h_shift = pix_fmt_info[pix_fmt].x_chroma_shift; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
187 *v_shift = pix_fmt_info[pix_fmt].y_chroma_shift; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
188 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
189 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
190 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
|
191 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
192 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
|
193 return "???"; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
194 else |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
195 return pix_fmt_info[pix_fmt].name; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
196 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
197 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
198 /* Picture field are filled with 'ptr' addresses. Also return size */ |
1064 | 199 int avpicture_fill(AVPicture *picture, uint8_t *ptr, |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
200 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
|
201 { |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
202 int size, w2, h2, size2; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
203 PixFmtInfo *pinfo; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
204 |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
205 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
|
206 size = width * height; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
207 switch(pix_fmt) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
208 case PIX_FMT_YUV420P: |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
209 case PIX_FMT_YUV422P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
210 case PIX_FMT_YUV444P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
211 case PIX_FMT_YUV410P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
212 case PIX_FMT_YUV411P: |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 picture->linesize[0] = width; |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
220 picture->linesize[1] = w2; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
221 picture->linesize[2] = w2; |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 return size * 3; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 return size * 4; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 return size * 2; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 return size; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 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
|
256 return picture->linesize[0] * height; |
1055 | 257 case PIX_FMT_PAL8: |
258 size2 = (size + 3) & ~3; | |
259 picture->data[0] = ptr; | |
260 picture->data[1] = ptr + size2; /* palette is stored here as 256 32 bit words */ | |
261 picture->data[2] = NULL; | |
262 picture->linesize[0] = width; | |
263 picture->linesize[1] = 4; | |
264 return size2 + 256 * 4; | |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
265 default: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
266 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
|
267 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
|
268 picture->data[2] = NULL; |
1055 | 269 picture->data[3] = NULL; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
270 return -1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
271 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
272 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
273 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
274 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
|
275 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
276 AVPicture dummy_pict; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
277 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
|
278 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
279 |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
280 /** |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
281 * compute the loss when converting from a pixel format to another |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
282 */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
283 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
284 int has_alpha) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
285 { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
286 const PixFmtInfo *pf, *ps; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
287 int loss; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
288 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
289 ps = &pix_fmt_info[src_pix_fmt]; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
290 pf = &pix_fmt_info[dst_pix_fmt]; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
291 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
292 /* compute loss */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
293 loss = 0; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
294 pf = &pix_fmt_info[dst_pix_fmt]; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
295 if (pf->depth < ps->depth) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
296 loss |= FF_LOSS_DEPTH; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
297 if (pf->x_chroma_shift >= ps->x_chroma_shift || |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
298 pf->y_chroma_shift >= ps->y_chroma_shift) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
299 loss |= FF_LOSS_RESOLUTION; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
300 switch(pf->color_type) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
301 case FF_COLOR_RGB: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
302 if (ps->color_type != FF_COLOR_RGB && |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
303 ps->color_type != FF_COLOR_GRAY) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
304 loss |= FF_LOSS_COLORSPACE; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
305 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
306 case FF_COLOR_GRAY: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
307 if (ps->color_type != FF_COLOR_GRAY) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
308 loss |= FF_LOSS_COLORSPACE; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
309 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
310 case FF_COLOR_YUV: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
311 if (ps->color_type != FF_COLOR_YUV) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
312 loss |= FF_LOSS_COLORSPACE; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
313 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
314 case FF_COLOR_YUV_JPEG: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
315 if (ps->color_type != FF_COLOR_YUV_JPEG && |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
316 ps->color_type != FF_COLOR_YUV) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
317 loss |= FF_LOSS_COLORSPACE; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
318 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
319 default: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
320 /* fail safe test */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
321 if (ps->color_type != pf->color_type) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
322 loss |= FF_LOSS_COLORSPACE; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
323 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
324 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
325 if (pf->color_type == FF_COLOR_GRAY && |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
326 ps->color_type != FF_COLOR_GRAY) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
327 loss |= FF_LOSS_CHROMA; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
328 if (!pf->is_alpha && (ps->is_alpha && has_alpha)) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
329 loss |= FF_LOSS_ALPHA; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
330 if (pf->is_paletted && (!ps->is_paletted && ps->color_type != FF_COLOR_GRAY)) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
331 loss |= FF_LOSS_COLORQUANT; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
332 return loss; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
333 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
334 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
335 static int avg_bits_per_pixel(int pix_fmt) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
336 { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
337 int bits; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
338 const PixFmtInfo *pf; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
339 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
340 pf = &pix_fmt_info[pix_fmt]; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
341 if (pf->is_packed) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
342 switch(pix_fmt) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
343 case PIX_FMT_RGB24: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
344 case PIX_FMT_BGR24: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
345 bits = 24; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
346 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
347 case PIX_FMT_RGBA32: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
348 bits = 32; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
349 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
350 case PIX_FMT_RGB565: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
351 case PIX_FMT_RGB555: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
352 bits = 16; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
353 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
354 case PIX_FMT_PAL8: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
355 bits = 8; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
356 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
357 default: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
358 bits = 32; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
359 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
360 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
361 } else { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
362 bits = pf->depth; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
363 bits += (2 * pf->depth >> |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
364 (pf->x_chroma_shift + pf->x_chroma_shift)); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
365 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
366 return bits; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
367 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
368 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
369 static int avcodec_find_best_pix_fmt1(int pix_fmt_mask, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
370 int src_pix_fmt, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
371 int has_alpha, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
372 int loss_mask) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
373 { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
374 int dist, i, loss, min_dist, dst_pix_fmt; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
375 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
376 /* find exact color match with smallest size */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
377 dst_pix_fmt = -1; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
378 min_dist = 0x7fffffff; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
379 for(i = 0;i < PIX_FMT_NB; i++) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
380 if (pix_fmt_mask & (1 << i)) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
381 loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
382 if (loss == 0) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
383 dist = avg_bits_per_pixel(i); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
384 if (dist < min_dist) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
385 min_dist = dist; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
386 dst_pix_fmt = i; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
387 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
388 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
389 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
390 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
391 return dst_pix_fmt; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
392 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
393 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
394 /** |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
395 * find best pixel format to convert to. Return -1 if none found |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
396 */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
397 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
398 int has_alpha, int *loss_ptr) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
399 { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
400 int dst_pix_fmt, loss_mask, i; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
401 static const int loss_mask_order[] = { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
402 ~0, /* no loss first */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
403 ~FF_LOSS_ALPHA, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
404 ~FF_LOSS_RESOLUTION, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
405 ~(FF_LOSS_COLORSPACE | FF_LOSS_RESOLUTION), |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
406 ~FF_LOSS_COLORQUANT, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
407 ~FF_LOSS_DEPTH, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
408 0, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
409 }; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
410 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
411 /* try with successive loss */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
412 i = 0; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
413 for(;;) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
414 loss_mask = loss_mask_order[i++]; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
415 dst_pix_fmt = avcodec_find_best_pix_fmt1(pix_fmt_mask, src_pix_fmt, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
416 has_alpha, loss_mask); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
417 if (dst_pix_fmt >= 0) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
418 goto found; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
419 if (loss_mask == 0) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
420 break; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
421 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
422 return -1; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
423 found: |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
424 if (loss_ptr) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
425 *loss_ptr = avcodec_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
426 return dst_pix_fmt; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
427 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
428 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
429 |
0 | 430 /* XXX: totally non optimized */ |
431 | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
432 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
|
433 int width, int height) |
0 | 434 { |
1064 | 435 uint8_t *lum, *cb, *cr; |
0 | 436 int x, y; |
1064 | 437 const uint8_t *p; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
438 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
439 lum = dst->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
440 cb = dst->data[1]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
441 cr = dst->data[2]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
442 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
443 |
0 | 444 for(y=0;y<height;y+=2) { |
445 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
|
446 lum[0] = p[0]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
447 cb[0] = p[1]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
448 lum[1] = p[2]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
449 cr[0] = p[3]; |
0 | 450 p += 4; |
451 lum += 2; | |
452 cb++; | |
453 cr++; | |
454 } | |
455 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
|
456 lum[0] = p[0]; |
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
457 lum[1] = p[2]; |
0 | 458 p += 4; |
459 lum += 2; | |
460 } | |
461 } | |
462 } | |
463 | |
464 #define SCALEBITS 8 | |
465 #define ONE_HALF (1 << (SCALEBITS - 1)) | |
466 #define FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) | |
467 | |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
468 #define SCALE_BITS 10 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
469 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
470 #define C_Y (76309 >> (16 - SCALE_BITS)) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
471 #define C_RV (117504 >> (16 - SCALE_BITS)) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
472 #define C_BU (138453 >> (16 - SCALE_BITS)) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
473 #define C_GU (13954 >> (16 - SCALE_BITS)) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
474 #define C_GV (34903 >> (16 - SCALE_BITS)) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
475 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
476 #define YUV_TO_RGB2(r, g, b, y1)\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
477 {\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
478 y = (y1 - 16) * C_Y;\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
479 r = cm[(y + r_add) >> SCALE_BITS];\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
480 g = cm[(y + g_add) >> SCALE_BITS];\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
481 b = cm[(y + b_add) >> SCALE_BITS];\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
482 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
483 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
484 /* XXX: use a table ? */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
485 #define CCIR_TO_GRAY(y)\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
486 cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS] |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
487 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
488 #define GRAY_TO_CCIR(y)\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
489 (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
490 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
491 #define RGB_TO_Y(r, g, b) \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
492 ((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
493 FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
494 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
495 #define RGB4_TO_U(r1, g1, b1)\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
496 (((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
497 FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
498 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
499 #define RGB4_TO_V(r1, g1, b1)\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
500 (((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
501 FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
502 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
503 #define RGB_TO_Y_CCIR(r, g, b) \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
504 ((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
505 FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
506 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
507 #define RGB4_TO_U_CCIR(r1, g1, b1)\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
508 (((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
509 FIX(0.50000*224.0/255.0) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
510 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
511 #define RGB4_TO_V_CCIR(r1, g1, b1)\ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
512 (((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
513 FIX(0.08131*224.0/255.0) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) + 128) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
514 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
515 /* convert from CCIR luma (16 <= Y <= 235) to full scale gray (0 <= Y <= 255) */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
516 static void luma_ccir_to_gray(uint8_t *dst, int dst_wrap, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
517 uint8_t *src, int src_wrap, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
518 int width, int height) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
519 { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
520 int n; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
521 const uint8_t *s; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
522 uint8_t *d; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
523 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
524 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
525 for(;height > 0; height--) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
526 s = src; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
527 d = dst; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
528 n = width; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
529 while (n >= 4) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
530 d[0] = CCIR_TO_GRAY(s[0]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
531 d[1] = CCIR_TO_GRAY(s[1]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
532 d[2] = CCIR_TO_GRAY(s[2]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
533 d[3] = CCIR_TO_GRAY(s[3]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
534 d += 4; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
535 s += 4; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
536 n -= 4; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
537 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
538 while (n > 0) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
539 d[0] = CCIR_TO_GRAY(s[0]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
540 d++; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
541 s++; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
542 n--; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
543 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
544 dst += dst_wrap; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
545 src += src_wrap; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
546 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
547 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
548 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
549 /* convert from full scale gray (0 <= Y <= 255) to CCIR luma (16 <= Y <= 235) */ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
550 static void gray_to_luma_ccir(uint8_t *dst, int dst_wrap, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
551 uint8_t *src, int src_wrap, |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
552 int width, int height) |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
553 { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
554 int n; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
555 const uint8_t *s; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
556 uint8_t *d; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
557 |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
558 for(;height > 0; height--) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
559 s = src; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
560 d = dst; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
561 n = width; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
562 while (n >= 4) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
563 d[0] = GRAY_TO_CCIR(s[0]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
564 d[1] = GRAY_TO_CCIR(s[1]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
565 d[2] = GRAY_TO_CCIR(s[2]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
566 d[3] = GRAY_TO_CCIR(s[3]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
567 d += 4; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
568 s += 4; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
569 n -= 4; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
570 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
571 while (n > 0) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
572 d[0] = GRAY_TO_CCIR(s[0]); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
573 d++; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
574 s++; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
575 n--; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
576 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
577 dst += dst_wrap; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
578 src += src_wrap; |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
579 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
580 } |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
581 |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
582 /* XXX: use generic filter ? */ |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
583 /* 1x2 -> 1x1 */ |
1064 | 584 static void shrink2(uint8_t *dst, int dst_wrap, |
585 uint8_t *src, int src_wrap, | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
586 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
587 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
588 int w; |
1064 | 589 uint8_t *s1, *s2, *d; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
590 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
591 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
592 s1 = src; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
593 s2 = s1 + src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
594 d = dst; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
595 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
|
596 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
|
597 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
|
598 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
|
599 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
|
600 s1 += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
601 s2 += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
602 d += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
603 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
604 for(;w > 0; w--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
605 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
|
606 s1++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
607 s2++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
608 d++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
609 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
610 src += 2 * src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
611 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
612 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
613 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
614 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
615 /* 2x2 -> 1x1 */ |
1064 | 616 static void shrink22(uint8_t *dst, int dst_wrap, |
617 uint8_t *src, int src_wrap, | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
618 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
619 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
620 int w; |
1064 | 621 uint8_t *s1, *s2, *d; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
622 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
623 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
624 s1 = src; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
625 s2 = s1 + src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
626 d = dst; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
627 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
|
628 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
|
629 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
|
630 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
|
631 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
|
632 s1 += 8; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
633 s2 += 8; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
634 d += 4; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
635 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
636 for(;w > 0; w--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
637 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
|
638 s1 += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
639 s2 += 2; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
640 d++; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
641 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
642 src += 2 * src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
643 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
644 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
645 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
646 |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
647 /* 1x1 -> 2x2 */ |
1064 | 648 static void grow22(uint8_t *dst, int dst_wrap, |
649 uint8_t *src, int src_wrap, | |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
650 int width, int height) |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
651 { |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
652 int w; |
1064 | 653 uint8_t *s1, *d; |
576
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
654 |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
655 for(;height > 0; height--) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
656 s1 = src; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
657 d = dst; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
658 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
|
659 d[1] = d[0] = s1[0]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
660 d[3] = d[2] = s1[1]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
661 s1 += 2; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
662 d += 4; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
663 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
664 for(;w > 0; w--) { |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
665 d[0] = s1[0]; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
666 s1 ++; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
667 d++; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
668 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
669 if (height%2) |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
670 src += src_wrap; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
671 dst += dst_wrap; |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
672 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
673 } |
9aa5f0d0124e
YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
674 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
675 /* 1x2 -> 2x1 */ |
1064 | 676 static void conv411(uint8_t *dst, int dst_wrap, |
677 uint8_t *src, int src_wrap, | |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
678 int width, int height) |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
679 { |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
680 int w, c; |
1064 | 681 uint8_t *s1, *s2, *d; |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
682 |
1166 | 683 width>>=1; |
684 | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
685 for(;height > 0; height--) { |
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
686 s1 = src; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
687 s2 = src + src_wrap; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
688 d = dst; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
689 for(w = width;w > 0; w--) { |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
690 c = (s1[0] + s2[0]) >> 1; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
691 d[0] = c; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
692 d[1] = c; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
693 s1++; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
694 s2++; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
695 d += 2; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
696 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
697 src += src_wrap * 2; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
698 dst += dst_wrap; |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
699 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
700 } |
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
701 |
1064 | 702 static void img_copy(uint8_t *dst, int dst_wrap, |
703 uint8_t *src, int src_wrap, | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
704 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
705 { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
706 for(;height > 0; height--) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
707 memcpy(dst, src, width); |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
708 dst += dst_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
709 src += src_wrap; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
710 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
711 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
712 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
713 /* XXX: no chroma interpolating is done */ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
714 #define RGB_FUNCTIONS(rgb_name) \ |
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 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
|
717 int width, int height) \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
718 { \ |
1064 | 719 uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *d, *d1, *d2; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
720 int w, y, cb, cr, r_add, g_add, b_add, width2; \ |
1064 | 721 uint8_t *cm = cropTbl + MAX_NEG_CROP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
722 unsigned int 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 d = dst->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
725 y1_ptr = src->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
726 cb_ptr = src->data[1]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
727 cr_ptr = src->data[2]; \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
728 width2 = (width + 1) >> 1; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
729 for(;height >= 2; height -= 2) { \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
730 d1 = d; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
731 d2 = d + dst->linesize[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
732 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
|
733 for(w = width; w >= 2; w -= 2) { \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
734 cb = cb_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
735 cr = cr_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
736 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
|
737 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
|
738 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
|
739 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
740 /* output 4 pixels */ \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
741 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
|
742 RGB_OUT(d1, r, g, b); \ |
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 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
|
745 RGB_OUT(d1 + BPP, r, g, b); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
746 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
747 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
|
748 RGB_OUT(d2, r, g, b); \ |
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 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
|
751 RGB_OUT(d2 + BPP, r, g, b); \ |
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 d1 += 2 * BPP; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
754 d2 += 2 * BPP; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
755 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
756 y1_ptr += 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
757 y2_ptr += 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
758 cb_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
759 cr_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
760 } \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
761 /* handle odd width */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
762 if (w) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
763 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
764 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
765 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
|
766 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
|
767 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
|
768 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
769 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
|
770 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
771 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
772 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
|
773 RGB_OUT(d2, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
774 d1 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
775 d2 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
776 y1_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
777 y2_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
778 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
779 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
780 } \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
781 d += 2 * dst->linesize[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
782 y1_ptr += 2 * src->linesize[0] - width; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
783 cb_ptr += src->linesize[1] - width2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
784 cr_ptr += src->linesize[2] - width2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
785 } \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
786 /* handle odd height */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
787 if (height) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
788 d1 = d; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
789 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
|
790 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
791 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
792 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
|
793 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
|
794 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
|
795 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
796 /* output 2 pixels */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
797 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
|
798 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
799 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
800 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
|
801 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
|
802 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
803 d1 += 2 * BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
804 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
805 y1_ptr += 2; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
806 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
807 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
808 } \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
809 /* handle width */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
810 if (w) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
811 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
812 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
813 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
|
814 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
|
815 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
|
816 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
817 /* output 2 pixels */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
818 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
|
819 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
820 d1 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
821 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
822 y1_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
823 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
824 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
825 } \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
826 } \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
827 } \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
828 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
829 /* XXX: no chroma interpolating is done */ \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
830 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
|
831 int width, int height) \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
832 { \ |
1064 | 833 uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *d, *d1; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
834 int w, y, cb, cr, r_add, g_add, b_add, width2; \ |
1064 | 835 uint8_t *cm = cropTbl + MAX_NEG_CROP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
836 unsigned int r, g, b; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
837 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
838 d = dst->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
839 y1_ptr = src->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
840 cb_ptr = src->data[1]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
841 cr_ptr = src->data[2]; \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
842 width2 = (width + 1) >> 1; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
843 for(;height > 0; height --) { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
844 d1 = d; \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
845 for(w = width; w >= 2; w -= 2) { \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
846 cb = cb_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
847 cr = cr_ptr[0] - 128; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
848 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
|
849 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
|
850 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
|
851 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
852 /* output 2 pixels */ \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
853 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
|
854 RGB_OUT(d1, r, g, b); \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
855 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
856 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
|
857 RGB_OUT(d1 + BPP, r, g, b); \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
858 \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
859 d1 += 2 * BPP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
860 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
861 y1_ptr += 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
862 cb_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
863 cr_ptr++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
864 } \ |
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
865 /* handle width */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
866 if (w) { \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
867 cb = cb_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
868 cr = cr_ptr[0] - 128; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
869 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
|
870 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
|
871 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
|
872 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
873 /* output 2 pixels */ \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
874 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
|
875 RGB_OUT(d1, r, g, b); \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
876 d1 += BPP; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
877 \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
878 y1_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
879 cb_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
880 cr_ptr++; \ |
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
881 } \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
882 d += dst->linesize[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
883 y1_ptr += src->linesize[0] - width; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
884 cb_ptr += src->linesize[1] - width2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
885 cr_ptr += src->linesize[2] - width2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
886 } \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
887 } \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
888 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
889 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
|
890 int width, int height) \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
891 { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
892 int wrap, wrap3, x, y; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
893 int r, g, b, r1, g1, b1; \ |
1064 | 894 uint8_t *lum, *cb, *cr; \ |
895 const uint8_t *p; \ | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
896 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
897 lum = dst->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
898 cb = dst->data[1]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
899 cr = dst->data[2]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
900 \ |
1052
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
901 wrap = dst->linesize[0]; \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
902 wrap3 = src->linesize[0]; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
903 p = src->data[0]; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
904 for(y=0;y<height;y+=2) { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
905 for(x=0;x<width;x+=2) { \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
906 RGB_IN(r, g, b, p); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
907 r1 = r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
908 g1 = g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
909 b1 = b; \ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
910 lum[0] = RGB_TO_Y_CCIR(r, g, b); \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
911 \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
912 RGB_IN(r, g, b, p + BPP); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
913 r1 += r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
914 g1 += g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
915 b1 += b; \ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
916 lum[1] = RGB_TO_Y_CCIR(r, g, b); \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
917 p += wrap3; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
918 lum += wrap; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
919 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
920 RGB_IN(r, g, b, p); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
921 r1 += r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
922 g1 += g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
923 b1 += b; \ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
924 lum[0] = RGB_TO_Y_CCIR(r, g, b); \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
925 \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
926 RGB_IN(r, g, b, p + BPP); \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
927 r1 += r; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
928 g1 += g; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
929 b1 += b; \ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
930 lum[1] = RGB_TO_Y_CCIR(r, g, b); \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
931 \ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
932 cb[0] = RGB4_TO_U_CCIR(r1, g1, b1); \ |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
933 cr[0] = RGB4_TO_V_CCIR(r1, g1, b1); \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
934 \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
935 cb++; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
936 cr++; \ |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
937 p += -wrap3 + 2 * BPP; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
938 lum += -wrap + 2; \ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
939 } \ |
1052
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
940 p += wrap3 + (wrap3 - width * BPP); \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
941 lum += wrap + (wrap - width); \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
942 cb += dst->linesize[1] - width / 2; \ |
f529b09e64b7
Fix a bug in the conversion of rgba32->yuv420p. This resulted in garbage images
philipjsg
parents:
1047
diff
changeset
|
943 cr += dst->linesize[2] - width / 2; \ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
944 } \ |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
945 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
946 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
947 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
|
948 int width, int height) \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
949 { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
950 const unsigned char *p; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
951 unsigned char *q; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
952 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
|
953 int x, y; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
954 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
955 p = src->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
956 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
|
957 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
958 q = dst->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
959 dst_wrap = dst->linesize[0] - width; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
960 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
961 for(y=0;y<height;y++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
962 for(x=0;x<width;x++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
963 RGB_IN(r, g, b, p); \ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
964 q[0] = RGB_TO_Y(r, g, b); \ |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
965 q++; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
966 p += BPP; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
967 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
968 p += src_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
969 q += dst_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
970 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
971 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
972 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
973 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
|
974 int width, int height) \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
975 { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
976 const unsigned char *p; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
977 unsigned char *q; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
978 int r, dst_wrap, src_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
979 int x, y; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
980 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
981 p = src->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
982 src_wrap = src->linesize[0] - width; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
983 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
984 q = dst->data[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
985 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
|
986 \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
987 for(y=0;y<height;y++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
988 for(x=0;x<width;x++) { \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
989 r = p[0]; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
990 RGB_OUT(q, r, r, r); \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
991 q += BPP; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
992 p ++; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
993 } \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
994 p += src_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
995 q += dst_wrap; \ |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
996 } \ |
1055 | 997 } \ |
998 \ | |
999 static void pal8_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \ | |
1000 int width, int height) \ | |
1001 { \ | |
1002 const unsigned char *p; \ | |
1003 unsigned char *q; \ | |
1004 int r, g, b, dst_wrap, src_wrap; \ | |
1005 int x, y; \ | |
1006 uint32_t v;\ | |
1007 const uint32_t *palette;\ | |
1008 \ | |
1009 p = src->data[0]; \ | |
1010 src_wrap = src->linesize[0] - width; \ | |
1011 palette = (uint32_t *)src->data[1];\ | |
1012 \ | |
1013 q = dst->data[0]; \ | |
1014 dst_wrap = dst->linesize[0] - BPP * width; \ | |
1015 \ | |
1016 for(y=0;y<height;y++) { \ | |
1017 for(x=0;x<width;x++) { \ | |
1018 v = palette[p[0]];\ | |
1019 r = (v >> 16) & 0xff;\ | |
1020 g = (v >> 8) & 0xff;\ | |
1021 b = (v) & 0xff;\ | |
1022 RGB_OUT(q, r, g, b); \ | |
1023 q += BPP; \ | |
1024 p ++; \ | |
1025 } \ | |
1026 p += src_wrap; \ | |
1027 q += dst_wrap; \ | |
1028 } \ | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1029 } |
583 | 1030 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1031 /* copy bit n to bits 0 ... n - 1 */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1032 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
|
1033 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1034 int mask; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1035 mask = (1 << n) - 1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1036 return (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1037 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1038 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1039 /* rgb555 handling */ |
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 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1042 {\ |
1064 | 1043 unsigned int v = ((const uint16_t *)(s))[0];\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1044 r = bitcopy_n(v >> (10 - 3), 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1045 g = bitcopy_n(v >> (5 - 3), 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1046 b = bitcopy_n(v << 3, 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1047 } |
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 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1050 {\ |
1064 | 1051 ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | 0x8000;\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1052 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1053 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1054 #define BPP 2 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1055 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1056 RGB_FUNCTIONS(rgb555) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1057 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1058 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1059 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1060 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1061 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1062 /* rgb565 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1063 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1064 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1065 {\ |
1064 | 1066 unsigned int v = ((const uint16_t *)(s))[0];\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1067 r = bitcopy_n(v >> (11 - 3), 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1068 g = bitcopy_n(v >> (5 - 2), 2);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1069 b = bitcopy_n(v << 3, 3);\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1070 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1071 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1072 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1073 {\ |
1064 | 1074 ((uint16_t *)(d))[0] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1075 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1076 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1077 #define BPP 2 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1078 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1079 RGB_FUNCTIONS(rgb565) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1080 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1081 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1082 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1083 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1084 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1085 /* bgr24 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1086 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1087 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1088 {\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1089 b = (s)[0];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1090 g = (s)[1];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1091 r = (s)[2];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1092 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1093 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1094 #define RGB_OUT(d, r, g, b)\ |
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 (d)[0] = b;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1097 (d)[1] = g;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1098 (d)[2] = r;\ |
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 #define BPP 3 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1102 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1103 RGB_FUNCTIONS(bgr24) |
583 | 1104 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1105 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1106 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1107 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1108 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1109 /* rgb24 handling */ |
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 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1112 {\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1113 r = (s)[0];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1114 g = (s)[1];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1115 b = (s)[2];\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1116 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1117 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1118 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1119 {\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1120 (d)[0] = r;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1121 (d)[1] = g;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1122 (d)[2] = b;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1123 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1124 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1125 #define BPP 3 |
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 RGB_FUNCTIONS(rgb24) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1128 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1129 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1130 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1131 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1132 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1133 /* rgba32 handling */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1134 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1135 #define RGB_IN(r, g, b, s)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1136 {\ |
1064 | 1137 unsigned int v = ((const uint32_t *)(s))[0];\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1138 r = (v >> 16) & 0xff;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1139 g = (v >> 8) & 0xff;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1140 b = v & 0xff;\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1141 } |
583 | 1142 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1143 #define RGB_OUT(d, r, g, b)\ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1144 {\ |
1064 | 1145 ((uint32_t *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;\ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1146 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1147 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1148 #define BPP 4 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1149 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1150 RGB_FUNCTIONS(rgba32) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1151 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1152 #undef RGB_IN |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1153 #undef RGB_OUT |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1154 #undef BPP |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1155 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1156 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1157 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
|
1158 int width, int height) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1159 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1160 const unsigned char *p; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1161 unsigned char *q; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1162 int r, g, b, dst_wrap, src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1163 int x, y; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1164 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1165 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1166 src_wrap = src->linesize[0] - 3 * width; |
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 q = dst->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1169 dst_wrap = dst->linesize[0] - 2 * width; |
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 for(y=0;y<height;y++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1172 for(x=0;x<width;x++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1173 r = p[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1174 g = p[1]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1175 b = p[2]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1176 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1177 ((unsigned short *)q)[0] = |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1178 ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1179 q += 2; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1180 p += 3; |
583 | 1181 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1182 p += src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1183 q += dst_wrap; |
583 | 1184 } |
1185 } | |
1186 | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1187 /* NOTE: we also add a dummy alpha bit */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1188 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
|
1189 int width, int height) |
583 | 1190 { |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1191 const unsigned char *p; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1192 unsigned char *q; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1193 int r, g, b, dst_wrap, src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1194 int x, y; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1195 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1196 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1197 src_wrap = src->linesize[0] - 3 * width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1198 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1199 q = dst->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1200 dst_wrap = dst->linesize[0] - 2 * width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1201 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1202 for(y=0;y<height;y++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1203 for(x=0;x<width;x++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1204 r = p[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1205 g = p[1]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1206 b = p[2]; |
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 ((unsigned short *)q)[0] = |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1209 ((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
|
1210 q += 2; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1211 p += 3; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1212 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1213 p += src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1214 q += dst_wrap; |
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 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1217 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1218 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
|
1219 int width, int height, int xor_mask) |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1220 { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1221 const unsigned char *p; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1222 unsigned char *q; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1223 int v, dst_wrap, src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1224 int y, w; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1225 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1226 p = src->data[0]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1227 src_wrap = src->linesize[0] - ((width + 7) >> 3); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1228 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1229 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
|
1230 dst_wrap = dst->linesize[0] - width; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1231 for(y=0;y<height;y++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1232 w = width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 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
|
1239 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
|
1240 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
|
1241 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
|
1242 q[7] = -((v >> 0) & 1); |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1243 w -= 8; |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1244 q += 8; |
583 | 1245 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1246 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
|
1247 v = *p++ ^ xor_mask; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1248 do { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1249 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
|
1250 q++; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1251 v <<= 1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1252 } while (--w); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1253 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1254 p += src_wrap; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1255 q += dst_wrap; |
583 | 1256 } |
1257 } | |
1258 | |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1259 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
|
1260 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
|
1261 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1262 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
|
1263 } |
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 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
|
1266 int width, int height) |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1267 { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1268 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
|
1269 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1270 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1271 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
|
1272 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
|
1273 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1274 int n; |
1064 | 1275 const uint8_t *s; |
1276 uint8_t *d; | |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1277 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
|
1278 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1279 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
|
1280 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
|
1281 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1282 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
|
1283 dst_wrap = dst->linesize[0] - ((width + 7) >> 3); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1284 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1285 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
|
1286 n = width; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1287 while (n >= 8) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1288 v = 0; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1289 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
|
1290 b = s[0]; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1291 s++; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1292 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
|
1293 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1294 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
|
1295 d++; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1296 n -= 8; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1297 } |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1298 if (n > 0) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1299 n1 = n; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1300 v = 0; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1301 while (n > 0) { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1302 b = s[0]; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1303 s++; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1304 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
|
1305 n--; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1306 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1307 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
|
1308 d++; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1309 } |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1310 s += src_wrap; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1311 d += dst_wrap; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1312 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1313 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1314 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1315 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
|
1316 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
|
1317 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1318 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
|
1319 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1320 |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1321 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
|
1322 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
|
1323 { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1324 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
|
1325 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1326 |
1055 | 1327 /* this is maybe slow, but allows for extensions */ |
1064 | 1328 static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b) |
1055 | 1329 { |
1330 return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6)); | |
1331 } | |
1332 | |
1333 /* XXX: put jpeg quantize code instead */ | |
1334 static void rgb24_to_pal8(AVPicture *dst, AVPicture *src, | |
1335 int width, int height) | |
1336 { | |
1337 const unsigned char *p; | |
1338 unsigned char *q; | |
1339 int r, g, b, dst_wrap, src_wrap; | |
1340 int x, y, i; | |
1341 static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff }; | |
1342 uint32_t *pal; | |
1343 | |
1344 p = src->data[0]; | |
1345 src_wrap = src->linesize[0] - 3 * width; | |
1346 | |
1347 q = dst->data[0]; | |
1348 dst_wrap = dst->linesize[0] - width; | |
1349 | |
1350 for(y=0;y<height;y++) { | |
1351 for(x=0;x<width;x++) { | |
1352 r = p[0]; | |
1353 g = p[1]; | |
1354 b = p[2]; | |
1355 | |
1356 q[0] = gif_clut_index(r, g, b); | |
1357 q++; | |
1358 p += 3; | |
1359 } | |
1360 p += src_wrap; | |
1361 q += dst_wrap; | |
1362 } | |
1363 | |
1364 /* build palette */ | |
1365 pal = (uint32_t *)dst->data[1]; | |
1366 i = 0; | |
1367 for(r = 0; r < 6; r++) { | |
1368 for(g = 0; g < 6; g++) { | |
1369 for(b = 0; b < 6; b++) { | |
1370 pal[i++] = (0xff << 24) | (pal_value[r] << 16) | | |
1371 (pal_value[g] << 8) | pal_value[b]; | |
1372 } | |
1373 } | |
1374 } | |
1375 while (i < 256) | |
1376 pal[i++] = 0; | |
1377 } | |
1378 | |
1199 | 1379 static void rgba32_to_rgb24(AVPicture *dst, AVPicture *src, |
1380 int width, int height) | |
1381 { | |
1382 const uint8_t *s; | |
1383 uint8_t *d; | |
1384 int src_wrap, dst_wrap, j, y; | |
1385 unsigned int v; | |
1386 | |
1387 s = src->data[0]; | |
1388 src_wrap = src->linesize[0] - width * 4; | |
1389 | |
1390 d = dst->data[0]; | |
1391 dst_wrap = dst->linesize[0] - width * 3; | |
1392 | |
1393 for(y=0;y<height;y++) { | |
1394 for(j = 0;j < width; j++) { | |
1395 v = *(uint32_t *)s; | |
1396 s += 4; | |
1397 d[0] = v >> 16; | |
1398 d[1] = v >> 8; | |
1399 d[2] = v; | |
1400 d += 3; | |
1401 } | |
1402 s += src_wrap; | |
1403 d += dst_wrap; | |
1404 } | |
1405 } | |
1406 | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1407 typedef struct ConvertEntry { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1408 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
|
1409 } ConvertEntry; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1410 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1411 /* add each new convertion function in this table */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1412 /* constraints; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1413 - 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
|
1414 */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1415 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
|
1416 [PIX_FMT_YUV420P] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1417 [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
|
1418 .convert = yuv420p_to_rgb555 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1419 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1420 [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
|
1421 .convert = yuv420p_to_rgb565 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1422 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1423 [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
|
1424 .convert = yuv420p_to_bgr24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1425 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1426 [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
|
1427 .convert = yuv420p_to_rgb24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1428 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1429 [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
|
1430 .convert = yuv420p_to_rgba32 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1431 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1432 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1433 [PIX_FMT_YUV422P] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1434 [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
|
1435 .convert = yuv422p_to_rgb555 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1436 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1437 [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
|
1438 .convert = yuv422p_to_rgb565 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1439 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1440 [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
|
1441 .convert = yuv422p_to_bgr24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1442 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1443 [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
|
1444 .convert = yuv422p_to_rgb24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1445 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1446 [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
|
1447 .convert = yuv422p_to_rgba32 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1448 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1449 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1450 [PIX_FMT_YUV422] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1451 [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
|
1452 .convert = yuv422_to_yuv420p, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1453 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1454 }, |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1455 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1456 [PIX_FMT_RGB24] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1457 [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
|
1458 .convert = rgb24_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1459 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1460 [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
|
1461 .convert = rgb24_to_rgb565 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1462 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1463 [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
|
1464 .convert = rgb24_to_rgb555 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1465 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1466 [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
|
1467 .convert = rgb24_to_gray |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1468 }, |
1055 | 1469 [PIX_FMT_PAL8] = { |
1470 .convert = rgb24_to_pal8 | |
1471 }, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1472 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1473 [PIX_FMT_RGBA32] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1474 [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
|
1475 .convert = rgba32_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1476 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1477 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1478 .convert = rgba32_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1479 }, |
1199 | 1480 [PIX_FMT_RGB24] = { |
1481 .convert = rgba32_to_rgb24 | |
1482 }, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1483 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1484 [PIX_FMT_BGR24] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1485 [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
|
1486 .convert = bgr24_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1487 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1488 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1489 .convert = bgr24_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1490 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1491 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1492 [PIX_FMT_RGB555] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1493 [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
|
1494 .convert = rgb555_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1495 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1496 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1497 .convert = rgb555_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1498 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1499 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1500 [PIX_FMT_RGB565] = { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1501 [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
|
1502 .convert = rgb565_to_yuv420p |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1503 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1504 [PIX_FMT_GRAY8] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1505 .convert = rgb565_to_gray |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1506 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1507 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1508 [PIX_FMT_GRAY8] = { |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1509 [PIX_FMT_RGB555] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1510 .convert = gray_to_rgb555 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1511 }, |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1512 [PIX_FMT_RGB565] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1513 .convert = gray_to_rgb565 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1514 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1515 [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
|
1516 .convert = gray_to_rgb24 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1517 }, |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1518 [PIX_FMT_BGR24] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1519 .convert = gray_to_bgr24 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1520 }, |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1521 [PIX_FMT_RGBA32] = { |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1522 .convert = gray_to_rgba32 |
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1523 }, |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1524 [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
|
1525 .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
|
1526 }, |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1527 [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
|
1528 .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
|
1529 }, |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1530 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1531 [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
|
1532 [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
|
1533 .convert = monowhite_to_gray |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1534 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1535 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1536 [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
|
1537 [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
|
1538 .convert = monoblack_to_gray |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1539 }, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1540 }, |
1055 | 1541 [PIX_FMT_PAL8] = { |
1542 [PIX_FMT_RGB555] = { | |
1543 .convert = pal8_to_rgb555 | |
1544 }, | |
1545 [PIX_FMT_RGB565] = { | |
1546 .convert = pal8_to_rgb565 | |
1547 }, | |
1548 [PIX_FMT_BGR24] = { | |
1549 .convert = pal8_to_bgr24 | |
1550 }, | |
1551 [PIX_FMT_RGB24] = { | |
1552 .convert = pal8_to_rgb24 | |
1553 }, | |
1554 [PIX_FMT_RGBA32] = { | |
1555 .convert = pal8_to_rgba32 | |
1556 }, | |
1557 }, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1558 }; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1559 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1560 static int avpicture_alloc(AVPicture *picture, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1561 int pix_fmt, int width, int height) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1562 { |
1057 | 1563 unsigned int size; |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1564 void *ptr; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1565 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1566 size = avpicture_get_size(pix_fmt, width, height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1567 if (size < 0) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1568 goto fail; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1569 ptr = av_malloc(size); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1570 if (!ptr) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1571 goto fail; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1572 avpicture_fill(picture, ptr, pix_fmt, width, height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1573 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1574 fail: |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1575 memset(picture, 0, sizeof(AVPicture)); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1576 return -1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1577 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1578 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1579 static void avpicture_free(AVPicture *picture) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1580 { |
1031
19de1445beb2
use av_malloc() functions - added av_strdup and av_realloc()
bellard
parents:
1028
diff
changeset
|
1581 av_free(picture->data[0]); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1582 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1583 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1584 /* 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
|
1585 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
|
1586 AVPicture *src, int src_pix_fmt, |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1587 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
|
1588 { |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1589 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
|
1590 PixFmtInfo *src_pix, *dst_pix; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1591 ConvertEntry *ce; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1592 AVPicture tmp1, *tmp = &tmp1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1593 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1594 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
|
1595 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
|
1596 return -1; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1597 if (src_width <= 0 || src_height <= 0) |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1598 return 0; |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1599 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1600 dst_width = src_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1601 dst_height = src_height; |
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1602 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1603 dst_pix = &pix_fmt_info[dst_pix_fmt]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1604 src_pix = &pix_fmt_info[src_pix_fmt]; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1605 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
|
1606 /* XXX: incorrect */ |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1607 /* same format: just copy */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1608 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
|
1609 int w, h; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1610 w = dst_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1611 h = dst_height; |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1612 if ((dst_pix->color_type == FF_COLOR_YUV || |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1613 dst_pix->color_type == FF_COLOR_YUV_JPEG) && |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1614 (i == 1 || i == 2)) { |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1615 w >>= dst_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1616 h >>= dst_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1617 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1618 img_copy(dst->data[i], dst->linesize[i], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1619 src->data[i], src->linesize[i], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1620 w, h); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1621 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1622 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1623 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1624 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1625 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
|
1626 if (ce->convert) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1627 /* specific convertion routine */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1628 ce->convert(dst, src, dst_width, dst_height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1629 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1630 } |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1631 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1632 /* gray to YUV */ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1633 if ((dst_pix->color_type == FF_COLOR_YUV || |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1634 dst_pix->color_type == FF_COLOR_YUV_JPEG) && |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1635 src_pix_fmt == PIX_FMT_GRAY8) { |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1636 int w, h, y; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1637 uint8_t *d; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1638 |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1639 if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1640 img_copy(dst->data[0], dst->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1641 src->data[0], src->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1642 dst_width, dst_height); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1643 } else { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1644 gray_to_luma_ccir(dst->data[0], dst->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1645 src->data[0], src->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1646 dst_width, dst_height); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1647 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1648 /* fill U and V with 128 */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1649 w = dst_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1650 h = dst_height; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1651 w >>= dst_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1652 h >>= dst_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1653 for(i = 1; i <= 2; i++) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1654 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
|
1655 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
|
1656 memset(d, 128, w); |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1657 d += dst->linesize[i]; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1658 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1659 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1660 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1661 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1662 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1663 /* YUV to gray */ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1664 if ((src_pix->color_type == FF_COLOR_YUV || |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1665 src_pix->color_type == FF_COLOR_YUV_JPEG) && |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1666 dst_pix_fmt == PIX_FMT_GRAY8) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1667 if (src_pix->color_type == FF_COLOR_YUV_JPEG) { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1668 img_copy(dst->data[0], dst->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1669 src->data[0], src->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1670 dst_width, dst_height); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1671 } else { |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1672 luma_ccir_to_gray(dst->data[0], dst->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1673 src->data[0], src->linesize[0], |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1674 dst_width, dst_height); |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1675 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1676 return 0; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1677 } |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1678 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1679 /* YUV to YUV */ |
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1680 if (dst_pix->color_type == FF_COLOR_YUV && |
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1681 dst_pix->color_type == src_pix->color_type) { |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1682 int x_shift, y_shift, w, h; |
1064 | 1683 void (*resize_func)(uint8_t *dst, int dst_wrap, |
1684 uint8_t *src, int src_wrap, | |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1685 int width, int height); |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1686 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1687 /* compute chroma size of the smallest dimensions */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1688 w = dst_width; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1689 h = dst_height; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1690 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
|
1691 w >>= dst_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1692 else |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1693 w >>= src_pix->x_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1694 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
|
1695 h >>= dst_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1696 else |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1697 h >>= src_pix->y_chroma_shift; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1698 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1699 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
|
1700 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
|
1701 if (x_shift == 0 && y_shift == 0) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1702 resize_func = img_copy; /* should never happen */ |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1703 } else if (x_shift == 0 && y_shift == 1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1704 resize_func = shrink2; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1705 } else if (x_shift == 1 && y_shift == 1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1706 resize_func = shrink22; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1707 } else if (x_shift == -1 && y_shift == -1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1708 resize_func = grow22; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1709 } else if (x_shift == -1 && y_shift == 1) { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1710 resize_func = conv411; |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1711 } else { |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1712 /* currently not handled */ |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1713 return -1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1714 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1715 |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1716 img_copy(dst->data[0], dst->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1717 src->data[0], src->linesize[0], |
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1718 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
|
1719 |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1720 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
|
1721 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
|
1722 src->data[i], src->linesize[i], |
1073 | 1723 dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift); |
1023
e61be5796027
img_convert() (YUV to YUV) patch by (Max Krasnyansky <maxk at qualcomm dot com>)
michaelni
parents:
1022
diff
changeset
|
1724 return 0; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1725 } |
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1726 |
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1727 /* 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
|
1728 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
|
1729 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
|
1730 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
|
1731 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
|
1732 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
|
1733 } else { |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1734 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
|
1735 } |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1736 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
|
1737 return -1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1738 ret = -1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1739 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
|
1740 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
|
1741 goto fail1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1742 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
|
1743 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
|
1744 goto fail1; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1745 ret = 0; |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1746 fail1: |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1747 avpicture_free(tmp); |
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1748 return ret; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1749 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1750 |
801 | 1751 |
1752 #ifdef HAVE_MMX | |
1753 #define DEINT_INPLACE_LINE_LUM \ | |
1754 movd_m2r(lum_m4[0],mm0);\ | |
1755 movd_m2r(lum_m3[0],mm1);\ | |
1756 movd_m2r(lum_m2[0],mm2);\ | |
1757 movd_m2r(lum_m1[0],mm3);\ | |
1758 movd_m2r(lum[0],mm4);\ | |
1759 punpcklbw_r2r(mm7,mm0);\ | |
1760 movd_r2m(mm2,lum_m4[0]);\ | |
1761 punpcklbw_r2r(mm7,mm1);\ | |
1762 punpcklbw_r2r(mm7,mm2);\ | |
1763 punpcklbw_r2r(mm7,mm3);\ | |
1764 punpcklbw_r2r(mm7,mm4);\ | |
1765 paddw_r2r(mm3,mm1);\ | |
1766 psllw_i2r(1,mm2);\ | |
1767 paddw_r2r(mm4,mm0);\ | |
1768 psllw_i2r(2,mm1);\ | |
1769 paddw_r2r(mm6,mm2);\ | |
1770 paddw_r2r(mm2,mm1);\ | |
1771 psubusw_r2r(mm0,mm1);\ | |
1772 psrlw_i2r(3,mm1);\ | |
1773 packuswb_r2r(mm7,mm1);\ | |
1774 movd_r2m(mm1,lum_m2[0]); | |
1775 | |
1776 #define DEINT_LINE_LUM \ | |
1777 movd_m2r(lum_m4[0],mm0);\ | |
1778 movd_m2r(lum_m3[0],mm1);\ | |
1779 movd_m2r(lum_m2[0],mm2);\ | |
1780 movd_m2r(lum_m1[0],mm3);\ | |
1781 movd_m2r(lum[0],mm4);\ | |
1782 punpcklbw_r2r(mm7,mm0);\ | |
1783 punpcklbw_r2r(mm7,mm1);\ | |
1784 punpcklbw_r2r(mm7,mm2);\ | |
1785 punpcklbw_r2r(mm7,mm3);\ | |
1786 punpcklbw_r2r(mm7,mm4);\ | |
1787 paddw_r2r(mm3,mm1);\ | |
1788 psllw_i2r(1,mm2);\ | |
1789 paddw_r2r(mm4,mm0);\ | |
1790 psllw_i2r(2,mm1);\ | |
1791 paddw_r2r(mm6,mm2);\ | |
1792 paddw_r2r(mm2,mm1);\ | |
1793 psubusw_r2r(mm0,mm1);\ | |
1794 psrlw_i2r(3,mm1);\ | |
1795 packuswb_r2r(mm7,mm1);\ | |
1796 movd_r2m(mm1,dst[0]); | |
1797 #endif | |
1798 | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1799 /* filter parameters: [-1 4 2 4 -1] // 8 */ |
1064 | 1800 static void deinterlace_line(uint8_t *dst, uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum, |
801 | 1801 int size) |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1802 { |
801 | 1803 #ifndef HAVE_MMX |
1064 | 1804 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1805 int sum; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1806 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1807 for(;size > 0;size--) { |
801 | 1808 sum = -lum_m4[0]; |
1809 sum += lum_m3[0] << 2; | |
1810 sum += lum_m2[0] << 1; | |
1811 sum += lum_m1[0] << 2; | |
1812 sum += -lum[0]; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1813 dst[0] = cm[(sum + 4) >> 3]; |
801 | 1814 lum_m4++; |
1815 lum_m3++; | |
1816 lum_m2++; | |
1817 lum_m1++; | |
1818 lum++; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1819 dst++; |
801 | 1820 } |
1821 #else | |
1822 | |
1044 | 1823 { |
1824 mmx_t rounder; | |
1825 rounder.uw[0]=4; | |
1826 rounder.uw[1]=4; | |
1827 rounder.uw[2]=4; | |
1828 rounder.uw[3]=4; | |
1829 pxor_r2r(mm7,mm7); | |
1830 movq_m2r(rounder,mm6); | |
1831 } | |
801 | 1832 for (;size > 3; size-=4) { |
1833 DEINT_LINE_LUM | |
1834 lum_m4+=4; | |
1835 lum_m3+=4; | |
1836 lum_m2+=4; | |
1837 lum_m1+=4; | |
1838 lum+=4; | |
1839 dst+=4; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1840 } |
801 | 1841 #endif |
1842 } | |
1064 | 1843 static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum, |
801 | 1844 int size) |
1845 { | |
1846 #ifndef HAVE_MMX | |
1064 | 1847 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
801 | 1848 int sum; |
1849 | |
1850 for(;size > 0;size--) { | |
1851 sum = -lum_m4[0]; | |
1852 sum += lum_m3[0] << 2; | |
1853 sum += lum_m2[0] << 1; | |
1854 lum_m4[0]=lum_m2[0]; | |
1855 sum += lum_m1[0] << 2; | |
1856 sum += -lum[0]; | |
1857 lum_m2[0] = cm[(sum + 4) >> 3]; | |
1858 lum_m4++; | |
1859 lum_m3++; | |
1860 lum_m2++; | |
1861 lum_m1++; | |
1862 lum++; | |
1863 } | |
1864 #else | |
1865 | |
1044 | 1866 { |
1867 mmx_t rounder; | |
1868 rounder.uw[0]=4; | |
1869 rounder.uw[1]=4; | |
1870 rounder.uw[2]=4; | |
1871 rounder.uw[3]=4; | |
1872 pxor_r2r(mm7,mm7); | |
1873 movq_m2r(rounder,mm6); | |
1874 } | |
801 | 1875 for (;size > 3; size-=4) { |
1876 DEINT_INPLACE_LINE_LUM | |
1877 lum_m4+=4; | |
1878 lum_m3+=4; | |
1879 lum_m2+=4; | |
1880 lum_m1+=4; | |
1881 lum+=4; | |
1882 } | |
1883 #endif | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1884 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1885 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1886 /* 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
|
1887 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
|
1888 against the top field. */ |
1064 | 1889 static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap, |
1890 uint8_t *src1, int src_wrap, | |
801 | 1891 int width, int height) |
1892 { | |
1064 | 1893 uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2; |
801 | 1894 int y; |
1895 | |
1896 src_m2 = src1; | |
1897 src_m1 = src1; | |
1898 src_0=&src_m1[src_wrap]; | |
1899 src_p1=&src_0[src_wrap]; | |
1900 src_p2=&src_p1[src_wrap]; | |
1901 for(y=0;y<(height-2);y+=2) { | |
1902 memcpy(dst,src_m1,width); | |
1903 dst += dst_wrap; | |
1904 deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width); | |
1905 src_m2 = src_0; | |
1906 src_m1 = src_p1; | |
1907 src_0 = src_p2; | |
1908 src_p1 += 2*src_wrap; | |
1909 src_p2 += 2*src_wrap; | |
1910 dst += dst_wrap; | |
1911 } | |
1912 memcpy(dst,src_m1,width); | |
1913 dst += dst_wrap; | |
1914 /* do last line */ | |
1915 deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width); | |
1916 } | |
1917 | |
1064 | 1918 static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap, |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1919 int width, int height) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1920 { |
1064 | 1921 uint8_t *src_m1, *src_0, *src_p1, *src_p2; |
801 | 1922 int y; |
1064 | 1923 uint8_t *buf; |
1924 buf = (uint8_t*)av_malloc(width); | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1925 |
801 | 1926 src_m1 = src1; |
1927 memcpy(buf,src_m1,width); | |
1928 src_0=&src_m1[src_wrap]; | |
1929 src_p1=&src_0[src_wrap]; | |
1930 src_p2=&src_p1[src_wrap]; | |
1931 for(y=0;y<(height-2);y+=2) { | |
1932 deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width); | |
1933 src_m1 = src_p1; | |
1934 src_0 = src_p2; | |
1935 src_p1 += 2*src_wrap; | |
1936 src_p2 += 2*src_wrap; | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1937 } |
801 | 1938 /* do last line */ |
1939 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
|
1940 av_free(buf); |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1941 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1942 |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1943 |
801 | 1944 /* 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
|
1945 int avpicture_deinterlace(AVPicture *dst, AVPicture *src, |
0 | 1946 int pix_fmt, int width, int height) |
1947 { | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1948 int i; |
0 | 1949 |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1950 if (pix_fmt != PIX_FMT_YUV420P && |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1951 pix_fmt != PIX_FMT_YUV422P && |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1952 pix_fmt != PIX_FMT_YUV444P) |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1953 return -1; |
801 | 1954 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
|
1955 return -1; |
801 | 1956 |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1957 for(i=0;i<3;i++) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1958 if (i == 1) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1959 switch(pix_fmt) { |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1960 case PIX_FMT_YUV420P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1961 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1962 height >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1963 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1964 case PIX_FMT_YUV422P: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1965 width >>= 1; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1966 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1967 default: |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1968 break; |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1969 } |
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1970 } |
801 | 1971 if (src == dst) { |
1972 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
|
1973 width, height); |
801 | 1974 } else { |
1975 deinterlace_bottom_field(dst->data[i],dst->linesize[i], | |
1976 src->data[i], src->linesize[i], | |
1977 width, height); | |
1978 } | |
0 | 1979 } |
801 | 1980 #ifdef HAVE_MMX |
1981 emms(); | |
1982 #endif | |
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1983 return 0; |
0 | 1984 } |
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
1985 |
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
1986 #undef FIX |