Mercurial > libavcodec.hg
annotate imgconvert.c @ 2137:ef47c0b1ff28 libavcodec
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
| author | michael |
|---|---|
| date | Sun, 25 Jul 2004 10:01:36 +0000 |
| parents | 5495691106c3 |
| children | 34eaf41657d5 |
| 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 | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
25 /* TODO: |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
26 * - write 'ffimg' program to test all the image related stuff |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
27 * - move all api to slice based system |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
28 * - integrate deinterlacing, postprocessing and scaling in the conversion process |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
29 */ |
| 1106 | 30 |
| 0 | 31 #include "avcodec.h" |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
32 #include "dsputil.h" |
| 0 | 33 |
| 17 | 34 #ifdef USE_FASTMEMCPY |
| 35 #include "fastmemcpy.h" | |
| 36 #endif | |
| 801 | 37 |
| 38 #ifdef HAVE_MMX | |
| 39 #include "i386/mmx.h" | |
| 40 #endif | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
41 |
| 1204 | 42 #define xglue(x, y) x ## y |
| 43 #define glue(x, y) xglue(x, y) | |
| 44 | |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
45 #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
|
46 #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
|
47 #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
|
48 #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
|
49 |
| 1204 | 50 #define FF_PIXEL_PLANAR 0 /* each channel has one component in AVPicture */ |
| 51 #define FF_PIXEL_PACKED 1 /* only one components containing all the channels */ | |
| 52 #define FF_PIXEL_PALETTE 2 /* one components containing indexes for a palette */ | |
| 53 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
54 typedef struct PixFmtInfo { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
55 const char *name; |
| 1204 | 56 uint8_t nb_channels; /* number of channels (including alpha) */ |
| 57 uint8_t color_type; /* color type (see FF_COLOR_xxx constants) */ | |
| 58 uint8_t pixel_type; /* pixel storage type (see FF_PIXEL_xxx constants) */ | |
| 1064 | 59 uint8_t is_alpha : 1; /* true if alpha can be specified */ |
| 1204 | 60 uint8_t x_chroma_shift; /* X chroma subsampling factor is 2 ^ shift */ |
| 61 uint8_t y_chroma_shift; /* Y chroma subsampling factor is 2 ^ shift */ | |
| 62 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
|
63 } PixFmtInfo; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
64 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
65 /* this table gives more information about formats */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
66 static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
67 /* YUV formats */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
68 [PIX_FMT_YUV420P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
69 .name = "yuv420p", |
| 1204 | 70 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
71 .color_type = FF_COLOR_YUV, |
| 1204 | 72 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
73 .depth = 8, |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
74 .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
|
75 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
76 [PIX_FMT_YUV422P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
77 .name = "yuv422p", |
| 1204 | 78 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
79 .color_type = FF_COLOR_YUV, |
| 1204 | 80 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
81 .depth = 8, |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
82 .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
|
83 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
84 [PIX_FMT_YUV444P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
85 .name = "yuv444p", |
| 1204 | 86 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
87 .color_type = FF_COLOR_YUV, |
| 1204 | 88 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
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 (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
90 .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
|
91 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
92 [PIX_FMT_YUV422] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
93 .name = "yuv422", |
| 1204 | 94 .nb_channels = 1, |
|
1202
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, |
| 1204 | 96 .pixel_type = FF_PIXEL_PACKED, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
97 .depth = 8, |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
98 .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
|
99 }, |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
100 [PIX_FMT_UYVY422] = { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
101 .name = "uyvy422", |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
102 .nb_channels = 1, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
103 .color_type = FF_COLOR_YUV, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
104 .pixel_type = FF_PIXEL_PACKED, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
105 .depth = 8, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
106 .x_chroma_shift = 1, .y_chroma_shift = 0, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
107 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
108 [PIX_FMT_YUV410P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
109 .name = "yuv410p", |
| 1204 | 110 .nb_channels = 3, |
|
1202
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, |
| 1204 | 112 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
113 .depth = 8, |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
114 .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
|
115 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
116 [PIX_FMT_YUV411P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
117 .name = "yuv411p", |
| 1204 | 118 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
119 .color_type = FF_COLOR_YUV, |
| 1204 | 120 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
121 .depth = 8, |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
122 .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
|
123 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
124 |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
125 /* JPEG YUV */ |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
126 [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
|
127 .name = "yuvj420p", |
| 1204 | 128 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
129 .color_type = FF_COLOR_YUV_JPEG, |
| 1204 | 130 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
131 .depth = 8, |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
132 .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
|
133 }, |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
134 [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
|
135 .name = "yuvj422p", |
| 1204 | 136 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
137 .color_type = FF_COLOR_YUV_JPEG, |
| 1204 | 138 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
139 .depth = 8, |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
140 .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
|
141 }, |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
142 [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
|
143 .name = "yuvj444p", |
| 1204 | 144 .nb_channels = 3, |
|
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_YUV_JPEG, |
| 1204 | 146 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
147 .depth = 8, |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
148 .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
|
149 }, |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
150 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
151 /* RGB formats */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
152 [PIX_FMT_RGB24] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
153 .name = "rgb24", |
| 1204 | 154 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
155 .color_type = FF_COLOR_RGB, |
| 1204 | 156 .pixel_type = FF_PIXEL_PACKED, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
157 .depth = 8, |
| 1593 | 158 .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
|
159 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
160 [PIX_FMT_BGR24] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
161 .name = "bgr24", |
| 1204 | 162 .nb_channels = 3, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
163 .color_type = FF_COLOR_RGB, |
| 1204 | 164 .pixel_type = FF_PIXEL_PACKED, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
165 .depth = 8, |
| 1593 | 166 .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
|
167 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
168 [PIX_FMT_RGBA32] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
169 .name = "rgba32", |
| 1204 | 170 .nb_channels = 4, .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
|
171 .color_type = FF_COLOR_RGB, |
| 1204 | 172 .pixel_type = FF_PIXEL_PACKED, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
173 .depth = 8, |
| 1593 | 174 .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
|
175 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
176 [PIX_FMT_RGB565] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
177 .name = "rgb565", |
| 1204 | 178 .nb_channels = 3, |
|
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, |
| 1204 | 180 .pixel_type = FF_PIXEL_PACKED, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
181 .depth = 5, |
| 1593 | 182 .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
|
183 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
184 [PIX_FMT_RGB555] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
185 .name = "rgb555", |
| 1204 | 186 .nb_channels = 4, .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
|
187 .color_type = FF_COLOR_RGB, |
| 1204 | 188 .pixel_type = FF_PIXEL_PACKED, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
189 .depth = 5, |
| 1593 | 190 .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
|
191 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
192 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
193 /* gray / mono formats */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
194 [PIX_FMT_GRAY8] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
195 .name = "gray", |
| 1204 | 196 .nb_channels = 1, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
197 .color_type = FF_COLOR_GRAY, |
| 1204 | 198 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
199 .depth = 8, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
200 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
201 [PIX_FMT_MONOWHITE] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
202 .name = "monow", |
| 1204 | 203 .nb_channels = 1, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
204 .color_type = FF_COLOR_GRAY, |
| 1204 | 205 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
206 .depth = 1, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
207 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
208 [PIX_FMT_MONOBLACK] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
209 .name = "monob", |
| 1204 | 210 .nb_channels = 1, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
211 .color_type = FF_COLOR_GRAY, |
| 1204 | 212 .pixel_type = FF_PIXEL_PLANAR, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
213 .depth = 1, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
214 }, |
| 1055 | 215 |
| 216 /* paletted formats */ | |
| 217 [PIX_FMT_PAL8] = { | |
| 218 .name = "pal8", | |
| 1204 | 219 .nb_channels = 4, .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
|
220 .color_type = FF_COLOR_RGB, |
| 1204 | 221 .pixel_type = FF_PIXEL_PALETTE, |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
222 .depth = 8, |
| 1055 | 223 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
224 }; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
225 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
226 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
|
227 { |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
228 *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
|
229 *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
|
230 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
231 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
232 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
|
233 { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
234 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
|
235 return "???"; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
236 else |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
237 return pix_fmt_info[pix_fmt].name; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
238 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
239 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
240 enum PixelFormat avcodec_get_pix_fmt(const char* name) |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
241 { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
242 int i; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
243 |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
244 for (i=0; i < PIX_FMT_NB; i++) |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
245 if (!strcmp(pix_fmt_info[i].name, name)) |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
246 break; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
247 return i; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
248 } |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
249 |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
250 /* Picture field are filled with 'ptr' addresses. Also return size */ |
| 1064 | 251 int avpicture_fill(AVPicture *picture, uint8_t *ptr, |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
252 int pix_fmt, int width, int height) |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
253 { |
|
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
254 int size, w2, h2, size2; |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
255 PixFmtInfo *pinfo; |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
256 |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
257 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
|
258 size = width * height; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
259 switch(pix_fmt) { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
260 case PIX_FMT_YUV420P: |
|
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
261 case PIX_FMT_YUV422P: |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
262 case PIX_FMT_YUV444P: |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
263 case PIX_FMT_YUV410P: |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
264 case PIX_FMT_YUV411P: |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
265 case PIX_FMT_YUVJ420P: |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
266 case PIX_FMT_YUVJ422P: |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
267 case PIX_FMT_YUVJ444P: |
|
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 picture->linesize[0] = width; |
|
1047
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
275 picture->linesize[1] = w2; |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
276 picture->linesize[2] = w2; |
|
3f316a471019
handle odd image sizes when using subsampled chroma (useful for JPEG images)
bellard
parents:
1044
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 return size * 3; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
285 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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 return size * 4; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 return size * 2; |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
299 case PIX_FMT_UYVY422: |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
300 picture->data[0] = ptr; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
301 picture->data[1] = NULL; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
302 picture->data[2] = NULL; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
303 picture->linesize[0] = width * 2; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
304 return size * 2; |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 return size; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 return picture->linesize[0] * height; |
| 1055 | 318 case PIX_FMT_PAL8: |
| 319 size2 = (size + 3) & ~3; | |
| 320 picture->data[0] = ptr; | |
| 321 picture->data[1] = ptr + size2; /* palette is stored here as 256 32 bit words */ | |
| 322 picture->data[2] = NULL; | |
| 323 picture->linesize[0] = width; | |
| 324 picture->linesize[1] = 4; | |
| 325 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
|
326 default: |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
327 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
|
328 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
|
329 picture->data[2] = NULL; |
| 1055 | 330 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
|
331 return -1; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
332 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
333 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
334 |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
335 int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height, |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
336 unsigned char *dest, int dest_size) |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
337 { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
338 PixFmtInfo* pf = &pix_fmt_info[pix_fmt]; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
339 int i, j, w, h, data_planes; |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
340 const unsigned char* s; |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
341 int size = avpicture_get_size(pix_fmt, width, height); |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
342 |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
343 if (size > dest_size) |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
344 return -1; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
345 |
|
1243
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
346 if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) { |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
347 if (pix_fmt == PIX_FMT_YUV422 || |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
348 pix_fmt == PIX_FMT_UYVY422 || |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
349 pix_fmt == PIX_FMT_RGB565 || |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
350 pix_fmt == PIX_FMT_RGB555) |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
351 w = width * 2; |
|
1243
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
352 else if (pix_fmt == PIX_FMT_PAL8) |
|
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
353 w = width; |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
354 else |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
355 w = width * (pf->depth * pf->nb_channels / 8); |
|
1243
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
356 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
357 data_planes = 1; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
358 h = height; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
359 } else { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
360 data_planes = pf->nb_channels; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
361 w = width; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
362 h = height; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
363 } |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
364 |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
365 for (i=0; i<data_planes; i++) { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
366 if (i == 1) { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
367 w = width >> pf->x_chroma_shift; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
368 h = height >> pf->y_chroma_shift; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
369 } |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
370 s = src->data[i]; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
371 for(j=0; j<h; j++) { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
372 memcpy(dest, s, w); |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
373 dest += w; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
374 s += src->linesize[i]; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
375 } |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
376 } |
|
1243
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
377 |
|
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
378 if (pf->pixel_type == FF_PIXEL_PALETTE) |
|
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
379 memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4); |
|
5d2376294fbf
* fixing a bug in avpicture_layout (PAL8 wasn't handled properly)
romansh
parents:
1231
diff
changeset
|
380 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
381 return size; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
382 } |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1209
diff
changeset
|
383 |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
384 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
|
385 { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
386 AVPicture dummy_pict; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
387 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
|
388 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
389 |
|
1202
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 * 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
|
392 */ |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
393 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
|
394 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
|
395 { |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
396 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
|
397 int loss; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
398 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
399 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
|
400 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
|
401 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
402 /* compute loss */ |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
403 loss = 0; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
404 pf = &pix_fmt_info[dst_pix_fmt]; |
|
1206
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
405 if (pf->depth < ps->depth || |
|
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
406 (dst_pix_fmt == PIX_FMT_RGB555 && src_pix_fmt == PIX_FMT_RGB565)) |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
407 loss |= FF_LOSS_DEPTH; |
|
1206
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
408 if (pf->x_chroma_shift > ps->x_chroma_shift || |
|
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
409 pf->y_chroma_shift > ps->y_chroma_shift) |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
410 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
|
411 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 break; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
417 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
|
418 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
|
419 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
|
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 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
|
422 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
|
423 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
|
424 break; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
425 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
|
426 if (ps->color_type != FF_COLOR_YUV_JPEG && |
|
1206
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
427 ps->color_type != FF_COLOR_YUV && |
|
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
428 ps->color_type != FF_COLOR_GRAY) |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
429 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
|
430 break; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
431 default: |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
432 /* 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
|
433 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
|
434 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
|
435 break; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
436 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
437 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
|
438 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
|
439 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
|
440 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
|
441 loss |= FF_LOSS_ALPHA; |
| 1204 | 442 if (pf->pixel_type == FF_PIXEL_PALETTE && |
| 443 (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY)) | |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
444 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
|
445 return loss; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
446 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
447 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
448 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
|
449 { |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
450 int bits; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
451 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
|
452 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
453 pf = &pix_fmt_info[pix_fmt]; |
| 1204 | 454 switch(pf->pixel_type) { |
| 455 case FF_PIXEL_PACKED: | |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
456 switch(pix_fmt) { |
| 1204 | 457 case PIX_FMT_YUV422: |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
458 case PIX_FMT_UYVY422: |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
459 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
|
460 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
|
461 bits = 16; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
462 break; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
463 default: |
| 1204 | 464 bits = pf->depth * pf->nb_channels; |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
465 break; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
466 } |
| 1204 | 467 break; |
| 468 case FF_PIXEL_PLANAR: | |
| 469 if (pf->x_chroma_shift == 0 && pf->y_chroma_shift == 0) { | |
| 470 bits = pf->depth * pf->nb_channels; | |
| 471 } else { | |
| 472 bits = pf->depth + ((2 * pf->depth) >> | |
| 473 (pf->x_chroma_shift + pf->y_chroma_shift)); | |
| 474 } | |
| 475 break; | |
| 476 case FF_PIXEL_PALETTE: | |
| 477 bits = 8; | |
| 478 break; | |
| 479 default: | |
| 480 bits = -1; | |
| 481 break; | |
|
1202
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 return bits; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
484 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
485 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
486 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
|
487 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
|
488 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
|
489 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
|
490 { |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
491 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
|
492 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
493 /* 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
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
505 } |
|
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 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
508 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
|
509 } |
|
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 /** |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
512 * 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
|
513 */ |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
514 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
|
515 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
|
516 { |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
517 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
|
518 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
|
519 ~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
|
520 ~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
|
521 ~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
|
522 ~(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
|
523 ~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
|
524 ~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
|
525 0, |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
526 }; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
527 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
528 /* 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
|
529 i = 0; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
530 for(;;) { |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
531 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
|
532 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
|
533 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
|
534 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
|
535 goto found; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
536 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
|
537 break; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
538 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
539 return -1; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
540 found: |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
541 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
|
542 *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
|
543 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
|
544 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
545 |
| 1204 | 546 static void img_copy_plane(uint8_t *dst, int dst_wrap, |
| 1205 | 547 const uint8_t *src, int src_wrap, |
| 548 int width, int height) | |
| 1204 | 549 { |
| 550 for(;height > 0; height--) { | |
| 551 memcpy(dst, src, width); | |
| 552 dst += dst_wrap; | |
| 553 src += src_wrap; | |
| 554 } | |
| 555 } | |
| 556 | |
| 1208 | 557 /** |
| 558 * Copy image 'src' to 'dst'. | |
| 559 */ | |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
560 void img_copy(AVPicture *dst, const AVPicture *src, |
| 1204 | 561 int pix_fmt, int width, int height) |
| 562 { | |
| 563 int bwidth, bits, i; | |
| 564 PixFmtInfo *pf = &pix_fmt_info[pix_fmt]; | |
| 565 | |
| 566 pf = &pix_fmt_info[pix_fmt]; | |
| 567 switch(pf->pixel_type) { | |
| 568 case FF_PIXEL_PACKED: | |
| 569 switch(pix_fmt) { | |
| 570 case PIX_FMT_YUV422: | |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
571 case PIX_FMT_UYVY422: |
| 1204 | 572 case PIX_FMT_RGB565: |
| 573 case PIX_FMT_RGB555: | |
| 574 bits = 16; | |
| 575 break; | |
| 576 default: | |
| 577 bits = pf->depth * pf->nb_channels; | |
| 578 break; | |
| 579 } | |
| 580 bwidth = (width * bits + 7) >> 3; | |
| 581 img_copy_plane(dst->data[0], dst->linesize[0], | |
| 582 src->data[0], src->linesize[0], | |
| 583 bwidth, height); | |
| 584 break; | |
| 585 case FF_PIXEL_PLANAR: | |
| 586 for(i = 0; i < pf->nb_channels; i++) { | |
| 587 int w, h; | |
| 588 w = width; | |
| 589 h = height; | |
| 590 if (i == 1 || i == 2) { | |
| 591 w >>= pf->x_chroma_shift; | |
| 592 h >>= pf->y_chroma_shift; | |
| 593 } | |
| 594 bwidth = (w * pf->depth + 7) >> 3; | |
| 595 img_copy_plane(dst->data[i], dst->linesize[i], | |
| 596 src->data[i], src->linesize[i], | |
| 597 bwidth, h); | |
| 598 } | |
| 599 break; | |
| 600 case FF_PIXEL_PALETTE: | |
| 601 img_copy_plane(dst->data[0], dst->linesize[0], | |
| 602 src->data[0], src->linesize[0], | |
| 603 width, height); | |
| 604 /* copy the palette */ | |
| 605 img_copy_plane(dst->data[1], dst->linesize[1], | |
| 606 src->data[1], src->linesize[1], | |
| 607 4, 256); | |
| 608 break; | |
| 609 } | |
| 610 } | |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
611 |
| 0 | 612 /* XXX: totally non optimized */ |
| 613 | |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
614 static void yuv422_to_yuv420p(AVPicture *dst, const AVPicture *src, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
615 int width, int height) |
| 0 | 616 { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
617 const uint8_t *p, *p1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
618 uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1; |
|
1353
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
619 int w; |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
620 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
621 p1 = src->data[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
622 lum1 = dst->data[0]; |
| 1207 | 623 cb1 = dst->data[1]; |
| 624 cr1 = dst->data[2]; | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
625 |
|
1353
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
626 for(;height >= 1; height -= 2) { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
627 p = p1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
628 lum = lum1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
629 cb = cb1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
630 cr = cr1; |
|
1353
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
631 for(w = width; w >= 2; w -= 2) { |
|
1028
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
632 lum[0] = p[0]; |
|
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
633 cb[0] = p[1]; |
|
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
634 lum[1] = p[2]; |
|
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
635 cr[0] = p[3]; |
| 0 | 636 p += 4; |
| 637 lum += 2; | |
| 638 cb++; | |
| 639 cr++; | |
| 640 } | |
|
1353
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
641 if (w) { |
|
1028
e76fb91de4cc
reversing my own stupidity ... (raw packed yuv422 files dont use YUY2 but UYVY)
michaelni
parents:
1023
diff
changeset
|
642 lum[0] = p[0]; |
|
1353
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
643 cb[0] = p[1]; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
644 cr[0] = p[3]; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
645 cb++; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
646 cr++; |
| 0 | 647 } |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
648 p1 += src->linesize[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
649 lum1 += dst->linesize[0]; |
|
1353
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
650 if (height>1) { |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
651 p = p1; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
652 lum = lum1; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
653 for(w = width; w >= 2; w -= 2) { |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
654 lum[0] = p[0]; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
655 lum[1] = p[2]; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
656 p += 4; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
657 lum += 2; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
658 } |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
659 if (w) { |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
660 lum[0] = p[0]; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
661 } |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
662 p1 += src->linesize[0]; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
663 lum1 += dst->linesize[0]; |
|
cfc80b3a4ada
flash video (flv) support patch by (Garrick Meeker <gmeeker at theoryllc dot com>)
michaelni
parents:
1282
diff
changeset
|
664 } |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
665 cb1 += dst->linesize[1]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
666 cr1 += dst->linesize[2]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
667 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
668 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
669 |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
670 static void uyvy422_to_yuv420p(AVPicture *dst, const AVPicture *src, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
671 int width, int height) |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
672 { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
673 const uint8_t *p, *p1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
674 uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
675 int w; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
676 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
677 p1 = src->data[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
678 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
679 lum1 = dst->data[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
680 cb1 = dst->data[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
681 cr1 = dst->data[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
682 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
683 for(;height >= 1; height -= 2) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
684 p = p1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
685 lum = lum1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
686 cb = cb1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
687 cr = cr1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
688 for(w = width; w >= 2; w -= 2) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
689 lum[0] = p[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
690 cb[0] = p[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
691 lum[1] = p[3]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
692 cr[0] = p[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
693 p += 4; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
694 lum += 2; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
695 cb++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
696 cr++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
697 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
698 if (w) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
699 lum[0] = p[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
700 cb[0] = p[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
701 cr[0] = p[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
702 cb++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
703 cr++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
704 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
705 p1 += src->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
706 lum1 += dst->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
707 if (height>1) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
708 p = p1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
709 lum = lum1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
710 for(w = width; w >= 2; w -= 2) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
711 lum[0] = p[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
712 lum[1] = p[3]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
713 p += 4; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
714 lum += 2; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
715 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
716 if (w) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
717 lum[0] = p[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
718 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
719 p1 += src->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
720 lum1 += dst->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
721 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
722 cb1 += dst->linesize[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
723 cr1 += dst->linesize[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
724 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
725 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
726 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
727 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
728 static void uyvy422_to_yuv422p(AVPicture *dst, const AVPicture *src, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
729 int width, int height) |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
730 { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
731 const uint8_t *p, *p1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
732 uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
733 int w; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
734 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
735 p1 = src->data[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
736 lum1 = dst->data[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
737 cb1 = dst->data[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
738 cr1 = dst->data[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
739 for(;height > 0; height--) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
740 p = p1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
741 lum = lum1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
742 cb = cb1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
743 cr = cr1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
744 for(w = width; w >= 2; w -= 2) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
745 lum[0] = p[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
746 cb[0] = p[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
747 lum[1] = p[3]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
748 cr[0] = p[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
749 p += 4; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
750 lum += 2; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
751 cb++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
752 cr++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
753 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
754 p1 += src->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
755 lum1 += dst->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
756 cb1 += dst->linesize[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
757 cr1 += dst->linesize[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
758 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
759 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
760 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
761 |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
762 static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src, |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
763 int width, int height) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
764 { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
765 const uint8_t *p, *p1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
766 uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
767 int w; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
768 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
769 p1 = src->data[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
770 lum1 = dst->data[0]; |
| 1207 | 771 cb1 = dst->data[1]; |
| 772 cr1 = dst->data[2]; | |
| 773 for(;height > 0; height--) { | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
774 p = p1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
775 lum = lum1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
776 cb = cb1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
777 cr = cr1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
778 for(w = width; w >= 2; w -= 2) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
779 lum[0] = p[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
780 cb[0] = p[1]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
781 lum[1] = p[2]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
782 cr[0] = p[3]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
783 p += 4; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
784 lum += 2; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
785 cb++; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
786 cr++; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
787 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
788 p1 += src->linesize[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
789 lum1 += dst->linesize[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
790 cb1 += dst->linesize[1]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
791 cr1 += dst->linesize[2]; |
| 0 | 792 } |
| 793 } | |
| 794 | |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
795 static void yuv422p_to_yuv422(AVPicture *dst, const AVPicture *src, |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
796 int width, int height) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
797 { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
798 uint8_t *p, *p1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
799 const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
800 int w; |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
801 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
802 p1 = dst->data[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
803 lum1 = src->data[0]; |
| 1207 | 804 cb1 = src->data[1]; |
| 805 cr1 = src->data[2]; | |
| 806 for(;height > 0; height--) { | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
807 p = p1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
808 lum = lum1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
809 cb = cb1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
810 cr = cr1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
811 for(w = width; w >= 2; w -= 2) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
812 p[0] = lum[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
813 p[1] = cb[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
814 p[2] = lum[1]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
815 p[3] = cr[0]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
816 p += 4; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
817 lum += 2; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
818 cb++; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
819 cr++; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
820 } |
| 1207 | 821 p1 += dst->linesize[0]; |
| 822 lum1 += src->linesize[0]; | |
| 823 cb1 += src->linesize[1]; | |
| 824 cr1 += src->linesize[2]; | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
825 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
826 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
827 |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
828 static void yuv422p_to_uyvy422(AVPicture *dst, const AVPicture *src, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
829 int width, int height) |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
830 { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
831 uint8_t *p, *p1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
832 const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
833 int w; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
834 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
835 p1 = dst->data[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
836 lum1 = src->data[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
837 cb1 = src->data[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
838 cr1 = src->data[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
839 for(;height > 0; height--) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
840 p = p1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
841 lum = lum1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
842 cb = cb1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
843 cr = cr1; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
844 for(w = width; w >= 2; w -= 2) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
845 p[1] = lum[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
846 p[0] = cb[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
847 p[3] = lum[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
848 p[2] = cr[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
849 p += 4; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
850 lum += 2; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
851 cb++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
852 cr++; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
853 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
854 p1 += dst->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
855 lum1 += src->linesize[0]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
856 cb1 += src->linesize[1]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
857 cr1 += src->linesize[2]; |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
858 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
859 } |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
860 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
861 |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
862 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
863 #define SCALEBITS 10 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
864 #define ONE_HALF (1 << (SCALEBITS - 1)) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
865 #define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5)) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
866 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
867 #define YUV_TO_RGB1_CCIR(cb1, cr1)\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
868 {\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
869 cb = (cb1) - 128;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
870 cr = (cr1) - 128;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
871 r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
872 g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
873 ONE_HALF;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
874 b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
875 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
876 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
877 #define YUV_TO_RGB2_CCIR(r, g, b, y1)\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
878 {\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
879 y = ((y1) - 16) * FIX(255.0/219.0);\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
880 r = cm[(y + r_add) >> SCALEBITS];\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
881 g = cm[(y + g_add) >> SCALEBITS];\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
882 b = cm[(y + b_add) >> SCALEBITS];\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
883 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
884 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
885 #define YUV_TO_RGB1(cb1, cr1)\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
886 {\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
887 cb = (cb1) - 128;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
888 cr = (cr1) - 128;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
889 r_add = FIX(1.40200) * cr + ONE_HALF;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
890 g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
891 b_add = FIX(1.77200) * cb + ONE_HALF;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
892 } |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
893 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
894 #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
|
895 {\ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
896 y = (y1) << SCALEBITS;\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
897 r = cm[(y + r_add) >> SCALEBITS];\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
898 g = cm[(y + g_add) >> SCALEBITS];\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
899 b = cm[(y + b_add) >> SCALEBITS];\ |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
900 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
901 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
902 #define Y_CCIR_TO_JPEG(y)\ |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
903 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
|
904 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
905 #define Y_JPEG_TO_CCIR(y)\ |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
906 (((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
|
907 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
908 #define C_CCIR_TO_JPEG(y)\ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
909 cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS] |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
910 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
911 /* NOTE: the clamp is really necessary! */ |
| 1282 | 912 static inline int C_JPEG_TO_CCIR(int y) { |
| 913 y = (((y - 128) * FIX(112.0/127.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS); | |
| 914 if (y < 16) | |
| 915 y = 16; | |
| 916 return y; | |
| 917 } | |
| 918 | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
919 |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
920 #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
|
921 ((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
|
922 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
|
923 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
924 #define RGB_TO_U(r1, g1, b1, shift)\ |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
925 (((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
926 FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
927 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
928 #define RGB_TO_V(r1, g1, b1, shift)\ |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
929 (((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
930 FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
931 |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
932 #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
|
933 ((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
|
934 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
|
935 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
936 #define RGB_TO_U_CCIR(r1, g1, b1, shift)\ |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
937 (((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
938 FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
939 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
940 #define RGB_TO_V_CCIR(r1, g1, b1, shift)\ |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
941 (((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
942 FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
943 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
944 static uint8_t y_ccir_to_jpeg[256]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
945 static uint8_t y_jpeg_to_ccir[256]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
946 static uint8_t c_ccir_to_jpeg[256]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
947 static uint8_t c_jpeg_to_ccir[256]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
948 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
949 /* init various conversion tables */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
950 static void img_convert_init(void) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
951 { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
952 int i; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
953 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
954 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
955 for(i = 0;i < 256; i++) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
956 y_ccir_to_jpeg[i] = Y_CCIR_TO_JPEG(i); |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
957 y_jpeg_to_ccir[i] = Y_JPEG_TO_CCIR(i); |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
958 c_ccir_to_jpeg[i] = C_CCIR_TO_JPEG(i); |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
959 c_jpeg_to_ccir[i] = C_JPEG_TO_CCIR(i); |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
960 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
961 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
962 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
963 /* apply to each pixel the given table */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
964 static void img_apply_table(uint8_t *dst, int dst_wrap, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
965 const uint8_t *src, int src_wrap, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
966 int width, int height, const uint8_t *table1) |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
967 { |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
968 int n; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
969 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
|
970 uint8_t *d; |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
971 const uint8_t *table; |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
972 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
973 table = table1; |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
974 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
|
975 s = src; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
976 d = dst; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
977 n = width; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
978 while (n >= 4) { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
979 d[0] = table[s[0]]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
980 d[1] = table[s[1]]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
981 d[2] = table[s[2]]; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
982 d[3] = table[s[3]]; |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
983 d += 4; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
984 s += 4; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
985 n -= 4; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
986 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
987 while (n > 0) { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
988 d[0] = table[s[0]]; |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
989 d++; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
990 s++; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
991 n--; |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
992 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
993 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
|
994 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
|
995 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
996 } |
|
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
997 |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
998 /* XXX: use generic filter ? */ |
| 1205 | 999 /* XXX: in most cases, the sampling position is incorrect */ |
| 1000 | |
| 1001 /* 4x1 -> 1x1 */ | |
| 1002 static void shrink41(uint8_t *dst, int dst_wrap, | |
| 1003 const uint8_t *src, int src_wrap, | |
| 1004 int width, int height) | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1005 { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1006 int w; |
| 1205 | 1007 const uint8_t *s; |
| 1008 uint8_t *d; | |
| 1009 | |
| 1010 for(;height > 0; height--) { | |
| 1011 s = src; | |
| 1012 d = dst; | |
| 1013 for(w = width;w > 0; w--) { | |
| 1014 d[0] = (s[0] + s[1] + s[2] + s[3] + 2) >> 2; | |
| 1015 s += 4; | |
| 1016 d++; | |
| 1017 } | |
| 1018 src += src_wrap; | |
| 1019 dst += dst_wrap; | |
| 1020 } | |
| 1021 } | |
| 1022 | |
| 1023 /* 2x1 -> 1x1 */ | |
| 1024 static void shrink21(uint8_t *dst, int dst_wrap, | |
| 1025 const uint8_t *src, int src_wrap, | |
| 1026 int width, int height) | |
| 1027 { | |
| 1028 int w; | |
| 1029 const uint8_t *s; | |
| 1030 uint8_t *d; | |
| 1031 | |
| 1032 for(;height > 0; height--) { | |
| 1033 s = src; | |
| 1034 d = dst; | |
| 1035 for(w = width;w > 0; w--) { | |
| 1036 d[0] = (s[0] + s[1]) >> 1; | |
| 1037 s += 2; | |
| 1038 d++; | |
| 1039 } | |
| 1040 src += src_wrap; | |
| 1041 dst += dst_wrap; | |
| 1042 } | |
| 1043 } | |
| 1044 | |
| 1045 /* 1x2 -> 1x1 */ | |
| 1046 static void shrink12(uint8_t *dst, int dst_wrap, | |
| 1047 const uint8_t *src, int src_wrap, | |
| 1048 int width, int height) | |
| 1049 { | |
| 1050 int w; | |
| 1051 uint8_t *d; | |
| 1052 const uint8_t *s1, *s2; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1053 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1054 for(;height > 0; height--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1055 s1 = src; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1056 s2 = s1 + src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1057 d = dst; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1058 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
|
1059 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
|
1060 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
|
1061 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
|
1062 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
|
1063 s1 += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1064 s2 += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1065 d += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1066 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1067 for(;w > 0; w--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1068 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
|
1069 s1++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1070 s2++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1071 d++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1072 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1073 src += 2 * src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1074 dst += dst_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1075 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1076 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1077 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1078 /* 2x2 -> 1x1 */ |
| 1064 | 1079 static void shrink22(uint8_t *dst, int dst_wrap, |
| 1205 | 1080 const 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
|
1081 int width, int height) |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1082 { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1083 int w; |
| 1205 | 1084 const uint8_t *s1, *s2; |
| 1085 uint8_t *d; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1086 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1087 for(;height > 0; height--) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1088 s1 = src; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1089 s2 = s1 + src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1090 d = dst; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1091 for(w = width;w >= 4; w-=4) { |
|
1206
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
1092 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2; |
|
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
1093 d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2; |
|
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
1094 d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2; |
|
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
1095 d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1096 s1 += 8; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1097 s2 += 8; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1098 d += 4; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1099 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1100 for(;w > 0; w--) { |
|
1206
fd676abc754c
loss fixes (thanks to Daniel Serpell) - shrink22 fix
bellard
parents:
1205
diff
changeset
|
1101 d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1102 s1 += 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1103 s2 += 2; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1104 d++; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1105 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1106 src += 2 * src_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1107 dst += dst_wrap; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1108 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1109 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1110 |
| 1205 | 1111 /* 4x4 -> 1x1 */ |
| 1112 static void shrink44(uint8_t *dst, int dst_wrap, | |
| 1113 const uint8_t *src, int src_wrap, | |
|
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1114 int width, int height) |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1115 { |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1116 int w; |
| 1205 | 1117 const uint8_t *s1, *s2, *s3, *s4; |
| 1118 uint8_t *d; | |
|
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1119 |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1120 for(;height > 0; height--) { |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1121 s1 = src; |
| 1205 | 1122 s2 = s1 + src_wrap; |
| 1123 s3 = s2 + src_wrap; | |
| 1124 s4 = s3 + src_wrap; | |
|
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1125 d = dst; |
| 1205 | 1126 for(w = width;w > 0; w--) { |
| 1127 d[0] = (s1[0] + s1[1] + s1[2] + s1[3] + | |
| 1128 s2[0] + s2[1] + s2[2] + s2[3] + | |
| 1129 s3[0] + s3[1] + s3[2] + s3[3] + | |
| 1130 s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4; | |
| 1131 s1 += 4; | |
| 1132 s2 += 4; | |
| 1133 s3 += 4; | |
| 1134 s4 += 4; | |
|
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1135 d++; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1136 } |
| 1205 | 1137 src += 4 * src_wrap; |
| 1138 dst += dst_wrap; | |
| 1139 } | |
| 1140 } | |
| 1141 | |
| 1142 static void grow21_line(uint8_t *dst, const uint8_t *src, | |
| 1143 int width) | |
| 1144 { | |
| 1145 int w; | |
| 1146 const uint8_t *s1; | |
| 1147 uint8_t *d; | |
| 1148 | |
| 1149 s1 = src; | |
| 1150 d = dst; | |
| 1151 for(w = width;w >= 4; w-=4) { | |
| 1152 d[1] = d[0] = s1[0]; | |
| 1153 d[3] = d[2] = s1[1]; | |
| 1154 s1 += 2; | |
| 1155 d += 4; | |
| 1156 } | |
| 1157 for(;w >= 2; w -= 2) { | |
| 1158 d[1] = d[0] = s1[0]; | |
| 1159 s1 ++; | |
| 1160 d += 2; | |
| 1161 } | |
| 1162 /* only needed if width is not a multiple of two */ | |
| 1163 /* XXX: veryfy that */ | |
| 1164 if (w) { | |
| 1165 d[0] = s1[0]; | |
| 1166 } | |
| 1167 } | |
| 1168 | |
| 1169 static void grow41_line(uint8_t *dst, const uint8_t *src, | |
| 1170 int width) | |
| 1171 { | |
| 1172 int w, v; | |
| 1173 const uint8_t *s1; | |
| 1174 uint8_t *d; | |
| 1175 | |
| 1176 s1 = src; | |
| 1177 d = dst; | |
| 1178 for(w = width;w >= 4; w-=4) { | |
| 1179 v = s1[0]; | |
| 1180 d[0] = v; | |
| 1181 d[1] = v; | |
| 1182 d[2] = v; | |
| 1183 d[3] = v; | |
| 1184 s1 ++; | |
| 1185 d += 4; | |
| 1186 } | |
| 1187 } | |
| 1188 | |
| 1189 /* 1x1 -> 2x1 */ | |
| 1190 static void grow21(uint8_t *dst, int dst_wrap, | |
| 1191 const uint8_t *src, int src_wrap, | |
| 1192 int width, int height) | |
| 1193 { | |
| 1194 for(;height > 0; height--) { | |
| 1195 grow21_line(dst, src, width); | |
| 1196 src += src_wrap; | |
| 1197 dst += dst_wrap; | |
| 1198 } | |
| 1199 } | |
| 1200 | |
| 1201 /* 1x1 -> 2x2 */ | |
| 1202 static void grow22(uint8_t *dst, int dst_wrap, | |
| 1203 const uint8_t *src, int src_wrap, | |
| 1204 int width, int height) | |
| 1205 { | |
| 1206 for(;height > 0; height--) { | |
| 1207 grow21_line(dst, src, width); | |
|
576
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1208 if (height%2) |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1209 src += src_wrap; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1210 dst += dst_wrap; |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1211 } |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1212 } |
|
9aa5f0d0124e
YUV410P to YUV420P patch by Fran?ois Revol <revol at free dot fr>
michaelni
parents:
440
diff
changeset
|
1213 |
| 1205 | 1214 /* 1x1 -> 4x1 */ |
| 1215 static void grow41(uint8_t *dst, int dst_wrap, | |
| 1216 const uint8_t *src, int src_wrap, | |
| 1217 int width, int height) | |
| 1218 { | |
| 1219 for(;height > 0; height--) { | |
| 1220 grow41_line(dst, src, width); | |
| 1221 src += src_wrap; | |
| 1222 dst += dst_wrap; | |
| 1223 } | |
| 1224 } | |
| 1225 | |
| 1226 /* 1x1 -> 4x4 */ | |
| 1227 static void grow44(uint8_t *dst, int dst_wrap, | |
| 1228 const uint8_t *src, int src_wrap, | |
| 1229 int width, int height) | |
| 1230 { | |
| 1231 for(;height > 0; height--) { | |
| 1232 grow41_line(dst, src, width); | |
| 1233 if ((height & 3) == 1) | |
| 1234 src += src_wrap; | |
| 1235 dst += dst_wrap; | |
| 1236 } | |
| 1237 } | |
| 1238 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1239 /* 1x2 -> 2x1 */ |
| 1064 | 1240 static void conv411(uint8_t *dst, int dst_wrap, |
| 1205 | 1241 const 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
|
1242 int width, int height) |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1243 { |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1244 int w, c; |
| 1205 | 1245 const uint8_t *s1, *s2; |
| 1246 uint8_t *d; | |
|
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1247 |
| 1166 | 1248 width>>=1; |
| 1249 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1250 for(;height > 0; height--) { |
|
736
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1251 s1 = src; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1252 s2 = src + src_wrap; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1253 d = dst; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1254 for(w = width;w > 0; w--) { |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1255 c = (s1[0] + s2[0]) >> 1; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1256 d[0] = c; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1257 d[1] = c; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1258 s1++; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1259 s2++; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1260 d += 2; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1261 } |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1262 src += src_wrap * 2; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1263 dst += dst_wrap; |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1264 } |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1265 } |
|
918756bffda2
minimum support for YUV411P (new combined scaler/converter will handle that better...)
bellard
parents:
583
diff
changeset
|
1266 |
| 1204 | 1267 /* XXX: add jpeg quantize code */ |
| 1268 | |
| 1269 #define TRANSP_INDEX (6*6*6) | |
| 1270 | |
| 1271 /* this is maybe slow, but allows for extensions */ | |
| 1272 static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b) | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1273 { |
| 1204 | 1274 return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6)); |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1275 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1276 |
| 1204 | 1277 static void build_rgb_palette(uint8_t *palette, int has_alpha) |
| 1278 { | |
| 1279 uint32_t *pal; | |
| 1280 static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff }; | |
| 1281 int i, r, g, b; | |
| 1282 | |
| 1283 pal = (uint32_t *)palette; | |
| 1284 i = 0; | |
| 1285 for(r = 0; r < 6; r++) { | |
| 1286 for(g = 0; g < 6; g++) { | |
| 1287 for(b = 0; b < 6; b++) { | |
| 1288 pal[i++] = (0xff << 24) | (pal_value[r] << 16) | | |
| 1289 (pal_value[g] << 8) | pal_value[b]; | |
| 1290 } | |
| 1291 } | |
| 1292 } | |
| 1293 if (has_alpha) | |
| 1294 pal[i++] = 0; | |
| 1295 while (i < 256) | |
| 1296 pal[i++] = 0xff000000; | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1297 } |
| 583 | 1298 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1299 /* copy bit n to bits 0 ... n - 1 */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1300 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
|
1301 { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1302 int mask; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1303 mask = (1 << n) - 1; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1304 return (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1305 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1306 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1307 /* rgb555 handling */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1308 |
| 1204 | 1309 #define RGB_NAME rgb555 |
| 1310 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1311 #define RGB_IN(r, g, b, s)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1312 {\ |
| 1064 | 1313 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
|
1314 r = bitcopy_n(v >> (10 - 3), 3);\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1315 g = bitcopy_n(v >> (5 - 3), 3);\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1316 b = bitcopy_n(v << 3, 3);\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1317 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1318 |
| 1204 | 1319 #define RGBA_IN(r, g, b, a, s)\ |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1320 {\ |
| 1204 | 1321 unsigned int v = ((const uint16_t *)(s))[0];\ |
| 1322 r = bitcopy_n(v >> (10 - 3), 3);\ | |
| 1323 g = bitcopy_n(v >> (5 - 3), 3);\ | |
| 1324 b = bitcopy_n(v << 3, 3);\ | |
| 1209 | 1325 a = (-(v >> 15)) & 0xff;\ |
| 1204 | 1326 } |
| 1327 | |
| 1328 #define RGBA_OUT(d, r, g, b, a)\ | |
| 1329 {\ | |
| 1330 ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | \ | |
| 1331 ((a << 8) & 0x8000);\ | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1332 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1333 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1334 #define BPP 2 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1335 |
| 1204 | 1336 #include "imgconvert_template.h" |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1337 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1338 /* rgb565 handling */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1339 |
| 1204 | 1340 #define RGB_NAME rgb565 |
| 1341 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1342 #define RGB_IN(r, g, b, s)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1343 {\ |
| 1064 | 1344 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
|
1345 r = bitcopy_n(v >> (11 - 3), 3);\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1346 g = bitcopy_n(v >> (5 - 2), 2);\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1347 b = bitcopy_n(v << 3, 3);\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1348 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1349 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1350 #define RGB_OUT(d, r, g, b)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1351 {\ |
| 1064 | 1352 ((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
|
1353 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1354 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1355 #define BPP 2 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1356 |
| 1204 | 1357 #include "imgconvert_template.h" |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1358 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1359 /* bgr24 handling */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1360 |
| 1204 | 1361 #define RGB_NAME bgr24 |
| 1362 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1363 #define RGB_IN(r, g, b, s)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1364 {\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1365 b = (s)[0];\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1366 g = (s)[1];\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1367 r = (s)[2];\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1368 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1369 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1370 #define RGB_OUT(d, r, g, b)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1371 {\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1372 (d)[0] = b;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1373 (d)[1] = g;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1374 (d)[2] = r;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1375 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1376 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1377 #define BPP 3 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1378 |
| 1204 | 1379 #include "imgconvert_template.h" |
| 583 | 1380 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1381 #undef RGB_IN |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1382 #undef RGB_OUT |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1383 #undef BPP |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1384 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1385 /* rgb24 handling */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1386 |
| 1204 | 1387 #define RGB_NAME rgb24 |
| 1388 #define FMT_RGB24 | |
| 1389 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1390 #define RGB_IN(r, g, b, s)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1391 {\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1392 r = (s)[0];\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1393 g = (s)[1];\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1394 b = (s)[2];\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1395 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1396 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1397 #define RGB_OUT(d, r, g, b)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1398 {\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1399 (d)[0] = r;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1400 (d)[1] = g;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1401 (d)[2] = b;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1402 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1403 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1404 #define BPP 3 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1405 |
| 1204 | 1406 #include "imgconvert_template.h" |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1407 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1408 /* rgba32 handling */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1409 |
| 1204 | 1410 #define RGB_NAME rgba32 |
| 1411 #define FMT_RGBA32 | |
| 1412 | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1413 #define RGB_IN(r, g, b, s)\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1414 {\ |
| 1064 | 1415 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
|
1416 r = (v >> 16) & 0xff;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1417 g = (v >> 8) & 0xff;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1418 b = v & 0xff;\ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1419 } |
| 583 | 1420 |
| 1204 | 1421 #define RGBA_IN(r, g, b, a, s)\ |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1422 {\ |
| 1204 | 1423 unsigned int v = ((const uint32_t *)(s))[0];\ |
| 1424 a = (v >> 24) & 0xff;\ | |
| 1425 r = (v >> 16) & 0xff;\ | |
| 1426 g = (v >> 8) & 0xff;\ | |
| 1427 b = v & 0xff;\ | |
| 1428 } | |
| 1429 | |
| 1430 #define RGBA_OUT(d, r, g, b, a)\ | |
| 1431 {\ | |
| 1432 ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;\ | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1433 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1434 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1435 #define BPP 4 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1436 |
| 1204 | 1437 #include "imgconvert_template.h" |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1438 |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1439 static void mono_to_gray(AVPicture *dst, const AVPicture *src, |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1440 int width, int height, int xor_mask) |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1441 { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1442 const unsigned char *p; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1443 unsigned char *q; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1444 int v, dst_wrap, src_wrap; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1445 int y, w; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1446 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1447 p = src->data[0]; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1448 src_wrap = src->linesize[0] - ((width + 7) >> 3); |
|
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 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
|
1451 dst_wrap = dst->linesize[0] - width; |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1452 for(y=0;y<height;y++) { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1453 w = width; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1454 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
|
1455 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
|
1456 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
|
1457 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
|
1458 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
|
1459 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
|
1460 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
|
1461 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
|
1462 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
|
1463 q[7] = -((v >> 0) & 1); |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1464 w -= 8; |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1465 q += 8; |
| 583 | 1466 } |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1467 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
|
1468 v = *p++ ^ xor_mask; |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1469 do { |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1470 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
|
1471 q++; |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1472 v <<= 1; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1473 } while (--w); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1474 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1475 p += src_wrap; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1476 q += dst_wrap; |
| 583 | 1477 } |
| 1478 } | |
| 1479 | |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1480 static void monowhite_to_gray(AVPicture *dst, const AVPicture *src, |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1481 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
|
1482 { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1483 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
|
1484 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1485 |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1486 static void monoblack_to_gray(AVPicture *dst, const AVPicture *src, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1487 int width, int height) |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1488 { |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1489 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
|
1490 } |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1491 |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1492 static void gray_to_mono(AVPicture *dst, const AVPicture *src, |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1493 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
|
1494 { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1495 int n; |
| 1064 | 1496 const uint8_t *s; |
| 1497 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
|
1498 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
|
1499 |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1500 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
|
1501 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
|
1502 |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1503 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
|
1504 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
|
1505 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1506 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
|
1507 n = width; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1508 while (n >= 8) { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1509 v = 0; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1510 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
|
1511 b = s[0]; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1512 s++; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1513 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
|
1514 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1515 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
|
1516 d++; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1517 n -= 8; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1518 } |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1519 if (n > 0) { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1520 n1 = n; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1521 v = 0; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1522 while (n > 0) { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1523 b = s[0]; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1524 s++; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1525 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
|
1526 n--; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1527 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1528 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
|
1529 d++; |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1530 } |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1531 s += src_wrap; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1532 d += dst_wrap; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1533 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1534 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1535 |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1536 static void gray_to_monowhite(AVPicture *dst, const AVPicture *src, |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1537 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
|
1538 { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1539 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
|
1540 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1541 |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1542 static void gray_to_monoblack(AVPicture *dst, const AVPicture *src, |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1543 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
|
1544 { |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1545 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
|
1546 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1547 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1548 typedef struct ConvertEntry { |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1549 void (*convert)(AVPicture *dst, |
|
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1550 const AVPicture *src, int width, int height); |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1551 } ConvertEntry; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1552 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1553 /* Add each new convertion function in this table. In order to be able |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1554 to convert from any format to any format, the following constraints |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1555 must be satisfied: |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1556 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1557 - all FF_COLOR_RGB formats must convert to and from PIX_FMT_RGB24 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1558 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1559 - all FF_COLOR_GRAY formats must convert to and from PIX_FMT_GRAY8 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1560 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1561 - all FF_COLOR_RGB formats with alpha must convert to and from PIX_FMT_RGBA32 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1562 |
| 1205 | 1563 - PIX_FMT_YUV444P and PIX_FMT_YUVJ444P must convert to and from |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1564 PIX_FMT_RGB24. |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1565 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1566 - PIX_FMT_422 must convert to and from PIX_FMT_422P. |
| 1205 | 1567 |
| 1568 The other conversion functions are just optimisations for common cases. | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1569 */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1570 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
|
1571 [PIX_FMT_YUV420P] = { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1572 [PIX_FMT_RGB555] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1573 .convert = yuv420p_to_rgb555 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1574 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1575 [PIX_FMT_RGB565] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1576 .convert = yuv420p_to_rgb565 |
|
989
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 [PIX_FMT_BGR24] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1579 .convert = yuv420p_to_bgr24 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1580 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1581 [PIX_FMT_RGB24] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1582 .convert = yuv420p_to_rgb24 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1583 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1584 [PIX_FMT_RGBA32] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1585 .convert = yuv420p_to_rgba32 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1586 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1587 }, |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1588 [PIX_FMT_YUV422P] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1589 [PIX_FMT_YUV422] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1590 .convert = yuv422p_to_yuv422, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1591 }, |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1592 [PIX_FMT_UYVY422] = { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1593 .convert = yuv422p_to_uyvy422, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1594 }, |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1595 }, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1596 [PIX_FMT_YUV444P] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1597 [PIX_FMT_RGB24] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1598 .convert = yuv444p_to_rgb24 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1599 }, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1600 }, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1601 [PIX_FMT_YUVJ420P] = { |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1602 [PIX_FMT_RGB555] = { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1603 .convert = yuvj420p_to_rgb555 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1604 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1605 [PIX_FMT_RGB565] = { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1606 .convert = yuvj420p_to_rgb565 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1607 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1608 [PIX_FMT_BGR24] = { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1609 .convert = yuvj420p_to_bgr24 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1610 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1611 [PIX_FMT_RGB24] = { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1612 .convert = yuvj420p_to_rgb24 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1613 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1614 [PIX_FMT_RGBA32] = { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1615 .convert = yuvj420p_to_rgba32 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1616 }, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1617 }, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1618 [PIX_FMT_YUVJ444P] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1619 [PIX_FMT_RGB24] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1620 .convert = yuvj444p_to_rgb24 |
|
989
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 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1623 [PIX_FMT_YUV422] = { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1624 [PIX_FMT_YUV420P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1625 .convert = yuv422_to_yuv420p, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1626 }, |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1627 [PIX_FMT_YUV422P] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1628 .convert = yuv422_to_yuv422p, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1629 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1630 }, |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1631 [PIX_FMT_UYVY422] = { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1632 [PIX_FMT_YUV420P] = { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1633 .convert = uyvy422_to_yuv420p, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1634 }, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1635 [PIX_FMT_YUV422P] = { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1636 .convert = uyvy422_to_yuv422p, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1637 }, |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1638 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1639 [PIX_FMT_RGB24] = { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1640 [PIX_FMT_YUV420P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1641 .convert = rgb24_to_yuv420p |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1642 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1643 [PIX_FMT_RGB565] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1644 .convert = rgb24_to_rgb565 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1645 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1646 [PIX_FMT_RGB555] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1647 .convert = rgb24_to_rgb555 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1648 }, |
| 1204 | 1649 [PIX_FMT_RGBA32] = { |
| 1650 .convert = rgb24_to_rgba32 | |
| 1651 }, | |
| 1652 [PIX_FMT_BGR24] = { | |
| 1653 .convert = rgb24_to_bgr24 | |
| 1654 }, | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1655 [PIX_FMT_GRAY8] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1656 .convert = rgb24_to_gray |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1657 }, |
| 1204 | 1658 [PIX_FMT_PAL8] = { |
| 1055 | 1659 .convert = rgb24_to_pal8 |
| 1660 }, | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1661 [PIX_FMT_YUV444P] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1662 .convert = rgb24_to_yuv444p |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1663 }, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1664 [PIX_FMT_YUVJ420P] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1665 .convert = rgb24_to_yuvj420p |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1666 }, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1667 [PIX_FMT_YUVJ444P] = { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1668 .convert = rgb24_to_yuvj444p |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1669 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1670 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1671 [PIX_FMT_RGBA32] = { |
| 1204 | 1672 [PIX_FMT_RGB24] = { |
| 1673 .convert = rgba32_to_rgb24 | |
| 1674 }, | |
| 1675 [PIX_FMT_RGB555] = { | |
| 1676 .convert = rgba32_to_rgb555 | |
| 1677 }, | |
| 1678 [PIX_FMT_PAL8] = { | |
| 1679 .convert = rgba32_to_pal8 | |
| 1680 }, | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1681 [PIX_FMT_YUV420P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1682 .convert = rgba32_to_yuv420p |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1683 }, |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1684 [PIX_FMT_GRAY8] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1685 .convert = rgba32_to_gray |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1686 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1687 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1688 [PIX_FMT_BGR24] = { |
| 1204 | 1689 [PIX_FMT_RGB24] = { |
| 1690 .convert = bgr24_to_rgb24 | |
| 1691 }, | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1692 [PIX_FMT_YUV420P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1693 .convert = bgr24_to_yuv420p |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1694 }, |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1695 [PIX_FMT_GRAY8] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1696 .convert = bgr24_to_gray |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1697 }, |
|
989
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 [PIX_FMT_RGB555] = { |
| 1204 | 1700 [PIX_FMT_RGB24] = { |
| 1701 .convert = rgb555_to_rgb24 | |
| 1702 }, | |
| 1703 [PIX_FMT_RGBA32] = { | |
| 1704 .convert = rgb555_to_rgba32 | |
| 1705 }, | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1706 [PIX_FMT_YUV420P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1707 .convert = rgb555_to_yuv420p |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1708 }, |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1709 [PIX_FMT_GRAY8] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1710 .convert = rgb555_to_gray |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1711 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1712 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1713 [PIX_FMT_RGB565] = { |
| 1204 | 1714 [PIX_FMT_RGB24] = { |
| 1715 .convert = rgb565_to_rgb24 | |
| 1716 }, | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1717 [PIX_FMT_YUV420P] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1718 .convert = rgb565_to_yuv420p |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1719 }, |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1720 [PIX_FMT_GRAY8] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1721 .convert = rgb565_to_gray |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1722 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1723 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1724 [PIX_FMT_GRAY8] = { |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1725 [PIX_FMT_RGB555] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1726 .convert = gray_to_rgb555 |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1727 }, |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1728 [PIX_FMT_RGB565] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1729 .convert = gray_to_rgb565 |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1730 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1731 [PIX_FMT_RGB24] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1732 .convert = gray_to_rgb24 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1733 }, |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1734 [PIX_FMT_BGR24] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1735 .convert = gray_to_bgr24 |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1736 }, |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1737 [PIX_FMT_RGBA32] = { |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1738 .convert = gray_to_rgba32 |
|
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1739 }, |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1740 [PIX_FMT_MONOWHITE] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1741 .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
|
1742 }, |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1743 [PIX_FMT_MONOBLACK] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1744 .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
|
1745 }, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1746 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1747 [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
|
1748 [PIX_FMT_GRAY8] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1749 .convert = monowhite_to_gray |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1750 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1751 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1752 [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
|
1753 [PIX_FMT_GRAY8] = { |
|
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M?ns Rullg?rd))
michaelni
parents:
993
diff
changeset
|
1754 .convert = monoblack_to_gray |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1755 }, |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1756 }, |
| 1055 | 1757 [PIX_FMT_PAL8] = { |
| 1758 [PIX_FMT_RGB555] = { | |
| 1759 .convert = pal8_to_rgb555 | |
| 1760 }, | |
| 1761 [PIX_FMT_RGB565] = { | |
| 1762 .convert = pal8_to_rgb565 | |
| 1763 }, | |
| 1764 [PIX_FMT_BGR24] = { | |
| 1765 .convert = pal8_to_bgr24 | |
| 1766 }, | |
| 1767 [PIX_FMT_RGB24] = { | |
| 1768 .convert = pal8_to_rgb24 | |
| 1769 }, | |
| 1770 [PIX_FMT_RGBA32] = { | |
| 1771 .convert = pal8_to_rgba32 | |
| 1772 }, | |
| 1773 }, | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1774 }; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1775 |
| 1508 | 1776 int avpicture_alloc(AVPicture *picture, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1777 int pix_fmt, int width, int height) |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1778 { |
| 1057 | 1779 unsigned int size; |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1780 void *ptr; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1781 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1782 size = avpicture_get_size(pix_fmt, width, height); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1783 ptr = av_malloc(size); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1784 if (!ptr) |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1785 goto fail; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1786 avpicture_fill(picture, ptr, pix_fmt, width, height); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1787 return 0; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1788 fail: |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1789 memset(picture, 0, sizeof(AVPicture)); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1790 return -1; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1791 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1792 |
| 1508 | 1793 void avpicture_free(AVPicture *picture) |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1794 { |
|
1031
19de1445beb2
use av_malloc() functions - added av_strdup and av_realloc()
bellard
parents:
1028
diff
changeset
|
1795 av_free(picture->data[0]); |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1796 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1797 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1798 /* return true if yuv planar */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1799 static inline int is_yuv_planar(PixFmtInfo *ps) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1800 { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1801 return (ps->color_type == FF_COLOR_YUV || |
| 1204 | 1802 ps->color_type == FF_COLOR_YUV_JPEG) && |
| 1803 ps->pixel_type == FF_PIXEL_PLANAR; | |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1804 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1805 |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1806 /* 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
|
1807 int img_convert(AVPicture *dst, int dst_pix_fmt, |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
1808 const AVPicture *src, int src_pix_fmt, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1809 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
|
1810 { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1811 static int inited; |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1812 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
|
1813 PixFmtInfo *src_pix, *dst_pix; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1814 ConvertEntry *ce; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1815 AVPicture tmp1, *tmp = &tmp1; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1816 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1817 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
|
1818 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
|
1819 return -1; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1820 if (src_width <= 0 || src_height <= 0) |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1821 return 0; |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1822 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1823 if (!inited) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1824 inited = 1; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1825 img_convert_init(); |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1826 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1827 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1828 dst_width = src_width; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1829 dst_height = src_height; |
|
1022
d651df667898
added gray<->RGB functions - fixed rgb<->yuv functions for non RGB24 case
bellard
parents:
1020
diff
changeset
|
1830 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1831 dst_pix = &pix_fmt_info[dst_pix_fmt]; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1832 src_pix = &pix_fmt_info[src_pix_fmt]; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1833 if (src_pix_fmt == dst_pix_fmt) { |
| 1204 | 1834 /* no conversion needed: just copy */ |
| 1835 img_copy(dst, src, dst_pix_fmt, dst_width, dst_height); | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1836 return 0; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1837 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1838 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1839 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
|
1840 if (ce->convert) { |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1841 /* specific conversion routine */ |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1842 ce->convert(dst, src, dst_width, dst_height); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1843 return 0; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1844 } |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1845 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1846 /* gray to YUV */ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1847 if (is_yuv_planar(dst_pix) && |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1848 src_pix_fmt == PIX_FMT_GRAY8) { |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1849 int w, h, y; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1850 uint8_t *d; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1851 |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1852 if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { |
| 1204 | 1853 img_copy_plane(dst->data[0], dst->linesize[0], |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1854 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
|
1855 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
|
1856 } else { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1857 img_apply_table(dst->data[0], dst->linesize[0], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1858 src->data[0], src->linesize[0], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1859 dst_width, dst_height, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1860 y_jpeg_to_ccir); |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1861 } |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1862 /* fill U and V with 128 */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1863 w = dst_width; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1864 h = dst_height; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1865 w >>= dst_pix->x_chroma_shift; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1866 h >>= dst_pix->y_chroma_shift; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1867 for(i = 1; i <= 2; i++) { |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1868 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
|
1869 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
|
1870 memset(d, 128, w); |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1871 d += dst->linesize[i]; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1872 } |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1873 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1874 return 0; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1875 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1876 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1877 /* YUV to gray */ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1878 if (is_yuv_planar(src_pix) && |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1879 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
|
1880 if (src_pix->color_type == FF_COLOR_YUV_JPEG) { |
| 1204 | 1881 img_copy_plane(dst->data[0], dst->linesize[0], |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1882 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
|
1883 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
|
1884 } else { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1885 img_apply_table(dst->data[0], dst->linesize[0], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1886 src->data[0], src->linesize[0], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1887 dst_width, dst_height, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1888 y_ccir_to_jpeg); |
|
1202
8b49a7ee4e4e
YUV formats/gray formats are correctly defined - added format loss information - preliminary JPEG YUV formats support
bellard
parents:
1199
diff
changeset
|
1889 } |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1890 return 0; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1891 } |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1892 |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1893 /* YUV to YUV planar */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1894 if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) { |
| 1205 | 1895 int x_shift, y_shift, w, h, xy_shift; |
| 1064 | 1896 void (*resize_func)(uint8_t *dst, int dst_wrap, |
| 1205 | 1897 const uint8_t *src, int src_wrap, |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1898 int width, int height); |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1899 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1900 /* compute chroma size of the smallest dimensions */ |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1901 w = dst_width; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1902 h = dst_height; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1903 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
|
1904 w >>= dst_pix->x_chroma_shift; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1905 else |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1906 w >>= src_pix->x_chroma_shift; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1907 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
|
1908 h >>= dst_pix->y_chroma_shift; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1909 else |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1910 h >>= src_pix->y_chroma_shift; |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1911 |
|
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1912 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
|
1913 y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift); |
| 1205 | 1914 xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf); |
| 1915 /* there must be filters for conversion at least from and to | |
| 1916 YUV444 format */ | |
| 1917 switch(xy_shift) { | |
| 1918 case 0x00: | |
| 1204 | 1919 resize_func = img_copy_plane; |
| 1205 | 1920 break; |
| 1921 case 0x10: | |
| 1922 resize_func = shrink21; | |
| 1923 break; | |
| 1924 case 0x20: | |
| 1925 resize_func = shrink41; | |
| 1926 break; | |
| 1927 case 0x01: | |
| 1928 resize_func = shrink12; | |
| 1929 break; | |
| 1930 case 0x11: | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1931 resize_func = shrink22; |
| 1205 | 1932 break; |
| 1933 case 0x22: | |
| 1934 resize_func = shrink44; | |
| 1935 break; | |
| 1936 case 0xf0: | |
| 1937 resize_func = grow21; | |
| 1938 break; | |
| 1939 case 0xe0: | |
| 1940 resize_func = grow41; | |
| 1941 break; | |
| 1942 case 0xff: | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1943 resize_func = grow22; |
| 1205 | 1944 break; |
| 1945 case 0xee: | |
| 1946 resize_func = grow44; | |
| 1947 break; | |
| 1948 case 0xf1: | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1949 resize_func = conv411; |
| 1205 | 1950 break; |
| 1951 default: | |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1952 /* currently not handled */ |
| 1205 | 1953 goto no_chroma_filter; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1954 } |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1955 |
| 1204 | 1956 img_copy_plane(dst->data[0], dst->linesize[0], |
| 1957 src->data[0], src->linesize[0], | |
| 1958 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
|
1959 |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1960 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
|
1961 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
|
1962 src->data[i], src->linesize[i], |
| 1073 | 1963 dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift); |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1964 /* if yuv color space conversion is needed, we do it here on |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1965 the destination image */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1966 if (dst_pix->color_type != src_pix->color_type) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1967 const uint8_t *y_table, *c_table; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1968 if (dst_pix->color_type == FF_COLOR_YUV) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1969 y_table = y_jpeg_to_ccir; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1970 c_table = c_jpeg_to_ccir; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1971 } else { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1972 y_table = y_ccir_to_jpeg; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1973 c_table = c_ccir_to_jpeg; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1974 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1975 img_apply_table(dst->data[0], dst->linesize[0], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1976 dst->data[0], dst->linesize[0], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1977 dst_width, dst_height, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1978 y_table); |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1979 |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1980 for(i = 1;i <= 2; i++) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1981 img_apply_table(dst->data[i], dst->linesize[i], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1982 dst->data[i], dst->linesize[i], |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1983 dst_width>>dst_pix->x_chroma_shift, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1984 dst_height>>dst_pix->y_chroma_shift, |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1985 c_table); |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1986 } |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1987 return 0; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
1988 } |
| 1205 | 1989 no_chroma_filter: |
|
989
fe9083c56733
simplified code (need automatic testing) - added primitive new format support.
bellard
parents:
940
diff
changeset
|
1990 |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
1991 /* try to use an intermediate format */ |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1992 if (src_pix_fmt == PIX_FMT_YUV422 || |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1993 dst_pix_fmt == PIX_FMT_YUV422) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1994 /* specific case: convert to YUV422P first */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
1995 int_pix_fmt = PIX_FMT_YUV422P; |
|
2137
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1996 } else if (src_pix_fmt == PIX_FMT_UYVY422 || |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1997 dst_pix_fmt == PIX_FMT_UYVY422) { |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1998 /* specific case: convert to YUV422P first */ |
|
ef47c0b1ff28
UYVY support patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents:
1593
diff
changeset
|
1999 int_pix_fmt = PIX_FMT_YUV422P; |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2000 } else if ((src_pix->color_type == FF_COLOR_GRAY && |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2001 src_pix_fmt != PIX_FMT_GRAY8) || |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2002 (dst_pix->color_type == FF_COLOR_GRAY && |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2003 dst_pix_fmt != PIX_FMT_GRAY8)) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2004 /* gray8 is the normalized format */ |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2005 int_pix_fmt = PIX_FMT_GRAY8; |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2006 } else if ((is_yuv_planar(src_pix) && |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2007 src_pix_fmt != PIX_FMT_YUV444P && |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2008 src_pix_fmt != PIX_FMT_YUVJ444P)) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2009 /* yuv444 is the normalized format */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2010 if (src_pix->color_type == FF_COLOR_YUV_JPEG) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2011 int_pix_fmt = PIX_FMT_YUVJ444P; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2012 else |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2013 int_pix_fmt = PIX_FMT_YUV444P; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2014 } else if ((is_yuv_planar(dst_pix) && |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2015 dst_pix_fmt != PIX_FMT_YUV444P && |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2016 dst_pix_fmt != PIX_FMT_YUVJ444P)) { |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2017 /* yuv444 is the normalized format */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2018 if (dst_pix->color_type == FF_COLOR_YUV_JPEG) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2019 int_pix_fmt = PIX_FMT_YUVJ444P; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2020 else |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2021 int_pix_fmt = PIX_FMT_YUV444P; |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2022 } else { |
|
1203
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2023 /* the two formats are rgb or gray8 or yuv[j]444p */ |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2024 if (src_pix->is_alpha && dst_pix->is_alpha) |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2025 int_pix_fmt = PIX_FMT_RGBA32; |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2026 else |
|
80c73b9b0ba2
accurate YUV to RGB and RGB to YUV conversions - added comments
bellard
parents:
1202
diff
changeset
|
2027 int_pix_fmt = PIX_FMT_RGB24; |
|
993
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2028 } |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2029 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
|
2030 return -1; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2031 ret = -1; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2032 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
|
2033 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
|
2034 goto fail1; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2035 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
|
2036 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
|
2037 goto fail1; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2038 ret = 0; |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2039 fail1: |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2040 avpicture_free(tmp); |
|
895d3b01c6f4
added missing formats in all functions - added monoblack, monowhite and gray8 support for most conversions
bellard
parents:
989
diff
changeset
|
2041 return ret; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2042 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2043 |
| 1208 | 2044 /* NOTE: we scan all the pixels to have an exact information */ |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2045 static int get_alpha_info_pal8(const AVPicture *src, int width, int height) |
| 1208 | 2046 { |
| 2047 const unsigned char *p; | |
| 2048 int src_wrap, ret, x, y; | |
| 2049 unsigned int a; | |
| 2050 uint32_t *palette = (uint32_t *)src->data[1]; | |
| 2051 | |
| 2052 p = src->data[0]; | |
| 2053 src_wrap = src->linesize[0] - width; | |
| 2054 ret = 0; | |
| 2055 for(y=0;y<height;y++) { | |
| 2056 for(x=0;x<width;x++) { | |
| 2057 a = palette[p[0]] >> 24; | |
| 2058 if (a == 0x00) { | |
| 2059 ret |= FF_ALPHA_TRANSP; | |
| 2060 } else if (a != 0xff) { | |
| 2061 ret |= FF_ALPHA_SEMI_TRANSP; | |
| 2062 } | |
| 2063 p++; | |
| 2064 } | |
| 2065 p += src_wrap; | |
| 2066 } | |
| 2067 return ret; | |
| 2068 } | |
| 2069 | |
| 2070 /** | |
| 2071 * Tell if an image really has transparent alpha values. | |
| 2072 * @return ored mask of FF_ALPHA_xxx constants | |
| 2073 */ | |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2074 int img_get_alpha_info(const AVPicture *src, |
|
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2075 int pix_fmt, int width, int height) |
| 1208 | 2076 { |
| 2077 PixFmtInfo *pf = &pix_fmt_info[pix_fmt]; | |
| 2078 int ret; | |
| 2079 | |
| 2080 pf = &pix_fmt_info[pix_fmt]; | |
| 2081 /* no alpha can be represented in format */ | |
| 2082 if (!pf->is_alpha) | |
| 2083 return 0; | |
| 2084 switch(pix_fmt) { | |
| 2085 case PIX_FMT_RGBA32: | |
| 2086 ret = get_alpha_info_rgba32(src, width, height); | |
| 2087 break; | |
| 2088 case PIX_FMT_RGB555: | |
| 2089 ret = get_alpha_info_rgb555(src, width, height); | |
| 2090 break; | |
| 2091 case PIX_FMT_PAL8: | |
| 2092 ret = get_alpha_info_pal8(src, width, height); | |
| 2093 break; | |
| 2094 default: | |
| 2095 /* we do not know, so everything is indicated */ | |
| 2096 ret = FF_ALPHA_TRANSP | FF_ALPHA_SEMI_TRANSP; | |
| 2097 break; | |
| 2098 } | |
| 2099 return ret; | |
| 2100 } | |
| 801 | 2101 |
| 2102 #ifdef HAVE_MMX | |
| 2103 #define DEINT_INPLACE_LINE_LUM \ | |
| 2104 movd_m2r(lum_m4[0],mm0);\ | |
| 2105 movd_m2r(lum_m3[0],mm1);\ | |
| 2106 movd_m2r(lum_m2[0],mm2);\ | |
| 2107 movd_m2r(lum_m1[0],mm3);\ | |
| 2108 movd_m2r(lum[0],mm4);\ | |
| 2109 punpcklbw_r2r(mm7,mm0);\ | |
| 2110 movd_r2m(mm2,lum_m4[0]);\ | |
| 2111 punpcklbw_r2r(mm7,mm1);\ | |
| 2112 punpcklbw_r2r(mm7,mm2);\ | |
| 2113 punpcklbw_r2r(mm7,mm3);\ | |
| 2114 punpcklbw_r2r(mm7,mm4);\ | |
| 2115 paddw_r2r(mm3,mm1);\ | |
| 2116 psllw_i2r(1,mm2);\ | |
| 2117 paddw_r2r(mm4,mm0);\ | |
| 2118 psllw_i2r(2,mm1);\ | |
| 2119 paddw_r2r(mm6,mm2);\ | |
| 2120 paddw_r2r(mm2,mm1);\ | |
| 2121 psubusw_r2r(mm0,mm1);\ | |
| 2122 psrlw_i2r(3,mm1);\ | |
| 2123 packuswb_r2r(mm7,mm1);\ | |
| 2124 movd_r2m(mm1,lum_m2[0]); | |
| 2125 | |
| 2126 #define DEINT_LINE_LUM \ | |
| 2127 movd_m2r(lum_m4[0],mm0);\ | |
| 2128 movd_m2r(lum_m3[0],mm1);\ | |
| 2129 movd_m2r(lum_m2[0],mm2);\ | |
| 2130 movd_m2r(lum_m1[0],mm3);\ | |
| 2131 movd_m2r(lum[0],mm4);\ | |
| 2132 punpcklbw_r2r(mm7,mm0);\ | |
| 2133 punpcklbw_r2r(mm7,mm1);\ | |
| 2134 punpcklbw_r2r(mm7,mm2);\ | |
| 2135 punpcklbw_r2r(mm7,mm3);\ | |
| 2136 punpcklbw_r2r(mm7,mm4);\ | |
| 2137 paddw_r2r(mm3,mm1);\ | |
| 2138 psllw_i2r(1,mm2);\ | |
| 2139 paddw_r2r(mm4,mm0);\ | |
| 2140 psllw_i2r(2,mm1);\ | |
| 2141 paddw_r2r(mm6,mm2);\ | |
| 2142 paddw_r2r(mm2,mm1);\ | |
| 2143 psubusw_r2r(mm0,mm1);\ | |
| 2144 psrlw_i2r(3,mm1);\ | |
| 2145 packuswb_r2r(mm7,mm1);\ | |
| 2146 movd_r2m(mm1,dst[0]); | |
| 2147 #endif | |
| 2148 | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2149 /* filter parameters: [-1 4 2 4 -1] // 8 */ |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2150 static void deinterlace_line(uint8_t *dst, |
|
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2151 const uint8_t *lum_m4, const uint8_t *lum_m3, |
|
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2152 const uint8_t *lum_m2, const uint8_t *lum_m1, |
|
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2153 const uint8_t *lum, |
|
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2154 int size) |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2155 { |
| 801 | 2156 #ifndef HAVE_MMX |
| 1064 | 2157 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
|
2158 int sum; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2159 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2160 for(;size > 0;size--) { |
| 801 | 2161 sum = -lum_m4[0]; |
| 2162 sum += lum_m3[0] << 2; | |
| 2163 sum += lum_m2[0] << 1; | |
| 2164 sum += lum_m1[0] << 2; | |
| 2165 sum += -lum[0]; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2166 dst[0] = cm[(sum + 4) >> 3]; |
| 801 | 2167 lum_m4++; |
| 2168 lum_m3++; | |
| 2169 lum_m2++; | |
| 2170 lum_m1++; | |
| 2171 lum++; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2172 dst++; |
| 801 | 2173 } |
| 2174 #else | |
| 2175 | |
| 1044 | 2176 { |
| 2177 mmx_t rounder; | |
| 2178 rounder.uw[0]=4; | |
| 2179 rounder.uw[1]=4; | |
| 2180 rounder.uw[2]=4; | |
| 2181 rounder.uw[3]=4; | |
| 2182 pxor_r2r(mm7,mm7); | |
| 2183 movq_m2r(rounder,mm6); | |
| 2184 } | |
| 801 | 2185 for (;size > 3; size-=4) { |
| 2186 DEINT_LINE_LUM | |
| 2187 lum_m4+=4; | |
| 2188 lum_m3+=4; | |
| 2189 lum_m2+=4; | |
| 2190 lum_m1+=4; | |
| 2191 lum+=4; | |
| 2192 dst+=4; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2193 } |
| 801 | 2194 #endif |
| 2195 } | |
| 1064 | 2196 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 | 2197 int size) |
| 2198 { | |
| 2199 #ifndef HAVE_MMX | |
| 1064 | 2200 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
| 801 | 2201 int sum; |
| 2202 | |
| 2203 for(;size > 0;size--) { | |
| 2204 sum = -lum_m4[0]; | |
| 2205 sum += lum_m3[0] << 2; | |
| 2206 sum += lum_m2[0] << 1; | |
| 2207 lum_m4[0]=lum_m2[0]; | |
| 2208 sum += lum_m1[0] << 2; | |
| 2209 sum += -lum[0]; | |
| 2210 lum_m2[0] = cm[(sum + 4) >> 3]; | |
| 2211 lum_m4++; | |
| 2212 lum_m3++; | |
| 2213 lum_m2++; | |
| 2214 lum_m1++; | |
| 2215 lum++; | |
| 2216 } | |
| 2217 #else | |
| 2218 | |
| 1044 | 2219 { |
| 2220 mmx_t rounder; | |
| 2221 rounder.uw[0]=4; | |
| 2222 rounder.uw[1]=4; | |
| 2223 rounder.uw[2]=4; | |
| 2224 rounder.uw[3]=4; | |
| 2225 pxor_r2r(mm7,mm7); | |
| 2226 movq_m2r(rounder,mm6); | |
| 2227 } | |
| 801 | 2228 for (;size > 3; size-=4) { |
| 2229 DEINT_INPLACE_LINE_LUM | |
| 2230 lum_m4+=4; | |
| 2231 lum_m3+=4; | |
| 2232 lum_m2+=4; | |
| 2233 lum_m1+=4; | |
| 2234 lum+=4; | |
| 2235 } | |
| 2236 #endif | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2237 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2238 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2239 /* 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
|
2240 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
|
2241 against the top field. */ |
| 1064 | 2242 static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap, |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2243 const uint8_t *src1, int src_wrap, |
| 801 | 2244 int width, int height) |
| 2245 { | |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2246 const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2; |
| 801 | 2247 int y; |
| 2248 | |
| 2249 src_m2 = src1; | |
| 2250 src_m1 = src1; | |
| 2251 src_0=&src_m1[src_wrap]; | |
| 2252 src_p1=&src_0[src_wrap]; | |
| 2253 src_p2=&src_p1[src_wrap]; | |
| 2254 for(y=0;y<(height-2);y+=2) { | |
| 2255 memcpy(dst,src_m1,width); | |
| 2256 dst += dst_wrap; | |
| 2257 deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width); | |
| 2258 src_m2 = src_0; | |
| 2259 src_m1 = src_p1; | |
| 2260 src_0 = src_p2; | |
| 2261 src_p1 += 2*src_wrap; | |
| 2262 src_p2 += 2*src_wrap; | |
| 2263 dst += dst_wrap; | |
| 2264 } | |
| 2265 memcpy(dst,src_m1,width); | |
| 2266 dst += dst_wrap; | |
| 2267 /* do last line */ | |
| 2268 deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width); | |
| 2269 } | |
| 2270 | |
| 1064 | 2271 static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap, |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2272 int width, int height) |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2273 { |
| 1064 | 2274 uint8_t *src_m1, *src_0, *src_p1, *src_p2; |
| 801 | 2275 int y; |
| 1064 | 2276 uint8_t *buf; |
| 2277 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
|
2278 |
| 801 | 2279 src_m1 = src1; |
| 2280 memcpy(buf,src_m1,width); | |
| 2281 src_0=&src_m1[src_wrap]; | |
| 2282 src_p1=&src_0[src_wrap]; | |
| 2283 src_p2=&src_p1[src_wrap]; | |
| 2284 for(y=0;y<(height-2);y+=2) { | |
| 2285 deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width); | |
| 2286 src_m1 = src_p1; | |
| 2287 src_0 = src_p2; | |
| 2288 src_p1 += 2*src_wrap; | |
| 2289 src_p2 += 2*src_wrap; | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2290 } |
| 801 | 2291 /* do last line */ |
| 2292 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
|
2293 av_free(buf); |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2294 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2295 |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2296 |
| 801 | 2297 /* deinterlace - if not supported return -1 */ |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2298 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, |
| 0 | 2299 int pix_fmt, int width, int height) |
| 2300 { | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2301 int i; |
| 0 | 2302 |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2303 if (pix_fmt != PIX_FMT_YUV420P && |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2304 pix_fmt != PIX_FMT_YUV422P && |
|
1425
f53d31c5eac9
* ffmpeg was *silently* rejecting to deinterlace NTSC DV. The problem
romansh
parents:
1353
diff
changeset
|
2305 pix_fmt != PIX_FMT_YUV444P && |
|
f53d31c5eac9
* ffmpeg was *silently* rejecting to deinterlace NTSC DV. The problem
romansh
parents:
1353
diff
changeset
|
2306 pix_fmt != PIX_FMT_YUV411P) |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2307 return -1; |
| 801 | 2308 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
|
2309 return -1; |
| 801 | 2310 |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2311 for(i=0;i<3;i++) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2312 if (i == 1) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2313 switch(pix_fmt) { |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2314 case PIX_FMT_YUV420P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2315 width >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2316 height >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2317 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2318 case PIX_FMT_YUV422P: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2319 width >>= 1; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2320 break; |
|
1425
f53d31c5eac9
* ffmpeg was *silently* rejecting to deinterlace NTSC DV. The problem
romansh
parents:
1353
diff
changeset
|
2321 case PIX_FMT_YUV411P: |
|
f53d31c5eac9
* ffmpeg was *silently* rejecting to deinterlace NTSC DV. The problem
romansh
parents:
1353
diff
changeset
|
2322 width >>= 2; |
|
f53d31c5eac9
* ffmpeg was *silently* rejecting to deinterlace NTSC DV. The problem
romansh
parents:
1353
diff
changeset
|
2323 break; |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2324 default: |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2325 break; |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2326 } |
|
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2327 } |
| 801 | 2328 if (src == dst) { |
|
1488
766a2f4edbea
avcodec const correctness patch by (Drew Hess <dhess at ilm dot com>)
michaelni
parents:
1425
diff
changeset
|
2329 deinterlace_bottom_field_inplace(dst->data[i], dst->linesize[i], |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2330 width, height); |
| 801 | 2331 } else { |
| 2332 deinterlace_bottom_field(dst->data[i],dst->linesize[i], | |
| 2333 src->data[i], src->linesize[i], | |
| 2334 width, height); | |
| 2335 } | |
| 0 | 2336 } |
| 801 | 2337 #ifdef HAVE_MMX |
| 2338 emms(); | |
| 2339 #endif | |
|
52
1d796bdb2c2a
added 422P, 444P support - added deinterlace support - added xxx to RGB24 convertion
glantau
parents:
18
diff
changeset
|
2340 return 0; |
| 0 | 2341 } |
|
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
2342 |
|
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
2343 #undef FIX |
