comparison libswscale/swscale-test.c @ 30783:1bd54aea2896

Make swscale-test take in input the name of the input and the output format. Make swscale-test only perform the test from the input to the output format rather than perform all. Also implement swscale-test-all.sh, for performing all the tests. Improve flexibility of the swscale-test tool, this way is simpler to perform only a subset of tests.
author stefano
date Thu, 04 Mar 2010 00:31:10 +0000
parents 3f9c8b7320a2
children 2c9cfd354ca0
comparison
equal deleted inserted replaced
30782:1c38d10731ab 30783:1bd54aea2896
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"
28 #include "libavutil/mem.h" 30 #include "libavutil/mem.h"
29 #include "libavutil/avutil.h" 31 #include "libavutil/avutil.h"
30 #include "libavutil/lfg.h" 32 #include "libavutil/lfg.h"
33 #include "libavutil/pixdesc.h"
31 #include "swscale.h" 34 #include "swscale.h"
32 35
33 /* HACK Duplicated from swscale_internal.h. 36 /* HACK Duplicated from swscale_internal.h.
34 * Should be removed when a cleaner pixel format system exists. */ 37 * Should be removed when a cleaner pixel format system exists. */
35 const char *sws_format_name(enum PixelFormat format); 38 const char *sws_format_name(enum PixelFormat format);
184 } 187 }
185 188
186 return res; 189 return res;
187 } 190 }
188 191
189 static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h) 192 static void selfTest(uint8_t *ref[4], int refStride[4], enum PixelFormat srcFormat, enum PixelFormat dstFormat, int w, int h)
190 { 193 {
191 const int flags[] = { SWS_FAST_BILINEAR, 194 const int flags[] = { SWS_FAST_BILINEAR,
192 SWS_BILINEAR, SWS_BICUBIC, 195 SWS_BILINEAR, SWS_BICUBIC,
193 SWS_X , SWS_POINT , SWS_AREA, 0 }; 196 SWS_X , SWS_POINT , SWS_AREA, 0 };
194 const int srcW = w; 197 const int srcW = w;
195 const int srcH = h; 198 const int srcH = h;
199 int i, j, k, res = 0;
196 const int dstW[] = { srcW - srcW/3, srcW, srcW + srcW/3, 0 }; 200 const int dstW[] = { srcW - srcW/3, srcW, srcW + srcW/3, 0 };
197 const int dstH[] = { srcH - srcH/3, srcH, srcH + srcH/3, 0 }; 201 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;
210 202
211 printf("%s -> %s\n", 203 printf("%s -> %s\n",
212 sws_format_name(srcFormat), 204 sws_format_name(srcFormat),
213 sws_format_name(dstFormat)); 205 sws_format_name(dstFormat));
214 fflush(stdout); 206 fflush(stdout);
215 207
216 for (i = 0; dstW[i] && !res; i++) 208 for (i = 0; dstW[i] && !res; i++)
217 for (j = 0; dstH[j] && !res; j++) 209 for (j = 0; dstH[j] && !res; j++)
218 for (k = 0; flags[k] && !res; k++) 210 for (k = 0; flags[k] && !res; k++)
219 res = doTest(ref, refStride, w, h, srcFormat, dstFormat, 211 res = doTest(ref, refStride, w, h, srcFormat, dstFormat,
220 srcW, srcH, dstW[i], dstH[j], flags[k]); 212 srcW, srcH, dstW[i], dstH[j], flags[k]|SWS_PRINT_INFO);
221 }
222 }
223 } 213 }
224 214
225 #define W 96 215 #define W 96
226 #define H 96 216 #define H 96
227 217
233 uint8_t *data = av_malloc (4*W*H); 223 uint8_t *data = av_malloc (4*W*H);
234 uint8_t *src[4]= {data, data+W*H, data+W*H*2, data+W*H*3}; 224 uint8_t *src[4]= {data, data+W*H, data+W*H*2, data+W*H*3};
235 int stride[4]={W, W, W, W}; 225 int stride[4]={W, W, W, W};
236 int x, y; 226 int x, y;
237 struct SwsContext *sws; 227 struct SwsContext *sws;
228 enum PixelFormat srcFmt, dstFmt;
238 AVLFG rand; 229 AVLFG rand;
239 230
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 }
240 if (!rgb_data || !data) 245 if (!rgb_data || !data)
241 return -1; 246 return -1;
242 247
243 sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL); 248 sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUVA420P,
249 SWS_BILINEAR|SWS_PRINT_INFO, NULL, NULL, NULL);
244 250
245 av_lfg_init(&rand, 1); 251 av_lfg_init(&rand, 1);
246 252
247 for (y=0; y<H; y++) { 253 for (y=0; y<H; y++) {
248 for (x=0; x<W*4; x++) { 254 for (x=0; x<W*4; x++) {
251 } 257 }
252 sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride); 258 sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride);
253 sws_freeContext(sws); 259 sws_freeContext(sws);
254 av_free(rgb_data); 260 av_free(rgb_data);
255 261
256 selfTest(src, stride, W, H); 262 selfTest(src, stride, srcFmt, dstFmt, W, H);
257 av_free(data); 263 av_free(data);
258 264
259 return 0; 265 return 0;
260 } 266 }