Revision 9b4bf9c2

View differences:

libswscale/swscale-test.c
242 242
    return res;
243 243
}
244 244

  
245
static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h)
245
static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h,
246
                     enum PixelFormat srcFormat_in,
247
                     enum PixelFormat dstFormat_in)
246 248
{
247 249
    const int flags[] = { SWS_FAST_BILINEAR,
248 250
                          SWS_BILINEAR, SWS_BICUBIC,
......
253 255
    const int dstH[] = { srcH - srcH/3, srcH, srcH + srcH/3, 0 };
254 256
    enum PixelFormat srcFormat, dstFormat;
255 257

  
256
    for (srcFormat = 0; srcFormat < PIX_FMT_NB; srcFormat++) {
258
    for (srcFormat = srcFormat_in != PIX_FMT_NONE ? srcFormat_in : 0;
259
         srcFormat < PIX_FMT_NB; srcFormat++) {
257 260
        if (!sws_isSupportedInput(srcFormat) || !sws_isSupportedOutput(srcFormat))
258 261
            continue;
259 262

  
260
        for (dstFormat = 0; dstFormat < PIX_FMT_NB; dstFormat++) {
263
        for (dstFormat = dstFormat_in != PIX_FMT_NONE ? dstFormat_in : 0;
264
             dstFormat < PIX_FMT_NB; dstFormat++) {
261 265
            int i, j, k;
262 266
            int res = 0;
263 267

  
......
277 281
                                     srcW, srcH, dstW[i], dstH[j], flags[k],
278 282
                                     NULL);
279 283
            }
284
            if (dstFormat_in != PIX_FMT_NONE)
285
                break;
280 286
        }
287
        if (srcFormat_in != PIX_FMT_NONE)
288
            break;
281 289
    }
282 290
}
283 291

  
284
static int fileTest(uint8_t *ref[4], int refStride[4], int w, int h, FILE *fp)
292
static int fileTest(uint8_t *ref[4], int refStride[4], int w, int h, FILE *fp,
293
                     enum PixelFormat srcFormat_in,
294
                     enum PixelFormat dstFormat_in)
285 295
{
286 296
    char buf[256];
287 297

  
......
312 322
            fprintf(stderr, "malformed input file\n");
313 323
            return -1;
314 324
        }
325
        if ((srcFormat_in != PIX_FMT_NONE && srcFormat_in != srcFormat) ||
326
            (dstFormat_in != PIX_FMT_NONE && dstFormat_in != dstFormat))
327
            continue;
315 328
        if (ret != 12) {
316 329
            printf("%s", buf);
317 330
            continue;
......
331 344

  
332 345
int main(int argc, char **argv)
333 346
{
347
    enum PixelFormat srcFormat = PIX_FMT_NONE;
348
    enum PixelFormat dstFormat = PIX_FMT_NONE;
334 349
    uint8_t *rgb_data = av_malloc (W*H*4);
335 350
    uint8_t *rgb_src[3]= {rgb_data, NULL, NULL};
336 351
    int rgb_stride[3]={4*W, 0, 0};
......
368 383
                fprintf(stderr, "could not open '%s'\n", argv[i+1]);
369 384
                goto error;
370 385
            }
371
            res = fileTest(src, stride, W, H, fp);
386
            res = fileTest(src, stride, W, H, fp, srcFormat, dstFormat);
372 387
            fclose(fp);
373 388
            goto end;
389
        } else if (!strcmp(argv[i], "-src")) {
390
            srcFormat = av_get_pix_fmt(argv[i+1]);
391
            if (srcFormat == PIX_FMT_NONE) {
392
                fprintf(stderr, "invalid pixel format %s\n", argv[i+1]);
393
                return -1;
394
            }
395
        } else if (!strcmp(argv[i], "-dst")) {
396
            dstFormat = av_get_pix_fmt(argv[i+1]);
397
            if (dstFormat == PIX_FMT_NONE) {
398
                fprintf(stderr, "invalid pixel format %s\n", argv[i+1]);
399
                return -1;
400
            }
374 401
        } else {
375 402
bad_option:
376 403
            fprintf(stderr, "bad option or argument missing (%s)\n", argv[i]);
......
378 405
        }
379 406
    }
380 407

  
381
    selfTest(src, stride, W, H);
408
    selfTest(src, stride, W, H, srcFormat, dstFormat);
382 409
end:
383 410
    res = 0;
384 411
error:

Also available in: Unified diff