diff options
author | Ramiro Polla <ramiro.polla@gmail.com> | 2010-09-12 18:14:42 +0000 |
---|---|---|
committer | Ramiro Polla <ramiro.polla@gmail.com> | 2010-09-12 18:14:42 +0000 |
commit | 3e1e78008bce7a1b3e66014f66e423fb6a765304 (patch) | |
tree | d804365dae2c3f20d1480fb568504ce2b4cff7a6 /libswscale/swscale-test.c | |
parent | a51125b52f5e23673782a421cb219b55933f4cec (diff) | |
download | ffmpeg-3e1e78008bce7a1b3e66014f66e423fb6a765304.tar.gz |
swscale-test: move conversion from ref to source back to doTest()
The source format parameters are kept in static variables and conversion from
ref to source is only made when any parameter changes.
Originally committed as revision 32211 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
Diffstat (limited to 'libswscale/swscale-test.c')
-rw-r--r-- | libswscale/swscale-test.c | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c index 09ccdb33d3..ec38ab0646 100644 --- a/libswscale/swscale-test.c +++ b/libswscale/swscale-test.c @@ -74,10 +74,13 @@ static uint64_t getSSD(uint8_t *src1, uint8_t *src2, int stride1, int stride2, i // test by ref -> src -> dst -> out & compare out against ref // ref & out are YV12 static int doTest(uint8_t *ref[4], int refStride[4], int w, int h, - uint8_t *src[4], int srcStride[4], enum PixelFormat srcFormat, enum PixelFormat dstFormat, int srcW, int srcH, int dstW, int dstH, int flags) { + static enum PixelFormat cur_srcFormat; + static int cur_srcW, cur_srcH, cur_flags; + static uint8_t *src[4]; + static int srcStride[4]; uint8_t *dst[4] = {0}; uint8_t *out[4] = {0}; int dstStride[4]; @@ -87,6 +90,44 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h, uint32_t crc = 0; int res = 0; + if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH || cur_flags != flags) { + struct SwsContext *srcContext = NULL; + int p; + + for (p = 0; p < 4; p++) + if (src[p]) + av_freep(&src[p]); + + av_image_fill_linesizes(srcStride, srcFormat, srcW); + for (p = 0; p < 4; p++) { + if (srcStride[p]) + src[p] = av_mallocz(srcStride[p]*srcH+16); + if (srcStride[p] && !src[p]) { + perror("Malloc"); + res = -1; + + goto end; + } + } + srcContext = sws_getContext(w, h, PIX_FMT_YUVA420P, srcW, srcH, + srcFormat, flags, NULL, NULL, NULL); + if (!srcContext) { + fprintf(stderr, "Failed to get %s ---> %s\n", + av_pix_fmt_descriptors[PIX_FMT_YUVA420P].name, + av_pix_fmt_descriptors[srcFormat].name); + res = -1; + + goto end; + } + sws_scale(srcContext, ref, refStride, 0, h, src, srcStride); + sws_freeContext(srcContext); + + cur_srcFormat = srcFormat; + cur_srcW = srcW; + cur_srcH = srcH; + cur_flags = flags; + } + av_image_fill_linesizes(dstStride, dstFormat, dstW); for (i=0; i<4; i++) { /* Image buffers passed into libswscale can be allocated any way you @@ -201,39 +242,11 @@ static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h) fflush(stdout); for (k = 0; flags[k] && !res; k++) { - struct SwsContext *srcContext = NULL; - uint8_t *src[4] = {0}; - int srcStride[4]; - int p; - av_image_fill_linesizes(srcStride, srcFormat, srcW); - for (p = 0; p < 4; p++) { - if (srcStride[p]) - src[p] = av_mallocz(srcStride[p]*srcH+16); - if (srcStride[p] && !src[p]) { - perror("Malloc"); - return; - } - } - srcContext = sws_getContext(w, h, PIX_FMT_YUVA420P, srcW, srcH, - srcFormat, flags[k], NULL, NULL, NULL); - if (!srcContext) { - fprintf(stderr, "Failed to get %s ---> %s\n", - av_pix_fmt_descriptors[PIX_FMT_YUVA420P].name, - av_pix_fmt_descriptors[srcFormat].name); - return; - } - sws_scale(srcContext, ref, refStride, 0, h, src, srcStride); - for (i = 0; dstW[i] && !res; i++) for (j = 0; dstH[j] && !res; j++) - res = doTest(ref, refStride, w, h, src, srcStride, + res = doTest(ref, refStride, w, h, srcFormat, dstFormat, srcW, srcH, dstW[i], dstH[j], flags[k]); - - sws_freeContext(srcContext); - for (p = 0; p < 4; p++) - if (srcStride[p]) - av_free(src[p]); } } } |