]> git.sesse.net Git - ffmpeg/blobdiff - libswscale/cs_test.c
av_logify
[ffmpeg] / libswscale / cs_test.c
index b1963f92f62a42f4ac173e2e3185762e506d266b..65b1de20b73455894f4f484d0aba5ab16197317d 100644 (file)
@@ -1,28 +1,32 @@
 /*
-    Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
 
 #include <stdio.h>
+#include <string.h>              /* for memset() */
+#include <unistd.h>
 #include <stdlib.h>
 #include <inttypes.h>
+#include <malloc.h>
 
 #include "swscale.h"
 #include "rgb2rgb.h"
-#include "cpudetect.h"
 
 #define SIZE 1000
 #define srcByte 0x55
 #define memalign(x,y) malloc(y)
 #endif
 
-static int get_sws_cpuflags()
+static int cpu_caps;
+
+static char *args_parse(int argc, char *argv[])
 {
-    return (gCpuCaps.hasMMX ? SWS_CPU_CAPS_MMX : 0) |
-       (gCpuCaps.hasMMX2 ? SWS_CPU_CAPS_MMX2 : 0) |
-       (gCpuCaps.has3DNow ? SWS_CPU_CAPS_3DNOW : 0);
+    int o;
+
+    while ((o = getopt(argc, argv, "m23")) != -1) {
+        switch (o) {
+            case 'm':
+                cpu_caps |= SWS_CPU_CAPS_MMX;
+                break;
+            case '2':
+                cpu_caps |= SWS_CPU_CAPS_MMX2;
+                break;
+            case '3':
+                cpu_caps |= SWS_CPU_CAPS_3DNOW;
+                break;
+            default:
+                av_log(NULL, AV_LOG_ERROR, "Unknown option %c\n", o);
+        }
+    }
+
+    return argv[optind];
 }
 
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
        int i, funcNum;
        uint8_t *srcBuffer= (uint8_t*)memalign(128, SIZE);
@@ -47,14 +69,10 @@ main(int argc, char **argv)
        int failedNum=0;
        int passedNum=0;
        
-       printf("memory corruption test ...\n");
-       
-       if(argc==2){
-               GetCpuCaps(&gCpuCaps);
-               printf("testing mmx\n");
-       }
-       
-       sws_rgb2rgb_init(get_sws_cpuflags());
+       av_log(NULL, AV_LOG_INFO, "memory corruption test ...\n");
+       args_parse(argc, argv);
+       av_log(NULL, AV_LOG_INFO, "CPU capabilities forced to %x\n", cpu_caps);
+       sws_rgb2rgb_init(cpu_caps);
        
        for(funcNum=0; funcNum<100; funcNum++){
                int width;
@@ -62,7 +80,7 @@ main(int argc, char **argv)
                int srcBpp=0;
                int dstBpp=0;
 
-               printf("."); fflush(stdout);
+               av_log(NULL, AV_LOG_INFO,"."); fflush(stdout);
                memset(srcBuffer, srcByte, SIZE);
 
                for(width=32; width<64; width++){
@@ -131,6 +149,7 @@ main(int argc, char **argv)
                                                srcBpp=4;
                                                dstBpp=2;
                                                name="rgb32to15";
+                        //((*s++) << TGA_SHIFT32) | TGA_ALPHA32;
                                                rgb32to15(src, dst, width*srcBpp);
                                                break;
                                        case 9:
@@ -254,7 +273,7 @@ main(int argc, char **argv)
 
                                        for(i=0; i<SIZE; i++){
                                                if(srcBuffer[i]!=srcByte){
-                                                       printf("src damaged at %d w:%d src:%d dst:%d %s\n", 
+                                                       av_log(NULL, AV_LOG_INFO, "src damaged at %d w:%d src:%d dst:%d %s\n", 
                                                                i, width, srcOffset, dstOffset, name);
                                                        failed=1;
                                                        break;
@@ -262,7 +281,7 @@ main(int argc, char **argv)
                                        }
                                        for(i=0; i<dstOffset; i++){
                                                if(dstBuffer[i]!=dstByte){
-                                                       printf("dst damaged at %d w:%d src:%d dst:%d %s\n", 
+                                                       av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", 
                                                                i, width, srcOffset, dstOffset, name);
                                                        failed=1;
                                                        break;
@@ -270,7 +289,7 @@ main(int argc, char **argv)
                                        }
                                        for(i=dstOffset + width*dstBpp; i<SIZE; i++){
                                                if(dstBuffer[i]!=dstByte){
-                                                       printf("dst damaged at %d w:%d src:%d dst:%d %s\n", 
+                                                       av_log(NULL, AV_LOG_INFO, "dst damaged at %d w:%d src:%d dst:%d %s\n", 
                                                                i, width, srcOffset, dstOffset, name);
                                                        failed=1;
                                                        break;
@@ -283,6 +302,6 @@ main(int argc, char **argv)
                else if(srcBpp) passedNum++;
        }
        
-       printf("%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum);
+       av_log(NULL, AV_LOG_INFO, "%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum);
        return failedNum;
 }