swscale-test: get strides using av_fill_image_linesizes() from libavcore
Originally committed as revision 31948 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
This commit is contained in:
		
							parent
							
								
									7d07d6f529
								
							
						
					
					
						commit
						06c93cb705
					
				@ -20,3 +20,4 @@ TESTPROGS = colorspace swscale
 | 
				
			|||||||
DIRS = bfin mlib ppc sparc x86
 | 
					DIRS = bfin mlib ppc sparc x86
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include $(SUBDIR)../subdir.mak
 | 
					include $(SUBDIR)../subdir.mak
 | 
				
			||||||
 | 
					$(SUBDIR)swscale-test$(EXESUF): ELIBS = -lavcore
 | 
				
			||||||
 | 
				
			|||||||
@ -25,6 +25,7 @@
 | 
				
			|||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef HAVE_AV_CONFIG_H
 | 
					#undef HAVE_AV_CONFIG_H
 | 
				
			||||||
 | 
					#include "libavcore/imgutils.h"
 | 
				
			||||||
#include "libavutil/mem.h"
 | 
					#include "libavutil/mem.h"
 | 
				
			||||||
#include "libavutil/avutil.h"
 | 
					#include "libavutil/avutil.h"
 | 
				
			||||||
#include "libavutil/pixdesc.h"
 | 
					#include "libavutil/pixdesc.h"
 | 
				
			||||||
@ -84,24 +85,19 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
 | 
				
			|||||||
    struct SwsContext *dstContext = NULL, *outContext = NULL;
 | 
					    struct SwsContext *dstContext = NULL, *outContext = NULL;
 | 
				
			||||||
    int res = 0;
 | 
					    int res = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    av_fill_image_linesizes(dstStride, dstFormat, dstW);
 | 
				
			||||||
    for (i=0; i<4; i++) {
 | 
					    for (i=0; i<4; i++) {
 | 
				
			||||||
        // avoid stride % bpp != 0
 | 
					 | 
				
			||||||
        if (dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24)
 | 
					 | 
				
			||||||
            dstStride[i]= dstW*3;
 | 
					 | 
				
			||||||
        else if (dstFormat==PIX_FMT_RGB48BE || dstFormat==PIX_FMT_RGB48LE)
 | 
					 | 
				
			||||||
            dstStride[i]= dstW*6;
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
            dstStride[i]= dstW*4;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /* Image buffers passed into libswscale can be allocated any way you
 | 
					        /* Image buffers passed into libswscale can be allocated any way you
 | 
				
			||||||
         * prefer, as long as they're aligned enough for the architecture, and
 | 
					         * prefer, as long as they're aligned enough for the architecture, and
 | 
				
			||||||
         * they're freed appropriately (such as using av_free for buffers
 | 
					         * they're freed appropriately (such as using av_free for buffers
 | 
				
			||||||
         * allocated with av_malloc). */
 | 
					         * allocated with av_malloc). */
 | 
				
			||||||
        /* An extra 16 bytes is being allocated because some scalers may write
 | 
					        /* An extra 16 bytes is being allocated because some scalers may write
 | 
				
			||||||
         * out of bounds. */
 | 
					         * out of bounds. */
 | 
				
			||||||
 | 
					        if (dstStride[i])
 | 
				
			||||||
        dst[i]= av_mallocz(dstStride[i]*dstH+16);
 | 
					        dst[i]= av_mallocz(dstStride[i]*dstH+16);
 | 
				
			||||||
 | 
					        if (refStride[i])
 | 
				
			||||||
        out[i]= av_mallocz(refStride[i]*h);
 | 
					        out[i]= av_mallocz(refStride[i]*h);
 | 
				
			||||||
        if (!dst[i] || !out[i]) {
 | 
					        if ((dstStride[i] && !dst[i]) || (refStride[i] && !out[i])) {
 | 
				
			||||||
            perror("Malloc");
 | 
					            perror("Malloc");
 | 
				
			||||||
            res = -1;
 | 
					            res = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -162,7 +158,9 @@ end:
 | 
				
			|||||||
    sws_freeContext(outContext);
 | 
					    sws_freeContext(outContext);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (i=0; i<4; i++) {
 | 
					    for (i=0; i<4; i++) {
 | 
				
			||||||
 | 
					        if (dstStride[i])
 | 
				
			||||||
        av_free(dst[i]);
 | 
					        av_free(dst[i]);
 | 
				
			||||||
 | 
					        if (refStride[i])
 | 
				
			||||||
        av_free(out[i]);
 | 
					        av_free(out[i]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -201,17 +199,11 @@ static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h)
 | 
				
			|||||||
                uint8_t *src[4] = {0};
 | 
					                uint8_t *src[4] = {0};
 | 
				
			||||||
                int srcStride[4];
 | 
					                int srcStride[4];
 | 
				
			||||||
                int p;
 | 
					                int p;
 | 
				
			||||||
 | 
					                av_fill_image_linesizes(srcStride, srcFormat, srcW);
 | 
				
			||||||
                for (p = 0; p < 4; p++) {
 | 
					                for (p = 0; p < 4; p++) {
 | 
				
			||||||
                    if (srcFormat == PIX_FMT_RGB24 ||
 | 
					                    if (srcStride[p])
 | 
				
			||||||
                        srcFormat == PIX_FMT_BGR24)
 | 
					 | 
				
			||||||
                        srcStride[p] = srcW*3;
 | 
					 | 
				
			||||||
                    else if (srcFormat==PIX_FMT_RGB48BE ||
 | 
					 | 
				
			||||||
                             srcFormat==PIX_FMT_RGB48LE)
 | 
					 | 
				
			||||||
                        srcStride[p] = srcW*6;
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                        srcStride[p] = srcW*4;
 | 
					 | 
				
			||||||
                    src[p] = av_mallocz(srcStride[p]*srcH+16);
 | 
					                    src[p] = av_mallocz(srcStride[p]*srcH+16);
 | 
				
			||||||
                    if (!src[p]) {
 | 
					                    if (srcStride[p] && !src[p]) {
 | 
				
			||||||
                        perror("Malloc");
 | 
					                        perror("Malloc");
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
@ -234,6 +226,7 @@ static void selfTest(uint8_t *ref[4], int refStride[4], int w, int h)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                sws_freeContext(srcContext);
 | 
					                sws_freeContext(srcContext);
 | 
				
			||||||
                for (p = 0; p < 4; p++)
 | 
					                for (p = 0; p < 4; p++)
 | 
				
			||||||
 | 
					                    if (srcStride[p])
 | 
				
			||||||
                    av_free(src[p]);
 | 
					                    av_free(src[p]);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user