Mercurial > mplayer.hg
comparison libswscale/swscale-test.c @ 30785:2c9cfd354ca0
Revert r30825, it was not supposed to be committed.
127.32L to me, beware when using git svn dcommit for committing stuff
to svn...
author | stefano |
---|---|
date | Thu, 04 Mar 2010 01:02:24 +0000 |
parents | 1bd54aea2896 |
children | 23c297eb1092 |
comparison
equal
deleted
inserted
replaced
30784:7e887f9d634d | 30785:2c9cfd354ca0 |
---|---|
23 #include <string.h> | 23 #include <string.h> |
24 #include <inttypes.h> | 24 #include <inttypes.h> |
25 #include <stdarg.h> | 25 #include <stdarg.h> |
26 | 26 |
27 #undef HAVE_AV_CONFIG_H | 27 #undef HAVE_AV_CONFIG_H |
28 | |
29 #include "libavutil/log.h" | |
30 #include "libavutil/mem.h" | 28 #include "libavutil/mem.h" |
31 #include "libavutil/avutil.h" | 29 #include "libavutil/avutil.h" |
32 #include "libavutil/lfg.h" | 30 #include "libavutil/lfg.h" |
33 #include "libavutil/pixdesc.h" | |
34 #include "swscale.h" | 31 #include "swscale.h" |
35 | 32 |
36 /* HACK Duplicated from swscale_internal.h. | 33 /* HACK Duplicated from swscale_internal.h. |
37 * Should be removed when a cleaner pixel format system exists. */ | 34 * Should be removed when a cleaner pixel format system exists. */ |
38 const char *sws_format_name(enum PixelFormat format); | 35 const char *sws_format_name(enum PixelFormat format); |
187 } | 184 } |
188 | 185 |
189 return res; | 186 return res; |
190 } | 187 } |
191 | 188 |
192 static void selfTest(uint8_t *ref[4], int refStride[4], enum PixelFormat srcFormat, enum PixelFormat dstFormat, int w, int h) | 189 static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h) |
193 { | 190 { |
194 const int flags[] = { SWS_FAST_BILINEAR, | 191 const int flags[] = { SWS_FAST_BILINEAR, |
195 SWS_BILINEAR, SWS_BICUBIC, | 192 SWS_BILINEAR, SWS_BICUBIC, |
196 SWS_X , SWS_POINT , SWS_AREA, 0 }; | 193 SWS_X , SWS_POINT , SWS_AREA, 0 }; |
197 const int srcW = w; | 194 const int srcW = w; |
198 const int srcH = h; | 195 const int srcH = h; |
199 int i, j, k, res = 0; | |
200 const int dstW[] = { srcW - srcW/3, srcW, srcW + srcW/3, 0 }; | 196 const int dstW[] = { srcW - srcW/3, srcW, srcW + srcW/3, 0 }; |
201 const int dstH[] = { srcH - srcH/3, srcH, srcH + srcH/3, 0 }; | 197 const int dstH[] = { srcH - srcH/3, srcH, srcH + srcH/3, 0 }; |
198 enum PixelFormat srcFormat, dstFormat; | |
199 | |
200 for (srcFormat = 0; srcFormat < PIX_FMT_NB; srcFormat++) { | |
201 if (!sws_isSupportedInput(srcFormat) || !sws_isSupportedOutput(srcFormat)) | |
202 continue; | |
203 | |
204 for (dstFormat = 0; dstFormat < PIX_FMT_NB; dstFormat++) { | |
205 int i, j, k; | |
206 int res = 0; | |
207 | |
208 if (!sws_isSupportedInput(dstFormat) || !sws_isSupportedOutput(dstFormat)) | |
209 continue; | |
202 | 210 |
203 printf("%s -> %s\n", | 211 printf("%s -> %s\n", |
204 sws_format_name(srcFormat), | 212 sws_format_name(srcFormat), |
205 sws_format_name(dstFormat)); | 213 sws_format_name(dstFormat)); |
206 fflush(stdout); | 214 fflush(stdout); |
207 | 215 |
208 for (i = 0; dstW[i] && !res; i++) | 216 for (i = 0; dstW[i] && !res; i++) |
209 for (j = 0; dstH[j] && !res; j++) | 217 for (j = 0; dstH[j] && !res; j++) |
210 for (k = 0; flags[k] && !res; k++) | 218 for (k = 0; flags[k] && !res; k++) |
211 res = doTest(ref, refStride, w, h, srcFormat, dstFormat, | 219 res = doTest(ref, refStride, w, h, srcFormat, dstFormat, |
212 srcW, srcH, dstW[i], dstH[j], flags[k]|SWS_PRINT_INFO); | 220 srcW, srcH, dstW[i], dstH[j], flags[k]); |
221 } | |
222 } | |
213 } | 223 } |
214 | 224 |
215 #define W 96 | 225 #define W 96 |
216 #define H 96 | 226 #define H 96 |
217 | 227 |
223 uint8_t *data = av_malloc (4*W*H); | 233 uint8_t *data = av_malloc (4*W*H); |
224 uint8_t *src[4]= {data, data+W*H, data+W*H*2, data+W*H*3}; | 234 uint8_t *src[4]= {data, data+W*H, data+W*H*2, data+W*H*3}; |
225 int stride[4]={W, W, W, W}; | 235 int stride[4]={W, W, W, W}; |
226 int x, y; | 236 int x, y; |
227 struct SwsContext *sws; | 237 struct SwsContext *sws; |
228 enum PixelFormat srcFmt, dstFmt; | |
229 AVLFG rand; | 238 AVLFG rand; |
230 | 239 |
231 av_log_set_level(AV_LOG_INFO); | |
232 | |
233 if (argc < 3) { | |
234 fprintf(stderr, "Usage: swscale-test SRC_PIX_FMT DST_PIX_FMT\n"); | |
235 return -1; | |
236 } | |
237 if ((srcFmt = av_get_pix_fmt(argv[1])) == PIX_FMT_NONE) { | |
238 fprintf(stderr, "Unknown pixel input format name: '%s'\n", argv[1]); | |
239 return -1; | |
240 } | |
241 if ((dstFmt = av_get_pix_fmt(argv[2])) == PIX_FMT_NONE) { | |
242 fprintf(stderr, "Unknown pixel output format name: '%s'\n", argv[2]); | |
243 return -1; | |
244 } | |
245 if (!rgb_data || !data) | 240 if (!rgb_data || !data) |
246 return -1; | 241 return -1; |
247 | 242 |
248 sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUVA420P, | 243 sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL); |
249 SWS_BILINEAR|SWS_PRINT_INFO, NULL, NULL, NULL); | |
250 | 244 |
251 av_lfg_init(&rand, 1); | 245 av_lfg_init(&rand, 1); |
252 | 246 |
253 for (y=0; y<H; y++) { | 247 for (y=0; y<H; y++) { |
254 for (x=0; x<W*4; x++) { | 248 for (x=0; x<W*4; x++) { |
257 } | 251 } |
258 sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride); | 252 sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride); |
259 sws_freeContext(sws); | 253 sws_freeContext(sws); |
260 av_free(rgb_data); | 254 av_free(rgb_data); |
261 | 255 |
262 selfTest(src, stride, srcFmt, dstFmt, W, H); | 256 selfTest(src, stride, W, H); |
263 av_free(data); | 257 av_free(data); |
264 | 258 |
265 return 0; | 259 return 0; |
266 } | 260 } |